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

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

Issue 2603383004: Sane asynchronous debugging and stack traces (Closed)
Patch Set: rebase Created 3 years, 11 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/object.h ('k') | runtime/vm/parser.cc » ('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 10641 matching lines...) Expand 10 before | Expand all | Expand 10 after
10652 &result.raw_ptr()->patch_classes_, 10652 &result.raw_ptr()->patch_classes_,
10653 GrowableObjectArray::New(Object::empty_array(), Heap::kOld)); 10653 GrowableObjectArray::New(Object::empty_array(), Heap::kOld));
10654 result.StorePointer(&result.raw_ptr()->imports_, Object::empty_array().raw()); 10654 result.StorePointer(&result.raw_ptr()->imports_, Object::empty_array().raw());
10655 result.StorePointer(&result.raw_ptr()->exports_, Object::empty_array().raw()); 10655 result.StorePointer(&result.raw_ptr()->exports_, Object::empty_array().raw());
10656 result.StorePointer(&result.raw_ptr()->loaded_scripts_, Array::null()); 10656 result.StorePointer(&result.raw_ptr()->loaded_scripts_, Array::null());
10657 result.StorePointer(&result.raw_ptr()->load_error_, Instance::null()); 10657 result.StorePointer(&result.raw_ptr()->load_error_, Instance::null());
10658 result.set_native_entry_resolver(NULL); 10658 result.set_native_entry_resolver(NULL);
10659 result.set_native_entry_symbol_resolver(NULL); 10659 result.set_native_entry_symbol_resolver(NULL);
10660 result.set_is_in_fullsnapshot(false); 10660 result.set_is_in_fullsnapshot(false);
10661 result.StoreNonPointer(&result.raw_ptr()->corelib_imported_, true); 10661 result.StoreNonPointer(&result.raw_ptr()->corelib_imported_, true);
10662 result.set_debuggable(!dart_private_scheme); 10662 if (dart_private_scheme) {
10663 // Never debug dart:_ libraries.
10664 result.set_debuggable(false);
10665 } else if (dart_scheme) {
10666 // Only debug dart: libraries if we have been requested to show invisible
10667 // frames.
10668 result.set_debuggable(FLAG_show_invisible_frames);
10669 } else {
10670 // Default to debuggable for all other libraries.
10671 result.set_debuggable(true);
10672 }
10663 result.set_is_dart_scheme(dart_scheme); 10673 result.set_is_dart_scheme(dart_scheme);
10664 result.StoreNonPointer(&result.raw_ptr()->load_state_, 10674 result.StoreNonPointer(&result.raw_ptr()->load_state_,
10665 RawLibrary::kAllocated); 10675 RawLibrary::kAllocated);
10666 result.StoreNonPointer(&result.raw_ptr()->index_, -1); 10676 result.StoreNonPointer(&result.raw_ptr()->index_, -1);
10667 const intptr_t kInitialNameCacheSize = 64; 10677 const intptr_t kInitialNameCacheSize = 64;
10668 result.InitResolvedNamesCache(kInitialNameCacheSize); 10678 result.InitResolvedNamesCache(kInitialNameCacheSize);
10669 result.InitClassDictionary(); 10679 result.InitClassDictionary();
10670 result.InitImportList(); 10680 result.InitImportList();
10671 result.AllocatePrivateKey(); 10681 result.AllocatePrivateKey();
10672 if (import_core_lib) { 10682 if (import_core_lib) {
(...skipping 3386 matching lines...) Expand 10 before | Expand all | Expand 10 after
14059 return Code::null(); 14069 return Code::null();
14060 } 14070 }
14061 const Array& array = Array::Handle(raw_ptr()->static_calls_target_table_); 14071 const Array& array = Array::Handle(raw_ptr()->static_calls_target_table_);
14062 Code& code = Code::Handle(); 14072 Code& code = Code::Handle();
14063 code ^= array.At(i + kSCallTableCodeEntry); 14073 code ^= array.At(i + kSCallTableCodeEntry);
14064 return code.raw(); 14074 return code.raw();
14065 #endif 14075 #endif
14066 } 14076 }
14067 14077
14068 14078
14079 void Code::SetAwaitTokenPositions(const Array& await_token_positions) const {
14080 #if defined(DART_PRECOMPILED_RUNTIME)
14081 UNREACHABLE();
14082 #else
14083 ASSERT(await_token_positions.IsOld());
14084 StorePointer(&raw_ptr()->await_token_positions_, await_token_positions.raw());
14085 #endif
14086 }
14087
14088
14069 void Code::SetStaticCallTargetCodeAt(uword pc, const Code& code) const { 14089 void Code::SetStaticCallTargetCodeAt(uword pc, const Code& code) const {
14070 #if defined(DART_PRECOMPILED_RUNTIME) 14090 #if defined(DART_PRECOMPILED_RUNTIME)
14071 UNREACHABLE(); 14091 UNREACHABLE();
14072 #else 14092 #else
14073 const intptr_t i = BinarySearchInSCallTable(pc); 14093 const intptr_t i = BinarySearchInSCallTable(pc);
14074 ASSERT(i >= 0); 14094 ASSERT(i >= 0);
14075 const Array& array = Array::Handle(raw_ptr()->static_calls_target_table_); 14095 const Array& array = Array::Handle(raw_ptr()->static_calls_target_table_);
14076 ASSERT(code.IsNull() || 14096 ASSERT(code.IsNull() ||
14077 (code.function() == array.At(i + kSCallTableFunctionEntry))); 14097 (code.function() == array.At(i + kSCallTableFunctionEntry)));
14078 array.SetAt(i + kSCallTableCodeEntry, code); 14098 array.SetAt(i + kSCallTableCodeEntry, code);
(...skipping 8539 matching lines...) Expand 10 before | Expand all | Expand 10 after
22618 const char* StackTrace::ToCStringInternal(intptr_t* frame_index, 22638 const char* StackTrace::ToCStringInternal(intptr_t* frame_index,
22619 intptr_t max_frames) const { 22639 intptr_t max_frames) const {
22620 Zone* zone = Thread::Current()->zone(); 22640 Zone* zone = Thread::Current()->zone();
22621 Function& function = Function::Handle(); 22641 Function& function = Function::Handle();
22622 Code& code = Code::Handle(); 22642 Code& code = Code::Handle();
22623 // Iterate through the stack frames and create C string description 22643 // Iterate through the stack frames and create C string description
22624 // for each frame. 22644 // for each frame.
22625 intptr_t total_len = 0; 22645 intptr_t total_len = 0;
22626 GrowableArray<char*> frame_strings; 22646 GrowableArray<char*> frame_strings;
22627 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { 22647 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) {
22648 code = CodeAtFrame(i);
22628 function = FunctionAtFrame(i); 22649 function = FunctionAtFrame(i);
22629 if (function.IsNull()) { 22650 if (code.raw() == StubCode::AsynchronousGapMarker_entry()->code()) {
22651 const char* kAsynchronousGap = "<asynchronous suspension>\n";
22652 intptr_t asynchronous_gap_len = strlen(kAsynchronousGap) + 1;
22653 char* chars = zone->Alloc<char>(asynchronous_gap_len);
22654 OS::SNPrint(chars, asynchronous_gap_len, "%s", kAsynchronousGap);
22655 frame_strings.Add(chars);
22656 total_len += asynchronous_gap_len;
22657 } else if (function.IsNull()) {
22630 // Check for a null function, which indicates a gap in a StackOverflow or 22658 // Check for a null function, which indicates a gap in a StackOverflow or
22631 // OutOfMemory trace. 22659 // OutOfMemory trace.
22632 if ((i < (Length() - 1)) && 22660 if ((i < (Length() - 1)) &&
22633 (FunctionAtFrame(i + 1) != Function::null())) { 22661 (FunctionAtFrame(i + 1) != Function::null())) {
22634 const char* kTruncated = "...\n...\n"; 22662 const char* kTruncated = "...\n...\n";
22635 intptr_t truncated_len = strlen(kTruncated) + 1; 22663 intptr_t truncated_len = strlen(kTruncated) + 1;
22636 char* chars = zone->Alloc<char>(truncated_len); 22664 char* chars = zone->Alloc<char>(truncated_len);
22637 OS::SNPrint(chars, truncated_len, "%s", kTruncated); 22665 OS::SNPrint(chars, truncated_len, "%s", kTruncated);
22638 frame_strings.Add(chars); 22666 frame_strings.Add(chars);
22639 total_len += truncated_len; 22667 total_len += truncated_len;
22640 ASSERT(PcOffsetAtFrame(i) != Smi::null()); 22668 ASSERT(PcOffsetAtFrame(i) != Smi::null());
22641 // To account for gap frames. 22669 // To account for gap frames.
22642 (*frame_index) += Smi::Value(PcOffsetAtFrame(i)); 22670 (*frame_index) += Smi::Value(PcOffsetAtFrame(i));
22643 } 22671 }
22644 } else { 22672 } else {
22645 code = CodeAtFrame(i);
22646 ASSERT(function.raw() == code.function()); 22673 ASSERT(function.raw() == code.function());
22647 uword pc = code.PayloadStart() + Smi::Value(PcOffsetAtFrame(i)); 22674 uword pc = code.PayloadStart() + Smi::Value(PcOffsetAtFrame(i));
22648 if (code.is_optimized() && expand_inlined() && 22675 if (code.is_optimized() && expand_inlined() &&
22649 !FLAG_precompiled_runtime) { 22676 !FLAG_precompiled_runtime) {
22650 // Traverse inlined frames. 22677 // Traverse inlined frames.
22651 for (InlinedFunctionsIterator it(code, pc); 22678 for (InlinedFunctionsIterator it(code, pc);
22652 !it.Done() && (*frame_index < max_frames); it.Advance()) { 22679 !it.Done() && (*frame_index < max_frames); it.Advance()) {
22653 function = it.function(); 22680 function = it.function();
22654 if (function.is_visible() || FLAG_show_invisible_frames) { 22681 if (function.is_visible() || FLAG_show_invisible_frames) {
22655 code = it.code(); 22682 code = it.code();
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
22999 return UserTag::null(); 23026 return UserTag::null();
23000 } 23027 }
23001 23028
23002 23029
23003 const char* UserTag::ToCString() const { 23030 const char* UserTag::ToCString() const {
23004 const String& tag_label = String::Handle(label()); 23031 const String& tag_label = String::Handle(label());
23005 return tag_label.ToCString(); 23032 return tag_label.ToCString();
23006 } 23033 }
23007 23034
23008 } // namespace dart 23035 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698