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

Side by Side Diff: runtime/lib/stacktrace.cc

Issue 2572563004: Improve the casing of Stackmap and Stacktrace. (Closed)
Patch Set: Build fixes Created 4 years 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/exceptions.h" 7 #include "vm/exceptions.h"
8 #include "vm/object_store.h" 8 #include "vm/object_store.h"
9 #include "vm/runtime_entry.h" 9 #include "vm/runtime_entry.h"
10 #include "vm/stack_frame.h" 10 #include "vm/stack_frame.h"
(...skipping 16 matching lines...) Expand all
27 code = frame->LookupDartCode(); 27 code = frame->LookupDartCode();
28 offset = Smi::New(frame->pc() - code.PayloadStart()); 28 offset = Smi::New(frame->pc() - code.PayloadStart());
29 code_list.Add(code); 29 code_list.Add(code);
30 pc_offset_list.Add(offset); 30 pc_offset_list.Add(offset);
31 } 31 }
32 } 32 }
33 frame = frames.NextFrame(); 33 frame = frames.NextFrame();
34 } 34 }
35 } 35 }
36 36
37 // Creates a Stacktrace object from the current stack. 37 // Creates a StackTrace object from the current stack.
38 // 38 //
39 // Skips the first skip_frames Dart frames. 39 // Skips the first skip_frames Dart frames.
40 const Stacktrace& GetCurrentStacktrace(int skip_frames) { 40 const StackTrace& GetCurrentStackTrace(int skip_frames) {
41 const GrowableObjectArray& code_list = 41 const GrowableObjectArray& code_list =
42 GrowableObjectArray::Handle(GrowableObjectArray::New()); 42 GrowableObjectArray::Handle(GrowableObjectArray::New());
43 const GrowableObjectArray& pc_offset_list = 43 const GrowableObjectArray& pc_offset_list =
44 GrowableObjectArray::Handle(GrowableObjectArray::New()); 44 GrowableObjectArray::Handle(GrowableObjectArray::New());
45 IterateFrames(code_list, pc_offset_list, skip_frames); 45 IterateFrames(code_list, pc_offset_list, skip_frames);
46 const Array& code_array = Array::Handle(Array::MakeArray(code_list)); 46 const Array& code_array = Array::Handle(Array::MakeArray(code_list));
47 const Array& pc_offset_array = 47 const Array& pc_offset_array =
48 Array::Handle(Array::MakeArray(pc_offset_list)); 48 Array::Handle(Array::MakeArray(pc_offset_list));
49 const Stacktrace& stacktrace = 49 const StackTrace& stacktrace =
50 Stacktrace::Handle(Stacktrace::New(code_array, pc_offset_array)); 50 StackTrace::Handle(StackTrace::New(code_array, pc_offset_array));
51 return stacktrace; 51 return stacktrace;
52 } 52 }
53 53
54 // An utility method for convenient printing of dart stack traces when 54 // An utility method for convenient printing of dart stack traces when
55 // inside 'gdb'. Note: This function will only work when there is a 55 // inside 'gdb'. Note: This function will only work when there is a
56 // valid exit frame information. It will not work when a breakpoint is 56 // valid exit frame information. It will not work when a breakpoint is
57 // set in dart code and control is got inside 'gdb' without going through 57 // set in dart code and control is got inside 'gdb' without going through
58 // the runtime or native transition stub. 58 // the runtime or native transition stub.
59 void _printCurrentStacktrace() { 59 void _printCurrentStackTrace() {
60 const Stacktrace& stacktrace = GetCurrentStacktrace(0); 60 const StackTrace& stacktrace = GetCurrentStackTrace(0);
61 OS::PrintErr("=== Current Trace:\n%s===\n", stacktrace.ToCString()); 61 OS::PrintErr("=== Current Trace:\n%s===\n", stacktrace.ToCString());
62 } 62 }
63 63
64 // Like _printCurrentStacktrace, but works in a NoSafepointScope. 64 // Like _printCurrentStackTrace, but works in a NoSafepointScope.
65 void _printCurrentStacktraceNoSafepoint() { 65 void _printCurrentStackTraceNoSafepoint() {
66 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); 66 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames);
67 StackFrame* frame = frames.NextFrame(); 67 StackFrame* frame = frames.NextFrame();
68 while (frame != NULL) { 68 while (frame != NULL) {
69 OS::Print("%s\n", frame->ToCString()); 69 OS::Print("%s\n", frame->ToCString());
70 frame = frames.NextFrame(); 70 frame = frames.NextFrame();
71 } 71 }
72 } 72 }
73 73
74 DEFINE_NATIVE_ENTRY(StackTrace_current, 0) { 74 DEFINE_NATIVE_ENTRY(StackTrace_current, 0) {
75 const Stacktrace& stacktrace = GetCurrentStacktrace(1); 75 const StackTrace& stacktrace = GetCurrentStackTrace(1);
76 return stacktrace.raw(); 76 return stacktrace.raw();
77 } 77 }
78 78
79 } // namespace dart 79 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/stacktrace.h ('k') | runtime/observatory/lib/src/elements/nav/notify_exception.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698