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

Unified Diff: runtime/vm/debugger_api_impl_test.cc

Issue 9716004: Properly recognize closures when 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') | runtime/vm/object.h » ('j') | 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 5596)
+++ runtime/vm/debugger_api_impl_test.cc (working copy)
@@ -154,6 +154,33 @@
}
+static void VerifyStackTrace(Dart_StackTrace trace,
+ const char* func_names[],
+ int names_len) {
+ intptr_t trace_len;
+ Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
+ Dart_Handle func_name;
+ EXPECT_NOT_ERROR(res);
+ for (int i = 0; i < trace_len; i++) {
+ Dart_ActivationFrame frame;
+ res = Dart_GetActivationFrame(trace, i, &frame);
+ EXPECT_NOT_ERROR(res);
+ res = Dart_ActivationFrameInfo(frame, &func_name, NULL, NULL);
+ EXPECT_NOT_ERROR(res);
+ EXPECT(Dart_IsString(func_name));
+ const char* func_name_chars;
+ Dart_StringToCString(func_name, &func_name_chars);
+ if (i < names_len) {
+ EXPECT_STREQ(func_name_chars, func_names[i]);
+ if (strcmp(func_name_chars, func_names[i]) != 0) {
+ OS::Print("Stack frame %d: expected function %s, but found %s\n",
+ i, func_names[i], func_name_chars);
+ }
+ }
+ }
+}
+
+
void TestBreakpointHandler(Dart_Breakpoint bpt, Dart_StackTrace trace) {
const char* expected_trace[] = {"A.foo", "main"};
const intptr_t expected_trace_length = 2;
@@ -583,6 +610,47 @@
}
+static void ExprClosureBreakpointHandler(Dart_Breakpoint bpt,
+ Dart_StackTrace trace) {
+ static const char* expected_trace[] = {"add", "main", ""};
+ breakpoint_hit_counter++;
+ PrintStackTrace(trace);
+ VerifyStackTrace(trace, expected_trace, 2);
+}
+
+
+TEST_CASE(Debug_ExprClosureBreakpoint) {
+ const char* kScriptChars =
+ "var c; \n"
+ " \n"
+ "main() { \n"
+ " c = add(a, b) { \n"
+ " return a + b; \n"
+ " }; \n"
+ " return c(10, 20); \n"
+ "} \n";
+
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+ EXPECT(!Dart_IsError(lib));
+
+ Dart_SetBreakpointHandler(&ExprClosureBreakpointHandler);
+
+ Dart_Handle script_url = Dart_NewString(TestCase::url());
+ Dart_Handle line_no = Dart_NewInteger(5); // In closure 'add'.
+ Dart_Breakpoint bpt;
+ Dart_Handle res = Dart_SetBreakpointAtLine(script_url, line_no, &bpt);
+ EXPECT_NOT_ERROR(res);
+
+ breakpoint_hit_counter = 0;
+ Dart_Handle retval = Invoke(lib, "main");
+ EXPECT_NOT_ERROR(retval);
+ int64_t int_value = 0;
+ Dart_IntegerToInt64(retval, &int_value);
+ EXPECT_EQ(30, int_value);
+ EXPECT_EQ(1, breakpoint_hit_counter);
+}
+
+
static void DeleteBreakpointHandler(Dart_Breakpoint bpt,
Dart_StackTrace trace) {
const char* expected_trace[] = {"foo", "main"};
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698