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 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2190 for (int i = 0; i < length; ++i) { | 2190 for (int i = 0; i < length; ++i) { |
2191 output_buffer[i] = static_cast<char>(input_buffer[i]); | 2191 output_buffer[i] = static_cast<char>(input_buffer[i]); |
2192 } | 2192 } |
2193 output_buffer[length] = '\0'; | 2193 output_buffer[length] = '\0'; |
2194 return length; | 2194 return length; |
2195 } | 2195 } |
2196 | 2196 |
2197 | 2197 |
2198 // We match parts of the message to get evaluate result int value. | 2198 // We match parts of the message to get evaluate result int value. |
2199 bool GetEvaluateStringResult(char *message, char* buffer, int buffer_size) { | 2199 bool GetEvaluateStringResult(char *message, char* buffer, int buffer_size) { |
2200 const char* value = "\"value\":"; | 2200 if (strstr(message, "\"command\":\"evaluate\"") == NULL) { |
2201 char* pos = strstr(message, value); | 2201 return false; |
2202 if (pos == NULL) { | 2202 } |
| 2203 const char* prefix = "\"text\":\""; |
| 2204 char* pos1 = strstr(message, prefix); |
| 2205 if (pos1 == NULL) { |
| 2206 return false; |
| 2207 } |
| 2208 pos1 += strlen(prefix); |
| 2209 char* pos2 = strchr(pos1, '"'); |
| 2210 if (pos2 == NULL) { |
2203 return false; | 2211 return false; |
2204 } | 2212 } |
2205 Vector<char> buf(buffer, buffer_size); | 2213 Vector<char> buf(buffer, buffer_size); |
2206 OS::StrNCpy(buf, pos, buffer_size - 1); | 2214 int len = pos2 - pos1; |
| 2215 if (len > buffer_size - 1) { |
| 2216 len = buffer_size - 1; |
| 2217 } |
| 2218 OS::StrNCpy(buf, pos1, len); |
2207 buffer[buffer_size - 1] = '\0'; | 2219 buffer[buffer_size - 1] = '\0'; |
2208 return true; | 2220 return true; |
2209 } | 2221 } |
2210 | 2222 |
2211 | 2223 |
2212 struct EvaluateResult { | 2224 struct EvaluateResult { |
2213 static const int kBufferSize = 20; | 2225 static const int kBufferSize = 20; |
2214 char buffer[kBufferSize]; | 2226 char buffer[kBufferSize]; |
2215 }; | 2227 }; |
2216 | 2228 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 " \"global\":true," | 2308 " \"global\":true," |
2297 " \"expression\":\"239 + 566\",\"disable_break\":true" | 2309 " \"expression\":\"239 + 566\",\"disable_break\":true" |
2298 "}}"; | 2310 "}}"; |
2299 | 2311 |
2300 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_113, buffer)); | 2312 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_113, buffer)); |
2301 | 2313 |
2302 v8::Debug::ProcessDebugMessages(); | 2314 v8::Debug::ProcessDebugMessages(); |
2303 | 2315 |
2304 CHECK_EQ(3, process_debug_messages_data.counter); | 2316 CHECK_EQ(3, process_debug_messages_data.counter); |
2305 | 2317 |
2306 CHECK(strcmp("Pinguin", process_debug_messages_data.results[0].buffer)); | 2318 CHECK(strcmp("Pinguin", process_debug_messages_data.results[0].buffer) == 0); |
2307 CHECK(strcmp("Captbara", process_debug_messages_data.results[1].buffer)); | 2319 CHECK(strcmp("Capybara", process_debug_messages_data.results[1].buffer) == 0); |
2308 CHECK(strcmp("805", process_debug_messages_data.results[2].buffer)); | 2320 CHECK(strcmp("805", process_debug_messages_data.results[2].buffer) == 0); |
2309 | 2321 |
2310 v8::Debug::SetMessageHandler(NULL); | 2322 v8::Debug::SetMessageHandler(NULL); |
2311 v8::Debug::SetDebugEventListener(NULL); | 2323 v8::Debug::SetDebugEventListener(NULL); |
2312 CheckDebuggerUnloaded(); | 2324 CheckDebuggerUnloaded(); |
2313 } | 2325 } |
2314 | 2326 |
2315 | 2327 |
2316 // Simple test of the stepping mechanism using only store ICs. | 2328 // Simple test of the stepping mechanism using only store ICs. |
2317 TEST(DebugStepLinear) { | 2329 TEST(DebugStepLinear) { |
2318 v8::HandleScope scope; | 2330 v8::HandleScope scope; |
(...skipping 3701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6020 | 6032 |
6021 break_point_hit_count = 0; | 6033 break_point_hit_count = 0; |
6022 foo->Call(env->Global(), 0, NULL); | 6034 foo->Call(env->Global(), 0, NULL); |
6023 CHECK_EQ(1, break_point_hit_count); | 6035 CHECK_EQ(1, break_point_hit_count); |
6024 | 6036 |
6025 v8::Debug::SetDebugEventListener(NULL); | 6037 v8::Debug::SetDebugEventListener(NULL); |
6026 debugee_context = v8::Handle<v8::Context>(); | 6038 debugee_context = v8::Handle<v8::Context>(); |
6027 debugger_context = v8::Handle<v8::Context>(); | 6039 debugger_context = v8::Handle<v8::Context>(); |
6028 CheckDebuggerUnloaded(); | 6040 CheckDebuggerUnloaded(); |
6029 } | 6041 } |
OLD | NEW |