summaryrefslogtreecommitdiffstats
path: root/lldb/tools/lldb-mi
diff options
context:
space:
mode:
authorIlia K <ki.stfu@gmail.com>2015-04-25 19:44:56 +0000
committerIlia K <ki.stfu@gmail.com>2015-04-25 19:44:56 +0000
commitaa82b4af84fb361077d3a984c1808fe7908d5c1f (patch)
tree6bc8da46f92c53130064261c27f678c54e362733 /lldb/tools/lldb-mi
parenta44b37e6760bb5a27fa57558065f3c7a64d155a0 (diff)
downloadbcm5719-llvm-aa82b4af84fb361077d3a984c1808fe7908d5c1f.tar.gz
bcm5719-llvm-aa82b4af84fb361077d3a984c1808fe7908d5c1f.zip
Add -gdb-set/-gdb-show print char-array-as-string option (MI)
llvm-svn: 235804
Diffstat (limited to 'lldb/tools/lldb-mi')
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp45
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdGdbSet.h1
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdGdbShow.cpp41
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdGdbShow.h1
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp1
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h1
-rw-r--r--lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp21
-rw-r--r--lldb/tools/lldb-mi/MICmnResources.cpp6
-rw-r--r--lldb/tools/lldb-mi/MICmnResources.h6
9 files changed, 118 insertions, 5 deletions
diff --git a/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp b/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp
index ace147597ce..b5202cf7789 100644
--- a/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp
@@ -21,6 +21,7 @@
// Instantiations:
const CMICmdCmdGdbSet::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbSet::ms_mapGdbOptionNameToFnGdbOptionPtr = {
{"target-async", &CMICmdCmdGdbSet::OptionFnTargetAsync},
+ {"print", &CMICmdCmdGdbSet::OptionFnPrint},
// { "auto-solib-add", &CMICmdCmdGdbSet::OptionFnAutoSolibAdd }, // Example code if need to implement GDB set other options
{"output-radix", &CMICmdCmdGdbSet::OptionFnOutputRadix},
{"solib-search-path", &CMICmdCmdGdbSet::OptionFnSolibSearchPath},
@@ -256,6 +257,50 @@ CMICmdCmdGdbSet::OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords)
}
//++ ------------------------------------------------------------------------------------
+// Details: Carry out work to complete the GDB set option 'print-char-array-as-string' 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::OptionFnPrint(const CMIUtilString::VecString_t &vrWords)
+{
+ const bool bAllArgs(vrWords.size() == 2);
+ const bool bArgOn(bAllArgs && (CMIUtilString::Compare(vrWords[1], "on") || CMIUtilString::Compare(vrWords[1], "1")));
+ const bool bArgOff(bAllArgs && (CMIUtilString::Compare(vrWords[1], "off") || CMIUtilString::Compare(vrWords[1], "0")));
+ if (!bAllArgs || (!bArgOn && !bArgOff))
+ {
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS);
+ return MIstatus::failure;
+ }
+
+ const CMIUtilString strOption(vrWords[0]);
+ CMIUtilString strOptionKey;
+ if (CMIUtilString::Compare(strOption, "char-array-as-string"))
+ strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintCharArrayAsString;
+ else
+ {
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION), strOption.c_str());
+ return MIstatus::failure;
+ }
+
+ const bool bOptionValue(bArgOn);
+ if (!m_rLLDBDebugSessionInfo.SharedDataAdd<bool>(strOptionKey, bOptionValue))
+ {
+ m_bGbbOptionFnHasError = false;
+ SetError(CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_ADD), m_cmdData.strMiCmd.c_str(), strOptionKey.c_str()));
+ return MIstatus::failure;
+ }
+
+ 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 3aa3e396757..0095f81838d 100644
--- a/lldb/tools/lldb-mi/MICmdCmdGdbSet.h
+++ b/lldb/tools/lldb-mi/MICmdCmdGdbSet.h
@@ -70,6 +70,7 @@ class CMICmdCmdGdbSet : public CMICmdBase
private:
bool GetOptionFn(const CMIUtilString &vrGdbOptionName, FnGdbOptionPtr &vrwpFn) const;
bool OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords);
+ bool OptionFnPrint(const CMIUtilString::VecString_t &vrWords);
bool OptionFnSolibSearchPath(const CMIUtilString::VecString_t &vrWords);
bool OptionFnOutputRadix(const CMIUtilString::VecString_t &vrWords);
bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords);
diff --git a/lldb/tools/lldb-mi/MICmdCmdGdbShow.cpp b/lldb/tools/lldb-mi/MICmdCmdGdbShow.cpp
index 73f5e8e14f6..41661c23e4a 100644
--- a/lldb/tools/lldb-mi/MICmdCmdGdbShow.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdGdbShow.cpp
@@ -21,6 +21,7 @@
// Instantiations:
const CMICmdCmdGdbShow::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbShow::ms_mapGdbOptionNameToFnGdbOptionPtr = {
{"target-async", &CMICmdCmdGdbShow::OptionFnTargetAsync},
+ {"print", &CMICmdCmdGdbShow::OptionFnPrint},
{"fallback", &CMICmdCmdGdbShow::OptionFnFallback}};
//++ ------------------------------------------------------------------------------------
@@ -239,6 +240,46 @@ CMICmdCmdGdbShow::OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords)
}
//++ ------------------------------------------------------------------------------------
+// Details: Carry out work to complete the GDB show option 'print' 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::OptionFnPrint(const CMIUtilString::VecString_t &vrWords)
+{
+ const bool bAllArgs(vrWords.size() == 1);
+ if (!bAllArgs)
+ {
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS);
+ return MIstatus::failure;
+ }
+
+ const CMIUtilString strOption(vrWords[0]);
+ CMIUtilString strOptionKey;
+ bool bOptionValueDefault = false;
+ if (CMIUtilString::Compare(strOption, "char-array-as-string"))
+ strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintCharArrayAsString;
+ else
+ {
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION), strOption.c_str());
+ return MIstatus::failure;
+ }
+
+ bool bOptionValue = false;
+ bOptionValue = bOptionValueDefault ? !m_rLLDBDebugSessionInfo.SharedDataRetrieve<bool>(strOptionKey, bOptionValue) || bOptionValue
+ : m_rLLDBDebugSessionInfo.SharedDataRetrieve<bool>(strOptionKey, bOptionValue) && bOptionValue;
+
+ m_strValue = bOptionValue ? "on" : "off";
+ return MIstatus::success;
+}
+
+//++ ------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB show option to prepare and send back the
// requested information.
// Type: Method.
diff --git a/lldb/tools/lldb-mi/MICmdCmdGdbShow.h b/lldb/tools/lldb-mi/MICmdCmdGdbShow.h
index 40d1b2f4aa0..3935e24fe26 100644
--- a/lldb/tools/lldb-mi/MICmdCmdGdbShow.h
+++ b/lldb/tools/lldb-mi/MICmdCmdGdbShow.h
@@ -67,6 +67,7 @@ class CMICmdCmdGdbShow : public CMICmdBase
private:
bool GetOptionFn(const CMIUtilString &vrGdbOptionName, FnGdbOptionPtr &vrwpFn) const;
bool OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords);
+ bool OptionFnPrint(const CMIUtilString::VecString_t &vrWords);
bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords);
// Attributes:
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
index 6ec49354190..63c9a183c04 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
@@ -40,6 +40,7 @@ CMICmnLLDBDebugSessionInfo::CMICmnLLDBDebugSessionInfo(void)
, m_currentSelectedThread(LLDB_INVALID_THREAD_ID)
, m_constStrSharedDataKeyWkDir("Working Directory")
, m_constStrSharedDataSolibPath("Solib Path")
+ , m_constStrPrintCharArrayAsString("Print CharArrayAsString")
{
}
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
index 48669bd78da..03ebc39aea3 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
@@ -183,6 +183,7 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC
// Note: This list is expected to grow and will be moved and abstracted in the future.
const CMIUtilString m_constStrSharedDataKeyWkDir;
const CMIUtilString m_constStrSharedDataSolibPath;
+ const CMIUtilString m_constStrPrintCharArrayAsString;
// Typedefs:
private:
diff --git a/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp b/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
index 7176aaab7b1..1fe907110dd 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
+++ b/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
@@ -144,10 +144,25 @@ CMICmnLLDBUtilSBValue::GetSimpleValue(const bool vbHandleArrayType, CMIUtilStrin
return MIstatus::success;
}
}
- else if (IsArrayType() && vbHandleArrayType)
+ else if (IsArrayType())
{
- vwrValue = CMIUtilString::Format("[%u]", nChildren);
- return MIstatus::success;
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ bool bPrintCharArrayAsString = false;
+ bPrintCharArrayAsString = rSessionInfo.SharedDataRetrieve<bool>(rSessionInfo.m_constStrPrintCharArrayAsString,
+ bPrintCharArrayAsString) && bPrintCharArrayAsString;
+ if (bPrintCharArrayAsString && m_bHandleCharType && IsFirstChildCharType())
+ {
+ // TODO: to match char* it should be the following
+ // vwrValue = CMIUtilString::Format("[%u] \"%s\"", nChildren, prefix.c_str());
+ const CMIUtilString prefix(GetValueCString().Escape().AddSlashes());
+ vwrValue = CMIUtilString::Format("\"%s\"", prefix.c_str());
+ return MIstatus::success;
+ }
+ else if (vbHandleArrayType)
+ {
+ vwrValue = CMIUtilString::Format("[%u]", nChildren);
+ return MIstatus::success;
+ }
}
// Composite variable type i.e. struct
diff --git a/lldb/tools/lldb-mi/MICmnResources.cpp b/lldb/tools/lldb-mi/MICmnResources.cpp
index 798036cfde7..65543fea3f7 100644
--- a/lldb/tools/lldb-mi/MICmnResources.cpp
+++ b/lldb/tools/lldb-mi/MICmnResources.cpp
@@ -244,7 +244,11 @@ const CMICmnResources::SRsrcTextData CMICmnResources::ms_pResourceId2TextData[]
{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"}};
+ {IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH, "'solib-search-path' requires at least one argument"},
+ {IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS, "'print' expects option-name and \"on\" or \"off\""},
+ {IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION, "'print' error. The option '%s' not found"},
+ {IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS, "'print' expects option-name and \"on\" or \"off\""},
+ {IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION, "'print' error. The option '%s' not found"}};
//++ ------------------------------------------------------------------------------------
// Details: CMICmnResources constructor.
diff --git a/lldb/tools/lldb-mi/MICmnResources.h b/lldb/tools/lldb-mi/MICmnResources.h
index 6064da62a78..ebcc2d15e13 100644
--- a/lldb/tools/lldb-mi/MICmnResources.h
+++ b/lldb/tools/lldb-mi/MICmnResources.h
@@ -262,7 +262,11 @@ enum
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
+ IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH,
+ IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS,
+ IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION,
+ IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS,
+ IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION
};
//++ ============================================================================
OpenPOWER on IntegriCloud