Recent

Author Topic: Stopping a program  (Read 2579 times)

zz28zz

  • New Member
  • *
  • Posts: 23
Re: Stopping a program
« Reply #30 on: June 22, 2019, 09:18:17 pm »
Tags?? Is that the line numbers?

Can I change this If BI_Result(False)>0 Then  to read If BI_Result(True)>0 Then ,, Save it, compile it and run?

OR Is the true/false entered by code that has been run already?






zz28zz

  • New Member
  • *
  • Posts: 23
Re: Stopping a program
« Reply #31 on: June 22, 2019, 09:46:44 pm »

However, I think you need to be in a true DOS environment with Dos debugging tools because
I suspect the code is using Port or ASM to read/ write to the cards and unless you have some
port drivers installed the debugging using Laz in windows isn't going to work out to well because
you can't access any of those devices so the error will always be there.

 Do you have port drivers for those cards that allows you to run that code in a non true DOS
environment?

I'm doing the code editing, compiling and testing on the DOS computer that runs the tester.

jamie

  • Hero Member
  • *****
  • Posts: 2068
Re: Stopping a program
« Reply #32 on: June 22, 2019, 10:43:01 pm »
obviously there is a problem brewing and I suspect you are trying to keep the app form terminating
if there is one device that isn't working properly...

 The section where the error message is generated can be altered to ether write to a log file and
move on or have some sort of scrolling window ..

  If you are getting errors on all devices then I suspect that you have some sort of interface
issue, for example a port driver being used to talk to the cards.
Number 1 at blue screen app creations!

zz28zz

  • New Member
  • *
  • Posts: 23
Re: Stopping a program
« Reply #33 on: June 23, 2019, 02:09:13 am »
Tester is fine until I add the oddball module. Setup screen has to be modified so the s/w knows to look for the oddball module during init. The s/w appears to think the oddball module is in an error state and with the Boolean set to false it isn't trying to clear the error state. The s/w will continue if you hit ENTER on the error message screen and completes initialization but pops up a window saying the oddball module did not init properly and may need repair.
 
I'm thinking I need to figure out what is placing it in a error state to begin with. This is what the old eng was saying abt modifying the code so the s/w would pause at predetermined points during initialization and report module error state status.

When you say the section where the error message can be altered to generate a log file, what info is gathered for the log file? How is the code altered?

BTW, I looked and found Turbo Debugger installed on the tester PC. I loaded the init.exe file and ran it but it just says "Terminated. Exit code 0". Not sure what that's supposed to tell me.


jamie

  • Hero Member
  • *****
  • Posts: 2068
Re: Stopping a program
« Reply #34 on: June 23, 2019, 02:21:58 am »
It means the app didn't exit abnormally.

EXIT code 0... Normal Exit.

The app isn't crashing, its the debugging test functions it has in there..

 You need to dig backwards in the program to see where the values are set.,.

Not knowing what you are using I guess to say they are IO cards in PCI slots where you
can read/write Bits data for output or input signals and maybe even do Analog in/out.
Number 1 at blue screen app creations!

trev

  • Full Member
  • ***
  • Posts: 220
  • Former Delphi 7 and Delphi 10.2 User
Re: Stopping a program
« Reply #35 on: June 23, 2019, 06:49:06 am »
You keep referring to the "oddball module" as the cause of the issue. Perhaps you need to debug that rather than the rest of the tester program. (Assuming I understand what you describe.)
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

Noodly

  • Jr. Member
  • **
  • Posts: 70
Re: Stopping a program
« Reply #36 on: June 23, 2019, 08:54:48 am »
Turbo debugger is the best answer if you can get that going. It's a very long time since I used it but the basic steps are to compile the BP program with debugging on and then step through the code. You will have to experiment a bit with where you put your breakpoints, especially if interrupts are being used.

I would guess that either the original programmer didn't test the oddball module or it's faulty. If you need to modify the program to deal with the oddball module properly I would uninstall it and debug one two standard modules to get a feel for the original programmer's approach.
Windows 10 Home, Lazarus 2.02 (svn 60954), FPC 3.04

lucamar

  • Hero Member
  • *****
  • Posts: 2075
Re: Stopping a program
« Reply #37 on: June 23, 2019, 03:47:15 pm »
Turbo debugger is the best answer if you can get that going.

TD is worse than useless unless the program was compiled with debug info for it. Since the OP is trying to modify/debug a BP program one may infer that there is a copy of Turbo/Borland Pascal installed in the machine? If so, it's much easier to debug in the IDE than with TD.

I'm (was?) a big fan of Turbo Debugger ... but in its proper place. Of course, if all you have is a hammer ... :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

Noodly

  • Jr. Member
  • **
  • Posts: 70
Re: Stopping a program
« Reply #38 on: June 23, 2019, 08:01:01 pm »
Turbo debugger is the best answer if you can get that going.

TD is worse than useless unless the program was compiled with debug info for it. Since the OP is trying to modify/debug a BP program one may infer that there is a copy of Turbo/Borland Pascal installed in the machine? If so, it's much easier to debug in the IDE than with TD.

I'm (was?) a big fan of Turbo Debugger ... but in its proper place. Of course, if all you have is a hammer ... :)

