OLD | NEW |
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 3175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3186 const char* src = "function foo(x) { " | 3186 const char* src = "function foo(x) { " |
3187 " var a = 0;" | 3187 " var a = 0;" |
3188 " while (a < x) {" | 3188 " while (a < x) {" |
3189 " a++;" | 3189 " a++;" |
3190 " }" | 3190 " }" |
3191 "}" | 3191 "}" |
3192 "foo()"; | 3192 "foo()"; |
3193 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); | 3193 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
3194 SetBreakPoint(foo, 8); // "var a = 0;" | 3194 SetBreakPoint(foo, 8); // "var a = 0;" |
3195 | 3195 |
| 3196 // Looping 0 times. We still should break at the while-condition once. |
| 3197 step_action = StepIn; |
| 3198 break_point_hit_count = 0; |
| 3199 v8::Handle<v8::Value> argv_0[argc] = { v8::Number::New(isolate, 0) }; |
| 3200 foo->Call(env->Global(), argc, argv_0); |
| 3201 CHECK_EQ(3, break_point_hit_count); |
| 3202 |
3196 // Looping 10 times. | 3203 // Looping 10 times. |
3197 step_action = StepIn; | 3204 step_action = StepIn; |
3198 break_point_hit_count = 0; | 3205 break_point_hit_count = 0; |
3199 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; | 3206 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; |
3200 foo->Call(env->Global(), argc, argv_10); | 3207 foo->Call(env->Global(), argc, argv_10); |
3201 CHECK_EQ(22, break_point_hit_count); | 3208 CHECK_EQ(23, break_point_hit_count); |
3202 | 3209 |
3203 // Looping 100 times. | 3210 // Looping 100 times. |
3204 step_action = StepIn; | 3211 step_action = StepIn; |
3205 break_point_hit_count = 0; | 3212 break_point_hit_count = 0; |
3206 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; | 3213 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; |
3207 foo->Call(env->Global(), argc, argv_100); | 3214 foo->Call(env->Global(), argc, argv_100); |
3208 CHECK_EQ(202, break_point_hit_count); | 3215 CHECK_EQ(203, break_point_hit_count); |
3209 | 3216 |
3210 // Get rid of the debug event listener. | 3217 // Get rid of the debug event listener. |
3211 v8::Debug::SetDebugEventListener(NULL); | 3218 v8::Debug::SetDebugEventListener(NULL); |
3212 CheckDebuggerUnloaded(); | 3219 CheckDebuggerUnloaded(); |
3213 } | 3220 } |
3214 | 3221 |
3215 | 3222 |
3216 TEST(DebugStepDoWhile) { | 3223 TEST(DebugStepDoWhile) { |
3217 DebugLocalContext env; | 3224 DebugLocalContext env; |
3218 v8::Isolate* isolate = env->GetIsolate(); | 3225 v8::Isolate* isolate = env->GetIsolate(); |
(...skipping 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5116 } | 5123 } |
5117 | 5124 |
5118 | 5125 |
5119 static void ThreadedMessageHandler(const v8::Debug::Message& message) { | 5126 static void ThreadedMessageHandler(const v8::Debug::Message& message) { |
5120 static char print_buffer[1000]; | 5127 static char print_buffer[1000]; |
5121 v8::String::Value json(message.GetJSON()); | 5128 v8::String::Value json(message.GetJSON()); |
5122 Utf16ToAscii(*json, json.length(), print_buffer); | 5129 Utf16ToAscii(*json, json.length(), print_buffer); |
5123 if (IsBreakEventMessage(print_buffer)) { | 5130 if (IsBreakEventMessage(print_buffer)) { |
5124 // Check that we are inside the while loop. | 5131 // Check that we are inside the while loop. |
5125 int source_line = GetSourceLineFromBreakEventMessage(print_buffer); | 5132 int source_line = GetSourceLineFromBreakEventMessage(print_buffer); |
5126 // TODO(2047): This should really be 8 <= source_line <= 13; but we | 5133 CHECK(8 <= source_line && source_line <= 13); |
5127 // currently have an off-by-one error when calculating the source | |
5128 // position corresponding to the program counter at the debug break. | |
5129 CHECK(7 <= source_line && source_line <= 13); | |
5130 threaded_debugging_barriers.barrier_2.Wait(); | 5134 threaded_debugging_barriers.barrier_2.Wait(); |
5131 } | 5135 } |
5132 } | 5136 } |
5133 | 5137 |
5134 | 5138 |
5135 void V8Thread::Run() { | 5139 void V8Thread::Run() { |
5136 const char* source = | 5140 const char* source = |
5137 "flag = true;\n" | 5141 "flag = true;\n" |
5138 "function bar( new_value ) {\n" | 5142 "function bar( new_value ) {\n" |
5139 " flag = new_value;\n" | 5143 " flag = new_value;\n" |
(...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7464 TEST(DebugBreakOffThreadTerminate) { | 7468 TEST(DebugBreakOffThreadTerminate) { |
7465 DebugLocalContext env; | 7469 DebugLocalContext env; |
7466 v8::Isolate* isolate = env->GetIsolate(); | 7470 v8::Isolate* isolate = env->GetIsolate(); |
7467 v8::HandleScope scope(isolate); | 7471 v8::HandleScope scope(isolate); |
7468 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate); | 7472 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate); |
7469 TerminationThread terminator(isolate); | 7473 TerminationThread terminator(isolate); |
7470 terminator.Start(); | 7474 terminator.Start(); |
7471 v8::Debug::DebugBreak(isolate); | 7475 v8::Debug::DebugBreak(isolate); |
7472 CompileRun("while (true);"); | 7476 CompileRun("while (true);"); |
7473 } | 7477 } |
OLD | NEW |