dart-sdk/runtime/lib/stacktrace.h
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

26 lines
763 B
C++

// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_LIB_STACKTRACE_H_
#define RUNTIME_LIB_STACKTRACE_H_
namespace dart {
class StackTrace;
class RawStackTrace;
// Creates a StackTrace object from the current stack. Skips the
// first skip_frames Dart frames.
//
// This function is exposed to provide stack trace printing in
// assertion failures, etc.
const StackTrace& GetCurrentStackTrace(int skip_frames);
// Creates a StackTrace object to be attached to an exception.
RawStackTrace* GetStackTraceForException();
} // namespace dart
#endif // RUNTIME_LIB_STACKTRACE_H_