| 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 VM_DEBUGGER_H_ | 5 #ifndef VM_DEBUGGER_H_ |
| 6 #define VM_DEBUGGER_H_ | 6 #define VM_DEBUGGER_H_ |
| 7 | 7 |
| 8 #include "include/dart_debugger_api.h" | 8 #include "include/dart_debugger_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 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 class ActiveVariables; | 15 class ActiveVariables; |
| 16 class CodeBreakpoint; | 16 class CodeBreakpoint; |
| 17 class Isolate; | 17 class Isolate; |
| 18 class JSONArray; | 18 class JSONArray; |
| 19 class JSONStream; | 19 class JSONStream; |
| 20 class ObjectPointerVisitor; | 20 class ObjectPointerVisitor; |
| 21 class RemoteObjectCache; | 21 class RemoteObjectCache; |
| 22 class SourceBreakpoint; | 22 class SourceBreakpoint; |
| 23 class StackFrame; | 23 class StackFrame; |
| 24 | 24 |
| 25 // SourceBreakpoint represents a user-specified breakpoint location in | 25 // SourceBreakpoint represents a user-specified breakpoint location in |
| 26 // Dart source. There may be more than one CodeBreakpoint object per | 26 // Dart source. There may be more than one CodeBreakpoint object per |
| 27 // SourceBreakpoint. | 27 // SourceBreakpoint. |
| 28 class SourceBreakpoint { | 28 class SourceBreakpoint { |
| 29 public: | 29 public: |
| 30 SourceBreakpoint(intptr_t id, const Function& func, intptr_t token_pos); | 30 SourceBreakpoint(intptr_t id, const Script& script, intptr_t token_pos); |
| 31 | 31 |
| 32 RawFunction* function() const { return function_; } | 32 RawFunction* function() const { return function_; } |
| 33 intptr_t token_pos() const { return token_pos_; } | 33 intptr_t token_pos() const { return token_pos_; } |
| 34 void set_token_pos(intptr_t value) { token_pos_ = value; } | |
| 35 intptr_t id() const { return id_; } | 34 intptr_t id() const { return id_; } |
| 36 | 35 |
| 37 RawScript* SourceCode(); | 36 RawScript* script() { return script_; } |
| 38 RawString* SourceUrl(); | 37 RawString* SourceUrl(); |
| 39 intptr_t LineNumber(); | 38 intptr_t LineNumber(); |
| 40 | 39 |
| 41 void GetCodeLocation(Library* lib, | 40 void GetCodeLocation(Library* lib, Script* script, intptr_t* token_pos); |
| 42 Script* script, | |
| 43 intptr_t* token_pos) const; | |
| 44 | 41 |
| 45 void Enable(); | 42 void Enable(); |
| 46 void Disable(); | 43 void Disable(); |
| 47 bool IsEnabled() const { return is_enabled_; } | 44 bool IsEnabled() const { return is_enabled_; } |
| 45 bool IsResolved() { return is_resolved_; } |
| 48 | 46 |
| 49 void PrintToJSONStream(JSONStream* stream) const; | 47 void PrintToJSONStream(JSONStream* stream); |
| 50 | 48 |
| 51 private: | 49 private: |
| 52 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 50 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 53 | 51 |
| 54 void set_function(const Function& func); | 52 void SetResolved(const Function& func, intptr_t token_pos); |
| 55 void set_next(SourceBreakpoint* value) { next_ = value; } | 53 void set_next(SourceBreakpoint* value) { next_ = value; } |
| 56 SourceBreakpoint* next() const { return this->next_; } | 54 SourceBreakpoint* next() const { return this->next_; } |
| 57 | 55 |
| 58 const intptr_t id_; | 56 const intptr_t id_; |
| 57 RawScript* script_; |
| 58 intptr_t token_pos_; |
| 59 bool is_resolved_; |
| 60 bool is_enabled_; |
| 61 SourceBreakpoint* next_; |
| 62 |
| 63 // Valid for resolved breakpoints: |
| 59 RawFunction* function_; | 64 RawFunction* function_; |
| 60 intptr_t token_pos_; | |
| 61 intptr_t line_number_; | 65 intptr_t line_number_; |
| 62 bool is_enabled_; | |
| 63 | |
| 64 SourceBreakpoint* next_; | |
| 65 | 66 |
| 66 friend class Debugger; | 67 friend class Debugger; |
| 67 DISALLOW_COPY_AND_ASSIGN(SourceBreakpoint); | 68 DISALLOW_COPY_AND_ASSIGN(SourceBreakpoint); |
| 68 }; | 69 }; |
| 69 | 70 |
| 70 | 71 |
| 71 // CodeBreakpoint represents a location in compiled code. There may be | 72 // CodeBreakpoint represents a location in compiled code. There may be |
| 72 // more than one CodeBreakpoint for one SourceBreakpoint, e.g. when a | 73 // more than one CodeBreakpoint for one SourceBreakpoint, e.g. when a |
| 73 // function gets compiled as a regular function and as a closure. | 74 // function gets compiled as a regular function and as a closure. |
| 74 class CodeBreakpoint { | 75 class CodeBreakpoint { |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 static bool IsDebuggable(const Function& func); | 372 static bool IsDebuggable(const Function& func); |
| 372 | 373 |
| 373 private: | 374 private: |
| 374 enum ResumeAction { | 375 enum ResumeAction { |
| 375 kContinue, | 376 kContinue, |
| 376 kStepOver, | 377 kStepOver, |
| 377 kStepOut, | 378 kStepOut, |
| 378 kSingleStep | 379 kSingleStep |
| 379 }; | 380 }; |
| 380 | 381 |
| 382 void FindEquivalentFunctions(const Script& script, |
| 383 intptr_t start_pos, |
| 384 intptr_t end_pos, |
| 385 GrowableObjectArray* function_list); |
| 386 RawFunction* FindBestFit(const Script& script, intptr_t token_pos); |
| 387 RawFunction* FindInnermostClosure(const Function& function, |
| 388 intptr_t token_pos); |
| 381 intptr_t ResolveBreakpointPos(const Function& func, | 389 intptr_t ResolveBreakpointPos(const Function& func, |
| 382 intptr_t first_token_pos, | 390 intptr_t requested_token_pos); |
| 383 intptr_t last_token_pos); | |
| 384 void DeoptimizeWorld(); | 391 void DeoptimizeWorld(); |
| 385 void InstrumentForStepping(const Function& target_function); | 392 void InstrumentForStepping(const Function& target_function); |
| 393 SourceBreakpoint* SetBreakpoint(const Script& script, intptr_t token_pos); |
| 386 SourceBreakpoint* SetBreakpoint(const Function& target_function, | 394 SourceBreakpoint* SetBreakpoint(const Function& target_function, |
| 387 intptr_t first_token_pos, | 395 intptr_t first_token_pos, |
| 388 intptr_t last_token_pos); | 396 intptr_t last_token_pos); |
| 389 void RemoveInternalBreakpoints(); | 397 void RemoveInternalBreakpoints(); |
| 390 void UnlinkCodeBreakpoints(SourceBreakpoint* src_bpt); | 398 void UnlinkCodeBreakpoints(SourceBreakpoint* src_bpt); |
| 391 void RegisterSourceBreakpoint(SourceBreakpoint* bpt); | 399 void RegisterSourceBreakpoint(SourceBreakpoint* bpt); |
| 392 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); | 400 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); |
| 393 SourceBreakpoint* GetSourceBreakpoint(const Function& func, | 401 SourceBreakpoint* GetSourceBreakpoint(const Script& script, |
| 394 intptr_t token_pos); | 402 intptr_t token_pos); |
| 395 void MakeCodeBreakpointsAt(const Function& func, | 403 void MakeCodeBreakpointsAt(const Function& func, |
| 396 intptr_t token_pos, | |
| 397 SourceBreakpoint* bpt); | 404 SourceBreakpoint* bpt); |
| 398 // Returns NULL if no breakpoint exists for the given address. | 405 // Returns NULL if no breakpoint exists for the given address. |
| 399 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); | 406 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); |
| 400 | 407 |
| 401 void SyncBreakpoint(SourceBreakpoint* bpt); | 408 void SyncBreakpoint(SourceBreakpoint* bpt); |
| 402 | 409 |
| 403 ActivationFrame* TopDartFrame() const; | 410 ActivationFrame* TopDartFrame() const; |
| 404 static ActivationFrame* CollectDartFrame(Isolate* isolate, | 411 static ActivationFrame* CollectDartFrame(Isolate* isolate, |
| 405 uword pc, | 412 uword pc, |
| 406 StackFrame* frame, | 413 StackFrame* frame, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 475 |
| 469 friend class Isolate; | 476 friend class Isolate; |
| 470 friend class SourceBreakpoint; | 477 friend class SourceBreakpoint; |
| 471 DISALLOW_COPY_AND_ASSIGN(Debugger); | 478 DISALLOW_COPY_AND_ASSIGN(Debugger); |
| 472 }; | 479 }; |
| 473 | 480 |
| 474 | 481 |
| 475 } // namespace dart | 482 } // namespace dart |
| 476 | 483 |
| 477 #endif // VM_DEBUGGER_H_ | 484 #endif // VM_DEBUGGER_H_ |
| OLD | NEW |