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

Side by Side Diff: runtime/vm/object.cc

Issue 2690683002: Improvements to causal async stack traces (Closed)
Patch Set: rmacnak review 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/become.h" 10 #include "vm/become.h"
(...skipping 7042 matching lines...) Expand 10 before | Expand all | Expand 10 after
7053 RawString* Function::UserVisibleName() const { 7053 RawString* Function::UserVisibleName() const {
7054 if (FLAG_show_internal_names) { 7054 if (FLAG_show_internal_names) {
7055 return name(); 7055 return name();
7056 } 7056 }
7057 return String::ScrubName(String::Handle(name())); 7057 return String::ScrubName(String::Handle(name()));
7058 } 7058 }
7059 7059
7060 7060
7061 RawString* Function::QualifiedName(NameVisibility name_visibility) const { 7061 RawString* Function::QualifiedName(NameVisibility name_visibility) const {
7062 ASSERT(name_visibility != kInternalName); // We never request it. 7062 ASSERT(name_visibility != kInternalName); // We never request it.
7063 // If |this| is the generated asynchronous body closure, use the
7064 // name of the parent function.
7065 Function& fun = Function::Handle(raw());
7066 if (fun.IsClosureFunction()) {
7067 // Sniff the parent function.
7068 fun = fun.parent_function();
7069 ASSERT(!fun.IsNull());
7070 if (!fun.IsAsyncGenerator() && !fun.IsAsyncFunction() &&
7071 !fun.IsSyncGenerator()) {
7072 // Parent function is not the generator of an asynchronous body closure,
7073 // start at |this|.
7074 fun = raw();
7075 }
7076 }
7063 // A function's scrubbed name and its user visible name are identical. 7077 // A function's scrubbed name and its user visible name are identical.
7064 String& result = String::Handle(UserVisibleName()); 7078 String& result = String::Handle(fun.UserVisibleName());
7065 if (IsClosureFunction()) { 7079 if (IsClosureFunction()) {
7066 Function& fun = Function::Handle(raw());
7067 while (fun.IsLocalFunction() && !fun.IsImplicitClosureFunction()) { 7080 while (fun.IsLocalFunction() && !fun.IsImplicitClosureFunction()) {
7068 fun = fun.parent_function(); 7081 fun = fun.parent_function();
7082 if (fun.IsAsyncClosure() || fun.IsSyncGenClosure() ||
7083 fun.IsAsyncGenClosure()) {
7084 // Skip the closure and use the real function name found in
7085 // the parent.
7086 fun = fun.parent_function();
7087 }
7069 result = String::Concat(Symbols::Dot(), result, Heap::kOld); 7088 result = String::Concat(Symbols::Dot(), result, Heap::kOld);
7070 result = String::Concat(String::Handle(fun.UserVisibleName()), result, 7089 result = String::Concat(String::Handle(fun.UserVisibleName()), result,
7071 Heap::kOld); 7090 Heap::kOld);
7072 } 7091 }
7073 } 7092 }
7074 const Class& cls = Class::Handle(Owner()); 7093 const Class& cls = Class::Handle(Owner());
7075 if (!cls.IsTopLevel()) { 7094 if (!cls.IsTopLevel()) {
7076 result = String::Concat(Symbols::Dot(), result, Heap::kOld); 7095 result = String::Concat(Symbols::Dot(), result, Heap::kOld);
7077 const String& cls_name = String::Handle(name_visibility == kScrubbedName 7096 const String& cls_name = String::Handle(name_visibility == kScrubbedName
7078 ? cls.ScrubbedName() 7097 ? cls.ScrubbedName()
(...skipping 15332 matching lines...) Expand 10 before | Expand all | Expand 10 after
22411 if ((i < (stack_trace.Length() - 1)) && 22430 if ((i < (stack_trace.Length() - 1)) &&
22412 (stack_trace.CodeAtFrame(i + 1) != Code::null())) { 22431 (stack_trace.CodeAtFrame(i + 1) != Code::null())) {
22413 buffer.AddString("...\n...\n"); 22432 buffer.AddString("...\n...\n");
22414 ASSERT(stack_trace.PcOffsetAtFrame(i) != Smi::null()); 22433 ASSERT(stack_trace.PcOffsetAtFrame(i) != Smi::null());
22415 // To account for gap frames. 22434 // To account for gap frames.
22416 (*frame_index) += Smi::Value(stack_trace.PcOffsetAtFrame(i)); 22435 (*frame_index) += Smi::Value(stack_trace.PcOffsetAtFrame(i));
22417 } 22436 }
22418 } else if (code.raw() == 22437 } else if (code.raw() ==
22419 StubCode::AsynchronousGapMarker_entry()->code()) { 22438 StubCode::AsynchronousGapMarker_entry()->code()) {
22420 buffer.AddString("<asynchronous suspension>\n"); 22439 buffer.AddString("<asynchronous suspension>\n");
22440 // The frame immediately after the asynchronous gap marker is the
22441 // identical to the frame above the marker. Skip the frame to enhance
22442 // the readability of the trace.
22443 i++;
22421 } else { 22444 } else {
22422 ASSERT(code.IsFunctionCode()); 22445 ASSERT(code.IsFunctionCode());
22423 intptr_t pc_offset = Smi::Value(stack_trace.PcOffsetAtFrame(i)); 22446 intptr_t pc_offset = Smi::Value(stack_trace.PcOffsetAtFrame(i));
22424 if (code.is_optimized() && stack_trace.expand_inlined() && 22447 if (code.is_optimized() && stack_trace.expand_inlined() &&
22425 !FLAG_precompiled_mode) { 22448 !FLAG_precompiled_mode) {
22426 code.GetInlinedFunctionsAtReturnAddress(pc_offset, &inlined_functions, 22449 code.GetInlinedFunctionsAtReturnAddress(pc_offset, &inlined_functions,
22427 &inlined_token_positions); 22450 &inlined_token_positions);
22428 ASSERT(inlined_functions.length() >= 1); 22451 ASSERT(inlined_functions.length() >= 1);
22429 for (intptr_t j = inlined_functions.length() - 1; j >= 0; j--) { 22452 for (intptr_t j = inlined_functions.length() - 1; j >= 0; j--) {
22430 if (inlined_functions[j]->is_visible() || 22453 if (inlined_functions[j]->is_visible() ||
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
22768 return UserTag::null(); 22791 return UserTag::null();
22769 } 22792 }
22770 22793
22771 22794
22772 const char* UserTag::ToCString() const { 22795 const char* UserTag::ToCString() const {
22773 const String& tag_label = String::Handle(label()); 22796 const String& tag_label = String::Handle(label());
22774 return tag_label.ToCString(); 22797 return tag_label.ToCString();
22775 } 22798 }
22776 22799
22777 } // namespace dart 22800 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698