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

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

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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/gc_sweeper.cc ('k') | runtime/vm/globals.h » ('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) 2017, the Dart project authors. Please see the AUTHORS file 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 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 "lib/stacktrace.h" 5 #include "lib/stacktrace.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/stack_frame.h" 7 #include "vm/stack_frame.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
11 #if !defined(PRODUCT) 11 #if !defined(PRODUCT)
12 12
13 DART_EXPORT 13 DART_EXPORT
14 void _printRawObject(RawObject* object) { 14 void _printRawObject(RawObject* object) {
15 OS::PrintErr("%s\n", Object::Handle(object).ToCString()); 15 OS::PrintErr("%s\n", Object::Handle(object).ToCString());
16 } 16 }
17 17
18
19 DART_EXPORT 18 DART_EXPORT
20 Object* _handle(RawObject* object) { 19 Object* _handle(RawObject* object) {
21 return &Object::Handle(object); 20 return &Object::Handle(object);
22 } 21 }
23 22
24
25 // An utility method for convenient printing of dart stack traces when 23 // An utility method for convenient printing of dart stack traces when
26 // inside 'gdb'. Note: This function will only work when there is a 24 // inside 'gdb'. Note: This function will only work when there is a
27 // valid exit frame information. It will not work when a breakpoint is 25 // valid exit frame information. It will not work when a breakpoint is
28 // set in dart code and control is got inside 'gdb' without going through 26 // set in dart code and control is got inside 'gdb' without going through
29 // the runtime or native transition stub. 27 // the runtime or native transition stub.
30 DART_EXPORT 28 DART_EXPORT
31 void _printDartStackTrace() { 29 void _printDartStackTrace() {
32 const StackTrace& stacktrace = GetCurrentStackTrace(0); 30 const StackTrace& stacktrace = GetCurrentStackTrace(0);
33 OS::PrintErr("=== Current Trace:\n%s===\n", stacktrace.ToCString()); 31 OS::PrintErr("=== Current Trace:\n%s===\n", stacktrace.ToCString());
34 } 32 }
35 33
36
37 // Like _printDartStackTrace, but works in a NoSafepointScope. Use it if you're 34 // Like _printDartStackTrace, but works in a NoSafepointScope. Use it if you're
38 // in the middle of a GC or interested in stub frames. 35 // in the middle of a GC or interested in stub frames.
39 DART_EXPORT 36 DART_EXPORT
40 void _printStackTrace() { 37 void _printStackTrace() {
41 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, 38 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames,
42 Thread::Current(), 39 Thread::Current(),
43 StackFrameIterator::kNoCrossThreadIteration); 40 StackFrameIterator::kNoCrossThreadIteration);
44 StackFrame* frame = frames.NextFrame(); 41 StackFrame* frame = frames.NextFrame();
45 while (frame != NULL) { 42 while (frame != NULL) {
46 OS::PrintErr("%s\n", frame->ToCString()); 43 OS::PrintErr("%s\n", frame->ToCString());
47 frame = frames.NextFrame(); 44 frame = frames.NextFrame();
48 } 45 }
49 } 46 }
50 47
51
52 class PrintObjectPointersVisitor : public ObjectPointerVisitor { 48 class PrintObjectPointersVisitor : public ObjectPointerVisitor {
53 public: 49 public:
54 PrintObjectPointersVisitor() : ObjectPointerVisitor(Isolate::Current()) {} 50 PrintObjectPointersVisitor() : ObjectPointerVisitor(Isolate::Current()) {}
55 51
56 void VisitPointers(RawObject** first, RawObject** last) { 52 void VisitPointers(RawObject** first, RawObject** last) {
57 for (RawObject** p = first; p <= last; p++) { 53 for (RawObject** p = first; p <= last; p++) {
58 Object& obj = Object::Handle(*p); 54 Object& obj = Object::Handle(*p);
59 OS::PrintErr("%p: %s\n", p, obj.ToCString()); 55 OS::PrintErr("%p: %s\n", p, obj.ToCString());
60 } 56 }
61 } 57 }
62 }; 58 };
63 59
64
65 DART_EXPORT 60 DART_EXPORT
66 void _printStackTraceWithLocals() { 61 void _printStackTraceWithLocals() {
67 PrintObjectPointersVisitor visitor; 62 PrintObjectPointersVisitor visitor;
68 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, 63 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames,
69 Thread::Current(), 64 Thread::Current(),
70 StackFrameIterator::kNoCrossThreadIteration); 65 StackFrameIterator::kNoCrossThreadIteration);
71 StackFrame* frame = frames.NextFrame(); 66 StackFrame* frame = frames.NextFrame();
72 while (frame != NULL) { 67 while (frame != NULL) {
73 OS::PrintErr("%s\n", frame->ToCString()); 68 OS::PrintErr("%s\n", frame->ToCString());
74 frame->VisitObjectPointers(&visitor); 69 frame->VisitObjectPointers(&visitor);
75 frame = frames.NextFrame(); 70 frame = frames.NextFrame();
76 } 71 }
77 } 72 }
78 73
79 #endif // !PRODUCT 74 #endif // !PRODUCT
80 75
81 } // namespace dart 76 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/gc_sweeper.cc ('k') | runtime/vm/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698