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

Unified Diff: test/cctest/test-debug.cc

Issue 67109: Fix the source position recorded for funtion return (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/codegen.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-debug.cc
===================================================================
--- test/cctest/test-debug.cc (revision 1693)
+++ test/cctest/test-debug.cc (working copy)
@@ -498,7 +498,7 @@
// ---
-// Source for The JavaScript function which picks out the function name on the
+// Source for The JavaScript function which picks out the function name of the
// top frame.
const char* frame_function_name_source =
"function frame_function_name(exec_state) {"
@@ -507,6 +507,24 @@
v8::Local<v8::Function> frame_function_name;
+// Source for The JavaScript function which picks out the source line for the
+// top frame.
+const char* frame_source_line_source =
+ "function frame_source_line(exec_state) {"
+ " return exec_state.frame(0).sourceLine();"
+ "}";
+v8::Local<v8::Function> frame_source_line;
+
+
+// Source for The JavaScript function which picks out the source column for the
+// top frame.
+const char* frame_source_column_source =
+ "function frame_source_column(exec_state) {"
+ " return exec_state.frame(0).sourceColumn();"
+ "}";
+v8::Local<v8::Function> frame_source_column;
+
+
// Source for The JavaScript function which returns the number of frames.
static const char* frame_count_source =
"function frame_count(exec_state) {"
@@ -518,6 +536,10 @@
// Global variable to store the last function hit - used by some tests.
char last_function_hit[80];
+// Global variables to store the last source position - used by some tests.
+int last_source_line = -1;
+int last_source_column = -1;
+
// Debug event handler which counts the break points which have been hit.
int break_point_hit_count = 0;
static void DebugEventBreakPointHitCount(v8::DebugEvent event,
@@ -544,6 +566,26 @@
function_name->WriteAscii(last_function_hit);
}
}
+
+ if (!frame_source_line.IsEmpty()) {
+ // Get the source line.
+ const int argc = 1;
+ v8::Handle<v8::Value> argv[argc] = { exec_state };
+ v8::Handle<v8::Value> result = frame_source_line->Call(exec_state,
+ argc, argv);
+ CHECK(result->IsNumber());
+ last_source_line = result->Int32Value();
+ }
+
+ if (!frame_source_column.IsEmpty()) {
+ // Get the source column.
+ const int argc = 1;
+ v8::Handle<v8::Value> argv[argc] = { exec_state };
+ v8::Handle<v8::Value> result = frame_source_column->Call(exec_state,
+ argc, argv);
+ CHECK(result->IsNumber());
+ last_source_column = result->Int32Value();
+ }
}
}
@@ -994,6 +1036,17 @@
break_point_hit_count = 0;
v8::HandleScope scope;
DebugLocalContext env;
+
+ // Create a functions for checking the source line and column when hitting
+ // a break point.
+ frame_source_line = CompileFunction(&env,
+ frame_source_line_source,
+ "frame_source_line");
+ frame_source_column = CompileFunction(&env,
+ frame_source_column_source,
+ "frame_source_column");
+
+
v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
v8::Undefined());
v8::Script::Compile(v8::String::New("function foo(){}"))->Run();
@@ -1008,8 +1061,12 @@
int bp = SetBreakPoint(foo, 0);
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
+ CHECK_EQ(0, last_source_line);
+ CHECK_EQ(16, last_source_column);
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count);
+ CHECK_EQ(0, last_source_line);
+ CHECK_EQ(16, last_source_column);
// Run without breakpoints.
ClearBreakPoint(bp);
@@ -3663,15 +3720,6 @@
}
-// Source for a JavaScript function which returns the source line for the top
-// frame.
-static const char* frame_source_line_source =
- "function frame_source_line(exec_state) {"
- " return exec_state.frame(0).sourceLine();"
- "}";
-v8::Handle<v8::Function> frame_source_line;
-
-
// Source for a JavaScript function which returns the data parameter of a
// function called in the context of the debugger. If no data parameter is
// passed it throws an exception.
« no previous file with comments | « src/codegen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698