| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 | 28 |
| 29 #include "d8.h" | 29 #include "d8.h" |
| 30 #include "d8-debug.h" | 30 #include "d8-debug.h" |
| 31 #include "platform.h" | 31 #include "platform.h" |
| 32 #include "debug-agent.h" | 32 #include "debug-agent.h" |
| 33 | 33 |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 | 36 |
| 37 static bool was_running = true; |
| 38 |
| 39 void PrintPrompt(bool is_running) { |
| 40 const char* prompt = is_running? "> " : "dbg> "; |
| 41 was_running = is_running; |
| 42 printf("%s", prompt); |
| 43 fflush(stdout); |
| 44 } |
| 45 |
| 46 |
| 37 void PrintPrompt() { | 47 void PrintPrompt() { |
| 38 printf("dbg> "); | 48 PrintPrompt(was_running); |
| 39 fflush(stdout); | |
| 40 } | 49 } |
| 41 | 50 |
| 42 | 51 |
| 43 void HandleDebugEvent(DebugEvent event, | 52 void HandleDebugEvent(DebugEvent event, |
| 44 Handle<Object> exec_state, | 53 Handle<Object> exec_state, |
| 45 Handle<Object> event_data, | 54 Handle<Object> event_data, |
| 46 Handle<Value> data) { | 55 Handle<Value> data) { |
| 47 HandleScope scope; | 56 HandleScope scope; |
| 48 | 57 |
| 49 // Check for handled event. | 58 // Check for handled event. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 Object::Cast(*fun->Call(exec_state, 0, NULL)); | 93 Object::Cast(*fun->Call(exec_state, 0, NULL)); |
| 85 if (try_catch.HasCaught()) { | 94 if (try_catch.HasCaught()) { |
| 86 Shell::ReportException(&try_catch); | 95 Shell::ReportException(&try_catch); |
| 87 return; | 96 return; |
| 88 } | 97 } |
| 89 | 98 |
| 90 static const int kBufferSize = 256; | 99 static const int kBufferSize = 256; |
| 91 bool running = false; | 100 bool running = false; |
| 92 while (!running) { | 101 while (!running) { |
| 93 char command[kBufferSize]; | 102 char command[kBufferSize]; |
| 94 PrintPrompt(); | 103 PrintPrompt(running); |
| 95 char* str = fgets(command, kBufferSize, stdin); | 104 char* str = fgets(command, kBufferSize, stdin); |
| 96 if (str == NULL) break; | 105 if (str == NULL) break; |
| 97 | 106 |
| 98 // Ignore empty commands. | 107 // Ignore empty commands. |
| 99 if (strlen(command) == 0) continue; | 108 if (strlen(command) == 0) continue; |
| 100 | 109 |
| 101 TryCatch try_catch; | 110 TryCatch try_catch; |
| 102 | 111 |
| 103 // Convert the debugger command to a JSON debugger request. | 112 // Convert the debugger command to a JSON debugger request. |
| 104 Handle<Value> request = | 113 Handle<Value> request = |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 String::Utf8Value str(details->Get(String::New("text"))); | 286 String::Utf8Value str(details->Get(String::New("text"))); |
| 278 if (str.length() == 0) { | 287 if (str.length() == 0) { |
| 279 // Empty string is used to signal not to process this event. | 288 // Empty string is used to signal not to process this event. |
| 280 return; | 289 return; |
| 281 } | 290 } |
| 282 if (*str != NULL) { | 291 if (*str != NULL) { |
| 283 printf("%s\n", *str); | 292 printf("%s\n", *str); |
| 284 } else { | 293 } else { |
| 285 printf("???\n"); | 294 printf("???\n"); |
| 286 } | 295 } |
| 287 PrintPrompt(); | 296 |
| 297 bool is_running = details->Get(String::New("running"))->ToBoolean()->Value(); |
| 298 PrintPrompt(is_running); |
| 288 } | 299 } |
| 289 | 300 |
| 290 | 301 |
| 291 void RemoteDebugger::HandleKeyboardCommand(char* command) { | 302 void RemoteDebugger::HandleKeyboardCommand(char* command) { |
| 292 HandleScope scope; | 303 HandleScope scope; |
| 293 | 304 |
| 294 // Convert the debugger command to a JSON debugger request. | 305 // Convert the debugger command to a JSON debugger request. |
| 295 TryCatch try_catch; | 306 TryCatch try_catch; |
| 296 Handle<Value> request = | 307 Handle<Value> request = |
| 297 Shell::DebugCommandToJSONRequest(String::New(command)); | 308 Shell::DebugCommandToJSONRequest(String::New(command)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 358 } |
| 348 | 359 |
| 349 // Pass the keyboard command to the main thread. | 360 // Pass the keyboard command to the main thread. |
| 350 remote_debugger_->KeyboardCommand( | 361 remote_debugger_->KeyboardCommand( |
| 351 i::SmartPointer<char>(i::StrDup(command))); | 362 i::SmartPointer<char>(i::StrDup(command))); |
| 352 } | 363 } |
| 353 } | 364 } |
| 354 | 365 |
| 355 | 366 |
| 356 } // namespace v8 | 367 } // namespace v8 |
| OLD | NEW |