[Lldb-commits] [lldb] r227958 - Fix CLI commands in lldb-mi.

Hafiz Abid Qadeer hafiz_abid at mentor.com
Tue Feb 3 02:05:55 PST 2015


Author: abidh
Date: Tue Feb  3 04:05:54 2015
New Revision: 227958

URL: http://llvm.org/viewvc/llvm-project?rev=227958&view=rev
Log:
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 at gmail.com. Approved by Greg.


Modified:
    lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdData.h
    lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdFile.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdMiscellanous.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdTarget.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdThread.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp
    lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
    lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
    lldb/trunk/tools/lldb-mi/MICmnLLDBDebugger.cpp
    lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
    lldb/trunk/tools/lldb-mi/MICmnLLDBProxySBValue.cpp
    lldb/trunk/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp Tue Feb  3 04:05:54 2015
@@ -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());

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp Tue Feb  3 04:05:54 2015
@@ -122,8 +122,8 @@ CMICmdCmdDataEvaluateExpression::Execute
 
     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(vo
     }
 
     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::CMICmdC
     , 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
     }
 
     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::CreateS
 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));

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdData.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdData.h?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdData.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdData.h Tue Feb  3 04:05:54 2015
@@ -263,7 +263,6 @@ class CMICmdCmdDataListRegisterValues :
     const CMIUtilString m_constStrArgFormat;
     const CMIUtilString m_constStrArgRegNo;
     CMICmnMIValueList m_miValueList;
-    lldb::SBProcess *m_pProcess;
 };
 
 //++ ============================================================================

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp Tue Feb  3 04:05:54 2015
@@ -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(vo
     }
 
     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(vo
     }
 
     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);

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdFile.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdFile.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdFile.cpp Tue Feb  3 04:05:54 2015
@@ -96,7 +96,7 @@ CMICmdCmdFileExecAndSymbols::Execute(voi
     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(voi
         return MIstatus::failure;
     }
 
-    rSessionInfo.m_lldbTarget = target;
-
     return MIstatus::success;
 }
 

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp Tue Feb  3 04:05:54 2015
@@ -198,11 +198,11 @@ CMICmdCmdGdbInfo::PrintFnSharedLibrary(v
     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(v
             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)

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdMiscellanous.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdMiscellanous.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdMiscellanous.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdMiscellanous.cpp Tue Feb  3 04:05:54 2015
@@ -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(v
         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(v
         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;

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp Tue Feb  3 04:05:54 2015
@@ -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(voi
     }
 
     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;

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdTarget.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdTarget.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdTarget.cpp Tue Feb  3 04:05:54 2015
@@ -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;

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdThread.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdThread.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdThread.cpp Tue Feb  3 04:05:54 2015
@@ -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;

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp Tue Feb  3 04:05:54 2015
@@ -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::ExamineSBValueForCha
     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;

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp Tue Feb  3 04:05:54 2015
@@ -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::RecordBrkPtI
 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::GetThreadFra
 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 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
 
     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();
+}

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h Tue Feb  3 04:05:54 2015
@@ -156,14 +156,14 @@ class CMICmnLLDBDebugSessionInfo : publi
     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;

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebugger.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugger.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugger.cpp Tue Feb  3 04:05:54 2015
@@ -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

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp Tue Feb  3 04:05:54 2015
@@ -722,9 +722,9 @@ CMICmnLLDBDebuggerHandleEvents::HandlePr
         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::HandlePr
 
     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::HandlePr
 {
     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::HandlePr
             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::HandlePr
         }
         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::HandlePr
 
                     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::HandlePr
         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::MiStoppe
 {
     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::HandlePr
 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::GetProce
     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::GetProce
     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::ConvertP
 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::ChkForSt
         }
     }
 
-    lldb::SBThread currentThread = rProcess.GetSelectedThread();
+    lldb::SBThread currentThread = sbProcess.GetSelectedThread();
     if (currentThread.IsValid())
     {
         const MIuint threadId = currentThread.GetIndexID();
@@ -1526,7 +1526,7 @@ CMICmnLLDBDebuggerHandleEvents::ChkForSt
     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\""

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBProxySBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBProxySBValue.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBProxySBValue.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBProxySBValue.cpp Tue Feb  3 04:05:54 2015
@@ -129,14 +129,14 @@ CMICmnLLDBProxySBValue::GetCString(const
         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;

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp?rev=227958&r1=227957&r2=227958&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp Tue Feb  3 04:05:54 2015
@@ -219,7 +219,7 @@ CMICmnLLDBUtilSBValue::ReadCStringFromHo
     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;





More information about the lldb-commits mailing list