Revert "Simplify debugger state."
This reverts r21346, it broke the layout tests. R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/292713002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21351 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
327c016af4
commit
7ac5dfbd3e
@ -2120,18 +2120,20 @@ bool Genesis::InstallSpecialObjects(Handle<Context> native_context) {
|
||||
|
||||
// Expose the debug global object in global if a name for it is specified.
|
||||
if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) {
|
||||
Debug* debug = isolate->debug();
|
||||
// If loading fails we just bail out without installing the
|
||||
// debugger but without tanking the whole context.
|
||||
Debug* debug = isolate->debug();
|
||||
if (!debug->Load()) return true;
|
||||
Handle<Context> debug_context = debug->debug_context();
|
||||
// Set the security token for the debugger context to the same as
|
||||
// the shell native context to allow calling between these (otherwise
|
||||
// exposing debug global object doesn't make much sense).
|
||||
debug_context->set_security_token(native_context->security_token());
|
||||
debug->debug_context()->set_security_token(
|
||||
native_context->security_token());
|
||||
|
||||
Handle<String> debug_string =
|
||||
factory->InternalizeUtf8String(FLAG_expose_debug_as);
|
||||
Handle<Object> global_proxy(debug_context->global_proxy(), isolate);
|
||||
Handle<Object> global_proxy(
|
||||
debug->debug_context()->global_proxy(), isolate);
|
||||
RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
|
@ -753,12 +753,11 @@ void Shell::InstallUtilityScript(Isolate* isolate) {
|
||||
// Install the debugger object in the utility scope
|
||||
i::Debug* debug = reinterpret_cast<i::Isolate*>(isolate)->debug();
|
||||
debug->Load();
|
||||
i::Handle<i::Context> debug_context = debug->debug_context();
|
||||
i::Handle<i::JSObject> js_debug
|
||||
= i::Handle<i::JSObject>(debug_context->global_object());
|
||||
= i::Handle<i::JSObject>(debug->debug_context()->global_object());
|
||||
utility_context->Global()->Set(String::NewFromUtf8(isolate, "$debug"),
|
||||
Utils::ToLocal(js_debug));
|
||||
debug_context->set_security_token(
|
||||
debug->debug_context()->set_security_token(
|
||||
reinterpret_cast<i::Isolate*>(isolate)->heap()->undefined_value());
|
||||
|
||||
// Run the d8 shell utility script in the utility context
|
||||
|
174
src/debug.cc
174
src/debug.cc
@ -45,6 +45,10 @@ Debug::Debug(Isolate* isolate)
|
||||
}
|
||||
|
||||
|
||||
Debug::~Debug() {
|
||||
}
|
||||
|
||||
|
||||
static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) {
|
||||
Handle<Context> context = isolate->debug()->debugger_entry()->GetContext();
|
||||
// Isolate::context() may have been NULL when "script collected" event
|
||||
@ -690,7 +694,9 @@ bool Debug::CompileDebuggerScript(Isolate* isolate, int index) {
|
||||
HandleScope scope(isolate);
|
||||
|
||||
// Bail out if the index is invalid.
|
||||
if (index == -1) return false;
|
||||
if (index == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find source and name for the requested script.
|
||||
Handle<String> source_code =
|
||||
@ -756,11 +762,13 @@ bool Debug::Load() {
|
||||
// Return if debugger is already loaded.
|
||||
if (IsLoaded()) return true;
|
||||
|
||||
Debugger* debugger = isolate_->debugger();
|
||||
|
||||
// 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 (debugger->ignore_debugger()) return false;
|
||||
|
||||
Debugger::IgnoreScope during_load(debugger);
|
||||
// Disable breakpoints and interrupts while compiling and running the
|
||||
// debugger scripts including the context creation code.
|
||||
DisableBreak disable(isolate_, true);
|
||||
@ -785,13 +793,14 @@ bool Debug::Load() {
|
||||
// Expose the builtins object in the debugger context.
|
||||
Handle<String> key = isolate_->factory()->InternalizeOneByteString(
|
||||
STATIC_ASCII_VECTOR("builtins"));
|
||||
Handle<GlobalObject> global =
|
||||
Handle<GlobalObject>(context->global_object(), isolate_);
|
||||
Handle<JSBuiltinsObject> builtin =
|
||||
Handle<JSBuiltinsObject>(global->builtins(), isolate_);
|
||||
Handle<GlobalObject> global = Handle<GlobalObject>(context->global_object());
|
||||
RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate_,
|
||||
JSReceiver::SetProperty(global, key, builtin, NONE, SLOPPY),
|
||||
JSReceiver::SetProperty(global,
|
||||
key,
|
||||
Handle<Object>(global->builtins(), isolate_),
|
||||
NONE,
|
||||
SLOPPY),
|
||||
false);
|
||||
|
||||
// Compile the JavaScript for the debugger in the debugger context.
|
||||
@ -803,24 +812,32 @@ bool Debug::Load() {
|
||||
caught_exception = caught_exception ||
|
||||
!CompileDebuggerScript(isolate_, Natives::GetIndex("liveedit"));
|
||||
}
|
||||
|
||||
// Make sure we mark the debugger as not loading before we might
|
||||
// return.
|
||||
|
||||
// Check for caught exceptions.
|
||||
if (caught_exception) return false;
|
||||
|
||||
// Debugger loaded, create debugger context global handle.
|
||||
debug_context_ = Handle<Context>::cast(
|
||||
isolate_->global_handles()->Create(*context));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Debug::Unload() {
|
||||
// Return debugger is not loaded.
|
||||
if (!IsLoaded()) return;
|
||||
if (!IsLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the script cache.
|
||||
DestroyScriptCache();
|
||||
|
||||
// Clear debugger context global handle.
|
||||
GlobalHandles::Destroy(Handle<Object>::cast(debug_context_).location());
|
||||
GlobalHandles::Destroy(reinterpret_cast<Object**>(debug_context_.location()));
|
||||
debug_context_ = Handle<Context>();
|
||||
}
|
||||
|
||||
@ -837,7 +854,7 @@ Object* Debug::Break(Arguments args) {
|
||||
JavaScriptFrame* frame = it.frame();
|
||||
|
||||
// Just continue if breaks are disabled or debugger cannot be loaded.
|
||||
if (disable_break()) {
|
||||
if (disable_break() || !Load()) {
|
||||
SetAfterBreakTarget(frame);
|
||||
return heap->undefined_value();
|
||||
}
|
||||
@ -2612,7 +2629,9 @@ Debugger::Debugger(Isolate* isolate)
|
||||
is_active_(false),
|
||||
ignore_debugger_(false),
|
||||
live_edit_enabled_(true),
|
||||
never_unload_debugger_(false),
|
||||
message_handler_(NULL),
|
||||
debugger_unload_pending_(false),
|
||||
command_queue_(isolate->logger(), kQueueInitialSize),
|
||||
command_received_(0),
|
||||
event_command_queue_(isolate->logger(), kQueueInitialSize),
|
||||
@ -2969,17 +2988,36 @@ void Debugger::CallJSEventCallback(v8::DebugEvent event,
|
||||
|
||||
|
||||
Handle<Context> Debugger::GetDebugContext() {
|
||||
never_unload_debugger_ = true;
|
||||
EnterDebugger debugger(isolate_);
|
||||
return isolate_->debug()->debug_context();
|
||||
}
|
||||
|
||||
|
||||
void Debugger::UnloadDebugger() {
|
||||
Debug* debug = isolate_->debug();
|
||||
|
||||
// Make sure that there are no breakpoints left.
|
||||
debug->ClearAllBreakPoints();
|
||||
|
||||
// Unload the debugger if feasible.
|
||||
if (!never_unload_debugger_) {
|
||||
debug->Unload();
|
||||
}
|
||||
|
||||
// Clear the flag indicating that the debugger should be unloaded.
|
||||
debugger_unload_pending_ = false;
|
||||
}
|
||||
|
||||
|
||||
void Debugger::NotifyMessageHandler(v8::DebugEvent event,
|
||||
Handle<JSObject> exec_state,
|
||||
Handle<JSObject> event_data,
|
||||
bool auto_continue) {
|
||||
ASSERT(is_active_);
|
||||
HandleScope scope(isolate_);
|
||||
|
||||
if (!isolate_->debug()->Load()) return;
|
||||
|
||||
// Process the individual events.
|
||||
bool sendEventMessage = false;
|
||||
switch (event) {
|
||||
@ -3107,60 +3145,77 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
|
||||
|
||||
void Debugger::SetEventListener(Handle<Object> callback,
|
||||
Handle<Object> data) {
|
||||
HandleScope scope(isolate_);
|
||||
GlobalHandles* global_handles = isolate_->global_handles();
|
||||
|
||||
// Remove existing entry.
|
||||
GlobalHandles::Destroy(event_listener_.location());
|
||||
event_listener_ = Handle<Object>();
|
||||
GlobalHandles::Destroy(event_listener_data_.location());
|
||||
event_listener_data_ = Handle<Object>();
|
||||
|
||||
// Set new entry.
|
||||
if (!callback->IsUndefined() && !callback->IsNull()) {
|
||||
event_listener_ = global_handles->Create(*callback);
|
||||
if (data.is_null()) data = isolate_->factory()->undefined_value();
|
||||
event_listener_data_ = global_handles->Create(*data);
|
||||
// Clear the global handles for the event listener and the event listener data
|
||||
// object.
|
||||
if (!event_listener_.is_null()) {
|
||||
GlobalHandles::Destroy(
|
||||
reinterpret_cast<Object**>(event_listener_.location()));
|
||||
event_listener_ = Handle<Object>();
|
||||
}
|
||||
if (!event_listener_data_.is_null()) {
|
||||
GlobalHandles::Destroy(
|
||||
reinterpret_cast<Object**>(event_listener_data_.location()));
|
||||
event_listener_data_ = Handle<Object>();
|
||||
}
|
||||
|
||||
UpdateState();
|
||||
// If there is a new debug event listener register it together with its data
|
||||
// object.
|
||||
if (!callback->IsUndefined() && !callback->IsNull()) {
|
||||
event_listener_ = Handle<Object>::cast(
|
||||
global_handles->Create(*callback));
|
||||
if (data.is_null()) {
|
||||
data = isolate_->factory()->undefined_value();
|
||||
}
|
||||
event_listener_data_ = Handle<Object>::cast(
|
||||
global_handles->Create(*data));
|
||||
}
|
||||
|
||||
ListenersChanged();
|
||||
}
|
||||
|
||||
|
||||
void Debugger::SetMessageHandler(v8::Debug::MessageHandler handler) {
|
||||
LockGuard<RecursiveMutex> with(&debugger_access_);
|
||||
|
||||
message_handler_ = handler;
|
||||
UpdateState();
|
||||
if (handler == NULL && isolate_->debug()->InDebugger()) {
|
||||
ListenersChanged();
|
||||
if (handler == NULL) {
|
||||
// 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());
|
||||
if (isolate_->debug()->InDebugger()) {
|
||||
EnqueueCommandMessage(Vector<const uint16_t>::empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Debugger::UpdateState() {
|
||||
bool activate = message_handler_ != NULL ||
|
||||
!event_listener_.is_null() ||
|
||||
isolate_->debug()->InDebugger();
|
||||
if (!is_active_ && activate) {
|
||||
// Note that the debug context could have already been loaded to
|
||||
// bootstrap test cases.
|
||||
void Debugger::ListenersChanged() {
|
||||
LockGuard<RecursiveMutex> with(&debugger_access_);
|
||||
is_active_ = message_handler_ != NULL || !event_listener_.is_null();
|
||||
if (is_active_) {
|
||||
// Disable the compilation cache when the debugger is active.
|
||||
isolate_->compilation_cache()->Disable();
|
||||
activate = isolate_->debug()->Load();
|
||||
} else if (is_active_ && !activate) {
|
||||
debugger_unload_pending_ = false;
|
||||
} else {
|
||||
isolate_->compilation_cache()->Enable();
|
||||
isolate_->debug()->ClearAllBreakPoints();
|
||||
isolate_->debug()->Unload();
|
||||
// Unload the debugger if event listener and message handler cleared.
|
||||
// Schedule this for later, because we may be in non-V8 thread.
|
||||
debugger_unload_pending_ = true;
|
||||
}
|
||||
is_active_ = activate;
|
||||
// At this point the debug context is loaded iff the debugger is active.
|
||||
ASSERT(isolate_->debug()->IsLoaded() == is_active_);
|
||||
}
|
||||
|
||||
|
||||
// Calls the registered debug message handler. This callback is part of the
|
||||
// public API.
|
||||
void Debugger::InvokeMessageHandler(MessageImpl message) {
|
||||
if (message_handler_ != NULL) message_handler_(message);
|
||||
LockGuard<RecursiveMutex> with(&debugger_access_);
|
||||
|
||||
if (message_handler_ != NULL) {
|
||||
message_handler_(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3204,6 +3259,9 @@ void Debugger::EnqueueDebugCommand(v8::Debug::ClientData* client_data) {
|
||||
|
||||
MaybeHandle<Object> Debugger::Call(Handle<JSFunction> fun,
|
||||
Handle<Object> data) {
|
||||
// When calling functions in the debugger prevent it from beeing unloaded.
|
||||
Debugger::never_unload_debugger_ = true;
|
||||
|
||||
// Enter the debugger.
|
||||
EnterDebugger debugger(isolate_);
|
||||
if (debugger.FailedToEnter()) {
|
||||
@ -3230,9 +3288,10 @@ MaybeHandle<Object> Debugger::Call(Handle<JSFunction> fun,
|
||||
EnterDebugger::EnterDebugger(Isolate* isolate)
|
||||
: isolate_(isolate),
|
||||
prev_(isolate_->debug()->debugger_entry()),
|
||||
it_(isolate_),
|
||||
has_js_frames_(!it_.done()),
|
||||
save_(isolate_) {
|
||||
Debug* debug = isolate_->debug();
|
||||
|
||||
// Link recursive debugger entry.
|
||||
debug->set_debugger_entry(this);
|
||||
|
||||
@ -3242,24 +3301,25 @@ EnterDebugger::EnterDebugger(Isolate* isolate)
|
||||
|
||||
// Create the new break info. If there is no JavaScript frames there is no
|
||||
// break frame id.
|
||||
JavaScriptFrameIterator it(isolate_);
|
||||
has_js_frames_ = !it.done();
|
||||
debug->NewBreak(has_js_frames_ ? it.frame()->id() : StackFrame::NO_ID);
|
||||
if (has_js_frames_) {
|
||||
debug->NewBreak(it_.frame()->id());
|
||||
} else {
|
||||
debug->NewBreak(StackFrame::NO_ID);
|
||||
}
|
||||
|
||||
isolate_->debugger()->UpdateState();
|
||||
// Make sure that debugger is loaded and enter the debugger context.
|
||||
// The previous context is kept in save_.
|
||||
load_failed_ = !debug->IsLoaded();
|
||||
if (!load_failed_) isolate_->set_context(*debug->debug_context());
|
||||
load_failed_ = !debug->Load();
|
||||
if (!load_failed_) {
|
||||
// NOTE the member variable save which saves the previous context before
|
||||
// this change.
|
||||
isolate_->set_context(*debug->debug_context());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EnterDebugger::~EnterDebugger() {
|
||||
Debug* debug = isolate_->debug();
|
||||
|
||||
// Leaving this debugger entry.
|
||||
debug->set_debugger_entry(prev_);
|
||||
|
||||
// Restore to the previous break state.
|
||||
debug->SetBreak(break_frame_id_, break_id_);
|
||||
|
||||
@ -3291,9 +3351,15 @@ EnterDebugger::~EnterDebugger() {
|
||||
if (isolate_->debugger()->HasCommands()) {
|
||||
isolate_->stack_guard()->RequestDebugCommand();
|
||||
}
|
||||
|
||||
// If leaving the debugger with the debugger no longer active unload it.
|
||||
if (!isolate_->debugger()->is_active()) {
|
||||
isolate_->debugger()->UnloadDebugger();
|
||||
}
|
||||
}
|
||||
|
||||
isolate_->debugger()->UpdateState();
|
||||
// Leaving this debugger entry.
|
||||
debug->set_debugger_entry(prev_);
|
||||
}
|
||||
|
||||
|
||||
|
91
src/debug.h
91
src/debug.h
@ -490,6 +490,7 @@ class Debug {
|
||||
|
||||
private:
|
||||
explicit Debug(Isolate* isolate);
|
||||
~Debug();
|
||||
|
||||
static bool CompileDebuggerScript(Isolate* isolate, int index);
|
||||
void ClearOneShot();
|
||||
@ -742,6 +743,25 @@ class LockingCommandMessageQueue BASE_EMBEDDED {
|
||||
|
||||
class Debugger {
|
||||
public:
|
||||
~Debugger();
|
||||
|
||||
void DebugRequest(const uint16_t* json_request, int length);
|
||||
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeJSObject(
|
||||
Vector<const char> constructor_name,
|
||||
int argc,
|
||||
Handle<Object> argv[]);
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState();
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent(
|
||||
Handle<Object> break_points_hit);
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent(
|
||||
Handle<Object> exception,
|
||||
bool uncaught,
|
||||
Handle<Object> promise);
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent(
|
||||
Handle<Script> script, bool before);
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeScriptCollectedEvent(int id);
|
||||
|
||||
void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue);
|
||||
void OnException(Handle<Object> exception, bool uncaught);
|
||||
void OnBeforeCompile(Handle<Script> script);
|
||||
@ -753,7 +773,13 @@ class Debugger {
|
||||
void OnAfterCompile(Handle<Script> script,
|
||||
AfterCompileFlags after_compile_flags);
|
||||
void OnScriptCollected(int id);
|
||||
|
||||
void ProcessDebugEvent(v8::DebugEvent event,
|
||||
Handle<JSObject> event_data,
|
||||
bool auto_continue);
|
||||
void NotifyMessageHandler(v8::DebugEvent event,
|
||||
Handle<JSObject> exec_state,
|
||||
Handle<JSObject> event_data,
|
||||
bool auto_continue);
|
||||
void SetEventListener(Handle<Object> callback, Handle<Object> data);
|
||||
void SetMessageHandler(v8::Debug::MessageHandler handler);
|
||||
|
||||
@ -772,13 +798,36 @@ class Debugger {
|
||||
|
||||
Handle<Context> GetDebugContext();
|
||||
|
||||
// Unload the debugger if possible. Only called when no debugger is currently
|
||||
// active.
|
||||
void UnloadDebugger();
|
||||
friend void ForceUnloadDebugger(); // In test-debug.cc
|
||||
|
||||
inline bool EventActive() {
|
||||
LockGuard<RecursiveMutex> lock_guard(&debugger_access_);
|
||||
|
||||
// Check whether the message handler was been cleared.
|
||||
// TODO(yangguo): handle loading and unloading of the debugger differently.
|
||||
if (debugger_unload_pending_) {
|
||||
if (isolate_->debug()->debugger_entry() == NULL) {
|
||||
UnloadDebugger();
|
||||
}
|
||||
}
|
||||
|
||||
// Currently argument event is not used.
|
||||
return !ignore_debugger_ && is_active_;
|
||||
}
|
||||
|
||||
bool ignore_debugger() const { return ignore_debugger_; }
|
||||
void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; }
|
||||
bool live_edit_enabled() const {
|
||||
return FLAG_enable_liveedit && live_edit_enabled_ ;
|
||||
}
|
||||
|
||||
bool is_active() { return is_active_; }
|
||||
bool is_active() {
|
||||
LockGuard<RecursiveMutex> lock_guard(&debugger_access_);
|
||||
return is_active_;
|
||||
}
|
||||
|
||||
class IgnoreScope {
|
||||
public:
|
||||
@ -800,22 +849,6 @@ class Debugger {
|
||||
|
||||
private:
|
||||
explicit Debugger(Isolate* isolate);
|
||||
~Debugger();
|
||||
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeJSObject(
|
||||
Vector<const char> constructor_name,
|
||||
int argc,
|
||||
Handle<Object> argv[]);
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState();
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent(
|
||||
Handle<Object> break_points_hit);
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent(
|
||||
Handle<Object> exception,
|
||||
bool uncaught,
|
||||
Handle<Object> promise);
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent(
|
||||
Handle<Script> script, bool before);
|
||||
MUST_USE_RESULT MaybeHandle<Object> MakeScriptCollectedEvent(int id);
|
||||
|
||||
void CallEventCallback(v8::DebugEvent event,
|
||||
Handle<Object> exec_state,
|
||||
@ -828,31 +861,18 @@ class Debugger {
|
||||
void CallJSEventCallback(v8::DebugEvent event,
|
||||
Handle<Object> exec_state,
|
||||
Handle<Object> event_data);
|
||||
void UpdateState();
|
||||
|
||||
void ProcessDebugEvent(v8::DebugEvent event,
|
||||
Handle<JSObject> event_data,
|
||||
bool auto_continue);
|
||||
void NotifyMessageHandler(v8::DebugEvent event,
|
||||
Handle<JSObject> exec_state,
|
||||
Handle<JSObject> event_data,
|
||||
bool auto_continue);
|
||||
void ListenersChanged();
|
||||
|
||||
// Invoke the message handler function.
|
||||
void InvokeMessageHandler(MessageImpl message);
|
||||
|
||||
inline bool EventActive() {
|
||||
// Check whether the message handler was been cleared.
|
||||
// TODO(yangguo): handle loading and unloading of the debugger differently.
|
||||
// Currently argument event is not used.
|
||||
return !ignore_debugger_ && is_active_;
|
||||
}
|
||||
|
||||
RecursiveMutex debugger_access_; // Mutex guarding debugger variables.
|
||||
Handle<Object> event_listener_; // Global handle to listener.
|
||||
Handle<Object> event_listener_data_;
|
||||
bool is_active_;
|
||||
bool ignore_debugger_; // Are we temporarily ignoring the debugger?
|
||||
bool live_edit_enabled_; // Enable LiveEdit.
|
||||
bool never_unload_debugger_; // Can we unload the debugger?
|
||||
v8::Debug::MessageHandler message_handler_;
|
||||
bool debugger_unload_pending_; // Was message handler cleared?
|
||||
|
||||
@ -891,7 +911,8 @@ class EnterDebugger BASE_EMBEDDED {
|
||||
private:
|
||||
Isolate* isolate_;
|
||||
EnterDebugger* prev_; // Previous debugger entry if entered recursively.
|
||||
bool has_js_frames_; // Were there any JavaScript frames?
|
||||
JavaScriptFrameIterator it_;
|
||||
const bool has_js_frames_; // Were there any JavaScript frames?
|
||||
StackFrame::Id break_frame_id_; // Previous break frame id.
|
||||
int break_id_; // Previous break id.
|
||||
bool load_failed_; // Did the debugger fail to load?
|
||||
|
@ -714,6 +714,9 @@ void Execution::DebugBreakHelper(Isolate* isolate) {
|
||||
|
||||
void Execution::ProcessDebugMessages(Isolate* isolate,
|
||||
bool debug_command_only) {
|
||||
// Assert that we are on the main thread of the isolate.
|
||||
ASSERT(ThreadId::Current().Equals(isolate->thread_id()));
|
||||
|
||||
isolate->stack_guard()->ClearDebugCommand();
|
||||
|
||||
StackLimitCheck check(isolate);
|
||||
|
@ -1546,6 +1546,8 @@ void Isolate::Deinit() {
|
||||
if (state_ == INITIALIZED) {
|
||||
TRACE_ISOLATE(deinit);
|
||||
|
||||
debugger()->UnloadDebugger();
|
||||
|
||||
if (concurrent_recompilation_enabled()) {
|
||||
optimizing_compiler_thread_->Stop();
|
||||
delete optimizing_compiler_thread_;
|
||||
|
@ -11044,9 +11044,8 @@ RUNTIME_FUNCTION(Runtime_DebugIndexedInterceptorElementValue) {
|
||||
|
||||
|
||||
static bool CheckExecutionState(Isolate* isolate, int break_id) {
|
||||
return !isolate->debug()->debug_context().is_null() &&
|
||||
isolate->debug()->break_id() != 0 &&
|
||||
isolate->debug()->break_id() == break_id;
|
||||
return (isolate->debug()->break_id() != 0 &&
|
||||
break_id == isolate->debug()->break_id());
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,11 +98,10 @@ class DebugLocalContext {
|
||||
v8::internal::Isolate* isolate =
|
||||
reinterpret_cast<v8::internal::Isolate*>(context_->GetIsolate());
|
||||
v8::internal::Factory* factory = isolate->factory();
|
||||
v8::internal::Debug* debug = isolate->debug();
|
||||
// Expose the debug context global object in the global object for testing.
|
||||
CHECK(isolate->debug()->Load());
|
||||
Handle<v8::internal::Context> debug_context =
|
||||
isolate->debug()->debug_context();
|
||||
debug_context->set_security_token(
|
||||
debug->Load();
|
||||
debug->debug_context()->set_security_token(
|
||||
v8::Utils::OpenHandle(*context_)->security_token());
|
||||
|
||||
Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast(
|
||||
@ -110,7 +109,7 @@ class DebugLocalContext {
|
||||
Handle<v8::internal::String> debug_string =
|
||||
factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug"));
|
||||
v8::internal::Runtime::SetObjectProperty(isolate, global, debug_string,
|
||||
Handle<Object>(debug_context->global_proxy(), isolate),
|
||||
Handle<Object>(debug->debug_context()->global_proxy(), isolate),
|
||||
DONT_ENUM,
|
||||
::v8::internal::SLOPPY).Check();
|
||||
}
|
||||
@ -422,6 +421,12 @@ void CheckDebuggerUnloaded(bool check_functions) {
|
||||
}
|
||||
|
||||
|
||||
void ForceUnloadDebugger() {
|
||||
CcTest::i_isolate()->debugger()->never_unload_debugger_ = false;
|
||||
CcTest::i_isolate()->debugger()->UnloadDebugger();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace v8::internal
|
||||
|
||||
|
||||
@ -5495,12 +5500,13 @@ static void CheckDataParameter(
|
||||
v8::String::NewFromUtf8(args.GetIsolate(), "Test");
|
||||
CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString());
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
v8::TryCatch catcher;
|
||||
CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
|
||||
CHECK(catcher.HasCaught());
|
||||
CHECK(catcher.Exception()->IsString());
|
||||
}
|
||||
CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
|
||||
CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty());
|
||||
|
||||
v8::TryCatch catcher;
|
||||
v8::Debug::Call(debugger_call_with_data);
|
||||
CHECK(catcher.HasCaught());
|
||||
CHECK(catcher.Exception()->IsString());
|
||||
}
|
||||
|
||||
|
||||
@ -6866,11 +6872,9 @@ TEST(CallingContextIsNotDebugContext) {
|
||||
|
||||
TEST(DebugContextIsPreservedBetweenAccesses) {
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
|
||||
v8::Local<v8::Context> context1 = v8::Debug::GetDebugContext();
|
||||
v8::Local<v8::Context> context2 = v8::Debug::GetDebugContext();
|
||||
CHECK_EQ(*context1, *context2);
|
||||
v8::Debug::SetDebugEventListener(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1888,7 +1888,7 @@ TEST(NoDebugObjectInSnapshot) {
|
||||
v8::HandleScope scope(env->GetIsolate());
|
||||
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
|
||||
|
||||
CHECK(CcTest::i_isolate()->debug()->Load());
|
||||
CcTest::i_isolate()->debug()->Load();
|
||||
CompileRun("foo = {};");
|
||||
const v8::HeapSnapshot* snapshot =
|
||||
heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
|
||||
|
@ -37,13 +37,12 @@ function TestCase(fun, frame_number) {
|
||||
var exception = false;
|
||||
var codeSnippet = undefined;
|
||||
var resultPositions = undefined;
|
||||
var step = 0;
|
||||
|
||||
function listener(event, exec_state, event_data, data) {
|
||||
try {
|
||||
if (event == Debug.DebugEvent.Break ||
|
||||
event == Debug.DebugEvent.Exception) {
|
||||
if (step++ > 0) return;
|
||||
Debug.setListener(null);
|
||||
assertHasLineMark(/pause/, exec_state.frame(0));
|
||||
assertHasLineMark(/positions/, exec_state.frame(frame_number));
|
||||
var frame = exec_state.frame(frame_number);
|
||||
|
Loading…
Reference in New Issue
Block a user