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

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

Issue 10537065: Debugger break on TypeError, AssertionError (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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) 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 "vm/object.h" 8 #include "vm/object.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 ZoneGrowableArray<intptr_t> desc_indices_; 158 ZoneGrowableArray<intptr_t> desc_indices_;
159 159
160 friend class Debugger; 160 friend class Debugger;
161 DISALLOW_COPY_AND_ASSIGN(ActivationFrame); 161 DISALLOW_COPY_AND_ASSIGN(ActivationFrame);
162 }; 162 };
163 163
164 164
165 // Array of function activations on the call stack. 165 // Array of function activations on the call stack.
166 class DebuggerStackTrace : public ZoneAllocated { 166 class DebuggerStackTrace : public ZoneAllocated {
167 public: 167 public:
168 explicit DebuggerStackTrace(int capacity) : trace_(capacity) { } 168 explicit DebuggerStackTrace(int capacity)
169 : trace_(capacity) { }
169 170
170 intptr_t Length() const { return trace_.length(); } 171 intptr_t Length() const { return trace_.length(); }
171 172
172 ActivationFrame* ActivationFrameAt(int i) const { 173 ActivationFrame* ActivationFrameAt(int i) const {
173 ASSERT(i < trace_.length()); 174 ASSERT(i < trace_.length());
174 return trace_[i]; 175 return trace_[i];
175 } 176 }
176 private: 177 private:
177 void AddActivation(ActivationFrame* frame); 178 void AddActivation(ActivationFrame* frame);
178 ZoneGrowableArray<ActivationFrame*> trace_; 179 ZoneGrowableArray<ActivationFrame*> trace_;
179 180
180 friend class Debugger; 181 friend class Debugger;
181 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); 182 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace);
182 }; 183 };
183 184
184 185
185 typedef void BreakpointHandler(SourceBreakpoint* bpt, 186 typedef void BreakpointHandler(SourceBreakpoint* bpt,
186 DebuggerStackTrace* stack); 187 DebuggerStackTrace* stack);
187 188
188 189
189 class Debugger { 190 class Debugger {
190 public: 191 public:
191 enum EventType { 192 enum EventType {
192 kPaused = 1, 193 kBreakpointReached = 1,
193 kBreakpointResolved = 2, 194 kBreakpointResolved = 2,
195 kExceptionThrown = 3,
194 }; 196 };
195 struct DebuggerEvent { 197 struct DebuggerEvent {
196 EventType type; 198 EventType type;
197 union { 199 union {
198 DebuggerStackTrace* stack_trace; 200 DebuggerStackTrace* stack_trace;
199 SourceBreakpoint* breakpoint; 201 SourceBreakpoint* breakpoint;
202 const Object* exception;
200 }; 203 };
201 }; 204 };
202 typedef void EventHandler(DebuggerEvent *event); 205 typedef void EventHandler(DebuggerEvent *event);
203 206
204 Debugger(); 207 Debugger();
205 ~Debugger(); 208 ~Debugger();
206 209
207 void Initialize(Isolate* isolate); 210 void Initialize(Isolate* isolate);
208 void Shutdown(); 211 void Shutdown();
209 bool IsActive(); 212 bool IsActive();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 249
247 // Utility functions. 250 // Utility functions.
248 static const char* QualifiedFunctionName(const Function& func); 251 static const char* QualifiedFunctionName(const Function& func);
249 252
250 RawObject* GetInstanceField(const Class& cls, 253 RawObject* GetInstanceField(const Class& cls,
251 const String& field_name, 254 const String& field_name,
252 const Instance& object); 255 const Instance& object);
253 RawObject* GetStaticField(const Class& cls, 256 RawObject* GetStaticField(const Class& cls,
254 const String& field_name); 257 const String& field_name);
255 258
259 void SignalBpReached();
260 void SignalExceptionThrown(const Object& exc);
261
256 private: 262 private:
257 enum ResumeAction { 263 enum ResumeAction {
258 kContinue, 264 kContinue,
259 kStepOver, 265 kStepOver,
260 kStepInto, 266 kStepInto,
261 kStepOut 267 kStepOut
262 }; 268 };
263 269
264 void EnsureFunctionIsDeoptimized(const Function& func); 270 void EnsureFunctionIsDeoptimized(const Function& func);
265 void InstrumentForStepping(const Function& target_function); 271 void InstrumentForStepping(const Function& target_function);
266 SourceBreakpoint* SetBreakpoint(const Function& target_function, 272 SourceBreakpoint* SetBreakpoint(const Function& target_function,
267 intptr_t token_index); 273 intptr_t token_index);
268 void RemoveInternalBreakpoints(); 274 void RemoveInternalBreakpoints();
269 void UnlinkCodeBreakpoints(SourceBreakpoint* src_bpt); 275 void UnlinkCodeBreakpoints(SourceBreakpoint* src_bpt);
270 void RegisterSourceBreakpoint(SourceBreakpoint* bpt); 276 void RegisterSourceBreakpoint(SourceBreakpoint* bpt);
271 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); 277 void RegisterCodeBreakpoint(CodeBreakpoint* bpt);
272 SourceBreakpoint* GetSourceBreakpoint(const Function& func, 278 SourceBreakpoint* GetSourceBreakpoint(const Function& func,
273 intptr_t token_index); 279 intptr_t token_index);
274 CodeBreakpoint* MakeCodeBreakpoint(const Function& func, 280 CodeBreakpoint* MakeCodeBreakpoint(const Function& func,
275 intptr_t token_index); 281 intptr_t token_index);
276 282
277 // Returns NULL if no breakpoint exists for the given address. 283 // Returns NULL if no breakpoint exists for the given address.
278 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); 284 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address);
279 285
280 void SyncBreakpoint(SourceBreakpoint* bpt); 286 void SyncBreakpoint(SourceBreakpoint* bpt);
281 287
288 DebuggerStackTrace* CollectStackTrace();
282 void SignalBpResolved(SourceBreakpoint *bpt); 289 void SignalBpResolved(SourceBreakpoint *bpt);
283 290
284 bool IsDebuggable(const Function& func); 291 bool IsDebuggable(const Function& func);
285 292
286 intptr_t nextId() { return next_id_++; } 293 intptr_t nextId() { return next_id_++; }
287 294
295 bool ShouldPauseOnException(DebuggerStackTrace* stack_trace,
296 const Object& exc);
297
288 Isolate* isolate_; 298 Isolate* isolate_;
289 bool initialized_; 299 bool initialized_;
290 BreakpointHandler* bp_handler_; 300 BreakpointHandler* bp_handler_;
291 EventHandler* event_handler_; 301 EventHandler* event_handler_;
292 302
293 // ID number generator. 303 // ID number generator.
294 intptr_t next_id_; 304 intptr_t next_id_;
295 305
296 // Current stack trace. Valid while executing breakpoint callback code. 306 // Current stack trace. Valid while executing breakpoint callback code.
297 DebuggerStackTrace* stack_trace_; 307 DebuggerStackTrace* stack_trace_;
298 308
299 RemoteObjectCache* obj_cache_; 309 RemoteObjectCache* obj_cache_;
300 310
301 SourceBreakpoint* src_breakpoints_; 311 SourceBreakpoint* src_breakpoints_;
302 CodeBreakpoint* code_breakpoints_; 312 CodeBreakpoint* code_breakpoints_;
303 313
304 // Tells debugger what to do when resuming execution after a breakpoint. 314 // Tells debugger what to do when resuming execution after a breakpoint.
305 ResumeAction resume_action_; 315 ResumeAction resume_action_;
306 316
307 // If >= 0, last_bpt_line contains the line number of the last breakpoint 317 // If >= 0, last_bpt_line contains the line number of the last breakpoint
308 // location for which the breakpoint callback function was called. 318 // location for which the breakpoint callback function was called.
309 intptr_t last_bpt_line_; 319 intptr_t last_bpt_line_;
310 320
311 // Do not call back to breakpoint handler if this flag is set. 321 // Do not call back to breakpoint handler if this flag is set.
312 // Effectively this means ignoring breakpoints. Set when Dart code may 322 // Effectively this means ignoring breakpoints. Set when Dart code may
313 // be run as a side effect of getting values of fields. 323 // be run as a side effect of getting values of fields.
314 bool ignore_breakpoints_; 324 bool ignore_breakpoints_;
315 325
326 // If true, notify debug client when (unhandled) exception is thrown.
327 bool pause_on_exception_;
328 bool pause_on_unhandled_exception_;
329
316 friend class SourceBreakpoint; 330 friend class SourceBreakpoint;
317 DISALLOW_COPY_AND_ASSIGN(Debugger); 331 DISALLOW_COPY_AND_ASSIGN(Debugger);
318 }; 332 };
319 333
320 334
321 } // namespace dart 335 } // namespace dart
322 336
323 #endif // VM_DEBUGGER_H_ 337 #endif // VM_DEBUGGER_H_
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | runtime/vm/debugger.cc » ('j') | runtime/vm/debugger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698