Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
tools/lldb-mi/MICmdCmdExec.cpp
Show All 12 Lines | |||||
// Overview: CMICmdCmdExecRun implementation. | // Overview: CMICmdCmdExecRun implementation. | ||||
// CMICmdCmdExecContinue implementation. | // CMICmdCmdExecContinue implementation. | ||||
// CMICmdCmdExecNext implementation. | // CMICmdCmdExecNext implementation. | ||||
// CMICmdCmdExecStep implementation. | // CMICmdCmdExecStep implementation. | ||||
// CMICmdCmdExecNextInstruction implementation. | // CMICmdCmdExecNextInstruction implementation. | ||||
// CMICmdCmdExecStepInstruction implementation. | // CMICmdCmdExecStepInstruction implementation. | ||||
// CMICmdCmdExecFinish implementation. | // CMICmdCmdExecFinish implementation. | ||||
// CMICmdCmdExecInterrupt implementation. | // CMICmdCmdExecInterrupt implementation. | ||||
// CMICmdCmdExecArguments implementation. | |||||
// | // | ||||
// Environment: Compilers: Visual C++ 12. | // Environment: Compilers: Visual C++ 12. | ||||
// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 | // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 | ||||
// Libraries: See MIReadmetxt. | // Libraries: See MIReadmetxt. | ||||
// | // | ||||
// Copyright: None. | // Copyright: None. | ||||
//-- | //-- | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
// Throws: None. | // Throws: None. | ||||
//-- | //-- | ||||
bool | bool | ||||
CMICmdCmdExecRun::Execute(void) | CMICmdCmdExecRun::Execute(void) | ||||
{ | { | ||||
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); | CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); | ||||
lldb::SBError error; | lldb::SBError error; | ||||
lldb::SBStream errMsg; | lldb::SBStream errMsg; | ||||
uint32_t launch_flags = lldb::LaunchFlags::eLaunchFlagDebug; | lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo(); | ||||
lldb::SBProcess process = rSessionInfo.GetTarget().Launch(rSessionInfo.GetListener(), nullptr, nullptr, nullptr, nullptr, | launchInfo.SetListener(rSessionInfo.GetListener()); | ||||
nullptr, nullptr, launch_flags, false, error); | lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error); | ||||
if ((!process.IsValid()) || (error.Fail())) | if ((!process.IsValid()) || (error.Fail())) | ||||
{ | { | ||||
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str(), errMsg.GetData())); | SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str(), errMsg.GetData())); | ||||
clayborg: If we store a SBLaunchInfo in CMICmnLLDBDebugSessionInfo then this becomes:
```
lldb… | |||||
return MIstatus::failure; | return MIstatus::failure; | ||||
} | } | ||||
if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) | if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) | ||||
{ | { | ||||
const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); | const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); | ||||
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str())); | SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str())); | ||||
return MIstatus::failure; | return MIstatus::failure; | ||||
▲ Show 20 Lines • Show All 903 Lines • ▼ Show 20 Lines | |||||
// Return: CMICmdBase * - Pointer to a new command. | // Return: CMICmdBase * - Pointer to a new command. | ||||
// Throws: None. | // Throws: None. | ||||
//-- | //-- | ||||
CMICmdBase * | CMICmdBase * | ||||
CMICmdCmdExecInterrupt::CreateSelf(void) | CMICmdCmdExecInterrupt::CreateSelf(void) | ||||
{ | { | ||||
return new CMICmdCmdExecInterrupt(); | return new CMICmdCmdExecInterrupt(); | ||||
} | } | ||||
//--------------------------------------------------------------------------------------- | |||||
//--------------------------------------------------------------------------------------- | |||||
//--------------------------------------------------------------------------------------- | |||||
//++ ------------------------------------------------------------------------------------ | |||||
// Details: CMICmdCmdExecArguments constructor. | |||||
// Type: Method. | |||||
// Args: None. | |||||
// Return: None. | |||||
// Throws: None. | |||||
//-- | |||||
CMICmdCmdExecArguments::CMICmdCmdExecArguments(void) | |||||
: m_constStrArgArguments("arguments") | |||||
{ | |||||
// Command factory matches this name with that received from the stdin stream | |||||
m_strMiCmd = "exec-arguments"; | |||||
// Required by the CMICmdFactory when registering *this command | |||||
m_pSelfCreatorFn = &CMICmdCmdExecArguments::CreateSelf; | |||||
} | |||||
//++ ------------------------------------------------------------------------------------ | |||||
// Details: CMICmdCmdExecArguments destructor. | |||||
// Type: Overrideable. | |||||
// Args: None. | |||||
// Return: None. | |||||
// Throws: None. | |||||
//-- | |||||
CMICmdCmdExecArguments::~CMICmdCmdExecArguments(void) | |||||
{ | |||||
} | |||||
//++ ------------------------------------------------------------------------------------ | |||||
// 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 - Function succeeded. | |||||
// MIstatus::failure - Function failed. | |||||
// Throws: None. | |||||
//-- | |||||
bool | |||||
CMICmdCmdExecArguments::ParseArgs(void) | |||||
{ | |||||
bool bOk = m_setCmdArgs.Add( | |||||
*(new CMICmdArgValListOfN(m_constStrArgArguments, false, true, CMICmdArgValListBase::eArgValType_StringAnything))); | |||||
return (bOk && 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 - Function succeeded. | |||||
// MIstatus::failure - Function failed. | |||||
// Throws: None. | |||||
//-- | |||||
bool | |||||
CMICmdCmdExecArguments::Execute(void) | |||||
{ | |||||
CMICMDBASE_GETOPTION(pArgArguments, ListOfN, m_constStrArgArguments); | |||||
CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); | |||||
lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); | |||||
if (!sbTarget.IsValid()) | |||||
{ | |||||
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), m_cmdData.strMiCmd.c_str())); | |||||
return MIstatus::failure; | |||||
} | |||||
lldb::SBLaunchInfo sbLaunchInfo = sbTarget.GetLaunchInfo(); | |||||
sbLaunchInfo.SetArguments(NULL, false); | |||||
CMIUtilString strArg; | |||||
size_t nArgIndex = 0; | |||||
while (pArgArguments->GetExpectedOption<CMICmdArgValString, CMIUtilString>(strArg, nArgIndex)) | |||||
{ | |||||
const char *argv[2] = { strArg.c_str(), NULL }; | |||||
sbLaunchInfo.SetArguments(argv, true); | |||||
++nArgIndex; | |||||
} | |||||
sbTarget.SetLaunchInfo(sbLaunchInfo); | |||||
return MIstatus::success; | |||||
} | |||||
//++ ------------------------------------------------------------------------------------ | |||||
// Details: The invoker requires this function. The command prepares a MI Record Result | |||||
// for the work carried out in the Execute(). | |||||
Not Done ReplyInline ActionsIf we store a SBLaunchInfo in CMICmnLLDBDebugSessionInfo we can turn this function into: bool CMICmdCmdExecArguments::Execute(void) { CMICMDBASE_GETOPTION(pArgArguments, ListOfN, m_constStrArgArguments); CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); const char *argv[2] = { nullptr, nullptr }; const bool append = true; CMIUtilString strArg; size_t nArgIndex = 0; while (pArgArguments->GetExpectedOption<CMICmdArgValString, CMIUtilString>(strArg, nArgIndex)) { argv[0] = strArg.c_str(); rSessionInfo.m_lldbLaunchInfo.SetArguments (argv, append); ++nArgIndex; } return MIstatus::success; } clayborg: If we store a SBLaunchInfo in CMICmnLLDBDebugSessionInfo we can turn this function into:
```… | |||||
// Type: Overridden. | |||||
// Args: None. | |||||
// Return: MIstatus::success - Function succeeded. | |||||
// MIstatus::failure - Function failed. | |||||
// Throws: None. | |||||
//-- | |||||
bool | |||||
CMICmdCmdExecArguments::Acknowledge(void) | |||||
{ | |||||
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 * | |||||
CMICmdCmdExecArguments::CreateSelf(void) | |||||
{ | |||||
return new CMICmdCmdExecArguments(); | |||||
} |
If we store a SBLaunchInfo in CMICmnLLDBDebugSessionInfo then this becomes:
And the SBLaunchInfo doesn't require the lldb::LaunchFlags::eLaunchFlagDebug as that is implied by the launch itself. You can set it in the m_lldbLaunchInfo if you want when you construct it inside CMICmnLLDBDebugSessionInfo.