| 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 19 matching lines...) Expand all Loading... |
| 30 SourceBreakpoint(intptr_t id, | 30 SourceBreakpoint(intptr_t id, |
| 31 const Script& script, | 31 const Script& script, |
| 32 intptr_t token_pos, | 32 intptr_t token_pos, |
| 33 intptr_t end_token_pos); | 33 intptr_t end_token_pos); |
| 34 | 34 |
| 35 RawFunction* function() const { return function_; } | 35 RawFunction* function() const { return function_; } |
| 36 intptr_t token_pos() const { return token_pos_; } | 36 intptr_t token_pos() const { return token_pos_; } |
| 37 intptr_t end_token_pos() const { return end_token_pos_; } | 37 intptr_t end_token_pos() const { return end_token_pos_; } |
| 38 intptr_t id() const { return id_; } | 38 intptr_t id() const { return id_; } |
| 39 | 39 |
| 40 RawScript* script() { return script_; } | 40 RawScript* script() const { return script_; } |
| 41 RawString* SourceUrl(); | 41 RawString* SourceUrl(); |
| 42 intptr_t LineNumber(); | 42 intptr_t LineNumber(); |
| 43 | 43 |
| 44 void GetCodeLocation(Library* lib, Script* script, intptr_t* token_pos); | 44 void GetCodeLocation(Library* lib, Script* script, intptr_t* token_pos); |
| 45 | 45 |
| 46 void Enable(); | 46 void Enable(); |
| 47 void Disable(); | 47 void Disable(); |
| 48 bool IsEnabled() const { return is_enabled_; } | 48 bool IsEnabled() const { return is_enabled_; } |
| 49 bool IsResolved() { return is_resolved_; } | 49 bool IsResolved() const { return is_resolved_; } |
| 50 | 50 |
| 51 void PrintJSON(JSONStream* stream); | 51 void PrintJSON(JSONStream* stream); |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 54 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 55 | 55 |
| 56 void SetResolved(const Function& func, intptr_t token_pos); | 56 void SetResolved(const Function& func, intptr_t token_pos); |
| 57 void set_next(SourceBreakpoint* value) { next_ = value; } | 57 void set_next(SourceBreakpoint* value) { next_ = value; } |
| 58 SourceBreakpoint* next() const { return this->next_; } | 58 SourceBreakpoint* next() const { return this->next_; } |
| 59 | 59 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 friend class Debugger; | 255 friend class Debugger; |
| 256 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); | 256 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); |
| 257 }; | 257 }; |
| 258 | 258 |
| 259 | 259 |
| 260 typedef void BreakpointHandler(Dart_Port isolate_id, | 260 typedef void BreakpointHandler(Dart_Port isolate_id, |
| 261 SourceBreakpoint* bpt, | 261 SourceBreakpoint* bpt, |
| 262 DebuggerStackTrace* stack); | 262 DebuggerStackTrace* stack); |
| 263 | 263 |
| 264 | 264 |
| 265 class Debugger { | 265 // TODO(turnidge): At some point we may want to turn this into a class |
| 266 // hierarchy. |
| 267 class DebuggerEvent { |
| 266 public: | 268 public: |
| 267 enum EventType { | 269 enum EventType { |
| 268 kBreakpointReached = 1, | 270 kBreakpointReached = 1, |
| 269 kBreakpointResolved = 2, | 271 kBreakpointResolved = 2, |
| 270 kExceptionThrown = 3, | 272 kExceptionThrown = 3, |
| 271 kIsolateCreated = 4, | 273 kIsolateCreated = 4, |
| 272 kIsolateShutdown = 5, | 274 kIsolateShutdown = 5, |
| 273 kIsolateInterrupted = 6, | 275 kIsolateInterrupted = 6, |
| 274 }; | 276 }; |
| 275 struct DebuggerEvent { | 277 |
| 276 explicit DebuggerEvent(EventType event_type) | 278 explicit DebuggerEvent(EventType event_type) |
| 277 : type(event_type) { | 279 : type_(event_type), |
| 278 top_frame = NULL; | 280 top_frame_(NULL), |
| 279 breakpoint = NULL; | 281 breakpoint_(NULL), |
| 280 exception = NULL; | 282 exception_(NULL), |
| 281 isolate_id = 0; | 283 isolate_id_(0) {} |
| 282 } | 284 |
| 283 EventType type; | 285 EventType type() const { return type_; } |
| 284 // type == kBreakpointReached. | 286 |
| 285 ActivationFrame* top_frame; | 287 ActivationFrame* top_frame() const { |
| 286 // type == kBreakpointResolved, kBreakpointReached. | 288 ASSERT(type_ == kBreakpointReached); |
| 287 SourceBreakpoint* breakpoint; | 289 return top_frame_; |
| 288 // type == kExceptionThrown. | 290 } |
| 289 const Object* exception; | 291 void set_top_frame(ActivationFrame* frame) { |
| 290 // type == kIsolate(Created|Shutdown|Interrupted). | 292 ASSERT(type_ == kBreakpointReached); |
| 291 Dart_Port isolate_id; | 293 top_frame_ = frame; |
| 292 }; | 294 } |
| 295 |
| 296 SourceBreakpoint* breakpoint() const { |
| 297 ASSERT(type_ == kBreakpointReached || type_ == kBreakpointResolved); |
| 298 return breakpoint_; |
| 299 } |
| 300 void set_breakpoint(SourceBreakpoint* bpt) { |
| 301 ASSERT(type_ == kBreakpointReached || type_ == kBreakpointResolved); |
| 302 breakpoint_ = bpt; |
| 303 } |
| 304 |
| 305 const Object* exception() const { |
| 306 ASSERT(type_ == kExceptionThrown); |
| 307 return exception_; |
| 308 } |
| 309 void set_exception(const Object* exception) { |
| 310 ASSERT(type_ == kExceptionThrown); |
| 311 exception_ = exception; |
| 312 } |
| 313 |
| 314 Dart_Port isolate_id() const { |
| 315 ASSERT(type_ == kIsolateCreated || |
| 316 type_ == kIsolateShutdown || |
| 317 type_ == kIsolateInterrupted); |
| 318 return isolate_id_; |
| 319 } |
| 320 void set_isolate_id(Dart_Port isolate_id) { |
| 321 ASSERT(type_ == kIsolateCreated || |
| 322 type_ == kIsolateShutdown || |
| 323 type_ == kIsolateInterrupted); |
| 324 isolate_id_ = isolate_id; |
| 325 } |
| 326 |
| 327 void PrintJSON(JSONStream* js) const; |
| 328 |
| 329 static const char* EventTypeToCString(EventType type); |
| 330 |
| 331 private: |
| 332 EventType type_; |
| 333 ActivationFrame* top_frame_; |
| 334 SourceBreakpoint* breakpoint_; |
| 335 const Object* exception_; |
| 336 Dart_Port isolate_id_; |
| 337 }; |
| 338 |
| 339 |
| 340 class Debugger { |
| 341 public: |
| 293 typedef void EventHandler(DebuggerEvent *event); | 342 typedef void EventHandler(DebuggerEvent *event); |
| 294 | 343 |
| 295 Debugger(); | 344 Debugger(); |
| 296 ~Debugger(); | 345 ~Debugger(); |
| 297 | 346 |
| 298 void Initialize(Isolate* isolate); | 347 void Initialize(Isolate* isolate); |
| 299 void Shutdown(); | 348 void Shutdown(); |
| 300 | 349 |
| 301 void NotifyCompilation(const Function& func); | 350 void NotifyCompilation(const Function& func); |
| 302 | 351 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 RawObject* GetInstanceField(const Class& cls, | 423 RawObject* GetInstanceField(const Class& cls, |
| 375 const String& field_name, | 424 const String& field_name, |
| 376 const Instance& object); | 425 const Instance& object); |
| 377 RawObject* GetStaticField(const Class& cls, | 426 RawObject* GetStaticField(const Class& cls, |
| 378 const String& field_name); | 427 const String& field_name); |
| 379 | 428 |
| 380 void SignalBpReached(); | 429 void SignalBpReached(); |
| 381 void DebuggerStepCallback(); | 430 void DebuggerStepCallback(); |
| 382 | 431 |
| 383 void SignalExceptionThrown(const Instance& exc); | 432 void SignalExceptionThrown(const Instance& exc); |
| 384 void SignalIsolateEvent(EventType type); | 433 void SignalIsolateEvent(DebuggerEvent::EventType type); |
| 385 static void SignalIsolateInterrupted(); | 434 static void SignalIsolateInterrupted(); |
| 386 | 435 |
| 387 uword GetPatchedStubAddress(uword breakpoint_address); | 436 uword GetPatchedStubAddress(uword breakpoint_address); |
| 388 | 437 |
| 389 void PrintBreakpointsToJSONArray(JSONArray* jsarr) const; | 438 void PrintBreakpointsToJSONArray(JSONArray* jsarr) const; |
| 390 | 439 |
| 391 static bool IsDebuggable(const Function& func); | 440 static bool IsDebuggable(const Function& func); |
| 392 | 441 |
| 393 private: | 442 private: |
| 394 enum ResumeAction { | 443 enum ResumeAction { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 550 |
| 502 friend class Isolate; | 551 friend class Isolate; |
| 503 friend class SourceBreakpoint; | 552 friend class SourceBreakpoint; |
| 504 DISALLOW_COPY_AND_ASSIGN(Debugger); | 553 DISALLOW_COPY_AND_ASSIGN(Debugger); |
| 505 }; | 554 }; |
| 506 | 555 |
| 507 | 556 |
| 508 } // namespace dart | 557 } // namespace dart |
| 509 | 558 |
| 510 #endif // VM_DEBUGGER_H_ | 559 #endif // VM_DEBUGGER_H_ |
| OLD | NEW |