// Ask LLDB to create a breakpoint
bool bOk = MIstatus::success;
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBTarget &rTarget = rSessionInfo.m_lldbTarget;
+ lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
switch (eBrkPtType)
{
case eBreakPoint_ByAddress:
- m_brkPt = rTarget.BreakpointCreateByAddress(nAddress);
+ m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress);
break;
case eBreakPoint_ByFileFn:
- m_brkPt = rTarget.BreakpointCreateByName(strFileFn.c_str(), fileName.c_str());
+ m_brkPt = sbTarget.BreakpointCreateByName(strFileFn.c_str(), fileName.c_str());
break;
case eBreakPoint_ByFileLine:
- m_brkPt = rTarget.BreakpointCreateByLocation(fileName.c_str(), nFileLine);
+ m_brkPt = sbTarget.BreakpointCreateByLocation(fileName.c_str(), nFileLine);
break;
case eBreakPoint_ByName:
- m_brkPt = rTarget.BreakpointCreateByName(m_brkName.c_str(), rTarget.GetExecutable().GetFilename());
+ m_brkPt = sbTarget.BreakpointCreateByName(m_brkName.c_str(), sbTarget.GetExecutable().GetFilename());
break;
case eBreakPoint_count:
case eBreakPoint_NotDefineYet:
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- const bool bBrkPt = rSessionInfo.m_lldbTarget.BreakpointDelete(static_cast<lldb::break_id_t>(nBrk));
+ const bool bBrkPt = rSessionInfo.GetTarget().BreakpointDelete(static_cast<lldb::break_id_t>(nBrk));
if (!bBrkPt)
{
const CMIUtilString strBrkNum(CMIUtilString::Format("%d", nBrk));
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID(static_cast<lldb::break_id_t>(nBrk));
+ lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(static_cast<lldb::break_id_t>(nBrk));
if (brkPt.IsValid())
{
m_bBrkPtDisabledOk = true;
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID(static_cast<lldb::break_id_t>(nBrk));
+ lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(static_cast<lldb::break_id_t>(nBrk));
if (brkPt.IsValid())
{
m_bBrkPtEnabledOk = true;
m_nBrkPtCount = pArgCount->GetValue();
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID(static_cast<lldb::break_id_t>(m_nBrkPtId));
+ lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(static_cast<lldb::break_id_t>(m_nBrkPtId));
if (brkPt.IsValid())
{
brkPt.SetIgnoreCount(m_nBrkPtCount);
m_strBrkPtExpr += GetRestOfExpressionNotSurroundedInQuotes();
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBBreakpoint brkPt = rSessionInfo.m_lldbTarget.FindBreakpointByID(static_cast<lldb::break_id_t>(m_nBrkPtId));
+ lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(static_cast<lldb::break_id_t>(m_nBrkPtId));
if (brkPt.IsValid())
{
brkPt.SetCondition(m_strBrkPtExpr.c_str());
const CMIUtilString &rExpression(pArgExpr->GetValue());
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBThread thread = rProcess.GetSelectedThread();
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
m_bExpressionValid = (thread.GetNumFrames() > 0);
if (!m_bExpressionValid)
return MIstatus::success;
const MIuint nDisasmMode = pArgMode->GetValue();
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBTarget &rTarget = rSessionInfo.m_lldbTarget;
+ lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
lldb::addr_t lldbStartAddr = static_cast<lldb::addr_t>(nAddrStart);
- lldb::SBInstructionList instructions = rTarget.ReadInstructions(lldb::SBAddress(lldbStartAddr, rTarget), nAddrEnd - nAddrStart);
+ lldb::SBInstructionList instructions = sbTarget.ReadInstructions(lldb::SBAddress(lldbStartAddr, sbTarget), nAddrEnd - nAddrStart);
const MIuint nInstructions = instructions.GetSize();
for (size_t i = 0; i < nInstructions; i++)
{
const MIchar *pUnknown = "??";
lldb::SBInstruction instrt = instructions.GetInstructionAtIndex(i);
- const MIchar *pStrMnemonic = instrt.GetMnemonic(rTarget);
+ const MIchar *pStrMnemonic = instrt.GetMnemonic(sbTarget);
pStrMnemonic = (pStrMnemonic != nullptr) ? pStrMnemonic : pUnknown;
lldb::SBAddress address = instrt.GetAddress();
- lldb::addr_t addr = address.GetLoadAddress(rTarget);
+ lldb::addr_t addr = address.GetLoadAddress(sbTarget);
const MIchar *pFnName = address.GetFunction().GetName();
pFnName = (pFnName != nullptr) ? pFnName : pUnknown;
lldb::addr_t addrOffSet = address.GetOffset();
- const MIchar *pStrOperands = instrt.GetOperands(rTarget);
+ const MIchar *pStrOperands = instrt.GetOperands(sbTarget);
pStrOperands = (pStrOperands != nullptr) ? pStrOperands : pUnknown;
// MI "{address=\"0x%08llx\",func-name=\"%s\",offset=\"%lld\",inst=\"%s %s\"}"
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
lldb::SBError error;
- const MIuint64 nReadBytes = rProcess.ReadMemory(static_cast<lldb::addr_t>(nAddrStart), (void *)m_pBufferMemory, nAddrNumBytes, error);
+ const MIuint64 nReadBytes = sbProcess.ReadMemory(static_cast<lldb::addr_t>(nAddrStart), (void *)m_pBufferMemory, nAddrNumBytes, error);
if (nReadBytes != nAddrNumBytes)
{
SetError(
CMICmdCmdDataListRegisterNames::Execute(void)
{
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
- if (!rProcess.IsValid())
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ if (sbProcess.IsValid())
{
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str()));
return MIstatus::failure;
}
- lldb::SBThread thread = rProcess.GetSelectedThread();
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
lldb::SBFrame frame = thread.GetSelectedFrame();
lldb::SBValueList registers = frame.GetRegisters();
const MIuint nRegisters = registers.GetSize();
, m_constStrArgFormat("fmt")
, m_constStrArgRegNo("regno")
, m_miValueList(true)
- , m_pProcess(nullptr)
{
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "data-list-register-values";
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
- if (!rProcess.IsValid())
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ if (!sbProcess.IsValid())
{
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str()));
return MIstatus::failure;
}
- m_pProcess = &rProcess;
const CMICmdArgValListBase::VecArgObjPtr_t &rVecRegNo(pArgRegNo->GetExpectedOptions());
CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecRegNo.begin();
lldb::SBValue
CMICmdCmdDataListRegisterValues::GetRegister(const MIuint vRegisterIndex) const
{
- lldb::SBThread thread = m_pProcess->GetSelectedThread();
+ lldb::SBThread thread = CMICmnLLDBDebugSessionInfo::Instance().GetProcess().GetSelectedThread();
lldb::SBFrame frame = thread.GetSelectedFrame();
lldb::SBValueList registers = frame.GetRegisters();
const MIuint nRegisters = registers.GetSize();
*m_pBufferMemory = static_cast<MIchar>(nValue);
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
lldb::SBError error;
lldb::addr_t addr = static_cast<lldb::addr_t>(m_nAddr + nAddrOffset);
- const size_t nBytesWritten = rProcess.WriteMemory(addr, (const void *)m_pBufferMemory, (size_t)m_nCount, error);
+ const size_t nBytesWritten = sbProcess.WriteMemory(addr, (const void *)m_pBufferMemory, (size_t)m_nCount, error);
if (nBytesWritten != static_cast<size_t>(m_nCount))
{
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDB_ERR_NOT_WRITE_WHOLEBLK), m_cmdData.strMiCmd.c_str(), m_nCount, addr));
const CMIUtilString m_constStrArgFormat;
const CMIUtilString m_constStrArgRegNo;
CMICmnMIValueList m_miValueList;
- lldb::SBProcess *m_pProcess;
};
//++ ============================================================================
lldb::SBError error;
lldb::SBStream errMsg;
uint32_t launch_flags = lldb::LaunchFlags::eLaunchFlagDebug;
- lldb::SBProcess process = rSessionInfo.m_lldbTarget.Launch(rSessionInfo.m_rLlldbListener, nullptr, nullptr, nullptr, nullptr, nullptr,
- nullptr, launch_flags, false, error);
+ lldb::SBProcess process = rSessionInfo.GetTarget().Launch(rSessionInfo.GetListener(), nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, launch_flags, false, error);
if ((!process.IsValid()) || (error.Fail()))
{
return MIstatus::failure;
}
- // Save the process in the session info
- rSessionInfo.m_lldbProcess = process;
-
if (!CMIDriver::Instance().SetDriverStateRunningDebugging())
{
const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
m_miResultRecord = miRecordResult;
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::pid_t pid = rSessionInfo.m_lldbProcess.GetProcessID();
+ lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
// Give the client '=thread-group-started,id="i1" pid="xyz"'
m_bHasResultRecordExtra = true;
const CMICmnMIValueConst miValueConst2("i1");
{
const MIchar *pCmd = "continue";
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- const lldb::ReturnStatus rtn = rSessionInfo.m_rLldbDebugger.GetCommandInterpreter().HandleCommand(pCmd, m_lldbResult);
+ const lldb::ReturnStatus rtn = rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(pCmd, m_lldbResult);
MIunused(rtn);
if (m_lldbResult.GetErrorSize() == 0)
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.m_rLldbDebugger;
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
CMIUtilString strCmd("thread step-over");
if (nThreadId != UINT64_MAX)
strCmd += CMIUtilString::Format(" %llu", nThreadId);
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.m_rLldbDebugger;
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
CMIUtilString strCmd("thread step-in");
if (nThreadId != UINT64_MAX)
strCmd += CMIUtilString::Format(" %llu", nThreadId);
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.m_rLldbDebugger;
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
CMIUtilString strCmd("thread step-inst-over");
if (nThreadId != UINT64_MAX)
strCmd += CMIUtilString::Format(" %llu", nThreadId);
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.m_rLldbDebugger;
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
CMIUtilString strCmd("thread step-inst");
if (nThreadId != UINT64_MAX)
strCmd += CMIUtilString::Format(" %llu", nThreadId);
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.m_rLldbDebugger;
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
CMIUtilString strCmd("thread step-out");
if (nThreadId != UINT64_MAX)
strCmd += CMIUtilString::Format(" %llu", nThreadId);
CMICmdCmdExecInterrupt::Execute(void)
{
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.m_rLldbDebugger;
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
CMIUtilString strCmd("process interrupt");
const lldb::ReturnStatus status = rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, false);
MIunused(status);
CMICmdArgValFile *pArgFile = static_cast<CMICmdArgValFile *>(pArgNamedFile);
const CMIUtilString &strExeFilePath(pArgFile->GetValue());
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDbgr = rSessionInfo.m_rLldbDebugger;
+ lldb::SBDebugger &rDbgr = rSessionInfo.GetDebugger();
lldb::SBError error;
const MIchar *pTargetTriple = nullptr; // Let LLDB discover the triple required
const MIchar *pTargetPlatformName = "";
return MIstatus::failure;
}
- rSessionInfo.m_lldbTarget = target;
-
return MIstatus::success;
}
bool bOk = rStdout.TextToStdout("~\"From To Syms Read Shared Object Library\"");
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBTarget &rTarget = rSessionInfo.m_lldbTarget;
- const MIuint nModules = rTarget.GetNumModules();
+ lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+ const MIuint nModules = sbTarget.GetNumModules();
for (MIuint i = 0; bOk && (i < nModules); i++)
{
- lldb::SBModule module = rTarget.GetModuleAtIndex(i);
+ lldb::SBModule module = sbTarget.GetModuleAtIndex(i);
if (module.IsValid())
{
const CMIUtilString strModuleFilePath(module.GetFileSpec().GetDirectory());
for (MIuint j = 0; j < nSections; j++)
{
lldb::SBSection section = module.GetSectionAtIndex(j);
- lldb::addr_t addrLoad = section.GetLoadAddress(rTarget);
+ lldb::addr_t addrLoad = section.GetLoadAddress(sbTarget);
if (addrLoad != (lldb::addr_t) - 1)
{
if (!bHaveAddrLoad)
CMICmdCmdGdbExit::Execute(void)
{
CMICmnLLDBDebugger::Instance().GetDriver().SetExitApplicationFlag(true);
- const lldb::SBError sbErr = m_rLLDBDebugSessionInfo.m_lldbProcess.Detach();
+ const lldb::SBError sbErr = m_rLLDBDebugSessionInfo.GetProcess().Detach();
// Do not check for sbErr.Fail() here, m_lldbProcess is likely !IsValid()
return MIstatus::success;
m_bIsI1 = true;
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
- // Note do not check for rProcess is IsValid(), continue
+ // Note do not check for sbProcess is IsValid(), continue
m_vecMIValueTuple.clear();
- const MIuint nThreads = rProcess.GetNumThreads();
+ const MIuint nThreads = sbProcess.GetNumThreads();
for (MIuint i = 0; i < nThreads; i++)
{
// GetThreadAtIndex() uses a base 0 index
// GetThreadByIndexID() uses a base 1 index
- lldb::SBThread thread = rProcess.GetThreadAtIndex(i);
+ lldb::SBThread thread = sbProcess.GetThreadAtIndex(i);
if (thread.IsValid())
{
miTuple.Add(miValueResult2);
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- if (rSessionInfo.m_lldbProcess.IsValid())
+ if (rSessionInfo.GetProcess().IsValid())
{
- const lldb::pid_t pid = rSessionInfo.m_lldbProcess.GetProcessID();
+ const lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
const CMIUtilString strPid(CMIUtilString::Format("%lld", pid));
const CMICmnMIValueConst miValueConst3(strPid);
const CMICmnMIValueResult miValueResult3("pid", miValueConst3);
miTuple.Add(miValueResult2);
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- if (rSessionInfo.m_lldbProcess.IsValid())
+ if (rSessionInfo.GetProcess().IsValid())
{
- const lldb::pid_t pid = rSessionInfo.m_lldbProcess.GetProcessID();
+ const lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
const CMIUtilString strPid(CMIUtilString::Format("%lld", pid));
const CMICmnMIValueConst miValueConst3(strPid);
const CMICmnMIValueResult miValueResult3("pid", miValueConst3);
miTuple.Add(miValueResult3);
}
- if (rSessionInfo.m_lldbTarget.IsValid())
+ if (rSessionInfo.GetTarget().IsValid())
{
- lldb::SBTarget &rTrgt = rSessionInfo.m_lldbTarget;
- const MIchar *pDir = rTrgt.GetExecutable().GetDirectory();
- const MIchar *pFileName = rTrgt.GetExecutable().GetFilename();
+ lldb::SBTarget sbTrgt = rSessionInfo.GetTarget();
+ const MIchar *pDir = sbTrgt.GetExecutable().GetDirectory();
+ const MIchar *pFileName = sbTrgt.GetExecutable().GetFilename();
const CMIUtilString strFile(CMIUtilString::Format("%s/%s", pDir, pFileName));
const CMICmnMIValueConst miValueConst4(strFile);
const CMICmnMIValueResult miValueResult4("executable", miValueConst4);
const CMIUtilString &rStrCommand(pArgCommand->GetValue());
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
const lldb::ReturnStatus rtn =
- rSessionInfo.m_rLldbDebugger.GetCommandInterpreter().HandleCommand(rStrCommand.c_str(), m_lldbResult, true);
+ rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(rStrCommand.c_str(), m_lldbResult, true);
MIunused(rtn);
return MIstatus::success;
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBThread thread = (nThreadId != UINT64_MAX) ? rProcess.GetThreadByIndexID(nThreadId) : rProcess.GetSelectedThread();
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBThread thread = (nThreadId != UINT64_MAX) ? sbProcess.GetThreadByIndexID(nThreadId) : sbProcess.GetSelectedThread();
m_nThreadFrames = thread.GetNumFrames();
return MIstatus::success;
const MIuint nFrameLow = pArgFrameLow->GetFound() ? pArgFrameLow->GetValue() : 0;
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBThread thread = (nThreadId != UINT64_MAX) ? rProcess.GetThreadByIndexID(nThreadId) : rProcess.GetSelectedThread();
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBThread thread = (nThreadId != UINT64_MAX) ? sbProcess.GetThreadByIndexID(nThreadId) : sbProcess.GetSelectedThread();
MIuint nThreadFrames = thread.GetNumFrames();
// Adjust nThreadFrames for the nFrameHigh argument as we use nFrameHigh+1 in the min calc as the arg
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBThread thread = (nThreadId != UINT64_MAX) ? rProcess.GetThreadByIndexID(nThreadId) : rProcess.GetSelectedThread();
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBThread thread = (nThreadId != UINT64_MAX) ? sbProcess.GetThreadByIndexID(nThreadId) : sbProcess.GetSelectedThread();
m_bThreadInvalid = !thread.IsValid();
if (m_bThreadInvalid)
return MIstatus::success;
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBThread thread = (nThreadId != UINT64_MAX) ? rProcess.GetThreadByIndexID(nThreadId) : rProcess.GetSelectedThread();
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBThread thread = (nThreadId != UINT64_MAX) ? sbProcess.GetThreadByIndexID(nThreadId) : sbProcess.GetSelectedThread();
m_bThreadInvalid = !thread.IsValid();
if (m_bThreadInvalid)
return MIstatus::success;
// Check we have a valid target
// Note: target created via 'file-exec-and-symbols' command
- if (!rSessionInfo.m_lldbTarget.IsValid())
+ if (!rSessionInfo.GetTarget().IsValid())
{
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), m_cmdData.strMiCmd.c_str()));
return MIstatus::failure;
// Ask LLDB to collect to the target port
const MIchar *pPlugin("gdb-remote");
lldb::SBError error;
- lldb::SBProcess process = rSessionInfo.m_lldbTarget.ConnectRemote(rSessionInfo.m_rLlldbListener, strUrl.c_str(), pPlugin, error);
+ lldb::SBProcess process = rSessionInfo.GetTarget().ConnectRemote(rSessionInfo.GetListener(), strUrl.c_str(), pPlugin, error);
// Verify that we have managed to connect successfully
lldb::SBStream errMsg;
return MIstatus::failure;
}
- // Save the process in the session info
- // Note: Order is important here since this process handle may be used by CMICmnLLDBDebugHandleEvents
- // which can fire when interpreting via HandleCommand() below.
- rSessionInfo.m_lldbProcess = process;
-
// Set the environment path if we were given one
CMIUtilString strWkDir;
if (rSessionInfo.SharedDataRetrieve<CMIUtilString>(rSessionInfo.m_constStrSharedDataKeyWkDir, strWkDir))
{
- lldb::SBDebugger &rDbgr = rSessionInfo.m_rLldbDebugger;
+ lldb::SBDebugger &rDbgr = rSessionInfo.GetDebugger();
if (!rDbgr.SetCurrentPlatformSDKRoot(strWkDir.c_str()))
{
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FNFAILED), m_cmdData.strMiCmd.c_str(), "target-select"));
CMIUtilString strSolibPath;
if (rSessionInfo.SharedDataRetrieve<CMIUtilString>(rSessionInfo.m_constStrSharedDataSolibPath, strSolibPath))
{
- lldb::SBDebugger &rDbgr = rSessionInfo.m_rLldbDebugger;
+ lldb::SBDebugger &rDbgr = rSessionInfo.GetDebugger();
lldb::SBCommandInterpreter cmdIterpreter = rDbgr.GetCommandInterpreter();
CMIUtilString strCmdString = CMIUtilString::Format("target modules search-paths add . %s", strSolibPath.c_str());
m_miResultRecord = miRecordResult;
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::pid_t pid = rSessionInfo.m_lldbProcess.GetProcessID();
+ lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
// Prod the client i.e. Eclipse with out-of-band results to help it 'continue' because it is using LLDB debugger
// Give the client '=thread-group-started,id="i1"'
m_bHasResultRecordExtra = true;
}
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBThread thread = rProcess.GetSelectedThread();
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
if (m_bSingleThread)
{
- thread = rProcess.GetThreadByIndexID(nThreadId);
+ thread = sbProcess.GetThreadByIndexID(nThreadId);
m_bThreadInvalid = thread.IsValid();
if (!m_bThreadInvalid)
return MIstatus::success;
// Multiple threads
m_vecMIValueTuple.clear();
- const MIuint nThreads = rProcess.GetNumThreads();
+ const MIuint nThreads = sbProcess.GetNumThreads();
for (MIuint i = 0; i < nThreads; i++)
{
- lldb::SBThread thread = rProcess.GetThreadAtIndex(i);
+ lldb::SBThread thread = sbProcess.GetThreadAtIndex(i);
if (thread.IsValid())
{
CMICmnMIValueTuple miTuple;
m_strVarName = CMIUtilString::Format("var%u", CMICmnLLDBDebugSessionInfoVarObj::VarObjIdGet());
CMICmnLLDBDebugSessionInfoVarObj::VarObjIdInc();
}
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBThread thread = (nThreadId != UINT64_MAX) ? rProcess.GetThreadByIndexID(nThreadId) : rProcess.GetSelectedThread();
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBThread thread = (nThreadId != UINT64_MAX) ? sbProcess.GetThreadByIndexID(nThreadId) : sbProcess.GetSelectedThread();
m_nThreadId = thread.GetIndexID();
lldb::SBFrame frame = thread.GetFrameAtIndex(nFrame);
lldb::SBValue value = frame.FindVariable(rStrExpression.c_str());
vrwbChanged = false;
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
- lldb::SBThread thread = rProcess.GetSelectedThread();
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
if (thread.GetNumFrames() == 0)
{
return MIstatus::success;
// Throws: None.
//--
CMICmnLLDBDebugSessionInfo::CMICmnLLDBDebugSessionInfo(void)
- : m_rLldbDebugger(CMICmnLLDBDebugger::Instance().GetTheDebugger())
- , m_rLlldbListener(CMICmnLLDBDebugger::Instance().GetTheListener())
- , m_nBrkPointCntMax(INT32_MAX)
+ : m_nBrkPointCntMax(INT32_MAX)
, m_currentSelectedThread(LLDB_INVALID_THREAD_ID)
, m_constStrSharedDataKeyWkDir("Working Directory")
, m_constStrSharedDataSolibPath("Solib Path")
bool
CMICmnLLDBDebugSessionInfo::GetThreadFrames(const SMICmdData &vCmdData, const MIuint vThreadIdx, CMIUtilString &vwrThreadFrames)
{
- lldb::SBThread thread = m_lldbProcess.GetThreadByIndexID(vThreadIdx);
+ lldb::SBThread thread = GetProcess().GetThreadByIndexID(vThreadIdx);
const uint32_t nFrames = thread.GetNumFrames();
if (nFrames == 0)
{
bool
CMICmnLLDBDebugSessionInfo::GetThreadFrames2(const SMICmdData &vCmdData, const MIuint vThreadIdx, CMIUtilString &vwrThreadFrames)
{
- lldb::SBThread thread = m_lldbProcess.GetThreadByIndexID(vThreadIdx);
+ lldb::SBThread thread = GetProcess().GetThreadByIndexID(vThreadIdx);
const uint32_t nFrames = thread.GetNumFrames();
if (nFrames == 0)
{
const MIchar *pFn = pUnkwn;
const MIchar *pFilePath = pUnkwn;
size_t nLine = 0;
- const size_t nAddr = brkPtAddr.GetLoadAddress(m_lldbTarget);
+ const size_t nAddr = brkPtAddr.GetLoadAddress(GetTarget());
lldb::SBCompileUnit rCmplUnit = symbolCntxt.GetCompileUnit();
if (rCmplUnit.IsValid())
return MIstatus::success;
}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Get current debugger.
+// Type: Method.
+// Args: None.
+// Return: lldb::SBDebugger - current debugger.
+// Throws: None.
+//--
+lldb::SBDebugger &
+CMICmnLLDBDebugSessionInfo::GetDebugger() const
+{
+ return CMICmnLLDBDebugger::Instance().GetTheDebugger();
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Get current listener.
+// Type: Method.
+// Args: None.
+// Return: lldb::SBListener - current listener.
+// Throws: None.
+//--
+lldb::SBListener &
+CMICmnLLDBDebugSessionInfo::GetListener() const
+{
+ return CMICmnLLDBDebugger::Instance().GetTheListener();
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Get current target.
+// Type: Method.
+// Args: None.
+// Return: lldb::SBTarget - current target.
+// Throws: None.
+//--
+lldb::SBTarget
+CMICmnLLDBDebugSessionInfo::GetTarget() const
+{
+ return GetDebugger().GetSelectedTarget();
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Get current process.
+// Type: Method.
+// Args: None.
+// Return: lldb::SBProcess - current process.
+// Throws: None.
+//--
+lldb::SBProcess
+CMICmnLLDBDebugSessionInfo::GetProcess() const
+{
+ return GetTarget().GetProcess();
+}
bool RecordBrkPtInfo(const MIuint vnBrkPtId, const SBrkPtInfo &vrBrkPtInfo);
bool RecordBrkPtInfoGet(const MIuint vnBrkPtId, SBrkPtInfo &vrwBrkPtInfo) const;
bool RecordBrkPtInfoDelete(const MIuint vnBrkPtId);
+ lldb::SBDebugger &GetDebugger() const;
+ lldb::SBListener &GetListener() const;
+ lldb::SBTarget GetTarget() const;
+ lldb::SBProcess GetProcess() const;
// Attributes:
public:
// The following are available to all command instances
- lldb::SBDebugger &m_rLldbDebugger;
- lldb::SBListener &m_rLlldbListener;
- lldb::SBTarget m_lldbTarget;
- lldb::SBProcess m_lldbProcess;
const MIuint m_nBrkPointCntMax;
VecActiveThreadId_t m_vecActiveThreadId;
lldb::tid_t m_currentSelectedThread;
// Explicitly delete the remote target in case MI needs to exit prematurely otherwise
// LLDB debugger may hang in its Destroy() fn waiting on events
- m_lldbDebugger.DeleteTarget(CMICmnLLDBDebugSessionInfo::Instance().m_lldbTarget);
+ lldb::SBTarget sbTarget = CMICmnLLDBDebugSessionInfo::Instance().GetTarget();
+ m_lldbDebugger.DeleteTarget(sbTarget);
// Debug: May need this but does seem to work without it so commented out the fudge 19/06/2014
// It appears we need to wait as hang does not occur when hitting a debug breakpoint here
return MIstatus::success;
bool bOk = MIstatus::success;
- lldb::SBDebugger &rDebugger = CMICmnLLDBDebugSessionInfo::Instance().m_rLldbDebugger;
- lldb::SBProcess &rProcess = CMICmnLLDBDebugSessionInfo::Instance().m_lldbProcess;
- lldb::SBTarget target = rProcess.GetTarget();
+ lldb::SBDebugger &rDebugger = CMICmnLLDBDebugSessionInfo::Instance().GetDebugger();
+ lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
+ lldb::SBTarget target = sbProcess.GetTarget();
if (rDebugger.GetSelectedTarget() == target)
{
if (!UpdateSelectedThread())
const MIchar *pEventType = "";
bool bOk = MIstatus::success;
- lldb::SBProcess &rProcess = CMICmnLLDBDebugSessionInfo::Instance().m_lldbProcess;
- const lldb::StopReason eStoppedReason = rProcess.GetSelectedThread().GetStopReason();
+ lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
+ const lldb::StopReason eStoppedReason = sbProcess.GetSelectedThread().GetStopReason();
switch (eStoppedReason)
{
case lldb::eStopReasonInvalid:
{
bool bOk = MIstatus::success;
- lldb::SBProcess &rProcess = CMICmnLLDBDebugSessionInfo::Instance().m_lldbProcess;
- const MIuint64 nStopReason = rProcess.GetSelectedThread().GetStopReasonDataAtIndex(0);
+ lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
+ const MIuint64 nStopReason = sbProcess.GetSelectedThread().GetStopReasonDataAtIndex(0);
switch (nStopReason)
{
case 2: // Terminal interrupt signal. SIGINT
const CMICmnMIValueConst miValueConst3("Segmentation fault");
const CMICmnMIValueResult miValueResult3("signal-meaning", miValueConst3);
bOk = bOk && miOutOfBandRecord.Add(miValueResult3);
- const CMIUtilString strThreadId(CMIUtilString::Format("%d", rProcess.GetSelectedThread().GetIndexID()));
+ const CMIUtilString strThreadId(CMIUtilString::Format("%d", sbProcess.GetSelectedThread().GetIndexID()));
const CMICmnMIValueConst miValueConst4(strThreadId);
const CMICmnMIValueResult miValueResult4("thread-id", miValueConst4);
bOk = bOk && miOutOfBandRecord.Add(miValueResult4);
}
break;
case 19:
- if (rProcess.IsValid())
- rProcess.Continue();
+ if (sbProcess.IsValid())
+ sbProcess.Continue();
break;
case 5: // Trace/breakpoint trap. SIGTRAP
{
- lldb::SBThread thread = rProcess.GetSelectedThread();
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
const MIuint nFrames = thread.GetNumFrames();
if (nFrames > 0)
{
if (CMIUtilString::Compare(threadCloneFn, fnName))
{
- if (rProcess.IsValid())
+ if (sbProcess.IsValid())
{
- rProcess.Continue();
+ sbProcess.Continue();
vwrbShouldBrk = true;
break;
}
CMICmnLLDBDebuggerHandleEvents::MiHelpGetCurrentThreadFrame(CMICmnMIValueTuple &vwrMiValueTuple)
{
CMIUtilString strThreadFrame;
- lldb::SBProcess &rProcess = CMICmnLLDBDebugSessionInfo::Instance().m_lldbProcess;
- lldb::SBThread thread = rProcess.GetSelectedThread();
+ lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
const MIuint nFrame = thread.GetNumFrames();
if (nFrame == 0)
{
return MIstatus::failure;
}
- lldb::SBProcess &rProcess = CMICmnLLDBDebugSessionInfo::Instance().m_lldbProcess;
- const MIuint64 brkPtId = rProcess.GetSelectedThread().GetStopReasonDataAtIndex(0);
- lldb::SBBreakpoint brkPt = CMICmnLLDBDebugSessionInfo::Instance().m_lldbTarget.GetBreakpointAtIndex((MIuint)brkPtId);
+ lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
+ const MIuint64 brkPtId = sbProcess.GetSelectedThread().GetStopReasonDataAtIndex(0);
+ lldb::SBBreakpoint brkPt = CMICmnLLDBDebugSessionInfo::Instance().GetTarget().GetBreakpointAtIndex((MIuint)brkPtId);
return MiStoppedAtBreakPoint(brkPtId, brkPt);
}
{
bool bOk = MIstatus::success;
- lldb::SBProcess &rProcess = CMICmnLLDBDebugSessionInfo::Instance().m_lldbProcess;
- lldb::SBThread thread = rProcess.GetSelectedThread();
+ lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
const MIuint nFrame = thread.GetNumFrames();
if (nFrame == 0)
{
CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace(void)
{
bool bOk = true;
- lldb::SBProcess &rProcess = CMICmnLLDBDebugSessionInfo::Instance().m_lldbProcess;
- lldb::SBThread thread = rProcess.GetSelectedThread();
+ lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
const MIuint nFrame = thread.GetNumFrames();
if (nFrame == 0)
{
bool
CMICmnLLDBDebuggerHandleEvents::UpdateSelectedThread(void)
{
- lldb::SBProcess process = CMICmnLLDBDebugSessionInfo::Instance().m_rLldbDebugger.GetSelectedTarget().GetProcess();
+ lldb::SBProcess process = CMICmnLLDBDebugSessionInfo::Instance().GetDebugger().GetSelectedTarget().GetProcess();
if (!process.IsValid())
return MIstatus::success;
char c;
size_t nBytes = 0;
CMIUtilString text;
- lldb::SBProcess process = CMICmnLLDBDebugSessionInfo::Instance().m_rLldbDebugger.GetSelectedTarget().GetProcess();
+ lldb::SBProcess process = CMICmnLLDBDebugSessionInfo::Instance().GetDebugger().GetSelectedTarget().GetProcess();
while (process.GetSTDOUT(&c, 1) > 0)
{
CMIUtilString str;
char c;
size_t nBytes = 0;
CMIUtilString text;
- lldb::SBProcess process = CMICmnLLDBDebugSessionInfo::Instance().m_rLldbDebugger.GetSelectedTarget().GetProcess();
+ lldb::SBProcess process = CMICmnLLDBDebugSessionInfo::Instance().GetDebugger().GetSelectedTarget().GetProcess();
while (process.GetSTDERR(&c, 1) > 0)
{
CMIUtilString str;
bool
CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void)
{
- lldb::SBProcess &rProcess = CMICmnLLDBDebugSessionInfo::Instance().m_lldbProcess;
- if (!rProcess.IsValid())
+ lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
+ if (!sbProcess.IsValid())
return MIstatus::success;
- lldb::SBTarget &rTarget = CMICmnLLDBDebugSessionInfo::Instance().m_lldbTarget;
- if (!rTarget.IsValid())
+ lldb::SBTarget sbTarget = CMICmnLLDBDebugSessionInfo::Instance().GetTarget();
+ if (!sbTarget.IsValid())
return MIstatus::success;
bool bOk = MIstatus::success;
// Check for created threads
- const MIuint nThread = rProcess.GetNumThreads();
+ const MIuint nThread = sbProcess.GetNumThreads();
for (MIuint i = 0; i < nThread; i++)
{
// GetThreadAtIndex() uses a base 0 index
// GetThreadByIndexID() uses a base 1 index
- lldb::SBThread thread = rProcess.GetThreadAtIndex(i);
+ lldb::SBThread thread = sbProcess.GetThreadAtIndex(i);
if (!thread.IsValid())
continue;
}
}
- lldb::SBThread currentThread = rProcess.GetSelectedThread();
+ lldb::SBThread currentThread = sbProcess.GetSelectedThread();
if (currentThread.IsValid())
{
const MIuint threadId = currentThread.GetIndexID();
while (it != CMICmnLLDBDebugSessionInfo::Instance().m_vecActiveThreadId.end())
{
const MIuint nThreadId = *it;
- lldb::SBThread thread = rProcess.GetThreadAtIndex(nThreadId);
+ lldb::SBThread thread = sbProcess.GetThreadAtIndex(nThreadId);
if (!thread.IsValid())
{
// Form MI "=thread-exited,id=\"%ld\",group-id=\"i1\""
return MIstatus::failure;
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess &rProcess = rSessionInfo.m_lldbProcess;
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
MIuint nBufferSize = 64;
bool bNeedResize = false;
MIchar *pBuffer = static_cast<MIchar *>(::malloc(nBufferSize));
do
{
lldb::SBError error;
- const size_t nReadSize = rProcess.ReadCStringFromMemory((lldb::addr_t)nNum, pBuffer, nBufferSize, error);
+ const size_t nReadSize = sbProcess.ReadCStringFromMemory((lldb::addr_t)nNum, pBuffer, nBufferSize, error);
if (nReadSize == (nBufferSize - 1))
{
bNeedResize = true;
const MIuint nBytes(128);
const MIchar *pBufferMemory = new MIchar[nBytes];
lldb::SBError error;
- const MIuint64 nReadBytes = rSessionInfo.m_lldbProcess.ReadMemory(addr, (void *)pBufferMemory, nBytes, error);
+ const MIuint64 nReadBytes = rSessionInfo.GetProcess().ReadMemory(addr, (void *)pBufferMemory, nBytes, error);
MIunused(nReadBytes);
text = CMIUtilString::Format("\\\"%s\\\"", pBufferMemory);
delete[] pBufferMemory;