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

Column breakpoints not working - breaking as if they were just line breakpoints #51563

Closed
DanTup opened this issue Feb 28, 2023 · 5 comments
Closed
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. vm-debugger

Comments

@DanTup
Copy link
Collaborator

DanTup commented Feb 28, 2023

While working on breakpoint resolution, I noticed that column breakpoints seem to behave as if they had no column specified.

Given the code:

void main() {
  a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(null)))))))))))))))));
}

int counter = 1;
Object? a(Object? a) {
  print(counter++);
  return a;
}

And a column breakpoint added in the middle of all of the a() calls:

Screenshot 2023-02-28 at 12 11 36

When I run, the debugger resolves and breaks on the innermost call to a() as if it was just a standard line breakpoint:

Screenshot 2023-02-28 at 12 12 30

Here's the relevant log with annotations:



// Paused at startup

// Add breakpoint at "line":2,"column":21
[12:06:51] [General] [Info] [dart] ==> [VM] {"jsonrpc":"2.0","id":"31","method":"addBreakpointWithScriptUri","params":{"isolateId":"isolates/1999819261193331","scriptUri":"file:///Users/danny/Desktop/dart_sample/bin/colbreakpoints.dart","line":2,"column":21}}
[12:06:51] [General] [Info] [dart] <== [VM] {"jsonrpc":"2.0","method":"streamNotify","params":{"streamId":"Debug","event":{"type":"Event","kind":"BreakpointAdded","isolate":{"type":"@Isolate","id":"isolates/1999819261193331","name":"main","number":"1999819261193331","isSystemIsolate":false,"isolateGroupId":"isolateGroups/16408247551111255273"},"timestamp":1677586010986,"breakpoint":{"type":"Breakpoint","fixedId":true,"id":"breakpoints/1","enabled":true,"breakpointNumber":1,"resolved":false,"location":{"type":"UnresolvedSourceLocation","script":{"type":"@Script","fixedId":true,"id":"libraries/@18271130/scripts/file%3A%2F%2F%2FUsers%2Fdanny%2FDesktop%2Fdart_sample%2Fbin%2Fcolbreakpoints.dart/18697eb12b1","uri":"file:///Users/danny/Desktop/dart_sample/bin/colbreakpoints.dart"},"line":2,"column":21}}}}}
[12:06:51] [General] [Info] [dart] <== [VM] {"jsonrpc":"2.0","result":{"type":"Breakpoint","fixedId":true,"id":"breakpoints/1","enabled":true,"breakpointNumber":1,"resolved":false,"location":{"type":"UnresolvedSourceLocation","script":{"type":"@Script","fixedId":true,"id":"libraries/@18271130/scripts/file%3A%2F%2F%2FUsers%2Fdanny%2FDesktop%2Fdart_sample%2Fbin%2Fcolbreakpoints.dart/18697eb12b1","uri":"file:///Users/danny/Desktop/dart_sample/bin/colbreakpoints.dart","_kind":"kernel"},"line":2,"column":21}},"id":"31"}

// Resume
[12:06:51] [General] [Info] [dart] ==> [VM] {"jsonrpc":"2.0","id":"32","method":"resume","params":{"isolateId":"isolates/1999819261193331"}}
[12:06:51] [General] [Info] [dart] <== [VM] {"jsonrpc":"2.0","method":"streamNotify","params":{"streamId":"Debug","event":{"type":"Event","kind":"Resume","isolate":{"type":"@Isolate","id":"isolates/1999819261193331","name":"main","number":"1999819261193331","isSystemIsolate":false,"isolateGroupId":"isolateGroups/16408247551111255273"},"timestamp":1677586010994}}}
[12:06:51] [General] [Info] [dart] <== [VM] {"jsonrpc":"2.0","result":{"type":"Success"},"id":"32"}