The opening poster states that both BP and TD are installed on the test machine. Back in the day I found TD a better tool for debugging programs that interface with external hardware.
Windows 10 Home, Lazarus 2.02 (svn 60954), FPC 3.04

jamie

  • Hero Member
  • *****
  • Posts: 2068
Re: Stopping a program
« Reply #39 on: June 23, 2019, 08:21:57 pm »
if you use BP IDE the debugger works in it.

or you can use the TD directly and single step the code in ASM land.

But the problem is that you need to know what you are looking at for this operation.
Number 1 at blue screen app creations!

lucamar

  • Hero Member
  • *****
  • Posts: 2075
Re: Stopping a program
« Reply #40 on: June 23, 2019, 08:44:44 pm »
or you can use the TD directly and single step the code in ASM land.

TD was one of the few debuggers with which you could do source-level debugging (if the program was compiled for it), so no need for the (frequently futile) "step-into-asm-land" games.

But then, you could already do that (and better) with the integrated debugger, so Turbo Debugger was--for me--a kind of "last resource weapon". And a very good one, in fact, to debug long assembler programs :)

Returning to the thread's subject ... here is how you set a breakpoint in your code (attached image):
  • Go to the line in which you wish to stop
  • Select the menu "Debug -> Add breakpoint
  • Done!

For run-testing, you can add a Write or WriteLn before that same line, or after, or both.

The real problem, as jamie said, is to guess just where you want to look.

When looking for an external error, you should find where in the code that error is being generated. Pausing (or logging) on  lines that deal with it much later is of little use.

In your case, there is probably some place where something is being sent/queried to/from each module. There is where you should concentrate your debugg¡ng efforts: Try to see exactly what is being sent and received and compare it with what the hardware specs say should be. Maybe you're forgetting to set/reset some bit? Skipping some step that must be done? Sending the wrong command or in the wrong order?

That's where I would start. YMMV, of course :-\
« Last Edit: June 23, 2019, 09:00:54 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

zz28zz

  • New Member
  • *
  • Posts: 23
Re: Stopping a program
« Reply #41 on: June 25, 2019, 05:08:14 am »
Back to digging thru the source code I found a procedure called STATUS.

I'd like to try inserting it in the init.pas code.

This is what I found:

Code: Pascal  [Select]
  1.  
  2. (*_________________________________________________________
  3. | PROCEDURE : Status
  4. | VERSION   : x.xx
  5. | DATE      : xxxxxxxx xx, xxxx
  6. |..........................................................
  7. | DEFINITION/NOTES:
  8. |   Graphically displays Device and connection status.
  9. |   Status removes any function key handler.  The calling
  10. |   program must restore its function key handler upon
  11. |   returning from Status.
  12. |
  13. |   DisplayAction Values :
  14. |    Status_NoRestore = 0 : xxxxxxx0 - do not restore
  15. |                           previous screen upon exit.
  16. |    Status_Restore   = 1 : xxxxxxx1 - restore previous
  17. |                           screen upon exit.
  18. |    Status_Screen    = 2 : xxxxxx1x - display status on
  19. |                           on screen.
  20. |    Status_NB        = 4 : xxxxx1xx - don't wait for
  21. |                           keycodes to exit
  22. |    Status_Hookup    = 8 : xxxx1xxx - called from hookup
  23. |                           so display even if HVP.
  24. |_________________________________________________________*)
  25.  
  26.  

Status_Restore is the option I want but not sure how to insert it in the init.pas file.

I tried inserting the following inside an existing procedure. It didn't like that.

Status_Restore;
Status_Restore=1;
Status _Restore = 1;

Then I tried making my own Procedure like this:

Procedure Status
begin
Status_Restore
end;


It errors during compile: "Error 113 Error in statement" and points to "Status_Restore" line.




« Last Edit: June 25, 2019, 05:51:34 am by zz28zz »

lucamar

  • Hero Member
  • *****
  • Posts: 2075
Re: Stopping a program
« Reply #42 on: June 25, 2019, 05:34:06 am »
What is the Status declaration?

If, as seems probable, is something like:

Code: Pascal  [Select]
  1. procedure Status(DisplayAction: Byte);

then all you need to do is call it like:
Code: Pascal  [Select]
  1.   {... some code ...}
  2.   Status(1);
  3.  {or maybe: Status(Status_Restore);}
  4.   {... some more code ...}

But take good notice of the warning about "function key handler"!

By the way, please surround the posted code with [code] tags to make your posts more readable. See here:Forum - Use code tags
« Last Edit: June 25, 2019, 05:41:00 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

zz28zz

  • New Member
  • *
  • Posts: 23
Re: Stopping a program
« Reply #43 on: June 25, 2019, 06:19:47 am »
Thx for telling me what the tags thing is. I edited my prev post so it now has tags.

Not sure what a Status declaration is but there's a line that looks exactly like what you typed just below where I copied the prev info from. ( I didn't include it).

I inserted "Status(1);" in a previously existing procedure that displays an on-screen warning message abt high voltage before starting init. It compiled OK.
Thought I might need to type in  "procedure Status(DisplayAction: Byte);" somewhere but maybe not..

Won't know if it works until I get back in front of the tester. thx!