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

Unified Diff: runtime/vm/gdb_helpers.cc

Issue 2957843002: Add gdb helper functions for creating a handle and using ToCString with RawObjects. (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/stacktrace.cc ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/gdb_helpers.cc
diff --git a/runtime/vm/gdb_helpers.cc b/runtime/vm/gdb_helpers.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2a9ab6bb7480d5a9786dbf0df786aadec22f358a
--- /dev/null
+++ b/runtime/vm/gdb_helpers.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "vm/object.h"
+#include "vm/stack_frame.h"
+
+#include "lib/stacktrace.h"
+
+namespace dart {
+
+DART_NOINLINE
+void _printRawObject(RawObject* object) {
+ OS::PrintErr("%s\n", Object::Handle(object).ToCString());
+}
+
+
+DART_NOINLINE
+Object& _handle(RawObject* object) {
+ return Object::Handle(object);
+}
+
+
+// An utility method for convenient printing of dart stack traces when
+// inside 'gdb'. Note: This function will only work when there is a
+// valid exit frame information. It will not work when a breakpoint is
+// set in dart code and control is got inside 'gdb' without going through
+// the runtime or native transition stub.
+DART_NOINLINE
+void _printDartStackTrace() {
+ const StackTrace& stacktrace = GetCurrentStackTrace(0);
+ OS::PrintErr("=== Current Trace:\n%s===\n", stacktrace.ToCString());
+}
+
+
+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.
+void _printStackTrace() {
+ StackFrameIterator frames(StackFrameIterator::kDontValidateFrames,
+ Thread::Current(),
+ StackFrameIterator::kNoCrossThreadIteration);
+ StackFrame* frame = frames.NextFrame();
+ while (frame != NULL) {
+ OS::PrintErr("%s\n", frame->ToCString());
+ frame = frames.NextFrame();
+ }
+}
+
+
+class PrintObjectPointersVisitor : public ObjectPointerVisitor {
+ public:
+ PrintObjectPointersVisitor() : ObjectPointerVisitor(Isolate::Current()) {}
+
+ void VisitPointers(RawObject** first, RawObject** last) {
+ for (RawObject** p = first; p <= last; p++) {
+ Object& obj = Object::Handle(*p);
+ OS::PrintErr("%p: %s\n", p, obj.ToCString());
+ }
+ }
+};
+
+
+DART_NOINLINE
+void _printStackTraceWithLocals() {
+ PrintObjectPointersVisitor visitor;
+ StackFrameIterator frames(StackFrameIterator::kDontValidateFrames,
+ Thread::Current(),
+ StackFrameIterator::kNoCrossThreadIteration);
+ StackFrame* frame = frames.NextFrame();
+ while (frame != NULL) {
+ OS::PrintErr("%s\n", frame->ToCString());
+ frame->VisitObjectPointers(&visitor);
+ frame = frames.NextFrame();
+ }
+}
+
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.
+} // namespace dart
« no previous file with comments | « runtime/lib/stacktrace.cc ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698