diff options
author | 2020-08-03 14:33:06 +0000 | |
---|---|---|
committer | 2020-08-03 14:33:06 +0000 | |
commit | 061da546b983eb767bad15e67af1174fb0bcf31c (patch) | |
tree | 83c78b820819d70aa40c36d90447978b300078c5 /gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands | |
parent | Import LLVM 10.0.0 release including clang, lld and lldb. (diff) | |
download | wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.tar.xz wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.zip |
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom
tested by plenty
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands')
3 files changed, 162 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/Makefile new file mode 100644 index 00000000000..6afea39f81c --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := nested.cpp + +include Makefile.rules diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py new file mode 100644 index 00000000000..32c974810f7 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py @@ -0,0 +1,83 @@ +""" +Test lldb breakpoint command for CPP methods & functions in a namespace. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class CPPBreakpointCommandsTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def make_breakpoint(self, name, type, expected_num_locations): + bkpt = self.target.BreakpointCreateByName(name, + type, + self.a_out_module, + self.nested_comp_unit) + num_locations = bkpt.GetNumLocations() + self.assertTrue( + num_locations == expected_num_locations, + "Wrong number of locations for '%s', expected: %d got: %d" % + (name, + expected_num_locations, + num_locations)) + return bkpt + + def test_cpp_breakpoint_cmds(self): + """Test a sequence of breakpoint command add, list, and delete.""" + self.build() + + exe = self.getBuildArtifact("a.out") + + # Create a target from the debugger. + + self.target = self.dbg.CreateTarget(exe) + self.assertTrue(self.target, VALID_TARGET) + + self.a_out_module = lldb.SBFileSpecList() + self.a_out_module.Append(lldb.SBFileSpec(exe)) + + self.nested_comp_unit = lldb.SBFileSpecList() + self.nested_comp_unit.Append(lldb.SBFileSpec("nested.cpp")) + + # First provide ONLY the method name. This should get everybody... + self.make_breakpoint("Function", + lldb.eFunctionNameTypeAuto, + 5) + + # Now add the Baz class specifier. This should get the version contained in Bar, + # AND the one contained in :: + self.make_breakpoint("Baz::Function", + lldb.eFunctionNameTypeAuto, + 2) + + # Then add the Bar::Baz specifier. This should get the version + # contained in Bar only + self.make_breakpoint("Bar::Baz::Function", + lldb.eFunctionNameTypeAuto, + 1) + + self.make_breakpoint("Function", + lldb.eFunctionNameTypeMethod, + 3) + + self.make_breakpoint("Baz::Function", + lldb.eFunctionNameTypeMethod, + 2) + + self.make_breakpoint("Bar::Baz::Function", + lldb.eFunctionNameTypeMethod, + 1) + + self.make_breakpoint("Function", + lldb.eFunctionNameTypeBase, + 2) + + self.make_breakpoint("Bar::Function", + lldb.eFunctionNameTypeBase, + 1) diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/nested.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/nested.cpp new file mode 100644 index 00000000000..740649622ca --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/nested.cpp @@ -0,0 +1,76 @@ +#include <stdio.h> + +namespace Foo +{ + namespace Bar + { + class Baz + { + public: + Baz (int value):m_value(value) {} + int Function () + { + printf ("%s returning: %d.\n", __FUNCTION__, m_value); + return m_value + 1; + } + private: + int m_value; + }; + + class Baz2 + { + public: + Baz2 (int value):m_value(value) {} + int Function () + { + printf ("%s returning: %d.\n", __FUNCTION__, m_value); + return m_value + 2; + } + private: + int m_value; + }; + + static int bar_value = 20; + int Function () + { + printf ("%s returning: %d.\n", __FUNCTION__, bar_value); + return bar_value + 3; + } + } +} + +class Baz +{ +public: + Baz (int value):m_value(value) {} + int Function () + { + printf ("%s returning: %d.\n", __FUNCTION__, m_value); + return m_value + 4; + } +private: + int m_value; +}; + +int +Function () +{ + printf ("I am a global function, I return 333.\n"); + return 333; +} + +int main () +{ + Foo::Bar::Baz mine(200); + Foo::Bar::Baz2 mine2(300); + ::Baz bare_baz (500); + + printf ("Yup, got %d from Baz.\n", mine.Function()); + printf ("Yup, got %d from Baz.\n", mine2.Function()); + printf ("Yup, got %d from Baz.\n", bare_baz.Function()); + printf ("And got %d from Bar.\n", Foo::Bar::Function()); + printf ("And got %d from ::.\n", ::Function()); + + return 0; + +} |