Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 #include "vm/object.h" | |
| 6 #include "vm/stack_frame.h" | |
| 7 | |
| 8 #include "lib/stacktrace.h" | |
| 9 | |
| 10 namespace dart { | |
| 11 | |
| 12 DART_NOINLINE | |
| 13 void _printRawObject(RawObject* object) { | |
| 14 OS::PrintErr("%s\n", Object::Handle(object).ToCString()); | |
| 15 } | |
| 16 | |
| 17 | |
| 18 DART_NOINLINE | |
| 19 Object& _handle(RawObject* object) { | |
| 20 return Object::Handle(object); | |
| 21 } | |
| 22 | |
| 23 | |
| 24 // An utility method for convenient printing of dart stack traces when | |
| 25 // inside 'gdb'. Note: This function will only work when there is a | |
| 26 // valid exit frame information. It will not work when a breakpoint is | |
| 27 // set in dart code and control is got inside 'gdb' without going through | |
| 28 // the runtime or native transition stub. | |
| 29 DART_NOINLINE | |
| 30 void _printDartStackTrace() { | |
| 31 const StackTrace& stacktrace = GetCurrentStackTrace(0); | |
| 32 OS::PrintErr("=== Current Trace:\n%s===\n", stacktrace.ToCString()); | |
| 33 } | |
| 34 | |
| 35 | |
| 36 DART_NOINLINE | |
|
siva
2017/06/26 20:19:05
Seems to have lost the comment
// Like _printCurre
rmacnak
2017/06/28 00:03:00
Done.
| |
| 37 void _printStackTrace() { | |
| 38 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, | |
| 39 Thread::Current(), | |
| 40 StackFrameIterator::kNoCrossThreadIteration); | |
| 41 StackFrame* frame = frames.NextFrame(); | |
| 42 while (frame != NULL) { | |
| 43 OS::PrintErr("%s\n", frame->ToCString()); | |
| 44 frame = frames.NextFrame(); | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 | |
| 49 class PrintObjectPointersVisitor : public ObjectPointerVisitor { | |
| 50 public: | |
| 51 PrintObjectPointersVisitor() : ObjectPointerVisitor(Isolate::Current()) {} | |
| 52 | |
| 53 void VisitPointers(RawObject** first, RawObject** last) { | |
| 54 for (RawObject** p = first; p <= last; p++) { | |
| 55 Object& obj = Object::Handle(*p); | |
| 56 OS::PrintErr("%p: %s\n", p, obj.ToCString()); | |
| 57 } | |
| 58 } | |
| 59 }; | |
| 60 | |
| 61 | |
| 62 DART_NOINLINE | |
| 63 void _printStackTraceWithLocals() { | |
| 64 PrintObjectPointersVisitor visitor; | |
| 65 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, | |
| 66 Thread::Current(), | |
| 67 StackFrameIterator::kNoCrossThreadIteration); | |
| 68 StackFrame* frame = frames.NextFrame(); | |
| 69 while (frame != NULL) { | |
| 70 OS::PrintErr("%s\n", frame->ToCString()); | |
| 71 frame->VisitObjectPointers(&visitor); | |
| 72 frame = frames.NextFrame(); | |
| 73 } | |
| 74 } | |
| 75 | |
|
siva
2017/06/26 20:19:05
Should this entire file be wrapped under #if !defi
zra
2017/06/26 20:31:23
+1
rmacnak
2017/06/28 00:03:00
Done.
| |
| 76 } // namespace dart | |
| OLD | NEW |