summaryrefslogtreecommitdiffstats
path: root/lldb/test/python_api
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2012-03-27 02:35:13 +0000
committerEnrico Granata <egranata@apple.com>2012-03-27 02:35:13 +0000
commitc5bc412cf6cb8ca4a8aaa33b36519affea73f9b7 (patch)
tree115bd96399cee3c0d45d3bf48cce6132de153a52 /lldb/test/python_api
parentfe384a2c84fb9808be47c894bd445bc18891556a (diff)
downloadbcm5719-llvm-c5bc412cf6cb8ca4a8aaa33b36519affea73f9b7.tar.gz
bcm5719-llvm-c5bc412cf6cb8ca4a8aaa33b36519affea73f9b7.zip
Synthetic values are now automatically enabled and active by default. SBValue is set up to always wrap a synthetic value when one is available.
A new setting enable-synthetic-value is provided on the target to disable this behavior. There also is a new GetNonSyntheticValue() API call on SBValue to go back from synthetic to non-synthetic. There is no call to go from non-synthetic to synthetic. The test suite has been changed accordingly. Fallout from changes to type searching: an hack has to be played to make it possible to use maps that contain std::string due to the special name replacement operated by clang Fixing a test case that was using libstdcpp instead of libc++ - caught as a consequence of said changes to type searching llvm-svn: 153495
Diffstat (limited to 'lldb/test/python_api')
-rw-r--r--lldb/test/python_api/formatters/TestFormattersSBAPI.py81
-rw-r--r--lldb/test/python_api/formatters/jas_synth.py3
-rw-r--r--lldb/test/python_api/formatters/main.cpp2
3 files changed, 85 insertions, 1 deletions
diff --git a/lldb/test/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/python_api/formatters/TestFormattersSBAPI.py
index 52cf01462d1..52bf0f470b7 100644
--- a/lldb/test/python_api/formatters/TestFormattersSBAPI.py
+++ b/lldb/test/python_api/formatters/TestFormattersSBAPI.py
@@ -24,6 +24,13 @@ class SBFormattersAPITestCase(TestBase):
self.setTearDownCleanup()
self.formatters()
+ @python_api_test
+ def test_force_synth_off(self):
+ """Test that one can have the public API return non-synthetic SBValues if desired"""
+ self.buildDwarf(dictionary={'EXE':'no_synth'})
+ self.setTearDownCleanup()
+ self.force_synth_off()
+
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
@@ -155,7 +162,18 @@ class SBFormattersAPITestCase(TestBase):
self.expect("frame variable foo", matching=True,
substrs = ['X = 1'])
+ foo_var = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('foo')
+ self.assertTrue(foo_var.IsValid(), 'could not find foo')
+
+ self.assertTrue(foo_var.GetNumChildren() == 2, 'synthetic value has wrong number of child items (synth)')
+ self.assertTrue(foo_var.GetChildMemberWithName('X').GetValueAsUnsigned() == 1, 'foo_synth.X has wrong value (synth)')
+ self.assertFalse(foo_var.GetChildMemberWithName('B').IsValid(), 'foo_synth.B is valid but should not (synth)')
+
self.dbg.GetCategory("JASSynth").SetEnabled(False)
+ foo_var = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('foo')
+ self.assertTrue(foo_var.IsValid(), 'could not find foo')
+
+ self.assertFalse(foo_var.GetNumChildren() == 2, 'still seeing synthetic value')
filter = lldb.SBTypeFilter(0)
filter.AppendExpressionPath("A")
@@ -164,6 +182,13 @@ class SBFormattersAPITestCase(TestBase):
self.expect("frame variable foo",
substrs = ['A = 1', 'D = 6.28'])
+ foo_var = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('foo')
+ self.assertTrue(foo_var.IsValid(), 'could not find foo')
+
+ self.assertTrue(foo_var.GetNumChildren() == 2, 'synthetic value has wrong number of child items (filter)')
+ self.assertTrue(foo_var.GetChildMemberWithName('X').GetValueAsUnsigned() == 0, 'foo_synth.X has wrong value (filter)')
+ self.assertTrue(foo_var.GetChildMemberWithName('A').GetValueAsUnsigned() == 1, 'foo_synth.A has wrong value (filter)')
+
self.assertTrue(filter.ReplaceExpressionPathAtIndex(0,"C"), "failed to replace an expression path in filter")
self.expect("frame variable foo",
substrs = ['A = 1', 'D = 6.28'])
@@ -180,6 +205,10 @@ class SBFormattersAPITestCase(TestBase):
self.expect("frame variable bar",
substrs = ["C = 'e'", 'D = 6.28'])
+ foo_var = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('foo')
+ self.assertTrue(foo_var.IsValid(), 'could not find foo')
+ self.assertTrue(foo_var.GetChildMemberWithName('C').GetValueAsUnsigned() == ord('e'), 'foo_synth.C has wrong value (filter)')
+
chosen = self.dbg.GetFilterForType(lldb.SBTypeNameSpecifier("JustAStruct"))
self.assertTrue(chosen.count == 2, "wrong filter found for JustAStruct")
self.assertTrue(chosen.GetExpressionPathAtIndex(0) == 'C', "wrong item at index 0 for JustAStruct")
@@ -269,6 +298,58 @@ 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*")
+ 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)
+
+ self.expect("breakpoint set -f main.cpp -l %d" % self.line,
+ BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" %
+ self.line)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synthetic clear', check=False)
+ self.runCmd('type category delete foobar', check=False)
+ self.runCmd('type category delete JASSynth', check=False)
+ self.runCmd('type category delete newbar', check=False)
+ self.runCmd('settings set target.enable-synthetic-value true')
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ frame = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
+ int_vector = frame.FindVariable("int_vector")
+ if self.TraceOn():
+ print int_vector
+ self.assertTrue(int_vector.GetNumChildren() == 0, 'synthetic vector is empty')
+
+ self.runCmd('settings set target.enable-synthetic-value false')
+ frame = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
+ int_vector = frame.FindVariable("int_vector")
+ if self.TraceOn():
+ print int_vector
+ self.assertFalse(int_vector.GetNumChildren() == 0, '"physical" vector is not empty')
+
+ self.runCmd('settings set target.enable-synthetic-value true')
+ frame = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
+ int_vector = frame.FindVariable("int_vector")
+ if self.TraceOn():
+ print int_vector
+ self.assertTrue(int_vector.GetNumChildren() == 0, 'synthetic vector is still empty')
+
+
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
diff --git a/lldb/test/python_api/formatters/jas_synth.py b/lldb/test/python_api/formatters/jas_synth.py
index 16db646d660..587671888e3 100644
--- a/lldb/test/python_api/formatters/jas_synth.py
+++ b/lldb/test/python_api/formatters/jas_synth.py
@@ -5,6 +5,7 @@ class jasSynthProvider:
def num_children(self):
return 2;
def get_child_at_index(self, index):
+ child = None
if index == 0:
child = self.valobj.GetChildMemberWithName('A');
if index == 1:
@@ -15,7 +16,7 @@ class jasSynthProvider:
return 0;
if name == 'X':
return 1;
- return 2;
+ return None;
def __lldb_init_module(debugger,dict):
debugger.CreateCategory("JASSynth").AddTypeSynthetic(lldb.SBTypeNameSpecifier("JustAStruct"),
diff --git a/lldb/test/python_api/formatters/main.cpp b/lldb/test/python_api/formatters/main.cpp
index 6785749e7d2..e26467e9fb0 100644
--- a/lldb/test/python_api/formatters/main.cpp
+++ b/lldb/test/python_api/formatters/main.cpp
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <vector>
struct JustAStruct
{
@@ -34,5 +35,6 @@ int main(int argc, char const *argv[]) {
bar.D = 6.28;
bar.E = 3100419850;
JustAStruct* foo_ptr = &foo;
+ std::vector<int> int_vector;
return 0; // Set break point at this line.
}
OpenPOWER on IntegriCloud