diff options
author | Tamas Berghammer <tberghammer@google.com> | 2017-03-31 20:07:20 +0000 |
---|---|---|
committer | Tamas Berghammer <tberghammer@google.com> | 2017-03-31 20:07:20 +0000 |
commit | af8953a0251608a7adbf02480f3fb03830e6f7e9 (patch) | |
tree | 55cb9ca9e2a771333418394c7143d5ec4985180e /lldb/packages/Python/lldbsuite/test | |
parent | 885fa12e8a0bf02c3d4c9dc5cbe5fffdb8cc5c8b (diff) | |
download | bcm5719-llvm-af8953a0251608a7adbf02480f3fb03830e6f7e9.tar.gz bcm5719-llvm-af8953a0251608a7adbf02480f3fb03830e6f7e9.zip |
Do not dereference std::unique_ptr by default
Summary:
Displaying the object pointed by the unique_ptr can cause an infinite
recursion when we have a pointer loop so this change stops that
behavior. Additionally it makes the unique_ptr act more like a class
containing a pointer (what is the underlying truth) instead of some
"magic" class.
Reviewers: labath, jingham
Differential Revision: https://reviews.llvm.org/D31366
llvm-svn: 299249
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
2 files changed, 47 insertions, 5 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py index 770d87178f5..eca690f94d8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py @@ -34,13 +34,13 @@ class StdUniquePtrDataFormatterTestCase(TestBase): self.assertTrue(frame.IsValid()) self.expect("frame variable nup", substrs=['nup = nullptr']) - self.expect("frame variable iup", substrs=['iup = 0x', 'object = 123']) - self.expect("frame variable sup", substrs=['sup = 0x', 'object = "foobar"']) + self.expect("frame variable iup", substrs=['iup = 0x']) + self.expect("frame variable sup", substrs=['sup = 0x']) self.expect("frame variable ndp", substrs=['ndp = nullptr']) - self.expect("frame variable idp", substrs=['idp = 0x', 'object = 456', 'deleter = ', 'a = 1', 'b = 2']) - self.expect("frame variable sdp", substrs=['sdp = 0x', 'object = "baz"', 'deleter = ', 'a = 3', 'b = 4']) - + self.expect("frame variable idp", substrs=['idp = 0x', 'deleter = ', 'a = 1', 'b = 2']) + self.expect("frame variable sdp", substrs=['sdp = 0x', 'deleter = ', 'a = 3', 'b = 4']) + self.assertEqual(123, frame.GetValueForVariablePath("iup.object").GetValueAsUnsigned()) self.assertFalse(frame.GetValueForVariablePath("iup.deleter").IsValid()) @@ -59,3 +59,32 @@ class StdUniquePtrDataFormatterTestCase(TestBase): self.assertTrue(sdp_deleter.IsValid()) self.assertEqual(3, sdp_deleter.GetChildMemberWithName("a").GetValueAsUnsigned()) self.assertEqual(4, sdp_deleter.GetChildMemberWithName("b").GetValueAsUnsigned()) + + @skipIfFreeBSD + @skipIfWindows # libstdcpp not ported to Windows + @skipIfDarwin # doesn't compile on Darwin + def test_recursive_unique_ptr(self): + # Tests that LLDB can handle when we have a loop in the unique_ptr + # reference chain and that it correctly handles the different options + # for the frame variable command in this case. + self.build() + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") + self.runCmd("run", RUN_SUCCEEDED) + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', 'stop reason = breakpoint']) + + self.expect("frame variable f1->fp", + substrs=['fp = 0x']) + self.expect("frame variable --ptr-depth=1 f1->fp", + substrs=['data = 2', 'fp = 0x']) + self.expect("frame variable --ptr-depth=2 f1->fp", + substrs=['data = 2', 'fp = 0x', 'data = 1']) + + frame = self.frame() + self.assertTrue(frame.IsValid()) + self.assertEqual(2, frame.GetValueForVariablePath("f1->fp.object.data").GetValueAsUnsigned()) + self.assertEqual(1, frame.GetValueForVariablePath("f1->fp.object.fp.object.data").GetValueAsUnsigned()) + diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp index 4a40309338c..dd0072764d4 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp @@ -8,6 +8,11 @@ struct Deleter { int b; }; +struct Foo { + int data; + std::unique_ptr<Foo> fp; +}; + int main() { std::unique_ptr<char> nup; std::unique_ptr<int> iup(new int{123}); @@ -18,5 +23,13 @@ int main() { std::unique_ptr<std::string, Deleter> sdp(new std::string("baz"), Deleter{3, 4}); + std::unique_ptr<Foo> fp(new Foo{3}); + + // Set up a structure where we have a loop in the unique_ptr chain. + Foo* f1 = new Foo{1}; + Foo* f2 = new Foo{2}; + f1->fp.reset(f2); + f2->fp.reset(f1); + return 0; // Set break point at this line. } |