Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: src/d8-debug.cc

Issue 83333002: Remove usage of deprecated APIs from d8 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/d8.gyp ('k') | src/d8-posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 DebugEvent event = event_details.GetEvent(); 57 DebugEvent event = event_details.GetEvent();
58 // Check for handled event. 58 // Check for handled event.
59 if (event != Break && event != Exception && event != AfterCompile) { 59 if (event != Break && event != Exception && event != AfterCompile) {
60 return; 60 return;
61 } 61 }
62 62
63 TryCatch try_catch; 63 TryCatch try_catch;
64 64
65 // Get the toJSONProtocol function on the event and get the JSON format. 65 // Get the toJSONProtocol function on the event and get the JSON format.
66 Local<String> to_json_fun_name = String::New("toJSONProtocol"); 66 Local<String> to_json_fun_name =
67 String::NewFromUtf8(isolate, "toJSONProtocol");
67 Handle<Object> event_data = event_details.GetEventData(); 68 Handle<Object> event_data = event_details.GetEventData();
68 Local<Function> to_json_fun = 69 Local<Function> to_json_fun =
69 Local<Function>::Cast(event_data->Get(to_json_fun_name)); 70 Local<Function>::Cast(event_data->Get(to_json_fun_name));
70 Local<Value> event_json = to_json_fun->Call(event_data, 0, NULL); 71 Local<Value> event_json = to_json_fun->Call(event_data, 0, NULL);
71 if (try_catch.HasCaught()) { 72 if (try_catch.HasCaught()) {
72 Shell::ReportException(isolate, &try_catch); 73 Shell::ReportException(isolate, &try_catch);
73 return; 74 return;
74 } 75 }
75 76
76 // Print the event details. 77 // Print the event details.
77 Handle<Object> details = 78 Handle<Object> details =
78 Shell::DebugMessageDetails(isolate, Handle<String>::Cast(event_json)); 79 Shell::DebugMessageDetails(isolate, Handle<String>::Cast(event_json));
79 if (try_catch.HasCaught()) { 80 if (try_catch.HasCaught()) {
80 Shell::ReportException(isolate, &try_catch); 81 Shell::ReportException(isolate, &try_catch);
81 return; 82 return;
82 } 83 }
83 String::Utf8Value str(details->Get(String::New("text"))); 84 String::Utf8Value str(details->Get(String::NewFromUtf8(isolate, "text")));
84 if (str.length() == 0) { 85 if (str.length() == 0) {
85 // Empty string is used to signal not to process this event. 86 // Empty string is used to signal not to process this event.
86 return; 87 return;
87 } 88 }
88 printf("%s\n", *str); 89 printf("%s\n", *str);
89 90
90 // Get the debug command processor. 91 // Get the debug command processor.
91 Local<String> fun_name = String::New("debugCommandProcessor"); 92 Local<String> fun_name =
93 String::NewFromUtf8(isolate, "debugCommandProcessor");
92 Handle<Object> exec_state = event_details.GetExecutionState(); 94 Handle<Object> exec_state = event_details.GetExecutionState();
93 Local<Function> fun = Local<Function>::Cast(exec_state->Get(fun_name)); 95 Local<Function> fun = Local<Function>::Cast(exec_state->Get(fun_name));
94 Local<Object> cmd_processor = 96 Local<Object> cmd_processor =
95 Local<Object>::Cast(fun->Call(exec_state, 0, NULL)); 97 Local<Object>::Cast(fun->Call(exec_state, 0, NULL));
96 if (try_catch.HasCaught()) { 98 if (try_catch.HasCaught()) {
97 Shell::ReportException(isolate, &try_catch); 99 Shell::ReportException(isolate, &try_catch);
98 return; 100 return;
99 } 101 }
100 102
101 static const int kBufferSize = 256; 103 static const int kBufferSize = 256;
102 bool running = false; 104 bool running = false;
103 while (!running) { 105 while (!running) {
104 char command[kBufferSize]; 106 char command[kBufferSize];
105 PrintPrompt(running); 107 PrintPrompt(running);
106 char* str = fgets(command, kBufferSize, stdin); 108 char* str = fgets(command, kBufferSize, stdin);
107 if (str == NULL) break; 109 if (str == NULL) break;
108 110
109 // Ignore empty commands. 111 // Ignore empty commands.
110 if (strlen(command) == 0) continue; 112 if (strlen(command) == 0) continue;
111 113
112 TryCatch try_catch; 114 TryCatch try_catch;
113 115
114 // Convert the debugger command to a JSON debugger request. 116 // Convert the debugger command to a JSON debugger request.
115 Handle<Value> request = 117 Handle<Value> request = Shell::DebugCommandToJSONRequest(
116 Shell::DebugCommandToJSONRequest(isolate, String::New(command)); 118 isolate, String::NewFromUtf8(isolate, command));
117 if (try_catch.HasCaught()) { 119 if (try_catch.HasCaught()) {
118 Shell::ReportException(isolate, &try_catch); 120 Shell::ReportException(isolate, &try_catch);
119 continue; 121 continue;
120 } 122 }
121 123
122 // If undefined is returned the command was handled internally and there is 124 // If undefined is returned the command was handled internally and there is
123 // no JSON to send. 125 // no JSON to send.
124 if (request->IsUndefined()) { 126 if (request->IsUndefined()) {
125 continue; 127 continue;
126 } 128 }
127 129
128 Handle<String> fun_name; 130 Handle<String> fun_name;
129 Handle<Function> fun; 131 Handle<Function> fun;
130 // All the functions used below take one argument. 132 // All the functions used below take one argument.
131 static const int kArgc = 1; 133 static const int kArgc = 1;
132 Handle<Value> args[kArgc]; 134 Handle<Value> args[kArgc];
133 135
134 // Invoke the JavaScript to convert the debug command line to a JSON 136 // Invoke the JavaScript to convert the debug command line to a JSON
135 // request, invoke the JSON request and convert the JSON respose to a text 137 // request, invoke the JSON request and convert the JSON respose to a text
136 // representation. 138 // representation.
137 fun_name = String::New("processDebugRequest"); 139 fun_name = String::NewFromUtf8(isolate, "processDebugRequest");
138 fun = Handle<Function>::Cast(cmd_processor->Get(fun_name)); 140 fun = Handle<Function>::Cast(cmd_processor->Get(fun_name));
139 args[0] = request; 141 args[0] = request;
140 Handle<Value> response_val = fun->Call(cmd_processor, kArgc, args); 142 Handle<Value> response_val = fun->Call(cmd_processor, kArgc, args);
141 if (try_catch.HasCaught()) { 143 if (try_catch.HasCaught()) {
142 Shell::ReportException(isolate, &try_catch); 144 Shell::ReportException(isolate, &try_catch);
143 continue; 145 continue;
144 } 146 }
145 Handle<String> response = Handle<String>::Cast(response_val); 147 Handle<String> response = Handle<String>::Cast(response_val);
146 148
147 // Convert the debugger response into text details and the running state. 149 // Convert the debugger response into text details and the running state.
148 Handle<Object> response_details = 150 Handle<Object> response_details =
149 Shell::DebugMessageDetails(isolate, response); 151 Shell::DebugMessageDetails(isolate, response);
150 if (try_catch.HasCaught()) { 152 if (try_catch.HasCaught()) {
151 Shell::ReportException(isolate, &try_catch); 153 Shell::ReportException(isolate, &try_catch);
152 continue; 154 continue;
153 } 155 }
154 String::Utf8Value text_str(response_details->Get(String::New("text"))); 156 String::Utf8Value text_str(
157 response_details->Get(String::NewFromUtf8(isolate, "text")));
155 if (text_str.length() > 0) { 158 if (text_str.length() > 0) {
156 printf("%s\n", *text_str); 159 printf("%s\n", *text_str);
157 } 160 }
158 running = 161 running = response_details->Get(String::NewFromUtf8(isolate, "running"))
159 response_details->Get(String::New("running"))->ToBoolean()->Value(); 162 ->ToBoolean()
163 ->Value();
160 } 164 }
161 } 165 }
162 166
163 167
164 void RunRemoteDebugger(Isolate* isolate, int port) { 168 void RunRemoteDebugger(Isolate* isolate, int port) {
165 RemoteDebugger debugger(isolate, port); 169 RemoteDebugger debugger(isolate, port);
166 debugger.Run(); 170 debugger.Run();
167 } 171 }
168 172
169 173
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return result; 270 return result;
267 } 271 }
268 272
269 273
270 void RemoteDebugger::HandleMessageReceived(char* message) { 274 void RemoteDebugger::HandleMessageReceived(char* message) {
271 Locker lock(isolate_); 275 Locker lock(isolate_);
272 HandleScope scope(isolate_); 276 HandleScope scope(isolate_);
273 277
274 // Print the event details. 278 // Print the event details.
275 TryCatch try_catch; 279 TryCatch try_catch;
276 Handle<Object> details = 280 Handle<Object> details = Shell::DebugMessageDetails(
277 Shell::DebugMessageDetails(isolate_, 281 isolate_, Handle<String>::Cast(String::NewFromUtf8(isolate_, message)));
278 Handle<String>::Cast(String::New(message)));
279 if (try_catch.HasCaught()) { 282 if (try_catch.HasCaught()) {
280 Shell::ReportException(isolate_, &try_catch); 283 Shell::ReportException(isolate_, &try_catch);
281 PrintPrompt(); 284 PrintPrompt();
282 return; 285 return;
283 } 286 }
284 String::Utf8Value str(details->Get(String::New("text"))); 287 String::Utf8Value str(details->Get(String::NewFromUtf8(isolate_, "text")));
285 if (str.length() == 0) { 288 if (str.length() == 0) {
286 // Empty string is used to signal not to process this event. 289 // Empty string is used to signal not to process this event.
287 return; 290 return;
288 } 291 }
289 if (*str != NULL) { 292 if (*str != NULL) {
290 printf("%s\n", *str); 293 printf("%s\n", *str);
291 } else { 294 } else {
292 printf("???\n"); 295 printf("???\n");
293 } 296 }
294 297
295 bool is_running = details->Get(String::New("running"))->ToBoolean()->Value(); 298 bool is_running = details->Get(String::NewFromUtf8(isolate_, "running"))
299 ->ToBoolean()
300 ->Value();
296 PrintPrompt(is_running); 301 PrintPrompt(is_running);
297 } 302 }
298 303
299 304
300 void RemoteDebugger::HandleKeyboardCommand(char* command) { 305 void RemoteDebugger::HandleKeyboardCommand(char* command) {
301 Locker lock(isolate_); 306 Locker lock(isolate_);
302 HandleScope scope(isolate_); 307 HandleScope scope(isolate_);
303 308
304 // Convert the debugger command to a JSON debugger request. 309 // Convert the debugger command to a JSON debugger request.
305 TryCatch try_catch; 310 TryCatch try_catch;
306 Handle<Value> request = 311 Handle<Value> request = Shell::DebugCommandToJSONRequest(
307 Shell::DebugCommandToJSONRequest(isolate_, String::New(command)); 312 isolate_, String::NewFromUtf8(isolate_, command));
308 if (try_catch.HasCaught()) { 313 if (try_catch.HasCaught()) {
309 Shell::ReportException(isolate_, &try_catch); 314 Shell::ReportException(isolate_, &try_catch);
310 PrintPrompt(); 315 PrintPrompt();
311 return; 316 return;
312 } 317 }
313 318
314 // If undefined is returned the command was handled internally and there is 319 // If undefined is returned the command was handled internally and there is
315 // no JSON to send. 320 // no JSON to send.
316 if (request->IsUndefined()) { 321 if (request->IsUndefined()) {
317 PrintPrompt(); 322 PrintPrompt();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // Pass the keyboard command to the main thread. 362 // Pass the keyboard command to the main thread.
358 remote_debugger_->KeyboardCommand( 363 remote_debugger_->KeyboardCommand(
359 i::SmartArrayPointer<char>(i::StrDup(command))); 364 i::SmartArrayPointer<char>(i::StrDup(command)));
360 } 365 }
361 } 366 }
362 367
363 368
364 } // namespace v8 369 } // namespace v8
365 370
366 #endif // ENABLE_DEBUGGER_SUPPORT 371 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « src/d8.gyp ('k') | src/d8-posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698