diff --git a/src/llnode.cc b/src/llnode.cc index 15c2e512..3d400e3b 100644 --- a/src/llnode.cc +++ b/src/llnode.cc @@ -69,12 +69,7 @@ bool BacktraceCmd::DoExecute(SBDebugger d, char** cmd, const char star = (frame == selected_frame ? '*' : ' '); const uint64_t pc = frame.GetPC(); - // TODO(mmarchini): There might be a better way to check for V8 builtins - // embedded in the binary. - auto c_function_name = frame.GetFunctionName(); - std::string function_name(c_function_name != nullptr ? c_function_name - : ""); - if (!frame.GetSymbol().IsValid() || function_name.find("Builtins_") == 0) { + if (v8::JSFrame::MightBeV8Frame(frame)) { Error err; v8::JSFrame v8_frame(llv8_, static_cast(frame.GetFP())); Printer printer(llv8_); @@ -263,7 +258,6 @@ bool ListCmd::DoExecute(SBDebugger d, char** cmd, // Load V8 constants from postmortem data llv8_->Load(target); SBFrame frame = thread.GetSelectedFrame(); - SBSymbol symbol = frame.GetSymbol(); bool reset_line = false; if (line_switch) { @@ -274,8 +268,7 @@ bool ListCmd::DoExecute(SBDebugger d, char** cmd, reset_line = true; } last_frame = frame; - // C++ symbol - if (symbol.IsValid()) { + if (!v8::JSFrame::MightBeV8Frame(frame)) { SBCommandInterpreter interpreter = d.GetCommandInterpreter(); std::string cmd = "source list "; cmd += full_cmd; diff --git a/src/llv8.cc b/src/llv8.cc index 4747d56a..155479cd 100644 --- a/src/llv8.cc +++ b/src/llv8.cc @@ -293,6 +293,16 @@ Smi JSFrame::FromFrameMarker(Value value) const { return Smi(value); } + +bool JSFrame::MightBeV8Frame(lldb::SBFrame& frame) { + // TODO(mmarchini): There might be a better way to check for V8 builtins + // embedded in the binary. + auto c_function_name = frame.GetFunctionName(); + std::string function_name(c_function_name != nullptr ? c_function_name : ""); + + return !frame.GetSymbol().IsValid() || function_name.find("Builtins_") == 0; +} + std::string JSFunction::GetDebugLine(std::string args, Error& err) { SharedFunctionInfo info = Info(err); if (err.Fail()) return std::string(); diff --git a/src/llv8.h b/src/llv8.h index 27a30ecb..afac08e4 100644 --- a/src/llv8.h +++ b/src/llv8.h @@ -590,6 +590,8 @@ class JSFrame : public Value { uint32_t line_limit, std::string lines[], uint32_t& lines_found, Error& err); + static bool MightBeV8Frame(lldb::SBFrame& frame); + private: Smi FromFrameMarker(Value value) const; friend class llnode::Printer;