Skip to content

Breaking change in how breakpoints are handled by the debugger #334

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

Closed
bergwerf opened this issue Jun 22, 2017 · 13 comments
Closed

Breaking change in how breakpoints are handled by the debugger #334

bergwerf opened this issue Jun 22, 2017 · 13 comments

Comments

@bergwerf
Copy link

See: dart-lang/sdk#29988. I noticed that with dart 1.25.0-dev.1.0 the debugger did not pause at all breakpoints (in particular some inside a closure, where I did not experience any issues previously). It seems that something was updated in the SDK and something has to be fixed in this plugin.

@DanTup
Copy link
Member

DanTup commented Jun 23, 2017

I'm struggling to reproduce this; I've got this:

main() {
  print(getThing().length);
}

getThing() {
  var result = [1, 2, 3, 4];
  return result.map((v) => v / 2).toList();
}

I'm putting a breakpoint on the map line and it always gets hit. I'm using v.1.25.0-dev.2.1. Are you able to make a simple repro?

@bergwerf
Copy link
Author

bergwerf commented Jun 23, 2017

It took me some tries to reproduce this as well, but this reproduces the bug:

lib/src/test.dart
part of test;

void doPrint() {
  print('Break!');
}
lib/test.dart
library test;
part 'src/test.dart';
test/test.dart
import 'dart:async';
import 'package:test/test.dart';
import 'package:yourpackage/test.dart';

Future main() async {
  test('Test', () {
    doPrint();
  });
}

(it doesn't reproduce the issue if you put the function directly in the primary library file)

Try to break on print('Break!');

@DanTup
Copy link
Member

DanTup commented Jun 23, 2017

@hermanbergwerf Perfect; I can repro with these files. I'll investigate!

@DanTup
Copy link
Member

DanTup commented Jun 23, 2017

Ok, I ran this same test in 1.24 and 1.25 and found this..

We currently send breakpoints twice because we previously found that depending on how a file was imported, the debugger would not break on it (some discussion in #134). So the request to add breakpoints looks like this:

==> {"id":"5","method":"addBreakpointWithScriptUri","params":{"isolateId":"isolates/11111111","scriptUri":"file:///c:/Users/danny/Desktop/DartDebugSample/lib/src/test.dart","line":4}}
==> {"id":"6","method":"addBreakpointWithScriptUri","params":{"isolateId":"isolates/11111111","scriptUri":"package:yourpackage/src/test.dart","line":4}}

In 1.24, both of these breakpoints are accepted:

<== {"jsonrpc":"2.0", "result":{"type":"Breakpoint","fixedId":true,"id":"breakpoints\/1","breakpointNumber":1,"resolved":false,"location":{"type":"UnresolvedSourceLocation","scriptUri":"file:\/\/\/c:\/Users\/danny\/Desktop\/DartDebugSample\/lib\/src\/test.dart","line":4}},"id":"5"}
<== {"jsonrpc":"2.0", "result":{"type":"Breakpoint","fixedId":true,"id":"breakpoints\/2","breakpointNumber":2,"resolved":false,"location":{"type":"UnresolvedSourceLocation","script":{"type":"@Script","fixedId":true,"id":"libraries\/@17134453\/scripts\/package%3Ayourpackage%2Fsrc%2Ftest.dart\/15cd52126c7","uri":"package:yourpackage\/src\/test.dart","_kind":"source"},"line":4}},"id":"6"}

and when we go on to execute, we stop at the second breakpoint - the "package" version.

However, here's what happens in 1.25. We send the same requests:

==> {"id":"5","method":"addBreakpointWithScriptUri","params":{"isolateId":"isolates/11111111","scriptUri":"file:///c:/Users/danny/Desktop/DartDebugSample/lib/src/test.dart","line":4}}
==> {"id":"6","method":"addBreakpointWithScriptUri","params":{"isolateId":"isolates/11111111","scriptUri":"package:yourpackage/src/test.dart","line":4}}

But here's the response:

<== {"jsonrpc":"2.0", "result":{"type":"Breakpoint","fixedId":true,"id":"breakpoints\/1","breakpointNumber":1,"resolved":false,"location":{"type":"UnresolvedSourceLocation","scriptUri":"file:\/\/\/c:\/Users\/danny\/Desktop\/DartDebugSample\/lib\/src\/test.dart","line":4}},"id":"5"}
<== {"jsonrpc":"2.0", "error":{"code":102,"message":"Cannot add breakpoint","data":{"request":{"method":"addBreakpointWithScriptUri","params":{"isolateId":"isolates\/11111111","scriptUri":"package:yourpackage\/src\/test.dart","line":"4"}},"details":"addBreakpointWithScriptUri: Cannot add breakpoint at line '4'"}},"id":"6"}

Note that the second breakpoint (which is the one that breaks in 1.24) is the one being rejected.

So, I have no idea how to fix this - the breakpoint we can't set is the one that would actually work.

DartDebugSample.zip

I'm gonna add this comment also to dart-lang/sdk#29988 because I need input from Google on how this is supposed to work.

@DanTup DanTup added in debugger Relates to the debug adapter or process of launching a debug session blocked on dart / flutter Requires a change in Dart or Flutter to progress is bug labels Jun 24, 2017
@DanTup DanTup modified the milestones: v1.5, v1.4.3 Jul 1, 2017
@DanTup DanTup added fixed in dart / flutter and removed blocked on dart / flutter Requires a change in Dart or Flutter to progress labels Jul 6, 2017
@DanTup
Copy link
Member

DanTup commented Jul 6, 2017

Looks like this has been fixed in Dart, so hopefully won't occur in any release SDKs.

@DanTup DanTup closed this as completed Jul 6, 2017
@DanTup
Copy link
Member

DanTup commented Jul 13, 2017

This seems fixed in SDK .dev.6.0 :-)

@DanTup DanTup removed in debugger Relates to the debug adapter or process of launching a debug session is bug labels Jul 13, 2017
@bergwerf
Copy link
Author

Again having issues in 1.25.0-dev.8.0 :-(

@DanTup
Copy link
Member

DanTup commented Jul 30, 2017

I think it's best posting back in dart-lang/sdk#29988 or raising a new case there with a sample. You can get a log like I posted above by setting the "dart.observatoryLogFile" setting to a file path/name, which should help track things down. Feel free to post it here for me to have a look before you raise an SDK issue if you want.

@bergwerf
Copy link
Author

Alright, will look into this a bit.
Also loading the scope variables for anything but the top of the stack trace is not working.

@DanTup
Copy link
Member

DanTup commented Jul 31, 2017

@hermanbergwerf Using dev.8.0 and performing the same steps on the above repro I hit the breakpoint fine. If you can provide new repro steps/sample I can take a look.

@bergwerf
Copy link
Author

bergwerf commented Jul 31, 2017 via email

@DanTup
Copy link
Member

DanTup commented Jul 31, 2017

@hermanbergwerf I'm just investigating an issue with breakpoints not being hit that may or may not be related - see #398. I think I know the cause and fix, but not why it's never been noticed before!

@bergwerf
Copy link
Author

bergwerf commented Jul 31, 2017 via email

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

2 participants