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 3646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3657 CHECK_EQ(2, break_point_hit_count); | 3657 CHECK_EQ(2, break_point_hit_count); |
3658 | 3658 |
3659 // Remove the debug event listener without clearing breakpoints again. | 3659 // Remove the debug event listener without clearing breakpoints again. |
3660 v8::Debug::SetDebugEventListener(NULL); | 3660 v8::Debug::SetDebugEventListener(NULL); |
3661 CheckDebuggerUnloaded(true); | 3661 CheckDebuggerUnloaded(true); |
3662 } | 3662 } |
3663 | 3663 |
3664 | 3664 |
3665 int host_dispatch_hit_count = 0; | 3665 int host_dispatch_hit_count = 0; |
3666 static void HostDispatchHandlerHitCount(void* dispatch, void *data) { | 3666 static void HostDispatchHandlerHitCount(void* dispatch, void *data) { |
3667 CHECK_EQ(dispatch, &HostDispatchHandlerHitCount); | |
3668 CHECK_EQ(data, &HostDispatchHandlerHitCount); | |
3669 host_dispatch_hit_count++; | 3667 host_dispatch_hit_count++; |
3670 } | 3668 } |
3671 | 3669 |
3672 | 3670 |
3673 // Test that clearing the debug event listener actually clears all break points | 3671 // Test that clearing the debug event listener actually clears all break points |
3674 // and related information. | 3672 // and related information. |
3675 TEST(DebuggerHostDispatch) { | 3673 TEST(DebuggerHostDispatch) { |
3676 v8::HandleScope scope; | 3674 v8::HandleScope scope; |
3677 DebugLocalContext env; | 3675 DebugLocalContext env; |
3678 | 3676 |
3679 const int kBufferSize = 1000; | 3677 const int kBufferSize = 1000; |
3680 uint16_t buffer[kBufferSize]; | 3678 uint16_t buffer[kBufferSize]; |
3681 const char* command_continue = | 3679 const char* command_continue = |
3682 "{\"seq\":106," | 3680 "{\"seq\":106," |
3683 "\"type\":\"request\"," | 3681 "\"type\":\"request\"," |
3684 "\"command\":\"continue\"}"; | 3682 "\"command\":\"continue\"}"; |
3685 | 3683 |
3686 // Setup message and host dispatch handlers. | 3684 // Setup message and host dispatch handlers. |
3687 v8::Debug::SetMessageHandler(DummyMessageHandler); | 3685 v8::Debug::SetMessageHandler(DummyMessageHandler); |
3688 v8::Debug::SetHostDispatchHandler(HostDispatchHandlerHitCount, | 3686 v8::Debug::SetHostDispatchHandler(HostDispatchHandlerHitCount, |
3689 &HostDispatchHandlerHitCount); | 3687 NULL); |
3690 | 3688 |
3691 // Fill a host dispatch and a continue command on the command queue before | 3689 // Fill a host dispatch and a continue command on the command queue before |
3692 // generating a debug break. | 3690 // generating a debug break. |
3693 v8::Debug::SendHostDispatch(&HostDispatchHandlerHitCount); | 3691 v8::Debug::SendHostDispatch(NULL); |
3694 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer)); | 3692 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer)); |
3695 CompileRun("debugger"); | 3693 CompileRun("debugger"); |
3696 | 3694 |
3697 // The host dispatch callback should be called. | 3695 // The host dispatch callback should be called. |
3698 CHECK_EQ(1, host_dispatch_hit_count); | 3696 CHECK_EQ(1, host_dispatch_hit_count); |
3699 } | 3697 } |
| 3698 |
OLD | NEW |