| 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(DebugEvent event, | 53 void HandleDebugEvent(const Debug::EventDetails& event_details) { |
| 54 Handle<Object> exec_state, | |
| 55 Handle<Object> event_data, | |
| 56 Handle<Value> data) { | |
| 57 // TODO(svenpanne) There should be a way to retrieve this in the callback. | 54 // TODO(svenpanne) There should be a way to retrieve this in the callback. |
| 58 Isolate* isolate = Isolate::GetCurrent(); | 55 Isolate* isolate = Isolate::GetCurrent(); |
| 59 HandleScope scope(isolate); | 56 HandleScope scope(isolate); |
| 60 | 57 |
| 58 DebugEvent event = event_details.GetEvent(); |
| 61 // Check for handled event. | 59 // Check for handled event. |
| 62 if (event != Break && event != Exception && event != AfterCompile) { | 60 if (event != Break && event != Exception && event != AfterCompile) { |
| 63 return; | 61 return; |
| 64 } | 62 } |
| 65 | 63 |
| 66 TryCatch try_catch; | 64 TryCatch try_catch; |
| 67 | 65 |
| 68 // Get the toJSONProtocol function on the event and get the JSON format. | 66 // Get the toJSONProtocol function on the event and get the JSON format. |
| 69 Local<String> to_json_fun_name = String::New("toJSONProtocol"); | 67 Local<String> to_json_fun_name = String::New("toJSONProtocol"); |
| 68 Handle<Object> event_data = event_details.GetEventData(); |
| 70 Local<Function> to_json_fun = | 69 Local<Function> to_json_fun = |
| 71 Local<Function>::Cast(event_data->Get(to_json_fun_name)); | 70 Local<Function>::Cast(event_data->Get(to_json_fun_name)); |
| 72 Local<Value> event_json = to_json_fun->Call(event_data, 0, NULL); | 71 Local<Value> event_json = to_json_fun->Call(event_data, 0, NULL); |
| 73 if (try_catch.HasCaught()) { | 72 if (try_catch.HasCaught()) { |
| 74 Shell::ReportException(isolate, &try_catch); | 73 Shell::ReportException(isolate, &try_catch); |
| 75 return; | 74 return; |
| 76 } | 75 } |
| 77 | 76 |
| 78 // Print the event details. | 77 // Print the event details. |
| 79 Handle<Object> details = | 78 Handle<Object> details = |
| 80 Shell::DebugMessageDetails(isolate, Handle<String>::Cast(event_json)); | 79 Shell::DebugMessageDetails(isolate, Handle<String>::Cast(event_json)); |
| 81 if (try_catch.HasCaught()) { | 80 if (try_catch.HasCaught()) { |
| 82 Shell::ReportException(isolate, &try_catch); | 81 Shell::ReportException(isolate, &try_catch); |
| 83 return; | 82 return; |
| 84 } | 83 } |
| 85 String::Utf8Value str(details->Get(String::New("text"))); | 84 String::Utf8Value str(details->Get(String::New("text"))); |
| 86 if (str.length() == 0) { | 85 if (str.length() == 0) { |
| 87 // Empty string is used to signal not to process this event. | 86 // Empty string is used to signal not to process this event. |
| 88 return; | 87 return; |
| 89 } | 88 } |
| 90 printf("%s\n", *str); | 89 printf("%s\n", *str); |
| 91 | 90 |
| 92 // Get the debug command processor. | 91 // Get the debug command processor. |
| 93 Local<String> fun_name = String::New("debugCommandProcessor"); | 92 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 |