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 4573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4584 char* pos = strstr(message, prefix); | 4584 char* pos = strstr(message, prefix); |
4585 if (pos == NULL) { | 4585 if (pos == NULL) { |
4586 return -1; | 4586 return -1; |
4587 } | 4587 } |
4588 pos += strlen(prefix); | 4588 pos += strlen(prefix); |
4589 int res = StringToInt(pos); | 4589 int res = StringToInt(pos); |
4590 return res; | 4590 return res; |
4591 } | 4591 } |
4592 | 4592 |
4593 | 4593 |
| 4594 // We match parts of the message to get source line. |
| 4595 int GetSourceLineFromBreakEventMessage(char *message) { |
| 4596 const char* source_line = "\"sourceLine\":"; |
| 4597 char* pos = strstr(message, source_line); |
| 4598 if (pos == NULL) { |
| 4599 return -1; |
| 4600 } |
| 4601 int res = -1; |
| 4602 res = StringToInt(pos + strlen(source_line)); |
| 4603 return res; |
| 4604 } |
| 4605 |
4594 /* Test MessageQueues */ | 4606 /* Test MessageQueues */ |
4595 /* Tests the message queues that hold debugger commands and | 4607 /* Tests the message queues that hold debugger commands and |
4596 * response messages to the debugger. Fills queues and makes | 4608 * response messages to the debugger. Fills queues and makes |
4597 * them grow. | 4609 * them grow. |
4598 */ | 4610 */ |
4599 Barriers message_queue_barriers; | 4611 Barriers message_queue_barriers; |
4600 | 4612 |
4601 // This is the debugger thread, that executes no v8 calls except | 4613 // This is the debugger thread, that executes no v8 calls except |
4602 // placing JSON debugger commands in the queue. | 4614 // placing JSON debugger commands in the queue. |
4603 class MessageQueueDebuggerThread : public v8::internal::Thread { | 4615 class MessageQueueDebuggerThread : public v8::internal::Thread { |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4863 threaded_debugging_barriers.barrier_1.Wait(); | 4875 threaded_debugging_barriers.barrier_1.Wait(); |
4864 return v8::Undefined(); | 4876 return v8::Undefined(); |
4865 } | 4877 } |
4866 | 4878 |
4867 | 4879 |
4868 static void ThreadedMessageHandler(const v8::Debug::Message& message) { | 4880 static void ThreadedMessageHandler(const v8::Debug::Message& message) { |
4869 static char print_buffer[1000]; | 4881 static char print_buffer[1000]; |
4870 v8::String::Value json(message.GetJSON()); | 4882 v8::String::Value json(message.GetJSON()); |
4871 Utf16ToAscii(*json, json.length(), print_buffer); | 4883 Utf16ToAscii(*json, json.length(), print_buffer); |
4872 if (IsBreakEventMessage(print_buffer)) { | 4884 if (IsBreakEventMessage(print_buffer)) { |
| 4885 // Check that we are inside the while loop. |
| 4886 int source_line = GetSourceLineFromBreakEventMessage(print_buffer); |
| 4887 CHECK(8 <= source_line && source_line <= 13); |
4873 threaded_debugging_barriers.barrier_2.Wait(); | 4888 threaded_debugging_barriers.barrier_2.Wait(); |
4874 } | 4889 } |
4875 } | 4890 } |
4876 | 4891 |
4877 | 4892 |
4878 void V8Thread::Run() { | 4893 void V8Thread::Run() { |
4879 const char* source = | 4894 const char* source = |
4880 "flag = true;\n" | 4895 "flag = true;\n" |
4881 "function bar( new_value ) {\n" | 4896 "function bar( new_value ) {\n" |
4882 " flag = new_value;\n" | 4897 " flag = new_value;\n" |
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6871 | 6886 |
6872 CHECK_EQ(2, TestClientData::constructor_call_counter); | 6887 CHECK_EQ(2, TestClientData::constructor_call_counter); |
6873 CHECK_EQ(TestClientData::constructor_call_counter, | 6888 CHECK_EQ(TestClientData::constructor_call_counter, |
6874 TestClientData::destructor_call_counter); | 6889 TestClientData::destructor_call_counter); |
6875 | 6890 |
6876 v8::Debug::SetDebugEventListener(NULL); | 6891 v8::Debug::SetDebugEventListener(NULL); |
6877 CheckDebuggerUnloaded(); | 6892 CheckDebuggerUnloaded(); |
6878 } | 6893 } |
6879 | 6894 |
6880 #endif // ENABLE_DEBUGGER_SUPPORT | 6895 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |