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

Unified Diff: src/frames.cc

Issue 1002010: Show file name/line number in stack trace (Closed)
Patch Set: merge Created 10 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 | « no previous file | src/handles.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/frames.cc
diff --git a/src/frames.cc b/src/frames.cc
index 3bf4c93e39893bba2031a58dd984e9ba450603c1..227fa67d54b2ba854a2682c890a8ae6bc4efe9a5 100644
--- a/src/frames.cc
+++ b/src/frames.cc
@@ -520,6 +520,31 @@ void JavaScriptFrame::Print(StringStream* accumulator,
Code* code = NULL;
if (IsConstructor()) accumulator->Add("new ");
accumulator->PrintFunction(function, receiver, &code);
+
+ if (function->IsJSFunction()) {
+ Handle<SharedFunctionInfo> shared(JSFunction::cast(function)->shared());
+ Object* script_obj = shared->script();
+ if (script_obj->IsScript()) {
+ Handle<Script> script(Script::cast(script_obj));
+ accumulator->Add(" [");
+ accumulator->PrintName(script->name());
+
+ Address pc = this->pc();
+ if (code != NULL && code->kind() == Code::FUNCTION &&
+ pc >= code->instruction_start() && pc < code->relocation_start()) {
+ int source_pos = code->SourcePosition(pc);
+ int line = GetScriptLineNumberSafe(script, source_pos) + 1;
+ accumulator->Add(":%d", line);
+ } else {
+ int function_start_pos = shared->start_position();
+ int line = GetScriptLineNumberSafe(script, function_start_pos) + 1;
+ accumulator->Add(":~%d", line);
+ }
+
+ accumulator->Add("] ");
+ }
+ }
+
accumulator->Add("(this=%o", receiver);
// Get scope information for nicer output, if possible. If code is
« no previous file with comments | « no previous file | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698