diff --git a/src/MICmdCmdBreak.cpp b/src/MICmdCmdBreak.cpp index 343dd35..dfc2183 100644 --- a/src/MICmdCmdBreak.cpp +++ b/src/MICmdCmdBreak.cpp @@ -149,7 +149,7 @@ bool CMICmdCmdBreakInsert::Execute() { // Ask LLDB for the target to check if we have valid or dummy one. CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + lldb::SBTarget sbTarget = rSessionInfo.GetSelectedOrDummyTarget(); m_bBreakpointEnabled = !pArgDisableBreakpoint->GetFound(); m_bBreakpointIsTemp = pArgTempBreakpoint->GetFound(); @@ -464,7 +464,7 @@ bool CMICmdCmdBreakDelete::Execute() { } bool bSuccess = false; - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + lldb::SBTarget sbTarget = rSessionInfo.GetSelectedOrDummyTarget(); if (sStoppointInfo.m_eType == CMICmnLLDBDebugSessionInfo::eStoppointType_Breakpoint) bSuccess = sbTarget.BreakpointDelete( @@ -601,7 +601,7 @@ bool CMICmdCmdBreakDisable::Execute() { } }; - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + lldb::SBTarget sbTarget = rSessionInfo.GetSelectedOrDummyTarget(); if (sStoppointInfo.m_eType == CMICmnLLDBDebugSessionInfo::eStoppointType_Breakpoint) { lldb::SBBreakpoint breakpoint = sbTarget.FindBreakpointByID( @@ -744,7 +744,7 @@ bool CMICmdCmdBreakEnable::Execute() { } }; - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + lldb::SBTarget sbTarget = rSessionInfo.GetSelectedOrDummyTarget(); if (sStoppointInfo.m_eType == CMICmnLLDBDebugSessionInfo::eStoppointType_Breakpoint) { lldb::SBBreakpoint breakpoint = sbTarget.FindBreakpointByID( @@ -875,7 +875,7 @@ bool CMICmdCmdBreakAfter::Execute() { return MIstatus::failure; } - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + lldb::SBTarget sbTarget = rSessionInfo.GetSelectedOrDummyTarget(); if (sStoppointInfo.m_eType == CMICmnLLDBDebugSessionInfo::eStoppointType_Breakpoint) { lldb::SBBreakpoint breakpoint = sbTarget.FindBreakpointByID( @@ -1023,7 +1023,7 @@ bool CMICmdCmdBreakCondition::Execute() { return MIstatus::failure; } - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + lldb::SBTarget sbTarget = rSessionInfo.GetSelectedOrDummyTarget(); if (sStoppointInfo.m_eType == CMICmnLLDBDebugSessionInfo::eStoppointType_Breakpoint) { lldb::SBBreakpoint breakpoint = sbTarget.FindBreakpointByID( @@ -1267,7 +1267,7 @@ bool CMICmdCmdBreakWatch::Execute() { // Ask LLDB for the target to check if we have valid or dummy one. CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - auto sbTarget = rSessionInfo.GetTarget(); + auto sbTarget = rSessionInfo.GetSelectedOrDummyTarget(); auto sbProcess = rSessionInfo.GetProcess(); auto sbThread = sbProcess.GetSelectedThread(); auto sbFrame = sbThread.GetSelectedFrame(); diff --git a/src/MICmdCmdSymbol.cpp b/src/MICmdCmdSymbol.cpp index 012e4a8..015b8a4 100644 --- a/src/MICmdCmdSymbol.cpp +++ b/src/MICmdCmdSymbol.cpp @@ -99,7 +99,8 @@ bool CMICmdCmdSymbolListLines::Execute() { CMICMDBASE_GETOPTION(pArgFile, File, m_constStrArgNameFile); const auto &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); - if (rSessionInfo.GetTarget() == rSessionInfo.GetDebugger().GetDummyTarget()) { + if (rSessionInfo.GetSelectedOrDummyTarget() == + rSessionInfo.GetDebugger().GetDummyTarget()) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), m_cmdData.strMiCmd.c_str())); return MIstatus::failure; diff --git a/src/MICmnLLDBDebugSessionInfo.cpp b/src/MICmnLLDBDebugSessionInfo.cpp index 8ae513b..51214d3 100644 --- a/src/MICmnLLDBDebugSessionInfo.cpp +++ b/src/MICmnLLDBDebugSessionInfo.cpp @@ -979,13 +979,25 @@ lldb::SBListener &CMICmnLLDBDebugSessionInfo::GetListener() const { } //++ -// Details: Get current target. +// Details: Get current selected target. // Type: Method. // Args: None. -// Return: lldb::SBTarget - current target. +// Return: lldb::SBTarget - current selected target. // Throws: None. //-- lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const { + auto target = GetDebugger().GetSelectedTarget(); + return target; +} + +//++ +// Details: Get current selected or dummy target. +// Type: Method. +// Args: None. +// Return: lldb::SBTarget - current selected or dummy target. +// Throws: None. +//-- +lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetSelectedOrDummyTarget() const { auto target = GetDebugger().GetSelectedTarget(); if (target.IsValid()) return target; diff --git a/src/MICmnLLDBDebugSessionInfo.h b/src/MICmnLLDBDebugSessionInfo.h index 9c9d2df..3a97579 100644 --- a/src/MICmnLLDBDebugSessionInfo.h +++ b/src/MICmnLLDBDebugSessionInfo.h @@ -204,6 +204,7 @@ class CMICmnLLDBDebugSessionInfo lldb::SBDebugger &GetDebugger() const; lldb::SBListener &GetListener() const; lldb::SBTarget GetTarget() const; + lldb::SBTarget GetSelectedOrDummyTarget() const; lldb::SBProcess GetProcess() const; void SetCreateTty(bool val);