aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command')
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py140
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py28
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py5
6 files changed, 88 insertions, 99 deletions
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 386eafbb0b60..7a2dc61b1b69 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -11,18 +11,14 @@ import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+import side_effect
class BreakpointCommandTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
mydir = TestBase.compute_mydir(__file__)
- @classmethod
- def classCleanup(cls):
- """Cleanup the test byproduct of breakpoint_command_sequence(self)."""
- cls.RemoveTempFile("output.txt")
- cls.RemoveTempFile("output2.txt")
-
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
def test_breakpoint_command_sequence(self):
"""Test a sequence of breakpoint command add, list, and delete."""
@@ -49,9 +45,28 @@ class BreakpointCommandTestCase(TestBase):
self.addTearDownHook(
lambda: self.runCmd("settings clear auto-confirm"))
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
+ def test_delete_all_breakpoints(self):
+ """Test that deleting all breakpoints works."""
+ self.build()
+ exe = self.getBuildArtifact("a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_symbol(self, "main")
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ self.runCmd("breakpoint delete")
+ self.runCmd("process continue")
+ self.expect("process status", PROCESS_STOPPED,
+ patterns=['Process .* exited with status = 0'])
+
+
def breakpoint_command_sequence(self):
"""Test a sequence of breakpoint command add, list, and delete."""
- exe = os.path.join(os.getcwd(), "a.out")
+ exe = self.getBuildArtifact("a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add three breakpoints on the same line. The first time we don't specify the file,
@@ -66,12 +81,36 @@ class BreakpointCommandTestCase(TestBase):
# setting breakpoint commands on two breakpoints at a time
lldbutil.run_break_set_by_file_and_line(
self, None, self.line, num_expected_locations=1, loc_exact=True)
-
+ # Make sure relative path source breakpoints work as expected. We test
+ # with partial paths with and without "./" prefixes.
+ lldbutil.run_break_set_by_file_and_line(
+ self, "./main.c", self.line,
+ num_expected_locations=1, loc_exact=True)
+ lldbutil.run_break_set_by_file_and_line(
+ self, "breakpoint_command/main.c", self.line,
+ num_expected_locations=1, loc_exact=True)
+ lldbutil.run_break_set_by_file_and_line(
+ self, "./breakpoint_command/main.c", self.line,
+ num_expected_locations=1, loc_exact=True)
+ lldbutil.run_break_set_by_file_and_line(
+ self, "breakpoint/breakpoint_command/main.c", self.line,
+ num_expected_locations=1, loc_exact=True)
+ lldbutil.run_break_set_by_file_and_line(
+ self, "./breakpoint/breakpoint_command/main.c", self.line,
+ num_expected_locations=1, loc_exact=True)
+ # Test relative breakpoints with incorrect paths and make sure we get
+ # no breakpoint locations
+ lldbutil.run_break_set_by_file_and_line(
+ self, "invalid/main.c", self.line,
+ num_expected_locations=0, loc_exact=True)
+ lldbutil.run_break_set_by_file_and_line(
+ self, "./invalid/main.c", self.line,
+ num_expected_locations=0, loc_exact=True)
# Now add callbacks for the breakpoints just created.
self.runCmd(
"breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4")
self.runCmd(
- "breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2")
+ "breakpoint command add -s python -o 'import side_effect; side_effect.one_liner = \"one liner was here\"' 2")
self.runCmd(
"breakpoint command add --python-function bktptcmd.function 3")
@@ -104,9 +143,8 @@ class BreakpointCommandTestCase(TestBase):
"frame variable --show-types --scope"])
self.expect("breakpoint command list 2", "Breakpoint 2 command ok",
substrs=["Breakpoint commands (Python):",
- "here = open",
- "here.write",
- "here.close()"])
+ "import side_effect",
+ "side_effect.one_liner"])
self.expect("breakpoint command list 3", "Breakpoint 3 command ok",
substrs=["Breakpoint commands (Python):",
"bktptcmd.function(frame, bp_loc, internal_dict)"])
@@ -151,40 +189,14 @@ class BreakpointCommandTestCase(TestBase):
extra_options="-f a.c",
num_expected_locations=1)
- # Run the program. Remove 'output.txt' if it exists.
- self.RemoveTempFile("output.txt")
- self.RemoveTempFile("output2.txt")
+ # Reset our canary variables and run the program.
+ side_effect.one_liner = None
+ side_effect.bktptcmd = None
self.runCmd("run", RUN_SUCCEEDED)
- # Check that the file 'output.txt' exists and contains the string
- # "lldb".
-
- # The 'output.txt' file should now exist.
- self.assertTrue(
- os.path.isfile("output.txt"),
- "'output.txt' exists due to breakpoint command for breakpoint 2.")
- self.assertTrue(
- os.path.isfile("output2.txt"),
- "'output2.txt' exists due to breakpoint command for breakpoint 3.")
-
- # Read the output file produced by running the program.
- with open('output.txt', 'r') as f:
- output = f.read()
-
- self.expect(
- output,
- "File 'output.txt' and the content matches",
- exe=False,
- startstr="lldb")
-
- with open('output2.txt', 'r') as f:
- output = f.read()
-
- self.expect(
- output,
- "File 'output2.txt' and the content matches",
- exe=False,
- startstr="lldb")
+ # Check the value of canary variables.
+ self.assertEquals("one liner was here", side_effect.one_liner)
+ self.assertEquals("function was here", side_effect.bktptcmd)
# Finish the program.
self.runCmd("process continue")
@@ -237,7 +249,7 @@ class BreakpointCommandTestCase(TestBase):
def breakpoint_command_script_parameters(self):
"""Test that the frame and breakpoint location are being properly passed to the script breakpoint command function."""
- exe = os.path.join(os.getcwd(), "a.out")
+ exe = self.getBuildArtifact("a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Add a breakpoint.
@@ -245,42 +257,20 @@ class BreakpointCommandTestCase(TestBase):
self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
# Now add callbacks for the breakpoints just created.
- self.runCmd("breakpoint command add -s python -o 'here = open(\"output-2.txt\", \"w\"); here.write(str(frame) + \"\\n\"); here.write(str(bp_loc) + \"\\n\"); here.close()' 1")
-
- # Remove 'output-2.txt' if it already exists.
+ self.runCmd("breakpoint command add -s python -o 'import side_effect; side_effect.frame = str(frame); side_effect.bp_loc = str(bp_loc)' 1")
- if (os.path.exists('output-2.txt')):
- os.remove('output-2.txt')
-
- # Run program, hit breakpoint, and hopefully write out new version of
- # 'output-2.txt'
+ # Reset canary variables and run.
+ side_effect.frame = None
+ side_effect.bp_loc = None
self.runCmd("run", RUN_SUCCEEDED)
- # Check that the file 'output.txt' exists and contains the string
- # "lldb".
-
- # The 'output-2.txt' file should now exist.
- self.assertTrue(
- os.path.isfile("output-2.txt"),
- "'output-2.txt' exists due to breakpoint command for breakpoint 1.")
-
- # Read the output file produced by running the program.
- with open('output-2.txt', 'r') as f:
- output = f.read()
-
- self.expect(
- output,
- "File 'output-2.txt' and the content matches",
- exe=False,
- startstr="frame #0:",
- patterns=["1.* where = .*main .* resolved, hit count = 1"])
-
- # Now remove 'output-2.txt'
- os.remove('output-2.txt')
+ self.expect(side_effect.frame, exe=False, startstr="frame #0:")
+ self.expect(side_effect.bp_loc, exe=False,
+ patterns=["1.* where = .*main .* resolved, hit count = 1"])
def breakpoint_commands_on_creation(self):
"""Test that setting breakpoint commands when creating the breakpoint works"""
- exe = os.path.join(os.getcwd(), "a.out")
+ exe = self.getBuildArtifact("a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), "Created an invalid target.")
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 01af8369aaf1..7c7aad0bc81e 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
@@ -12,12 +12,13 @@ import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+import side_effect
class PythonBreakpointCommandSettingTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- my_var = 10
+ NO_DEBUG_INFO_TESTCASE = True
@add_test_categories(['pyapi'])
def test_step_out_python(self):
@@ -31,7 +32,7 @@ class PythonBreakpointCommandSettingTestCase(TestBase):
self.main_source_spec = lldb.SBFileSpec(self.main_source)
def do_set_python_command_from_python(self):
- exe = os.path.join(os.getcwd(), "a.out")
+ exe = self.getBuildArtifact("a.out")
error = lldb.SBError()
self.target = self.dbg.CreateTarget(exe)
@@ -69,12 +70,9 @@ class PythonBreakpointCommandSettingTestCase(TestBase):
self.assertTrue(got_one_in_B, "Failed to match the pattern in B")
self.target.BreakpointDelete(no_files_bkpt.GetID())
- PythonBreakpointCommandSettingTestCase.my_var = 10
error = lldb.SBError()
- error = body_bkpt.SetScriptCallbackBody("\
-import TestBreakpointCommandsFromPython\n\
-TestBreakpointCommandsFromPython.PythonBreakpointCommandSettingTestCase.my_var = 20\n\
-print('Hit breakpoint')")
+ error = body_bkpt.SetScriptCallbackBody(
+ "import side_effect; side_effect.callback = 'callback was here'")
self.assertTrue(
error.Success(),
"Failed to set the script callback body: %s." %
@@ -84,9 +82,9 @@ print('Hit breakpoint')")
"command script import --allow-reload ./bktptcmd.py")
func_bkpt.SetScriptCallbackFunction("bktptcmd.function")
- # We will use the function that touches a text file, so remove it
- # first:
- self.RemoveTempFile("output2.txt")
+ # Clear out canary variables
+ side_effect.bktptcmd = None
+ side_effect.callback = None
# Now launch the process, and do not stop at entry point.
self.process = self.target.LaunchSimple(
@@ -100,11 +98,5 @@ print('Hit breakpoint')")
self.assertTrue(len(threads) == 1, "Stopped at inner breakpoint.")
self.thread = threads[0]
- self.assertTrue(PythonBreakpointCommandSettingTestCase.my_var == 20)
-
- # Check for the function version as well, which produced this file:
- # Remember to clean up after ourselves...
- self.assertTrue(
- os.path.isfile("output2.txt"),
- "'output2.txt' exists due to breakpoint command for breakpoint function.")
- self.RemoveTempFile("output2.txt")
+ self.assertEquals("callback was here", side_effect.callback)
+ self.assertEquals("function was here", side_effect.bktptcmd)
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py
index baf237bf0764..d064b75b91cf 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py
@@ -31,7 +31,7 @@ class RegexpBreakCommandTestCase(TestBase):
def regexp_break_command(self):
"""Test the super consie "b" command, which is analias for _regexp-break."""
- exe = os.path.join(os.getcwd(), "a.out")
+ exe = self.getBuildArtifact("a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
break_results = lldbutil.run_break_set_command(
@@ -54,7 +54,7 @@ class RegexpBreakCommandTestCase(TestBase):
num_locations=1)
# Check breakpoint with full file path.
- full_path = os.path.join(os.getcwd(), self.source)
+ full_path = os.path.join(self.getSourceDir(), self.source)
break_results = lldbutil.run_break_set_command(
self, "b %s:%d" % (full_path, self.line))
lldbutil.check_breakpoint_result(
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py
index cf1fc2cf02c9..ac0f753ccd8d 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py
@@ -1,7 +1,5 @@
from __future__ import print_function
-
+import side_effect
def function(frame, bp_loc, dict):
- there = open("output2.txt", "w")
- print("lldb", file=there)
- there.close()
+ side_effect.bktptcmd = "function was here"
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c
index 62ec97f43284..702644b692d8 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c
@@ -9,5 +9,9 @@
int main (int argc, char const *argv[])
{
+ // Add a body to the function, so we can set more than one
+ // breakpoint in it.
+ static volatile int var = 0;
+ var++;
return 0; // Set break point at this line.
}
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py
new file mode 100644
index 000000000000..ef4ab2b159cc
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py
@@ -0,0 +1,5 @@
+"""
+A dummy module for testing the execution of various breakpoint commands. A
+command will modify a global variable in this module and test will check its
+value.
+"""