bool SBModule::SetPlatformFileSpec (const lldb::SBFileSpec &platform_file) { bool result = false; LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); ModuleSP module_sp (GetSP ()); if (module_sp) { module_sp->SetPlatformFileSpec(*platform_file); result = true; } if (log) { log->Printf ("SBModule(%p)::SetPlatformFileSpec (SBFileSpec(%p (%s%s%s)) => %i", module_sp.get(), platform_file.get(), platform_file->GetDirectory().GetCString(), platform_file->GetDirectory() ? "/" : "", platform_file->GetFilename().GetCString(), result); } return result; }
void SBLineEntry::SetFileSpec (lldb::SBFileSpec filespec) { if (filespec.IsValid()) ref().file = filespec.ref(); else ref().file.Clear(); }
void SBLineEntry::SetFileSpec(lldb::SBFileSpec filespec) { LLDB_RECORD_METHOD(void, SBLineEntry, SetFileSpec, (lldb::SBFileSpec), filespec); if (filespec.IsValid()) ref().file = filespec.ref(); else ref().file.Clear(); }
bool SBModule::SetRemoteInstallFileSpec(lldb::SBFileSpec &file) { ModuleSP module_sp(GetSP()); if (module_sp) { module_sp->SetRemoteInstallFileSpec(file.ref()); return true; } return false; }
bool SBModule::SetPlatformFileSpec(const lldb::SBFileSpec &platform_file) { bool result = false; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); ModuleSP module_sp(GetSP()); if (module_sp) { module_sp->SetPlatformFileSpec(*platform_file); result = true; } if (log) log->Printf("SBModule(%p)::SetPlatformFileSpec (SBFileSpec(%p (%s)) => %i", static_cast<void *>(module_sp.get()), static_cast<const void *>(platform_file.get()), platform_file->GetPath().c_str(), result); return result; }
void SBCommandInterpreter::HandleCommandsFromFile (lldb::SBFileSpec &file, lldb::SBExecutionContext &override_context, lldb::SBCommandInterpreterRunOptions &options, lldb::SBCommandReturnObject result) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { SBStream s; file.GetDescription (s); log->Printf ("SBCommandInterpreter(%p)::HandleCommandsFromFile (file=\"%s\", SBCommandReturnObject(%p))", static_cast<void*>(m_opaque_ptr), s.GetData(), static_cast<void*>(result.get())); } if (!IsValid()) { result->AppendError ("SBCommandInterpreter is not valid."); result->SetStatus (eReturnStatusFailed); return; } if (!file.IsValid()) { SBStream s; file.GetDescription (s); result->AppendErrorWithFormat ("File is not valid: %s.", s.GetData()); result->SetStatus (eReturnStatusFailed); } FileSpec tmp_spec = file.ref(); ExecutionContext ctx, *ctx_ptr; if (override_context.get()) { ctx = override_context.get()->Lock(true); ctx_ptr = &ctx; } else ctx_ptr = nullptr; m_opaque_ptr->HandleCommandsFromFile (tmp_spec, ctx_ptr, options.ref(), result.ref()); }
SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); SBError sb_error; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf("SBThread(%p)::JumpToLine (file+line = %s:%u)", static_cast<void *>(exe_ctx.GetThreadPtr()), file_spec->GetPath().c_str(), line); if (!exe_ctx.HasThreadScope()) { sb_error.SetErrorString("this SBThread object is invalid"); return sb_error; } Thread *thread = exe_ctx.GetThreadPtr(); Status err = thread->JumpToLine(file_spec.get(), line, true); sb_error.SetError(err); return sb_error; }
//++ //------------------------------------------------------------------------------------ // Details: The invoker requires this function. The command does work in this // function. // The command is likely to communicate with the LLDB SBDebugger in // here. // Synopsis: -symbol-list-lines file // Ref: // http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Symbol-Query.html#GDB_002fMI-Symbol-Query // Type: Overridden. // Args: None. // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. // Throws: None. //-- bool CMICmdCmdSymbolListLines::Execute() { CMICMDBASE_GETOPTION(pArgFile, File, m_constStrArgNameFile); const auto &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); if (rSessionInfo.GetTarget() == rSessionInfo.GetDebugger().GetDummyTarget()) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), m_cmdData.strMiCmd.c_str())); return MIstatus::failure; } const lldb::SBFileSpec source_file_spec(pArgFile->GetValue().c_str(), true); const char *source_file_name = source_file_spec.GetFilename(); const char *source_file_directory = source_file_spec.GetDirectory(); const bool has_path = source_file_directory; lldb::SBSymbolContextList sc_cu_list = CMICmnLLDBDebugSessionInfo::Instance().GetTarget().FindCompileUnits( source_file_spec); bool found_something = false; for (uint32_t i = 0, e = sc_cu_list.GetSize(); i < e; ++i) { const lldb::SBCompileUnit cu = sc_cu_list.GetContextAtIndex(i).GetCompileUnit(); for (uint32_t j = 0, e = cu.GetNumLineEntries(); j < e; ++j) { const lldb::SBLineEntry line = cu.GetLineEntryAtIndex(j); const lldb::SBFileSpec line_spec = line.GetFileSpec(); if (line_spec.GetFilename() == source_file_name) { if (has_path && (line_spec.GetDirectory() != source_file_directory)) continue; // We don't need a line with start address equals to end one, // so just skip it. const lldb::SBAddress line_start_address = line.GetStartAddress(); const lldb::SBAddress line_end_address = line.GetEndAddress(); if (line_start_address == line_end_address) continue; // We have a matching line. found_something = true; m_resultList.Add(CreateMITuplePCLine( line_start_address.GetFileAddress(), line.GetLine())); } } } if (!found_something) { SetError(MIRSRC(IDS_UTIL_FILE_ERR_INVALID_PATHNAME)); return MIstatus::failure; } return MIstatus::success; }
SBError SBThread::JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBError sb_error; Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); if (log) log->Printf ("SBThread(%p)::JumpToLine (file+line = %s:%u)", exe_ctx.GetThreadPtr(), file_spec->GetPath().c_str(), line); if (!exe_ctx.HasThreadScope()) { sb_error.SetErrorString("this SBThread object is invalid"); return sb_error; } Thread *thread = exe_ctx.GetThreadPtr(); Error err = thread->JumpToLine (file_spec.get(), line, true); sb_error.SetError (err); return sb_error; }
SBError SBThread::StepOverUntil (lldb::SBFrame &sb_frame, lldb::SBFileSpec &sb_file_spec, uint32_t line) { SBError sb_error; Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); char path[PATH_MAX]; Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); StackFrameSP frame_sp (sb_frame.GetFrameSP()); if (log) { SBStream frame_desc_strm; sb_frame.GetDescription (frame_desc_strm); sb_file_spec->GetPath (path, sizeof(path)); log->Printf ("SBThread(%p)::StepOverUntil (frame = SBFrame(%p): %s, file+line = %s:%u)", exe_ctx.GetThreadPtr(), frame_sp.get(), frame_desc_strm.GetData(), path, line); } if (exe_ctx.HasThreadScope()) { Target *target = exe_ctx.GetTargetPtr(); Thread *thread = exe_ctx.GetThreadPtr(); if (line == 0) { sb_error.SetErrorString("invalid line argument"); return sb_error; } if (!frame_sp) { frame_sp = thread->GetSelectedFrame (); if (!frame_sp) frame_sp = thread->GetStackFrameAtIndex (0); } SymbolContext frame_sc; if (!frame_sp) { sb_error.SetErrorString("no valid frames in thread to step"); return sb_error; } // If we have a frame, get its line frame_sc = frame_sp->GetSymbolContext (eSymbolContextCompUnit | eSymbolContextFunction | eSymbolContextLineEntry | eSymbolContextSymbol ); if (frame_sc.comp_unit == NULL) { sb_error.SetErrorStringWithFormat("frame %u doesn't have debug information", frame_sp->GetFrameIndex()); return sb_error; } FileSpec step_file_spec; if (sb_file_spec.IsValid()) { // The file spec passed in was valid, so use it step_file_spec = sb_file_spec.ref(); } else { if (frame_sc.line_entry.IsValid()) step_file_spec = frame_sc.line_entry.file; else { sb_error.SetErrorString("invalid file argument or no file for frame"); return sb_error; } } // Grab the current function, then we will make sure the "until" address is // within the function. We discard addresses that are out of the current // function, and then if there are no addresses remaining, give an appropriate // error message. bool all_in_function = true; AddressRange fun_range = frame_sc.function->GetAddressRange(); std::vector<addr_t> step_over_until_addrs; const bool abort_other_plans = false; const bool stop_other_threads = false; const bool check_inlines = true; const bool exact = false; SymbolContextList sc_list; const uint32_t num_matches = frame_sc.comp_unit->ResolveSymbolContext (step_file_spec, line, check_inlines, exact, eSymbolContextLineEntry, sc_list); if (num_matches > 0) { SymbolContext sc; for (uint32_t i=0; i<num_matches; ++i) { if (sc_list.GetContextAtIndex(i, sc)) { addr_t step_addr = sc.line_entry.range.GetBaseAddress().GetLoadAddress(target); if (step_addr != LLDB_INVALID_ADDRESS) { if (fun_range.ContainsLoadAddress(step_addr, target)) step_over_until_addrs.push_back(step_addr); else all_in_function = false; } } } } if (step_over_until_addrs.empty()) { if (all_in_function) { step_file_spec.GetPath (path, sizeof(path)); sb_error.SetErrorStringWithFormat("No line entries for %s:%u", path, line); } else sb_error.SetErrorString ("step until target not in current function"); } else { ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil (abort_other_plans, &step_over_until_addrs[0], step_over_until_addrs.size(), stop_other_threads, frame_sp->GetFrameIndex())); sb_error = ResumeNewPlan (exe_ctx, new_plan_sp.get()); } } else { sb_error.SetErrorString("this SBThread object is invalid"); } return sb_error; }