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

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

Issue 10698123: Fix Debug::Break crash. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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 | « src/runtime.cc ('k') | 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 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 7331 matching lines...) Expand 10 before | Expand all | Expand 10 after
7342 "g(false); \n" 7342 "g(false); \n"
7343 "g(false); \n" 7343 "g(false); \n"
7344 "%OptimizeFunctionOnNextCall(g); \n" 7344 "%OptimizeFunctionOnNextCall(g); \n"
7345 "g(true);"; 7345 "g(true);";
7346 v8::Debug::SetDebugEventListener(DebugBreakInlineListener); 7346 v8::Debug::SetDebugEventListener(DebugBreakInlineListener);
7347 inline_script = v8::Script::Compile(v8::String::New(source)); 7347 inline_script = v8::Script::Compile(v8::String::New(source));
7348 inline_script->Run(); 7348 inline_script->Run();
7349 } 7349 }
7350 7350
7351 7351
7352 static void DebugEventStepNext(v8::DebugEvent event,
7353 v8::Handle<v8::Object> exec_state,
7354 v8::Handle<v8::Object> event_data,
7355 v8::Handle<v8::Value> data) {
7356 if (event == v8::Break) {
7357 PrepareStep(StepNext);
7358 }
7359 }
7360
7361
7362 static void RunScriptInANewCFrame(const char* source) {
7363 v8::TryCatch try_catch;
7364 CompileRun(source);
7365 CHECK(try_catch.HasCaught());
7366 }
7367
7368
7369 TEST(Regress131642) {
7370 // Bug description:
7371 // When doing StepNext through the first script, the debugger is not reset
7372 // after exiting through exception. A flawed implementation enabling the
7373 // debugger to step into Array.prototype.forEach breaks inside the callback
7374 // for forEach in the second script under the assumption that we are in a
7375 // recursive call. In an attempt to step out, we crawl the stack using the
7376 // recorded frame pointer from the first script and fail when not finding it
7377 // on the stack.
7378 v8::HandleScope scope;
7379 DebugLocalContext env;
7380 v8::Debug::SetDebugEventListener(DebugEventStepNext);
7381
7382 // We step through the first script. It exits through an exception. We run
7383 // this inside a new frame to record a different FP than the second script
7384 // would expect.
7385 const char* script_1 = "debugger; throw new Error();";
7386 RunScriptInANewCFrame(script_1);
7387
7388 // The second script uses forEach.
7389 const char* script_2 = "[0].forEach(function() { });";
7390 CompileRun(script_2);
7391
7392 v8::Debug::SetDebugEventListener(NULL);
7393 }
7394
7352 #endif // ENABLE_DEBUGGER_SUPPORT 7395 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698