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

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

Issue 2691213003: Reland 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/debugger.cc ('k') | tests/language/language.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7046 matching lines...) Expand 10 before | Expand all | Expand 10 after
7057 RawString* Function::UserVisibleName() const { 7057 RawString* Function::UserVisibleName() const {
7058 if (FLAG_show_internal_names) { 7058 if (FLAG_show_internal_names) {
7059 return name(); 7059 return name();
7060 } 7060 }
7061 return String::ScrubName(String::Handle(name())); 7061 return String::ScrubName(String::Handle(name()));
7062 } 7062 }
7063 7063
7064 7064
7065 RawString* Function::QualifiedName(NameVisibility name_visibility) const { 7065 RawString* Function::QualifiedName(NameVisibility name_visibility) const {
7066 ASSERT(name_visibility != kInternalName); // We never request it. 7066 ASSERT(name_visibility != kInternalName); // We never request it.
7067 // If |this| is the generated asynchronous body closure, use the
7068 // name of the parent function.
7069 Function& fun = Function::Handle(raw());
7070 if (fun.IsClosureFunction()) {
7071 // Sniff the parent function.
7072 fun = fun.parent_function();
7073 ASSERT(!fun.IsNull());
7074 if (!fun.IsAsyncGenerator() && !fun.IsAsyncFunction() &&
7075 !fun.IsSyncGenerator()) {
7076 // Parent function is not the generator of an asynchronous body closure,
7077 // start at |this|.
7078 fun = raw();
7079 }
7080 }
7067 // A function's scrubbed name and its user visible name are identical. 7081 // A function's scrubbed name and its user visible name are identical.
7068 String& result = String::Handle(UserVisibleName()); 7082 String& result = String::Handle(fun.UserVisibleName());
7069 if (IsClosureFunction()) { 7083 if (IsClosureFunction()) {
7070 Function& fun = Function::Handle(raw());
7071 while (fun.IsLocalFunction() && !fun.IsImplicitClosureFunction()) { 7084 while (fun.IsLocalFunction() && !fun.IsImplicitClosureFunction()) {
7072 fun = fun.parent_function(); 7085 fun = fun.parent_function();
7086 if (fun.IsAsyncClosure() || fun.IsSyncGenClosure() ||
7087 fun.IsAsyncGenClosure()) {
7088 // Skip the closure and use the real function name found in
7089 // the parent.
7090 fun = fun.parent_function();
7091 }
7073 result = String::Concat(Symbols::Dot(), result, Heap::kOld); 7092 result = String::Concat(Symbols::Dot(), result, Heap::kOld);
7074 result = String::Concat(String::Handle(fun.UserVisibleName()), result, 7093 result = String::Concat(String::Handle(fun.UserVisibleName()), result,
7075 Heap::kOld); 7094 Heap::kOld);
7076 } 7095 }
7077 } 7096 }
7078 const Class& cls = Class::Handle(Owner()); 7097 const Class& cls = Class::Handle(Owner());
7079 if (!cls.IsTopLevel()) { 7098 if (!cls.IsTopLevel()) {
7080 result = String::Concat(Symbols::Dot(), result, Heap::kOld); 7099 result = String::Concat(Symbols::Dot(), result, Heap::kOld);
7081 const String& cls_name = String::Handle(name_visibility == kScrubbedName 7100 const String& cls_name = String::Handle(name_visibility == kScrubbedName
7082 ? cls.ScrubbedName() 7101 ? cls.ScrubbedName()
(...skipping 15387 matching lines...) Expand 10 before | Expand all | Expand 10 after
22470 if ((i < (stack_trace.Length() - 1)) && 22489 if ((i < (stack_trace.Length() - 1)) &&
22471 (stack_trace.CodeAtFrame(i + 1) != Code::null())) { 22490 (stack_trace.CodeAtFrame(i + 1) != Code::null())) {
22472 buffer.AddString("...\n...\n"); 22491 buffer.AddString("...\n...\n");
22473 ASSERT(stack_trace.PcOffsetAtFrame(i) != Smi::null()); 22492 ASSERT(stack_trace.PcOffsetAtFrame(i) != Smi::null());
22474 // To account for gap frames. 22493 // To account for gap frames.
22475 (*frame_index) += Smi::Value(stack_trace.PcOffsetAtFrame(i)); 22494 (*frame_index) += Smi::Value(stack_trace.PcOffsetAtFrame(i));
22476 } 22495 }
22477 } else if (code.raw() == 22496 } else if (code.raw() ==
22478 StubCode::AsynchronousGapMarker_entry()->code()) { 22497 StubCode::AsynchronousGapMarker_entry()->code()) {
22479 buffer.AddString("<asynchronous suspension>\n"); 22498 buffer.AddString("<asynchronous suspension>\n");
22499 // The frame immediately after the asynchronous gap marker is the
22500 // identical to the frame above the marker. Skip the frame to enhance
22501 // the readability of the trace.
22502 i++;
22480 } else { 22503 } else {
22481 ASSERT(code.IsFunctionCode()); 22504 ASSERT(code.IsFunctionCode());
22482 intptr_t pc_offset = Smi::Value(stack_trace.PcOffsetAtFrame(i)); 22505 intptr_t pc_offset = Smi::Value(stack_trace.PcOffsetAtFrame(i));
22483 if (code.is_optimized() && stack_trace.expand_inlined()) { 22506 if (code.is_optimized() && stack_trace.expand_inlined()) {
22484 code.GetInlinedFunctionsAtReturnAddress(pc_offset, &inlined_functions, 22507 code.GetInlinedFunctionsAtReturnAddress(pc_offset, &inlined_functions,
22485 &inlined_token_positions); 22508 &inlined_token_positions);
22486 ASSERT(inlined_functions.length() >= 1); 22509 ASSERT(inlined_functions.length() >= 1);
22487 for (intptr_t j = inlined_functions.length() - 1; j >= 0; j--) { 22510 for (intptr_t j = inlined_functions.length() - 1; j >= 0; j--) {
22488 if (inlined_functions[j]->is_visible() || 22511 if (inlined_functions[j]->is_visible() ||
22489 FLAG_show_invisible_frames) { 22512 FLAG_show_invisible_frames) {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
22826 return UserTag::null(); 22849 return UserTag::null();
22827 } 22850 }
22828 22851
22829 22852
22830 const char* UserTag::ToCString() const { 22853 const char* UserTag::ToCString() const {
22831 const String& tag_label = String::Handle(label()); 22854 const String& tag_label = String::Handle(label());
22832 return tag_label.ToCString(); 22855 return tag_label.ToCString();
22833 } 22856 }
22834 22857
22835 } // namespace dart 22858 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698