summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-01-10 01:35:02 +0000
committerGreg Clayton <gclayton@apple.com>2015-01-10 01:35:02 +0000
commitb9ea4231615ec1b1849cea54de62113315af169d (patch)
treed4b2d458347379e1fd5630606b7857eeaa458993
parent62d5bc9ce41f30d57088bd095e2277104647c61b (diff)
Add C++ breakpoint tests where names are partially specified to ensure we don't regress on this again.
Top of tree never regressed, but we have internal branches that we constantly merge and we need to make sure we don't regress. <rdar://problem/19429907> git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@225572 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/functionalities/breakpoint/cpp/Makefile9
-rw-r--r--test/functionalities/breakpoint/cpp/TestCPPBreakpoints.py73
-rw-r--r--test/functionalities/breakpoint/cpp/main.cpp77
3 files changed, 159 insertions, 0 deletions
diff --git a/test/functionalities/breakpoint/cpp/Makefile b/test/functionalities/breakpoint/cpp/Makefile
new file mode 100644
index 000000000..f89b52a97
--- /dev/null
+++ b/test/functionalities/breakpoint/cpp/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+ifneq (,$(findstring icc,$(CC)))
+ CXXFLAGS += -debug inline-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/test/functionalities/breakpoint/cpp/TestCPPBreakpoints.py b/test/functionalities/breakpoint/cpp/TestCPPBreakpoints.py
new file mode 100644
index 000000000..d3b233141
--- /dev/null
+++ b/test/functionalities/breakpoint/cpp/TestCPPBreakpoints.py
@@ -0,0 +1,73 @@
+"""
+Test lldb breakpoint ids.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+import lldbutil
+
+class TestCPPBreakpoints(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ @dsym_test
+ def test_with_dsym (self):
+ self.buildDsym ()
+ self.breakpoint_id_tests ()
+
+ @dwarf_test
+ def test_with_dwarf (self):
+ self.buildDwarf ()
+ self.breakpoint_id_tests ()
+
+ def verify_breakpoint_locations(self, target, bp_dict):
+
+ name = bp_dict['name']
+ names = bp_dict['loc_names']
+ bp = target.BreakpointCreateByName (name)
+ self.assertTrue (bp.GetNumLocations() == len(names), "Make sure we find the right number of breakpoint locations")
+
+ bp_loc_names = list()
+ for bp_loc in bp:
+ bp_loc_names.append(bp_loc.GetAddress().GetFunction().GetName())
+
+ for name in names:
+ found = name in bp_loc_names
+ if not found:
+ print "Didn't find '%s' in: %s" % (name, bp_loc_names)
+ self.assertTrue (found, "Make sure we find all required locations")
+
+ def breakpoint_id_tests (self):
+
+ # Create a target by the debugger.
+ exe = os.path.join(os.getcwd(), "a.out")
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+ bp_dicts = [
+ { 'name' : 'func1', 'loc_names' : [ 'a::c::func1()', 'b::c::func1()'] },
+ { 'name' : 'func2', 'loc_names' : [ 'a::c::func2()', 'c::d::func2()'] },
+ { 'name' : 'func3', 'loc_names' : [ 'a::c::func3()', 'b::c::func3()', 'c::d::func3()'] },
+ { 'name' : 'c::func1', 'loc_names' : [ 'a::c::func1()', 'b::c::func1()'] },
+ { 'name' : 'c::func2', 'loc_names' : [ 'a::c::func2()'] },
+ { 'name' : 'c::func3', 'loc_names' : [ 'a::c::func3()', 'b::c::func3()'] },
+ { 'name' : 'a::c::func1', 'loc_names' : [ 'a::c::func1()'] },
+ { 'name' : 'b::c::func1', 'loc_names' : [ 'b::c::func1()'] },
+ { 'name' : 'c::d::func2', 'loc_names' : [ 'c::d::func2()'] },
+ { 'name' : 'a::c::func1()', 'loc_names' : [ 'a::c::func1()'] },
+ { 'name' : 'b::c::func1()', 'loc_names' : [ 'b::c::func1()'] },
+ { 'name' : 'c::d::func2()', 'loc_names' : [ 'c::d::func2()'] },
+ ]
+
+ for bp_dict in bp_dicts:
+ self.verify_breakpoint_locations(target, bp_dict)
+
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
+
diff --git a/test/functionalities/breakpoint/cpp/main.cpp b/test/functionalities/breakpoint/cpp/main.cpp
new file mode 100644
index 000000000..ef582aa36
--- /dev/null
+++ b/test/functionalities/breakpoint/cpp/main.cpp
@@ -0,0 +1,77 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+#include <stdint.h>
+
+namespace a {
+ class c {
+ public:
+ c () {}
+ ~c() {}
+ void func1()
+ {
+ puts (__PRETTY_FUNCTION__);
+ }
+ void func2()
+ {
+ puts (__PRETTY_FUNCTION__);
+ }
+ void func3()
+ {
+ puts (__PRETTY_FUNCTION__);
+ }
+ };
+}
+
+namespace b {
+ class c {
+ public:
+ c () {}
+ ~c() {}
+ void func1()
+ {
+ puts (__PRETTY_FUNCTION__);
+ }
+ void func3()
+ {
+ puts (__PRETTY_FUNCTION__);
+ }
+ };
+}
+
+namespace c {
+ class d {
+ public:
+ d () {}
+ ~d() {}
+ void func2()
+ {
+ puts (__PRETTY_FUNCTION__);
+ }
+ void func3()
+ {
+ puts (__PRETTY_FUNCTION__);
+ }
+ };
+}
+
+int main (int argc, char const *argv[])
+{
+ a::c ac;
+ b::c bc;
+ c::d cd;
+ ac.func1();
+ ac.func2();
+ ac.func3();
+ bc.func1();
+ bc.func3();
+ cd.func2();
+ cd.func3();
+ return 0;
+}