diff options
| author | Enrico Granata <egranata@apple.com> | 2012-03-27 02:35:13 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2012-03-27 02:35:13 +0000 |
| commit | c5bc412cf6cb8ca4a8aaa33b36519affea73f9b7 (patch) | |
| tree | 115bd96399cee3c0d45d3bf48cce6132de153a52 /lldb/test | |
| parent | fe384a2c84fb9808be47c894bd445bc18891556a (diff) | |
| download | bcm5719-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')
8 files changed, 131 insertions, 50 deletions
diff --git a/lldb/test/functionalities/completion/TestCompletion.py b/lldb/test/functionalities/completion/TestCompletion.py index 7f7c0cbd455..e40e8e99b89 100644 --- a/lldb/test/functionalities/completion/TestCompletion.py +++ b/lldb/test/functionalities/completion/TestCompletion.py @@ -57,12 +57,12 @@ class CommandLineCompletionTestCase(TestBase): self.complete_from_to('settings append target.er', 'settings append target.error-path') def test_settings_insert_after_target_en(self): - """Test that 'settings insert-after target.en' completes to 'settings insert-after target.env-vars'.""" - self.complete_from_to('settings insert-after target.en', 'settings insert-after target.env-vars') + """Test that 'settings insert-after target.env' completes to 'settings insert-after target.env-vars'.""" + self.complete_from_to('settings insert-after target.env', 'settings insert-after target.env-vars') def test_settings_insert_before_target_en(self): - """Test that 'settings insert-before target.en' completes to 'settings insert-before target.env-vars'.""" - self.complete_from_to('settings insert-before target.en', 'settings insert-before target.env-vars') + """Test that 'settings insert-before target.env' completes to 'settings insert-before target.env-vars'.""" + self.complete_from_to('settings insert-before target.env', 'settings insert-before target.env-vars') def test_settings_replace_target_ru(self): """Test that 'settings replace target.ru' completes to 'settings replace target.run-args'.""" diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py index 871dfe77871..366a1539807 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py @@ -9,7 +9,7 @@ from lldbtest import * class LibcxxMapDataFormatterTestCase(TestBase): - mydir = os.path.join("functionalities", "data-formatter", "data-formatter-stl", "libstdcpp", "map") + mydir = os.path.join("functionalities", "data-formatter", "data-formatter-stl", "libcxx", "map") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): @@ -56,6 +56,8 @@ class LibcxxMapDataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) + self.expect('image list',substrs=['libc++.1.dylib','libc++abi.dylib']) + self.runCmd("frame variable ii -T") self.runCmd("type summary add -x \"std::__1::map<\" --summary-string \"map has ${svar%#} items\" -e") @@ -87,19 +89,20 @@ class LibcxxMapDataFormatterTestCase(TestBase): 'second = 1']) self.runCmd("n");self.runCmd("n"); - self.runCmd("n");self.runCmd("n");self.runCmd("n"); + self.runCmd("n");self.runCmd("n"); + self.runCmd("frame select 0") self.expect("frame variable ii", - substrs = ['map has 9 items', + substrs = ['map has 8 items', '[5] = {', 'first = 5', 'second = 0', '[7] = {', 'first = 7', 'second = 1']) - + self.expect("p ii", - substrs = ['map has 9 items', + substrs = ['map has 8 items', '[5] = {', 'first = 5', 'second = 0', @@ -114,9 +117,6 @@ class LibcxxMapDataFormatterTestCase(TestBase): self.expect("frame variable ii[3]", substrs = ['first =', 'second =']); - - self.expect("frame variable ii[8]", matching=True, - substrs = ['1234567']) # check that the expression parser does not make use of # synthetic children instead of running code @@ -126,20 +126,19 @@ class LibcxxMapDataFormatterTestCase(TestBase): #self.expect("expression ii[8]", matching=False, error=True, # substrs = ['1234567']) - self.runCmd("n") + self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0') self.expect('frame variable ii', substrs = ['map has 0 items', '{}']) - self.runCmd("n") self.runCmd("frame variable si -T") self.expect('frame variable si', substrs = ['map has 0 items', '{}']) - self.runCmd("n") + self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0') self.expect('frame variable si', substrs = ['map has 1 items', @@ -148,9 +147,11 @@ class LibcxxMapDataFormatterTestCase(TestBase): 'second = 0']) self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); + self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n") + self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0') self.expect("frame variable si", - substrs = ['map has 5 items', + substrs = ['map has 4 items', '[0] = ', 'first = \"zero\"', 'second = 0', @@ -162,13 +163,10 @@ class LibcxxMapDataFormatterTestCase(TestBase): 'second = 2', '[3] = ', 'first = \"three\"', - 'second = 3', - '[4] = ', - 'first = \"four\"', - 'second = 4']) + 'second = 3']) self.expect("p si", - substrs = ['map has 5 items', + substrs = ['map has 4 items', '[0] = ', 'first = \"zero\"', 'second = 0', @@ -180,15 +178,12 @@ class LibcxxMapDataFormatterTestCase(TestBase): 'second = 2', '[3] = ', 'first = \"three\"', - 'second = 3', - '[4] = ', - 'first = \"four\"', - 'second = 4']) + 'second = 3']) # check access-by-index self.expect("frame variable si[0]", - substrs = ['first = ', 'four', - 'second = 4']); + substrs = ['first = ', 'one', + 'second = 1']); # check that the expression parser does not make use of # synthetic children instead of running code @@ -198,7 +193,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): #self.expect("expression si[0]", matching=False, error=True, # substrs = ['first = ', 'zero']) - self.runCmd("n") + self.runCmd("n");self.runCmd("n"); self.expect('frame variable si', substrs = ['map has 0 items', @@ -262,17 +257,18 @@ class LibcxxMapDataFormatterTestCase(TestBase): substrs = ['map has 0 items', '{}']) - self.runCmd("n") + self.runCmd("n");self.runCmd("n"); self.runCmd("frame variable ss -T") self.expect('frame variable ss', substrs = ['map has 0 items', '{}']) - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); + self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); + self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0') self.expect("frame variable ss", - substrs = ['map has 4 items', + substrs = ['map has 3 items', '[0] = ', 'second = \"hello\"', 'first = \"ciao\"', @@ -281,13 +277,10 @@ class LibcxxMapDataFormatterTestCase(TestBase): 'first = \"casa\"', '[2] = ', 'second = \"cat\"', - 'first = \"gatto\"', - '[3] = ', - 'second = \"..is always a Mac!\"', - 'first = \"a Mac..\"']) + 'first = \"gatto\"']) self.expect("p ss", - substrs = ['map has 4 items', + substrs = ['map has 3 items', '[0] = ', 'second = \"hello\"', 'first = \"ciao\"', @@ -296,13 +289,10 @@ class LibcxxMapDataFormatterTestCase(TestBase): 'first = \"casa\"', '[2] = ', 'second = \"cat\"', - 'first = \"gatto\"', - '[3] = ', - 'second = \"..is always a Mac!\"', - 'first = \"a Mac..\"']) + 'first = \"gatto\"']) # check access-by-index - self.expect("frame variable ss[3]", + self.expect("frame variable ss[2]", substrs = ['gatto', 'cat']); # check that the expression parser does not make use of @@ -313,7 +303,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): #self.expect("expression ss[3]", matching=False, error=True, # substrs = ['gatto']) - self.runCmd("n") + self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd('frame select 0') self.expect('frame variable ss', substrs = ['map has 0 items', diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp index 58ab9980e14..704d17d5211 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp +++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp @@ -1,5 +1,9 @@ -#include <map> #include <string> +#ifdef _LIBCPP_INLINE_VISIBILITY +#undef _LIBCPP_INLINE_VISIBILITY +#endif +#define _LIBCPP_INLINE_VISIBILITY +#include <map> #define intint_map std::map<int, int> #define strint_map std::map<std::string, int> diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py b/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py index f65cca2e84f..ac5d9792977 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py @@ -64,6 +64,9 @@ class StdListDataFormatterTestCase(TestBase): self.expect("frame variable numbers_list --raw", matching=False, substrs = ['list has 0 items', '{}']) + self.expect("frame variable &numbers_list._M_impl._M_node --raw", matching=False, + substrs = ['list has 0 items', + '{}']) self.expect("frame variable numbers_list", substrs = ['list has 0 items', diff --git a/lldb/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py b/lldb/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py index 0cd2f453510..950fc55993a 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py @@ -83,16 +83,16 @@ class SynthDataFormatterTestCase(TestBase): 'z = 8']) # Summary+Synth must work together - self.runCmd("type summary add BagOfInts --summary-string \"y=${var.y}\" -e") + self.runCmd("type summary add BagOfInts --summary-string \"x=${var.x}\" -e") self.expect('frame variable int_bag', - substrs = ['y=7', + substrs = ['x=6', 'x = 6', 'z = 8']) # Same output, but using Python - self.runCmd("type summary add BagOfInts --python-script \"return 'y=%s' % valobj.GetChildMemberWithName('y').GetValue()\" -e") + self.runCmd("type summary add BagOfInts --python-script \"return 'x=%s' % valobj.GetChildMemberWithName('x').GetValue()\" -e") self.expect('frame variable int_bag', - substrs = ['y=7', + substrs = ['x=6', 'x = 6', 'z = 8']) @@ -111,10 +111,10 @@ class SynthDataFormatterTestCase(TestBase): # Add the synth again and check that it's honored deeper in the hierarchy self.runCmd("type filter add BagOfInts --child x --child z") self.expect('frame variable bag_bag', - substrs = ['x = y=70 {', + substrs = ['x = x=69 {', 'x = 69', 'z = 71', - 'y = y=67 {', + 'y = x=66 {', 'x = 66', 'z = 68']) self.expect('frame variable bag_bag', matching=False, 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. } |

