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

Unified Diff: runtime/vm/debugger_api_impl_test.cc

Issue 9696020: Deoptimize functions before setting breakpoints (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/debugger.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/debugger_api_impl_test.cc
===================================================================
--- runtime/vm/debugger_api_impl_test.cc (revision 5412)
+++ runtime/vm/debugger_api_impl_test.cc (working copy)
@@ -370,7 +370,7 @@
}
-void TestIgnoreBPHandler(Dart_Breakpoint bpt, Dart_StackTrace trace) {
+static void StepIntoHandler(Dart_Breakpoint bpt, Dart_StackTrace trace) {
if (verbose) {
OS::Print(">>> Breakpoint nr. %d in %s <<<\n",
breakpoint_hit_counter, BreakpointInfo(trace));
@@ -399,7 +399,7 @@
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
EXPECT(!Dart_IsError(lib));
- Dart_SetBreakpointHandler(&TestIgnoreBPHandler);
+ Dart_SetBreakpointHandler(&StepIntoHandler);
Dart_Handle c_name = Dart_NewString("");
Dart_Handle f_name = Dart_NewString("main");
@@ -419,6 +419,49 @@
}
+TEST_CASE(Debug_DeoptimizeFunction) {
+ const char* kScriptChars =
+ "foo(x) => 2 * x; \n"
+ " \n"
+ "warmup() { \n"
+ " for (int i = 0; i < 5000; i++) { \n"
+ " foo(i); \n"
+ " } \n"
+ "} \n"
+ " \n"
+ "void main() { \n"
+ " return foo(99); \n"
+ "} \n";
+
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+ EXPECT(!Dart_IsError(lib));
+
+ Dart_SetBreakpointHandler(&StepIntoHandler);
+
+
+ // Cause function foo to be optimized before we set a BP.
+ Dart_Handle res = Invoke(lib, "warmup");
+ EXPECT_NOT_ERROR(res);
+
+ // Now set breakpoint in main and then step into optimized function foo.
+ Dart_Handle c_name = Dart_NewString("");
+ Dart_Handle f_name = Dart_NewString("main");
+ Dart_Breakpoint bpt;
+ res = Dart_SetBreakpointAtEntry(lib, c_name, f_name, &bpt);
+ EXPECT_NOT_ERROR(res);
+
+ breakpoint_hit = false;
+ breakpoint_hit_counter = 0;
+ Dart_Handle retval = Invoke(lib, "main");
+ EXPECT(!Dart_IsError(retval));
+ EXPECT(Dart_IsInteger(retval));
+ int64_t int_value = 0;
+ Dart_IntegerToInt64(retval, &int_value);
+ EXPECT_EQ(2 * 99, int_value);
+ EXPECT(breakpoint_hit == true);
+}
+
+
void TestSingleStepHandler(Dart_Breakpoint bpt, Dart_StackTrace trace) {
const char* expected_bpts[] = {
"moo", "foo", "moo", "foo", "moo", "foo", "main"};
« no previous file with comments | « runtime/vm/debugger.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698