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 2363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2374 // Set breakpoint does not duplicate hits | 2374 // Set breakpoint does not duplicate hits |
2375 foo->Call(env->Global(), 0, NULL); | 2375 foo->Call(env->Global(), 0, NULL); |
2376 CHECK_EQ(2, break_point_hit_count); | 2376 CHECK_EQ(2, break_point_hit_count); |
2377 | 2377 |
2378 ClearBreakPoint(bp); | 2378 ClearBreakPoint(bp); |
2379 v8::Debug::SetDebugEventListener(NULL); | 2379 v8::Debug::SetDebugEventListener(NULL); |
2380 CheckDebuggerUnloaded(); | 2380 CheckDebuggerUnloaded(); |
2381 } | 2381 } |
2382 | 2382 |
2383 | 2383 |
2384 // Thest that the evaluation of expressions when a break point is hit generates | 2384 // Test that the evaluation of expressions when a break point is hit generates |
2385 // the correct results. | 2385 // the correct results. |
2386 TEST(DebugEvaluate) { | 2386 TEST(DebugEvaluate) { |
2387 v8::HandleScope scope; | 2387 v8::HandleScope scope; |
2388 DebugLocalContext env; | 2388 DebugLocalContext env; |
2389 env.ExposeDebug(); | 2389 env.ExposeDebug(); |
2390 | 2390 |
2391 // Create a function for checking the evaluation when hitting a break point. | 2391 // Create a function for checking the evaluation when hitting a break point. |
2392 evaluate_check_function = CompileFunction(&env, | 2392 evaluate_check_function = CompileFunction(&env, |
2393 evaluate_check_source, | 2393 evaluate_check_source, |
2394 "evaluate_check"); | 2394 "evaluate_check"); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2490 v8::Handle<v8::Value> argv_bar_3[2] = { | 2490 v8::Handle<v8::Value> argv_bar_3[2] = { |
2491 v8::String::New("Hello, world!"), | 2491 v8::String::New("Hello, world!"), |
2492 v8::Number::New(barbar_break_position + 1) | 2492 v8::Number::New(barbar_break_position + 1) |
2493 }; | 2493 }; |
2494 bar->Call(env->Global(), 2, argv_bar_3); | 2494 bar->Call(env->Global(), 2, argv_bar_3); |
2495 | 2495 |
2496 v8::Debug::SetDebugEventListener(NULL); | 2496 v8::Debug::SetDebugEventListener(NULL); |
2497 CheckDebuggerUnloaded(); | 2497 CheckDebuggerUnloaded(); |
2498 } | 2498 } |
2499 | 2499 |
2500 | |
2501 int debugEventCount = 0; | |
2502 static void CheckDebugEvent(const v8::Debug::EventDetails& eventDetails) { | |
2503 if (eventDetails.GetEvent() == v8::Break) | |
Michael Starzinger
2012/10/15 09:51:25
Either on one line or add curly brackets.
yurys
2012/10/15 10:14:53
Done.
| |
2504 ++debugEventCount; | |
2505 } | |
2506 | |
2507 // Test that the conditional breakpoints work event if code generation from | |
2508 // strings is prohibited in the debugee context. | |
2509 TEST(ConditionalBreakpointWithCodeGenerationDisallowed) { | |
2510 v8::HandleScope scope; | |
2511 DebugLocalContext env; | |
2512 env.ExposeDebug(); | |
2513 | |
2514 v8::Debug::SetDebugEventListener2(CheckDebugEvent); | |
2515 | |
2516 v8::Local<v8::Function> foo = CompileFunction(&env, | |
2517 "function foo(x) {\n" | |
2518 " var s = 'String value2';\n" | |
2519 " return s + x;\n" | |
2520 "}", | |
2521 "foo"); | |
2522 | |
2523 // Set conditional breakpoint with condition 'true'. | |
2524 CompileRun("debug.Debug.setBreakPoint(foo, 2, 0, 'true')"); | |
2525 | |
2526 debugEventCount = 0; | |
2527 env->AllowCodeGenerationFromStrings(false); | |
2528 foo->Call(env->Global(), 0, NULL); | |
2529 CHECK_EQ(1, debugEventCount); | |
2530 | |
2531 v8::Debug::SetDebugEventListener2(NULL); | |
2532 CheckDebuggerUnloaded(); | |
2533 } | |
2534 | |
Michael Starzinger
2012/10/15 09:51:25
Add second empty newline for readability.
yurys
2012/10/15 10:14:53
Done.
| |
2535 bool checkedDebugEvals = true; | |
2536 v8::Handle<v8::Function> checkGlobalEvalFunction; | |
2537 v8::Handle<v8::Function> checkFrameEvalFunction; | |
2538 static void CheckDebugEval(const v8::Debug::EventDetails& eventDetails) { | |
2539 if (eventDetails.GetEvent() == v8::Break) { | |
2540 ++debugEventCount; | |
2541 v8::HandleScope handleScope; | |
2542 | |
2543 v8::Handle<v8::Value> args[] = { eventDetails.GetExecutionState() }; | |
2544 CHECK(checkGlobalEvalFunction->Call( | |
2545 eventDetails.GetEventContext()->Global(), 1, args)->IsTrue()); | |
2546 CHECK(checkFrameEvalFunction->Call( | |
2547 eventDetails.GetEventContext()->Global(), 1, args)->IsTrue()); | |
2548 } | |
2549 } | |
2550 | |
2551 // Test that the evaluation of expressions when a break point is hit generates | |
2552 // the correct results in case code generation from strings is disallowed in the | |
2553 // debugee context. | |
2554 TEST(DebugEvaluateWithCodeGenerationDisallowed) { | |
2555 v8::HandleScope scope; | |
2556 DebugLocalContext env; | |
2557 env.ExposeDebug(); | |
2558 | |
2559 v8::Debug::SetDebugEventListener2(CheckDebugEval); | |
2560 | |
2561 v8::Local<v8::Function> foo = CompileFunction(&env, | |
2562 "var global = 'Global';\n" | |
2563 "function foo(x) {\n" | |
2564 " var local = 'Local';\n" | |
2565 " debugger;\n" | |
2566 " return local + x;\n" | |
2567 "}", | |
2568 "foo"); | |
2569 checkGlobalEvalFunction = CompileFunction(&env, | |
2570 "function checkGlobalEval(exec_state) {\n" | |
2571 " return exec_state.evaluateGlobal('global').value() === 'Global';\n" | |
2572 "}", | |
2573 "checkGlobalEval"); | |
2574 | |
2575 checkFrameEvalFunction = CompileFunction(&env, | |
2576 "function checkFrameEval(exec_state) {\n" | |
2577 " return exec_state.frame(0).evaluate('local').value() === 'Local';\n" | |
2578 "}", | |
2579 "checkFrameEval"); | |
2580 debugEventCount = 0; | |
2581 env->AllowCodeGenerationFromStrings(false); | |
2582 foo->Call(env->Global(), 0, NULL); | |
2583 CHECK_EQ(1, debugEventCount); | |
2584 | |
2585 checkGlobalEvalFunction.Clear(); | |
2586 checkFrameEvalFunction.Clear(); | |
2587 v8::Debug::SetDebugEventListener2(NULL); | |
2588 CheckDebuggerUnloaded(); | |
2589 } | |
2590 | |
Michael Starzinger
2012/10/15 09:51:25
Add second empty newline for readability.
yurys
2012/10/15 10:14:53
Done.
| |
2500 // Copies a C string to a 16-bit string. Does not check for buffer overflow. | 2591 // Copies a C string to a 16-bit string. Does not check for buffer overflow. |
2501 // Does not use the V8 engine to convert strings, so it can be used | 2592 // Does not use the V8 engine to convert strings, so it can be used |
2502 // in any thread. Returns the length of the string. | 2593 // in any thread. Returns the length of the string. |
2503 int AsciiToUtf16(const char* input_buffer, uint16_t* output_buffer) { | 2594 int AsciiToUtf16(const char* input_buffer, uint16_t* output_buffer) { |
2504 int i; | 2595 int i; |
2505 for (i = 0; input_buffer[i] != '\0'; ++i) { | 2596 for (i = 0; input_buffer[i] != '\0'; ++i) { |
2506 // ASCII does not use chars > 127, but be careful anyway. | 2597 // ASCII does not use chars > 127, but be careful anyway. |
2507 output_buffer[i] = static_cast<unsigned char>(input_buffer[i]); | 2598 output_buffer[i] = static_cast<unsigned char>(input_buffer[i]); |
2508 } | 2599 } |
2509 output_buffer[i] = 0; | 2600 output_buffer[i] = 0; |
(...skipping 4923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7433 TEST(LiveEditDisabled) { | 7524 TEST(LiveEditDisabled) { |
7434 v8::internal::FLAG_allow_natives_syntax = true; | 7525 v8::internal::FLAG_allow_natives_syntax = true; |
7435 v8::HandleScope scope; | 7526 v8::HandleScope scope; |
7436 LocalContext context; | 7527 LocalContext context; |
7437 v8::Debug::SetLiveEditEnabled(false); | 7528 v8::Debug::SetLiveEditEnabled(false); |
7438 CompileRun("%LiveEditCompareStrings('', '')"); | 7529 CompileRun("%LiveEditCompareStrings('', '')"); |
7439 } | 7530 } |
7440 | 7531 |
7441 | 7532 |
7442 #endif // ENABLE_DEBUGGER_SUPPORT | 7533 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |