Commit Graph

585 Commits

Author SHA1 Message Date
Ryan Macnak 8b96a31c7f Move runtime functions to the more logical runtime_entry.cc.
Make --trace-runtime-calls respect the isolate filter.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2827873002 .
2017-04-19 10:22:04 -07:00
John McCutchan 6f039b508b Kill dead code
BUG=

Review-Url: https://codereview.chromium.org/2819573002 .
2017-04-13 09:55:13 -07:00
John McCutchan 7399d4bdec DBC follow up CL
- [x] Hoist handle out of loop.
- [x] Avoid allocating a handle.

BUG=

Review-Url: https://codereview.chromium.org/2819523003 .
2017-04-13 07:38:15 -07:00
John McCutchan f0734f99b3 Detect unhandled exceptions in async functions without an awaiter
- [x] Produce an awaiter stack trace even when there is no awaiter.
- [x] Fix fetching the saved context from Closure.call (fixes --trace_debugger_stacktrace)

Fixes #29200

Example code:

```
main(List<String> args) async {
  var f = new Foo();
  print(f.a.length);
  print('Should not get here');
}

class Foo {
  String a;
}
```

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2815863002 .
2017-04-12 13:15:41 -07:00
Regis Crelier d0a7bad121 Pass a second type argument vector to all type instantiation calls in the VM.
With generic methods, uninstantiated types will require 2 instantiators, one
reflecting the class type arguments (as of today) and one reflecting the
function type arguments (new).
This is work in progress and the second instantiator is always null for now.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2799373002 .
2017-04-10 21:25:33 -07:00
John McCutchan e33e09a23c Disable async debugger support until context mismatch issue is resolved.
BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2795303002 .
2017-04-04 13:36:42 -07:00
John McCutchan fb84ff3fc4 Revert "Disable awaiter stepping by default until context level computation is fixed"
This reverts commit 61e11c6808.

BUG=

Review-Url: https://codereview.chromium.org/2791953002 .
2017-04-03 00:06:28 -07:00
John McCutchan 61e11c6808 Disable awaiter stepping by default until context level computation is fixed
BUG=
R=asiva@google.com, fschneider@google.com

Review-Url: https://codereview.chromium.org/2787023002 .
2017-04-02 21:03:11 -07:00
John McCutchan 193f26d1e1 Implement support for single stepping out of an async function.
BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2785243003 .
2017-03-31 10:55:11 -07:00
Florian Schneider 5a3f9d9398 Fix a couple of bugs with async stack traces
Related to #29145.

Fixes #29199.

1. Missing source positions in async and async* functions (synthetic code)

2. Added unit tests for issues #28980 and added asyns stack trace testing flags to existing test.

3. Handle uninitialized Completer object when collecting async stack traces.

Still missing is the correct calculation of context levels in ActivationFrame::ContextLevel. This is planned for a separate CL.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2786503003 .
2017-03-30 11:02:33 -07:00
John McCutchan 2815f3f775 Implement debugger support for async step-out
BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2777093006 .
2017-03-29 07:44:18 -07:00
John McCutchan 8cee5258ee Fix crash when determining whether an async exception is handled
BUG=

Review-Url: https://codereview.chromium.org/2780163002 .
2017-03-29 07:30:29 -07:00
John McCutchan d8555fb5a8 Include the awaiter stack trace in the service protocol
- [x] Include the (non-empty) awaiter stack trace in every `getStack` RPC.
- [x] Append the causal stack trace to the final frame of the awaiter stack trace.
- [x] Unit test for awaiter stack trace.

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2782703002 .
2017-03-29 06:56:50 -07:00
John McCutchan 11cf515e5e Cleanups needed for async step-out
BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2774233003 .
2017-03-27 15:18:41 -07:00
John McCutchan 07a257573d Debugger support for step-into async and async* functions.
- [x] Support stepping into an async function.
- [x] Support stepping into the async generator in an await for loop.
- [x] Unit test for async function.
- [x] Unit test for async* function.

BUG=
R=asiva@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/2768103002 .
2017-03-24 07:56:50 -07:00
Regis Crelier bde22d2dee Cleanup change.
AssertAssignableInstr::Canonicalize was too restrictive: it can instantiate the
type even if the instantiator is null.
Do not allocate empty TypeArguments handles, but use the common one instead.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2759393005 .
2017-03-21 13:55:39 -07:00
Florian Schneider 537eacb525 Ensure unoptimized code when collecting awaiter return stack trace.
Fixes crashes when running reload stress tests with the async stack trace stress flag
(python tools/test.py --hot-reload -t240 --builder-tag no_ipv6 language/await_exceptions_test)

R=johnmccutchan@google.com

Also: Use iterators to get function of a stack frame (refactoring only).
Review-Url: https://codereview.chromium.org/2761143004 .
2017-03-21 13:03:03 -07:00
Florian Schneider ef7487a7a8 Fix two bugs with async stack traces.
1. A crash when collecting an async stack trace with inlined frames on the stack.

2. A missing source position in an async stack trace.

Fixes #29080.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2767483002 .
2017-03-21 09:31:11 -07:00
Matthias Hausner d8ddd7766b Fix debugger regression in issue 28980
When generating the implicit try-catch of an async function, use the
end token position of the function for the completeError() call. Before
this change, the position was one token past last function token.

CL https://codereview.chromium.org/2646093006/ introduced a regression.
This CL fixes #28980 and implements a different fix for #28443.

BUG=#28980
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2740783007 .
2017-03-09 16:20:48 -08:00
Matthias Hausner 408a64756e Fix setting breakpoint setting in await statements
CL https://codereview.chromium.org/2626753002 introduced a “real” token
position for the synthetic code that re-throws an exception returned
by an await’ed expression. This interferes with setting a breakpoint
in a line that contains an await, since the synthetic code happens to
be at the lowest compiled code address and will thus be picked as the
breakpoint location.

This CL makes the re-throw a synthetic token position again, but
includes synthetic token positions in stack traces. This is an alternative
fix for bug #28325.

BUG=#28770
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2727803002 .
2017-03-02 12:21:42 -08:00
John McCutchan 6cb83f037e Address comments from Matthias on previous CL
original CL: https://codereview.chromium.org/2692803006/

R=hausner@google.com

Review-Url: https://codereview.chromium.org/2720723006 .
2017-02-28 14:02:32 -08:00
Kevin Millikin f31b6d5e2c Reland "Track the 'awaiter return' call stack..."
Original CL: https://codereview.chromium.org/2692803006/

Original commit message:
Tracking the awaiter return call stack:

- [x] Each async function closure now knows who is awaiting on their
return. This is effectively the asynchronous equivalent of the 'frame pointer'.
- [x] Each async* function closure now knows how is listening on their
stream. This is effectively the asynchronous equivalent of the 'frame pointer'.

Detecting uncaught exceptions in async functions:

- [x] Code object keeps a map from :await_jump_var to token position
- [x] Exception Handlers keep track if they are generated (as part of compilation) or directly from user code
- [x] Debugger maps :await_jump_var to a specific try index

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2725623003 .
2017-02-28 16:13:41 +01:00
Kevin Millikin a0965a641f Revert "Track the 'awaiter return' call stack..."
Revert a pair of commits that cause failure of the Kernel continuation
transformer:

  cba7e3e79a
  4fe4f177de

R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2718353002 .
2017-02-28 12:46:31 +01:00
John McCutchan cba7e3e79a Track the 'awaiter return' call stack use it to detect uncaught exceptions in async functions
Tracking the awaiter return call stack:

- [x] Each async function closure now knows who is awaiting on their
return. This is effectively the asynchronous equivalent of the 'frame pointer'.
- [x] Each async* function closure now knows how is listening on their
stream. This is effectively the asynchronous equivalent of the 'frame pointer'.

Detecting uncaught exceptions in async functions:

- [x] Code object keeps a map from :await_jump_var to token position
- [x] Exception Handlers keep track if they are generated (as part of compilation) or directly from user code
- [x] Debugger maps :await_jump_var to a specific try index

Fixes #27242

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2692803006 .
2017-02-27 14:16:15 -08:00
John McCutchan 6a312d429b Fix causal_async_star_stack_contents_test with optimization-counter-threshold=5
There was an off by one error when generating the causal async stack trace
in the debugger. We were always adding one more frame pass the sentinel frame.
This frame is always _Closure.call which is filtered out by the debugger
already. However when --optimization-counter-threshold=5, _Closure.call was
inlined and we ended up appending the inliner to the stack trace. The
inliner is not filtered out by the debugger so we got an extra frame in
the stack trace.

Fixes #28861

BUG=
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2707413002 .
2017-02-24 06:58:39 -08:00
John McCutchan 19abef97f1 Reland improvements to causal async stack traces
Original CL: https://codereview.chromium.org/2690683002

Improvements to causal async stack traces

UX improvements:

- [x] Stop printing the suffix <%s_async_body> and <%s_async_gen_body> for the generated closures.

Fixes #28743

- [x] Don't include the duplicate frame below the asynchronous suspension marker.

Fixes #28742

Bug fixes:

- [x] Fix service protocol enum naming so that it is consistent with other enums.

Fixes #28726

Misc:

- [x] Stop using package:stack_trace now that the VM does it for us.

BUG=
R=asiva@google.com, devoncarew@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/2691213003 .
2017-02-14 05:00:04 -08:00
John McCutchan e84d8a1f11 Revert "Improvements to causal async stack traces"
This reverts commit 8538d81473.

BUG=

Review-Url: https://codereview.chromium.org/2694213002 .
2017-02-14 02:29:40 -08:00
John McCutchan 8538d81473 Improvements to causal async stack traces
UX improvements:

- [x] Stop printing the suffix <%s_async_body> and <%s_async_gen_body> for the generated closures.

Fixes #28743

- [x] Don't include the duplicate frame below the asynchronous suspension marker.

Fixes #28742

Bug fixes:

- [x] Fix service protocol enum naming so that it is consistent with other enums.

Fixes #28726

Misc:

- [x] Stop using package:stack_trace now that the VM does it for us.

BUG=
R=asiva@google.com, devoncarew@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/2690683002 .
2017-02-14 00:56:55 -08:00
Matthias Hausner 74da383d6f Delete Breakpoint objects, fixing memory leak
Delete Breakpoint objects from the C heap when they are no longer needed.
Also delete inactive code breakpoint objects more aggressively.

This should fix the memory leaks reported in #28348.

General cleanup of breakpoint handling code and comments.

BUG=#28348
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2689623002 .
2017-02-10 10:43:24 -08:00
Ryan Macnak b15b98bcc3 Reapply "Use CodeSourceMap for stack traces (still JIT only)."
- Fix missing null termination in initialization of ZoneTextBuffer.
 - Merge with John's async stack trace changes.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2686813006 .
2017-02-09 18:03:41 -08:00
John McCutchan a0ee5b24db Track async causal stack traces
This CL improves the stack traces that accompany exceptions. Whenever an
async function is entered, we remember how we got there. This is similar
in spirit to package:stack_trace but the implementation is more efficient
and memory usage can be more easily reasoned about.

Tracking causal stack traces:

- [x] Upon entry to an async function, capture the synchronous stack trace prefix and store it into the closure.
- [x] Upon entry to an async* function, capture the synchronous stack trace prefix and store it into the closure.
- [x] Before returning from an async function, clear the Thread's asynchronous stack trace.
- [x] After resuming an async function, load the sychronous stack trace prefix into the Thread.
- [x] Filter stack traces to remove async machinery.

Service protocol changes:

- [x] Send causal async stack trace.

Observatory changes:

- [x] Display causal async stack trace below async functions.

Fixes https://github.com/dart-lang/sdk/issues/27661

R=asiva@google.com, rmacnak@google.com

Comparisons: https://docs.google.com/a/google.com/document/d/10r6jEqr8OCiDZ4y9SYU_uOimcHiOGAZMly2ghTErALI/edit?usp=sharing
Review-Url: https://codereview.chromium.org/2646443005 .
2017-02-09 15:39:44 -08:00
Ryan Macnak 15a9eafb77 Revert "Reapply "Use CodeSourceMap for stack traces (still JIT only).""
This reverts commit bee82fef8b.

Revert "Use zone memory for StackTrace::ToCString."

This reverts commit 4e8b265ea0.

The later CL somehow caused hangs in some service tests.

Review-Url: https://codereview.chromium.org/2683033007 .
2017-02-09 13:14:01 -08:00
Ryan Macnak bee82fef8b Reapply "Use CodeSourceMap for stack traces (still JIT only)."
Include CodeSourceMaps in app-jit snapshots.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2686623006 .
2017-02-08 16:43:47 -08:00
Ryan Macnak 9e3bd0ef0a Revert "Use CodeSourceMap for stack traces (still JIT only)."
Failed with app-jit snapshots.

This reverts commit 7d2e6b1615.

Review-Url: https://codereview.chromium.org/2685723004 .
2017-02-08 13:33:23 -08:00
Ryan Macnak 7d2e6b1615 Use CodeSourceMap for stack traces (still JIT only).
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2684763002 .
2017-02-08 11:31:46 -08:00
Jens Johansen e7766c950e Debugging in kernel shaping up.
This introduces

- a list of valid token positions, so debugging actually
  starts to work, and the observatory can be loaded without crash.

- a list of valid yield positions, so stepping over await stuff
  works as expected.

- Adding "DebugStepCheckInstr" to the kernel generated il so stepping
  over await stuff works as expected, we can break in empty methods etc.

With this, approximately 80% of the service tests pass in kernel mode.

R=kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/2d5147be9d7435c06dd892d145d8717b6d1f62d5
Review-Url: https://codereview.chromium.org/2632183002 .
2017-01-31 11:59:06 +01:00
Jens Johansen d0e0ef52ef Revert "Debugging in kernel shaping up."
This reverts commit 2d5147be9d.

INTPTR_MAX doesn't exist on all builders.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2664143002 .
2017-01-31 11:26:46 +01:00
Jens Johansen 2d5147be9d Debugging in kernel shaping up.
This introduces