// Brekapoint resolves to "tokenPos":48,"line":2,"column":35
[12:06:51] [General] [Info] [dart] <== [VM] {"jsonrpc":"2.0","method":"streamNotify","params":{"streamId":"Debug","event":{"type":"Event","kind":"BreakpointResolved","isolate":{"type":"@Isolate","id":"isolates/1999819261193331","name":"main","number":"1999819261193331","isSystemIsolate":false,"isolateGroupId":"isolateGroups/16408247551111255273"},"timestamp":1677586010995,"breakpoint":{"type":"Breakpoint","fixedId":true,"id":"breakpoints/1","enabled":true,"breakpointNumber":1,"resolved":true,"location":{"type":"SourceLocation","script":{"type":"@Script","fixedId":true,"id":"libraries/@18271130/scripts/file%3A%2F%2F%2FUsers%2Fdanny%2FDesktop%2Fdart_sample%2Fbin%2Fcolbreakpoints.dart/18697eb12b1","uri":"file:///Users/danny/Desktop/dart_sample/bin/colbreakpoints.dart"},"tokenPos":48,"line":2,"column":35}}}}}

// Breakpoint hit at "tokenPos":48,"line":2,"column":35
[12:06:51] [General] [Info] [dart] <== [VM] {"jsonrpc":"2.0","method":"streamNotify","params":{"streamId":"Debug","event":{"type":"Event","kind":"PauseBreakpoint","isolate":{"type":"@Isolate","id":"isolates/1999819261193331","name":"main","number":"1999819261193331","isSystemIsolate":false,"isolateGroupId":"isolateGroups/16408247551111255273"},"timestamp":1677586010996,"pauseBreakpoints":[{"type":"Breakpoint","fixedId":true,"id":"breakpoints/1","enabled":true,"breakpointNumber":1,"resolved":true,"location":{"type":"SourceLocation","script":{"type":"@Script","fixedId":true,"id":"libraries/@18271130/scripts/file%3A%2F%2F%2FUsers%2Fdanny%2FDesktop%2Fdart_sample%2Fbin%2Fcolbreakpoints.dart/18697eb12b1","uri":"file:///Users/danny/Desktop/dart_sample/bin/colbreakpoints.dart"},"tokenPos":48,"line":2,"column":35}}],"topFrame":{"type":"Frame","kind":"Regular","location":{"type":"SourceLocation","script":{"type":"@Script","fixedId":true,"id":"libraries/@18271130/scripts/file%3A%2F%2F%2FUsers%2Fdanny%2FDesktop%2Fdart_sample%2Fbin%2Fcolbreakpoints.dart/18697eb12b1","uri":"file:///Users/danny/Desktop/dart_sample/bin/colbreakpoints.dart"},"tokenPos":48,"line":2,"column":35},"function":{"type":"@Function","fixedId":true,"id":"libraries/@18271130/functions/main","name":"main","owner":{"type":"@Library","fixedId":true,"id":"libraries/@18271130","name":"","uri":"file:///Users/danny/Desktop/dart_sample/bin/colbreakpoints.dart"},"static":true,"const":false,"implicit":false,"abstract":false,"location":{"type":"SourceLocation","script":{"type":"@Script","fixedId":true,"id":"libraries/@18271130/scripts/file%3A%2F%2F%2FUsers%2Fdanny%2FDesktop%2Fdart_sample%2Fbin%2Fcolbreakpoints.dart/18697eb12b1","uri":"file:///Users/danny/Desktop/dart_sample/bin/colbreakpoints.dart"},"tokenPos":0,"endTokenPos":73,"line":1,"column":1}},"code":{"type":"@Code","fixedId":true,"id":"code/2544601bd-1169a3270","name":"[Unoptimized] main","kind":"Dart","function":{"type":"@Function","fixedId":true,"id":"libraries/@18271130/functions/main","name":"main","owner":{"type":"@Library","fixedId":true,"id":"libraries/@18271130","name":"","uri":"file:///Users/danny/Desktop/dart_sample/bin/colbreakpoints.dart"},"static":true,"const":false,"implicit":false,"abstract":false,"location":{"type":"SourceLocation","script":{"type":"@Script","fixedId":true,"id":"libraries/@18271130/scripts/file%3A%2F%2F%2FUsers%2Fdanny%2FDesktop%2Fdart_sample%2Fbin%2Fcolbreakpoints.dart/18697eb12b1","uri":"file:///Users/danny/Desktop/dart_sample/bin/colbreakpoints.dart"},"tokenPos":0,"endTokenPos":73,"line":1,"column":1}}},"vars":[],"index":0}}}}

The full log is here:

full_log.txt

@jacob314
Copy link
Member

Fyi @bkonyi

@bkonyi bkonyi self-assigned this Feb 28, 2023
@lrhn lrhn added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Mar 1, 2023
@a-siva
Copy link
Contributor

a-siva commented May 18, 2023

//cc @derekxu16

@derekxu16
Copy link
Member

If I try to set the inline breakpoint before starting the debug session, the breakpoint incorrectly acts like a line breakpoint. But inline breakpoints do work if I follow the following procedure:

  1. Add another arbitrary line at the start of main, for example print('hi);`
  2. Set a breakpoint on that
  3. Start the debug session
  4. Add an inline breakpoint
  5. Resume the program
  6. Observe that the program correctly stops at the inline breakpoint

I tried setting an inline breakpoint in a similar JavaScript program before starting the debug session, and the breakpoint did correctly behave as an inline breakpoint, so I think something can be changed in the Dart Code extension to fix that flow. Do you mind looking into this when you get the chance @DanTup?

@DanTup
Copy link
Collaborator Author

DanTup commented Jun 12, 2023

I see the same behaviour described above, but I'm not sure how the VS Code extension can fix this - the requests to the VM Service are the same in both cases (allowing for the difference in code when adding an earlier breakpoint). It seems like the VM might be doing things incorrectly if the breakpoint is set before the script is loaded - but there's no way VS Code can wait before sending the breakpoint, because by then it will have been missed. Here's the VM call for the breakpoint that isn't working right, which shows the correct column (as does the response from the VM).

[4:09:25 PM] [General] [Info] [Dart] ==> [VM] {"jsonrpc":"2.0","id":"30","method":"addBreakpointWithScriptUri","params":{"isolateId":"isolates/1512056957684895","scriptUri":"file:///C:/Dev/Test%20Projects/dart_sdk_51563/bin/dart_sdk_51563.dart","line":2,"column":21}}
[4:09:25 PM] [General] [Info] [Dart] <== [VM] {"jsonrpc":"2.0","method":"streamNotify","params":{"streamId":"Debug","event":{"type":"Event","kind":"BreakpointAdded","isolate":{"type":"@Isolate","id":"isolates/1512056957684895","name":"main","number":"1512056957684895","isSystemIsolate":false,"isolateGroupId":"isolateGroups/15225165641369050677"},"timestamp":1686582565707,"breakpoint":{"type":"Breakpoint","fixedId":true,"id":"breakpoints/1","enabled":true,"breakpointNumber":1,"resolved":false,"location":{"type":"UnresolvedSourceLocation","script":{"type":"@Script","fixedId":true,"id":"libraries/@18266854/scripts/file%3A%2F%2F%2FC%3A%2FDev%2FTest%2520Projects%2Fdart_sdk_51563%2Fbin%2Fdart_sdk_51563.dart/188b0279af6","uri":"file:///C:/Dev/Test%20Projects/dart_sdk_51563/bin/dart_sdk_51563.dart"},"line":2,"column":21}}}}}
[4:09:25 PM] [General] [Info] [Dart] <== [VM] {"jsonrpc":"2.0","result":{"type":"Breakpoint","fixedId":true,"id":"breakpoints/1","enabled":true,"breakpointNumber":1,"resolved":false,"location":{"type":"UnresolvedSourceLocation","script":{"type":"@Script","fixedId":true,"id":"libraries/@18266854/scripts/file%3A%2F%2F%2FC%3A%2FDev%2FTest%2520Projects%2Fdart_sdk_51563%2Fbin%2Fdart_sdk_51563.dart/188b0279af6","uri":"file:///C:/Dev/Test%20Projects/dart_sdk_51563/bin/dart_sdk_51563.dart","_kind":"kernel"},"line":2,"column":21}},"id":"30"}

What's been weirder, is that if I add an additional print line before it:

image

Then now the breakpoint happens after all of the calls on that line instead of before:

image

Again, the VM service call looks fine - line 3, column 21.

@bkonyi bkonyi assigned derekxu16 and unassigned bkonyi Jun 14, 2023
@DanTup
Copy link
Collaborator Author

DanTup commented Jul 27, 2023

Fix works great, thanks @derekxu16!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. vm-debugger
Projects
None yet
Development

No branches or pull requests

6 participants