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

Side by Side Diff: vm/debugger.cc

Issue 12225031: Minor cleanup of activation frame creation code. Get the code object while iterating the frames as … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 10 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 | « vm/debugger.h ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/debugger.h" 5 #include "vm/debugger.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 129
130 130
131 131
132 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { 132 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) {
133 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); 133 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_));
134 } 134 }
135 135
136 136
137 ActivationFrame::ActivationFrame(uword pc, uword fp, uword sp, 137 ActivationFrame::ActivationFrame(uword pc, uword fp, uword sp,
138 const Code& code,
138 const Context& ctx) 139 const Context& ctx)
139 : pc_(pc), fp_(fp), sp_(sp), 140 : pc_(pc), fp_(fp), sp_(sp),
140 ctx_(Context::ZoneHandle(ctx.raw())), 141 ctx_(Context::ZoneHandle(ctx.raw())),
141 function_(Function::ZoneHandle()), 142 code_(Code::ZoneHandle(code.raw())),
142 code_(Code::ZoneHandle()), 143 function_(Function::ZoneHandle(code.function())),
143 token_pos_(-1), 144 token_pos_(-1),
144 pc_desc_index_(-1), 145 pc_desc_index_(-1),
145 line_number_(-1), 146 line_number_(-1),
146 context_level_(-1), 147 context_level_(-1),
147 vars_initialized_(false), 148 vars_initialized_(false),
148 var_descriptors_(LocalVarDescriptors::ZoneHandle()), 149 var_descriptors_(LocalVarDescriptors::ZoneHandle()),
149 desc_indices_(8), 150 desc_indices_(8),
150 pc_desc_(PcDescriptors::ZoneHandle()) { 151 pc_desc_(PcDescriptors::ZoneHandle()) {
151 } 152 }
152 153
153 154
154 const Code& ActivationFrame::DartCode() { 155 const Code& ActivationFrame::DartCode() {
hausner 2013/02/06 01:22:15 As discussed offline, this can now be a simple acc
siva 2013/02/06 01:41:43 Done.
155 if (code_.IsNull()) { 156 ASSERT(!code_.IsNull());
156 Isolate* isolate = Isolate::Current();
157 ASSERT(isolate != NULL);
158 code_ = Code::LookupCode(pc_);
159 }
160 return code_; 157 return code_;
161 } 158 }
162 159
163 160
164 const Function& ActivationFrame::DartFunction() { 161 const Function& ActivationFrame::DartFunction() {
hausner 2013/02/06 01:22:15 Ditto, turn into function().
siva 2013/02/06 01:41:43 Done.
165 if (function_.IsNull()) { 162 ASSERT(!function_.IsNull());
166 function_ = DartCode().function();
167 }
168 return function_; 163 return function_;
169 } 164 }
170 165
171 166
172 void Debugger::SignalIsolateEvent(EventType type) { 167 void Debugger::SignalIsolateEvent(EventType type) {
173 if (event_handler_ != NULL) { 168 if (event_handler_ != NULL) {
174 Debugger* debugger = Isolate::Current()->debugger(); 169 Debugger* debugger = Isolate::Current()->debugger();
175 ASSERT(debugger != NULL); 170 ASSERT(debugger != NULL);
176 DebuggerEvent event; 171 DebuggerEvent event;
177 event.type = type; 172 event.type = type;
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 if (event_handler_ != NULL) { 868 if (event_handler_ != NULL) {
874 DebuggerEvent event; 869 DebuggerEvent event;
875 event.type = kBreakpointResolved; 870 event.type = kBreakpointResolved;
876 event.breakpoint = bpt; 871 event.breakpoint = bpt;
877 (*event_handler_)(&event); 872 (*event_handler_)(&event);
878 } 873 }
879 } 874 }
880 875
881 876
882 DebuggerStackTrace* Debugger::CollectStackTrace() { 877 DebuggerStackTrace* Debugger::CollectStackTrace() {
878 Isolate* isolate = Isolate::Current();
883 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); 879 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8);
884 Context& ctx = Context::Handle(Isolate::Current()->top_context()); 880 Context& ctx = Context::Handle(isolate->top_context());
881 Code& code = Code::Handle(isolate);
885 DartFrameIterator iterator; 882 DartFrameIterator iterator;
886 StackFrame* frame = iterator.NextFrame(); 883 StackFrame* frame = iterator.NextFrame();
887 while (frame != NULL) { 884 while (frame != NULL) {
888 ASSERT(frame->IsValid()); 885 ASSERT(frame->IsValid());
889 ASSERT(frame->IsDartFrame()); 886 ASSERT(frame->IsDartFrame());
887 code = frame->LookupDartCode();
890 ActivationFrame* activation = 888 ActivationFrame* activation =
891 new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), ctx); 889 new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), code, ctx);
892 ctx = activation->CallerContext(); 890 ctx = activation->CallerContext();
893 stack_trace->AddActivation(activation); 891 stack_trace->AddActivation(activation);
894 frame = iterator.NextFrame(); 892 frame = iterator.NextFrame();
895 } 893 }
896 return stack_trace; 894 return stack_trace;
897 } 895 }
898 896
899 897
900 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { 898 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) {
901 ASSERT((pause_info == kNoPauseOnExceptions) || 899 ASSERT((pause_info == kNoPauseOnExceptions) ||
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 } 1726 }
1729 1727
1730 1728
1731 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1729 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1732 ASSERT(bpt->next() == NULL); 1730 ASSERT(bpt->next() == NULL);
1733 bpt->set_next(code_breakpoints_); 1731 bpt->set_next(code_breakpoints_);
1734 code_breakpoints_ = bpt; 1732 code_breakpoints_ = bpt;
1735 } 1733 }
1736 1734
1737 } // namespace dart 1735 } // namespace dart
OLDNEW
« no previous file with comments | « vm/debugger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698