diff options
| author | Hafiz Abid Qadeer <hafiz_abid@mentor.com> | 2015-02-03 10:05:54 +0000 |
|---|---|---|
| committer | Hafiz Abid Qadeer <hafiz_abid@mentor.com> | 2015-02-03 10:05:54 +0000 |
| commit | 0d51c1563b8c37ee34a82e7f7592d7a27ba28822 (patch) | |
| tree | 88da8fb8d5e4de42d1a180c148515871bd06d53f /lldb/tools | |
| parent | e03491d39074a28585f7d4b8eebc88ad24d69aab (diff) | |
| download | bcm5719-llvm-0d51c1563b8c37ee34a82e7f7592d7a27ba28822.tar.gz bcm5719-llvm-0d51c1563b8c37ee34a82e7f7592d7a27ba28822.zip | |
Fix CLI commands in lldb-mi.
This patch fixes execution of CLI commands in MI mode. The CLI commands are
executed using "-interpreter-exec" command. The bug was in the
CMICmnLLDBDebugSessionInfo class which contained the following members:
SBProcess, SBTarget, SBDebugger and SBListener, but CLI commands don't affect
them and they aren't updated. Therefore some members can contain incorrect
(or obsolete) reference and it can cause an error. My patch removes these
members and uses getters that provides the updated instance every time it is used.
Patch from Ilia K ki.stfu@gmail.com. Approved by Greg.
llvm-svn: 227958
Diffstat (limited to 'lldb/tools')
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdBreak.cpp | 20 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdData.cpp | 36 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdData.h | 1 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdExec.cpp | 23 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdFile.cpp | 4 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdGdbInfo.cpp | 8 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdMiscellanous.cpp | 28 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdStack.cpp | 16 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdTarget.cpp | 15 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdThread.cpp | 10 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdVar.cpp | 8 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp | 62 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h | 8 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmnLLDBDebugger.cpp | 3 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp | 66 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmnLLDBProxySBValue.cpp | 4 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp | 2 |
17 files changed, 176 insertions, 138 deletions
diff --git a/lldb/tools/lldb-mi/MICmdCmdBreak.cpp b/lldb/tools/lldb-mi/MICmdCmdBreak.cpp index 21282909c4a..12bba91fa98 100644 --- a/lldb/tools/lldb-mi/MICmdCmdBreak.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdBreak.cpp @@ -232,20 +232,20 @@ CMICmdCmdBreakInsert::Execute(void) // 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: @@ -440,7 +440,7 @@ CMICmdCmdBreakDelete::Execute(void) } 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)); @@ -560,7 +560,7 @@ CMICmdCmdBreakDisable::Execute(void) } 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; @@ -700,7 +700,7 @@ CMICmdCmdBreakEnable::Execute(void) } 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; @@ -837,7 +837,7 @@ CMICmdCmdBreakAfter::Execute(void) 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); @@ -972,7 +972,7 @@ CMICmdCmdBreakCondition::Execute(void) 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()); diff --git a/lldb/tools/lldb-mi/MICmdCmdData.cpp b/lldb/tools/lldb-mi/MICmdCmdData.cpp index 05b59a78787..efd831046e8 100644 --- a/lldb/tools/lldb-mi/MICmdCmdData.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdData.cpp @@ -122,8 +122,8 @@ CMICmdCmdDataEvaluateExpression::Execute(void) 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; @@ -410,22 +410,22 @@ CMICmdCmdDataDisassemble::Execute(void) 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\"}" @@ -599,9 +599,9 @@ CMICmdCmdDataReadMemoryBytes::Execute(void) } 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( @@ -827,14 +827,14 @@ bool 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(); @@ -906,7 +906,6 @@ CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues(void) , 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"; @@ -975,13 +974,12 @@ CMICmdCmdDataListRegisterValues::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; } - m_pProcess = &rProcess; const CMICmdArgValListBase::VecArgObjPtr_t &rVecRegNo(pArgRegNo->GetExpectedOptions()); CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecRegNo.begin(); @@ -1051,7 +1049,7 @@ CMICmdCmdDataListRegisterValues::CreateSelf(void) 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(); @@ -1371,10 +1369,10 @@ CMICmdCmdDataWriteMemory::Execute(void) *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)); diff --git a/lldb/tools/lldb-mi/MICmdCmdData.h b/lldb/tools/lldb-mi/MICmdCmdData.h index 74ceeb8581b..b1d076268c1 100644 --- a/lldb/tools/lldb-mi/MICmdCmdData.h +++ b/lldb/tools/lldb-mi/MICmdCmdData.h @@ -263,7 +263,6 @@ class CMICmdCmdDataListRegisterValues : public CMICmdBase const CMIUtilString m_constStrArgFormat; const CMIUtilString m_constStrArgRegNo; CMICmnMIValueList m_miValueList; - lldb::SBProcess *m_pProcess; }; //++ ============================================================================ diff --git a/lldb/tools/lldb-mi/MICmdCmdExec.cpp b/lldb/tools/lldb-mi/MICmdCmdExec.cpp index da58993e02a..eec62c8d37e 100644 --- a/lldb/tools/lldb-mi/MICmdCmdExec.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdExec.cpp @@ -91,8 +91,8 @@ CMICmdCmdExecRun::Execute(void) 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())) { @@ -100,9 +100,6 @@ CMICmdCmdExecRun::Execute(void) return MIstatus::failure; } - // Save the process in the session info - rSessionInfo.m_lldbProcess = process; - if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) { const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); @@ -137,7 +134,7 @@ CMICmdCmdExecRun::Acknowledge(void) 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"); @@ -212,7 +209,7 @@ CMICmdCmdExecContinue::Execute(void) { 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) @@ -356,7 +353,7 @@ CMICmdCmdExecNext::Execute(void) } 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); @@ -483,7 +480,7 @@ CMICmdCmdExecStep::Execute(void) } 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); @@ -610,7 +607,7 @@ CMICmdCmdExecNextInstruction::Execute(void) } 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); @@ -737,7 +734,7 @@ CMICmdCmdExecStepInstruction::Execute(void) } 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); @@ -865,7 +862,7 @@ CMICmdCmdExecFinish::Execute(void) } 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); @@ -962,7 +959,7 @@ bool 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); diff --git a/lldb/tools/lldb-mi/MICmdCmdFile.cpp b/lldb/tools/lldb-mi/MICmdCmdFile.cpp index 671f3fe6f1a..83862f24f1f 100644 --- a/lldb/tools/lldb-mi/MICmdCmdFile.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdFile.cpp @@ -96,7 +96,7 @@ CMICmdCmdFileExecAndSymbols::Execute(void) 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 = ""; @@ -137,8 +137,6 @@ CMICmdCmdFileExecAndSymbols::Execute(void) return MIstatus::failure; } - rSessionInfo.m_lldbTarget = target; - return MIstatus::success; } diff --git a/lldb/tools/lldb-mi/MICmdCmdGdbInfo.cpp b/lldb/tools/lldb-mi/MICmdCmdGdbInfo.cpp index 4b2f0a783ef..be70962b63a 100644 --- a/lldb/tools/lldb-mi/MICmdCmdGdbInfo.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdGdbInfo.cpp @@ -198,11 +198,11 @@ CMICmdCmdGdbInfo::PrintFnSharedLibrary(void) 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()); @@ -216,7 +216,7 @@ CMICmdCmdGdbInfo::PrintFnSharedLibrary(void) 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) diff --git a/lldb/tools/lldb-mi/MICmdCmdMiscellanous.cpp b/lldb/tools/lldb-mi/MICmdCmdMiscellanous.cpp index 4bbd03d82cb..03e05f3b005 100644 --- a/lldb/tools/lldb-mi/MICmdCmdMiscellanous.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdMiscellanous.cpp @@ -84,7 +84,7 @@ bool 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; @@ -234,17 +234,17 @@ CMICmdCmdListThreadGroups::Execute(void) 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()) { @@ -292,9 +292,9 @@ CMICmdCmdListThreadGroups::Acknowledge(void) 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); @@ -328,20 +328,20 @@ CMICmdCmdListThreadGroups::Acknowledge(void) 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); @@ -470,7 +470,7 @@ CMICmdCmdInterpreterExec::Execute(void) 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; diff --git a/lldb/tools/lldb-mi/MICmdCmdStack.cpp b/lldb/tools/lldb-mi/MICmdCmdStack.cpp index 112e6032a40..7322be0d624 100644 --- a/lldb/tools/lldb-mi/MICmdCmdStack.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdStack.cpp @@ -111,8 +111,8 @@ CMICmdCmdStackInfoDepth::Execute(void) } 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; @@ -237,8 +237,8 @@ CMICmdCmdStackListFrames::Execute(void) 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 @@ -414,8 +414,8 @@ CMICmdCmdStackListArguments::Execute(void) } 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; @@ -583,8 +583,8 @@ CMICmdCmdStackListLocals::Execute(void) } 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; diff --git a/lldb/tools/lldb-mi/MICmdCmdTarget.cpp b/lldb/tools/lldb-mi/MICmdCmdTarget.cpp index 36dfd487846..c3ef0b44e80 100644 --- a/lldb/tools/lldb-mi/MICmdCmdTarget.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdTarget.cpp @@ -100,7 +100,7 @@ CMICmdCmdTargetSelect::Execute(void) // 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; @@ -120,7 +120,7 @@ CMICmdCmdTargetSelect::Execute(void) // 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; @@ -135,16 +135,11 @@ CMICmdCmdTargetSelect::Execute(void) 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")); @@ -156,7 +151,7 @@ CMICmdCmdTargetSelect::Execute(void) 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()); @@ -190,7 +185,7 @@ CMICmdCmdTargetSelect::Acknowledge(void) 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; diff --git a/lldb/tools/lldb-mi/MICmdCmdThread.cpp b/lldb/tools/lldb-mi/MICmdCmdThread.cpp index bc36260810f..52fd9605063 100644 --- a/lldb/tools/lldb-mi/MICmdCmdThread.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdThread.cpp @@ -99,12 +99,12 @@ CMICmdCmdThreadInfo::Execute(void) } 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; @@ -120,10 +120,10 @@ CMICmdCmdThreadInfo::Execute(void) // 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; diff --git a/lldb/tools/lldb-mi/MICmdCmdVar.cpp b/lldb/tools/lldb-mi/MICmdCmdVar.cpp index e07ce2c39ce..040b623b10f 100644 --- a/lldb/tools/lldb-mi/MICmdCmdVar.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdVar.cpp @@ -169,8 +169,8 @@ CMICmdCmdVarCreate::Execute(void) 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()); @@ -519,8 +519,8 @@ CMICmdCmdVarUpdate::ExamineSBValueForChange(const CMICmnLLDBDebugSessionInfoVarO 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; diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp index 4a810be7e5f..b52750aa2e6 100644 --- a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -47,9 +47,7 @@ // 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") @@ -226,7 +224,7 @@ CMICmnLLDBDebugSessionInfo::RecordBrkPtInfoDelete(const MIuint vnBrkPtId) 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) { @@ -299,7 +297,7 @@ CMICmnLLDBDebugSessionInfo::GetThreadFrames(const SMICmdData &vCmdData, const MI 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) { @@ -1329,7 +1327,7 @@ CMICmnLLDBDebugSessionInfo::GetBrkPtInfo(const lldb::SBBreakpoint &vBrkPt, SBrkP 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()) @@ -1356,3 +1354,55 @@ CMICmnLLDBDebugSessionInfo::GetBrkPtInfo(const lldb::SBBreakpoint &vBrkPt, SBrkP 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(); +} diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h index e45f3ca2da1..be5904a3546 100644 --- a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h +++ b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h @@ -156,14 +156,14 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC 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; diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugger.cpp b/lldb/tools/lldb-mi/MICmnLLDBDebugger.cpp index dc3ad4b0341..5ac380c00a1 100644 --- a/lldb/tools/lldb-mi/MICmnLLDBDebugger.cpp +++ b/lldb/tools/lldb-mi/MICmnLLDBDebugger.cpp @@ -148,7 +148,8 @@ CMICmnLLDBDebugger::Shutdown(void) // 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 diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp index 4d22bda6bc7..a9cf995d048 100644 --- a/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp +++ b/lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp @@ -722,9 +722,9 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateSuspended(const lldb::SBE 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()) @@ -768,8 +768,8 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateStopped(bool &vwrbShouldB 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: @@ -831,8 +831,8 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(bool &vwrbShouldBrk { 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 @@ -868,7 +868,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(bool &vwrbShouldBrk 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); @@ -881,12 +881,12 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(bool &vwrbShouldBrk } 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) { @@ -899,9 +899,9 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(bool &vwrbShouldBrk if (CMIUtilString::Compare(threadCloneFn, fnName)) { - if (rProcess.IsValid()) + if (sbProcess.IsValid()) { - rProcess.Continue(); + sbProcess.Continue(); vwrbShouldBrk = true; break; } @@ -942,8 +942,8 @@ bool 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) { @@ -997,9 +997,9 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonBreakpoint(void) 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); } @@ -1018,8 +1018,8 @@ CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(const MIuint64 vBrkPtId, c { 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) { @@ -1121,8 +1121,8 @@ bool 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) { @@ -1200,7 +1200,7 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace(void) 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; @@ -1342,7 +1342,7 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStdout(void) 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; @@ -1377,7 +1377,7 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStderr(void) 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; @@ -1451,22 +1451,22 @@ CMICmnLLDBDebuggerHandleEvents::ConvertPrintfCtrlCodeToString(const MIchar vCtrl 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; @@ -1503,7 +1503,7 @@ CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void) } } - lldb::SBThread currentThread = rProcess.GetSelectedThread(); + lldb::SBThread currentThread = sbProcess.GetSelectedThread(); if (currentThread.IsValid()) { const MIuint threadId = currentThread.GetIndexID(); @@ -1526,7 +1526,7 @@ CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges(void) 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\"" diff --git a/lldb/tools/lldb-mi/MICmnLLDBProxySBValue.cpp b/lldb/tools/lldb-mi/MICmnLLDBProxySBValue.cpp index 5884abc6b8f..6a07f207840 100644 --- a/lldb/tools/lldb-mi/MICmnLLDBProxySBValue.cpp +++ b/lldb/tools/lldb-mi/MICmnLLDBProxySBValue.cpp @@ -129,14 +129,14 @@ CMICmnLLDBProxySBValue::GetCString(const lldb::SBValue &vrValue, CMIUtilString & 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; diff --git a/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp b/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp index 847bba2c8d0..66a4efd5a96 100644 --- a/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp +++ b/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp @@ -219,7 +219,7 @@ CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory(const lldb::SBValue &vrValueObj 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; |

