Commit fa8bac65 authored by yangguo's avatar yangguo Committed by Commit bot

[interpreter] Fix stack trace printers for debugging.

This is pretty useful when debugging. There is no easy way to find the
bytecode arrays on the stack.

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/1909663005

Cr-Commit-Position: refs/heads/master@{#35712}
parent 81c965d4
......@@ -1398,14 +1398,20 @@ void JavaScriptFrame::Print(StringStream* accumulator,
int offset = static_cast<int>(pc - code->instruction_start());
int source_pos = code->SourcePosition(offset);
int line = script->GetLineNumber(source_pos) + 1;
accumulator->Add(":%d", line);
accumulator->Add(":%d] [pc=%p]", line, pc);
} else if (is_interpreted()) {
const InterpretedFrame* iframe =
reinterpret_cast<const InterpretedFrame*>(this);
BytecodeArray* bytecodes = iframe->GetBytecodeArray();
int offset = iframe->GetBytecodeOffset();
int source_pos = bytecodes->SourcePosition(offset);
int line = script->GetLineNumber(source_pos) + 1;
accumulator->Add(":%d] [bytecode=%p offset=%d]", line, bytecodes, offset);
} else {
int function_start_pos = shared->start_position();
int line = script->GetLineNumber(function_start_pos) + 1;
accumulator->Add(":~%d", line);
accumulator->Add(":~%d] [pc=%p]", line, pc);
}
accumulator->Add("] [pc=%p] ", pc);
}
accumulator->Add("(this=%o", receiver);
......
......@@ -1327,9 +1327,16 @@ void Isolate::PrintCurrentStackTrace(FILE* out) {
HandleScope scope(this);
// Find code position if recorded in relocation info.
StandardFrame* frame = it.frame();
Code* code = frame->LookupCode();
int offset = static_cast<int>(frame->pc() - code->instruction_start());
int pos = frame->LookupCode()->SourcePosition(offset);
int pos;
if (frame->is_interpreted()) {
InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame);
pos = iframe->GetBytecodeArray()->SourcePosition(
iframe->GetBytecodeOffset());
} else {
Code* code = frame->LookupCode();
int offset = static_cast<int>(frame->pc() - code->instruction_start());
pos = frame->LookupCode()->SourcePosition(offset);
}
Handle<Object> pos_obj(Smi::FromInt(pos), this);
// Fetch function and receiver.
Handle<JSFunction> fun(frame->function());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment