OLD | NEW |
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 22686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22697 function_name.ToCString(), url.ToCString()); | 22697 function_name.ToCString(), url.ToCString()); |
22698 } | 22698 } |
22699 frame_strings->Add(chars); | 22699 frame_strings->Add(chars); |
22700 return strlen(chars); | 22700 return strlen(chars); |
22701 } | 22701 } |
22702 | 22702 |
22703 | 22703 |
22704 const char* StackTrace::ToCStringInternal(intptr_t* frame_index, | 22704 const char* StackTrace::ToCStringInternal(intptr_t* frame_index, |
22705 intptr_t max_frames) const { | 22705 intptr_t max_frames) const { |
22706 Zone* zone = Thread::Current()->zone(); | 22706 Zone* zone = Thread::Current()->zone(); |
22707 Function& function = Function::Handle(); | 22707 Function& function = Function::Handle(zone); |
22708 Code& code = Code::Handle(); | 22708 Code& code = Code::Handle(zone); |
22709 // Iterate through the stack frames and create C string description | 22709 // Iterate through the stack frames and create C string description |
22710 // for each frame. | 22710 // for each frame. |
22711 intptr_t total_len = 0; | 22711 intptr_t total_len = 0; |
22712 GrowableArray<char*> frame_strings; | 22712 GrowableArray<char*> frame_strings; |
22713 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { | 22713 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { |
| 22714 code = CodeAtFrame(i); |
22714 function = FunctionAtFrame(i); | 22715 function = FunctionAtFrame(i); |
22715 if (function.IsNull()) { | 22716 if (code.raw() == StubCode::AsynchronousGapMarker_entry()->code()) { |
| 22717 const char* kAsynchronousGap = "<asynchronous suspension>\n"; |
| 22718 intptr_t asynchronous_gap_len = strlen(kAsynchronousGap) + 1; |
| 22719 frame_strings.Add(const_cast<char*>(kAsynchronousGap)); |
| 22720 total_len += asynchronous_gap_len; |
| 22721 } else if (function.IsNull()) { |
22716 // Check for a null function, which indicates a gap in a StackOverflow or | 22722 // Check for a null function, which indicates a gap in a StackOverflow or |
22717 // OutOfMemory trace. | 22723 // OutOfMemory trace. |
22718 if ((i < (Length() - 1)) && | 22724 if ((i < (Length() - 1)) && |
22719 (FunctionAtFrame(i + 1) != Function::null())) { | 22725 (FunctionAtFrame(i + 1) != Function::null())) { |
22720 const char* kTruncated = "...\n...\n"; | 22726 const char* kTruncated = "...\n...\n"; |
22721 intptr_t truncated_len = strlen(kTruncated) + 1; | 22727 intptr_t truncated_len = strlen(kTruncated) + 1; |
22722 char* chars = zone->Alloc<char>(truncated_len); | 22728 frame_strings.Add(const_cast<char*>(kTruncated)); |
22723 OS::SNPrint(chars, truncated_len, "%s", kTruncated); | |
22724 frame_strings.Add(chars); | |
22725 total_len += truncated_len; | 22729 total_len += truncated_len; |
22726 ASSERT(PcOffsetAtFrame(i) != Smi::null()); | 22730 ASSERT(PcOffsetAtFrame(i) != Smi::null()); |
22727 // To account for gap frames. | 22731 // To account for gap frames. |
22728 (*frame_index) += Smi::Value(PcOffsetAtFrame(i)); | 22732 (*frame_index) += Smi::Value(PcOffsetAtFrame(i)); |
22729 } | 22733 } |
22730 } else { | 22734 } else { |
22731 code = CodeAtFrame(i); | |
22732 ASSERT(function.raw() == code.function()); | 22735 ASSERT(function.raw() == code.function()); |
22733 uword pc = code.PayloadStart() + Smi::Value(PcOffsetAtFrame(i)); | 22736 uword pc = code.PayloadStart() + Smi::Value(PcOffsetAtFrame(i)); |
22734 if (code.is_optimized() && expand_inlined() && | 22737 if (code.is_optimized() && expand_inlined() && |
22735 !FLAG_precompiled_runtime) { | 22738 !FLAG_precompiled_runtime) { |
22736 // Traverse inlined frames. | 22739 // Traverse inlined frames. |
22737 for (InlinedFunctionsIterator it(code, pc); | 22740 for (InlinedFunctionsIterator it(code, pc); |
22738 !it.Done() && (*frame_index < max_frames); it.Advance()) { | 22741 !it.Done() && (*frame_index < max_frames); it.Advance()) { |
22739 function = it.function(); | 22742 function = it.function(); |
22740 if (function.is_visible() || FLAG_show_invisible_frames) { | 22743 if (function.is_visible() || FLAG_show_invisible_frames) { |
22741 code = it.code(); | 22744 code = it.code(); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23085 return UserTag::null(); | 23088 return UserTag::null(); |
23086 } | 23089 } |
23087 | 23090 |
23088 | 23091 |
23089 const char* UserTag::ToCString() const { | 23092 const char* UserTag::ToCString() const { |
23090 const String& tag_label = String::Handle(label()); | 23093 const String& tag_label = String::Handle(label()); |
23091 return tag_label.ToCString(); | 23094 return tag_label.ToCString(); |
23092 } | 23095 } |
23093 | 23096 |
23094 } // namespace dart | 23097 } // namespace dart |
OLD | NEW |