| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 if (text_str.length() > 0) { | 143 if (text_str.length() > 0) { |
| 144 printf("%s\n", *text_str); | 144 printf("%s\n", *text_str); |
| 145 } | 145 } |
| 146 running = | 146 running = |
| 147 response_details->Get(String::New("running"))->ToBoolean()->Value(); | 147 response_details->Get(String::New("running"))->ToBoolean()->Value(); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 | 151 |
| 152 void RunRemoteDebugger(int port) { | 152 void RunRemoteDebugger(int port) { |
| 153 RemoteDebugger debugger(port); | 153 RemoteDebugger debugger(i::Isolate::Current(), port); |
| 154 debugger.Run(); | 154 debugger.Run(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 | 157 |
| 158 void RemoteDebugger::Run() { | 158 void RemoteDebugger::Run() { |
| 159 bool ok; | 159 bool ok; |
| 160 | 160 |
| 161 // Make sure that socket support is initialized. | 161 // Make sure that socket support is initialized. |
| 162 ok = i::Socket::Setup(); | 162 ok = i::Socket::Setup(); |
| 163 if (!ok) { | 163 if (!ok) { |
| 164 printf("Unable to initialize socket support %d\n", i::Socket::LastError()); | 164 printf("Unable to initialize socket support %d\n", i::Socket::LastError()); |
| 165 return; | 165 return; |
| 166 } | 166 } |
| 167 | 167 |
| 168 // Connect to the debugger agent. | 168 // Connect to the debugger agent. |
| 169 conn_ = i::OS::CreateSocket(); | 169 conn_ = i::OS::CreateSocket(); |
| 170 static const int kPortStrSize = 6; | 170 static const int kPortStrSize = 6; |
| 171 char port_str[kPortStrSize]; | 171 char port_str[kPortStrSize]; |
| 172 i::OS::SNPrintF(i::Vector<char>(port_str, kPortStrSize), "%d", port_); | 172 i::OS::SNPrintF(i::Vector<char>(port_str, kPortStrSize), "%d", port_); |
| 173 ok = conn_->Connect("localhost", port_str); | 173 ok = conn_->Connect("localhost", port_str); |
| 174 if (!ok) { | 174 if (!ok) { |
| 175 printf("Unable to connect to debug agent %d\n", i::Socket::LastError()); | 175 printf("Unable to connect to debug agent %d\n", i::Socket::LastError()); |
| 176 return; | 176 return; |
| 177 } | 177 } |
| 178 | 178 |
| 179 // Start the receiver thread. | 179 // Start the receiver thread. |
| 180 ReceiverThread receiver(this); | 180 ReceiverThread receiver(isolate_, this); |
| 181 receiver.Start(); | 181 receiver.Start(); |
| 182 | 182 |
| 183 // Start the keyboard thread. | 183 // Start the keyboard thread. |
| 184 KeyboardThread keyboard(this); | 184 KeyboardThread keyboard(isolate_, this); |
| 185 keyboard.Start(); | 185 keyboard.Start(); |
| 186 PrintPrompt(); | 186 PrintPrompt(); |
| 187 | 187 |
| 188 // Process events received from debugged VM and from the keyboard. | 188 // Process events received from debugged VM and from the keyboard. |
| 189 bool terminate = false; | 189 bool terminate = false; |
| 190 while (!terminate) { | 190 while (!terminate) { |
| 191 event_available_->Wait(); | 191 event_available_->Wait(); |
| 192 RemoteDebuggerEvent* event = GetEvent(); | 192 RemoteDebuggerEvent* event = GetEvent(); |
| 193 switch (event->type()) { | 193 switch (event->type()) { |
| 194 case RemoteDebuggerEvent::kMessage: | 194 case RemoteDebuggerEvent::kMessage: |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 347 } |
| 348 | 348 |
| 349 // Pass the keyboard command to the main thread. | 349 // Pass the keyboard command to the main thread. |
| 350 remote_debugger_->KeyboardCommand( | 350 remote_debugger_->KeyboardCommand( |
| 351 i::SmartPointer<char>(i::StrDup(command))); | 351 i::SmartPointer<char>(i::StrDup(command))); |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 | 355 |
| 356 } // namespace v8 | 356 } // namespace v8 |
| OLD | NEW |