Skip to content

Commit

Permalink
Fix the problem that the module list cannot be obtained (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonyps5201314 authored Sep 10, 2023
1 parent 610d71a commit f846a13
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/MICmdCmdBreak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/MICmdCmdSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 14 additions & 2 deletions src/MICmnLLDBDebugSessionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/MICmnLLDBDebugSessionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f846a13

Please sign in to comment.