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

Side by Side Diff: src/debug.h

Issue 67266: Accompany debugger commands with senders data (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 8 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 | « src/api.cc ('k') | src/debug.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 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // Code object for debug break return entry code. 390 // Code object for debug break return entry code.
391 static Code* debug_break_return_entry_; 391 static Code* debug_break_return_entry_;
392 392
393 // Code to call for handling debug break on return. 393 // Code to call for handling debug break on return.
394 static Code* debug_break_return_; 394 static Code* debug_break_return_;
395 395
396 DISALLOW_COPY_AND_ASSIGN(Debug); 396 DISALLOW_COPY_AND_ASSIGN(Debug);
397 }; 397 };
398 398
399 399
400 // Message send by user to v8 debugger or debugger output message.
401 // In addition to command text it may contain a pointer to some user data
402 // which are expected to be passed along with the command reponse to message
403 // handler.
404 class Message {
405 public:
406 static Message NewCommand(const Vector<uint16_t>& command,
407 v8::Debug::ClientData* data);
408 static Message NewHostDispatch(v8::Debug::ClientData* dispatch);
409 static Message NewOutput(v8::Handle<v8::String> output,
410 v8::Debug::ClientData* data);
411 static Message NewEmptyMessage();
412 Message();
413 ~Message();
414
415 // Deletes user data and disposes of the text.
416 void Dispose();
417 bool IsHostDispatch() const;
418 Vector<uint16_t> text() const { return text_; }
419 v8::Debug::ClientData* client_data() const { return client_data_; }
420 private:
421 Message(const Vector<uint16_t>& text,
422 v8::Debug::ClientData* data,
423 bool is_host_dispatch);
424
425 Vector<uint16_t> text_;
426 v8::Debug::ClientData* client_data_;
427 bool is_host_dispatch_;
428 };
429
400 // A Queue of Vector<uint16_t> objects. A thread-safe version is 430 // A Queue of Vector<uint16_t> objects. A thread-safe version is
401 // LockingMessageQueue, based on this class. 431 // LockingMessageQueue, based on this class.
402 class MessageQueue BASE_EMBEDDED { 432 class MessageQueue BASE_EMBEDDED {
403 public: 433 public:
404 explicit MessageQueue(int size); 434 explicit MessageQueue(int size);
405 ~MessageQueue(); 435 ~MessageQueue();
406 bool IsEmpty() const { return start_ == end_; } 436 bool IsEmpty() const { return start_ == end_; }
407 Vector<uint16_t> Get(); 437 Message Get();
408 void Put(const Vector<uint16_t>& message); 438 void Put(const Message& message);
409 void Clear() { start_ = end_ = 0; } // Queue is empty after Clear(). 439 void Clear() { start_ = end_ = 0; } // Queue is empty after Clear().
410 private: 440 private:
411 // Doubles the size of the message queue, and copies the messages. 441 // Doubles the size of the message queue, and copies the messages.
412 void Expand(); 442 void Expand();
413 443
414 Vector<uint16_t>* messages_; 444 Message* messages_;
415 int start_; 445 int start_;
416 int end_; 446 int end_;
417 int size_; // The size of the queue buffer. Queue can hold size-1 messages. 447 int size_; // The size of the queue buffer. Queue can hold size-1 messages.
418 }; 448 };
419 449
420 450
421 // LockingMessageQueue is a thread-safe circular buffer of Vector<uint16_t> 451 // LockingMessageQueue is a thread-safe circular buffer of Vector<uint16_t>
422 // messages. The message data is not managed by LockingMessageQueue. 452 // messages. The message data is not managed by LockingMessageQueue.
423 // Pointers to the data are passed in and out. Implemented by adding a 453 // Pointers to the data are passed in and out. Implemented by adding a
424 // Mutex to MessageQueue. Includes logging of all puts and gets. 454 // Mutex to MessageQueue. Includes logging of all puts and gets.
425 class LockingMessageQueue BASE_EMBEDDED { 455 class LockingMessageQueue BASE_EMBEDDED {
426 public: 456 public:
427 explicit LockingMessageQueue(int size); 457 explicit LockingMessageQueue(int size);
428 ~LockingMessageQueue(); 458 ~LockingMessageQueue();
429 bool IsEmpty() const; 459 bool IsEmpty() const;
430 Vector<uint16_t> Get(); 460 Message Get();
431 void Put(const Vector<uint16_t>& message); 461 void Put(const Message& message);
432 void Clear(); 462 void Clear();
433 private: 463 private:
434 MessageQueue queue_; 464 MessageQueue queue_;
435 Mutex* lock_; 465 Mutex* lock_;
436 DISALLOW_COPY_AND_ASSIGN(LockingMessageQueue); 466 DISALLOW_COPY_AND_ASSIGN(LockingMessageQueue);
437 }; 467 };
438 468
439 469
440 class DebugMessageThread; 470 class DebugMessageThread;
441 471
(...skipping 24 matching lines...) Expand all
466 Handle<JSFunction> fun); 496 Handle<JSFunction> fun);
467 static void OnNewFunction(Handle<JSFunction> fun); 497 static void OnNewFunction(Handle<JSFunction> fun);
468 static void ProcessDebugEvent(v8::DebugEvent event, 498 static void ProcessDebugEvent(v8::DebugEvent event,
469 Handle<Object> event_data, 499 Handle<Object> event_data,
470 bool auto_continue); 500 bool auto_continue);
471 static void NotifyMessageHandler(v8::DebugEvent event, 501 static void NotifyMessageHandler(v8::DebugEvent event,
472 Handle<Object> exec_state, 502 Handle<Object> exec_state,
473 Handle<Object> event_data, 503 Handle<Object> event_data,
474 bool auto_continue); 504 bool auto_continue);
475 static void SetEventListener(Handle<Object> callback, Handle<Object> data); 505 static void SetEventListener(Handle<Object> callback, Handle<Object> data);
476 static void SetMessageHandler(v8::DebugMessageHandler handler, void* data, 506 static void SetMessageHandler(v8::Debug::MessageHandler handler,
477 bool message_handler_thread); 507 bool message_handler_thread);
478 static void TearDown(); 508 static void TearDown();
479 static void SetHostDispatchHandler(v8::DebugHostDispatchHandler handler, 509 static void SetHostDispatchHandler(v8::Debug::HostDispatchHandler handler);
480 void* data);
481 510
482 // Invoke the message handler function. 511 // Invoke the message handler function.
483 static void InvokeMessageHandler(Vector< uint16_t> message); 512 static void InvokeMessageHandler(Message message);
484 513
485 // Send a message to the message handler eiher through the message thread or 514 // Send a message to the message handler eiher through the message thread or
486 // directly. 515 // directly.
487 static void SendMessage(Vector<uint16_t> message); 516 static void SendMessage(Message message);
488 517
489 // Send the JSON message for a debug event. 518 // Send the JSON message for a debug event.
490 static bool SendEventMessage(Handle<Object> event_data); 519 static bool SendEventMessage(Handle<Object> event_data);
491 520
492 // Add a debugger command to the command queue. 521 // Add a debugger command to the command queue.
493 static void ProcessCommand(Vector<const uint16_t> command); 522 static void ProcessCommand(Vector<const uint16_t> command,
523 v8::Debug::ClientData* client_data = NULL);
494 524
495 // Check whether there are commands in the command queue. 525 // Check whether there are commands in the command queue.
496 static bool HasCommands(); 526 static bool HasCommands();
497 527
498 static void ProcessHostDispatch(void* dispatch); 528 static void ProcessHostDispatch(v8::Debug::ClientData* dispatch);
499 static Handle<Object> Call(Handle<JSFunction> fun, 529 static Handle<Object> Call(Handle<JSFunction> fun,
500 Handle<Object> data, 530 Handle<Object> data,
501 bool* pending_exception); 531 bool* pending_exception);
502 532
503 // Start the debugger agent listening on the provided port. 533 // Start the debugger agent listening on the provided port.
504 static bool StartAgent(const char* name, int port); 534 static bool StartAgent(const char* name, int port);
505 535
506 // Stop the debugger agent. 536 // Stop the debugger agent.
507 static void StopAgent(); 537 static void StopAgent();
508 538
(...skipping 23 matching lines...) Expand all
532 private: 562 private:
533 static bool IsDebuggerActive(); 563 static bool IsDebuggerActive();
534 564
535 static Mutex* debugger_access_; // Mutex guarding debugger variables. 565 static Mutex* debugger_access_; // Mutex guarding debugger variables.
536 static Handle<Object> event_listener_; // Global handle to listener. 566 static Handle<Object> event_listener_; // Global handle to listener.
537 static Handle<Object> event_listener_data_; 567 static Handle<Object> event_listener_data_;
538 static bool compiling_natives_; // Are we compiling natives? 568 static bool compiling_natives_; // Are we compiling natives?
539 static bool is_loading_debugger_; // Are we loading the debugger? 569 static bool is_loading_debugger_; // Are we loading the debugger?
540 static bool never_unload_debugger_; // Can we unload the debugger? 570 static bool never_unload_debugger_; // Can we unload the debugger?
541 static DebugMessageThread* message_thread_; 571 static DebugMessageThread* message_thread_;
542 static v8::DebugMessageHandler message_handler_; 572 static v8::Debug::MessageHandler message_handler_;
543 static bool message_handler_cleared_; // Was message handler cleared? 573 static bool message_handler_cleared_; // Was message handler cleared?
544 static void* message_handler_data_; 574 static v8::Debug::HostDispatchHandler host_dispatch_handler_;
545 static v8::DebugHostDispatchHandler host_dispatch_handler_;
546 static void* host_dispatch_handler_data_;
547 575
548 static DebuggerAgent* agent_; 576 static DebuggerAgent* agent_;
549 577
550 static const int kQueueInitialSize = 4; 578 static const int kQueueInitialSize = 4;
551 static LockingMessageQueue command_queue_; 579 static LockingMessageQueue command_queue_;
552 static LockingMessageQueue message_queue_; 580 static LockingMessageQueue message_queue_;
553 static Semaphore* command_received_; // Signaled for each command received. 581 static Semaphore* command_received_; // Signaled for each command received.
554 static Semaphore* message_received_; // Signalled for each message send. 582 static Semaphore* message_received_; // Signalled for each message send.
555 583
556 friend class EnterDebugger; 584 friend class EnterDebugger;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 Debug::AddressId id_; 744 Debug::AddressId id_;
717 int reg_; 745 int reg_;
718 }; 746 };
719 747
720 748
721 } } // namespace v8::internal 749 } } // namespace v8::internal
722 750
723 #endif // ENABLE_DEBUGGER_SUPPORT 751 #endif // ENABLE_DEBUGGER_SUPPORT
724 752
725 #endif // V8_V8_DEBUG_H_ 753 #endif // V8_V8_DEBUG_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698