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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // Check for handled event. | 61 // Check for handled event. |
62 if (event != Break && event != Exception && event != AfterCompile) { | 62 if (event != Break && event != Exception && event != AfterCompile) { |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 TryCatch try_catch; | 66 TryCatch try_catch; |
67 | 67 |
68 // 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. |
69 Local<String> to_json_fun_name = String::New("toJSONProtocol"); | 69 Local<String> to_json_fun_name = String::New("toJSONProtocol"); |
70 Local<Function> to_json_fun = | 70 Local<Function> to_json_fun = |
71 Function::Cast(*event_data->Get(to_json_fun_name)); | 71 Local<Function>::Cast(event_data->Get(to_json_fun_name)); |
72 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); |
73 if (try_catch.HasCaught()) { | 73 if (try_catch.HasCaught()) { |
74 Shell::ReportException(isolate, &try_catch); | 74 Shell::ReportException(isolate, &try_catch); |
75 return; | 75 return; |
76 } | 76 } |
77 | 77 |
78 // Print the event details. | 78 // Print the event details. |
79 Handle<Object> details = | 79 Handle<Object> details = |
80 Shell::DebugMessageDetails(isolate, Handle<String>::Cast(event_json)); | 80 Shell::DebugMessageDetails(isolate, Handle<String>::Cast(event_json)); |
81 if (try_catch.HasCaught()) { | 81 if (try_catch.HasCaught()) { |
82 Shell::ReportException(isolate, &try_catch); | 82 Shell::ReportException(isolate, &try_catch); |
83 return; | 83 return; |
84 } | 84 } |
85 String::Utf8Value str(details->Get(String::New("text"))); | 85 String::Utf8Value str(details->Get(String::New("text"))); |
86 if (str.length() == 0) { | 86 if (str.length() == 0) { |
87 // Empty string is used to signal not to process this event. | 87 // Empty string is used to signal not to process this event. |
88 return; | 88 return; |
89 } | 89 } |
90 printf("%s\n", *str); | 90 printf("%s\n", *str); |
91 | 91 |
92 // Get the debug command processor. | 92 // Get the debug command processor. |
93 Local<String> fun_name = String::New("debugCommandProcessor"); | 93 Local<String> fun_name = String::New("debugCommandProcessor"); |
94 Local<Function> fun = 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 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; |
104 while (!running) { | 104 while (!running) { |
105 char command[kBufferSize]; | 105 char command[kBufferSize]; |
106 PrintPrompt(running); | 106 PrintPrompt(running); |
(...skipping 258 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 |