OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-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 17 matching lines...) Expand all Loading... |
28 #include <stdlib.h> | 28 #include <stdlib.h> |
29 | 29 |
30 #include "v8.h" | 30 #include "v8.h" |
31 | 31 |
32 #include "api.h" | 32 #include "api.h" |
33 #include "debug.h" | 33 #include "debug.h" |
34 #include "platform.h" | 34 #include "platform.h" |
35 #include "stub-cache.h" | 35 #include "stub-cache.h" |
36 #include "cctest.h" | 36 #include "cctest.h" |
37 | 37 |
| 38 |
| 39 using ::v8::internal::EmbeddedVector; |
38 using ::v8::internal::Object; | 40 using ::v8::internal::Object; |
39 using ::v8::internal::OS; | 41 using ::v8::internal::OS; |
40 using ::v8::internal::Handle; | 42 using ::v8::internal::Handle; |
41 using ::v8::internal::Heap; | 43 using ::v8::internal::Heap; |
42 using ::v8::internal::JSGlobalObject; | 44 using ::v8::internal::JSGlobalObject; |
43 using ::v8::internal::Code; | 45 using ::v8::internal::Code; |
44 using ::v8::internal::Debug; | 46 using ::v8::internal::Debug; |
45 using ::v8::internal::Debugger; | 47 using ::v8::internal::Debugger; |
46 using ::v8::internal::StepAction; | 48 using ::v8::internal::StepAction; |
47 using ::v8::internal::StepIn; // From StepAction enum | 49 using ::v8::internal::StepIn; // From StepAction enum |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // number. | 198 // number. |
197 static int SetBreakPoint(v8::Handle<v8::Function> fun, int position) { | 199 static int SetBreakPoint(v8::Handle<v8::Function> fun, int position) { |
198 return SetBreakPoint(v8::Utils::OpenHandle(*fun), position); | 200 return SetBreakPoint(v8::Utils::OpenHandle(*fun), position); |
199 } | 201 } |
200 | 202 |
201 | 203 |
202 // Set a break point in a function using the Debug object and return the | 204 // Set a break point in a function using the Debug object and return the |
203 // associated break point number. | 205 // associated break point number. |
204 static int SetBreakPointFromJS(const char* function_name, | 206 static int SetBreakPointFromJS(const char* function_name, |
205 int line, int position) { | 207 int line, int position) { |
206 char buffer[SMALL_STRING_BUFFER_SIZE]; | 208 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
207 OS::SNPrintF(buffer, SMALL_STRING_BUFFER_SIZE, | 209 OS::SNPrintF(buffer, |
208 "debug.Debug.setBreakPoint(%s,%d,%d)", | 210 "debug.Debug.setBreakPoint(%s,%d,%d)", |
209 function_name, line, position); | 211 function_name, line, position); |
210 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 212 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
211 return v8::Script::Compile(v8::String::New(buffer))->Run()->Int32Value(); | 213 v8::Handle<v8::String> str = v8::String::New(buffer.start()); |
| 214 return v8::Script::Compile(str)->Run()->Int32Value(); |
212 } | 215 } |
213 | 216 |
214 | 217 |
215 // Set a break point in a script using the global Debug object. | 218 // Set a break point in a script using the global Debug object. |
216 static int SetScriptBreakPointFromJS(const char* script_data, | 219 static int SetScriptBreakPointFromJS(const char* script_data, |
217 int line, int column) { | 220 int line, int column) { |
218 char buffer[SMALL_STRING_BUFFER_SIZE]; | 221 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
219 if (column >= 0) { | 222 if (column >= 0) { |
220 // Column specified set script break point on precise location. | 223 // Column specified set script break point on precise location. |
221 OS::SNPrintF(buffer, SMALL_STRING_BUFFER_SIZE, | 224 OS::SNPrintF(buffer, |
222 "debug.Debug.setScriptBreakPoint(\"%s\",%d,%d)", | 225 "debug.Debug.setScriptBreakPoint(\"%s\",%d,%d)", |
223 script_data, line, column); | 226 script_data, line, column); |
224 } else { | 227 } else { |
225 // Column not specified set script break point on line. | 228 // Column not specified set script break point on line. |
226 OS::SNPrintF(buffer, SMALL_STRING_BUFFER_SIZE, | 229 OS::SNPrintF(buffer, |
227 "debug.Debug.setScriptBreakPoint(\"%s\",%d)", | 230 "debug.Debug.setScriptBreakPoint(\"%s\",%d)", |
228 script_data, line); | 231 script_data, line); |
229 } | 232 } |
230 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 233 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
231 | 234 v8::Handle<v8::String> str = v8::String::New(buffer.start()); |
232 return v8::Script::Compile(v8::String::New(buffer))->Run()->Int32Value(); | 235 return v8::Script::Compile(str)->Run()->Int32Value(); |
233 } | 236 } |
234 | 237 |
235 | 238 |
236 // Clear a break point. | 239 // Clear a break point. |
237 static void ClearBreakPoint(int break_point) { | 240 static void ClearBreakPoint(int break_point) { |
238 Debug::ClearBreakPoint( | 241 Debug::ClearBreakPoint( |
239 Handle<Object>(v8::internal::Smi::FromInt(break_point))); | 242 Handle<Object>(v8::internal::Smi::FromInt(break_point))); |
240 } | 243 } |
241 | 244 |
242 | 245 |
243 // Clear a break point using the global Debug object. | 246 // Clear a break point using the global Debug object. |
244 static void ClearBreakPointFromJS(int break_point_number) { | 247 static void ClearBreakPointFromJS(int break_point_number) { |
245 char buffer[SMALL_STRING_BUFFER_SIZE]; | 248 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
246 OS::SNPrintF(buffer, SMALL_STRING_BUFFER_SIZE, | 249 OS::SNPrintF(buffer, |
247 "debug.Debug.clearBreakPoint(%d)", | 250 "debug.Debug.clearBreakPoint(%d)", |
248 break_point_number); | 251 break_point_number); |
249 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 252 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
250 v8::Script::Compile(v8::String::New(buffer))->Run(); | 253 v8::Script::Compile(v8::String::New(buffer.start()))->Run(); |
251 } | 254 } |
252 | 255 |
253 | 256 |
254 static void EnableScriptBreakPointFromJS(int break_point_number) { | 257 static void EnableScriptBreakPointFromJS(int break_point_number) { |
255 char buffer[SMALL_STRING_BUFFER_SIZE]; | 258 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
256 OS::SNPrintF(buffer, SMALL_STRING_BUFFER_SIZE, | 259 OS::SNPrintF(buffer, |
257 "debug.Debug.enableScriptBreakPoint(%d)", | 260 "debug.Debug.enableScriptBreakPoint(%d)", |
258 break_point_number); | 261 break_point_number); |
259 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 262 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
260 v8::Script::Compile(v8::String::New(buffer))->Run(); | 263 v8::Script::Compile(v8::String::New(buffer.start()))->Run(); |
261 } | 264 } |
262 | 265 |
263 | 266 |
264 static void DisableScriptBreakPointFromJS(int break_point_number) { | 267 static void DisableScriptBreakPointFromJS(int break_point_number) { |
265 char buffer[SMALL_STRING_BUFFER_SIZE]; | 268 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
266 OS::SNPrintF(buffer, SMALL_STRING_BUFFER_SIZE, | 269 OS::SNPrintF(buffer, |
267 "debug.Debug.disableScriptBreakPoint(%d)", | 270 "debug.Debug.disableScriptBreakPoint(%d)", |
268 break_point_number); | 271 break_point_number); |
269 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 272 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
270 v8::Script::Compile(v8::String::New(buffer))->Run(); | 273 v8::Script::Compile(v8::String::New(buffer.start()))->Run(); |
271 } | 274 } |
272 | 275 |
273 | 276 |
274 static void ChangeScriptBreakPointConditionFromJS(int break_point_number, | 277 static void ChangeScriptBreakPointConditionFromJS(int break_point_number, |
275 const char* condition) { | 278 const char* condition) { |
276 char buffer[SMALL_STRING_BUFFER_SIZE]; | 279 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
277 OS::SNPrintF(buffer, SMALL_STRING_BUFFER_SIZE, | 280 OS::SNPrintF(buffer, |
278 "debug.Debug.changeScriptBreakPointCondition(%d, \"%s\")", | 281 "debug.Debug.changeScriptBreakPointCondition(%d, \"%s\")", |
279 break_point_number, condition); | 282 break_point_number, condition); |
280 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 283 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
281 v8::Script::Compile(v8::String::New(buffer))->Run(); | 284 v8::Script::Compile(v8::String::New(buffer.start()))->Run(); |
282 } | 285 } |
283 | 286 |
284 | 287 |
285 static void ChangeScriptBreakPointIgnoreCountFromJS(int break_point_number, | 288 static void ChangeScriptBreakPointIgnoreCountFromJS(int break_point_number, |
286 int ignoreCount) { | 289 int ignoreCount) { |
287 char buffer[SMALL_STRING_BUFFER_SIZE]; | 290 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
288 OS::SNPrintF(buffer, SMALL_STRING_BUFFER_SIZE, | 291 OS::SNPrintF(buffer, |
289 "debug.Debug.changeScriptBreakPointIgnoreCount(%d, %d)", | 292 "debug.Debug.changeScriptBreakPointIgnoreCount(%d, %d)", |
290 break_point_number, ignoreCount); | 293 break_point_number, ignoreCount); |
291 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 294 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
292 v8::Script::Compile(v8::String::New(buffer))->Run(); | 295 v8::Script::Compile(v8::String::New(buffer.start()))->Run(); |
293 } | 296 } |
294 | 297 |
295 | 298 |
296 // Change break on exception. | 299 // Change break on exception. |
297 static void ChangeBreakOnException(bool caught, bool uncaught) { | 300 static void ChangeBreakOnException(bool caught, bool uncaught) { |
298 Debug::ChangeBreakOnException(v8::internal::BreakException, caught); | 301 Debug::ChangeBreakOnException(v8::internal::BreakException, caught); |
299 Debug::ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught); | 302 Debug::ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught); |
300 } | 303 } |
301 | 304 |
302 | 305 |
(...skipping 2821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3124 Barriers stack_allocated_breakpoints_barriers; | 3127 Barriers stack_allocated_breakpoints_barriers; |
3125 stack_allocated_breakpoints_barriers.Initialize(); | 3128 stack_allocated_breakpoints_barriers.Initialize(); |
3126 breakpoints_barriers = &stack_allocated_breakpoints_barriers; | 3129 breakpoints_barriers = &stack_allocated_breakpoints_barriers; |
3127 | 3130 |
3128 breakpoints_v8_thread.Start(); | 3131 breakpoints_v8_thread.Start(); |
3129 breakpoints_debugger_thread.Start(); | 3132 breakpoints_debugger_thread.Start(); |
3130 | 3133 |
3131 breakpoints_v8_thread.Join(); | 3134 breakpoints_v8_thread.Join(); |
3132 breakpoints_debugger_thread.Join(); | 3135 breakpoints_debugger_thread.Join(); |
3133 } | 3136 } |
OLD | NEW |