Index: packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py =================================================================== --- packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py +++ packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py @@ -249,3 +249,29 @@ self.expect("\^done") self.runCmd("-data-disassemble -s %d -e %d -- 0" % (s_addr, e_addr)) self.expect("movl ") + + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + def test_lldbmi_gdb_set_show_non_stop(self): + """Test that 'lldb-mi --interpreter' can turn on and off non-stop mode.""" + + self.spawnLldbMi(args=None) + + # default is off + self.runCmd("-gdb-show non-stop") + self.expect("\^done,value=\"off\"") + + # turn on non-stop mode + self.runCmd("-gdb-set non-stop on") + self.expect("\^done") + self.runCmd("-gdb-show non-stop") + self.expect("\^done,value=\"on\"") + + # turn off non-stop mode + self.runCmd("-gdb-set non-stop off") + self.expect("\^done") + self.runCmd("-gdb-show non-stop") + self.expect("\^done,value=\"off\"") + Index: tools/lldb-mi/MICmdCmdGdbSet.h =================================================================== --- tools/lldb-mi/MICmdCmdGdbSet.h +++ tools/lldb-mi/MICmdCmdGdbSet.h @@ -81,6 +81,7 @@ bool OptionFnOutputRadix(const CMIUtilString::VecString_t &vrWords); bool OptionFnDisassemblyFlavor(const CMIUtilString::VecString_t &vrWords); bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords); + bool OptionFnNonStop(const CMIUtilString::VecString_t &vrWords); // Attributes: private: Index: tools/lldb-mi/MICmdCmdGdbSet.cpp =================================================================== --- tools/lldb-mi/MICmdCmdGdbSet.cpp +++ tools/lldb-mi/MICmdCmdGdbSet.cpp @@ -28,6 +28,7 @@ {"output-radix", &CMICmdCmdGdbSet::OptionFnOutputRadix}, {"solib-search-path", &CMICmdCmdGdbSet::OptionFnSolibSearchPath}, {"disassembly-flavor", &CMICmdCmdGdbSet::OptionFnDisassemblyFlavor}, + {"non-stop", &CMICmdCmdGdbSet::OptionFnNonStop}, {"fallback", &CMICmdCmdGdbSet::OptionFnFallback}}; //++ @@ -453,3 +454,49 @@ return MIstatus::success; } + +//++ +//------------------------------------------------------------------------------------ +// Details: Carry out work to complete the GDB set option 'non-stop' to +// prepare and send back information asked for. +// Type: Method. +// Args: vrWords - (R) List of additional parameters used by this option. +// Return: MIstatus::success - Function succeeded. +// MIstatus::failure - Function failed. +// Throws: None. +//-- +bool CMICmdCmdGdbSet::OptionFnNonStop( + const CMIUtilString::VecString_t &vrWords) { + bool bOk = true; + const char *strValue; + + if (vrWords.size() > 1) + // Too many arguments. + bOk = false; + else if (vrWords.size() == 0) + // If no arguments, default is "on". + strValue = "true"; + else if (CMIUtilString::Compare(vrWords[0], "on")) + strValue = "true"; + else if (CMIUtilString::Compare(vrWords[0], "off")) + strValue = "false"; + else + // Unrecognized argument. + bOk = false; + + if (!bOk) { + // Report error. + m_bGbbOptionFnHasError = true; + m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSET_OPT_NONSTOP); + return MIstatus::failure; + } + + lldb::SBDebugger &rDbgr = m_rLLDBDebugSessionInfo.GetDebugger(); + lldb::SBError error = lldb::SBDebugger::SetInternalVariable( + "target.non-stop-mode", strValue, rDbgr.GetInstanceName()); + if (error.Fail()) { + m_strGdbOptionFnError = error.GetCString(); + return MIstatus::failure; + } + return MIstatus::success; +} Index: tools/lldb-mi/MICmdCmdGdbShow.h =================================================================== --- tools/lldb-mi/MICmdCmdGdbShow.h +++ tools/lldb-mi/MICmdCmdGdbShow.h @@ -80,6 +80,7 @@ bool OptionFnLanguage(const CMIUtilString::VecString_t &vrWords); bool OptionFnDisassemblyFlavor(const CMIUtilString::VecString_t &vrWords); bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords); + bool OptionFnNonStop(const CMIUtilString::VecString_t &vrWords); // Attributes: private: Index: tools/lldb-mi/MICmdCmdGdbShow.cpp =================================================================== --- tools/lldb-mi/MICmdCmdGdbShow.cpp +++ tools/lldb-mi/MICmdCmdGdbShow.cpp @@ -25,6 +25,8 @@ #include "MICmnMIResultRecord.h" #include "MICmnMIValueConst.h" +#include + // Instantiations: const CMICmdCmdGdbShow::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbShow::ms_mapGdbOptionNameToFnGdbOptionPtr = { @@ -32,6 +34,7 @@ {"print", &CMICmdCmdGdbShow::OptionFnPrint}, {"language", &CMICmdCmdGdbShow::OptionFnLanguage}, {"disassembly-flavor", &CMICmdCmdGdbShow::OptionFnDisassemblyFlavor}, + {"non-stop", &CMICmdCmdGdbShow::OptionFnNonStop}, {"fallback", &CMICmdCmdGdbShow::OptionFnFallback}}; //++ @@ -329,7 +332,8 @@ //++ //------------------------------------------------------------------------------------ -// Details: Carry out work to complete the GDB show option 'disassembly-flavor' to prepare +// Details: Carry out work to complete the GDB show option 'disassembly-flavor' +// to prepare // and send back the requested information. // Type: Method. // Args: vrWords - (R) List of additional parameters used by this option. @@ -337,13 +341,42 @@ // MIstatus::failure - Function failed. // Throws: None. //-- -bool CMICmdCmdGdbShow::OptionFnDisassemblyFlavor(const CMIUtilString::VecString_t &vrWords) { +bool CMICmdCmdGdbShow::OptionFnDisassemblyFlavor( + const CMIUtilString::VecString_t &vrWords) { MIunused(vrWords); // Get current disassembly flavor lldb::SBDebugger &rDbgr = m_rLLDBDebugSessionInfo.GetDebugger(); - m_strValue = lldb::SBDebugger::GetInternalVariableValue("target.x86-disassembly-flavor", - rDbgr.GetInstanceName()).GetStringAtIndex(0); + m_strValue = lldb::SBDebugger::GetInternalVariableValue( + "target.x86-disassembly-flavor", rDbgr.GetInstanceName()) + .GetStringAtIndex(0); + return MIstatus::success; +} + +//++ +//------------------------------------------------------------------------------------ +// Details: Carry out work to complete the GDB show option 'non-stop' to +// prepare and send back the requested information. +// Type: Method. +// Args: vrWords - (R) List of additional parameters used by this option. +// Return: MIstatus::success - Function succeeded. +// MIstatus::failure - Function failed. +// Throws: None. +//-- +bool CMICmdCmdGdbShow::OptionFnNonStop( + const CMIUtilString::VecString_t &vrWords) { + MIunused(vrWords); + + lldb::SBDebugger &rDbgr = m_rLLDBDebugSessionInfo.GetDebugger(); + const char *strValue = lldb::SBDebugger::GetInternalVariableValue( + "target.non-stop-mode", rDbgr.GetInstanceName()) + .GetStringAtIndex(0); + + if (!::strcmp(strValue, "true")) + m_strValue = "on"; + else + m_strValue = "off"; + return MIstatus::success; } Index: tools/lldb-mi/MICmnResources.h =================================================================== --- tools/lldb-mi/MICmnResources.h +++ tools/lldb-mi/MICmnResources.h @@ -264,6 +264,7 @@ IDS_CMD_ERR_INFO_PRINTFN_FAILED, IDS_CMD_ERR_GDBSET_OPT_TARGETASYNC, IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH, + IDS_CMD_ERR_GDBSET_OPT_NONSTOP, IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS, IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION, IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS, Index: tools/lldb-mi/MICmnResources.cpp =================================================================== --- tools/lldb-mi/MICmnResources.cpp +++ tools/lldb-mi/MICmnResources.cpp @@ -439,6 +439,8 @@ "'target-async' expects \"on\" or \"off\""}, {IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH, "'solib-search-path' requires at least one argument"}, + {IDS_CMD_ERR_GDBSET_OPT_NONSTOP, + "'non-stop' expects \"on\" or \"off\""}, {IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS, "'print' expects option-name and \"on\" or \"off\""}, {IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION,