Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger doesn't understand conditional breakpoints #385

Closed
mburns08109 opened this issue Aug 25, 2021 · 9 comments
Closed

Debugger doesn't understand conditional breakpoints #385

mburns08109 opened this issue Aug 25, 2021 · 9 comments

Comments

@mburns08109
Copy link

mburns08109 commented Aug 25, 2021

Describe the bug
First: I enhanced the HelloWorld.twin code as follows:
Public Sub Main()

Dim iAns As Integer
    
    MsgBox "Hello world!"
    iAns = MsgBox("Did you get that?", vbYesNoCancel)
    Select Case iAns
    Case vbYes
        MsgBox "You Got it! Yay!", vbOKOnly
    Case vbNo
        MsgBox "You didn't!? - Darn!"
    Case Else
        MsgBox "Huh?"
    End Select
End Sub

Second: I set an Expression breakpoint "iAns = 7"
This breakpoint attached to the Public Sub Main() line in the VSCode Editor.

At EVERY run, on startup, this breakpoint was hit and stopped execution AT the Public Sub Main() line.
When told to continue running, the code ran as expected. EXCEPT, when NO was chosen on the 2nd msgbox line, The Breakpoint was IGNORED.

To Reproduce
see above

Expected behavior

  1. the code should NOT stop on the Public Sub Main() line at all
  2. whenever iAns = 7 occurs during the run, the breakpoint should stop execution at the next possible point/statement

Note: If the breakpoint is specified as iAns - vbNo....the breakpoint is never hit (the debugger seems not to understand the predefined VB/VBA constants). This should ALSO work as expected.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • twinBASIC compiler version ? (where can I see this?)

Additional context
Add any other context about the problem here.

@mburns08109
Copy link
Author

FYI - Changing the break expression to "iAns=7" (no spaces) - changed nothing.

@mburns08109
Copy link
Author

Additionally - setting a breakpoint on the End Select line was skipped.

@WaynePhillipsEA
Copy link
Collaborator

Hi @mburns08109 thanks for opening this issue. The debugger does not yet understand conditional breakpoints at all.

As a first step, we'll add an error message if the user tries to add a conditional breakpoint. And then a little later we'll look to add conditional breakpoint support.

At EVERY run, on startup, this breakpoint was hit and stopped execution AT the Public Sub Main() line.
When told to continue running, the code ran as expected. EXCEPT, when NO was chosen on the 2nd msgbox line, The Breakpoint was IGNORED.

As the debugger doesn't understand conditional breakpoints, it will currently see the conditional breakpoint as an ordinary breakpoint for the moment, so this behaviour is expected. However, even if this feature was implemented, your expectation for this to stop on the vbNo line is not correct. It would only stop there if you had put the conditional breakpoint on that line (not at the top of the procedure). The debugger is expected to evaluate the expression you've entered immediately before deciding whether or not to break on the line where you've set the breakpoint (not on any other line being executed in the procedure).

Note that the conditional breakpoint feature is NOT the exact equivalent of the 'Break When Value Is True' option in the VBx Watch Window debugger (see #76 for that).

@WaynePhillipsEA WaynePhillipsEA changed the title Enhanced HelloWorld Debugging issues. Debugger doesn't understand conditional breakpoints Aug 25, 2021
@WaynePhillipsEA
Copy link
Collaborator

v0.10.4980 now displays a warning that it is unsupported when you add a conditional breakpoint.

We'll leave this issue open to track the actual support for conditional breakpoints.

@mburns08109
Copy link
Author

Oh - not sure if you saw it, but as I'm new to the twinBasic bandwagon...how do I see the current compiler version?
...and how do I refresh it to the "current" version?

@uwbwsvd
Copy link

uwbwsvd commented Aug 25, 2021

grafik

@uwbwsvd
Copy link

uwbwsvd commented Aug 25, 2021

...and how do I refresh it to the "current" version?
As far as I know: Restart VS-Code

@WaynePhillipsEA
Copy link
Collaborator

As @uwbwsvd mentioned, the version number can be seen in the extension panel, but it can also be seen in the debugger callstack window:

tb_debugCallstack

With regards to getting updates, this is handled by VS Code. If you haven't changed any VS Code settings, then the default behaviour is that VS Code will download and install extension updates automatically for you. twinBASIC updates require a restart of VS Code, so if you go to the extension panel you will often see [Reboot Required] next to the twinBASIC extension as updates are pushed out very frequently.

@WaynePhillipsEA
Copy link
Collaborator

As of v0.10.5070, conditional breakpoints are now supported.

To set conditional breakpoints in VS Code, right click in the gutter (where you would normally click to set a breakpoint), and then you'll see the 'Add Conditional Breakpoint...' option. Enter an expression such as 'Index > 500' and twinBASIC will only break at that line if that condition evaluates to TRUE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants