bool DoExecute(Args &command, CommandReturnObject &result) override { StringList commands; commands.AppendString("thread backtrace"); Thread *thread = m_exe_ctx.GetThreadPtr(); if (thread) { char command_buffer[256]; uint32_t frame_count = thread->GetStackFrameCount(); for (uint32_t i = 0; i < frame_count; ++i) { StackFrameSP frame = thread->GetStackFrameAtIndex(i); lldb::addr_t pc = frame->GetStackID().GetPC(); snprintf(command_buffer, sizeof(command_buffer), "disassemble --bytes --address 0x%" PRIx64, pc); commands.AppendString(command_buffer); snprintf(command_buffer, sizeof(command_buffer), "image show-unwind --address 0x%" PRIx64, pc); commands.AppendString(command_buffer); } } const FileSpec &outfile_spec = m_outfile_options.GetFile().GetCurrentValue(); if (outfile_spec) { char path[PATH_MAX]; outfile_spec.GetPath(path, sizeof(path)); uint32_t open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate | File::eOpenOptionAppend | File::eOpenOptionCloseOnExec; const bool append = m_outfile_options.GetAppend().GetCurrentValue(); if (!append) open_options |= File::eOpenOptionTruncate; StreamFileSP outfile_stream = std::make_shared<StreamFile>(); Status error = outfile_stream->GetFile().Open(path, open_options); if (error.Fail()) { result.AppendErrorWithFormat("Failed to open file '%s' for %s: %s\n", path, append ? "append" : "write", error.AsCString()); result.SetStatus(eReturnStatusFailed); return false; } result.SetImmediateOutputStream(outfile_stream); } CommandInterpreterRunOptions options; options.SetStopOnError(false); options.SetEchoCommands(true); options.SetPrintResults(true); options.SetAddToHistory(false); m_interpreter.HandleCommands(commands, &m_exe_ctx, options, result); return result.Succeeded(); }
SBFrame::SBFrame (const StackFrameSP &lldb_object_sp) : m_opaque_sp (new ExecutionContextRef (lldb_object_sp)) { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { SBStream sstr; GetDescription (sstr); log->Printf ("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s", lldb_object_sp.get(), lldb_object_sp.get(), sstr.GetData()); } }
void SBFrame::SetFrame (const StackFrameSP &lldb_object_sp) { void *old_ptr = m_opaque_sp.get(); m_opaque_sp = lldb_object_sp; LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { log->Printf ("SBFrame(%p)::SetFrame(sp=%p) := SBFrame(%p)", old_ptr, lldb_object_sp.get(), m_opaque_sp.get()); } }
static bool CompareStackID(const StackFrameSP &stack_sp, const StackID &stack_id) { return stack_sp->GetStackID() < stack_id; }