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" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 friend class Debugger; | 270 friend class Debugger; |
271 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); | 271 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); |
272 }; | 272 }; |
273 | 273 |
274 | 274 |
275 typedef void BreakpointHandler(Dart_Port isolate_id, | 275 typedef void BreakpointHandler(Dart_Port isolate_id, |
276 SourceBreakpoint* bpt, | 276 SourceBreakpoint* bpt, |
277 DebuggerStackTrace* stack); | 277 DebuggerStackTrace* stack); |
278 | 278 |
279 | 279 |
280 // TODO(turnidge): At some point we may want to turn this into a class | |
281 // hierarchy. | |
282 class DebuggerEvent { | 280 class DebuggerEvent { |
283 public: | 281 public: |
284 enum EventType { | 282 enum EventType { |
285 kBreakpointReached = 1, | 283 kBreakpointReached = 1, |
286 kBreakpointResolved = 2, | 284 kBreakpointResolved = 2, |
287 kExceptionThrown = 3, | 285 kExceptionThrown = 3, |
288 kIsolateCreated = 4, | 286 kIsolateCreated = 4, |
289 kIsolateShutdown = 5, | 287 kIsolateShutdown = 5, |
290 kIsolateInterrupted = 6, | 288 kIsolateInterrupted = 6, |
291 kIsolateResumed = 7, | |
292 }; | 289 }; |
293 | 290 |
294 explicit DebuggerEvent(Isolate* isolate, EventType event_type) | 291 explicit DebuggerEvent(Isolate* isolate, EventType event_type) |
295 : isolate_(isolate), | 292 : isolate_(isolate), |
296 type_(event_type), | 293 type_(event_type), |
297 top_frame_(NULL), | 294 top_frame_(NULL), |
298 breakpoint_(NULL), | 295 breakpoint_(NULL), |
299 exception_(NULL) {} | 296 exception_(NULL) {} |
300 | 297 |
301 Isolate* isolate() const { return isolate_; } | 298 Isolate* isolate() const { return isolate_; } |
302 | 299 |
303 EventType type() const { return type_; } | 300 EventType type() const { return type_; } |
304 | 301 |
| 302 bool IsPauseEvent() const { |
| 303 return (type_ == kBreakpointReached || |
| 304 type_ == kIsolateInterrupted || |
| 305 type_ == kExceptionThrown); |
| 306 } |
| 307 |
305 ActivationFrame* top_frame() const { | 308 ActivationFrame* top_frame() const { |
306 ASSERT(type_ == kBreakpointReached); | 309 ASSERT(IsPauseEvent()); |
307 return top_frame_; | 310 return top_frame_; |
308 } | 311 } |
309 void set_top_frame(ActivationFrame* frame) { | 312 void set_top_frame(ActivationFrame* frame) { |
310 ASSERT(type_ == kBreakpointReached); | 313 ASSERT(IsPauseEvent()); |
311 top_frame_ = frame; | 314 top_frame_ = frame; |
312 } | 315 } |
313 | 316 |
314 SourceBreakpoint* breakpoint() const { | 317 SourceBreakpoint* breakpoint() const { |
315 ASSERT(type_ == kBreakpointReached || type_ == kBreakpointResolved); | 318 ASSERT(type_ == kBreakpointReached || type_ == kBreakpointResolved); |
316 return breakpoint_; | 319 return breakpoint_; |
317 } | 320 } |
318 void set_breakpoint(SourceBreakpoint* bpt) { | 321 void set_breakpoint(SourceBreakpoint* bpt) { |
319 ASSERT(type_ == kBreakpointReached || type_ == kBreakpointResolved); | 322 ASSERT(type_ == kBreakpointReached || type_ == kBreakpointResolved); |
320 breakpoint_ = bpt; | 323 breakpoint_ = bpt; |
321 } | 324 } |
322 | 325 |
323 const Object* exception() const { | 326 const Object* exception() const { |
324 ASSERT(type_ == kExceptionThrown); | 327 ASSERT(type_ == kExceptionThrown); |
325 return exception_; | 328 return exception_; |
326 } | 329 } |
327 void set_exception(const Object* exception) { | 330 void set_exception(const Object* exception) { |
328 ASSERT(type_ == kExceptionThrown); | 331 ASSERT(type_ == kExceptionThrown); |
329 exception_ = exception; | 332 exception_ = exception; |
330 } | 333 } |
331 | 334 |
332 Dart_Port isolate_id() const { | 335 Dart_Port isolate_id() const { |
333 return isolate_->main_port(); | 336 return isolate_->main_port(); |
334 } | 337 } |
335 | 338 |
336 void PrintJSON(JSONStream* js) const; | |
337 | |
338 static const char* EventTypeToCString(EventType type); | |
339 | |
340 private: | 339 private: |
341 Isolate* isolate_; | 340 Isolate* isolate_; |
342 EventType type_; | 341 EventType type_; |
343 ActivationFrame* top_frame_; | 342 ActivationFrame* top_frame_; |
344 SourceBreakpoint* breakpoint_; | 343 SourceBreakpoint* breakpoint_; |
345 const Object* exception_; | 344 const Object* exception_; |
346 }; | 345 }; |
347 | 346 |
348 | 347 |
349 class Debugger { | 348 class Debugger { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 | 563 |
565 friend class Isolate; | 564 friend class Isolate; |
566 friend class SourceBreakpoint; | 565 friend class SourceBreakpoint; |
567 DISALLOW_COPY_AND_ASSIGN(Debugger); | 566 DISALLOW_COPY_AND_ASSIGN(Debugger); |
568 }; | 567 }; |
569 | 568 |
570 | 569 |
571 } // namespace dart | 570 } // namespace dart |
572 | 571 |
573 #endif // VM_DEBUGGER_H_ | 572 #endif // VM_DEBUGGER_H_ |
OLD | NEW |