| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/object.h" | 8 #include "vm/object.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 friend class Debugger; | 44 friend class Debugger; |
| 45 DISALLOW_COPY_AND_ASSIGN(Breakpoint); | 45 DISALLOW_COPY_AND_ASSIGN(Breakpoint); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 | 48 |
| 49 // ActivationFrame represents one dart function activation frame | 49 // ActivationFrame represents one dart function activation frame |
| 50 // on the call stack. | 50 // on the call stack. |
| 51 class ActivationFrame : public ZoneAllocated { | 51 class ActivationFrame : public ZoneAllocated { |
| 52 public: | 52 public: |
| 53 explicit ActivationFrame(uword pc); | 53 explicit ActivationFrame(uword pc, uword fp); |
| 54 | 54 |
| 55 uword pc() const { return pc_; } | 55 uword pc() const { return pc_; } |
| 56 uword fp() const { return fp_; } |
| 56 | 57 |
| 57 Function* DartFunction(); | 58 const Function& DartFunction(); |
| 58 RawString* QualifiedFunctionName(); | 59 RawString* QualifiedFunctionName(); |
| 59 RawString* SourceUrl(); | 60 RawString* SourceUrl(); |
| 60 RawScript* SourceScript(); | 61 RawScript* SourceScript(); |
| 61 intptr_t TokenIndex(); | 62 intptr_t TokenIndex(); |
| 62 intptr_t LineNumber(); | 63 intptr_t LineNumber(); |
| 63 const char* ToCString(); | 64 const char* ToCString(); |
| 64 | 65 |
| 65 ActiveVariables* LocalVariables(); | 66 intptr_t NumLocalVariables(); |
| 67 |
| 68 void VariableAt(intptr_t i, |
| 69 String* name, |
| 70 intptr_t* token_pos, |
| 71 intptr_t* end_pos, |
| 72 Instance* value); |
| 66 | 73 |
| 67 // Returns the value of the given variable in the context of the | 74 // Returns the value of the given variable in the context of the |
| 68 // activation frame. | 75 // activation frame. |
| 69 RawInstance* Value(const String& variable_name); | 76 RawInstance* Value(const String& variable_name); |
| 70 | 77 |
| 71 private: | 78 private: |
| 79 void GetLocalVariables(); |
| 80 RawInstance* GetLocalVarValue(intptr_t slot_index); |
| 81 |
| 72 uword pc_; | 82 uword pc_; |
| 73 Function* function_; | 83 uword fp_; |
| 84 Function& function_; |
| 74 intptr_t token_index_; | 85 intptr_t token_index_; |
| 75 intptr_t line_number_; | 86 intptr_t line_number_; |
| 76 ActiveVariables* locals_; | 87 |
| 88 LocalVarDescriptors* var_descriptors_; |
| 89 ZoneGrowableArray<intptr_t> desc_indices_; |
| 77 | 90 |
| 78 DISALLOW_COPY_AND_ASSIGN(ActivationFrame); | 91 DISALLOW_COPY_AND_ASSIGN(ActivationFrame); |
| 79 }; | 92 }; |
| 80 | 93 |
| 81 | 94 |
| 82 // Array of function activations on the call stack. | 95 // Array of function activations on the call stack. |
| 83 class StackTrace : public ZoneAllocated { | 96 class StackTrace : public ZoneAllocated { |
| 84 public: | 97 public: |
| 85 explicit StackTrace(int capacity) : trace_(capacity) { } | 98 explicit StackTrace(int capacity) : trace_(capacity) { } |
| 86 | 99 |
| 87 intptr_t Length() const { return trace_.length(); } | 100 intptr_t Length() const { return trace_.length(); } |
| 88 | 101 |
| 89 ActivationFrame* ActivationFrameAt(int i) const { | 102 ActivationFrame* ActivationFrameAt(int i) const { |
| 90 ASSERT(i < trace_.length()); | 103 ASSERT(i < trace_.length()); |
| 91 return trace_[i]; | 104 return trace_[i]; |
| 92 } | 105 } |
| 93 private: | 106 private: |
| 94 void AddActivation(ActivationFrame* frame); | 107 void AddActivation(ActivationFrame* frame); |
| 95 ZoneGrowableArray<ActivationFrame*> trace_; | 108 ZoneGrowableArray<ActivationFrame*> trace_; |
| 96 | 109 |
| 97 friend class Debugger; | 110 friend class Debugger; |
| 98 DISALLOW_COPY_AND_ASSIGN(StackTrace); | 111 DISALLOW_COPY_AND_ASSIGN(StackTrace); |
| 99 }; | 112 }; |
| 100 | 113 |
| 101 | 114 |
| 102 class ActiveVariables : public ZoneAllocated { | |
| 103 public: | |
| 104 ActiveVariables(const Function& function, intptr_t token_pos); | |
| 105 | |
| 106 intptr_t Length() const { return desc_indices_.length(); } | |
| 107 | |
| 108 void VariableAt(intptr_t i, | |
| 109 String* name, | |
| 110 intptr_t* token_pos, | |
| 111 intptr_t* end_pos, | |
| 112 Instance* value) const; | |
| 113 private: | |
| 114 LocalVarDescriptors* descriptors_; | |
| 115 ZoneGrowableArray<intptr_t> desc_indices_; | |
| 116 DISALLOW_COPY_AND_ASSIGN(ActiveVariables); | |
| 117 }; | |
| 118 | |
| 119 | |
| 120 typedef void BreakpointHandler(Breakpoint* bpt, StackTrace* stack); | 115 typedef void BreakpointHandler(Breakpoint* bpt, StackTrace* stack); |
| 121 | 116 |
| 122 | 117 |
| 123 class Debugger { | 118 class Debugger { |
| 124 public: | 119 public: |
| 125 Debugger(); | 120 Debugger(); |
| 126 | 121 |
| 127 void Initialize(Isolate* isolate); | 122 void Initialize(Isolate* isolate); |
| 128 bool IsActive(); | 123 bool IsActive(); |
| 129 | 124 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 153 bool initialized_; | 148 bool initialized_; |
| 154 BreakpointHandler* bp_handler_; | 149 BreakpointHandler* bp_handler_; |
| 155 Breakpoint* breakpoints_; | 150 Breakpoint* breakpoints_; |
| 156 DISALLOW_COPY_AND_ASSIGN(Debugger); | 151 DISALLOW_COPY_AND_ASSIGN(Debugger); |
| 157 }; | 152 }; |
| 158 | 153 |
| 159 | 154 |
| 160 } // namespace dart | 155 } // namespace dart |
| 161 | 156 |
| 162 #endif // VM_DEBUGGER_H_ | 157 #endif // VM_DEBUGGER_H_ |
| OLD | NEW |