Commit acb4ff99 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Removed all functions for parsing the debugger command line commands. The core...

Removed all functions for parsing the debugger command line commands. The core debugger should only support the JSON protocol. Expect these functions to re-appear in d8.

Added processDebugRequest to the debugger which will only process a JSON request. Use that function in the debugger.
Review URL: http://codereview.chromium.org/11395

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@824 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 95d1d400
This diff is collapsed.
...@@ -1769,10 +1769,10 @@ void DebugMessageThread::DebugEvent(v8::DebugEvent event, ...@@ -1769,10 +1769,10 @@ void DebugMessageThread::DebugEvent(v8::DebugEvent event,
host_running_ = false; host_running_ = false;
SetEventJSONFromEvent(event_data); SetEventJSONFromEvent(event_data);
// Wait for commands from the debugger. // Wait for requests from the debugger.
while (true) { while (true) {
command_received_->Wait(); command_received_->Wait();
Logger::DebugTag("Get command from command queue, in interactive loop."); Logger::DebugTag("Got request from command queue, in interactive loop.");
Vector<uint16_t> command = command_queue_.Get(); Vector<uint16_t> command = command_queue_.Get();
ASSERT(!host_running_); ASSERT(!host_running_);
if (!Debugger::debugger_active()) { if (!Debugger::debugger_active()) {
...@@ -1780,52 +1780,54 @@ void DebugMessageThread::DebugEvent(v8::DebugEvent event, ...@@ -1780,52 +1780,54 @@ void DebugMessageThread::DebugEvent(v8::DebugEvent event,
return; return;
} }
// Invoke the JavaScript to convert the debug command line to a JSON // Invoke the JavaScript to process the debug request.
// request, invoke the JSON request and convert the JSON response to a text
// representation.
v8::Local<v8::String> fun_name; v8::Local<v8::String> fun_name;
v8::Local<v8::Function> fun; v8::Local<v8::Function> fun;
v8::Local<v8::Value> args[1]; v8::Local<v8::Value> request;
v8::TryCatch try_catch; v8::TryCatch try_catch;
fun_name = v8::String::New("processDebugCommand"); fun_name = v8::String::New("processDebugRequest");
fun = v8::Function::Cast(*cmd_processor->Get(fun_name)); fun = v8::Function::Cast(*cmd_processor->Get(fun_name));
args[0] = v8::String::New(reinterpret_cast<uint16_t*>(command.start()), request = v8::String::New(reinterpret_cast<uint16_t*>(command.start()),
command.length()); command.length());
v8::Local<v8::Value> result_val = fun->Call(cmd_processor, 1, args); static const int kArgc = 1;
v8::Handle<Value> argv[kArgc] = { request };
v8::Local<v8::Value> response_val = fun->Call(cmd_processor, kArgc, argv);
// Get the result of the command. // Get the response.
v8::Local<v8::String> result_string; v8::Local<v8::String> response;
bool running = false; bool running = false;
if (!try_catch.HasCaught()) { if (!try_catch.HasCaught()) {
// Get the result as an object. // Get response string.
v8::Local<v8::Object> result = v8::Object::Cast(*result_val); if (!response_val->IsUndefined()) {
response = v8::String::Cast(*response_val);
} else {
response = v8::String::New("");
}
// Log the JSON request/response. // Log the JSON request/response.
if (FLAG_trace_debug_json) { if (FLAG_trace_debug_json) {
PrintLn(result->Get(v8::String::New("request"))); PrintLn(request);
PrintLn(result->Get(v8::String::New("response"))); PrintLn(response);
} }
// Get the running state. // Get the running state.
running = result->Get(v8::String::New("running"))->ToBoolean()->Value(); fun_name = v8::String::New("isRunning");
fun = v8::Function::Cast(*cmd_processor->Get(fun_name));
// Get result text. static const int kArgc = 1;
v8::Local<v8::Value> text_result = v8::Handle<Value> argv[kArgc] = { response };
result->Get(v8::String::New("response")); v8::Local<v8::Value> running_val = fun->Call(cmd_processor, kArgc, argv);
if (!text_result->IsUndefined()) { if (!try_catch.HasCaught()) {
result_string = text_result->ToString(); running = running_val->ToBoolean()->Value();
} else {
result_string = v8::String::New("");
} }
} else { } else {
// In case of failure the result text is the exception text. // In case of failure the result text is the exception text.
result_string = try_catch.Exception()->ToString(); response = try_catch.Exception()->ToString();
} }
// Convert text result to C string. // Convert text result to C string.
v8::String::Value val(result_string); v8::String::Value val(response);
Vector<uint16_t> str(reinterpret_cast<uint16_t*>(*val), Vector<uint16_t> str(reinterpret_cast<uint16_t*>(*val),
result_string->Length()); response->Length());
// Set host_running_ correctly for nested debugger evaluations. // Set host_running_ correctly for nested debugger evaluations.
host_running_ = running; host_running_ = running;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment