debugger watchpoints - how?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

debugger watchpoints - how?

Post by bluebird »

Dear Mentors

I frequently use the debugger breakpoint, evaluate etc, but I have not figured out how to use watchpoint or tracepoint.
How do you set up a list of points to watch?

Secondly, the DOC file saves that you can change the values of variables while running degug. Kindly explain how.

SIncere thanks
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: debugger watchpoints - how?

Post by mol »

You can assign new value in this way
YourVariable:=NewValue
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: debugger watchpoints - how?

Post by esgici »

bluebird wrote: Tue Sep 19, 2017 3:59 pm Dear Mentors

I frequently use the debugger breakpoint, evaluate etc, but I have not figured out how to use watchpoint or tracepoint.
How do you set up a list of points to watch?

Secondly, the DOC file saves that you can change the values of variables while running degug. Kindly explain how.

SIncere thanks
My best tracing points of watch tool is MsgDebug() function ;)

Saving changed values of variables to a file (not .doc but .txt file) is something like this:

Before beginning of (for example) traversing records of data file(s)

SET ALTERNATE TO <my trace file>
SET ALTERNATE ON

inside of loop :

? <myVariable>

after loop:

SET ALTERNATE TO
SET ALTERNATE OFF



That is all for me 8-)

Happy HMG'ing :D
Last edited by esgici on Tue Oct 03, 2017 8:41 am, edited 1 time in total.
Viva INTERNATIONAL HMG :D
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: debugger watchpoints - how?

Post by bluebird »

Thanks for the reply Mr. Esqici

Still, i would like to know how to use the debug utility
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: debugger watchpoints - how?

Post by Rathinagiri »

My sample test code: main.prg

Code: Select all

#include <hmg.ch>

Function Main
   public nVar1 := 0
   define window main at 0, 0 width 400 height 300 main
      define button count
         row 10
         col 10
         caption 'Click me!'
         action clicked()
      end button   
   end window
   main.center
   main.activate
Return


function clicked
   for i := 1 to 100
   next i
   nVar1 := 1000
   msginfo( 'Counting over' )
return nil
in debug.hbp

Code: Select all

main.prg
Open IDE and open debug.hpb project.

Click on Debugger icon in IDE as shown below:
Clipboard01.jpg
Clipboard01.jpg (38.3 KiB) Viewed 2333 times
As the debugger is opened, you can see many options. Find Watch Point and click that icon as below:
Clipboard02.jpg
Clipboard02.jpg (61.54 KiB) Viewed 2333 times
In the watch expression textbox, enter the name of the variable you want to watch as the program runs. (for example I have added nVar1 public variable)
Clipboard03.jpg
Clipboard03.jpg (70.72 KiB) Viewed 2333 times
Now, adjust the watch monitor grid column sizes to show all the columns as shown in the figure below. You can see that as of now nVar1 is undefined and the value is NIL.
Clipboard04.jpg
Clipboard04.jpg (54.27 KiB) Viewed 2333 times
Now start the program execution in Animate mode as shown the figure below:
Clipboard05.jpg
Clipboard05.jpg (47.06 KiB) Viewed 2333 times
You can see that the nVar1 value is now changed to 0 (which is initialized in line no. 4 Now the program expects the user to click the button. Now click the button.
Clipboard06.jpg
Clipboard06.jpg (60.6 KiB) Viewed 2333 times
You can also see that when the counting is over, the value of nVar1 is changed to 1000.
Clipboard07.jpg
Clipboard07.jpg (49.03 KiB) Viewed 2333 times
I hope this explains how to use watchpoints in Debugger.

Let us thank Dr. Claudio for giving this wonderful tool!
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply