bool SBThread::DisplaySingleFrameForCurrentContext (FILE *out, FILE *err, SBFrame &frame, bool show_frame_info, bool show_source, uint32_t source_lines_after, uint32_t source_lines_before) { bool success = false; if ((out == NULL) || (err == NULL)) return false; if (m_opaque_sp && frame.IsValid()) { StreamFile str (out); SBSymbolContext sc(frame.GetSymbolContext(eSymbolContextEverything)); if (show_frame_info && sc.IsValid()) { user_id_t frame_idx = (user_id_t) frame.GetFrameID(); lldb::addr_t pc = frame.GetPC(); ::fprintf (out, " frame #%u: tid = 0x%4.4x, pc = 0x%llx ", frame_idx, GetThreadID(), (long long)pc); sc->DumpStopContext (&str, &m_opaque_sp->GetProcess(), *frame.GetPCAddress()); fprintf (out, "\n"); success = true; } SBCompileUnit comp_unit(sc.GetCompileUnit()); if (show_source && comp_unit.IsValid()) { success = false; SBLineEntry line_entry; if (line_entry.IsValid()) { SourceManager& source_manager = m_opaque_sp->GetProcess().GetTarget().GetDebugger().GetSourceManager(); SBFileSpec line_entry_file_spec (line_entry.GetFileSpec()); if (line_entry_file_spec.IsValid()) { source_manager.DisplaySourceLinesWithLineNumbers (line_entry_file_spec.ref(), line_entry.GetLine(), source_lines_after, source_lines_before, "->", &str); success = true; } } } } return success; }
char * formatThreadInfo (StringB &threaddescB, SBProcess process, int threadindexid) { logprintf (LOG_TRACE, "formatThreadInfo (0x%x, 0x%x, %d)\n", &threaddescB, &process, threadindexid); threaddescB.clear(); if (!process.IsValid()) return threaddescB.c_str(); int pid=process.GetProcessID(); int state = process.GetState (); if (state == eStateStopped) { int tmin, tmax; bool useindexid; if (threadindexid < 0) { tmin = 0; tmax = process.GetNumThreads(); useindexid = false; } else{ tmin = threadindexid; tmax = threadindexid+1; useindexid = false; } const char *separator=""; for (int ithread=tmin; ithread<tmax; ithread++) { SBThread thread; if (useindexid) thread = process.GetThreadByIndexID(ithread); else thread = process.GetThreadAtIndex(ithread); if (!thread.IsValid()) continue; int tid=thread.GetThreadID(); threadindexid=thread.GetIndexID(); int frames = getNumFrames (thread); if (frames > 0) { SBFrame frame = thread.GetFrameAtIndex(0); if (frame.IsValid()) { char * framedescstr = formatFrame (frame, WITH_LEVEL_AND_ARGS); threaddescB.catsprintf ( "%s{id=\"%d\",target-id=\"Thread 0x%x of process %d\",%s,state=\"stopped\"}", separator, threadindexid, tid, pid, framedescstr); } } separator=","; } } return threaddescB.c_str(); }
bool SBFrame::IsEqual (const SBFrame &that) const { lldb::StackFrameSP this_sp = GetFrameSP(); lldb::StackFrameSP that_sp = that.GetFrameSP(); return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID()); }
void Xcode::FetchVariables (SBFrame frame, uint32_t expand, bool verbose) { auto values = frame.GetVariables (true,true,true,false, eDynamicCanRunTarget); auto count = values.GetSize(); for (int i = 0; i < count; i++) { SBValue value(values.GetValueAtIndex(i)); FetchVariable (value,expand,verbose); } }
lldb::SBFrame SBValue::GetFrame() { SBFrame result; if (m_opaque_sp) { if (m_opaque_sp->GetExecutionContextScope()) { result.SetFrame (m_opaque_sp->GetExecutionContextScope()->CalculateStackFrame()->GetSP()); } } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { if (result.get() == NULL) log->Printf ("SBValue(%p)::GetFrame () => NULL", m_opaque_sp.get()); else log->Printf ("SBValue(%p)::GetFrame () => %p", m_opaque_sp.get(), result.get()); } return result; }
SBError SBThread::ReturnFromFrame(SBFrame &frame, SBValue &return_value) { SBError sb_error; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf("SBThread(%p)::ReturnFromFrame (frame=%d)", static_cast<void *>(exe_ctx.GetThreadPtr()), frame.GetFrameID()); if (exe_ctx.HasThreadScope()) { Thread *thread = exe_ctx.GetThreadPtr(); sb_error.SetError( thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP())); } return sb_error; }
void Xcode::RunExpression (SBFrame frame, const char* expression, bool po, bool verbose) { SBValue value (frame.EvaluateExpression (expression, eDynamicCanRunTarget)); FetchVariable (value,0,verbose); if (po) { auto descr = value.GetObjectDescription(); if (descr) printf("po = %s\n",descr); } }
SBError SBThread::ReturnFromFrame (SBFrame &frame, SBValue &return_value) { SBError sb_error; Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); if (log) log->Printf ("SBThread(%p)::ReturnFromFrame (frame=%d)", exe_ctx.GetThreadPtr(), frame.GetFrameID()); if (exe_ctx.HasThreadScope()) { Thread *thread = exe_ctx.GetThreadPtr(); sb_error.SetError (thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP())); } return sb_error; }