summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/functionalities/breakpoint
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
commitf3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch)
tree48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /packages/Python/lldbsuite/test/functionalities/breakpoint
parent2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff)
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/breakpoint')
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py77
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py121
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c8
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py11
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py3
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py43
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp25
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py11
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py59
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/Makefile (renamed from packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/Makefile)0
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py101
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/main.cpp (renamed from packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/main.cpp)0
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py39
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp14
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py11
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py100
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.c16
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.h1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/main.c17
28 files changed, 616 insertions, 94 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
new file mode 100644
index 000000000000..73b3ef5eae28
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
@@ -0,0 +1,77 @@
+"""
+Test that breakpoints set on a bad address say they are bad.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+class BadAddressBreakpointTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_bad_address_breakpoints (self):
+ """Test that breakpoints set on a bad address say they are bad."""
+ self.build()
+ self.address_breakpoints()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def address_breakpoints(self):
+ """Test that breakpoints set on a bad address say they are bad."""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint on main.c by name 'c'.
+ breakpoint = target.BreakpointCreateBySourceRegex("Set a breakpoint here", lldb.SBFileSpec("main.c"))
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ # Get the breakpoint location from breakpoint after we verified that,
+ # indeed, it has one location.
+ location = breakpoint.GetLocationAtIndex(0)
+ self.assertTrue(location and
+ location.IsEnabled(),
+ VALID_BREAKPOINT_LOCATION)
+
+ launch_info = lldb.SBLaunchInfo(None)
+
+ error = lldb.SBError()
+
+ process = target.Launch (launch_info, error)
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Did we hit our breakpoint?
+ from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+ threads = get_threads_stopped_at_breakpoint (process, breakpoint)
+ self.assertTrue(len(threads) == 1, "There should be a thread stopped at our breakpoint")
+
+ # The hit count for the breakpoint should be 1.
+ self.assertTrue(breakpoint.GetHitCount() == 1)
+
+ # Now see if we can read from 0. If I can't do that, I don't have a good way to know
+ # what an illegal address is...
+ error.Clear()
+
+ ptr = process.ReadPointerFromMemory(0x0, error)
+
+ if not error.Success():
+ bkpt = target.BreakpointCreateByAddress(0x0)
+ for bp_loc in bkpt:
+ self.assertTrue(bp_loc.IsResolved() == False)
+ else:
+ self.fail("Could not find an illegal address at which to set a bad breakpoint.")
+
+
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile
new file mode 100644
index 000000000000..6067ee45e984
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+CFLAGS_EXTRAS += -std=c99
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
new file mode 100644
index 000000000000..aa4ee14ffc5a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
@@ -0,0 +1,121 @@
+"""
+Test case sensitivity of paths on Windows / POSIX
+llvm.org/pr22667
+"""
+
+import os
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test import lldbplatform, lldbplatformutil
+
+class BreakpointCaseSensitivityTestCase(TestBase):
+ mydir = TestBase.compute_mydir(__file__)
+ BREAKPOINT_TEXT = 'Set a breakpoint here'
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ self.line = line_number('main.c', self.BREAKPOINT_TEXT)
+
+ @skipIf(oslist=no_match(['windows'])) # Skip for non-windows platforms
+ def test_breakpoint_matches_file_with_different_case(self):
+ """Set breakpoint on file, should match files with different case on Windows"""
+ self.build()
+ self.case_sensitivity_breakpoint(True)
+
+ @skipIf(oslist=['windows']) # Skip for windows platforms
+ @expectedFailureAll() # Failing for unknown reason on non-Windows platforms.
+ def test_breakpoint_doesnt_match_file_with_different_case(self):
+ """Set breakpoint on file, shouldn't match files with different case on POSIX systems"""
+ self.build()
+ self.case_sensitivity_breakpoint(False)
+
+ def case_sensitivity_breakpoint(self, case_insensitive):
+ """Set breakpoint on file, should match files with different case if case_insensitive is True"""
+
+ # use different case to check CreateTarget
+ exe = 'a.out'
+ if case_insensitive:
+ exe = exe.upper()
+
+ exe = os.path.join(os.getcwd(), exe)
+
+ # Create a target by the debugger.
+ self.target = self.dbg.CreateTarget(exe)
+ self.assertTrue(self.target, VALID_TARGET)
+ cwd = self.get_process_working_directory();
+
+ # try both BreakpointCreateByLocation and BreakpointCreateBySourceRegex
+ for regex in [False, True]:
+ # should always hit
+ self.check_breakpoint('main.c', regex, True)
+ # should always hit
+ self.check_breakpoint(os.path.join(cwd, 'main.c'), regex, True)
+ # different case for directory
+ self.check_breakpoint(os.path.join(cwd.upper(), 'main.c'),
+ regex,
+ case_insensitive)
+ # different case for file
+ self.check_breakpoint('Main.c',
+ regex,
+ case_insensitive)
+ # different case for both
+ self.check_breakpoint(os.path.join(cwd.upper(), 'Main.c'),
+ regex,
+ case_insensitive)
+
+ def check_breakpoint(self, file, source_regex, should_hit):
+ """
+ Check breakpoint hit at given file set by given method
+
+ file:
+ File where insert the breakpoint
+
+ source_regex:
+ True for testing using BreakpointCreateBySourceRegex,
+ False for BreakpointCreateByLocation
+
+ should_hit:
+ True if the breakpoint should hit, False otherwise
+ """
+
+ desc = ' file %s set by %s' % (file, 'regex' if source_regex else 'location')
+ if source_regex:
+ breakpoint = self.target.BreakpointCreateBySourceRegex(self.BREAKPOINT_TEXT,
+ lldb.SBFileSpec(file))
+ else:
+ breakpoint = self.target.BreakpointCreateByLocation(file, self.line)
+
+ self.assertEqual(breakpoint and breakpoint.GetNumLocations() == 1,
+ should_hit,
+ VALID_BREAKPOINT + desc)
+
+ # Get the breakpoint location from breakpoint after we verified that,
+ # indeed, it has one location.
+ location = breakpoint.GetLocationAtIndex(0)
+ self.assertEqual(location and location.IsEnabled(),
+ should_hit,
+ VALID_BREAKPOINT_LOCATION + desc)
+
+ process = self.target.LaunchSimple(None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID + desc)
+
+ if should_hit:
+ # Did we hit our breakpoint?
+ from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+ threads = get_threads_stopped_at_breakpoint (process, breakpoint)
+ self.assertEqual(len(threads), 1, "There should be a thread stopped at breakpoint" + desc)
+ # The hit count for the breakpoint should be 1.
+ self.assertEqual(breakpoint.GetHitCount(), 1)
+
+ else:
+ # check the breakpoint was not hit
+ self.assertEqual(lldb.eStateExited, process.GetState())
+ self.assertEqual(breakpoint.GetHitCount(), 0)
+
+ # let process finish
+ process.Continue()
+
+ # cleanup
+ self.target.BreakpointDelete(breakpoint.GetID())
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c
new file mode 100644
index 000000000000..281ddfe7ef67
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int
+main()
+{
+ printf("Set a breakpoint here.\n");
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
index 8cf7539432ba..78d14b7d7705 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -8,8 +8,9 @@ from __future__ import print_function
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class BreakpointCommandTestCase(TestBase):
@@ -21,7 +22,7 @@ class BreakpointCommandTestCase(TestBase):
cls.RemoveTempFile("output.txt")
cls.RemoveTempFile("output2.txt")
- @expectedFailureWindows("llvm.org/pr24528")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
def test(self):
"""Test a sequence of breakpoint command add, list, and delete."""
self.build()
@@ -142,7 +143,7 @@ class BreakpointCommandTestCase(TestBase):
self.expect("breakpoint command list 1",
startstr = "Breakpoint 1 does not have an associated command.")
self.expect("breakpoint command list 2", error=True,
- startstr = "error: '2' is not a currently valid breakpoint id.")
+ startstr = "error: '2' is not a currently valid breakpoint ID.")
# The breakpoint list now only contains breakpoint 1.
self.expect("breakpoint list -f", "Breakpoint 1 exists",
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
index 7a9cc744d528..4f8ab9e115de 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
@@ -8,10 +8,11 @@ from __future__ import print_function
import os
import re
-import lldb
-import lldbsuite.test.lldbutil as lldbutil
import sys
+import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
class PythonBreakpointCommandSettingTestCase(TestBase):
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
index 8c22c8fe869c..0d34dd85dc50 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
@@ -9,8 +9,9 @@ from __future__ import print_function
import os, time
import re
import lldb
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
class BreakpointConditionsTestCase(TestBase):
@@ -107,11 +108,13 @@ class BreakpointConditionsTestCase(TestBase):
if arch in ['x86_64', 'i386']:
self.runCmd("breakpoint modify -c ($eax&&i)")
elif arch in ['aarch64']:
- self.runCmd("breakpoint modify -c ($x1&&i)")
+ self.runCmd("breakpoint modify -c ($x0&&i)")
elif arch in ['arm']:
self.runCmd("breakpoint modify -c ($r0&&i)")
elif re.match("mips",arch):
self.runCmd("breakpoint modify -c ($r2&&i)")
+ elif arch in ['s390x']:
+ self.runCmd("breakpoint modify -c ($r2&&i)")
self.runCmd("run")
self.expect("process status", PROCESS_STOPPED,
@@ -178,4 +181,8 @@ class BreakpointConditionsTestCase(TestBase):
# The hit count for the breakpoint should be 1.
self.assertTrue(breakpoint.GetHitCount() == 1)
+ # Test that the condition expression didn't create a result variable:
+ options = lldb.SBExpressionOptions()
+ value = frame0.EvaluateExpression("$0", options)
+ self.assertTrue(value.GetError().Fail(), "Conditions should not make result variables.")
process.Continue()
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
index 8a83cb627f7a..05ef1c6d94c7 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
@@ -9,8 +9,9 @@ from __future__ import print_function
import os, time
import re
import lldb
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
class BreakpointIgnoreCountTestCase(TestBase):
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
index 324401ff44e1..b1e0d3deeae7 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
@@ -8,14 +8,15 @@ import os, time
import re
import unittest2
import lldb
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
class AvoidBreakpointInDelaySlotAPITestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipUnlessArch(archs=re.compile('mips*'))
+ @skipIf(archs=no_match(re.compile('mips*')))
def test(self):
self.build()
exe = os.path.join(os.getcwd(), "a.out")
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
index 5c4dc219a106..707b6502e91c 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
@@ -8,15 +8,15 @@ from __future__ import print_function
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class BreakpointLocationsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @expectedFailureWindows("llvm.org/pr24528")
- @expectedFailureAll(oslist=["linux"], compiler="clang", compiler_version=["=", "3.8"], archs=["i386"], debug_info="dwo")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
def test(self):
"""Test breakpoint enable/disable for a breakpoint ID with multiple locations."""
self.build()
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py
new file mode 100644
index 000000000000..4ca93765b656
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py
@@ -0,0 +1,43 @@
+"""
+Test inferior restart when breakpoint is set on running target.
+"""
+
+import os
+import lldb
+from lldbsuite.test.lldbtest import *
+
+class BreakpointSetRestart(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ BREAKPOINT_TEXT = 'Set a breakpoint here'
+
+ def test_breakpoint_set_restart(self):
+ self.build()
+
+ cwd = os.getcwd()
+ exe = os.path.join(cwd, 'a.out')
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ self.dbg.SetAsync(True)
+ process = target.LaunchSimple(None, None, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ event = lldb.SBEvent()
+ # Wait for inferior to transition to running state
+ while self.dbg.GetListener().WaitForEvent(2, event):
+ if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning:
+ break
+
+ bp = target.BreakpointCreateBySourceRegex(self.BREAKPOINT_TEXT,
+ lldb.SBFileSpec(os.path.join(cwd, 'main.cpp')))
+ self.assertTrue(bp.IsValid() and bp.GetNumLocations() == 1, VALID_BREAKPOINT)
+
+ while self.dbg.GetListener().WaitForEvent(2, event):
+ if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateStopped and lldb.SBProcess.GetRestartedFromEvent(event):
+ continue
+ if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning:
+ continue
+ self.fail("Setting a breakpoint generated an unexpected event: %s" % lldb.SBDebugger.StateAsCString(lldb.SBProcess.GetStateFromEvent(event)))
+
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp
new file mode 100644
index 000000000000..e6d3a95d017f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp
@@ -0,0 +1,25 @@
+//===-- 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 <chrono>
+#include <stdio.h>
+#include <thread>
+
+
+int main(int argc, char const *argv[])
+{
+ static bool done = false;
+ while (!done)
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds{100});
+ }
+ printf("Set a breakpoint here.\n");
+ return 0;
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
index e1de38bcad8c..4933d6d01d44 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
@@ -6,10 +6,11 @@ from __future__ import print_function
import os
+import shutil
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
-import shutil
+from lldbsuite.test import lldbutil
_EXE_NAME = 'CompDirSymLink' # Must match Makefile
@@ -27,21 +28,21 @@ class CompDirSymLinkTestCase(TestBase):
self.line = line_number(_SRC_FILE, '// Set break point at this line.')
self.src_path = os.path.join(os.getcwd(), _SRC_FILE)
- @skipIfHostWindows
+ @skipIf(hostoslist=["windows"])
def test_symlink_paths_set(self):
pwd_symlink = self.create_src_symlink()
self.doBuild(pwd_symlink)
self.runCmd("settings set %s %s" % (_COMP_DIR_SYM_LINK_PROP, pwd_symlink))
lldbutil.run_break_set_by_file_and_line(self, self.src_path, self.line)
- @skipUnlessHostLinux
+ @skipIf(hostoslist=no_match(["linux"]))
def test_symlink_paths_set_procselfcwd(self):
pwd_symlink = '/proc/self/cwd'
self.doBuild(pwd_symlink)
self.runCmd("settings set %s %s" % (_COMP_DIR_SYM_LINK_PROP, pwd_symlink))
lldbutil.run_break_set_by_file_and_line(self, self.src_path, self.line)
- @skipIfHostWindows
+ @skipIf(hostoslist=["windows"])
def test_symlink_paths_unset(self):
pwd_symlink = self.create_src_symlink()
self.doBuild(pwd_symlink)
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py
deleted file mode 100644
index af6df3764829..000000000000
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py
+++ /dev/null
@@ -1,59 +0,0 @@
-"""
-Test continue from a breakpoint when there is a breakpoint on the next instruction also.
-"""
-
-from __future__ import print_function
-
-
-
-import unittest2
-import lldb
-import lldbsuite.test.lldbutil as lldbutil
-from lldbsuite.test.lldbtest import *
-
-class ConsecutiveBreakpoitsTestCase(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- @expectedFailureAll("llvm.org/pr23478", oslist = not_in(["macosx"]))
- def test (self):
- self.build ()
- self.consecutive_breakpoints_tests()
-
- def consecutive_breakpoints_tests(self):
- exe = os.path.join (os.getcwd(), "a.out")
-
- # Create a target by the debugger.
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- breakpoint = target.BreakpointCreateBySourceRegex("Set breakpoint here", lldb.SBFileSpec("main.cpp"))
- self.assertTrue(breakpoint and
- breakpoint.GetNumLocations() == 1,
- VALID_BREAKPOINT)
-
- # Now launch the process, and do not stop at entry point.
- process = target.LaunchSimple (None, None, self.get_process_working_directory())
- self.assertTrue(process, PROCESS_IS_VALID)
-
- # We should be stopped at the first breakpoint
- thread = process.GetThreadAtIndex(0)
- self.assertEqual(thread.GetStopReason(), lldb.eStopReasonBreakpoint)
-
- # Set breakpoint to the next instruction
- frame = thread.GetFrameAtIndex(0)
-
- address = frame.GetPCAddress()
- instructions = target.ReadInstructions(address, 2)
- self.assertTrue(len(instructions) == 2)
- address = instructions[1].GetAddress()
-
- target.BreakpointCreateByAddress(address.GetLoadAddress(target))
- process.Continue()
-
- # We should be stopped at the second breakpoint
- thread = process.GetThreadAtIndex(0)
- self.assertEqual(thread.GetStopReason(), lldb.eStopReasonBreakpoint)
-
- # Run the process until termination
- process.Continue()
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/Makefile
index f89b52a972e9..f89b52a972e9 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/Makefile
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/Makefile
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
new file mode 100644
index 000000000000..472479391c02
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
@@ -0,0 +1,101 @@
+"""
+Test that we handle breakpoints on consecutive instructions correctly.
+"""
+
+from __future__ import print_function
+
+
+
+import unittest2
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class ConsecutiveBreakpointsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def prepare_test(self):
+ self.build()
+ exe = os.path.join (os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ self.target = self.dbg.CreateTarget(exe)
+ self.assertTrue(self.target, VALID_TARGET)
+
+ breakpoint1 = self.target.BreakpointCreateBySourceRegex("Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+ self.assertTrue(breakpoint1 and breakpoint1.GetNumLocations() == 1, VALID_BREAKPOINT)
+
+ # Now launch the process, and do not stop at entry point.
+ self.process = self.target.LaunchSimple (None, None, self.get_process_working_directory())
+ self.assertIsNotNone(self.process, PROCESS_IS_VALID)
+
+ # We should be stopped at the first breakpoint
+ self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, breakpoint1)
+ self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 1")
+
+ # Set breakpoint to the next instruction
+ frame = self.thread.GetFrameAtIndex(0)
+
+ address = frame.GetPCAddress()
+ instructions = self.target.ReadInstructions(address, 2)
+ self.assertTrue(len(instructions) == 2)
+ self.bkpt_address = instructions[1].GetAddress()
+ self.breakpoint2 = self.target.BreakpointCreateByAddress(self.bkpt_address.GetLoadAddress(self.target))
+ self.assertTrue(self.breakpoint2 and self.breakpoint2.GetNumLocations() == 1, VALID_BREAKPOINT)
+
+ def finish_test(self):
+ # Run the process until termination
+ self.process.Continue()
+ self.assertEquals(self.process.GetState(), lldb.eStateExited)
+
+ @no_debug_info_test
+ def test_continue(self):
+ """Test that continue stops at the second breakpoint."""
+ self.prepare_test()
+
+ self.process.Continue()
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ # We should be stopped at the second breakpoint
+ self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint2)
+ self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 2")
+
+ self.finish_test()
+
+ @no_debug_info_test
+ def test_single_step(self):
+ """Test that single step stops at the second breakpoint."""
+ self.prepare_test()
+
+ step_over = False
+ self.thread.StepInstruction(step_over)
+
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(self.target),
+ self.bkpt_address.GetLoadAddress(self.target))
+ self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint2)
+ self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 2")
+
+ self.finish_test()
+
+ @no_debug_info_test
+ def test_single_step_thread_specific(self):
+ """Test that single step stops, even though the second breakpoint is not valid."""
+ self.prepare_test()
+
+ # Choose a thread other than the current one. A non-existing thread is fine.
+ thread_index = self.process.GetNumThreads()+1
+ self.assertFalse(self.process.GetThreadAtIndex(thread_index).IsValid())
+ self.breakpoint2.SetThreadIndex(thread_index)
+
+ step_over = False
+ self.thread.StepInstruction(step_over)
+
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(self.target),
+ self.bkpt_address.GetLoadAddress(self.target))
+ self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete,
+ "Stop reason should be 'plan complete'")
+
+ self.finish_test()
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/main.cpp
index c1943f03dbf1..c1943f03dbf1 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/main.cpp
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
index dea206b9e9d2..c2aa597214ed 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
@@ -8,14 +8,15 @@ from __future__ import print_function
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class TestCPPBreakpointLocations(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @expectedFailureWindows("llvm.org/pr24764")
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
def test (self):
self.build ()
self.breakpoint_id_tests ()
@@ -25,7 +26,7 @@ class TestCPPBreakpointLocations(TestBase):
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")
+ self.assertEquals(bp.GetNumLocations(), len(names), "Make sure we find the right number of breakpoint locations")
bp_loc_names = list()
for bp_loc in bp:
@@ -60,3 +61,35 @@ class TestCPPBreakpointLocations(TestBase):
for bp_dict in bp_dicts:
self.verify_breakpoint_locations(target, bp_dict)
+
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+ def test_destructors(self):
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+ target = self.dbg.CreateTarget(exe)
+
+ # Don't skip prologue, so we can check the breakpoint address more easily
+ self.runCmd("settings set target.skip-prologue false")
+ try:
+ names = ['~c', 'c::~c', 'c::~c()']
+ loc_names = {'a::c::~c()', 'b::c::~c()'}
+ # TODO: For windows targets we should put windows mangled names here
+ symbols = ['_ZN1a1cD1Ev', '_ZN1a1cD2Ev', '_ZN1b1cD1Ev', '_ZN1b1cD2Ev']
+
+ for name in names:
+ bp = target.BreakpointCreateByName(name)
+
+ bp_loc_names = { bp_loc.GetAddress().GetFunction().GetName() for bp_loc in bp }
+ self.assertEquals(bp_loc_names, loc_names, "Breakpoint set on the correct symbol")
+
+ bp_addresses = { bp_loc.GetLoadAddress() for bp_loc in bp }
+ symbol_addresses = set()
+ for symbol in symbols:
+ sc_list = target.FindSymbols(symbol, lldb.eSymbolTypeCode)
+ self.assertEquals(sc_list.GetSize(), 1, "Found symbol " + symbol)
+ symbol = sc_list.GetContextAtIndex(0).GetSymbol()
+ symbol_addresses.add(symbol.GetStartAddress().GetLoadAddress(target))
+
+ self.assertEquals(symbol_addresses, bp_addresses, "Breakpoint set on correct address")
+ finally:
+ self.runCmd("settings clear target.skip-prologue")
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp
index ef582aa36ebb..01f679139249 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp
@@ -12,8 +12,8 @@
namespace a {
class c {
public:
- c () {}
- ~c() {}
+ c();
+ ~c();
void func1()
{
puts (__PRETTY_FUNCTION__);
@@ -27,13 +27,16 @@ namespace a {
puts (__PRETTY_FUNCTION__);
}
};
+
+ c::c() {}
+ c::~c() {}
}
namespace b {
class c {
public:
- c () {}
- ~c() {}
+ c();
+ ~c();
void func1()
{
puts (__PRETTY_FUNCTION__);
@@ -43,6 +46,9 @@ namespace b {
puts (__PRETTY_FUNCTION__);
}
};
+
+ c::c() {}
+ c::~c() {}
}
namespace c {
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py
index f7a19098b492..2aac3a9600d3 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py
@@ -8,10 +8,11 @@ from __future__ import print_function
import os
import re
-import lldb
-import lldbsuite.test.lldbutil as lldbutil
import sys
+import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
class TestCPPExceptionBreakpoint (TestBase):
@@ -19,7 +20,7 @@ class TestCPPExceptionBreakpoint (TestBase):
my_var = 10
@add_test_categories(['pyapi'])
- @expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support throw or catch
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24538")
def test_cpp_exception_breakpoint(self):
"""Test setting and hitting the C++ exception breakpoint."""
self.build()
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py
index b32c970301c9..de61f9e88f1b 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py
@@ -6,14 +6,15 @@ from __future__ import print_function
import os
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class DebugBreakTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIf(archs=not_in(["i386", "i686"]))
+ @skipIf(archs=no_match(["i386", "i686", "x86_64"]))
@no_debug_info_test
def test_asm_int_3(self):
"""Test that intrinsics like `__debugbreak();` and `asm {"int3"}` are treated like breakpoints."""
@@ -26,13 +27,15 @@ class DebugBreakTestCase(TestBase):
# We've hit the first stop, so grab the frame.
self.assertEqual(process.GetState(), lldb.eStateStopped)
- thread = process.GetThreadAtIndex(0)
+ stop_reason = lldb.eStopReasonException if (lldbplatformutil.getPlatform()=="windows" or lldbplatformutil.getPlatform()=="macosx") else lldb.eStopReasonSignal
+ thread = lldbutil.get_stopped_thread(process, stop_reason)
+ self.assertIsNotNone(thread, "Unable to find thread stopped at the __debugbreak()")
frame = thread.GetFrameAtIndex(0)
# We should be in funciton 'bar'.
self.assertTrue(frame.IsValid())
function_name = frame.GetFunctionName()
- self.assertTrue('bar' in function_name)
+ self.assertTrue('bar' in function_name, "Unexpected function name {}".format(function_name))
# We should be able to evaluate the parameter foo.
value = frame.EvaluateExpression('*foo')
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py
index 648a0f5ea07c..c48cee1bd2b2 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py
@@ -8,11 +8,12 @@ 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
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
@skipUnlessDarwin
class TestObjCBreakpoints(TestBase):
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/Makefile
new file mode 100644
index 000000000000..ac984f101c18
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c a.c
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py
new file mode 100644
index 000000000000..81cab927d214
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py
@@ -0,0 +1,100 @@
+"""
+Test lldb breakpoint setting by source regular expression.
+This test just tests the source file & function restrictions.
+"""
+
+from __future__ import print_function
+
+import os, time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestSourceRegexBreakpoints(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_location (self):
+ self.build()
+ self.source_regex_locations()
+
+ def test_restrictions (self):
+ self.build ()
+ self.source_regex_restrictions ()
+
+
+ def source_regex_locations (self):
+ """ Test that restricting source expressions to files & to functions. """
+ # Create a target by the debugger.
+ exe = os.path.join(os.getcwd(), "a.out")
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # First look just in main:
+ target_files = lldb.SBFileSpecList()
+ target_files.Append(lldb.SBFileSpec("a.c"))
+
+ func_names = lldb.SBStringList()
+ func_names.AppendString("a_func")
+
+ source_regex = "Set . breakpoint here"
+ main_break = target.BreakpointCreateBySourceRegex (source_regex,
+ lldb.SBFileSpecList(),
+ target_files,
+ func_names)
+ num_locations = main_break.GetNumLocations()
+ self.assertTrue(num_locations == 1, "a.c in a_func should give one breakpoint, got %d."%(num_locations))
+
+ loc = main_break.GetLocationAtIndex(0)
+ self.assertTrue(loc.IsValid(), "Got a valid location.")
+ address = loc.GetAddress()
+ self.assertTrue(address.IsValid(), "Got a valid address from the location.")
+
+ a_func_line = line_number("a.c", "Set A breakpoint here")
+ line_entry = address.GetLineEntry()
+ self.assertTrue(line_entry.IsValid(), "Got a valid line entry.")
+ self.assertTrue(line_entry.line == a_func_line, "Our line number matches the one lldbtest found.")
+
+ def source_regex_restrictions (self):
+ """ Test that restricting source expressions to files & to functions. """
+ # Create a target by the debugger.
+ exe = os.path.join(os.getcwd(), "a.out")
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # First look just in main:
+ target_files = lldb.SBFileSpecList()
+ target_files.Append(lldb.SBFileSpec("main.c"))
+ source_regex = "Set . breakpoint here"
+ main_break = target.BreakpointCreateBySourceRegex (source_regex,
+ lldb.SBFileSpecList(),
+ target_files,
+ lldb.SBStringList())
+
+ num_locations = main_break.GetNumLocations()
+ self.assertTrue(num_locations == 2, "main.c should have 2 matches, got %d."%(num_locations))
+
+ # Now look in both files:
+ target_files.Append(lldb.SBFileSpec("a.c"))
+
+ main_break = target.BreakpointCreateBySourceRegex (source_regex,
+ lldb.SBFileSpecList(),
+ target_files,
+ lldb.SBStringList())
+
+ num_locations =main_break.GetNumLocations()
+ self.assertTrue(num_locations == 4, "main.c and a.c should have 4 matches, got %d."%(num_locations))
+
+ # Now restrict it to functions:
+ func_names = lldb.SBStringList()
+ func_names.AppendString("main_func")
+ main_break = target.BreakpointCreateBySourceRegex (source_regex,
+ lldb.SBFileSpecList(),
+ target_files,
+ func_names)
+
+ num_locations =main_break.GetNumLocations()
+ self.assertTrue(num_locations == 2, "main_func in main.c and a.c should have 2 matches, got %d."%(num_locations))
+
+
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.c
new file mode 100644
index 000000000000..056583f1c42c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+#include "a.h"
+
+static int
+main_func(int input)
+{
+ return printf("Set B breakpoint here: %d", input);
+}
+
+int
+a_func(int input)
+{
+ input += 1; // Set A breakpoint here;
+ return main_func(input);
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.h b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.h
new file mode 100644
index 000000000000..f578ac0304cd
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.h
@@ -0,0 +1 @@
+int a_func(int);
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/main.c
new file mode 100644
index 000000000000..9c8625e877f5
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/main.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include "a.h"
+
+int
+main_func(int input)
+{
+ return printf("Set B breakpoint here: %d.\n", input);
+}
+
+int
+main()
+{
+ a_func(10);
+ main_func(10);
+ printf("Set a breakpoint here:\n");
+ return 0;
+}