- a list of valid token positions, so debugging actually
  starts to work, and the observatory can be loaded without crash.

- a list of valid yield positions, so stepping over await stuff
  works as expected.

- Adding "DebugStepCheckInstr" to the kernel generated il so stepping
  over await stuff works as expected, we can break in empty methods etc.

With this, approximately 80% of the service tests pass in kernel mode.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2632183002 .
2017-01-31 11:01:29 +01:00
Florian Schneider 3e59f95717 Fix debugger's calculation of the context level in async code.
The synthetic call to completeError has the function end as a token position.

This caused the < comparison to fail, and not find the correct context level
when creating a stacktrace in the debugger.

Fixes #28443

R=hausner@google.com

Review-Url: https://codereview.chromium.org/2646093006 .
2017-01-20 16:08:38 -08:00
Jens Johansen b2b00e8909 TokenPositions on more nodes when running from Kernel
Utilize the offsets added in previous CLs.
While this doesn't by it self give anything that resembles
a good debugging experience, it should now be possible to
set *some* breakpoints and actually break on them.

Because of the way observatory works (and because of an
unfinished Script::GenerateLineNumberArray (for kernel))
the formatting of the code you try to load up and 'debug'
has to be quite specific (e.g. no indentation at all),
and even then it mostly doesn't work.

This is step #3 in introducing these things, next step(s) will be
fixing stuff like the above.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2628693004 .
2017-01-13 13:10:20 +01:00
John McCutchan f125cc7d0b Improve the casing of Stackmap and Stacktrace.
- [x] Stackmap -> StackMap
- [x] Stacktrace -> StackTrace

This makes us consistent with the Dart language (StackTrace) and
corrects the casing of StackMap.

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2572563004 .
2016-12-12 14:51:30 -08:00
Todd Turnidge e0d350aa27 Implement rewind on all platforms except for dbc.
BUG=

Review URL: https://codereview.chromium.org/2534413005 .
2016-12-01 17:19:31 -08:00
Todd Turnidge 193ddba4db Revert "Implement rewind: drop one or more frames from the debugger."
This reverts commit af1875be91.

BUG=

Review URL: https://codereview.chromium.org/2521413002 .
2016-11-22 16:05:26 -08:00
Todd Turnidge af1875be91 Implement rewind: drop one or more frames from the debugger.
Not yet implemented on dbc.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2523053002 .
2016-11-22 15:26:08 -08:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
John McCutchan 8061bd5a8a Add local variable declaration token position to service protocol
- [x] Add three public fields to the "BoundVariable" service type: declarationTokenPos, visibleStartTokenPos, and visibleEndTokenPos. (naming suggestions welcome!)
- [x] Extend LocalVarDescriptors to hold the declaration token position (it already had the scope visibility boundaries).
- [x] Extend ContextScope to hold the declaration token position.
- [x] Add a unit test which verifies this works for local variables, function parameters, and closure captured variables.

Fixes https://github.com/dart-lang/sdk/issues/25569

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2419013004 .
2016-10-17 11:18:24 -07:00
John McCutchan 2d0a08baf9 Make reloadSources service RPC public
- [x] Make `reloadSources` RPC public.
- [x] Add an optional 'pause' parameter to `reloadSources`. When set to true, the isolate will enter the debug pause loop immediately after reloading sources and before resuming execution. This makes it possible for debugger clients to set breakpoints before resuming.
- [x] Add reload_sources_test which tests pausing after reload.
- [x] Fix a bug in `GetVarDescriptors` where a null code object could be used.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/2411153002 .
2016-10-13 07:45:56 -07:00
John McCutchan 48c6f19600 Respect setLibraryDebuggable
- [x] Mark all libraries debuggable by default
- [x] Mark all dart:_* libraries as not debuggable by default
- [x] Respect setLibraryDebuggable
- [x] Add set library debuggable test case
- [x] Do not allow dart:_* libraries to be marked debuggable

Fixes https://github.com/dart-lang/sdk/issues/27370

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2361183002 .
2016-09-23 10:45:51 -07:00
Matthias Hausner 74e779d4fe Fix stepping over await statements
When async-stepping over an await statement that follows a previous
async-step command, ensure that the synthetic breakpoint at the
beginning of the async closure is not accidentally deleted.

Removing a test that depends on minute details of the internal
implementation of async-step commands.

Adding new test that checks for multiple consecutive async-step
commands.

Note that debugger.cc seems to contain a memory leak. Breakpoint
objects are not deleted (deallocated) when RemoveBreakpoint()
is called. Will address this in a separate CL.

BUG=#27238
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2366463002 .
2016-09-22 14:06:24 -07:00
Todd Turnidge cd8292d175 Don't return negative token positions in stack traces.
Closes #27128

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2294883004 .
2016-08-31 16:22:18 -07:00