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

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

Issue 9460012: StepOver, StepInto, StepOut (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
OLDNEW
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 {
11 11
12 class Breakpoint; 12 class Breakpoint;
13 class Isolate; 13 class Isolate;
14 class ObjectPointerVisitor; 14 class ObjectPointerVisitor;
15 class ActiveVariables; 15 class ActiveVariables;
16 16
17 17
18 // Breakpoint represents a location in Dart source and the corresponding 18 // Breakpoint represents a location in Dart source and the corresponding
19 // address in compiled code. 19 // address in compiled code.
20 class Breakpoint { 20 class Breakpoint {
21 public: 21 public:
22 Breakpoint(const Function& func, intptr_t pc_desc_index); 22 Breakpoint(const Function& func, intptr_t pc_desc_index);
23 23
24 RawFunction* function() const { return function_; } 24 RawFunction* function() const { return function_; }
25 uword pc() const { return pc_; } 25 uword pc() const { return pc_; }
26 intptr_t token_index() const { return token_index_; } 26 intptr_t token_index() const { return token_index_; }
27 bool is_temporary() const { return is_temporary_; }
28 void set_temporary(bool value) { is_temporary_ = value; }
27 29
28 RawScript* SourceCode(); 30 RawScript* SourceCode();
29 RawString* SourceUrl(); 31 RawString* SourceUrl();
30 intptr_t LineNumber(); 32 intptr_t LineNumber();
31 33
34 void SetActive(bool value);
35 bool IsActive();
36
32 private: 37 private:
33 void VisitObjectPointers(ObjectPointerVisitor* visitor); 38 void VisitObjectPointers(ObjectPointerVisitor* visitor);
34 39
35 void set_next(Breakpoint* value) { next_ = value; } 40 void set_next(Breakpoint* value) { next_ = value; }
36 Breakpoint* next() const { return this->next_; } 41 Breakpoint* next() const { return this->next_; }
37 intptr_t pc_desc_index() const { return pc_desc_index_; } 42 intptr_t pc_desc_index() const { return pc_desc_index_; }
38 43
44 void PatchCode();
45 void RestoreCode();
46 void PatchFunctionReturn();
47 void RestoreFunctionReturn();
48
39 RawFunction* function_; 49 RawFunction* function_;
40 intptr_t pc_desc_index_; 50 intptr_t pc_desc_index_;
41 intptr_t token_index_; 51 intptr_t token_index_;
42 uword pc_; 52 uword pc_;
43 uword saved_bytes_;
44 intptr_t line_number_; 53 intptr_t line_number_;
54 bool is_temporary_;
55
56 bool is_patched_;
57 PcDescriptors::Kind breakpoint_kind_;
58 union {
59 uword target_address_;
60 uint8_t raw[2 * sizeof(uword)];
61 } saved_bytes_;
62
45 Breakpoint* next_; 63 Breakpoint* next_;
46 64
47 friend class Debugger; 65 friend class Debugger;
48 DISALLOW_COPY_AND_ASSIGN(Breakpoint); 66 DISALLOW_COPY_AND_ASSIGN(Breakpoint);
49 }; 67 };
50 68
51 69
52 // ActivationFrame represents one dart function activation frame 70 // ActivationFrame represents one dart function activation frame
53 // on the call stack. 71 // on the call stack.
54 class ActivationFrame : public ZoneAllocated { 72 class ActivationFrame : public ZoneAllocated {
55 public: 73 public:
56 explicit ActivationFrame(uword pc, uword fp); 74 explicit ActivationFrame(uword pc, uword fp, uword sp);
57 75
58 uword pc() const { return pc_; } 76 uword pc() const { return pc_; }
59 uword fp() const { return fp_; } 77 uword fp() const { return fp_; }
78 uword sp() const { return sp_; }
60 79
61 const Function& DartFunction(); 80 const Function& DartFunction();
62 RawString* QualifiedFunctionName(); 81 RawString* QualifiedFunctionName();
63 RawString* SourceUrl(); 82 RawString* SourceUrl();
64 RawScript* SourceScript(); 83 RawScript* SourceScript();
65 intptr_t TokenIndex(); 84 intptr_t TokenIndex();
66 intptr_t LineNumber(); 85 intptr_t LineNumber();
67 const char* ToCString(); 86 const char* ToCString();
68 87
69 intptr_t NumLocalVariables(); 88 intptr_t NumLocalVariables();
70 89
71 void VariableAt(intptr_t i, 90 void VariableAt(intptr_t i,
72 String* name, 91 String* name,
73 intptr_t* token_pos, 92 intptr_t* token_pos,
74 intptr_t* end_pos, 93 intptr_t* end_pos,
75 Instance* value); 94 Instance* value);
76 95
77 RawArray* GetLocalVariables(); 96 RawArray* GetLocalVariables();
78 97
79 private: 98 private:
80 void GetDescIndices(); 99 void GetDescIndices();
81 RawInstance* GetLocalVarValue(intptr_t slot_index); 100 RawInstance* GetLocalVarValue(intptr_t slot_index);
101 RawInstance* GetInstanceCallReceiver(intptr_t num_actual_args);
82 102
83 uword pc_; 103 uword pc_;
84 uword fp_; 104 uword fp_;
105 uword sp_;
85 Function& function_; 106 Function& function_;
86 intptr_t token_index_; 107 intptr_t token_index_;
87 intptr_t line_number_; 108 intptr_t line_number_;
88 109
89 LocalVarDescriptors* var_descriptors_; 110 LocalVarDescriptors* var_descriptors_;
90 ZoneGrowableArray<intptr_t> desc_indices_; 111 ZoneGrowableArray<intptr_t> desc_indices_;
91 112
113 friend class Debugger;
92 DISALLOW_COPY_AND_ASSIGN(ActivationFrame); 114 DISALLOW_COPY_AND_ASSIGN(ActivationFrame);
93 }; 115 };
94 116
95 117
96 // Array of function activations on the call stack. 118 // Array of function activations on the call stack.
97 class StackTrace : public ZoneAllocated { 119 class StackTrace : public ZoneAllocated {
98 public: 120 public:
99 explicit StackTrace(int capacity) : trace_(capacity) { } 121 explicit StackTrace(int capacity) : trace_(capacity) { }
100 122
101 intptr_t Length() const { return trace_.length(); } 123 intptr_t Length() const { return trace_.length(); }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 155
134 // Set breakpoint at closest location to function entry. 156 // Set breakpoint at closest location to function entry.
135 Breakpoint* SetBreakpointAtEntry(const Function& target_function, 157 Breakpoint* SetBreakpointAtEntry(const Function& target_function,
136 Error* error); 158 Error* error);
137 Breakpoint* SetBreakpointAtLine(const String& script_url, 159 Breakpoint* SetBreakpointAtLine(const String& script_url,
138 intptr_t line_number, 160 intptr_t line_number,
139 Error* error); 161 Error* error);
140 162
141 void RemoveBreakpoint(Breakpoint* bpt); 163 void RemoveBreakpoint(Breakpoint* bpt);
142 164
165 void SetStepOver() { resume_action_ = kStepOver; }
166 void SetStepInto() { resume_action_ = kStepInto; }
167 void SetStepOut() { resume_action_ = kStepOut; }
168
143 void VisitObjectPointers(ObjectPointerVisitor* visitor); 169 void VisitObjectPointers(ObjectPointerVisitor* visitor);
144 170
145 // Returns NULL if no breakpoint exists for the given address. 171 // Returns NULL if no breakpoint exists for the given address.
146 Breakpoint* GetBreakpoint(uword breakpoint_address); 172 Breakpoint* GetBreakpoint(uword breakpoint_address);
147 173
148 // Called from Runtime when a breakpoint in Dart code is reached. 174 // Called from Runtime when a breakpoint in Dart code is reached.
149 void BreakpointCallback(); 175 void BreakpointCallback();
150 176
151 RawArray* GetInstanceFields(const Instance& obj); 177 RawArray* GetInstanceFields(const Instance& obj);
152 RawArray* GetStaticFields(const Class& cls); 178 RawArray* GetStaticFields(const Class& cls);
153 179
154 // Utility functions. 180 // Utility functions.
155 static const char* QualifiedFunctionName(const Function& func); 181 static const char* QualifiedFunctionName(const Function& func);
156 182
157 RawObject* GetInstanceField(const Class& cls, 183 RawObject* GetInstanceField(const Class& cls,
158 const String& field_name, 184 const String& field_name,
159 const Instance& object); 185 const Instance& object);
160 RawObject* GetStaticField(const Class& cls, 186 RawObject* GetStaticField(const Class& cls,
161 const String& field_name); 187 const String& field_name);
162 188
163 private: 189 private:
190 enum ResumeAction {
191 kContinue,
192 kStepOver,
193 kStepInto,
194 kStepOut
195 };
196
197 void InstrumentForStepping(const Function &target_function);
164 Breakpoint* SetBreakpoint(const Function& target_function, 198 Breakpoint* SetBreakpoint(const Function& target_function,
165 intptr_t token_index, 199 intptr_t token_index,
166 Error* error); 200 Error* error);
167 void UnsetBreakpoint(Breakpoint* bpt); 201 void UnsetBreakpoint(Breakpoint* bpt);
202 void RemoveTemporaryBreakpoints();
168 Breakpoint* NewBreakpoint(const Function& func, intptr_t pc_desc_index); 203 Breakpoint* NewBreakpoint(const Function& func, intptr_t pc_desc_index);
169 void RegisterBreakpoint(Breakpoint* bpt); 204 void RegisterBreakpoint(Breakpoint* bpt);
170 Breakpoint* GetBreakpointByFunction(const Function& func, 205 Breakpoint* GetBreakpointByFunction(const Function& func,
171 intptr_t token_index); 206 intptr_t token_index);
172 207
173 Isolate* isolate_; 208 Isolate* isolate_;
174 bool initialized_; 209 bool initialized_;
175 BreakpointHandler* bp_handler_; 210 BreakpointHandler* bp_handler_;
176 Breakpoint* breakpoints_; 211 Breakpoint* breakpoints_;
212
213 // Tells debugger what to do when resuming execution after a breakpoint.
214 ResumeAction resume_action_;
215
177 DISALLOW_COPY_AND_ASSIGN(Debugger); 216 DISALLOW_COPY_AND_ASSIGN(Debugger);
178 }; 217 };
179 218
180 219
181 } // namespace dart 220 } // namespace dart
182 221
183 #endif // VM_DEBUGGER_H_ 222 #endif // VM_DEBUGGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698