OLD | NEW |
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 #ifndef RUNTIME_VM_DEBUGGER_H_ | 5 #ifndef RUNTIME_VM_DEBUGGER_H_ |
6 #define RUNTIME_VM_DEBUGGER_H_ | 6 #define RUNTIME_VM_DEBUGGER_H_ |
7 | 7 |
8 #include "include/dart_tools_api.h" | 8 #include "include/dart_tools_api.h" |
9 | 9 |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
11 #include "vm/port.h" | 11 #include "vm/port.h" |
12 #include "vm/service_event.h" | 12 #include "vm/service_event.h" |
13 | 13 |
| 14 DECLARE_FLAG(bool, verbose_debug); |
| 15 |
| 16 // 'Trace Debugger' TD_Print. |
| 17 #if defined(_MSC_VER) |
| 18 #define TD_Print(format, ...) \ |
| 19 if (FLAG_verbose_debug) Log::Current()->Print(format, __VA_ARGS__) |
| 20 #else |
| 21 #define TD_Print(format, ...) \ |
| 22 if (FLAG_verbose_debug) Log::Current()->Print(format, ##__VA_ARGS__) |
| 23 #endif |
| 24 |
14 namespace dart { | 25 namespace dart { |
15 | 26 |
16 class CodeBreakpoint; | 27 class CodeBreakpoint; |
17 class Isolate; | 28 class Isolate; |
18 class JSONArray; | 29 class JSONArray; |
19 class JSONStream; | 30 class JSONStream; |
20 class ObjectPointerVisitor; | 31 class ObjectPointerVisitor; |
21 class RemoteObjectCache; | 32 class RemoteObjectCache; |
22 class BreakpointLocation; | 33 class BreakpointLocation; |
23 class StackFrame; | 34 class StackFrame; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 RawScript* SourceCode(); | 208 RawScript* SourceCode(); |
198 RawString* SourceUrl(); | 209 RawString* SourceUrl(); |
199 intptr_t LineNumber(); | 210 intptr_t LineNumber(); |
200 | 211 |
201 void Enable(); | 212 void Enable(); |
202 void Disable(); | 213 void Disable(); |
203 bool IsEnabled() const { return is_enabled_; } | 214 bool IsEnabled() const { return is_enabled_; } |
204 | 215 |
205 RawCode* OrigStubAddress() const; | 216 RawCode* OrigStubAddress() const; |
206 | 217 |
| 218 const char* ToCString(); |
| 219 |
207 private: | 220 private: |
208 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 221 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
209 | 222 |
210 BreakpointLocation* bpt_location() const { return bpt_location_; } | 223 BreakpointLocation* bpt_location() const { return bpt_location_; } |
211 void set_bpt_location(BreakpointLocation* value) { bpt_location_ = value; } | 224 void set_bpt_location(BreakpointLocation* value) { bpt_location_ = value; } |
212 | 225 |
213 void set_next(CodeBreakpoint* value) { next_ = value; } | 226 void set_next(CodeBreakpoint* value) { next_ = value; } |
214 CodeBreakpoint* next() const { return this->next_; } | 227 CodeBreakpoint* next() const { return this->next_; } |
215 | 228 |
216 void PatchCode(); | 229 void PatchCode(); |
(...skipping 21 matching lines...) Expand all Loading... |
238 | 251 |
239 friend class Debugger; | 252 friend class Debugger; |
240 DISALLOW_COPY_AND_ASSIGN(CodeBreakpoint); | 253 DISALLOW_COPY_AND_ASSIGN(CodeBreakpoint); |
241 }; | 254 }; |
242 | 255 |
243 | 256 |
244 // ActivationFrame represents one dart function activation frame | 257 // ActivationFrame represents one dart function activation frame |
245 // on the call stack. | 258 // on the call stack. |
246 class ActivationFrame : public ZoneAllocated { | 259 class ActivationFrame : public ZoneAllocated { |
247 public: | 260 public: |
| 261 enum Kind { |
| 262 kRegular, |
| 263 kAsyncLive, |
| 264 kAsyncSuspensionMarker, |
| 265 kAsyncHistorical, |
| 266 }; |
| 267 |
248 ActivationFrame(uword pc, | 268 ActivationFrame(uword pc, |
249 uword fp, | 269 uword fp, |
250 uword sp, | 270 uword sp, |
251 const Code& code, | 271 const Code& code, |
252 const Array& deopt_frame, | 272 const Array& deopt_frame, |
253 intptr_t deopt_frame_offset); | 273 intptr_t deopt_frame_offset, |
| 274 Kind kind = kRegular); |
| 275 |
| 276 ActivationFrame(uword pc, const Code& code); |
| 277 |
| 278 explicit ActivationFrame(Kind kind); |
| 279 |
| 280 explicit ActivationFrame(const Closure& async_activation); |
254 | 281 |
255 uword pc() const { return pc_; } | 282 uword pc() const { return pc_; } |
256 uword fp() const { return fp_; } | 283 uword fp() const { return fp_; } |
257 uword sp() const { return sp_; } | 284 uword sp() const { return sp_; } |
258 const Function& function() const { | 285 const Function& function() const { |
259 ASSERT(!function_.IsNull()); | 286 ASSERT(!function_.IsNull()); |
260 return function_; | 287 return function_; |
261 } | 288 } |
262 const Code& code() const { | 289 const Code& code() const { |
263 ASSERT(!code_.IsNull()); | 290 ASSERT(!code_.IsNull()); |
264 return code_; | 291 return code_; |
265 } | 292 } |
266 | 293 |
267 RawString* QualifiedFunctionName(); | 294 RawString* QualifiedFunctionName(); |
268 RawString* SourceUrl(); | 295 RawString* SourceUrl(); |
269 RawScript* SourceScript(); | 296 RawScript* SourceScript(); |
270 RawLibrary* Library(); | 297 RawLibrary* Library(); |
271 TokenPosition TokenPos(); | 298 TokenPosition TokenPos(); |
272 intptr_t LineNumber(); | 299 intptr_t LineNumber(); |
273 intptr_t ColumnNumber(); | 300 intptr_t ColumnNumber(); |
274 | 301 |
| 302 bool IsLiveFrame() const { |
| 303 return (kind_ == kRegular) || (kind_ == kAsyncLive); |
| 304 } |
| 305 |
275 // Returns true if this frame is for a function that is visible | 306 // Returns true if this frame is for a function that is visible |
276 // to the user and can be debugged. | 307 // to the user and can be debugged. |
277 bool IsDebuggable() const; | 308 bool IsDebuggable() const; |
278 | 309 |
279 // Returns true if it is possible to rewind the debugger to this frame. | 310 // Returns true if it is possible to rewind the debugger to this frame. |
280 bool IsRewindable() const; | 311 bool IsRewindable() const; |
281 | 312 |
| 313 // Returns true if this function is _SyncCompleter._completeOnAsyncReturn |
| 314 // from the async library. |
| 315 bool IsCompleteOnAsyncReturn(); |
| 316 |
| 317 // Returns true if this function is from the AsyncStartStreamController class. |
| 318 bool IsInAsyncStarStreamController(); |
| 319 |
| 320 // Returns true if this function is part of the async implementation |
| 321 // machinery. |
| 322 bool IsInAsyncMachinery(); |
| 323 |
282 // The context level of a frame is the context level at the | 324 // The context level of a frame is the context level at the |
283 // PC/token index of the frame. It determines the depth of the context | 325 // PC/token index of the frame. It determines the depth of the context |
284 // chain that belongs to the function of this activation frame. | 326 // chain that belongs to the function of this activation frame. |
285 intptr_t ContextLevel(); | 327 intptr_t ContextLevel(); |
286 | 328 |
287 const char* ToCString(); | 329 const char* ToCString(); |
288 | 330 |
289 intptr_t NumLocalVariables(); | 331 intptr_t NumLocalVariables(); |
290 | 332 |
291 void VariableAt(intptr_t i, | 333 void VariableAt(intptr_t i, |
292 String* name, | 334 String* name, |
293 TokenPosition* declaration_token_pos, | 335 TokenPosition* declaration_token_pos, |
294 TokenPosition* visible_start_token_pos, | 336 TokenPosition* visible_start_token_pos, |
295 TokenPosition* visible_end_token_pos, | 337 TokenPosition* visible_end_token_pos, |
296 Object* value); | 338 Object* value); |
297 | 339 |
298 RawArray* GetLocalVariables(); | 340 RawArray* GetLocalVariables(); |
299 RawObject* GetParameter(intptr_t index); | 341 RawObject* GetParameter(intptr_t index); |
300 RawObject* GetClosure(); | 342 RawObject* GetClosure(); |
301 RawObject* GetReceiver(); | 343 RawObject* GetReceiver(); |
302 | 344 |
303 const Context& GetSavedCurrentContext(); | 345 const Context& GetSavedCurrentContext(); |
304 RawObject* GetAsyncOperation(); | 346 RawObject* GetAsyncOperation(); |
| 347 RawObject* GetAsyncCompleter(); |
| 348 RawObject* GetAsyncCompleterAwaiter(const Object& completer); |
| 349 |
| 350 void ExtractTokenPositionFromAsyncClosure(); |
| 351 |
| 352 RawObject* GetAsyncStreamControllerStream(); |
| 353 RawObject* GetAsyncStreamControllerStreamAwaiter(const Object& stream); |
| 354 |
| 355 RawObject* GetAsyncAwaiter(); |
305 | 356 |
306 RawObject* Evaluate(const String& expr); | 357 RawObject* Evaluate(const String& expr); |
307 | 358 |
308 // Print the activation frame into |jsobj|. if |full| is false, script | 359 // Print the activation frame into |jsobj|. if |full| is false, script |
309 // and local variable objects are only references. if |full| is true, | 360 // and local variable objects are only references. if |full| is true, |
310 // the complete script, function, and, local variable objects are included. | 361 // the complete script, function, and, local variable objects are included. |
311 void PrintToJSONObject(JSONObject* jsobj, bool full = false); | 362 void PrintToJSONObject(JSONObject* jsobj, bool full = false); |
312 | 363 |
313 private: | 364 private: |
| 365 void PrintToJSONObjectAsync(JSONObject* jsobj, bool full = false); |
| 366 void PrintToJSONObjectRegular(JSONObject* jsobj, bool full = false); |
| 367 void PrintToJSONObjectHistoricalFrame(JSONObject* jsobj, bool full = false); |
| 368 |
| 369 void PrintToJSONObjectLiveFrame(JSONObject* jsobj, bool full = false); |
| 370 |
314 void PrintContextMismatchError(intptr_t ctx_slot, | 371 void PrintContextMismatchError(intptr_t ctx_slot, |
315 intptr_t frame_ctx_level, | 372 intptr_t frame_ctx_level, |
316 intptr_t var_ctx_level); | 373 intptr_t var_ctx_level); |
317 | 374 |
318 intptr_t TryIndex(); | 375 intptr_t TryIndex(); |
319 void GetPcDescriptors(); | 376 void GetPcDescriptors(); |
320 void GetVarDescriptors(); | 377 void GetVarDescriptors(); |
321 void GetDescIndices(); | 378 void GetDescIndices(); |
322 | 379 |
| 380 static const char* KindToCString(Kind kind) { |
| 381 switch (kind) { |
| 382 case kRegular: |
| 383 return "kRegular"; |
| 384 case kAsyncLive: |
| 385 return "kAsyncLive"; |
| 386 case kAsyncSuspensionMarker: |
| 387 return "kMarker"; |
| 388 case kAsyncHistorical: |
| 389 return "kAsyncHistorical"; |
| 390 default: |
| 391 UNREACHABLE(); |
| 392 return ""; |
| 393 } |
| 394 } |
| 395 |
323 RawObject* GetStackVar(intptr_t slot_index); | 396 RawObject* GetStackVar(intptr_t slot_index); |
324 RawObject* GetContextVar(intptr_t ctxt_level, intptr_t slot_index); | 397 RawObject* GetContextVar(intptr_t ctxt_level, intptr_t slot_index); |
325 | 398 |
326 uword pc_; | 399 uword pc_; |
327 uword fp_; | 400 uword fp_; |
328 uword sp_; | 401 uword sp_; |
329 | 402 |
330 // The anchor of the context chain for this function. | 403 // The anchor of the context chain for this function. |
331 Context& ctx_; | 404 Context& ctx_; |
332 const Code& code_; | 405 Code& code_; |
333 const Function& function_; | 406 Function& function_; |
| 407 bool suspended_frame_; |
334 bool token_pos_initialized_; | 408 bool token_pos_initialized_; |
335 TokenPosition token_pos_; | 409 TokenPosition token_pos_; |
336 intptr_t try_index_; | 410 intptr_t try_index_; |
337 | 411 |
338 intptr_t line_number_; | 412 intptr_t line_number_; |
339 intptr_t column_number_; | 413 intptr_t column_number_; |
340 intptr_t context_level_; | 414 intptr_t context_level_; |
341 | 415 |
342 // Some frames are deoptimized into a side array in order to inspect them. | 416 // Some frames are deoptimized into a side array in order to inspect them. |
343 const Array& deopt_frame_; | 417 const Array& deopt_frame_; |
344 const intptr_t deopt_frame_offset_; | 418 const intptr_t deopt_frame_offset_; |
345 | 419 |
| 420 Kind kind_; |
| 421 |
346 bool vars_initialized_; | 422 bool vars_initialized_; |
347 LocalVarDescriptors& var_descriptors_; | 423 LocalVarDescriptors& var_descriptors_; |
348 ZoneGrowableArray<intptr_t> desc_indices_; | 424 ZoneGrowableArray<intptr_t> desc_indices_; |
349 PcDescriptors& pc_desc_; | 425 PcDescriptors& pc_desc_; |
350 | 426 |
351 friend class Debugger; | 427 friend class Debugger; |
352 friend class DebuggerStackTrace; | 428 friend class DebuggerStackTrace; |
353 DISALLOW_COPY_AND_ASSIGN(ActivationFrame); | 429 DISALLOW_COPY_AND_ASSIGN(ActivationFrame); |
354 }; | 430 }; |
355 | 431 |
356 | 432 |
357 // Array of function activations on the call stack. | 433 // Array of function activations on the call stack. |
358 class DebuggerStackTrace : public ZoneAllocated { | 434 class DebuggerStackTrace : public ZoneAllocated { |
359 public: | 435 public: |
360 explicit DebuggerStackTrace(int capacity) : trace_(capacity) {} | 436 explicit DebuggerStackTrace(int capacity) : trace_(capacity) {} |
361 | 437 |
362 intptr_t Length() const { return trace_.length(); } | 438 intptr_t Length() const { return trace_.length(); } |
363 | 439 |
364 ActivationFrame* FrameAt(int i) const { return trace_[i]; } | 440 ActivationFrame* FrameAt(int i) const { return trace_[i]; } |
365 | 441 |
366 ActivationFrame* GetHandlerFrame(const Instance& exc_obj) const; | 442 ActivationFrame* GetHandlerFrame(const Instance& exc_obj) const; |
367 | 443 |
368 private: | 444 private: |
369 void AddActivation(ActivationFrame* frame); | 445 void AddActivation(ActivationFrame* frame); |
| 446 void AddMarker(ActivationFrame::Kind marker); |
| 447 void AddAsyncHistoricalFrame(uword pc, const Code& code); |
| 448 |
370 ZoneGrowableArray<ActivationFrame*> trace_; | 449 ZoneGrowableArray<ActivationFrame*> trace_; |
371 | 450 |
372 friend class Debugger; | 451 friend class Debugger; |
373 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); | 452 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); |
374 }; | 453 }; |
375 | 454 |
376 | 455 |
377 class Debugger { | 456 class Debugger { |
378 public: | 457 public: |
379 enum ResumeAction { | 458 enum ResumeAction { |
380 kContinue, | 459 kContinue, |
381 kStepInto, | 460 kStepInto, |
382 kStepOver, | 461 kStepOver, |
383 kStepOut, | 462 kStepOut, |
384 kStepRewind, | 463 kStepRewind, |
385 kStepOverAsyncSuspension, | 464 kStepOverAsyncSuspension, |
386 }; | 465 }; |
387 | 466 |
388 typedef void EventHandler(ServiceEvent* event); | 467 typedef void EventHandler(ServiceEvent* event); |
389 | 468 |
390 Debugger(); | 469 Debugger(); |
391 ~Debugger(); | 470 ~Debugger(); |
392 | 471 |
393 void Initialize(Isolate* isolate); | 472 void Initialize(Isolate* isolate); |
394 void NotifyIsolateCreated(); | 473 void NotifyIsolateCreated(); |
395 void Shutdown(); | 474 void Shutdown(); |
396 | 475 |
| 476 void WhenRunnable(); |
| 477 |
397 void NotifyCompilation(const Function& func); | 478 void NotifyCompilation(const Function& func); |
398 void NotifyDoneLoading(); | 479 void NotifyDoneLoading(); |
399 | 480 |
400 RawFunction* ResolveFunction(const Library& library, | 481 RawFunction* ResolveFunction(const Library& library, |
401 const String& class_name, | 482 const String& class_name, |
402 const String& function_name); | 483 const String& function_name); |
403 | 484 |
404 // Set breakpoint at closest location to function entry. | 485 // Set breakpoint at closest location to function entry. |
405 Breakpoint* SetBreakpointAtEntry(const Function& target_function, | 486 Breakpoint* SetBreakpointAtEntry(const Function& target_function, |
406 bool single_shot); | 487 bool single_shot); |
(...skipping 16 matching lines...) Expand all Loading... |
423 | 504 |
424 void RemoveBreakpoint(intptr_t bp_id); | 505 void RemoveBreakpoint(intptr_t bp_id); |
425 Breakpoint* GetBreakpointById(intptr_t id); | 506 Breakpoint* GetBreakpointById(intptr_t id); |
426 | 507 |
427 bool SetResumeAction(ResumeAction action, | 508 bool SetResumeAction(ResumeAction action, |
428 intptr_t frame_index = 1, | 509 intptr_t frame_index = 1, |
429 const char** error = NULL); | 510 const char** error = NULL); |
430 | 511 |
431 bool IsStepping() const { return resume_action_ != kContinue; } | 512 bool IsStepping() const { return resume_action_ != kContinue; } |
432 | 513 |
| 514 bool IsSingleStepping() const { return resume_action_ == kStepInto; } |
| 515 |
433 bool IsPaused() const { return pause_event_ != NULL; } | 516 bool IsPaused() const { return pause_event_ != NULL; } |
434 | 517 |
| 518 void AsyncStepInto(const Closure& async_op); |
| 519 void AsyncContinue(); |
| 520 |
435 // Put the isolate into single stepping mode when Dart code next runs. | 521 // Put the isolate into single stepping mode when Dart code next runs. |
436 // | 522 // |
437 // This is used by the vm service to allow the user to step while | 523 // This is used by the vm service to allow the user to step while |
438 // paused at isolate start. | 524 // paused at isolate start. |
439 void EnterSingleStepMode(); | 525 void EnterSingleStepMode(); |
440 | 526 |
441 // Indicates why the debugger is currently paused. If the debugger | 527 // Indicates why the debugger is currently paused. If the debugger |
442 // is not paused, this returns NULL. Note that the debugger can be | 528 // is not paused, this returns NULL. Note that the debugger can be |
443 // paused for breakpoints, isolate interruption, and (sometimes) | 529 // paused for breakpoints, isolate interruption, and (sometimes) |
444 // exceptions. | 530 // exceptions. |
(...skipping 18 matching lines...) Expand all Loading... |
463 // a debugger stub. | 549 // a debugger stub. |
464 bool HasActiveBreakpoint(uword pc); | 550 bool HasActiveBreakpoint(uword pc); |
465 | 551 |
466 // Returns a stack trace with frames corresponding to invisible functions | 552 // Returns a stack trace with frames corresponding to invisible functions |
467 // omitted. CurrentStackTrace always returns a new trace on the current stack. | 553 // omitted. CurrentStackTrace always returns a new trace on the current stack. |
468 // The trace returned by StackTrace may have been cached; it is suitable for | 554 // The trace returned by StackTrace may have been cached; it is suitable for |
469 // use when stepping, but otherwise may be out of sync with the current stack. | 555 // use when stepping, but otherwise may be out of sync with the current stack. |
470 DebuggerStackTrace* StackTrace(); | 556 DebuggerStackTrace* StackTrace(); |
471 DebuggerStackTrace* CurrentStackTrace(); | 557 DebuggerStackTrace* CurrentStackTrace(); |
472 | 558 |
| 559 // Returns a stack trace with frames corresponding to invisible functions |
| 560 // omitted. CurrentAsyncStackTrace always returns a new trace on the current |
| 561 // stack. The trace returned by AsyncStackTrace may have been cached; it is |
| 562 // suitable for use when stepping, but otherwise may be out of sync with the |
| 563 // current stack. |
| 564 DebuggerStackTrace* AsyncStackTrace(); |
| 565 DebuggerStackTrace* CurrentAsyncStackTrace(); |
| 566 |
| 567 DebuggerStackTrace* AsyncReturnStack(); |
| 568 DebuggerStackTrace* CurrentAsyncReturnStack(); |
| 569 |
473 // Returns a debugger stack trace corresponding to a dart.core.StackTrace. | 570 // Returns a debugger stack trace corresponding to a dart.core.StackTrace. |
474 // Frames corresponding to invisible functions are omitted. It is not valid | 571 // Frames corresponding to invisible functions are omitted. It is not valid |
475 // to query local variables in the returned stack. | 572 // to query local variables in the returned stack. |
476 DebuggerStackTrace* StackTraceFrom(const class StackTrace& dart_stacktrace); | 573 DebuggerStackTrace* StackTraceFrom(const class StackTrace& dart_stacktrace); |
477 | 574 |
478 RawArray* GetInstanceFields(const Instance& obj); | 575 RawArray* GetInstanceFields(const Instance& obj); |
479 RawArray* GetStaticFields(const Class& cls); | 576 RawArray* GetStaticFields(const Class& cls); |
480 RawArray* GetLibraryFields(const Library& lib); | 577 RawArray* GetLibraryFields(const Library& lib); |
481 RawArray* GetGlobalFields(const Library& lib); | 578 RawArray* GetGlobalFields(const Library& lib); |
482 | 579 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 static bool IsDebuggable(const Function& func); | 620 static bool IsDebuggable(const Function& func); |
524 | 621 |
525 intptr_t limitBreakpointId() { return next_id_; } | 622 intptr_t limitBreakpointId() { return next_id_; } |
526 | 623 |
527 // Callback to the debugger to continue frame rewind, post-deoptimization. | 624 // Callback to the debugger to continue frame rewind, post-deoptimization. |
528 void RewindPostDeopt(); | 625 void RewindPostDeopt(); |
529 | 626 |
530 private: | 627 private: |
531 RawError* PauseRequest(ServiceEvent::EventKind kind); | 628 RawError* PauseRequest(ServiceEvent::EventKind kind); |
532 | 629 |
| 630 /// Finds the breakpoint we hit at |location|. |
| 631 Breakpoint* FindHitBreakpoint(BreakpointLocation* location, |
| 632 ActivationFrame* top_frame); |
| 633 |
| 634 // Returns true if the debugger had just taken a step after hitting a |
| 635 // synthetic async breakpoint. |
| 636 bool SteppedForSyntheticAsyncBreakpoint() const; |
| 637 |
| 638 RawError* StepForSyntheticAsyncBreakpoint(Breakpoint* bpt); |
| 639 |
| 640 void CleanupSyntheticAsyncBreakpoint(); |
| 641 |
533 // Will return false if we are not at an await. | 642 // Will return false if we are not at an await. |
534 bool SetupStepOverAsyncSuspension(const char** error); | 643 bool SetupStepOverAsyncSuspension(const char** error); |
535 | 644 |
| 645 uword GetAsyncActivationGeneratorSteppingFramePointer(); |
| 646 |
536 bool NeedsIsolateEvents(); | 647 bool NeedsIsolateEvents(); |
537 bool NeedsDebugEvents(); | 648 bool NeedsDebugEvents(); |
538 void InvokeEventHandler(ServiceEvent* event); | 649 void InvokeEventHandler(ServiceEvent* event); |
539 | 650 |
540 void SendBreakpointEvent(ServiceEvent::EventKind kind, Breakpoint* bpt); | 651 void SendBreakpointEvent(ServiceEvent::EventKind kind, Breakpoint* bpt); |
541 | 652 |
542 bool IsAtAsyncJump(ActivationFrame* top_frame); | 653 bool IsAtAsyncJump(ActivationFrame* top_frame); |
543 void FindCompiledFunctions(const Script& script, | 654 void FindCompiledFunctions(const Script& script, |
544 TokenPosition start_pos, | 655 TokenPosition start_pos, |
545 TokenPosition end_pos, | 656 TokenPosition end_pos, |
(...skipping 21 matching lines...) Expand all Loading... |
567 BreakpointLocation* GetBreakpointLocation(const Script& script, | 678 BreakpointLocation* GetBreakpointLocation(const Script& script, |
568 TokenPosition token_pos, | 679 TokenPosition token_pos, |
569 intptr_t requested_column); | 680 intptr_t requested_column); |
570 void MakeCodeBreakpointAt(const Function& func, BreakpointLocation* bpt); | 681 void MakeCodeBreakpointAt(const Function& func, BreakpointLocation* bpt); |
571 // Returns NULL if no breakpoint exists for the given address. | 682 // Returns NULL if no breakpoint exists for the given address. |
572 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); | 683 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); |
573 | 684 |
574 void SyncBreakpointLocation(BreakpointLocation* loc); | 685 void SyncBreakpointLocation(BreakpointLocation* loc); |
575 | 686 |
576 ActivationFrame* TopDartFrame() const; | 687 ActivationFrame* TopDartFrame() const; |
577 static ActivationFrame* CollectDartFrame(Isolate* isolate, | 688 static ActivationFrame* CollectDartFrame( |
578 uword pc, | 689 Isolate* isolate, |
579 StackFrame* frame, | 690 uword pc, |
580 const Code& code, | 691 StackFrame* frame, |
581 const Array& deopt_frame, | 692 const Code& code, |
582 intptr_t deopt_frame_offset); | 693 const Array& deopt_frame, |
| 694 intptr_t deopt_frame_offset, |
| 695 ActivationFrame::Kind kind = ActivationFrame::kRegular); |
583 static RawArray* DeoptimizeToArray(Thread* thread, | 696 static RawArray* DeoptimizeToArray(Thread* thread, |
584 StackFrame* frame, | 697 StackFrame* frame, |
585 const Code& code); | 698 const Code& code); |
| 699 static DebuggerStackTrace* CollectAsyncStackTrace(); |
586 static DebuggerStackTrace* CollectStackTrace(); | 700 static DebuggerStackTrace* CollectStackTrace(); |
| 701 static DebuggerStackTrace* CollectAsyncReturnCallStack(); |
| 702 |
587 void SignalPausedEvent(ActivationFrame* top_frame, Breakpoint* bpt); | 703 void SignalPausedEvent(ActivationFrame* top_frame, Breakpoint* bpt); |
588 | 704 |
589 intptr_t nextId() { return next_id_++; } | 705 intptr_t nextId() { return next_id_++; } |
590 | 706 |
591 bool ShouldPauseOnException(DebuggerStackTrace* stack_trace, | 707 bool ShouldPauseOnException(DebuggerStackTrace* stack_trace, |
592 const Instance& exc); | 708 const Instance& exc); |
593 | 709 |
594 void CollectLibraryFields(const GrowableObjectArray& field_list, | 710 void CollectLibraryFields(const GrowableObjectArray& field_list, |
595 const Library& lib, | 711 const Library& lib, |
596 const String& prefix, | 712 const String& prefix, |
597 bool include_private_fields); | 713 bool include_private_fields); |
598 | 714 |
599 // Handles any events which pause vm execution. Breakpoints, | 715 // Handles any events which pause vm execution. Breakpoints, |
600 // interrupts, etc. | 716 // interrupts, etc. |
601 void Pause(ServiceEvent* event); | 717 void Pause(ServiceEvent* event); |
602 | 718 |
603 void HandleSteppingRequest(DebuggerStackTrace* stack_trace, | 719 void HandleSteppingRequest(DebuggerStackTrace* stack_trace, |
604 bool skip_next_step = false); | 720 bool skip_next_step = false); |
605 | 721 |
| 722 void CacheStackTraces(DebuggerStackTrace* stack_trace, |
| 723 DebuggerStackTrace* async_stack_trace, |
| 724 DebuggerStackTrace* async_return_stack_trace); |
| 725 void ClearCachedStackTraces(); |
| 726 |
606 // Can we rewind to the indicated frame? | 727 // Can we rewind to the indicated frame? |
607 bool CanRewindFrame(intptr_t frame_index, const char** error) const; | 728 bool CanRewindFrame(intptr_t frame_index, const char** error) const; |
608 | 729 |
609 void RewindToFrame(intptr_t frame_index); | 730 void RewindToFrame(intptr_t frame_index); |
610 void RewindToUnoptimizedFrame(StackFrame* frame, const Code& code); | 731 void RewindToUnoptimizedFrame(StackFrame* frame, const Code& code); |
611 void RewindToOptimizedFrame(StackFrame* frame, | 732 void RewindToOptimizedFrame(StackFrame* frame, |
612 const Code& code, | 733 const Code& code, |
613 intptr_t post_deopt_frame_index); | 734 intptr_t post_deopt_frame_index); |
614 | 735 |
615 Isolate* isolate_; | 736 Isolate* isolate_; |
(...skipping 22 matching lines...) Expand all Loading... |
638 // paused for breakpoints, isolate interruption, and (sometimes) | 759 // paused for breakpoints, isolate interruption, and (sometimes) |
639 // exceptions. | 760 // exceptions. |
640 ServiceEvent* pause_event_; | 761 ServiceEvent* pause_event_; |
641 | 762 |
642 // An id -> object map. Valid only while IsPaused(). | 763 // An id -> object map. Valid only while IsPaused(). |
643 RemoteObjectCache* obj_cache_; | 764 RemoteObjectCache* obj_cache_; |
644 | 765 |
645 // Current stack trace. Valid only while IsPaused(). | 766 // Current stack trace. Valid only while IsPaused(). |
646 DebuggerStackTrace* stack_trace_; | 767 DebuggerStackTrace* stack_trace_; |
647 | 768 |
| 769 // Current async stack trace. Valid only while IsPaused(). |
| 770 DebuggerStackTrace* async_stack_trace_; |
| 771 |
| 772 // Current async return call trace. Valid only while IsPaused(). |
| 773 DebuggerStackTrace* async_return_call_stack_; |
| 774 |
648 // When stepping through code, only pause the program if the top | 775 // When stepping through code, only pause the program if the top |
649 // frame corresponds to this fp value, or if the top frame is | 776 // frame corresponds to this fp value, or if the top frame is |
650 // lower on the stack. | 777 // lower on the stack. |
651 uword stepping_fp_; | 778 uword stepping_fp_; |
652 | 779 |
| 780 // In order to support automatic step-out behaviour for asynchronous functions |
| 781 // we track the top frame's awaiter. This is where execution should begin |
| 782 // once we've left the current function. We keep track of the |
| 783 // async_stepping_fp_ and use it to determine if we have single stepped our |
| 784 // way out of the asynchronous function. |
| 785 RawObject* top_frame_awaiter_; |
| 786 uword async_stepping_fp_; |
| 787 |
653 // If we step while at a breakpoint, we would hit the same pc twice. | 788 // If we step while at a breakpoint, we would hit the same pc twice. |
654 // We use this field to let us skip the next single-step after a | 789 // We use this field to let us skip the next single-step after a |
655 // breakpoint. | 790 // breakpoint. |
656 bool skip_next_step_; | 791 bool skip_next_step_; |
657 | 792 |
658 // We keep this breakpoint alive until after the debugger does the step over | 793 // We keep this breakpoint alive until after the debugger does the step over |
659 // async continuation machinery so that we can report that we've stopped | 794 // async continuation machinery so that we can report that we've stopped |
660 // at the breakpoint. | 795 // at the breakpoint. |
661 Breakpoint* synthetic_async_breakpoint_; | 796 Breakpoint* synthetic_async_breakpoint_; |
662 | 797 |
663 Dart_ExceptionPauseInfo exc_pause_info_; | 798 Dart_ExceptionPauseInfo exc_pause_info_; |
664 | 799 |
665 static EventHandler* event_handler_; | 800 static EventHandler* event_handler_; |
666 | 801 |
667 friend class Isolate; | 802 friend class Isolate; |
668 friend class BreakpointLocation; | 803 friend class BreakpointLocation; |
669 DISALLOW_COPY_AND_ASSIGN(Debugger); | 804 DISALLOW_COPY_AND_ASSIGN(Debugger); |
670 }; | 805 }; |
671 | 806 |
672 | 807 |
673 } // namespace dart | 808 } // namespace dart |
674 | 809 |
675 #endif // RUNTIME_VM_DEBUGGER_H_ | 810 #endif // RUNTIME_VM_DEBUGGER_H_ |
OLD | NEW |