From fd77f8cf80bb3eef670c0dbb8a74ed7f06dd62f8 Mon Sep 17 00:00:00 2001 From: Ilia K Date: Mon, 23 Mar 2015 20:49:51 +0000 Subject: [PATCH] Add target-async option in -gdb-set command (MI) llvm-svn: 233018 --- lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp | 46 ++++++++++++++++++++++++++++++++++- lldb/tools/lldb-mi/MICmdCmdGdbSet.h | 1 + lldb/tools/lldb-mi/MICmnResources.cpp | 1 + lldb/tools/lldb-mi/MICmnResources.h | 1 + 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp b/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp index 169d60c..44cc955 100644 --- a/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp @@ -20,7 +20,7 @@ // Instantiations: const CMICmdCmdGdbSet::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbSet::ms_mapGdbOptionNameToFnGdbOptionPtr = { - // { "target-async", &CMICmdCmdGdbSet::OptionFnTargetAsync }, // Example code if need to implement GDB set other options + {"target-async", &CMICmdCmdGdbSet::OptionFnTargetAsync}, // { "auto-solib-add", &CMICmdCmdGdbSet::OptionFnAutoSolibAdd }, // Example code if need to implement GDB set other options {"solib-search-path", &CMICmdCmdGdbSet::OptionFnSolibSearchPath}, {"fallback", &CMICmdCmdGdbSet::OptionFnFallback}}; @@ -210,6 +210,50 @@ CMICmdCmdGdbSet::GetOptionFn(const CMIUtilString &vrPrintFnName, FnGdbOptionPtr } //++ ------------------------------------------------------------------------------------ +// Details: Carry out work to complete the GDB set option 'target-async' 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::OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords) +{ + bool bAsyncMode; + bool bOk = true; + + if (vrWords.size() > 1) + // Too many arguments. + bOk = false; + else if (vrWords.size() == 0) + // If no arguments, default is "on". + bAsyncMode = true; + else if (CMIUtilString::Compare(vrWords[0], "on")) + bAsyncMode = true; + else if (CMIUtilString::Compare(vrWords[0], "off")) + bAsyncMode = false; + else + // Unrecognized argument. + bOk = false; + + if (!bOk) + { + // Report error. + m_bGbbOptionFnHasError = true; + m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSET_OPT_TARGETASYNC); + return MIstatus::failure; + } + + // Turn async mode on/off. + CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); + rSessionInfo.GetDebugger().SetAsync(bAsyncMode); + + return MIstatus::success; +} + +//++ ------------------------------------------------------------------------------------ // Details: Carry out work to complete the GDB set option 'solib-search-path' to prepare // and send back information asked for. // Type: Method. diff --git a/lldb/tools/lldb-mi/MICmdCmdGdbSet.h b/lldb/tools/lldb-mi/MICmdCmdGdbSet.h index f084002..d9684bd 100644 --- a/lldb/tools/lldb-mi/MICmdCmdGdbSet.h +++ b/lldb/tools/lldb-mi/MICmdCmdGdbSet.h @@ -69,6 +69,7 @@ class CMICmdCmdGdbSet : public CMICmdBase // Methods: private: bool GetOptionFn(const CMIUtilString &vrGdbOptionName, FnGdbOptionPtr &vrwpFn) const; + bool OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords); bool OptionFnSolibSearchPath(const CMIUtilString::VecString_t &vrWords); bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords); diff --git a/lldb/tools/lldb-mi/MICmnResources.cpp b/lldb/tools/lldb-mi/MICmnResources.cpp index 784847c..69420ba 100644 --- a/lldb/tools/lldb-mi/MICmnResources.cpp +++ b/lldb/tools/lldb-mi/MICmnResources.cpp @@ -243,6 +243,7 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[] {IDS_CMD_ERR_SET_NEW_DRIVER_STATE, "Command '%s'. Command tried to set new MI Driver running state and failed. %s"}, {IDS_CMD_ERR_INFO_PRINTFN_NOT_FOUND, "The request '%s' was not recogised, not implemented"}, {IDS_CMD_ERR_INFO_PRINTFN_FAILED, "The request '%s' failed."}, + {IDS_CMD_ERR_GDBSET_OPT_TARGETASYNC, "'target-async' expects \"on\" or \"off\""}, {IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH, "'solib-search-path' requires at least one argument"}}; //++ ------------------------------------------------------------------------------------ diff --git a/lldb/tools/lldb-mi/MICmnResources.h b/lldb/tools/lldb-mi/MICmnResources.h index e1d8aea..6852303 100644 --- a/lldb/tools/lldb-mi/MICmnResources.h +++ b/lldb/tools/lldb-mi/MICmnResources.h @@ -261,6 +261,7 @@ enum IDS_CMD_ERR_SET_NEW_DRIVER_STATE, IDS_CMD_ERR_INFO_PRINTFN_NOT_FOUND, IDS_CMD_ERR_INFO_PRINTFN_FAILED, + IDS_CMD_ERR_GDBSET_OPT_TARGETASYNC, IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH }; -- 2.7.4