Chromium Code Reviews| Index: src/frames.cc |
| diff --git a/src/frames.cc b/src/frames.cc |
| index 412a59cc7d61aba1a7011fc7955fd34650dd6182..f97e5bef40bec9a6e2d101b22fd66390afcc262f 100644 |
| --- a/src/frames.cc |
| +++ b/src/frames.cc |
| @@ -711,6 +711,56 @@ void JavaScriptFrame::Summarize(List<FrameSummary>* functions) { |
| } |
| +void JavaScriptFrame::PrintTop(bool print_args, bool print_line_number) { |
| + // constructor calls |
| + HandleScope scope; |
| + AssertNoAllocation no_allocation; |
| + JavaScriptFrameIterator it; |
| + while (!it.done()) { |
| + if (it.frame()->is_java_script()) { |
| + JavaScriptFrame* frame = it.frame(); |
| + if (frame->IsConstructor()) PrintF("new "); |
| + // function name |
| + Object* fun = frame->function(); |
| + if (fun->IsJSFunction()) { |
| + JSFunction::cast(fun)->shared()->name()->MiniPrint(); |
| + } else { |
| + fun->MiniPrint(); |
| + } |
| + if (print_line_number) { |
| + PrintF(" "); |
|
Jakob Kummerow
2011/10/19 16:02:28
Insert this printed space into the PrintF() below.
|
| + Address pc = frame->pc(); |
| + Code* code = Code::cast( |
| + v8::internal::Isolate::Current()->heap()->FindCodeObject(pc)); |
| + int source_pos = code->SourcePosition(pc); |
| + SharedFunctionInfo* shared = JSFunction::cast(fun)->shared(); |
| + Handle<Script> script(Script::cast(shared->script())); |
| + int line = GetScriptLineNumberSafe(script, source_pos) + 1; |
| + String* script_name = String::cast(script->name()); |
| + SmartArrayPointer<char> c_script_name = |
| + script_name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| + PrintF("%s:%d", *c_script_name, line); |
| + } |
| + if (print_args) { |
| + // function arguments |
| + // (we are intentionally only printing the actually |
| + // supplied parameters, not all parameters required) |
| + PrintF("(this="); |
| + frame->receiver()->MiniPrint(); |
| + const int length = frame->ComputeParametersCount(); |
| + for (int i = 0; i < length; i++) { |
| + PrintF(", "); |
| + frame->GetParameter(i)->MiniPrint(); |
| + } |
| + PrintF(")"); |
| + } |
| + break; |
| + } |
| + it.Advance(); |
| + } |
| +} |
| + |
| + |
| void FrameSummary::Print() { |
| PrintF("receiver: "); |
| receiver_->ShortPrint(); |