28 #ifdef ENABLE_DEBUGGER_SUPPORT
38 static bool was_running =
true;
40 void PrintPrompt(
bool is_running) {
41 const char* prompt = is_running?
"> " :
"dbg> ";
42 was_running = is_running;
49 PrintPrompt(was_running);
54 Handle<Object> exec_state,
55 Handle<Object> event_data,
67 Local<String> to_json_fun_name =
String::New(
"toJSONProtocol");
68 Local<Function> to_json_fun =
70 Local<Value> event_json = to_json_fun->
Call(event_data, 0,
NULL);
71 if (try_catch.HasCaught()) {
77 Handle<Object> details =
79 if (try_catch.HasCaught()) {
83 String::Utf8Value str(details->Get(
String::New(
"text")));
84 if (str.length() == 0) {
91 Local<String> fun_name =
String::New(
"debugCommandProcessor");
93 Local<Object> cmd_processor =
95 if (try_catch.HasCaught()) {
100 static const int kBufferSize = 256;
101 bool running =
false;
103 char command[kBufferSize];
104 PrintPrompt(running);
105 char* str = fgets(command, kBufferSize, stdin);
106 if (str ==
NULL)
break;
109 if (strlen(command) == 0)
continue;
114 Handle<Value> request =
115 Shell::DebugCommandToJSONRequest(
String::New(command));
116 if (try_catch.HasCaught()) {
123 if (request->IsUndefined()) {
127 Handle<String> fun_name;
128 Handle<Function> fun;
130 static const int kArgc = 1;
131 Handle<Value> args[kArgc];
139 Handle<Value> response_val = fun->Call(cmd_processor, kArgc, args);
140 if (try_catch.HasCaught()) {
147 Handle<Object> response_details = Shell::DebugMessageDetails(response);
148 if (try_catch.HasCaught()) {
152 String::Utf8Value text_str(response_details->Get(
String::New(
"text")));
153 if (text_str.length() > 0) {
154 printf(
"%s\n", *text_str);
157 response_details->Get(
String::New(
"running"))->ToBoolean()->Value();
163 RemoteDebugger debugger(port);
180 static const int kPortStrSize = 6;
181 char port_str[kPortStrSize];
183 ok = conn_->
Connect(
"localhost", port_str);
194 KeyboardThread keyboard(
this);
199 bool terminate =
false;
201 event_available_->
Wait();
202 RemoteDebuggerEvent*
event = GetEvent();
203 switch (event->type()) {
205 HandleMessageReceived(event->data());
208 HandleKeyboardCommand(event->data());
226 RemoteDebuggerEvent*
event =
233 RemoteDebuggerEvent*
event =
240 RemoteDebuggerEvent*
event =
247 void RemoteDebugger::AddEvent(RemoteDebuggerEvent* event) {
255 tail_->set_next(event);
258 event_available_->
Signal();
262 RemoteDebuggerEvent* RemoteDebugger::GetEvent() {
265 RemoteDebuggerEvent* result = head_;
266 head_ = head_->next();
275 void RemoteDebugger::HandleMessageReceived(
char* message) {
281 Handle<Object> details =
283 if (try_catch.HasCaught()) {
288 String::Utf8Value str(details->Get(
String::New(
"text")));
289 if (str.length() == 0) {
294 printf(
"%s\n", *str);
299 bool is_running = details->Get(
String::New(
"running"))->ToBoolean()->Value();
300 PrintPrompt(is_running);
304 void RemoteDebugger::HandleKeyboardCommand(
char* command) {
310 Handle<Value> request =
311 Shell::DebugCommandToJSONRequest(
String::New(command));
312 if (try_catch.HasCaught()) {
320 if (request->IsUndefined()) {
333 i::DebuggerAgentUtil::ReceiveMessage(remote_debugger_->conn());
339 i::DebuggerAgentUtil::ReceiveMessage(remote_debugger_->conn());
340 if (*message ==
NULL) {
352 static const int kBufferSize = 256;
355 char command[kBufferSize];
356 char* str = fgets(command, kBufferSize, stdin);
370 #endif // ENABLE_DEBUGGER_SUPPORT
static Object * Cast(Value *obj)
void RunRemoteDebugger(int port)
friend class ReceiverThread
static const int kDisconnect
static V8EXPORT Local< String > New(const char *data, int length=-1)
static Handle< String > Cast(Handle< S > that)
V8EXPORT Local< Value > Call(Handle< Object > recv, int argc, Handle< Value > argv[])
#define ASSERT(condition)
static const int kMessage
static Function * Cast(Value *obj)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
void KeyboardCommand(i::SmartArrayPointer< char > command)
static const int kKeyboard
virtual bool Connect(const char *host, const char *port)=0
static int SNPrintF(Vector< char > str, const char *format,...)
static void ReportException(TryCatch *try_catch)
char * StrDup(const char *str)
void MessageReceived(i::SmartArrayPointer< char > message)
void HandleDebugEvent(DebugEvent event, Handle< Object > exec_state, Handle< Object > event_data, Handle< Value > data)
static Socket * CreateSocket()