| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 printf("%s", prompt); | 43 printf("%s", prompt); |
| 44 fflush(stdout); | 44 fflush(stdout); |
| 45 } | 45 } |
| 46 | 46 |
| 47 | 47 |
| 48 void PrintPrompt() { | 48 void PrintPrompt() { |
| 49 PrintPrompt(was_running); | 49 PrintPrompt(was_running); |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 |
| 53 void HandleDebugEvent(const Debug::EventDetails& event_details) { | 53 void HandleDebugEvent(DebugEvent event, |
| 54 Handle<Object> exec_state, |
| 55 Handle<Object> event_data, |
| 56 Handle<Value> data) { |
| 54 // TODO(svenpanne) There should be a way to retrieve this in the callback. | 57 // TODO(svenpanne) There should be a way to retrieve this in the callback. |
| 55 Isolate* isolate = Isolate::GetCurrent(); | 58 Isolate* isolate = Isolate::GetCurrent(); |
| 56 HandleScope scope(isolate); | 59 HandleScope scope(isolate); |
| 57 | 60 |
| 58 DebugEvent event = event_details.GetEvent(); | |
| 59 // Check for handled event. | 61 // Check for handled event. |
| 60 if (event != Break && event != Exception && event != AfterCompile) { | 62 if (event != Break && event != Exception && event != AfterCompile) { |
| 61 return; | 63 return; |
| 62 } | 64 } |
| 63 | 65 |
| 64 TryCatch try_catch; | 66 TryCatch try_catch; |
| 65 | 67 |
| 66 // Get the toJSONProtocol function on the event and get the JSON format. | 68 // Get the toJSONProtocol function on the event and get the JSON format. |
| 67 Local<String> to_json_fun_name = String::New("toJSONProtocol"); | 69 Local<String> to_json_fun_name = String::New("toJSONProtocol"); |
| 68 Handle<Object> event_data = event_details.GetEventData(); | |
| 69 Local<Function> to_json_fun = | 70 Local<Function> to_json_fun = |
| 70 Local<Function>::Cast(event_data->Get(to_json_fun_name)); | 71 Local<Function>::Cast(event_data->Get(to_json_fun_name)); |
| 71 Local<Value> event_json = to_json_fun->Call(event_data, 0, NULL); | 72 Local<Value> event_json = to_json_fun->Call(event_data, 0, NULL); |
| 72 if (try_catch.HasCaught()) { | 73 if (try_catch.HasCaught()) { |
| 73 Shell::ReportException(isolate, &try_catch); | 74 Shell::ReportException(isolate, &try_catch); |
| 74 return; | 75 return; |
| 75 } | 76 } |
| 76 | 77 |
| 77 // Print the event details. | 78 // Print the event details. |
| 78 Handle<Object> details = | 79 Handle<Object> details = |
| 79 Shell::DebugMessageDetails(isolate, Handle<String>::Cast(event_json)); | 80 Shell::DebugMessageDetails(isolate, Handle<String>::Cast(event_json)); |
| 80 if (try_catch.HasCaught()) { | 81 if (try_catch.HasCaught()) { |
| 81 Shell::ReportException(isolate, &try_catch); | 82 Shell::ReportException(isolate, &try_catch); |
| 82 return; | 83 return; |
| 83 } | 84 } |
| 84 String::Utf8Value str(details->Get(String::New("text"))); | 85 String::Utf8Value str(details->Get(String::New("text"))); |
| 85 if (str.length() == 0) { | 86 if (str.length() == 0) { |
| 86 // Empty string is used to signal not to process this event. | 87 // Empty string is used to signal not to process this event. |
| 87 return; | 88 return; |
| 88 } | 89 } |
| 89 printf("%s\n", *str); | 90 printf("%s\n", *str); |
| 90 | 91 |
| 91 // Get the debug command processor. | 92 // Get the debug command processor. |
| 92 Local<String> fun_name = String::New("debugCommandProcessor"); | 93 Local<String> fun_name = String::New("debugCommandProcessor"); |
| 93 Handle<Object> exec_state = event_details.GetExecutionState(); | |
| 94 Local<Function> fun = Local<Function>::Cast(exec_state->Get(fun_name)); | 94 Local<Function> fun = Local<Function>::Cast(exec_state->Get(fun_name)); |
| 95 Local<Object> cmd_processor = | 95 Local<Object> cmd_processor = |
| 96 Local<Object>::Cast(fun->Call(exec_state, 0, NULL)); | 96 Local<Object>::Cast(fun->Call(exec_state, 0, NULL)); |
| 97 if (try_catch.HasCaught()) { | 97 if (try_catch.HasCaught()) { |
| 98 Shell::ReportException(isolate, &try_catch); | 98 Shell::ReportException(isolate, &try_catch); |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 static const int kBufferSize = 256; | 102 static const int kBufferSize = 256; |
| 103 bool running = false; | 103 bool running = false; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // Pass the keyboard command to the main thread. | 365 // Pass the keyboard command to the main thread. |
| 366 remote_debugger_->KeyboardCommand( | 366 remote_debugger_->KeyboardCommand( |
| 367 i::SmartArrayPointer<char>(i::StrDup(command))); | 367 i::SmartArrayPointer<char>(i::StrDup(command))); |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 | 370 |
| 371 | 371 |
| 372 } // namespace v8 | 372 } // namespace v8 |
| 373 | 373 |
| 374 #endif // ENABLE_DEBUGGER_SUPPORT | 374 #endif // ENABLE_DEBUGGER_SUPPORT |
| OLD | NEW |