Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
|
Jakob Kummerow
2012/01/19 16:23:13
nit: 2012
| |
| 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 String::Utf8Value text_str(response_details->Get(String::New("text"))); | 152 String::Utf8Value text_str(response_details->Get(String::New("text"))); |
| 153 if (text_str.length() > 0) { | 153 if (text_str.length() > 0) { |
| 154 printf("%s\n", *text_str); | 154 printf("%s\n", *text_str); |
| 155 } | 155 } |
| 156 running = | 156 running = |
| 157 response_details->Get(String::New("running"))->ToBoolean()->Value(); | 157 response_details->Get(String::New("running"))->ToBoolean()->Value(); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 | 161 |
| 162 void RunRemoteDebugger(int port) { | 162 void RunRemoteDebugger(int port, Handle<Context> context) { |
| 163 RemoteDebugger debugger(port); | 163 RemoteDebugger debugger(port, context); |
| 164 debugger.Run(); | 164 debugger.Run(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 void RemoteDebugger::Run() { | 168 void RemoteDebugger::Run() { |
| 169 bool ok; | 169 bool ok; |
| 170 | 170 |
| 171 // Make sure that socket support is initialized. | 171 // Make sure that socket support is initialized. |
| 172 ok = i::Socket::SetUp(); | 172 ok = i::Socket::SetUp(); |
| 173 if (!ok) { | 173 if (!ok) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 if (head_ == NULL) { | 267 if (head_ == NULL) { |
| 268 ASSERT(tail_ == result); | 268 ASSERT(tail_ == result); |
| 269 tail_ = NULL; | 269 tail_ = NULL; |
| 270 } | 270 } |
| 271 return result; | 271 return result; |
| 272 } | 272 } |
| 273 | 273 |
| 274 | 274 |
| 275 void RemoteDebugger::HandleMessageReceived(char* message) { | 275 void RemoteDebugger::HandleMessageReceived(char* message) { |
| 276 Locker lock; | 276 Locker lock; |
| 277 Context::Scope cscope(context_); | |
| 277 HandleScope scope; | 278 HandleScope scope; |
| 278 | 279 |
| 279 // Print the event details. | 280 // Print the event details. |
| 280 TryCatch try_catch; | 281 TryCatch try_catch; |
| 281 Handle<Object> details = | 282 Handle<Object> details = |
| 282 Shell::DebugMessageDetails(Handle<String>::Cast(String::New(message))); | 283 Shell::DebugMessageDetails(Handle<String>::Cast(String::New(message))); |
| 283 if (try_catch.HasCaught()) { | 284 if (try_catch.HasCaught()) { |
| 284 Shell::ReportException(&try_catch); | 285 Shell::ReportException(&try_catch); |
| 285 PrintPrompt(); | 286 PrintPrompt(); |
| 286 return; | 287 return; |
| 287 } | 288 } |
| 288 String::Utf8Value str(details->Get(String::New("text"))); | 289 String::Utf8Value str(details->Get(String::New("text"))); |
| 289 if (str.length() == 0) { | 290 if (str.length() == 0) { |
| 290 // Empty string is used to signal not to process this event. | 291 // Empty string is used to signal not to process this event. |
| 291 return; | 292 return; |
| 292 } | 293 } |
| 293 if (*str != NULL) { | 294 if (*str != NULL) { |
| 294 printf("%s\n", *str); | 295 printf("%s\n", *str); |
| 295 } else { | 296 } else { |
| 296 printf("???\n"); | 297 printf("???\n"); |
| 297 } | 298 } |
| 298 | 299 |
| 299 bool is_running = details->Get(String::New("running"))->ToBoolean()->Value(); | 300 bool is_running = details->Get(String::New("running"))->ToBoolean()->Value(); |
| 300 PrintPrompt(is_running); | 301 PrintPrompt(is_running); |
| 301 } | 302 } |
| 302 | 303 |
| 303 | 304 |
| 304 void RemoteDebugger::HandleKeyboardCommand(char* command) { | 305 void RemoteDebugger::HandleKeyboardCommand(char* command) { |
| 305 Locker lock; | 306 Locker lock; |
| 307 Context::Scope cscope(context_); | |
| 306 HandleScope scope; | 308 HandleScope scope; |
| 307 | 309 |
| 308 // Convert the debugger command to a JSON debugger request. | 310 // Convert the debugger command to a JSON debugger request. |
| 309 TryCatch try_catch; | 311 TryCatch try_catch; |
| 310 Handle<Value> request = | 312 Handle<Value> request = |
| 311 Shell::DebugCommandToJSONRequest(String::New(command)); | 313 Shell::DebugCommandToJSONRequest(String::New(command)); |
| 312 if (try_catch.HasCaught()) { | 314 if (try_catch.HasCaught()) { |
| 313 v8::String::Utf8Value exception(try_catch.Exception()); | 315 v8::String::Utf8Value exception(try_catch.Exception()); |
| 314 const char* exception_string = Shell::ToCString(exception); | 316 const char* exception_string = Shell::ToCString(exception); |
| 315 printf("%s\n", exception_string); | 317 printf("%s\n", exception_string); |
| (...skipping 47 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 |