Skip to content

Commit 1ac9193

Browse files
committed
Update more tests
1 parent 8c7a014 commit 1ac9193

File tree

11 files changed

+81
-26
lines changed

11 files changed

+81
-26
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ def attach(
349349
expectFailure=False,
350350
gdbRemotePort=None,
351351
gdbRemoteHostname=None,
352+
sourceBreakpoints=None,
353+
functionBreakpoints=None,
352354
):
353355
"""Build the default Makefile target, create the DAP debug adapter,
354356
and attach to the process.
@@ -366,6 +368,26 @@ def cleanup():
366368
# Initialize and launch the program
367369
self.dap_server.request_initialize(sourceInitFile)
368370
self.dap_server.wait_for_event("initialized")
371+
372+
# Set source breakpoints as part of the launch sequence.
373+
if sourceBreakpoints:
374+
for source_path, lines in sourceBreakpoints:
375+
response = self.dap_server.request_setBreakpoints(source_path, lines)
376+
self.assertTrue(
377+
response["success"],
378+
"setBreakpoints failed (%s)" % (response),
379+
)
380+
381+
# Set function breakpoints as part of the launch sequence.
382+
if functionBreakpoints:
383+
response = self.dap_server.request_setFunctionBreakpoints(
384+
functionBreakpoints
385+
)
386+
self.assertTrue(
387+
response["success"],
388+
"setFunctionBreakpoint failed (%s)" % (response),
389+
)
390+
369391
self.dap_server.request_configurationDone()
370392
response = self.dap_server.request_attach(
371393
program=program,
@@ -423,6 +445,8 @@ def launch(
423445
commandEscapePrefix=None,
424446
customFrameFormat=None,
425447
customThreadFormat=None,
448+
sourceBreakpoints=None,
449+
functionBreakpoints=None,
426450
):
427451
"""Sending launch request to dap"""
428452

@@ -439,6 +463,26 @@ def cleanup():
439463
# Initialize and launch the program
440464
self.dap_server.request_initialize(sourceInitFile)
441465
self.dap_server.wait_for_event("initialized")
466+
467+
# Set source breakpoints as part of the launch sequence.
468+
if sourceBreakpoints:
469+
for source_path, lines in sourceBreakpoints:
470+
response = self.dap_server.request_setBreakpoints(source_path, lines)
471+
self.assertTrue(
472+
response["success"],
473+
"setBreakpoints failed (%s)" % (response),
474+
)
475+
476+
# Set function breakpoints as part of the launch sequence.
477+
if functionBreakpoints:
478+
response = self.dap_server.request_setFunctionBreakpoints(
479+
functionBreakpoints
480+
)
481+
self.assertTrue(
482+
response["success"],
483+
"setFunctionBreakpoint failed (%s)" % (response),
484+
)
485+
442486
self.dap_server.request_configurationDone()
443487

444488
response = self.dap_server.request_launch(
@@ -511,6 +555,8 @@ def build_and_launch(
511555
customThreadFormat=None,
512556
launchCommands=None,
513557
expectFailure=False,
558+
sourceBreakpoints=None,
559+
functionBreakpoints=None,
514560
):
515561
"""Build the default Makefile target, create the DAP debug adapter,
516562
and launch the process.
@@ -547,6 +593,8 @@ def build_and_launch(
547593
customThreadFormat=customThreadFormat,
548594
launchCommands=launchCommands,
549595
expectFailure=expectFailure,
596+
sourceBreakpoints=sourceBreakpoints,
597+
functionBreakpoints=functionBreakpoints,
550598
)
551599

552600
def getBuiltinDebugServerTool(self):

lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Test lldb-dap completions request
33
"""
44

5-
65
import lldbdap_testcase
76
import dap_server
87
from lldbsuite.test import lldbutil
@@ -32,6 +31,7 @@
3231
variable_var1_completion = {"text": "var1", "label": "var1 -- int &"}
3332
variable_var2_completion = {"text": "var2", "label": "var2 -- int &"}
3433

34+
3535
# Older version of libcxx produce slightly different typename strings for
3636
# templates like vector.
3737
@skipIf(compiler="clang", compiler_version=["<", "16.0"])
@@ -43,16 +43,22 @@ def verify_completions(self, actual_list, expected_list, not_expected_list=[]):
4343
for not_expected_item in not_expected_list:
4444
self.assertNotIn(not_expected_item, actual_list)
4545

46-
4746
def setup_debugee(self, stopOnEntry=False):
4847
program = self.getBuildArtifact("a.out")
49-
self.build_and_launch(program, stopOnEntry=stopOnEntry)
50-
5148
source = "main.cpp"
52-
breakpoint1_line = line_number(source, "// breakpoint 1")
53-
breakpoint2_line = line_number(source, "// breakpoint 2")
54-
55-
self.set_source_breakpoints(source, [breakpoint1_line, breakpoint2_line])
49+
self.build_and_launch(
50+
program,
51+
stopOnEntry=stopOnEntry,
52+
sourceBreakpoints=[
53+
(
54+
source,
55+
[
56+
line_number(source, "// breakpoint 1"),
57+
line_number(source, "// breakpoint 2"),
58+
],
59+
),
60+
],
61+
)
5662

5763
def test_command_completions(self):
5864
"""

lldb/test/API/tools/lldb-dap/console/TestDAP_console.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def get_subprocess(root_process, process_name):
1919

2020
self.assertTrue(False, "No subprocess with name %s found" % process_name)
2121

22+
2223
class TestDAP_console(lldbdap_testcase.DAPTestCaseBase):
2324
def check_lldb_command(
2425
self, lldb_command, contains_string, assert_msg, command_escape_prefix="`"
@@ -52,7 +53,7 @@ def test_scopes_variables_setVariable_evaluate(self):
5253
character.
5354
"""
5455
program = self.getBuildArtifact("a.out")
55-
self.build_and_launch(program)
56+
self.build_and_launch(program, stopOnEntry=True)
5657
source = "main.cpp"
5758
breakpoint1_line = line_number(source, "// breakpoint 1")
5859
lines = [breakpoint1_line]
@@ -81,7 +82,7 @@ def test_scopes_variables_setVariable_evaluate(self):
8182

8283
def test_custom_escape_prefix(self):
8384
program = self.getBuildArtifact("a.out")
84-
self.build_and_launch(program, commandEscapePrefix="::")
85+
self.build_and_launch(program, stopOnEntry=True, commandEscapePrefix="::")
8586
source = "main.cpp"
8687
breakpoint1_line = line_number(source, "// breakpoint 1")
8788
breakpoint_ids = self.set_source_breakpoints(source, [breakpoint1_line])
@@ -96,7 +97,7 @@ def test_custom_escape_prefix(self):
9697

9798
def test_empty_escape_prefix(self):
9899
program = self.getBuildArtifact("a.out")
99-
self.build_and_launch(program, commandEscapePrefix="")
100+
self.build_and_launch(program, stopOnEntry=True, commandEscapePrefix="")
100101
source = "main.cpp"
101102
breakpoint1_line = line_number(source, "// breakpoint 1")
102103
breakpoint_ids = self.set_source_breakpoints(source, [breakpoint1_line])
@@ -113,7 +114,7 @@ def test_empty_escape_prefix(self):
113114
def test_exit_status_message_sigterm(self):
114115
source = "main.cpp"
115116
program = self.getBuildArtifact("a.out")
116-
self.build_and_launch(program, commandEscapePrefix="")
117+
self.build_and_launch(program, stopOnEntry=True, commandEscapePrefix="")
117118
breakpoint1_line = line_number(source, "// breakpoint 1")
118119
breakpoint_ids = self.set_source_breakpoints(source, [breakpoint1_line])
119120
self.continue_to_breakpoints(breakpoint_ids)

lldb/test/API/tools/lldb-dap/console/TestDAP_redirection_to_console.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ def test(self):
1616
"""
1717
program = self.getBuildArtifact("a.out")
1818
self.build_and_launch(
19-
program, lldbDAPEnv={"LLDB_DAP_TEST_STDOUT_STDERR_REDIRECTION": ""}
19+
program,
20+
stopOnEntry=True,
21+
lldbDAPEnv={"LLDB_DAP_TEST_STDOUT_STDERR_REDIRECTION": ""},
2022
)
2123

2224
source = "main.cpp"

lldb/test/API/tools/lldb-dap/exception/TestDAP_exception.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Test exception behavior in DAP with signal.
33
"""
44

5-
65
from lldbsuite.test.decorators import *
76
from lldbsuite.test.lldbtest import *
87
import lldbdap_testcase
@@ -17,7 +16,7 @@ def test_stopped_description(self):
1716
"""
1817
program = self.getBuildArtifact("a.out")
1918
self.build_and_launch(program)
20-
self.dap_server.request_continue()
19+
2120
self.assertTrue(self.verify_stop_exception_info("signal SIGABRT"))
2221
exceptionInfo = self.get_exceptionInfo()
2322
self.assertEqual(exceptionInfo["breakMode"], "always")

lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# Despite the test program printing correctly. See
1616
# https://github.com/llvm/llvm-project/issues/137599.
1717

18+
1819
class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase):
1920
@skipIfWindows
2021
def test_default(self):
@@ -357,6 +358,7 @@ def test_commands(self):
357358
terminateCommands = ["expr 4+2"]
358359
self.build_and_launch(
359360
program,
361+
stopOnEntry=True,
360362
initCommands=initCommands,
361363
preRunCommands=preRunCommands,
362364
postRunCommands=postRunCommands,
@@ -530,6 +532,7 @@ def test_terminate_commands(self):
530532
terminateCommands = ["expr 4+2"]
531533
self.launch(
532534
program=program,
535+
stopOnEntry=True,
533536
terminateCommands=terminateCommands,
534537
disconnectAutomatically=False,
535538
)

lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ def test_send_event(self):
1616
"""
1717
program = self.getBuildArtifact("a.out")
1818
source = "main.c"
19+
breakpoint_line = line_number(source, "// breakpoint")
1920
custom_event_body = {
2021
"key": 321,
2122
"arr": [True],
2223
}
2324
self.build_and_launch(
2425
program,
26+
sourceBreakpoints=[(source, [breakpoint_line])],
2527
stopCommands=[
2628
"lldb-dap send-event my-custom-event-no-body",
2729
"lldb-dap send-event my-custom-event '{}'".format(
@@ -30,11 +32,6 @@ def test_send_event(self):
3032
],
3133
)
3234

33-
breakpoint_line = line_number(source, "// breakpoint")
34-
35-
self.set_source_breakpoints(source, [breakpoint_line])
36-
self.continue_to_next_stop()
37-
3835
custom_event = self.dap_server.wait_for_event(
3936
filter=["my-custom-event-no-body"]
4037
)

lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_stackTrace(self):
6161
Tests the 'stackTrace' packet and all its variants.
6262
"""
6363
program = self.getBuildArtifact("a.out")
64-
self.build_and_launch(program)
64+
self.build_and_launch(program, stopOnEntry=True)
6565
source = "main.c"
6666
self.source_path = os.path.join(os.getcwd(), source)
6767
self.recurse_end = line_number(source, "recurse end")

lldb/test/API/tools/lldb-dap/stackTraceDisassemblyDisplay/TestDAP_stackTraceDisassemblyDisplay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def build_and_run_until_breakpoint(self):
3737
breakpoint_line = line_number(other_source_file, "// Break here")
3838

3939
program = self.getBuildArtifact("a.out")
40-
self.build_and_launch(program, commandEscapePrefix="")
40+
self.build_and_launch(program, stopOnEntry=True, commandEscapePrefix="")
4141

4242
breakpoint_ids = self.set_source_breakpoints(
4343
other_source_file, [breakpoint_line]

lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Test lldb-dap start-debugging reverse requests.
33
"""
44

5-
65
from lldbsuite.test.decorators import *
76
from lldbsuite.test.lldbtest import *
87
import lldbdap_testcase
@@ -16,7 +15,7 @@ def test_startDebugging(self):
1615
"""
1716
program = self.getBuildArtifact("a.out")
1817
source = "main.c"
19-
self.build_and_launch(program)
18+
self.build_and_launch(program, stopOnEntry=True)
2019

2120
breakpoint_line = line_number(source, "// breakpoint")
2221

lldb/test/API/tools/lldb-dap/variables/children/TestDAP_variables_children.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ def test_get_num_children(self):
1313
program = self.getBuildArtifact("a.out")
1414
self.build_and_launch(
1515
program,
16+
stopOnEntry=True,
1617
preRunCommands=[
1718
"command script import '%s'" % self.getSourcePath("formatter.py")
1819
],
1920
)
2021
source = "main.cpp"
2122
breakpoint1_line = line_number(source, "// break here")
22-
lines = [breakpoint1_line]
2323

2424
breakpoint_ids = self.set_source_breakpoints(
2525
source, [line_number(source, "// break here")]
@@ -47,7 +47,7 @@ def test_return_variable_with_children(self):
4747
Test the stepping out of a function with return value show the children correctly
4848
"""
4949
program = self.getBuildArtifact("a.out")
50-
self.build_and_launch(program)
50+
self.build_and_launch(program, stopOnEntry=True)
5151

5252
function_name = "test_return_variable_with_children"
5353
breakpoint_ids = self.set_function_breakpoints([function_name])

0 commit comments

Comments
 (0)