summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlia K <ki.stfu@gmail.com>2015-04-25 20:10:02 +0000
committerIlia K <ki.stfu@gmail.com>2015-04-25 20:10:02 +0000
commit81bd06d787f9934f4ee8bd491b7ea389c9b05019 (patch)
tree81bfede6fefab64949434c874ca4d1af69606f83
parentaa82b4af84fb361077d3a984c1808fe7908d5c1f (diff)
downloadbcm5719-llvm-81bd06d787f9934f4ee8bd491b7ea389c9b05019.tar.gz
bcm5719-llvm-81bd06d787f9934f4ee8bd491b7ea389c9b05019.zip
Add -gdb-set/-gdb-show expand-aggregates option (MI)
Use this option to expand complex types always: ``` -var-create var1 * complx ^done,name="var1",numchild="3",value="{...}",type="complex_type",thread-id="1",has_more="0" -var-create var2 * complx_array ^done,name="var2",numchild="2",value="[2]",type="complex_type [2]",thread-id="1",has_more="0" -gdb-set print expand-aggregates on ^done -var-create var3 * complx ^done,name="var3",numchild="3",value="{i = 3, inner = {l = 3}, complex_ptr = 0x[0-9a-f]+}",type="complex_type",thread-id="1",has_more="0" -var-create var4 * complx_array ^done,name="var4",numchild="2",value="{[0] = {i = 4, inner = {l = 4}, complex_ptr = 0x[0-9a-f]+}, [1] = {i = 5, inner = {l = 5}, complex_ptr = 0x[0-9a-f]+}}",type="complex_type [2]",thread-id="1",has_more="0" ``` llvm-svn: 235805
-rw-r--r--lldb/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py55
-rw-r--r--lldb/test/tools/lldb-mi/variable/main.cpp10
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp2
-rw-r--r--lldb/tools/lldb-mi/MICmdCmdGdbShow.cpp2
-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.cpp9
7 files changed, 78 insertions, 2 deletions
diff --git a/lldb/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py b/lldb/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
index 19284468137..938e2425560 100644
--- a/lldb/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
+++ b/lldb/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
@@ -65,5 +65,60 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-gdb-set print char-array-as-string unknown")
self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
+ @lldbmi_test
+ @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+ def test_lldbmi_gdb_set_show_print_expand_aggregates(self):
+ """Test that 'lldb-mi --interpreter' can expand aggregates everywhere."""
+
+ self.spawnLldbMi(args = None)
+
+ # Load executable
+ self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+ self.expect("\^done")
+
+ # Run to BP_gdb_set_show_print_expand_aggregates
+ line = line_number('main.cpp', '// BP_gdb_set_show_print_expand_aggregates')
+ self.runCmd("-break-insert main.cpp:%d" % line)
+ self.expect("\^done,bkpt={number=\"1\"")
+ self.runCmd("-exec-run")
+ self.expect("\^running")
+ self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+ # Test that default print expand-aggregates value is "off"
+ self.runCmd("-gdb-show print expand-aggregates")
+ self.expect("\^done,value=\"off\"")
+
+ # Test that composite type isn't expanded when print expand-aggregates is "off"
+ self.runCmd("-var-create var1 * complx")
+ self.expect("\^done,name=\"var1\",numchild=\"3\",value=\"{\.\.\.}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
+
+ # Test that composite type[] isn't expanded when print expand-aggregates is "off"
+ self.runCmd("-var-create var2 * complx_array")
+ self.expect("\^done,name=\"var2\",numchild=\"2\",value=\"\[2\]\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
+
+ # Test that -gdb-set can set print expand-aggregates flag
+ self.runCmd("-gdb-set print expand-aggregates on")
+ self.expect("\^done")
+ self.runCmd("-gdb-set print expand-aggregates 1")
+ self.expect("\^done")
+ self.runCmd("-gdb-show print expand-aggregates")
+ self.expect("\^done,value=\"on\"")
+
+ # Test that composite type is expanded when print expand-aggregates is "on"
+ self.runCmd("-var-create var3 * complx")
+ self.expect("\^done,name=\"var3\",numchild=\"3\",value=\"{i = 3, inner = {l = 3}, complex_ptr = 0x[0-9a-f]+}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
+
+ # Test that composite type[] is expanded when print expand-aggregates is "on"
+ self.runCmd("-var-create var4 * complx_array")
+ self.expect("\^done,name=\"var4\",numchild=\"2\",value=\"{\[0\] = {i = 4, inner = {l = 4}, complex_ptr = 0x[0-9a-f]+}, \[1\] = {i = 5, inner = {l = 5}, complex_ptr = 0x[0-9a-f]+}}\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
+
+ # Test that -gdb-set print expand-aggregates fails if "on"/"off" isn't specified
+ self.runCmd("-gdb-set print expand-aggregates")
+ self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
+
+ # Test that -gdb-set print expand-aggregates fails when option is unknown
+ self.runCmd("-gdb-set print expand-aggregates unknown")
+ self.expect("\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"")
+
if __name__ == '__main__':
unittest2.main()
diff --git a/lldb/test/tools/lldb-mi/variable/main.cpp b/lldb/test/tools/lldb-mi/variable/main.cpp
index a61baa56103..294f54542d7 100644
--- a/lldb/test/tools/lldb-mi/variable/main.cpp
+++ b/lldb/test/tools/lldb-mi/variable/main.cpp
@@ -43,6 +43,15 @@ gdb_set_show_print_char_array_as_string_test(void)
// BP_gdb_set_show_print_char_array_as_string_test
}
+void
+gdb_set_show_print_expand_aggregates(void)
+{
+ complex_type complx = { 3, { 3L }, &complx };
+ complex_type complx_array[2] = { { 4, { 4L }, &complx_array[1] }, { 5, { 5 }, &complx_array[0] } };
+
+ // BP_gdb_set_show_print_expand_aggregates
+}
+
int g_MyVar = 3;
static int s_MyVar = 4;
@@ -53,5 +62,6 @@ main(int argc, char const *argv[])
s_MyVar = a + b;
var_update_test();
gdb_set_show_print_char_array_as_string_test();
+ gdb_set_show_print_expand_aggregates();
return 0; // BP_return
}
diff --git a/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp b/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp
index b5202cf7789..dde01fb4037 100644
--- a/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdGdbSet.cpp
@@ -282,6 +282,8 @@ CMICmdCmdGdbSet::OptionFnPrint(const CMIUtilString::VecString_t &vrWords)
CMIUtilString strOptionKey;
if (CMIUtilString::Compare(strOption, "char-array-as-string"))
strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintCharArrayAsString;
+ else if (CMIUtilString::Compare(strOption, "expand-aggregates"))
+ strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintExpandAggregates;
else
{
m_bGbbOptionFnHasError = true;
diff --git a/lldb/tools/lldb-mi/MICmdCmdGdbShow.cpp b/lldb/tools/lldb-mi/MICmdCmdGdbShow.cpp
index 41661c23e4a..df2bfcff67d 100644
--- a/lldb/tools/lldb-mi/MICmdCmdGdbShow.cpp
+++ b/lldb/tools/lldb-mi/MICmdCmdGdbShow.cpp
@@ -264,6 +264,8 @@ CMICmdCmdGdbShow::OptionFnPrint(const CMIUtilString::VecString_t &vrWords)
bool bOptionValueDefault = false;
if (CMIUtilString::Compare(strOption, "char-array-as-string"))
strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintCharArrayAsString;
+ else if (CMIUtilString::Compare(strOption, "expand-aggregates"))
+ strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintExpandAggregates;
else
{
m_bGbbOptionFnHasError = true;
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
index 63c9a183c04..f65fbe2b00a 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
@@ -41,6 +41,7 @@ CMICmnLLDBDebugSessionInfo::CMICmnLLDBDebugSessionInfo(void)
, m_constStrSharedDataKeyWkDir("Working Directory")
, m_constStrSharedDataSolibPath("Solib Path")
, m_constStrPrintCharArrayAsString("Print CharArrayAsString")
+ , m_constStrPrintExpandAggregates("Print ExpandAggregates")
{
}
diff --git a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
index 03ebc39aea3..2f9ae0c9b04 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
+++ b/lldb/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
@@ -184,6 +184,7 @@ class CMICmnLLDBDebugSessionInfo : public CMICmnBase, public MI::ISingleton<CMIC
const CMIUtilString m_constStrSharedDataKeyWkDir;
const CMIUtilString m_constStrSharedDataSolibPath;
const CMIUtilString m_constStrPrintCharArrayAsString;
+ const CMIUtilString m_constStrPrintExpandAggregates;
// Typedefs:
private:
diff --git a/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp b/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
index 1fe907110dd..ea5965ec165 100644
--- a/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
+++ b/lldb/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
@@ -77,13 +77,18 @@ CMICmnLLDBUtilSBValue::GetValue(const bool vbExpandAggregates /* = false */) con
if (!m_bValidSBValue)
return m_pUnkwn;
- const bool bHandleArrayTypeAsSimple = m_bHandleArrayType && !vbExpandAggregates;
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ bool bPrintExpandAggregates = false;
+ bPrintExpandAggregates = rSessionInfo.SharedDataRetrieve<bool>(rSessionInfo.m_constStrPrintExpandAggregates,
+ bPrintExpandAggregates) && bPrintExpandAggregates;
+
+ const bool bHandleArrayTypeAsSimple = m_bHandleArrayType && !vbExpandAggregates && !bPrintExpandAggregates;
CMIUtilString value;
const bool bIsSimpleValue = GetSimpleValue(bHandleArrayTypeAsSimple, value);
if (bIsSimpleValue)
return value;
- if (!vbExpandAggregates)
+ if (!vbExpandAggregates && !bPrintExpandAggregates)
return m_pComposite;
CMICmnMIValueTuple miValueTuple;
OpenPOWER on IntegriCloud