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

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

Issue 9295014: Find correct source position in inlined functions on debug break. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Change test to be single-threaded. Created 8 years, 10 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 7268 matching lines...) Expand 10 before | Expand all | Expand 10 after
7279 7279
7280 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); 7280 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}");
7281 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}"); 7281 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}");
7282 7282
7283 // Get rid of the debug event listener. 7283 // Get rid of the debug event listener.
7284 v8::Debug::SetDebugEventListener(NULL); 7284 v8::Debug::SetDebugEventListener(NULL);
7285 CheckDebuggerUnloaded(); 7285 CheckDebuggerUnloaded();
7286 } 7286 }
7287 7287
7288 7288
7289 static void DebugBreakInlineListener(v8::DebugEvent event,
7290 v8::Handle<v8::Object> exec_state,
7291 v8::Handle<v8::Object> event_data,
7292 v8::Handle<v8::Value> data) {
7293 if (event != v8::Break) return;
7294
7295 int break_id = v8::internal::Isolate::Current()->debug()->break_id();
7296 char script[128];
7297 i::Vector<char> script_vector(script, sizeof(script));
7298 OS::SNPrintF(script_vector, "%%GetFrameCount(%d)", break_id);
7299 v8::Local<v8::Value> result = CompileRun(script);
7300 int frame_count = result->Int32Value();
7301 int previous = -1;
7302 for (int i = 0; i < frame_count; i++) {
7303 // The 5. element in the returned array of GetFrameDetails contains the
7304 // source position of that frame.
7305 OS::SNPrintF(script_vector, "%%GetFrameDetails(%d, %d)[5]", break_id, i);
7306 v8::Local<v8::Value> result = CompileRun(script);
7307 // Each frame's source position has to be different from the previous one.
Søren Gjesse 2012/01/30 12:26:57 Maybe put in expected lines int expected_line[..]
7308 CHECK_NE(previous, result->Int32Value());
7309 previous = result->Int32Value();
7310 }
7311 v8::Debug::SetDebugEventListener(NULL);
7312 v8::V8::TerminateExecution();
7313 }
7314
7315
7316 TEST(DebugBreakInline) {
7317 i::FLAG_allow_natives_syntax = true;
7318 v8::HandleScope scope;
7319 DebugLocalContext env;
7320 const char* source =
7321 "function debug(b) { \n"
7322 " if (b) debugger; \n"
7323 "} \n"
7324 "function f(b) { \n"
7325 " debug(b) \n"
7326 "}; \n"
7327 "function g(b) { \n"
7328 " f(b); \n"
7329 "}; \n"
7330 "g(false); \n"
7331 "g(false); \n"
7332 "%OptimizeFunctionOnNextCall(g); \n"
7333 "g(true);";
7334 v8::Debug::SetDebugEventListener(DebugBreakInlineListener);
7335 CompileRun(source);
7336 }
7337
7338
7289 #endif // ENABLE_DEBUGGER_SUPPORT 7339 #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