-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[vm/debugger/dart-code] Debugger local variables below asynchronous gap #51763
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
Comments
I would think that we are missing VM implementation for inspecting suspend states. /cc @alexmarkov |
In VS Code we're showing the @mraleph slightly related - in the VM Service docs I see there are both |
I think with the current implementation both should effectively be the same. Maybe we should remove one? /cc @rmacnak-google @bkonyi
It is very expensive to produce the type of stack trace that |
I've never been 100% confident in my understanding of the difference between |
@mraleph great, thanks for the explanation! :-) |
It looks like this issue is a duplicate of an older issue #48836. With the new async implementation it should be easier to support this as suspend state of an async function contains a copy of the whole frame. @DanTup I see 3 different implementations of stack trace scanning in the VM debugger support: |
I'm not sure about IntelliJ/AS/etc., but in VS Code and the DAP we always show I can try and build some code examples and capture each type of stack (inc. the |
Correct, the example in that issue reproduces the same issue in VSCode, but is a single file repro. 👍 class Foo {}
void main() async {
final mainVar = new Foo();
await foo();
print(mainVar);
}
Future<void> foo() async {
final fooVar = new Foo();
await null;
await foo2();
print(fooVar);
}
Future<void> foo2() async {
print("hello"); // breakpoint here: fooVar still available, mainVar not
await Future.value(); // make a new <asynchronous gap>
print("hello2"); // breakpoint here: fooVar also unavailable
} (I'll close the other issue, as this one has more info.) |
FWIW (slightly off-topic for this issue, but continuining some discussion from above), I tried testing with the example given in the import 'dart:async';
void main() {
_scheduleAsync();
}
void _scheduleAsync() {
Future.delayed(Duration(seconds: 1)).then((_) => _runAsync());
}
void _runAsync() {
throw 'oh no!'; // break here
} Which results in the "bad" ( I was going to compare it to |
This is currently working as intended. See #46318 |
I have been recently looking at our stack trace collection machinery to fix some AOT related bugs and as part of this, I stumbled across this code again, which made me do some code archaeology. Here is what I have found.
The are few differences between these two:
I don't think there are any other fundamental differences between these two fields. I have looked around in the internal and external codesearch (GitHub) and I could not find any uses of Internally in the VM Based on these observations I have started to remove |
This field was supposed[1] to replace Stack.asyncCausalFrames but IDEs and other service protocol users never adopted it. The mechanism for collecting awaiterFrames and asyncCausalFrames was originally considerably different, but we have since unified both[2] after we switched to lazy async stack traces[3]. Today the only differences between the two are: - asyncCausalFrames represens async gaps explicitly, while awaiterFrames does not; - when asynchronous function is running its synchronous part before the first suspension awaiterFrames will still represent the corresponding frame as an asynchronous activation, while asyncCausalFrames will treat the same frame as regular frame. Consequently having this field does not add any value. This CL removes it from the response and updates all tests to test against asyncCausalFrames. [1]: https://codereview.chromium.org/2692803006/ [2]: https://dart-review.googlesource.com/c/sdk/+/167561 [3]: #37668 Tested: pkg/vm_service, service, service_2 Bug: #51763 Change-Id: If2b035a8840047423b8ed8ce3b5d81155e9f38d0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301062 Commit-Queue: Slava Egorov <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
|
what does this mean now? any chance to get local variables over asynchronous gaps? |
When having
<asynchronous gap>
on the stack, all frames under it do not have their local variables accessible.It would be convenient for debugging if these were available.
I'm not entirely sure where in the chain the information is missing, is this a limitation of our implementation in the VM? Or are we missing the necessary plumbing in the debugger or Dart-Code?
Local variables above the first asynchronous gap work fine:

cc @DanTup
The text was updated successfully, but these errors were encountered: