OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // Code object for debug break return entry code. | 394 // Code object for debug break return entry code. |
395 static Code* debug_break_return_entry_; | 395 static Code* debug_break_return_entry_; |
396 | 396 |
397 // Code to call for handling debug break on return. | 397 // Code to call for handling debug break on return. |
398 static Code* debug_break_return_; | 398 static Code* debug_break_return_; |
399 | 399 |
400 DISALLOW_COPY_AND_ASSIGN(Debug); | 400 DISALLOW_COPY_AND_ASSIGN(Debug); |
401 }; | 401 }; |
402 | 402 |
403 | 403 |
404 // Message delivered to the message handler callback. This is either a debugger | |
405 // event or the response to a command. | |
406 class MessageImpl: public v8::Debug::Message { | |
407 public: | |
408 // Create a message object for a debug event. | |
409 static MessageImpl NewEvent(DebugEvent event, | |
410 bool running, | |
411 Handle<JSObject> exec_state, | |
412 Handle<JSObject> event_data); | |
413 | |
414 // Create a message object for the response to a debug command. | |
415 static MessageImpl NewResponse(DebugEvent event, | |
416 bool running, | |
417 Handle<JSObject> exec_state, | |
418 Handle<JSObject> event_data, | |
419 Handle<String> response_json, | |
420 v8::Debug::ClientData* client_data); | |
421 | |
422 // Implementation of interface v8::Debug::Message. | |
423 virtual bool IsEvent() const; | |
424 virtual bool IsResponse() const; | |
425 virtual DebugEvent GetEvent() const; | |
426 virtual bool WillStartRunning() const; | |
427 virtual v8::Handle<v8::Object> GetExecutionState() const; | |
428 virtual v8::Handle<v8::Object> GetEventData() const; | |
429 virtual v8::Handle<v8::String> GetJSON() const; | |
430 virtual v8::Handle<v8::Context> GetEventContext() const; | |
431 virtual v8::Debug::ClientData* GetClientData() const; | |
432 | |
433 private: | |
434 MessageImpl(bool is_event, | |
435 DebugEvent event, | |
436 bool running, | |
437 Handle<JSObject> exec_state, | |
438 Handle<JSObject> event_data, | |
439 Handle<String> response_json, | |
440 v8::Debug::ClientData* client_data); | |
441 | |
442 bool is_event_; // Does this message represent a debug event? | |
443 DebugEvent event_; // Debug event causing the break. | |
444 bool running_; // Will the VM start running after this event? | |
445 Handle<JSObject> exec_state_; // Current execution state. | |
446 Handle<JSObject> event_data_; // Data associated with the event. | |
447 Handle<String> response_json_; // Response JSON if message holds a response. | |
448 v8::Debug::ClientData* client_data_; // Client data passed with the request. | |
449 }; | |
450 | |
451 | |
452 // Message send by user to v8 debugger or debugger output message. | 404 // Message send by user to v8 debugger or debugger output message. |
453 // In addition to command text it may contain a pointer to some user data | 405 // In addition to command text it may contain a pointer to some user data |
454 // which are expected to be passed along with the command reponse to message | 406 // which are expected to be passed along with the command reponse to message |
455 // handler. | 407 // handler. |
456 class CommandMessage { | 408 class CommandMessage { |
457 public: | 409 public: |
458 static CommandMessage New(const Vector<uint16_t>& command, | 410 static CommandMessage New(const Vector<uint16_t>& command, |
459 v8::Debug::ClientData* data); | 411 v8::Debug::ClientData* data); |
460 CommandMessage(); | 412 CommandMessage(); |
461 ~CommandMessage(); | 413 ~CommandMessage(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 static Handle<Object> MakeCompileEvent(Handle<Script> script, | 484 static Handle<Object> MakeCompileEvent(Handle<Script> script, |
533 bool before, | 485 bool before, |
534 bool* caught_exception); | 486 bool* caught_exception); |
535 static void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue); | 487 static void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue); |
536 static void OnException(Handle<Object> exception, bool uncaught); | 488 static void OnException(Handle<Object> exception, bool uncaught); |
537 static void OnBeforeCompile(Handle<Script> script); | 489 static void OnBeforeCompile(Handle<Script> script); |
538 static void OnAfterCompile(Handle<Script> script, | 490 static void OnAfterCompile(Handle<Script> script, |
539 Handle<JSFunction> fun); | 491 Handle<JSFunction> fun); |
540 static void OnNewFunction(Handle<JSFunction> fun); | 492 static void OnNewFunction(Handle<JSFunction> fun); |
541 static void ProcessDebugEvent(v8::DebugEvent event, | 493 static void ProcessDebugEvent(v8::DebugEvent event, |
542 Handle<JSObject> event_data, | 494 Handle<Object> event_data, |
543 bool auto_continue); | 495 bool auto_continue); |
544 static void NotifyMessageHandler(v8::DebugEvent event, | 496 static void NotifyMessageHandler(v8::DebugEvent event, |
545 Handle<JSObject> exec_state, | 497 Handle<Object> exec_state, |
546 Handle<JSObject> event_data, | 498 Handle<Object> event_data, |
547 bool auto_continue); | 499 bool auto_continue); |
548 static void SetEventListener(Handle<Object> callback, Handle<Object> data); | 500 static void SetEventListener(Handle<Object> callback, Handle<Object> data); |
549 static void SetMessageHandler(v8::Debug::MessageHandler handler); | 501 static void SetMessageHandler(v8::Debug::MessageHandler handler); |
550 static void SetHostDispatchHandler(v8::Debug::HostDispatchHandler handler, | 502 static void SetHostDispatchHandler(v8::Debug::HostDispatchHandler handler, |
551 int period); | 503 int period); |
552 | 504 |
553 // Invoke the message handler function. | 505 // Invoke the message handler function. |
554 static void InvokeMessageHandler(MessageImpl message); | 506 static void InvokeMessageHandler(v8::Handle<v8::String> output, |
| 507 v8::Debug::ClientData* data); |
| 508 |
| 509 // Send the JSON message for a debug event. |
| 510 static bool InvokeMessageHandlerWithEvent(Handle<Object> event_data); |
555 | 511 |
556 // Add a debugger command to the command queue. | 512 // Add a debugger command to the command queue. |
557 static void ProcessCommand(Vector<const uint16_t> command, | 513 static void ProcessCommand(Vector<const uint16_t> command, |
558 v8::Debug::ClientData* client_data = NULL); | 514 v8::Debug::ClientData* client_data = NULL); |
559 | 515 |
560 // Check whether there are commands in the command queue. | 516 // Check whether there are commands in the command queue. |
561 static bool HasCommands(); | 517 static bool HasCommands(); |
562 | 518 |
563 static Handle<Object> Call(Handle<JSFunction> fun, | 519 static Handle<Object> Call(Handle<JSFunction> fun, |
564 Handle<Object> data, | 520 Handle<Object> data, |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 Debug::AddressId id_; | 712 Debug::AddressId id_; |
757 int reg_; | 713 int reg_; |
758 }; | 714 }; |
759 | 715 |
760 | 716 |
761 } } // namespace v8::internal | 717 } } // namespace v8::internal |
762 | 718 |
763 #endif // ENABLE_DEBUGGER_SUPPORT | 719 #endif // ENABLE_DEBUGGER_SUPPORT |
764 | 720 |
765 #endif // V8_V8_DEBUG_H_ | 721 #endif // V8_V8_DEBUG_H_ |
OLD | NEW |