Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Unified Diff: runtime/vm/object.cc

Issue 2690683002: Improvements to causal async stack traces (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 1588b917c6f3e2e7f8686b1a883999a46b86093f..64b763ce6a29507b73ae4782b43e73a0b14717a3 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -7060,10 +7060,22 @@ RawString* Function::UserVisibleName() const {
RawString* Function::QualifiedName(NameVisibility name_visibility) const {
ASSERT(name_visibility != kInternalName); // We never request it.
+ // If |this| is the generated asynchronous body closure, use the
+ // name of the parent function.
+ Function& fun = Function::Handle(raw());
+ if (fun.IsClosureFunction()) {
+ // Sniff the parent function.
+ fun = fun.parent_function();
+ ASSERT(!fun.IsNull());
+ if (!fun.IsAsyncGenerator() && !fun.IsAsyncFunction()) {
rmacnak 2017/02/10 21:27:14 Do this for a sync generator as well?
Cutch 2017/02/11 00:02:39 Done.
+ // Parent function is not the generator of an asynchronous body closure,
+ // start at |this|.
+ fun = raw();
+ }
+ }
// A function's scrubbed name and its user visible name are identical.
- String& result = String::Handle(UserVisibleName());
+ String& result = String::Handle(fun.UserVisibleName());
if (IsClosureFunction()) {
- Function& fun = Function::Handle(raw());
while (fun.IsLocalFunction() && !fun.IsImplicitClosureFunction()) {
fun = fun.parent_function();
result = String::Concat(Symbols::Dot(), result, Heap::kOld);
@@ -22418,6 +22430,10 @@ const char* StackTrace::ToCStringInternal(const StackTrace& stack_trace_in,
} else if (code.raw() ==
StubCode::AsynchronousGapMarker_entry()->code()) {
buffer.AddString("<asynchronous suspension>\n");
+ // The frame immediately after the asynchronous gap marker is the
+ // identical to the frame above the marker. Skip the frame to enhance
+ // the readability of the trace.
+ i++;
} else {
ASSERT(code.IsFunctionCode());
intptr_t pc_offset = Smi::Value(stack_trace.PcOffsetAtFrame(i));

Powered by Google App Engine
This is Rietveld 408576698