Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions src/MICmdCmdThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,107 @@ bool CMICmdCmdThreadInfo::Acknowledge() {
CMICmdBase *CMICmdCmdThreadInfo::CreateSelf() {
return new CMICmdCmdThreadInfo();
}

//++
// Details: CMICmdCmdThreadSelect constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
CMICmdCmdThreadSelect::CMICmdCmdThreadSelect()
: m_bThreadInvalid(true), m_constStrArgNamedThreadId("thread-id") {
// Command factory matches this name with that received from the stdin stream
m_strMiCmd = "thread-select";

// Required by the CMICmdFactory when registering *this command
m_pSelfCreatorFn = &CMICmdCmdThreadSelect::CreateSelf;
}

//++
// Details: CMICmdCmdThreadSelect destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
CMICmdCmdThreadSelect::~CMICmdCmdThreadSelect() {}

//++
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
// Type: Overridden.
// Args: None.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
// Throws: None.
//--
bool CMICmdCmdThreadSelect::ParseArgs() {
m_setCmdArgs.Add(
new CMICmdArgValNumber(m_constStrArgNamedThreadId, true, true));
return ParseValidateCmdOptions();
}

//++
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
// here.
// Type: Overridden.
// Args: None.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
// Throws: None.
//--
bool CMICmdCmdThreadSelect::Execute() {
CMICMDBASE_GETOPTION(pArgThreadId, Number, m_constStrArgNamedThreadId);
const MIuint nThreadId = static_cast<MIuint>(pArgThreadId->GetValue());

CMICmnLLDBDebugSessionInfo &rSessionInfo(
CMICmnLLDBDebugSessionInfo::Instance());
lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
m_bThreadInvalid = !sbProcess.SetSelectedThreadByIndexID(nThreadId);
return MIstatus::success;
}

//++
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
// Type: Overridden.
// Args: None.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
// Throws: None.
//--
bool CMICmdCmdThreadSelect::Acknowledge() {
if (m_bThreadInvalid) {
const CMICmnMIValueConst miValueConst("invalid thread id");
const CMICmnMIValueResult miValueResult("msg", miValueConst);
const CMICmnMIResultRecord miRecordResult(
m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
miValueResult);
m_miResultRecord = miRecordResult;
return MIstatus::success;
}

const CMICmnMIResultRecord miRecordResult(
m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;

return MIstatus::success;
}

//++
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
// Type: Static method.
// Args: None.
// Return: CMICmdBase * - Pointer to a new command.
// Throws: None.
//--
CMICmdBase *CMICmdCmdThreadSelect::CreateSelf() {
return new CMICmdCmdThreadSelect();
}
30 changes: 30 additions & 0 deletions src/MICmdCmdThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,33 @@ class CMICmdCmdThreadInfo : public CMICmdBase {
bool m_bHasCurrentThread;
CMICmnMIValue m_miValueCurrThreadId;
};

//++
//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "thread-select".
//--
class CMICmdCmdThreadSelect : public CMICmdBase {
// Statics:
public:
// Required by the CMICmdFactory when registering *this command
static CMICmdBase *CreateSelf();

// Methods:
public:
/* ctor */ CMICmdCmdThreadSelect();

// Overridden:
public:
// From CMICmdInvoker::ICmd
bool Execute() override;
bool Acknowledge() override;
bool ParseArgs() override;
// From CMICmnBase
/* dtor */ ~CMICmdCmdThreadSelect() override;

// Attributes:
private:
bool m_bThreadInvalid; // True = invalid, false = ok
const CMIUtilString m_constStrArgNamedThreadId;
};
1 change: 1 addition & 0 deletions src/MICmdCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ bool MICmnCommands::RegisterAll() {
bOk &= Register<CMICmdCmdTargetAttach>();
bOk &= Register<CMICmdCmdTargetDetach>();
bOk &= Register<CMICmdCmdThreadInfo>();
bOk &= Register<CMICmdCmdThreadSelect>();
bOk &= Register<CMICmdCmdVarAssign>();
bOk &= Register<CMICmdCmdVarCreate>();
bOk &= Register<CMICmdCmdVarDelete>();
Expand Down
Loading