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 pauses on wrong line with debugger() in catch block #46006

Closed
DanTup opened this issue May 13, 2021 · 2 comments
Closed

Debugger pauses on wrong line with debugger() in catch block #46006

DanTup opened this issue May 13, 2021 · 2 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. vm-debugger

Comments

@DanTup
Copy link
Collaborator

DanTup commented May 13, 2021

Raised by @4amVim at Dart-Code/Dart-Code#3337. I could repro using the supplied Flutter sample in Android Studio too, though was also able to reduce it to a standard CLI script using latest nightly build:

import 'dart:developer';

void main() {
  try {
    throw 'a';
  } catch (e) {
    debugger();
  }
  print('debugger pauses here');
}

Screenshot 2021-05-13 at 11 10 28

The pause event has tokenPos: 101, and the tokenPosTable looks like this:

[
	[3,26,1,31,6,35,10,38,13],
	[4,46,7],
	[5,52,5],
	[6,65,3,67,5,74,12,77,15],
	[7,83,5],
	[8,97,3],
	[9,101,3], // Token 101 is on line 9
	[10,132,1]
]

This prevents examining the e variable since it appears to have gone out of scope.

@mkustermann
Copy link
Member

/cc @aam

@aam
Copy link
Contributor

aam commented Jun 21, 2023

This is due to the fact that debugger() gets dart program to stop after the call is completed (

/// was hit. The breakpoint will be placed right after the call to `debugger`.
), but there is no next available stopping point from vm perspective until program execution leaves the catch block and gets to print statement.
Potentially we could introduce such a stopping point - see https://dart-review.googlesource.com/c/sdk/+/310779

cc @a-siva

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, FFI, and the AOT and JIT backends. vm-debugger
Projects
None yet
Development

No branches or pull requests

5 participants