Revision: 4437
Author: [email protected]
Date: Fri Apr 16 05:19:47 2010
Log: Tweak D8 remote debugger
When D8 is used as remote debugger the command 'break' (shorthand 'b') can
be used to break JavaScript execution.
Fixed the printing of the prompt 'dbg>' and printing of error messages.
Review URL: http://codereview.chromium.org/1566049
http://code.google.com/p/v8/source/detail?r=4437
Modified:
/branches/bleeding_edge/src/d8-debug.cc
/branches/bleeding_edge/src/d8.cc
/branches/bleeding_edge/src/d8.h
/branches/bleeding_edge/src/d8.js
=======================================
--- /branches/bleeding_edge/src/d8-debug.cc Mon Mar 23 15:23:39 2009
+++ /branches/bleeding_edge/src/d8-debug.cc Fri Apr 16 05:19:47 2010
@@ -34,6 +34,11 @@
namespace v8 {
+void PrintPrompt() {
+ printf("dbg> ");
+ fflush(stdout);
+}
+
void HandleDebugEvent(DebugEvent event,
Handle<Object> exec_state,
@@ -86,7 +91,7 @@
bool running = false;
while (!running) {
char command[kBufferSize];
- printf("dbg> ");
+ PrintPrompt();
char* str = fgets(command, kBufferSize, stdin);
if (str == NULL) break;
@@ -178,6 +183,7 @@
// Start the keyboard thread.
KeyboardThread keyboard(this);
keyboard.Start();
+ PrintPrompt();
// Process events received from debugged VM and from the keyboard.
bool terminate = false;
@@ -264,7 +270,8 @@
Handle<Object> details =
Shell::DebugMessageDetails(Handle<String>::Cast(String::New(message)));
if (try_catch.HasCaught()) {
- Shell::ReportException(&try_catch);
+ Shell::ReportException(&try_catch);
+ PrintPrompt();
return;
}
String::Utf8Value str(details->Get(String::New("text")));
@@ -277,7 +284,7 @@
} else {
printf("???\n");
}
- printf("dbg> ");
+ PrintPrompt();
}
@@ -289,13 +296,17 @@
Handle<Value> request =
Shell::DebugCommandToJSONRequest(String::New(command));
if (try_catch.HasCaught()) {
- Shell::ReportException(&try_catch);
+ v8::String::Utf8Value exception(try_catch.Exception());
+ const char* exception_string = Shell::ToCString(exception);
+ printf("%s\n", exception_string);
+ PrintPrompt();
return;
}
// If undefined is returned the command was handled internally and there
is
// no JSON to send.
if (request->IsUndefined()) {
+ PrintPrompt();
return;
}
=======================================
--- /branches/bleeding_edge/src/d8.cc Tue Mar 23 05:23:15 2010
+++ /branches/bleeding_edge/src/d8.cc Fri Apr 16 05:19:47 2010
@@ -102,7 +102,7 @@
// Converts a V8 value to a C string.
-const char* ToCString(const v8::String::Utf8Value& value) {
+const char* Shell::ToCString(const v8::String::Utf8Value& value) {
return *value ? *value : "<string conversion failed>";
}
=======================================
--- /branches/bleeding_edge/src/d8.h Tue Apr 13 01:44:50 2010
+++ /branches/bleeding_edge/src/d8.h Fri Apr 16 05:19:47 2010
@@ -117,6 +117,7 @@
Handle<Value> name,
bool print_result,
bool report_exceptions);
+ static const char* ToCString(const v8::String::Utf8Value& value);
static void ReportException(TryCatch* try_catch);
static void Initialize();
static void OnExit();
=======================================
--- /branches/bleeding_edge/src/d8.js Tue Mar 30 00:15:23 2010
+++ /branches/bleeding_edge/src/d8.js Fri Apr 16 05:19:47 2010
@@ -715,8 +715,6 @@
// Create a JSON request for the break command.
DebugRequest.prototype.breakCommandToJSONRequest_ = function(args) {
// Build a evaluate request from the text command.
- var request = this.createRequest('setbreakpoint');
-
// Process arguments if any.
if (args && args.length > 0) {
var target = args;
@@ -726,6 +724,8 @@
var condition;
var pos;
+ var request = this.createRequest('setbreakpoint');
+
// Check for breakpoint condition.
pos = args.indexOf(' ');
if (pos > 0) {
@@ -763,7 +763,7 @@
request.arguments.column = column;
request.arguments.condition = condition;
} else {
- throw new Error('Invalid break arguments.');
+ var request = this.createRequest('suspend');
}
return request.toJSONProtocol();
@@ -817,6 +817,7 @@
print('warning: arguments to \'help\' are ignored');
}
+ print('break');
print('break location [condition]');
print(' break on named function: location is a function name');
print(' break on function: location is #<id>#');
@@ -931,6 +932,10 @@
var body = response.body();
var result = '';
switch (response.command()) {
+ case 'suspend':
+ details.text = 'stopped';
+ break;
+
case 'setbreakpoint':
result = 'set breakpoint #';
result += body.breakpoint;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev