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

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

Issue 9581013: Splitting debugger breakpoints into two parts (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/debugger.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) 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 SourceBreakpoint;
13 class CodeBreakpoint;
13 class Isolate; 14 class Isolate;
14 class ObjectPointerVisitor; 15 class ObjectPointerVisitor;
15 class ActiveVariables; 16 class ActiveVariables;
16 17
17 18
18 // Breakpoint represents a location in Dart source and the corresponding 19 // SourceBreakpoint represents a user-specified breakpoint location in
19 // address in compiled code. 20 // Dart source. There may be more than one CodeBreakpoint object per
20 class Breakpoint { 21 // SourceBreakpoint.
22 class SourceBreakpoint {
21 public: 23 public:
22 Breakpoint(const Function& func, intptr_t pc_desc_index); 24 SourceBreakpoint(const Function& func, intptr_t token_index);
23 25
24 RawFunction* function() const { return function_; } 26 RawFunction* function() const { return function_; }
25 uword pc() const { return pc_; }
26 intptr_t token_index() const { return token_index_; } 27 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; }
29 28
30 RawScript* SourceCode(); 29 RawScript* SourceCode();
31 RawString* SourceUrl(); 30 RawString* SourceUrl();
32 intptr_t LineNumber(); 31 intptr_t LineNumber();
33 32
34 void SetActive(bool value); 33 void Enable();
35 bool IsActive(); 34 void Disable();
35 bool IsEnabled() const { return is_enabled_; }
regis 2012/03/02 17:54:53 According to our coding style, it should be is_ena
hausner 2012/03/02 18:01:19 Forward ditto.
36 36
37 private: 37 private:
38 void VisitObjectPointers(ObjectPointerVisitor* visitor); 38 void VisitObjectPointers(ObjectPointerVisitor* visitor);
39 39
40 void set_next(Breakpoint* value) { next_ = value; } 40 void set_next(SourceBreakpoint* value) { next_ = value; }
41 Breakpoint* next() const { return this->next_; } 41 SourceBreakpoint* next() const { return this->next_; }
42
43 RawFunction* function_;
44 intptr_t token_index_;
45 intptr_t line_number_;
46 bool is_enabled_;
47
48 SourceBreakpoint* next_;
49
50 friend class Debugger;
51 DISALLOW_COPY_AND_ASSIGN(SourceBreakpoint);
52 };
53
54
55 // CodeBreakpoint represents a location in compiled code. There may be
56 // more than one CodeBreakpoint for one SourceBreakpoint, e.g. when a
57 // function gets compiled as a regular function and as a closure.
58 class CodeBreakpoint {
59 public:
60 CodeBreakpoint(const Function& func, intptr_t pc_desc_index);
61 ~CodeBreakpoint();
62
63 RawFunction* function() const { return function_; }
64 uword pc() const { return pc_; }
65 intptr_t token_index() const { return token_index_; }
66 bool IsInternal() const { return src_bpt_ == NULL; }
67
68 RawScript* SourceCode();
69 RawString* SourceUrl();
70 intptr_t LineNumber();
71
72 void Enable();
73 void Disable();
74 bool IsEnabled() const { return is_enabled_; }
regis 2012/03/02 17:54:53 According to our coding style, it should be is_ena
hausner 2012/03/02 18:01:19 True. I anticipate though that this function could
75
76 private:
77 void VisitObjectPointers(ObjectPointerVisitor* visitor);
78
79 SourceBreakpoint* src_bpt() const { return src_bpt_; }
80 void set_src_bpt(SourceBreakpoint* value) { src_bpt_ = value; }
81
82 void set_next(CodeBreakpoint* value) { next_ = value; }
83 CodeBreakpoint* next() const { return this->next_; }
42 intptr_t pc_desc_index() const { return pc_desc_index_; } 84 intptr_t pc_desc_index() const { return pc_desc_index_; }
43 85
44 void PatchCode(); 86 void PatchCode();
45 void RestoreCode(); 87 void RestoreCode();
46 void PatchFunctionReturn(); 88 void PatchFunctionReturn();
47 void RestoreFunctionReturn(); 89 void RestoreFunctionReturn();
48 90
49 RawFunction* function_; 91 RawFunction* function_;
50 intptr_t pc_desc_index_; 92 intptr_t pc_desc_index_;
51 intptr_t token_index_; 93 intptr_t token_index_;
52 uword pc_; 94 uword pc_;
53 intptr_t line_number_; 95 intptr_t line_number_;
54 bool is_temporary_; 96 bool is_enabled_;
55 97
56 bool is_patched_; 98 SourceBreakpoint* src_bpt_;
99 CodeBreakpoint* next_;
100
57 PcDescriptors::Kind breakpoint_kind_; 101 PcDescriptors::Kind breakpoint_kind_;
58 union { 102 union {
59 uword target_address_; 103 uword target_address_;
60 uint8_t raw[2 * sizeof(uword)]; 104 uint8_t raw[2 * sizeof(uword)];
61 } saved_bytes_; 105 } saved_bytes_;
62 106
63 Breakpoint* next_; 107 friend class Debugger;
108 DISALLOW_COPY_AND_ASSIGN(CodeBreakpoint);
109 };
64 110
65 friend class Debugger; 111
66 DISALLOW_COPY_AND_ASSIGN(Breakpoint);
67 };
68 112
69 113
70 // ActivationFrame represents one dart function activation frame 114 // ActivationFrame represents one dart function activation frame
71 // on the call stack. 115 // on the call stack.
72 class ActivationFrame : public ZoneAllocated { 116 class ActivationFrame : public ZoneAllocated {
73 public: 117 public:
74 explicit ActivationFrame(uword pc, uword fp, uword sp); 118 explicit ActivationFrame(uword pc, uword fp, uword sp);
75 119
76 uword pc() const { return pc_; } 120 uword pc() const { return pc_; }
77 uword fp() const { return fp_; } 121 uword fp() const { return fp_; }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 172 }
129 private: 173 private:
130 void AddActivation(ActivationFrame* frame); 174 void AddActivation(ActivationFrame* frame);
131 ZoneGrowableArray<ActivationFrame*> trace_; 175 ZoneGrowableArray<ActivationFrame*> trace_;
132 176
133 friend class Debugger; 177 friend class Debugger;
134 DISALLOW_COPY_AND_ASSIGN(StackTrace); 178 DISALLOW_COPY_AND_ASSIGN(StackTrace);
135 }; 179 };
136 180
137 181
138 typedef void BreakpointHandler(Breakpoint* bpt, StackTrace* stack); 182 typedef void BreakpointHandler(SourceBreakpoint* bpt, StackTrace* stack);
139 183
140 184
141 class Debugger { 185 class Debugger {
142 public: 186 public:
143 Debugger(); 187 Debugger();
144 ~Debugger(); 188 ~Debugger();
145 189
146 void Initialize(Isolate* isolate); 190 void Initialize(Isolate* isolate);
147 void Shutdown(); 191 void Shutdown();
148 bool IsActive(); 192 bool IsActive();
149 193
194 void NotifyCompilation(const Function& func);
195
150 void SetBreakpointHandler(BreakpointHandler* handler); 196 void SetBreakpointHandler(BreakpointHandler* handler);
151 197
152 RawFunction* ResolveFunction(const Library& library, 198 RawFunction* ResolveFunction(const Library& library,
153 const String& class_name, 199 const String& class_name,
154 const String& function_name); 200 const String& function_name);
155 201
156 // Set breakpoint at closest location to function entry. 202 // Set breakpoint at closest location to function entry.
157 Breakpoint* SetBreakpointAtEntry(const Function& target_function, 203 SourceBreakpoint* SetBreakpointAtEntry(const Function& target_function);
158 Error* error); 204 SourceBreakpoint* SetBreakpointAtLine(const String& script_url,
159 Breakpoint* SetBreakpointAtLine(const String& script_url, 205 intptr_t line_number);
160 intptr_t line_number,
161 Error* error);
162 206
163 void RemoveBreakpoint(Breakpoint* bpt); 207 void RemoveBreakpoint(SourceBreakpoint* bpt);
164 208
165 void SetStepOver() { resume_action_ = kStepOver; } 209 void SetStepOver() { resume_action_ = kStepOver; }
166 void SetStepInto() { resume_action_ = kStepInto; } 210 void SetStepInto() { resume_action_ = kStepInto; }
167 void SetStepOut() { resume_action_ = kStepOut; } 211 void SetStepOut() { resume_action_ = kStepOut; }
168 212
169 void VisitObjectPointers(ObjectPointerVisitor* visitor); 213 void VisitObjectPointers(ObjectPointerVisitor* visitor);
170 214
171 // Returns NULL if no breakpoint exists for the given address.
172 Breakpoint* GetBreakpoint(uword breakpoint_address);
173
174 // Called from Runtime when a breakpoint in Dart code is reached. 215 // Called from Runtime when a breakpoint in Dart code is reached.
175 void BreakpointCallback(); 216 void BreakpointCallback();
176 217
177 RawArray* GetInstanceFields(const Instance& obj); 218 RawArray* GetInstanceFields(const Instance& obj);
178 RawArray* GetStaticFields(const Class& cls); 219 RawArray* GetStaticFields(const Class& cls);
179 220
180 // Utility functions. 221 // Utility functions.
181 static const char* QualifiedFunctionName(const Function& func); 222 static const char* QualifiedFunctionName(const Function& func);
182 223
183 RawObject* GetInstanceField(const Class& cls, 224 RawObject* GetInstanceField(const Class& cls,
184 const String& field_name, 225 const String& field_name,
185 const Instance& object); 226 const Instance& object);
186 RawObject* GetStaticField(const Class& cls, 227 RawObject* GetStaticField(const Class& cls,
187 const String& field_name); 228 const String& field_name);
188 229
189 private: 230 private:
190 enum ResumeAction { 231 enum ResumeAction {
191 kContinue, 232 kContinue,
192 kStepOver, 233 kStepOver,
193 kStepInto, 234 kStepInto,
194 kStepOut 235 kStepOut
195 }; 236 };
196 237
197 void InstrumentForStepping(const Function &target_function); 238 void InstrumentForStepping(const Function &target_function);
198 Breakpoint* SetBreakpoint(const Function& target_function, 239 SourceBreakpoint* SetBreakpoint(const Function& target_function,
199 intptr_t token_index, 240 intptr_t token_index);
200 Error* error); 241 void RemoveInternalBreakpoints();
201 void UnsetBreakpoint(Breakpoint* bpt); 242 void RemoveCodeBreakpoints(SourceBreakpoint* src_bpt);
202 void RemoveTemporaryBreakpoints(); 243 void RegisterSourceBreakpoint(SourceBreakpoint* bpt);
203 Breakpoint* NewBreakpoint(const Function& func, intptr_t pc_desc_index); 244 void RegisterCodeBreakpoint(CodeBreakpoint* bpt);
204 void RegisterBreakpoint(Breakpoint* bpt); 245 SourceBreakpoint* GetSourceBreakpoint(const Function& func,
205 Breakpoint* GetBreakpointByFunction(const Function& func, 246 intptr_t token_index);
206 intptr_t token_index); 247 CodeBreakpoint* MakeCodeBreakpoint(SourceBreakpoint* src_bpt);
248
249 // Returns NULL if no breakpoint exists for the given address.
250 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address);
251
252 void SyncBreakpoint(SourceBreakpoint* bpt);
207 253
208 Isolate* isolate_; 254 Isolate* isolate_;
209 bool initialized_; 255 bool initialized_;
210 BreakpointHandler* bp_handler_; 256 BreakpointHandler* bp_handler_;
211 Breakpoint* breakpoints_; 257 SourceBreakpoint* src_breakpoints_;
258 CodeBreakpoint* code_breakpoints_;
212 259
213 // Tells debugger what to do when resuming execution after a breakpoint. 260 // Tells debugger what to do when resuming execution after a breakpoint.
214 ResumeAction resume_action_; 261 ResumeAction resume_action_;
215 262
263 friend class SourceBreakpoint;
216 DISALLOW_COPY_AND_ASSIGN(Debugger); 264 DISALLOW_COPY_AND_ASSIGN(Debugger);
217 }; 265 };
218 266
219 267
220 } // namespace dart 268 } // namespace dart
221 269
222 #endif // VM_DEBUGGER_H_ 270 #endif // VM_DEBUGGER_H_
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698