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

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

Issue 23964003: Traverse inlined frames lazily when printing the stacktrace. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/exceptions.cc » ('j') | runtime/vm/object.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 #include "vm/exceptions.h" 6 #include "vm/exceptions.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/runtime_entry.h" 8 #include "vm/runtime_entry.h"
9 #include "vm/stack_frame.h" 9 #include "vm/stack_frame.h"
10 10
(...skipping 18 matching lines...) Expand all
29 return String::New(trace.ToCStringInternal(0)); 29 return String::New(trace.ToCStringInternal(0));
30 } 30 }
31 31
32 32
33 // Setup a full stack trace. 33 // Setup a full stack trace.
34 // Arg0: stack trace object. 34 // Arg0: stack trace object.
35 // Return value: None. 35 // Return value: None.
36 DEFINE_NATIVE_ENTRY(Stacktrace_setupFullStacktrace, 1) { 36 DEFINE_NATIVE_ENTRY(Stacktrace_setupFullStacktrace, 1) {
37 const Stacktrace& trace = 37 const Stacktrace& trace =
38 Stacktrace::CheckedHandle(arguments->NativeArgAt(0)); 38 Stacktrace::CheckedHandle(arguments->NativeArgAt(0));
39 const GrowableObjectArray& func_list =
40 GrowableObjectArray::Handle(GrowableObjectArray::New());
41 const GrowableObjectArray& code_list = 39 const GrowableObjectArray& code_list =
42 GrowableObjectArray::Handle(GrowableObjectArray::New()); 40 GrowableObjectArray::Handle(GrowableObjectArray::New());
43 const GrowableObjectArray& pc_offset_list = 41 const GrowableObjectArray& pc_offset_list =
44 GrowableObjectArray::Handle(GrowableObjectArray::New()); 42 GrowableObjectArray::Handle(GrowableObjectArray::New());
45 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); 43 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames);
46 StackFrame* frame = frames.NextFrame(); 44 StackFrame* frame = frames.NextFrame();
47 ASSERT(frame != NULL); // We expect to find a dart invocation frame. 45 ASSERT(frame != NULL); // We expect to find a dart invocation frame.
48 Function& func = Function::Handle(); 46 Function& func = Function::Handle();
49 Code& code = Code::Handle(); 47 Code& code = Code::Handle();
50 Smi& offset = Smi::Handle(); 48 Smi& offset = Smi::Handle();
51 bool catch_frame_skipped = false; // Tracks if catch frame has been skipped. 49 bool catch_frame_skipped = false; // Tracks if catch frame has been skipped.
52 while (frame != NULL) { 50 while (frame != NULL) {
53 if (frame->IsDartFrame()) { 51 if (frame->IsDartFrame()) {
54 code = frame->LookupDartCode(); 52 code = frame->LookupDartCode();
55 if (code.is_optimized()) { 53 offset = Smi::New(frame->pc() - code.EntryPoint());
56 // For optimized frames, extract all the inlined functions if any 54 func = code.function();
57 // into the stack trace. 55 if (func.is_visible()) {
siva 2013/09/04 22:25:21 I think we should do this filtering in the print f
srdjan 2013/09/05 18:14:09 Done.
58 for (InlinedFunctionsIterator it(code, frame->pc()); 56 if (!catch_frame_skipped) {
59 !it.Done(); it.Advance()) { 57 catch_frame_skipped = true;
60 func = it.function(); 58 } else {
61 code = it.code(); 59 code_list.Add(code);
62 uword pc = it.pc(); 60 pc_offset_list.Add(offset);
63 ASSERT(pc != 0);
64 ASSERT(code.EntryPoint() <= pc);
65 ASSERT(pc < (code.EntryPoint() + code.Size()));
66 if (func.is_visible()) {
67 if (!catch_frame_skipped) {
68 catch_frame_skipped = true;
69 } else {
70 offset = Smi::New(pc - code.EntryPoint());
71 func_list.Add(func);
72 code_list.Add(code);
73 pc_offset_list.Add(offset);
74 }
75 }
76 }
77 } else {
78 offset = Smi::New(frame->pc() - code.EntryPoint());
79 func = code.function();
80 if (func.is_visible()) {
81 if (!catch_frame_skipped) {
82 catch_frame_skipped = true;
83 } else {
84 func_list.Add(func);
85 code_list.Add(code);
86 pc_offset_list.Add(offset);
87 }
88 } 61 }
89 } 62 }
90 } 63 }
91 frame = frames.NextFrame(); 64 frame = frames.NextFrame();
92 } 65 }
93 const Array& func_array = Array::Handle(Array::MakeArray(func_list));
94 const Array& code_array = Array::Handle(Array::MakeArray(code_list)); 66 const Array& code_array = Array::Handle(Array::MakeArray(code_list));
95 const Array& pc_offset_array = 67 const Array& pc_offset_array =
96 Array::Handle(Array::MakeArray(pc_offset_list)); 68 Array::Handle(Array::MakeArray(pc_offset_list));
97 trace.SetCatchStacktrace(func_array, code_array, pc_offset_array); 69 trace.SetCatchStacktrace(code_array, pc_offset_array);
98 return Object::null(); 70 return Object::null();
99 } 71 }
100 72
101 } // namespace dart 73 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/exceptions.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698