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

Unified Diff: src/debug.cc

Issue 301633005: Merge Debugger and Debug. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug.h ('k') | src/execution.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index 058ec358735cf6a0152c6e8e99353d7f8851cfe0..ace8b557fff781ea2a720c689516675fb003f7dd 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -31,12 +31,22 @@ namespace v8 {
namespace internal {
Debug::Debug(Isolate* isolate)
- : has_break_points_(false),
- script_cache_(NULL),
- debug_info_list_(NULL),
+ : debug_context_(Handle<Context>()),
+ event_listener_(Handle<Object>()),
+ event_listener_data_(Handle<Object>()),
+ message_handler_(NULL),
+ command_received_(0),
+ command_queue_(isolate->logger(), kQueueInitialSize),
+ event_command_queue_(isolate->logger(), kQueueInitialSize),
+ is_active_(false),
+ ignore_debugger_(false),
+ live_edit_enabled_(true), // TODO(yangguo): set to false by default.
+ has_break_points_(false),
disable_break_(false),
break_on_exception_(false),
break_on_uncaught_exception_(false),
+ script_cache_(NULL),
+ debug_info_list_(NULL),
isolate_(isolate) {
ThreadInit();
}
@@ -596,9 +606,9 @@ Handle<FixedArray> ScriptCache::GetScripts() {
void ScriptCache::ProcessCollectedScripts() {
- Debugger* debugger = isolate_->debugger();
+ Debug* debug = isolate_->debug();
for (int i = 0; i < collected_scripts_.length(); i++) {
- debugger->OnScriptCollected(collected_scripts_[i]);
+ debug->OnScriptCollected(collected_scripts_[i]);
}
collected_scripts_.Clear();
}
@@ -749,8 +759,8 @@ bool Debug::Load() {
// Bail out if we're already in the process of compiling the native
// JavaScript source code for the debugger.
- if (isolate_->debugger()->ignore_debugger()) return false;
- Debugger::IgnoreScope during_create(isolate_->debugger());
+ if (isolate_->debug()->ignore_debugger()) return false;
+ Debug::IgnoreScope during_create(isolate_->debug());
// Disable breakpoints and interrupts while compiling and running the
// debugger scripts including the context creation code.
@@ -901,7 +911,7 @@ Object* Debug::Break(Arguments args) {
PrepareStep(StepNext, step_count, StackFrame::NO_ID);
} else {
// Notify the debug event listeners.
- isolate_->debugger()->OnDebugBreak(break_points_hit, false);
+ OnDebugBreak(break_points_hit, false);
}
} else if (thread_local_.last_step_action_ != StepNone) {
// Hold on to last step action as it is cleared by the call to
@@ -2610,24 +2620,7 @@ void Debug::AfterGarbageCollection() {
}
-Debugger::Debugger(Isolate* isolate)
- : event_listener_(Handle<Object>()),
- event_listener_data_(Handle<Object>()),
- is_active_(false),
- ignore_debugger_(false),
- live_edit_enabled_(true),
- message_handler_(NULL),
- command_queue_(isolate->logger(), kQueueInitialSize),
- command_received_(0),
- event_command_queue_(isolate->logger(), kQueueInitialSize),
- isolate_(isolate) {
-}
-
-
-Debugger::~Debugger() {}
-
-
-MaybeHandle<Object> Debugger::MakeJSObject(
+MaybeHandle<Object> Debug::MakeJSObject(
Vector<const char> constructor_name,
int argc,
Handle<Object> argv[]) {
@@ -2649,7 +2642,7 @@ MaybeHandle<Object> Debugger::MakeJSObject(
}
-MaybeHandle<Object> Debugger::MakeExecutionState() {
+MaybeHandle<Object> Debug::MakeExecutionState() {
// Create the execution state object.
Handle<Object> break_id = isolate_->factory()->NewNumberFromInt(
isolate_->debug()->break_id());
@@ -2658,7 +2651,7 @@ MaybeHandle<Object> Debugger::MakeExecutionState() {
}
-MaybeHandle<Object> Debugger::MakeBreakEvent(Handle<Object> break_points_hit) {
+MaybeHandle<Object> Debug::MakeBreakEvent(Handle<Object> break_points_hit) {
Handle<Object> exec_state;
if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>();
// Create the new break event object.
@@ -2667,7 +2660,7 @@ MaybeHandle<Object> Debugger::MakeBreakEvent(Handle<Object> break_points_hit) {
}
-MaybeHandle<Object> Debugger::MakeExceptionEvent(Handle<Object> exception,
+MaybeHandle<Object> Debug::MakeExceptionEvent(Handle<Object> exception,
bool uncaught,
Handle<Object> promise) {
Handle<Object> exec_state;
@@ -2681,7 +2674,7 @@ MaybeHandle<Object> Debugger::MakeExceptionEvent(Handle<Object> exception,
}
-MaybeHandle<Object> Debugger::MakeCompileEvent(Handle<Script> script,
+MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script,
bool before) {
Handle<Object> exec_state;
if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>();
@@ -2694,7 +2687,7 @@ MaybeHandle<Object> Debugger::MakeCompileEvent(Handle<Script> script,
}
-MaybeHandle<Object> Debugger::MakeScriptCollectedEvent(int id) {
+MaybeHandle<Object> Debug::MakeScriptCollectedEvent(int id) {
Handle<Object> exec_state;
if (!MakeExecutionState().ToHandle(&exec_state)) return MaybeHandle<Object>();
// Create the script collected event object.
@@ -2706,13 +2699,13 @@ MaybeHandle<Object> Debugger::MakeScriptCollectedEvent(int id) {
}
-void Debugger::OnException(Handle<Object> exception, bool uncaught) {
+void Debug::OnException(Handle<Object> exception, bool uncaught) {
HandleScope scope(isolate_);
Debug* debug = isolate_->debug();
// Bail out based on state or if there is no listener for this event
if (debug->InDebugger()) return;
- if (!Debugger::EventActive()) return;
+ if (!EventActive()) return;
Handle<Object> promise = debug->GetPromiseForUncaughtException();
uncaught |= !promise->IsUndefined();
@@ -2748,18 +2741,15 @@ void Debugger::OnException(Handle<Object> exception, bool uncaught) {
}
-void Debugger::OnDebugBreak(Handle<Object> break_points_hit,
+void Debug::OnDebugBreak(Handle<Object> break_points_hit,
bool auto_continue) {
HandleScope scope(isolate_);
// Debugger has already been entered by caller.
- ASSERT(isolate_->context() == *isolate_->debug()->debug_context());
+ ASSERT(isolate_->context() == *debug_context());
// Bail out if there is no listener for this event
- if (!Debugger::EventActive()) return;
-
- // Debugger must be entered in advance.
- ASSERT(isolate_->context() == *isolate_->debug()->debug_context());
+ if (!EventActive()) return;
// Create the event data object.
Handle<Object> event_data;
@@ -2773,11 +2763,11 @@ void Debugger::OnDebugBreak(Handle<Object> break_points_hit,
}
-void Debugger::OnBeforeCompile(Handle<Script> script) {
+void Debug::OnBeforeCompile(Handle<Script> script) {
HandleScope scope(isolate_);
// Bail out based on state or if there is no listener for this event
- if (isolate_->debug()->InDebugger()) return;
+ if (InDebugger()) return;
if (!EventActive()) return;
// Enter the debugger.
@@ -2797,19 +2787,18 @@ void Debugger::OnBeforeCompile(Handle<Script> script) {
// Handle debugger actions when a new script is compiled.
-void Debugger::OnAfterCompile(Handle<Script> script,
+void Debug::OnAfterCompile(Handle<Script> script,
AfterCompileFlags after_compile_flags) {
HandleScope scope(isolate_);
- Debug* debug = isolate_->debug();
// Add the newly compiled script to the script cache.
- debug->AddScriptToScriptCache(script);
+ AddScriptToScriptCache(script);
// No more to do if not debugging.
- if (!Debugger::EventActive()) return;
+ if (!EventActive()) return;
// Store whether in debugger before entering debugger.
- bool in_debugger = debug->InDebugger();
+ bool in_debugger = InDebugger();
// Enter the debugger.
EnterDebugger debugger(isolate_);
@@ -2822,7 +2811,7 @@ void Debugger::OnAfterCompile(Handle<Script> script,
Handle<String> update_script_break_points_string =
isolate_->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("UpdateScriptBreakPoints"));
- Handle<GlobalObject> debug_global(debug->debug_context()->global_object());
+ Handle<GlobalObject> debug_global(debug_context()->global_object());
Handle<Object> update_script_break_points =
Object::GetProperty(
debug_global, update_script_break_points_string).ToHandleChecked();
@@ -2856,12 +2845,12 @@ void Debugger::OnAfterCompile(Handle<Script> script,
}
-void Debugger::OnScriptCollected(int id) {
+void Debug::OnScriptCollected(int id) {
HandleScope scope(isolate_);
// No more to do if not debugging.
- if (isolate_->debug()->InDebugger()) return;
- if (!Debugger::EventActive()) return;
+ if (InDebugger()) return;
+ if (!EventActive()) return;
// Enter the debugger.
EnterDebugger debugger(isolate_);
@@ -2879,15 +2868,13 @@ void Debugger::OnScriptCollected(int id) {
}
-void Debugger::ProcessDebugEvent(v8::DebugEvent event,
- Handle<JSObject> event_data,
- bool auto_continue) {
+void Debug::ProcessDebugEvent(v8::DebugEvent event,
+ Handle<JSObject> event_data,
+ bool auto_continue) {
HandleScope scope(isolate_);
// Clear any pending debug break if this is a real break.
- if (!auto_continue) {
- isolate_->debug()->set_has_pending_interrupt(false);
- }
+ if (!auto_continue) set_has_pending_interrupt(false);
// Create the execution state.
Handle<Object> exec_state;
@@ -2923,10 +2910,10 @@ void Debugger::ProcessDebugEvent(v8::DebugEvent event,
}
-void Debugger::CallEventCallback(v8::DebugEvent event,
- Handle<Object> exec_state,
- Handle<Object> event_data,
- v8::Debug::ClientData* client_data) {
+void Debug::CallEventCallback(v8::DebugEvent event,
+ Handle<Object> exec_state,
+ Handle<Object> event_data,
+ v8::Debug::ClientData* client_data) {
if (event_listener_->IsForeign()) {
CallCEventCallback(event, exec_state, event_data, client_data);
} else {
@@ -2935,10 +2922,10 @@ void Debugger::CallEventCallback(v8::DebugEvent event,
}
-void Debugger::CallCEventCallback(v8::DebugEvent event,
- Handle<Object> exec_state,
- Handle<Object> event_data,
- v8::Debug::ClientData* client_data) {
+void Debug::CallCEventCallback(v8::DebugEvent event,
+ Handle<Object> exec_state,
+ Handle<Object> event_data,
+ v8::Debug::ClientData* client_data) {
Handle<Foreign> callback_obj(Handle<Foreign>::cast(event_listener_));
v8::Debug::EventCallback2 callback =
FUNCTION_CAST<v8::Debug::EventCallback2>(
@@ -2953,9 +2940,9 @@ void Debugger::CallCEventCallback(v8::DebugEvent event,
}
-void Debugger::CallJSEventCallback(v8::DebugEvent event,
- Handle<Object> exec_state,
- Handle<Object> event_data) {
+void Debug::CallJSEventCallback(v8::DebugEvent event,
+ Handle<Object> exec_state,
+ Handle<Object> event_data) {
ASSERT(event_listener_->IsJSFunction());
Handle<JSFunction> fun(Handle<JSFunction>::cast(event_listener_));
@@ -2972,17 +2959,17 @@ void Debugger::CallJSEventCallback(v8::DebugEvent event,
}
-Handle<Context> Debugger::GetDebugContext() {
+Handle<Context> Debug::GetDebugContext() {
EnterDebugger debugger(isolate_);
// The global handle may be destroyed soon after. Return it reboxed.
- return handle(*isolate_->debug()->debug_context(), isolate_);
+ return handle(*debug_context(), isolate_);
}
-void Debugger::NotifyMessageHandler(v8::DebugEvent event,
- Handle<JSObject> exec_state,
- Handle<JSObject> event_data,
- bool auto_continue) {
+void Debug::NotifyMessageHandler(v8::DebugEvent event,
+ Handle<JSObject> exec_state,
+ Handle<JSObject> event_data,
+ bool auto_continue) {
ASSERT(is_active_);
HandleScope scope(isolate_);
// Process the individual events.
@@ -3012,7 +2999,7 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
// The debug command interrupt flag might have been set when the command was
// added. It should be enough to clear the flag only once while we are in the
// debugger.
- ASSERT(isolate_->debug()->InDebugger());
+ ASSERT(InDebugger());
isolate_->stack_guard()->ClearDebugCommand();
// Notify the debugger that a debug event has occurred unless auto continue is
@@ -3057,7 +3044,7 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
CommandMessage command = command_queue_.Get();
isolate_->logger()->DebugTag(
"Got request from command queue, in interactive loop.");
- if (!Debugger::is_active()) {
+ if (!is_active()) {
// Delete command text and user data.
command.Dispose();
return;
@@ -3110,8 +3097,8 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
}
-void Debugger::SetEventListener(Handle<Object> callback,
- Handle<Object> data) {
+void Debug::SetEventListener(Handle<Object> callback,
+ Handle<Object> data) {
GlobalHandles* global_handles = isolate_->global_handles();
// Remove existing entry.
@@ -3131,10 +3118,10 @@ void Debugger::SetEventListener(Handle<Object> callback,
}
-void Debugger::SetMessageHandler(v8::Debug::MessageHandler handler) {
+void Debug::SetMessageHandler(v8::Debug::MessageHandler handler) {
message_handler_ = handler;
UpdateState();
- if (handler == NULL && isolate_->debug()->InDebugger()) {
+ if (handler == NULL && InDebugger()) {
// Send an empty command to the debugger if in a break to make JavaScript
// run again if the debugger is closed.
EnqueueCommandMessage(Vector<const uint16_t>::empty());
@@ -3142,29 +3129,29 @@ void Debugger::SetMessageHandler(v8::Debug::MessageHandler handler) {
}
-void Debugger::UpdateState() {
- Debug* debug = isolate_->debug();
+
+void Debug::UpdateState() {
bool activate = message_handler_ != NULL ||
!event_listener_.is_null() ||
- debug->InDebugger();
+ InDebugger();
if (!is_active_ && activate) {
// Note that the debug context could have already been loaded to
// bootstrap test cases.
isolate_->compilation_cache()->Disable();
- activate = debug->Load();
- } else if (debug->IsLoaded() && !activate) {
+ activate = Load();
+ } else if (IsLoaded() && !activate) {
isolate_->compilation_cache()->Enable();
- debug->Unload();
+ Unload();
}
is_active_ = activate;
// At this point the debug context is loaded iff the debugger is active.
- ASSERT(debug->IsLoaded() == is_active_);
+ ASSERT(IsLoaded() == is_active_);
}
// Calls the registered debug message handler. This callback is part of the
// public API.
-void Debugger::InvokeMessageHandler(MessageImpl message) {
+void Debug::InvokeMessageHandler(MessageImpl message) {
if (message_handler_ != NULL) message_handler_(message);
}
@@ -3173,8 +3160,8 @@ void Debugger::InvokeMessageHandler(MessageImpl message) {
// a copy of the command string managed by the debugger. Up to this
// point, the command data was managed by the API client. Called
// by the API client thread.
-void Debugger::EnqueueCommandMessage(Vector<const uint16_t> command,
- v8::Debug::ClientData* client_data) {
+void Debug::EnqueueCommandMessage(Vector<const uint16_t> command,
+ v8::Debug::ClientData* client_data) {
// Need to cast away const.
CommandMessage message = CommandMessage::New(
Vector<uint16_t>(const_cast<uint16_t*>(command.start()),
@@ -3191,24 +3178,21 @@ void Debugger::EnqueueCommandMessage(Vector<const uint16_t> command,
}
-bool Debugger::HasCommands() {
+bool Debug::HasCommands() {
return !command_queue_.IsEmpty();
}
-void Debugger::EnqueueDebugCommand(v8::Debug::ClientData* client_data) {
+void Debug::EnqueueDebugCommand(v8::Debug::ClientData* client_data) {
CommandMessage message = CommandMessage::New(Vector<uint16_t>(), client_data);
event_command_queue_.Put(message);
// Set the debug command break flag to have the command processed.
- if (!isolate_->debug()->InDebugger()) {
- isolate_->stack_guard()->RequestDebugCommand();
- }
+ if (!InDebugger()) isolate_->stack_guard()->RequestDebugCommand();
}
-MaybeHandle<Object> Debugger::Call(Handle<JSFunction> fun,
- Handle<Object> data) {
+MaybeHandle<Object> Debug::Call(Handle<JSFunction> fun, Handle<Object> data) {
// Enter the debugger.
EnterDebugger debugger(isolate_);
if (debugger.FailedToEnter()) {
@@ -3225,8 +3209,7 @@ MaybeHandle<Object> Debugger::Call(Handle<JSFunction> fun,
return Execution::Call(
isolate_,
fun,
- Handle<Object>(isolate_->debug()->debug_context_->global_proxy(),
- isolate_),
+ Handle<Object>(debug_context()->global_proxy(), isolate_),
ARRAY_SIZE(argv),
argv);
}
@@ -3251,7 +3234,7 @@ EnterDebugger::EnterDebugger(Isolate* isolate)
has_js_frames_ = !it.done();
debug->NewBreak(has_js_frames_ ? it.frame()->id() : StackFrame::NO_ID);
- isolate_->debugger()->UpdateState();
+ debug->UpdateState();
// Make sure that debugger is loaded and enter the debugger context.
// The previous context is kept in save_.
load_failed_ = !debug->IsLoaded();
@@ -3277,7 +3260,7 @@ EnterDebugger::~EnterDebugger() {
// If there are commands in the queue when leaving the debugger request
// that these commands are processed.
- if (isolate_->debugger()->HasCommands()) {
+ if (debug->HasCommands()) {
isolate_->stack_guard()->RequestDebugCommand();
}
}
@@ -3285,7 +3268,7 @@ EnterDebugger::~EnterDebugger() {
// Leaving this debugger entry.
debug->set_debugger_entry(prev_);
- isolate_->debugger()->UpdateState();
+ debug->UpdateState();
}
« no previous file with comments | « src/debug.h ('k') | src/execution.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698