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)
void KeyboardCommand(i::SmartArrayPointer< char > command)
static const int kKeyboard
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra 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 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage message
virtual bool Connect(const char *host, const char *port)=0
static int SNPrintF(Vector< char > str, const char *format,...)
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra 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 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
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()