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

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

Issue 51793002: Add an API function to get a debugger stack trace from an error handle. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 7 years, 1 month 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 | « runtime/vm/debugger.h ('k') | runtime/vm/debugger_api_impl.cc » ('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) 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 const Code& code, 133 const Code& code,
134 const Array& deopt_frame, 134 const Array& deopt_frame,
135 intptr_t deopt_frame_offset) 135 intptr_t deopt_frame_offset)
136 : pc_(pc), fp_(fp), sp_(sp), 136 : pc_(pc), fp_(fp), sp_(sp),
137 ctx_(Context::ZoneHandle()), 137 ctx_(Context::ZoneHandle()),
138 code_(Code::ZoneHandle(code.raw())), 138 code_(Code::ZoneHandle(code.raw())),
139 function_(Function::ZoneHandle(code.function())), 139 function_(Function::ZoneHandle(code.function())),
140 token_pos_(-1), 140 token_pos_(-1),
141 pc_desc_index_(-1), 141 pc_desc_index_(-1),
142 line_number_(-1), 142 line_number_(-1),
143 column_number_(-1),
143 context_level_(-1), 144 context_level_(-1),
144 deopt_frame_(Array::ZoneHandle(deopt_frame.raw())), 145 deopt_frame_(Array::ZoneHandle(deopt_frame.raw())),
145 deopt_frame_offset_(deopt_frame_offset), 146 deopt_frame_offset_(deopt_frame_offset),
146 vars_initialized_(false), 147 vars_initialized_(false),
147 var_descriptors_(LocalVarDescriptors::ZoneHandle()), 148 var_descriptors_(LocalVarDescriptors::ZoneHandle()),
148 desc_indices_(8), 149 desc_indices_(8),
149 pc_desc_(PcDescriptors::ZoneHandle()) { 150 pc_desc_(PcDescriptors::ZoneHandle()) {
150 } 151 }
151 152
152 153
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 intptr_t ActivationFrame::LineNumber() { 289 intptr_t ActivationFrame::LineNumber() {
289 // Compute line number lazily since it causes scanning of the script. 290 // Compute line number lazily since it causes scanning of the script.
290 if ((line_number_ < 0) && (TokenPos() >= 0)) { 291 if ((line_number_ < 0) && (TokenPos() >= 0)) {
291 const Script& script = Script::Handle(SourceScript()); 292 const Script& script = Script::Handle(SourceScript());
292 script.GetTokenLocation(TokenPos(), &line_number_, NULL); 293 script.GetTokenLocation(TokenPos(), &line_number_, NULL);
293 } 294 }
294 return line_number_; 295 return line_number_;
295 } 296 }
296 297
297 298
299 intptr_t ActivationFrame::ColumnNumber() {
300 // Compute column number lazily since it causes scanning of the script.
301 if ((column_number_ < 0) && (TokenPos() >= 0)) {
302 const Script& script = Script::Handle(SourceScript());
303 if (script.HasSource()) {
304 script.GetTokenLocation(TokenPos(), &line_number_, &column_number_);
305 } else {
306 column_number_ = -1;
307 }
308 }
309 return column_number_;
310 }
311
312
298 void ActivationFrame::GetVarDescriptors() { 313 void ActivationFrame::GetVarDescriptors() {
299 if (var_descriptors_.IsNull()) { 314 if (var_descriptors_.IsNull()) {
300 var_descriptors_ = code().var_descriptors(); 315 var_descriptors_ = code().var_descriptors();
301 ASSERT(!var_descriptors_.IsNull()); 316 ASSERT(!var_descriptors_.IsNull());
302 } 317 }
303 } 318 }
304 319
305 320
306 bool ActivationFrame::IsDebuggable() const { 321 bool ActivationFrame::IsDebuggable() const {
307 return Debugger::IsDebuggable(function()); 322 return Debugger::IsDebuggable(function());
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), code, 1277 new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), code,
1263 Object::null_array(), 0); 1278 Object::null_array(), 0);
1264 return activation; 1279 return activation;
1265 } 1280 }
1266 1281
1267 1282
1268 DebuggerStackTrace* Debugger::StackTrace() { 1283 DebuggerStackTrace* Debugger::StackTrace() {
1269 return (stack_trace_ != NULL) ? stack_trace_ : CollectStackTrace(); 1284 return (stack_trace_ != NULL) ? stack_trace_ : CollectStackTrace();
1270 } 1285 }
1271 1286
1287 DebuggerStackTrace* Debugger::CurrentStackTrace() {
1288 return CollectStackTraceNew();
1289 }
1290
1291 DebuggerStackTrace* Debugger::StackTraceFrom(const Stacktrace& ex_trace) {
1292 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8);
1293 Function& function = Function::Handle();
1294 Code& code = Code::Handle();
1295
1296 const uword fp = 0;
1297 const uword sp = 0;
1298 const Array& deopt_frame = Array::Handle();
1299 const intptr_t deopt_frame_offset = -1;
1300
1301 for (intptr_t i = 0; i < ex_trace.Length(); i++) {
1302 function = ex_trace.FunctionAtFrame(i);
1303 if (function.IsNull()) {
1304 // Check if null function object indicates a stack trace overflow.
1305 // Preallocated stacktraces like StackOverflow or OutOfMemory make skip
1306 // frames.
1307 ASSERT((i < (ex_trace.Length() - 1)) &&
1308 (ex_trace.FunctionAtFrame(i + 1) != Function::null()));
1309 } else if (function.is_visible()) {
1310 code = ex_trace.CodeAtFrame(i);
1311 ASSERT(function.raw() == code.function());
1312 uword pc = code.EntryPoint() + Smi::Value(ex_trace.PcOffsetAtFrame(i));
1313 if (code.is_optimized() && ex_trace.expand_inlined()) {
1314 // Traverse inlined frames.
1315 for (InlinedFunctionsIterator it(code, pc); !it.Done(); it.Advance()) {
1316 function = it.function();
1317 code = it.code();
1318 ASSERT(function.raw() == code.function());
1319 uword pc = it.pc();
1320 ASSERT(pc != 0);
1321 ASSERT(code.EntryPoint() <= pc);
1322 ASSERT(pc < (code.EntryPoint() + code.Size()));
1323
1324 ActivationFrame* activation = new ActivationFrame(
1325 pc, fp, sp, code, deopt_frame, deopt_frame_offset);
1326 stack_trace->AddActivation(activation);
1327 }
1328 } else {
1329 ActivationFrame* activation = new ActivationFrame(
1330 pc, fp, sp, code, deopt_frame, deopt_frame_offset);
1331 stack_trace->AddActivation(activation);
1332 }
1333 }
1334 }
1335 return stack_trace;
1336 }
1337
1272 1338
1273 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { 1339 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) {
1274 ASSERT((pause_info == kNoPauseOnExceptions) || 1340 ASSERT((pause_info == kNoPauseOnExceptions) ||
1275 (pause_info == kPauseOnUnhandledExceptions) || 1341 (pause_info == kPauseOnUnhandledExceptions) ||
1276 (pause_info == kPauseOnAllExceptions)); 1342 (pause_info == kPauseOnAllExceptions));
1277 exc_pause_info_ = pause_info; 1343 exc_pause_info_ = pause_info;
1278 } 1344 }
1279 1345
1280 1346
1281 Dart_ExceptionPauseInfo Debugger::GetExceptionPauseInfo() { 1347 Dart_ExceptionPauseInfo Debugger::GetExceptionPauseInfo() {
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 } 2227 }
2162 2228
2163 2229
2164 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 2230 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
2165 ASSERT(bpt->next() == NULL); 2231 ASSERT(bpt->next() == NULL);
2166 bpt->set_next(code_breakpoints_); 2232 bpt->set_next(code_breakpoints_);
2167 code_breakpoints_ = bpt; 2233 code_breakpoints_ = bpt;
2168 } 2234 }
2169 2235
2170 } // namespace dart 2236 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/debugger_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698