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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 Local<Function> to_json_fun = | 70 Local<Function> to_json_fun = |
71 Function::Cast(*event_data->Get(to_json_fun_name)); | 71 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(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); |
(...skipping 16 matching lines...) Expand all Loading... |
107 char* str = fgets(command, kBufferSize, stdin); | 107 char* str = fgets(command, kBufferSize, stdin); |
108 if (str == NULL) break; | 108 if (str == NULL) break; |
109 | 109 |
110 // Ignore empty commands. | 110 // Ignore empty commands. |
111 if (strlen(command) == 0) continue; | 111 if (strlen(command) == 0) continue; |
112 | 112 |
113 TryCatch try_catch; | 113 TryCatch try_catch; |
114 | 114 |
115 // Convert the debugger command to a JSON debugger request. | 115 // Convert the debugger command to a JSON debugger request. |
116 Handle<Value> request = | 116 Handle<Value> request = |
117 Shell::DebugCommandToJSONRequest(String::New(command)); | 117 Shell::DebugCommandToJSONRequest(isolate, String::New(command)); |
118 if (try_catch.HasCaught()) { | 118 if (try_catch.HasCaught()) { |
119 Shell::ReportException(isolate, &try_catch); | 119 Shell::ReportException(isolate, &try_catch); |
120 continue; | 120 continue; |
121 } | 121 } |
122 | 122 |
123 // If undefined is returned the command was handled internally and there is | 123 // If undefined is returned the command was handled internally and there is |
124 // no JSON to send. | 124 // no JSON to send. |
125 if (request->IsUndefined()) { | 125 if (request->IsUndefined()) { |
126 continue; | 126 continue; |
127 } | 127 } |
(...skipping 11 matching lines...) Expand all Loading... |
139 fun = Handle<Function>::Cast(cmd_processor->Get(fun_name)); | 139 fun = Handle<Function>::Cast(cmd_processor->Get(fun_name)); |
140 args[0] = request; | 140 args[0] = request; |
141 Handle<Value> response_val = fun->Call(cmd_processor, kArgc, args); | 141 Handle<Value> response_val = fun->Call(cmd_processor, kArgc, args); |
142 if (try_catch.HasCaught()) { | 142 if (try_catch.HasCaught()) { |
143 Shell::ReportException(isolate, &try_catch); | 143 Shell::ReportException(isolate, &try_catch); |
144 continue; | 144 continue; |
145 } | 145 } |
146 Handle<String> response = Handle<String>::Cast(response_val); | 146 Handle<String> response = Handle<String>::Cast(response_val); |
147 | 147 |
148 // Convert the debugger response into text details and the running state. | 148 // Convert the debugger response into text details and the running state. |
149 Handle<Object> response_details = Shell::DebugMessageDetails(response); | 149 Handle<Object> response_details = |
| 150 Shell::DebugMessageDetails(isolate, response); |
150 if (try_catch.HasCaught()) { | 151 if (try_catch.HasCaught()) { |
151 Shell::ReportException(isolate, &try_catch); | 152 Shell::ReportException(isolate, &try_catch); |
152 continue; | 153 continue; |
153 } | 154 } |
154 String::Utf8Value text_str(response_details->Get(String::New("text"))); | 155 String::Utf8Value text_str(response_details->Get(String::New("text"))); |
155 if (text_str.length() > 0) { | 156 if (text_str.length() > 0) { |
156 printf("%s\n", *text_str); | 157 printf("%s\n", *text_str); |
157 } | 158 } |
158 running = | 159 running = |
159 response_details->Get(String::New("running"))->ToBoolean()->Value(); | 160 response_details->Get(String::New("running"))->ToBoolean()->Value(); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 } | 275 } |
275 | 276 |
276 | 277 |
277 void RemoteDebugger::HandleMessageReceived(char* message) { | 278 void RemoteDebugger::HandleMessageReceived(char* message) { |
278 Locker lock(isolate_); | 279 Locker lock(isolate_); |
279 HandleScope scope(isolate_); | 280 HandleScope scope(isolate_); |
280 | 281 |
281 // Print the event details. | 282 // Print the event details. |
282 TryCatch try_catch; | 283 TryCatch try_catch; |
283 Handle<Object> details = | 284 Handle<Object> details = |
284 Shell::DebugMessageDetails(Handle<String>::Cast(String::New(message))); | 285 Shell::DebugMessageDetails(isolate_, |
| 286 Handle<String>::Cast(String::New(message))); |
285 if (try_catch.HasCaught()) { | 287 if (try_catch.HasCaught()) { |
286 Shell::ReportException(isolate_, &try_catch); | 288 Shell::ReportException(isolate_, &try_catch); |
287 PrintPrompt(); | 289 PrintPrompt(); |
288 return; | 290 return; |
289 } | 291 } |
290 String::Utf8Value str(details->Get(String::New("text"))); | 292 String::Utf8Value str(details->Get(String::New("text"))); |
291 if (str.length() == 0) { | 293 if (str.length() == 0) { |
292 // Empty string is used to signal not to process this event. | 294 // Empty string is used to signal not to process this event. |
293 return; | 295 return; |
294 } | 296 } |
295 if (*str != NULL) { | 297 if (*str != NULL) { |
296 printf("%s\n", *str); | 298 printf("%s\n", *str); |
297 } else { | 299 } else { |
298 printf("???\n"); | 300 printf("???\n"); |
299 } | 301 } |
300 | 302 |
301 bool is_running = details->Get(String::New("running"))->ToBoolean()->Value(); | 303 bool is_running = details->Get(String::New("running"))->ToBoolean()->Value(); |
302 PrintPrompt(is_running); | 304 PrintPrompt(is_running); |
303 } | 305 } |
304 | 306 |
305 | 307 |
306 void RemoteDebugger::HandleKeyboardCommand(char* command) { | 308 void RemoteDebugger::HandleKeyboardCommand(char* command) { |
307 Locker lock(isolate_); | 309 Locker lock(isolate_); |
308 HandleScope scope(isolate_); | 310 HandleScope scope(isolate_); |
309 | 311 |
310 // Convert the debugger command to a JSON debugger request. | 312 // Convert the debugger command to a JSON debugger request. |
311 TryCatch try_catch; | 313 TryCatch try_catch; |
312 Handle<Value> request = | 314 Handle<Value> request = |
313 Shell::DebugCommandToJSONRequest(String::New(command)); | 315 Shell::DebugCommandToJSONRequest(isolate_, String::New(command)); |
314 if (try_catch.HasCaught()) { | 316 if (try_catch.HasCaught()) { |
315 Shell::ReportException(isolate_, &try_catch); | 317 Shell::ReportException(isolate_, &try_catch); |
316 PrintPrompt(); | 318 PrintPrompt(); |
317 return; | 319 return; |
318 } | 320 } |
319 | 321 |
320 // If undefined is returned the command was handled internally and there is | 322 // If undefined is returned the command was handled internally and there is |
321 // no JSON to send. | 323 // no JSON to send. |
322 if (request->IsUndefined()) { | 324 if (request->IsUndefined()) { |
323 PrintPrompt(); | 325 PrintPrompt(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 // Pass the keyboard command to the main thread. | 365 // Pass the keyboard command to the main thread. |
364 remote_debugger_->KeyboardCommand( | 366 remote_debugger_->KeyboardCommand( |
365 i::SmartArrayPointer<char>(i::StrDup(command))); | 367 i::SmartArrayPointer<char>(i::StrDup(command))); |
366 } | 368 } |
367 } | 369 } |
368 | 370 |
369 | 371 |
370 } // namespace v8 | 372 } // namespace v8 |
371 | 373 |
372 #endif // ENABLE_DEBUGGER_SUPPORT | 374 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |