summaryrefslogtreecommitdiffstats
path: root/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
committerdim <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
commit78b9749c0a4ea980a8b934645da6ae98fcc665e8 (patch)
treedd2a1ddf0476664c2b823409c36cbccd52662ca7 /packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language
parent60cb593f9d55fa5ca7a5372b731f2330345b4b9a (diff)
downloadFreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.zip
FreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.tar.gz
Vendor import of lldb trunk r256945:
https://llvm.org/svn/llvm-project/lldb/trunk@256945
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language')
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py85
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/a.c5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/b.cpp5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/main.cpp11
5 files changed, 112 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/Makefile
new file mode 100644
index 0000000..4f6b058
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+C_SOURCES := a.c
+CXX_SOURCES := main.cpp b.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py
new file mode 100644
index 0000000..94fc7bf
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py
@@ -0,0 +1,85 @@
+"""
+Test that the language option for breakpoints works correctly
+parser.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+import shutil
+import subprocess
+
+class TestBreakpointLanguage(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+
+ def check_location_file (self, bp, loc, test_name):
+ bp_loc = bp.GetLocationAtIndex(loc)
+ addr = bp_loc.GetAddress()
+ comp_unit = addr.GetCompileUnit()
+ comp_name = comp_unit.GetFileSpec().GetFilename()
+ return comp_name == test_name
+
+ def test_regex_breakpoint_language(self):
+ """Test that the name regex breakpoint commands obey the language filter."""
+
+ self.build()
+ # Create a target by the debugger.
+ exe = os.path.join(os.getcwd(), "a.out")
+ error = lldb.SBError()
+ # Don't read in dependencies so we don't come across false matches that
+ # add unwanted breakpoint hits.
+ self.target = self.dbg.CreateTarget(exe, None, None, False, error)
+ self.assertTrue(self.target, VALID_TARGET)
+
+ cpp_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(cpp_bp.GetNumLocations() == 1, "Only one C++ symbol matches")
+ self.assertTrue(self.check_location_file(cpp_bp, 0, "b.cpp"))
+
+ c_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(c_bp.GetNumLocations() == 1, "Only one C symbol matches")
+ self.assertTrue(self.check_location_file(c_bp, 0, "a.c"))
+
+ objc_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeObjC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(objc_bp.GetNumLocations() == 0, "No ObjC symbol matches")
+
+ def test_by_name_breakpoint_language(self):
+ """Test that the name regex breakpoint commands obey the language filter."""
+
+ self.build()
+ # Create a target by the debugger.
+ exe = os.path.join(os.getcwd(), "a.out")
+ error = lldb.SBError()
+ # Don't read in dependencies so we don't come across false matches that
+ # add unwanted breakpoint hits.
+ self.target = self.dbg.CreateTarget(exe, None, None, False, error)
+ self.assertTrue(self.target, VALID_TARGET)
+
+ cpp_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(cpp_bp.GetNumLocations() == 1, "Only one C++ symbol matches")
+ self.assertTrue(self.check_location_file(cpp_bp, 0, "b.cpp"))
+
+ no_cpp_bp = self.target.BreakpointCreateByName("func_from_c", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(no_cpp_bp.GetNumLocations() == 0, "And the C one doesn't match")
+
+ c_bp = self.target.BreakpointCreateByName("func_from_c", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(c_bp.GetNumLocations() == 1, "Only one C symbol matches")
+ self.assertTrue(self.check_location_file(c_bp, 0, "a.c"))
+
+ no_c_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(no_c_bp.GetNumLocations() == 0, "And the C++ one doesn't match")
+
+ objc_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeObjC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(objc_bp.GetNumLocations() == 0, "No ObjC symbol matches")
+
+
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/a.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/a.c
new file mode 100644
index 0000000..b90e2bd
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/a.c
@@ -0,0 +1,5 @@
+int
+func_from_c ()
+{
+ return 5;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/b.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/b.cpp
new file mode 100644
index 0000000..8937344
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/b.cpp
@@ -0,0 +1,5 @@
+int
+func_from_cpp()
+{
+ return 10;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/main.cpp
new file mode 100644
index 0000000..b7d00a6
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/main.cpp
@@ -0,0 +1,11 @@
+#include <stdio.h>
+extern "C" int func_from_c();
+extern int func_from_cpp();
+
+int
+main()
+{
+ func_from_c();
+ func_from_cpp();
+ return 0;
+}
OpenPOWER on IntegriCloud