summaryrefslogtreecommitdiffstats
path: root/lldb/test/python_api
diff options
context:
space:
mode:
authorSiva Chandra <sivachandra@google.com>2015-07-24 21:30:58 +0000
committerSiva Chandra <sivachandra@google.com>2015-07-24 21:30:58 +0000
commitd26eb907bc5970c12d096b3d668909134502f102 (patch)
treec77c9e58c928a45629dbd54e06fe5574abd435de /lldb/test/python_api
parentfd4dfdcea1c9f52f4fc75c5c6d3d4acc078eb9f2 (diff)
downloadbcm5719-llvm-d26eb907bc5970c12d096b3d668909134502f102.tar.gz
bcm5719-llvm-d26eb907bc5970c12d096b3d668909134502f102.zip
Add option eTypeOptionHideEmptyAggregates.
Summary: For certain data structures, when the synthetic child provider returns zero children, a summary like "Empty instance of <typename>" could be more appropriate than something like "size=0 {}". This new option helps hide the trailing "{}". This is also exposed with a -h option for the command "type summary add". Reviewers: granata.enrico Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D11473 llvm-svn: 243166
Diffstat (limited to 'lldb/test/python_api')
-rw-r--r--lldb/test/python_api/formatters/TestFormattersSBAPI.py4
-rw-r--r--lldb/test/python_api/formatters/main.cpp6
-rw-r--r--lldb/test/python_api/formatters/synth.py45
3 files changed, 53 insertions, 2 deletions
diff --git a/lldb/test/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/python_api/formatters/TestFormattersSBAPI.py
index b8806abf314..854b3acae58 100644
--- a/lldb/test/python_api/formatters/TestFormattersSBAPI.py
+++ b/lldb/test/python_api/formatters/TestFormattersSBAPI.py
@@ -302,6 +302,10 @@ class SBFormattersAPITestCase(TestBase):
self.assertTrue(summary.IsValid(), "no summary found for foo* when one was in place")
self.assertTrue(summary.GetData() == "hello static world", "wrong summary found for foo*")
+ self.expect("frame variable e1", substrs=["I am an empty Empty1 {}"])
+ self.expect("frame variable e2", substrs=["I am an empty Empty2"])
+ self.expect("frame variable e2", substrs=["I am an empty Empty2 {}"], matching=False)
+
def force_synth_off(self):
"""Test that one can have the public API return non-synthetic SBValues if desired"""
self.runCmd("file no_synth", CURRENT_EXECUTABLE_SET)
diff --git a/lldb/test/python_api/formatters/main.cpp b/lldb/test/python_api/formatters/main.cpp
index cf7e4c08ef8..f21c956144c 100644
--- a/lldb/test/python_api/formatters/main.cpp
+++ b/lldb/test/python_api/formatters/main.cpp
@@ -26,6 +26,9 @@ struct CCC
int a, b, c;
};
+struct Empty1 { void *data; };
+struct Empty2 { void *data; };
+
int main(int argc, char const *argv[]) {
JustAStruct foo;
@@ -49,5 +52,8 @@ int main(int argc, char const *argv[]) {
CCC ccc = {111, 222, 333};
+ Empty1 e1;
+ Empty2 e2;
+
return 0; // Set break point at this line.
}
diff --git a/lldb/test/python_api/formatters/synth.py b/lldb/test/python_api/formatters/synth.py
index b1e95a91f67..5a30c9a94bb 100644
--- a/lldb/test/python_api/formatters/synth.py
+++ b/lldb/test/python_api/formatters/synth.py
@@ -48,6 +48,36 @@ class CCCSynthProvider(object):
return self._sbvalue.GetChildMemberWithName("c")
+def empty1_summary(sbvalue, internal_dict):
+ return "I am an empty Empty1"
+
+
+class Empty1SynthProvider(object):
+ def __init__(self, sbvalue, internal_dict):
+ self._sbvalue = sbvalue
+
+ def num_children(self):
+ return 0
+
+ def get_child_at_index(self, index):
+ return None
+
+
+def empty2_summary(sbvalue, internal_dict):
+ return "I am an empty Empty2"
+
+
+class Empty2SynthProvider(object):
+ def __init__(self, sbvalue, internal_dict):
+ self._sbvalue = sbvalue
+
+ def num_children(self):
+ return 0
+
+ def get_child_at_index(self, index):
+ return None
+
+
def __lldb_init_module(debugger,dict):
debugger.CreateCategory("JASSynth").AddTypeSynthetic(lldb.SBTypeNameSpecifier("JustAStruct"),
lldb.SBTypeSynthetic.CreateWithClassName("synth.jasSynthProvider"))
@@ -60,5 +90,16 @@ def __lldb_init_module(debugger,dict):
lldb.SBTypeNameSpecifier("CCC"),
lldb.SBTypeSummary.CreateWithFunctionName("synth.ccc_summary",
lldb.eTypeOptionCascade))
-
-
+ cat.AddTypeSynthetic(
+ lldb.SBTypeNameSpecifier("Empty1"),
+ lldb.SBTypeSynthetic.CreateWithClassName("synth.Empty1SynthProvider"))
+ cat.AddTypeSummary(
+ lldb.SBTypeNameSpecifier("Empty1"),
+ lldb.SBTypeSummary.CreateWithFunctionName("synth.empty1_summary"))
+ cat.AddTypeSynthetic(
+ lldb.SBTypeNameSpecifier("Empty2"),
+ lldb.SBTypeSynthetic.CreateWithClassName("synth.Empty2SynthProvider"))
+ cat.AddTypeSummary(
+ lldb.SBTypeNameSpecifier("Empty2"),
+ lldb.SBTypeSummary.CreateWithFunctionName("synth.empty2_summary",
+ lldb.eTypeOptionHideEmptyAggregates))
OpenPOWER on IntegriCloud