Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: test/cctest/test-debug.cc

Issue 42686: Fix issue 96, test-debug/ThreadedDebugging is flaky... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3282 matching lines...) Expand 10 before | Expand all | Expand 10 after
3293 public: 3293 public:
3294 void Run(); 3294 void Run();
3295 }; 3295 };
3296 3296
3297 class DebuggerThread : public v8::internal::Thread { 3297 class DebuggerThread : public v8::internal::Thread {
3298 public: 3298 public:
3299 void Run(); 3299 void Run();
3300 }; 3300 };
3301 3301
3302 3302
3303 static v8::Handle<v8::Value> ThreadedSetBarrier1(const v8::Arguments& args) {
3304 threaded_debugging_barriers.barrier_1.Wait();
3305 return v8::Undefined();
3306 }
3307
3308
3303 static void ThreadedMessageHandler(const uint16_t* message, int length, 3309 static void ThreadedMessageHandler(const uint16_t* message, int length,
3304 void *data) { 3310 void *data) {
3305 static char print_buffer[1000]; 3311 static char print_buffer[1000];
3306 Utf16ToAscii(message, length, print_buffer); 3312 Utf16ToAscii(message, length, print_buffer);
3307 if (IsBreakEventMessage(print_buffer)) { 3313 if (IsBreakEventMessage(print_buffer)) {
3308 threaded_debugging_barriers.barrier_2.Wait(); 3314 threaded_debugging_barriers.barrier_2.Wait();
3309 } 3315 }
3310 printf("%s\n", print_buffer); 3316 printf("%s\n", print_buffer);
3311 fflush(stdout); 3317 fflush(stdout);
3312 } 3318 }
3313 3319
3314 3320
3315 void V8Thread::Run() { 3321 void V8Thread::Run() {
3316 const char* source_1 = 3322 const char* source =
3317 "flag = true;\n" 3323 "flag = true;\n"
3318 "function bar( new_value ) {\n" 3324 "function bar( new_value ) {\n"
3319 " flag = new_value;\n" 3325 " flag = new_value;\n"
3320 " return \"Return from bar(\" + new_value + \")\";\n" 3326 " return \"Return from bar(\" + new_value + \")\";\n"
3321 "}\n" 3327 "}\n"
3322 "\n" 3328 "\n"
3323 "function foo() {\n" 3329 "function foo() {\n"
3324 " var x = 1;\n" 3330 " var x = 1;\n"
3325 " while ( flag == true ) {\n" 3331 " while ( flag == true ) {\n"
3332 " if ( x == 1 ) {\n"
3333 " ThreadedSetBarrier1();\n"
3334 " }\n"
3326 " x = x + 1;\n" 3335 " x = x + 1;\n"
3327 " }\n" 3336 " }\n"
3328 "}\n" 3337 "}\n"
3329 "\n"; 3338 "\n"
3330 const char* source_2 = "foo();\n"; 3339 "foo();\n";
3331 3340
3332 v8::HandleScope scope; 3341 v8::HandleScope scope;
3333 DebugLocalContext env; 3342 DebugLocalContext env;
3334 v8::Debug::SetMessageHandler(&ThreadedMessageHandler); 3343 v8::Debug::SetMessageHandler(&ThreadedMessageHandler);
3344 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
3345 global_template->Set(v8::String::New("ThreadedSetBarrier1"),
3346 v8::FunctionTemplate::New(ThreadedSetBarrier1));
3347 v8::Handle<v8::Context> context = v8::Context::New(NULL, global_template);
3348 v8::Context::Scope context_scope(context);
3335 3349
3336 CompileRun(source_1); 3350 CompileRun(source);
3337 threaded_debugging_barriers.barrier_1.Wait();
3338 CompileRun(source_2);
3339 } 3351 }
3340 3352
3341 void DebuggerThread::Run() { 3353 void DebuggerThread::Run() {
3342 const int kBufSize = 1000; 3354 const int kBufSize = 1000;
3343 uint16_t buffer[kBufSize]; 3355 uint16_t buffer[kBufSize];
3344 3356
3345 const char* command_1 = "{\"seq\":102," 3357 const char* command_1 = "{\"seq\":102,"
3346 "\"type\":\"request\"," 3358 "\"type\":\"request\","
3347 "\"command\":\"evaluate\"," 3359 "\"command\":\"evaluate\","
3348 "\"arguments\":{\"expression\":\"bar(false)\"}}"; 3360 "\"arguments\":{\"expression\":\"bar(false)\"}}";
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
4078 bool allow_natives_syntax = i::FLAG_allow_natives_syntax; 4090 bool allow_natives_syntax = i::FLAG_allow_natives_syntax;
4079 i::FLAG_allow_natives_syntax = true; 4091 i::FLAG_allow_natives_syntax = true;
4080 CompileRun( 4092 CompileRun(
4081 "var scripts = %DebugGetLoadedScripts();" 4093 "var scripts = %DebugGetLoadedScripts();"
4082 "for (var i = 0; i < scripts.length; ++i) {" 4094 "for (var i = 0; i < scripts.length; ++i) {"
4083 " scripts[i].line_ends;" 4095 " scripts[i].line_ends;"
4084 "}"); 4096 "}");
4085 // Must not crash while accessing line_ends. 4097 // Must not crash while accessing line_ends.
4086 i::FLAG_allow_natives_syntax = allow_natives_syntax; 4098 i::FLAG_allow_natives_syntax = allow_natives_syntax;
4087 } 4099 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698