Debugging: Stop program if variable = value ?

Post

Posted
Rating:
#1 (In Topic #649)
Avatar
Trainee
 Hello out there.
I am a newbie to Gambas and try to find out, if the following is possible:

While debugging, I want the program to stop/break if variable xy has a determined value.
Can you do that with the Gambas IDE?

Thanks a lot.
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
Just put a Stop in the code where you want it to stop and then highlight the variable to see its value.

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3.   Dim sDir As String[] = Dir(User.Home &/ "Pictures")
  4.  
  5.   Stop
  6.  

<IMG src="https://www.cogier.com/gambas/ToStop.png"> </IMG>
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
stevedee is in the usergroup ‘Regular’

fox73 said

…While debugging, I want the program to stop/break if variable xy has a determined value.
Can you do that with the Gambas IDE?

That's a great question.
It doesn't look like this feature is included in Gambas breakpoint options.

I did find that if you run code until it stops at a line breakpoint, the breakpoint window changes, and you get an "Add Expression" option via an eye-ball icon.
But I can't see how to use this.

Image

(Click to enlarge)


Breaking on a variable value would be a valuable inclusion to the Gambas IDE. Its far more useful in some situations than a line breakpoint.

For example in this code, it would be great to be able to break when (say) x = 2000:-

Code (gambas)

  1.   For x = 0 To 10000
  2.     'do stuff
  3.   Next
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
01McAc is in the usergroup ‘Regular’
I suppose a

Code (gambas)

will do the trick.
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Trainee
Hello cogier,
thanks for your reply. I know the possibility to place a break on a line and then display the value by clicking on the variable.
But this "hard break" is not, what I am looking for.

I am looking for a "smart break" that stops at the line, where an determined condition is reached, without knowing in advance at what line of the code.
It's as stevedee wrote in his example.I know this feature from tibe IBM z/OS mainframe tool DEBUG and it would be great to have it in Gambas, too :-)
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
stevedee is in the usergroup ‘Regular’

01McAc said

I suppose a

Code (gambas)

will do the trick.

Yes, that's the kind of workaround I would use, but I'm beginning to suspect there are existing features (which are pretty standard in other languages IDEs) that I either don't know how to enable or maybe they are broken.

For example there is both an Add Expression and an Add Watches button that I can't figure out.

I've only just discovered that after you stop program execution, you can then change the current value of variables…that's handy!

That is why I said fox73's question was a good one…its got me thinking about things I've taken for granted for years.
Online now: No Back to the top

Post

Posted
Rating:
#7
Regular
01McAc is in the usergroup ‘Regular’

stevedee said

I've only just discovered that after you stop program execution, you can then change the current value of variables…that's handy!

Sounds interesting, I didn't know this. VB is able to change values in debug mode - but Gambas? How would you do this?
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Regular
stevedee is in the usergroup ‘Regular’

01McAc said

…VB is able to change values in debug mode - but Gambas? How would you do this?

Pause execution using a line breakpoint, then double click on the variable's value in the Local variable list and type the new value.

Image

(Click to enlarge)


Yes, VB6 was great for debugging; you could pause execution, drag the execution point back a few lines, and then get it to re-execute the lines again!
Online now: No Back to the top

Post

Posted
Rating:
#9
Trainee
What you are looking for is called a conditional breakpoint.  I see it's in the TODO list in the Gitlab repo page:
https://gitlab.com/gam…547b807fe253b4a7f29b/TODO - line 36 as off right now.

Hopefully that'll be implemented soon(ish).
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
Dont hold your breath. It's been there for some years now.
But it would be nice.  :roll:

Online now: No Back to the top
1 guest and 0 members have just viewed this.