Chromium Code Reviews| 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 22613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 22624 function_name.ToCString(), url.ToCString()); | 22624 function_name.ToCString(), url.ToCString()); |
| 22625 } | 22625 } |
| 22626 frame_strings->Add(chars); | 22626 frame_strings->Add(chars); |
| 22627 return strlen(chars); | 22627 return strlen(chars); |
| 22628 } | 22628 } |
| 22629 | 22629 |
| 22630 | 22630 |
| 22631 const char* StackTrace::ToCStringInternal(intptr_t* frame_index, | 22631 const char* StackTrace::ToCStringInternal(intptr_t* frame_index, |
| 22632 intptr_t max_frames) const { | 22632 intptr_t max_frames) const { |
| 22633 Zone* zone = Thread::Current()->zone(); | 22633 Zone* zone = Thread::Current()->zone(); |
| 22634 Function& function = Function::Handle(); | 22634 Function& function = Function::Handle(); |
|
rmacnak
2017/01/26 18:05:58
Handle(zone)
Cutch
2017/01/31 23:45:31
Done.
| |
| 22635 Code& code = Code::Handle(); | 22635 Code& code = Code::Handle(); |
| 22636 // Iterate through the stack frames and create C string description | 22636 // Iterate through the stack frames and create C string description |
| 22637 // for each frame. | 22637 // for each frame. |
| 22638 intptr_t total_len = 0; | 22638 intptr_t total_len = 0; |
| 22639 GrowableArray<char*> frame_strings; | 22639 GrowableArray<char*> frame_strings; |
| 22640 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { | 22640 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { |
| 22641 code = CodeAtFrame(i); | |
| 22641 function = FunctionAtFrame(i); | 22642 function = FunctionAtFrame(i); |
| 22642 if (function.IsNull()) { | 22643 if (code.raw() == StubCode::AsynchronousGapMarker_entry()->code()) { |
| 22644 const char* kAsynchronousGap = "<asynchronous suspension>\n"; | |
|
rmacnak
2017/01/26 18:05:58
No need to dup the string.
Cutch
2017/01/31 23:45:31
Done.
| |
| 22645 intptr_t asynchronous_gap_len = strlen(kAsynchronousGap) + 1; | |
| 22646 char* chars = zone->Alloc<char>(asynchronous_gap_len); | |
| 22647 OS::SNPrint(chars, asynchronous_gap_len, "%s", kAsynchronousGap); | |
| 22648 frame_strings.Add(chars); | |
| 22649 total_len += asynchronous_gap_len; | |
| 22650 } else if (function.IsNull()) { | |
| 22643 // Check for a null function, which indicates a gap in a StackOverflow or | 22651 // Check for a null function, which indicates a gap in a StackOverflow or |
| 22644 // OutOfMemory trace. | 22652 // OutOfMemory trace. |
| 22645 if ((i < (Length() - 1)) && | 22653 if ((i < (Length() - 1)) && |
| 22646 (FunctionAtFrame(i + 1) != Function::null())) { | 22654 (FunctionAtFrame(i + 1) != Function::null())) { |
| 22647 const char* kTruncated = "...\n...\n"; | 22655 const char* kTruncated = "...\n...\n"; |
| 22648 intptr_t truncated_len = strlen(kTruncated) + 1; | 22656 intptr_t truncated_len = strlen(kTruncated) + 1; |
| 22649 char* chars = zone->Alloc<char>(truncated_len); | 22657 char* chars = zone->Alloc<char>(truncated_len); |
| 22650 OS::SNPrint(chars, truncated_len, "%s", kTruncated); | 22658 OS::SNPrint(chars, truncated_len, "%s", kTruncated); |
|
rmacnak
2017/01/26 18:05:58
No need to dup the string.
Cutch
2017/01/31 23:45:31
Done.
| |
| 22651 frame_strings.Add(chars); | 22659 frame_strings.Add(chars); |
| 22652 total_len += truncated_len; | 22660 total_len += truncated_len; |
| 22653 ASSERT(PcOffsetAtFrame(i) != Smi::null()); | 22661 ASSERT(PcOffsetAtFrame(i) != Smi::null()); |
| 22654 // To account for gap frames. | 22662 // To account for gap frames. |
| 22655 (*frame_index) += Smi::Value(PcOffsetAtFrame(i)); | 22663 (*frame_index) += Smi::Value(PcOffsetAtFrame(i)); |
| 22656 } | 22664 } |
| 22657 } else { | 22665 } else { |
| 22658 code = CodeAtFrame(i); | |
| 22659 ASSERT(function.raw() == code.function()); | 22666 ASSERT(function.raw() == code.function()); |
| 22660 uword pc = code.PayloadStart() + Smi::Value(PcOffsetAtFrame(i)); | 22667 uword pc = code.PayloadStart() + Smi::Value(PcOffsetAtFrame(i)); |
| 22661 if (code.is_optimized() && expand_inlined() && | 22668 if (code.is_optimized() && expand_inlined() && |
| 22662 !FLAG_precompiled_runtime) { | 22669 !FLAG_precompiled_runtime) { |
| 22663 // Traverse inlined frames. | 22670 // Traverse inlined frames. |
| 22664 for (InlinedFunctionsIterator it(code, pc); | 22671 for (InlinedFunctionsIterator it(code, pc); |
| 22665 !it.Done() && (*frame_index < max_frames); it.Advance()) { | 22672 !it.Done() && (*frame_index < max_frames); it.Advance()) { |
| 22666 function = it.function(); | 22673 function = it.function(); |
| 22667 if (function.is_visible() || FLAG_show_invisible_frames) { | 22674 if (function.is_visible() || FLAG_show_invisible_frames) { |
| 22668 code = it.code(); | 22675 code = it.code(); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 23012 return UserTag::null(); | 23019 return UserTag::null(); |
| 23013 } | 23020 } |
| 23014 | 23021 |
| 23015 | 23022 |
| 23016 const char* UserTag::ToCString() const { | 23023 const char* UserTag::ToCString() const { |
| 23017 const String& tag_label = String::Handle(label()); | 23024 const String& tag_label = String::Handle(label()); |
| 23018 return tag_label.ToCString(); | 23025 return tag_label.ToCString(); |
| 23019 } | 23026 } |
| 23020 | 23027 |
| 23021 } // namespace dart | 23028 } // namespace dart |
| OLD | NEW |