[lldb-dap] Re-land refactor of DebugCommunication. (#147787)
Originally commited in 362b9d78b4ee9107da2b5e90b3764b0f0fa610fe and then reverted in cb63b75e32a415c9bfc298ed7fdcd67e8d9de54c. This re-lands a subset of the changes to dap_server.py/DebugCommunication and addresses the python3.10 compatibility issue. This includes less type annotations since those were the reason for the failures on that specific version of python. I've done additional testing on python3.8, python3.10 and python3.13 to further validate these changes.
This commit is contained in:
parent
bce9b6d177
commit
13eca5248c
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
import os
|
||||
import time
|
||||
from typing import Optional
|
||||
from typing import Optional, Callable, Any, List, Union
|
||||
import uuid
|
||||
|
||||
import dap_server
|
||||
@ -67,7 +67,10 @@ class DAPTestCaseBase(TestBase):
|
||||
self, source_reference, lines, data=None, wait_for_resolve=True
|
||||
):
|
||||
return self.set_source_breakpoints_from_source(
|
||||
Source(source_reference=source_reference), lines, data, wait_for_resolve
|
||||
Source.build(source_reference=source_reference),
|
||||
lines,
|
||||
data,
|
||||
wait_for_resolve,
|
||||
)
|
||||
|
||||
def set_source_breakpoints_from_source(
|
||||
@ -120,11 +123,19 @@ class DAPTestCaseBase(TestBase):
|
||||
f"Expected to resolve all breakpoints. Unresolved breakpoint ids: {unresolved_breakpoints}",
|
||||
)
|
||||
|
||||
def waitUntil(self, condition_callback):
|
||||
for _ in range(20):
|
||||
if condition_callback():
|
||||
def wait_until(
|
||||
self,
|
||||
predicate: Callable[[], bool],
|
||||
delay: float = 0.5,
|
||||
timeout: float = DEFAULT_TIMEOUT,
|
||||
) -> bool:
|
||||
"""Repeatedly run the predicate until either the predicate returns True
|
||||
or a timeout has occurred."""
|
||||
deadline = time.monotonic() + timeout
|
||||
while deadline > time.monotonic():
|
||||
if predicate():
|
||||
return True
|
||||
time.sleep(0.5)
|
||||
time.sleep(delay)
|
||||
return False
|
||||
|
||||
def assertCapabilityIsSet(self, key: str, msg: Optional[str] = None) -> None:
|
||||
@ -137,13 +148,16 @@ class DAPTestCaseBase(TestBase):
|
||||
if key in self.dap_server.capabilities:
|
||||
self.assertEqual(self.dap_server.capabilities[key], False, msg)
|
||||
|
||||
def verify_breakpoint_hit(self, breakpoint_ids, timeout=DEFAULT_TIMEOUT):
|
||||
def verify_breakpoint_hit(
|
||||
self, breakpoint_ids: List[Union[int, str]], timeout: float = DEFAULT_TIMEOUT
|
||||
):
|
||||
"""Wait for the process we are debugging to stop, and verify we hit
|
||||
any breakpoint location in the "breakpoint_ids" array.
|
||||
"breakpoint_ids" should be a list of breakpoint ID strings
|
||||
(["1", "2"]). The return value from self.set_source_breakpoints()
|
||||
or self.set_function_breakpoints() can be passed to this function"""
|
||||
stopped_events = self.dap_server.wait_for_stopped(timeout)
|
||||
normalized_bp_ids = [str(b) for b in breakpoint_ids]
|
||||
for stopped_event in stopped_events:
|
||||
if "body" in stopped_event:
|
||||
body = stopped_event["body"]
|
||||
@ -154,22 +168,16 @@ class DAPTestCaseBase(TestBase):
|
||||
and body["reason"] != "instruction breakpoint"
|
||||
):
|
||||
continue
|
||||
if "description" not in body:
|
||||
if "hitBreakpointIds" not in body:
|
||||
continue
|
||||
# Descriptions for breakpoints will be in the form
|
||||
# "breakpoint 1.1", so look for any description that matches
|
||||
# ("breakpoint 1.") in the description field as verification
|
||||
# that one of the breakpoint locations was hit. DAP doesn't
|
||||
# allow breakpoints to have multiple locations, but LLDB does.
|
||||
# So when looking at the description we just want to make sure
|
||||
# the right breakpoint matches and not worry about the actual
|
||||
# location.
|
||||
description = body["description"]
|
||||
for breakpoint_id in breakpoint_ids:
|
||||
match_desc = f"breakpoint {breakpoint_id}."
|
||||
if match_desc in description:
|
||||
hit_breakpoint_ids = body["hitBreakpointIds"]
|
||||
for bp in hit_breakpoint_ids:
|
||||
if str(bp) in normalized_bp_ids:
|
||||
return
|
||||
self.assertTrue(False, f"breakpoint not hit, stopped_events={stopped_events}")
|
||||
self.assertTrue(
|
||||
False,
|
||||
f"breakpoint not hit, wanted breakpoint_ids {breakpoint_ids} in stopped_events {stopped_events}",
|
||||
)
|
||||
|
||||
def verify_all_breakpoints_hit(self, breakpoint_ids, timeout=DEFAULT_TIMEOUT):
|
||||
"""Wait for the process we are debugging to stop, and verify we hit
|
||||
@ -213,7 +221,7 @@ class DAPTestCaseBase(TestBase):
|
||||
return True
|
||||
return False
|
||||
|
||||
def verify_commands(self, flavor, output, commands):
|
||||
def verify_commands(self, flavor: str, output: str, commands: list[str]):
|
||||
self.assertTrue(output and len(output) > 0, "expect console output")
|
||||
lines = output.splitlines()
|
||||
prefix = "(lldb) "
|
||||
@ -226,10 +234,11 @@ class DAPTestCaseBase(TestBase):
|
||||
found = True
|
||||
break
|
||||
self.assertTrue(
|
||||
found, "verify '%s' found in console output for '%s'" % (cmd, flavor)
|
||||
found,
|
||||
f"Command '{flavor}' - '{cmd}' not found in output: {output}",
|
||||
)
|
||||
|
||||
def get_dict_value(self, d, key_path):
|
||||
def get_dict_value(self, d: dict, key_path: list[str]) -> Any:
|
||||
"""Verify each key in the key_path array is in contained in each
|
||||
dictionary within "d". Assert if any key isn't in the
|
||||
corresponding dictionary. This is handy for grabbing values from VS
|
||||
@ -298,28 +307,34 @@ class DAPTestCaseBase(TestBase):
|
||||
return (source["path"], stackFrame["line"])
|
||||
return ("", 0)
|
||||
|
||||
def get_stdout(self, timeout=0.0):
|
||||
return self.dap_server.get_output("stdout", timeout=timeout)
|
||||
def get_stdout(self):
|
||||
return self.dap_server.get_output("stdout")
|
||||
|
||||
def get_console(self, timeout=0.0):
|
||||
return self.dap_server.get_output("console", timeout=timeout)
|
||||
def get_console(self):
|
||||
return self.dap_server.get_output("console")
|
||||
|
||||
def get_important(self, timeout=0.0):
|
||||
return self.dap_server.get_output("important", timeout=timeout)
|
||||
def get_important(self):
|
||||
return self.dap_server.get_output("important")
|
||||
|
||||
def collect_stdout(self, timeout_secs, pattern=None):
|
||||
def collect_stdout(
|
||||
self, timeout: float = DEFAULT_TIMEOUT, pattern: Optional[str] = None
|
||||
) -> str:
|
||||
return self.dap_server.collect_output(
|
||||
"stdout", timeout_secs=timeout_secs, pattern=pattern
|
||||
"stdout", timeout=timeout, pattern=pattern
|
||||
)
|
||||
|
||||
def collect_console(self, timeout_secs, pattern=None):
|
||||
def collect_console(
|
||||
self, timeout: float = DEFAULT_TIMEOUT, pattern: Optional[str] = None
|
||||
) -> str:
|
||||
return self.dap_server.collect_output(
|
||||
"console", timeout_secs=timeout_secs, pattern=pattern
|
||||
"console", timeout=timeout, pattern=pattern
|
||||
)
|
||||
|
||||
def collect_important(self, timeout_secs, pattern=None):
|
||||
def collect_important(
|
||||
self, timeout: float = DEFAULT_TIMEOUT, pattern: Optional[str] = None
|
||||
) -> str:
|
||||
return self.dap_server.collect_output(
|
||||
"important", timeout_secs=timeout_secs, pattern=pattern
|
||||
"important", timeout=timeout, pattern=pattern
|
||||
)
|
||||
|
||||
def get_local_as_int(self, name, threadId=None):
|
||||
|
@ -153,7 +153,7 @@ class TestDAP_attach(lldbdap_testcase.DAPTestCaseBase):
|
||||
breakpoint_ids = self.set_function_breakpoints(functions)
|
||||
self.assertEqual(len(breakpoint_ids), len(functions), "expect one breakpoint")
|
||||
self.continue_to_breakpoints(breakpoint_ids)
|
||||
output = self.collect_console(timeout_secs=10, pattern=stopCommands[-1])
|
||||
output = self.collect_console(timeout=10, pattern=stopCommands[-1])
|
||||
self.verify_commands("stopCommands", output, stopCommands)
|
||||
|
||||
# Continue after launch and hit the "pause()" call and stop the target.
|
||||
@ -163,7 +163,7 @@ class TestDAP_attach(lldbdap_testcase.DAPTestCaseBase):
|
||||
time.sleep(0.5)
|
||||
self.dap_server.request_pause()
|
||||
self.dap_server.wait_for_stopped()
|
||||
output = self.collect_console(timeout_secs=10, pattern=stopCommands[-1])
|
||||
output = self.collect_console(timeout=10, pattern=stopCommands[-1])
|
||||
self.verify_commands("stopCommands", output, stopCommands)
|
||||
|
||||
# Continue until the program exits
|
||||
@ -172,7 +172,7 @@ class TestDAP_attach(lldbdap_testcase.DAPTestCaseBase):
|
||||
# "exitCommands" that were run after the second breakpoint was hit
|
||||
# and the "terminateCommands" due to the debugging session ending
|
||||
output = self.collect_console(
|
||||
timeout_secs=10.0,
|
||||
timeout=10.0,
|
||||
pattern=terminateCommands[0],
|
||||
)
|
||||
self.verify_commands("exitCommands", output, exitCommands)
|
||||
@ -223,7 +223,7 @@ class TestDAP_attach(lldbdap_testcase.DAPTestCaseBase):
|
||||
# "terminateCommands"
|
||||
self.dap_server.request_disconnect(terminateDebuggee=True)
|
||||
output = self.collect_console(
|
||||
timeout_secs=1.0,
|
||||
timeout=1.0,
|
||||
pattern=terminateCommands[0],
|
||||
)
|
||||
self.verify_commands("terminateCommands", output, terminateCommands)
|
||||
|
@ -2,7 +2,6 @@
|
||||
Test lldb-dap setBreakpoints request in assembly source references.
|
||||
"""
|
||||
|
||||
|
||||
from lldbsuite.test.decorators import *
|
||||
from dap_server import Source
|
||||
import lldbdap_testcase
|
||||
@ -52,7 +51,7 @@ class TestDAP_setBreakpointsAssembly(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
# Verify that setting a breakpoint on an invalid source reference fails
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source(source_reference=-1), [1]
|
||||
Source.build(source_reference=-1), [1]
|
||||
)
|
||||
self.assertIsNotNone(response)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
@ -69,7 +68,7 @@ class TestDAP_setBreakpointsAssembly(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
# Verify that setting a breakpoint on a source reference that is not created fails
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source(source_reference=200), [1]
|
||||
Source.build(source_reference=200), [1]
|
||||
)
|
||||
self.assertIsNotNone(response)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
@ -116,7 +115,7 @@ class TestDAP_setBreakpointsAssembly(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
persistent_breakpoint_source = self.dap_server.resolved_breakpoints[
|
||||
persistent_breakpoint_ids[0]
|
||||
].source()
|
||||
]["source"]
|
||||
self.assertIn(
|
||||
"adapterData",
|
||||
persistent_breakpoint_source,
|
||||
@ -139,7 +138,7 @@ class TestDAP_setBreakpointsAssembly(lldbdap_testcase.DAPTestCaseBase):
|
||||
self.dap_server.request_initialize()
|
||||
self.dap_server.request_launch(program)
|
||||
new_session_breakpoints_ids = self.set_source_breakpoints_from_source(
|
||||
Source(raw_dict=persistent_breakpoint_source),
|
||||
Source(persistent_breakpoint_source),
|
||||
[persistent_breakpoint_line],
|
||||
)
|
||||
|
||||
|
@ -58,7 +58,7 @@ class TestDAP_breakpointEvents(lldbdap_testcase.DAPTestCaseBase):
|
||||
# Set breakpoints and verify that they got set correctly
|
||||
dap_breakpoint_ids = []
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source(main_source_path), [main_bp_line]
|
||||
Source.build(path=main_source_path), [main_bp_line]
|
||||
)
|
||||
self.assertTrue(response["success"])
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
@ -70,7 +70,7 @@ class TestDAP_breakpointEvents(lldbdap_testcase.DAPTestCaseBase):
|
||||
)
|
||||
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source(foo_source_path), [foo_bp1_line]
|
||||
Source.build(path=foo_source_path), [foo_bp1_line]
|
||||
)
|
||||
self.assertTrue(response["success"])
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
|
@ -2,7 +2,6 @@
|
||||
Test lldb-dap setBreakpoints request
|
||||
"""
|
||||
|
||||
|
||||
from dap_server import Source
|
||||
import shutil
|
||||
from lldbsuite.test.decorators import *
|
||||
@ -58,7 +57,7 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
# breakpoint in main.cpp
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source(new_main_path), [main_line]
|
||||
Source.build(path=new_main_path), [main_line]
|
||||
)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(len(breakpoints), 1)
|
||||
@ -70,7 +69,7 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
# 2nd breakpoint, which is from a dynamically loaded library
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source(new_other_path), [other_line]
|
||||
Source.build(path=new_other_path), [other_line]
|
||||
)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
breakpoint = breakpoints[0]
|
||||
@ -85,7 +84,7 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
# 2nd breakpoint again, which should be valid at this point
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source(new_other_path), [other_line]
|
||||
Source.build(path=new_other_path), [other_line]
|
||||
)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
breakpoint = breakpoints[0]
|
||||
@ -129,7 +128,9 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
self.build_and_launch(program)
|
||||
|
||||
# Set 3 breakpoints and verify that they got set correctly
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source.build(path=self.main_path), lines
|
||||
)
|
||||
line_to_id = {}
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(
|
||||
@ -154,7 +155,9 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
lines.remove(second_line)
|
||||
# Set 2 breakpoints and verify that the previous breakpoints that were
|
||||
# set above are still set.
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source.build(path=self.main_path), lines
|
||||
)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(
|
||||
len(breakpoints),
|
||||
@ -199,7 +202,9 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
# Now clear all breakpoints for the source file by passing down an
|
||||
# empty lines array
|
||||
lines = []
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source.build(path=self.main_path), lines
|
||||
)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(
|
||||
len(breakpoints),
|
||||
@ -219,7 +224,9 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
# Now set a breakpoint again in the same source file and verify it
|
||||
# was added.
|
||||
lines = [second_line]
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source.build(path=self.main_path), lines
|
||||
)
|
||||
if response:
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(
|
||||
@ -270,7 +277,9 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
self.build_and_launch(program)
|
||||
|
||||
# Set one breakpoint and verify that it got set correctly.
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source.build(path=self.main_path), lines
|
||||
)
|
||||
line_to_id = {}
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(
|
||||
@ -286,7 +295,9 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
# Now clear all breakpoints for the source file by not setting the
|
||||
# lines array.
|
||||
lines = None
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source.build(path=self.main_path), lines
|
||||
)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(len(breakpoints), 0, "expect no source breakpoints")
|
||||
|
||||
@ -362,7 +373,7 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
# Set two breakpoints on the loop line at different columns.
|
||||
columns = [13, 39]
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source(self.main_path),
|
||||
Source.build(path=self.main_path),
|
||||
[loop_line, loop_line],
|
||||
list({"column": c} for c in columns),
|
||||
)
|
||||
|
@ -10,16 +10,14 @@ import lldbdap_testcase
|
||||
|
||||
|
||||
class TestDAP_cancel(lldbdap_testcase.DAPTestCaseBase):
|
||||
def send_async_req(self, command: str, arguments={}) -> int:
|
||||
seq = self.dap_server.sequence
|
||||
self.dap_server.send_packet(
|
||||
def send_async_req(self, command: str, arguments: dict = {}) -> int:
|
||||
return self.dap_server.send_packet(
|
||||
{
|
||||
"type": "request",
|
||||
"command": command,
|
||||
"arguments": arguments,
|
||||
}
|
||||
)
|
||||
return seq
|
||||
|
||||
def async_blocking_request(self, duration: float) -> int:
|
||||
"""
|
||||
@ -54,18 +52,18 @@ class TestDAP_cancel(lldbdap_testcase.DAPTestCaseBase):
|
||||
pending_seq = self.async_blocking_request(duration=self.DEFAULT_TIMEOUT / 2)
|
||||
cancel_seq = self.async_cancel(requestId=pending_seq)
|
||||
|
||||
blocking_resp = self.dap_server.recv_packet(filter_type=["response"])
|
||||
blocking_resp = self.dap_server.receive_response(blocking_seq)
|
||||
self.assertEqual(blocking_resp["request_seq"], blocking_seq)
|
||||
self.assertEqual(blocking_resp["command"], "evaluate")
|
||||
self.assertEqual(blocking_resp["success"], True)
|
||||
|
||||
pending_resp = self.dap_server.recv_packet(filter_type=["response"])
|
||||
pending_resp = self.dap_server.receive_response(pending_seq)
|
||||
self.assertEqual(pending_resp["request_seq"], pending_seq)
|
||||
self.assertEqual(pending_resp["command"], "evaluate")
|
||||
self.assertEqual(pending_resp["success"], False)
|
||||
self.assertEqual(pending_resp["message"], "cancelled")
|
||||
|
||||
cancel_resp = self.dap_server.recv_packet(filter_type=["response"])
|
||||
cancel_resp = self.dap_server.receive_response(cancel_seq)
|
||||
self.assertEqual(cancel_resp["request_seq"], cancel_seq)
|
||||
self.assertEqual(cancel_resp["command"], "cancel")
|
||||
self.assertEqual(cancel_resp["success"], True)
|
||||
@ -80,19 +78,16 @@ class TestDAP_cancel(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
blocking_seq = self.async_blocking_request(duration=self.DEFAULT_TIMEOUT / 2)
|
||||
# Wait for the sleep to start to cancel the inflight request.
|
||||
self.collect_console(
|
||||
timeout_secs=self.DEFAULT_TIMEOUT,
|
||||
pattern="starting sleep",
|
||||
)
|
||||
self.collect_console(pattern="starting sleep")
|
||||
cancel_seq = self.async_cancel(requestId=blocking_seq)
|
||||
|
||||
blocking_resp = self.dap_server.recv_packet(filter_type=["response"])
|
||||
blocking_resp = self.dap_server.receive_response(blocking_seq)
|
||||
self.assertEqual(blocking_resp["request_seq"], blocking_seq)
|
||||
self.assertEqual(blocking_resp["command"], "evaluate")
|
||||
self.assertEqual(blocking_resp["success"], False)
|
||||
self.assertEqual(blocking_resp["message"], "cancelled")
|
||||
|
||||
cancel_resp = self.dap_server.recv_packet(filter_type=["response"])
|
||||
cancel_resp = self.dap_server.receive_response(cancel_seq)
|
||||
self.assertEqual(cancel_resp["request_seq"], cancel_seq)
|
||||
self.assertEqual(cancel_resp["command"], "cancel")
|
||||
self.assertEqual(cancel_resp["success"], True)
|
||||
|
@ -1,8 +1,8 @@
|
||||
import os
|
||||
"""
|
||||
Test lldb-dap command hooks
|
||||
"""
|
||||
|
||||
import dap_server
|
||||
import lldbdap_testcase
|
||||
from lldbsuite.test import lldbtest, lldbutil
|
||||
from lldbsuite.test.decorators import *
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ class TestDAP_commands(lldbdap_testcase.DAPTestCaseBase):
|
||||
exitCommands=["?" + command_quiet, command_not_quiet],
|
||||
)
|
||||
full_output = self.collect_console(
|
||||
timeout_secs=1.0,
|
||||
timeout=1.0,
|
||||
pattern=command_not_quiet,
|
||||
)
|
||||
self.assertNotIn(command_quiet, full_output)
|
||||
@ -51,7 +51,7 @@ class TestDAP_commands(lldbdap_testcase.DAPTestCaseBase):
|
||||
expectFailure=True,
|
||||
)
|
||||
full_output = self.collect_console(
|
||||
timeout_secs=1.0,
|
||||
timeout=1.0,
|
||||
pattern=command_abort_on_error,
|
||||
)
|
||||
self.assertNotIn(command_quiet, full_output)
|
||||
@ -81,9 +81,6 @@ class TestDAP_commands(lldbdap_testcase.DAPTestCaseBase):
|
||||
expectFailure=True,
|
||||
)
|
||||
self.assertFalse(resp["success"], "expected 'attach' failure")
|
||||
full_output = self.collect_console(
|
||||
timeout_secs=1.0,
|
||||
pattern=command_abort_on_error,
|
||||
)
|
||||
full_output = self.collect_console(pattern=command_abort_on_error)
|
||||
self.assertNotIn(command_quiet, full_output)
|
||||
self.assertIn(command_abort_on_error, full_output)
|
||||
|
@ -139,9 +139,7 @@ class TestDAP_console(lldbdap_testcase.DAPTestCaseBase):
|
||||
process.wait()
|
||||
|
||||
# Get the console output
|
||||
console_output = self.collect_console(
|
||||
timeout_secs=10.0, pattern="exited with status"
|
||||
)
|
||||
console_output = self.collect_console(pattern="exited with status")
|
||||
|
||||
# Verify the exit status message is printed.
|
||||
self.assertRegex(
|
||||
@ -156,9 +154,7 @@ class TestDAP_console(lldbdap_testcase.DAPTestCaseBase):
|
||||
self.continue_to_exit()
|
||||
|
||||
# Get the console output
|
||||
console_output = self.collect_console(
|
||||
timeout_secs=10.0, pattern="exited with status"
|
||||
)
|
||||
console_output = self.collect_console(pattern="exited with status")
|
||||
|
||||
# Verify the exit status message is printed.
|
||||
self.assertIn(
|
||||
@ -177,9 +173,7 @@ class TestDAP_console(lldbdap_testcase.DAPTestCaseBase):
|
||||
f"target create --core {core}", context="repl"
|
||||
)
|
||||
|
||||
diagnostics = self.collect_important(
|
||||
timeout_secs=self.DEFAULT_TIMEOUT, pattern="minidump file"
|
||||
)
|
||||
diagnostics = self.collect_important(pattern="minidump file")
|
||||
|
||||
self.assertIn(
|
||||
"warning: unable to retrieve process ID from minidump file",
|
||||
|
@ -34,7 +34,7 @@ class TestDAP_InstructionBreakpointTestCase(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
# Set source breakpoint 1
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source(self.main_path), [main_line]
|
||||
Source.build(path=self.main_path), [main_line]
|
||||
)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(len(breakpoints), 1)
|
||||
|
@ -2,12 +2,9 @@
|
||||
Test lldb-dap setBreakpoints request
|
||||
"""
|
||||
|
||||
import dap_server
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
import lldbdap_testcase
|
||||
import time
|
||||
import os
|
||||
import re
|
||||
|
||||
@ -208,7 +205,7 @@ class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase):
|
||||
self.continue_to_exit()
|
||||
# Now get the STDOUT and verify our program argument is correct
|
||||
output = self.get_stdout()
|
||||
self.assertEqual(output, None, "expect no program output")
|
||||
self.assertEqual(output, "", "expect no program output")
|
||||
|
||||
@skipIfWindows
|
||||
@skipIfLinux # shell argument expansion doesn't seem to work on Linux
|
||||
@ -409,14 +406,14 @@ class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase):
|
||||
# Get output from the console. This should contain both the
|
||||
# "stopCommands" that were run after the first breakpoint was hit
|
||||
self.continue_to_breakpoints(breakpoint_ids)
|
||||
output = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
output = self.get_console()
|
||||
self.verify_commands("stopCommands", output, stopCommands)
|
||||
|
||||
# Continue again and hit the second breakpoint.
|
||||
# Get output from the console. This should contain both the
|
||||
# "stopCommands" that were run after the second breakpoint was hit
|
||||
self.continue_to_breakpoints(breakpoint_ids)
|
||||
output = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
output = self.get_console()
|
||||
self.verify_commands("stopCommands", output, stopCommands)
|
||||
|
||||
# Continue until the program exits
|
||||
@ -424,10 +421,7 @@ class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase):
|
||||
# Get output from the console. This should contain both the
|
||||
# "exitCommands" that were run after the second breakpoint was hit
|
||||
# and the "terminateCommands" due to the debugging session ending
|
||||
output = self.collect_console(
|
||||
timeout_secs=1.0,
|
||||
pattern=terminateCommands[0],
|
||||
)
|
||||
output = self.collect_console(pattern=terminateCommands[0])
|
||||
self.verify_commands("exitCommands", output, exitCommands)
|
||||
self.verify_commands("terminateCommands", output, terminateCommands)
|
||||
|
||||
@ -480,21 +474,21 @@ class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase):
|
||||
self.verify_commands("launchCommands", output, launchCommands)
|
||||
# Verify the "stopCommands" here
|
||||
self.continue_to_next_stop()
|
||||
output = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
output = self.get_console()
|
||||
self.verify_commands("stopCommands", output, stopCommands)
|
||||
|
||||
# Continue and hit the second breakpoint.
|
||||
# Get output from the console. This should contain both the
|
||||
# "stopCommands" that were run after the first breakpoint was hit
|
||||
self.continue_to_next_stop()
|
||||
output = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
output = self.get_console()
|
||||
self.verify_commands("stopCommands", output, stopCommands)
|
||||
|
||||
# Continue until the program exits
|
||||
self.continue_to_exit()
|
||||
# Get output from the console. This should contain both the
|
||||
# "exitCommands" that were run after the second breakpoint was hit
|
||||
output = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
output = self.get_console()
|
||||
self.verify_commands("exitCommands", output, exitCommands)
|
||||
|
||||
def test_failing_launch_commands(self):
|
||||
@ -558,10 +552,7 @@ class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase):
|
||||
# Once it's disconnected the console should contain the
|
||||
# "terminateCommands"
|
||||
self.dap_server.request_disconnect(terminateDebuggee=True)
|
||||
output = self.collect_console(
|
||||
timeout_secs=1.0,
|
||||
pattern=terminateCommands[0],
|
||||
)
|
||||
output = self.collect_console(pattern=terminateCommands[0])
|
||||
self.verify_commands("terminateCommands", output, terminateCommands)
|
||||
|
||||
@skipIfWindows
|
||||
|
@ -23,15 +23,15 @@ class TestDAP_module_event(lldbdap_testcase.DAPTestCaseBase):
|
||||
self.continue_to_breakpoints(breakpoint_ids)
|
||||
|
||||
# We're now stopped at breakpoint 1 before the dlopen. Flush all the module events.
|
||||
event = self.dap_server.wait_for_event("module", 0.25)
|
||||
event = self.dap_server.wait_for_event(["module"], 0.25)
|
||||
while event is not None:
|
||||
event = self.dap_server.wait_for_event("module", 0.25)
|
||||
event = self.dap_server.wait_for_event(["module"], 0.25)
|
||||
|
||||
# Continue to the second breakpoint, before the dlclose.
|
||||
self.continue_to_breakpoints(breakpoint_ids)
|
||||
|
||||
# Make sure we got a module event for libother.
|
||||
event = self.dap_server.wait_for_event("module", 5)
|
||||
event = self.dap_server.wait_for_event(["module"], 5)
|
||||
self.assertIsNotNone(event, "didn't get a module event")
|
||||
module_name = event["body"]["module"]["name"]
|
||||
module_id = event["body"]["module"]["id"]
|
||||
@ -42,7 +42,7 @@ class TestDAP_module_event(lldbdap_testcase.DAPTestCaseBase):
|
||||
self.continue_to_breakpoints(breakpoint_ids)
|
||||
|
||||
# Make sure we got a module event for libother.
|
||||
event = self.dap_server.wait_for_event("module", 5)
|
||||
event = self.dap_server.wait_for_event(["module"], 5)
|
||||
self.assertIsNotNone(event, "didn't get a module event")
|
||||
reason = event["body"]["reason"]
|
||||
self.assertEqual(reason, "removed")
|
||||
@ -56,7 +56,7 @@ class TestDAP_module_event(lldbdap_testcase.DAPTestCaseBase):
|
||||
self.assertEqual(module_data["name"], "", "expects empty name.")
|
||||
|
||||
# Make sure we do not send another event
|
||||
event = self.dap_server.wait_for_event("module", 3)
|
||||
event = self.dap_server.wait_for_event(["module"], 3)
|
||||
self.assertIsNone(event, "expects no events.")
|
||||
|
||||
self.continue_to_exit()
|
||||
|
@ -1,11 +1,9 @@
|
||||
"""
|
||||
Test lldb-dap setBreakpoints request
|
||||
Test lldb-dap module request
|
||||
"""
|
||||
|
||||
import dap_server
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
from lldbsuite.test import lldbutil
|
||||
import lldbdap_testcase
|
||||
import re
|
||||
|
||||
@ -55,7 +53,7 @@ class TestDAP_module(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
if expect_debug_info_size:
|
||||
self.assertTrue(
|
||||
self.waitUntil(check_symbols_loaded_with_size),
|
||||
self.wait_until(check_symbols_loaded_with_size),
|
||||
"expect has debug info size",
|
||||
)
|
||||
|
||||
@ -68,7 +66,7 @@ class TestDAP_module(lldbdap_testcase.DAPTestCaseBase):
|
||||
# Collect all the module names we saw as events.
|
||||
module_new_names = []
|
||||
module_changed_names = []
|
||||
module_event = self.dap_server.wait_for_event("module", 1)
|
||||
module_event = self.dap_server.wait_for_event(["module"], 1)
|
||||
while module_event is not None:
|
||||
reason = module_event["body"]["reason"]
|
||||
if reason == "new":
|
||||
@ -76,7 +74,7 @@ class TestDAP_module(lldbdap_testcase.DAPTestCaseBase):
|
||||
elif reason == "changed":
|
||||
module_changed_names.append(module_event["body"]["module"]["name"])
|
||||
|
||||
module_event = self.dap_server.wait_for_event("module", 1)
|
||||
module_event = self.dap_server.wait_for_event(["module"], 1)
|
||||
|
||||
# Make sure we got an event for every active module.
|
||||
self.assertNotEqual(len(module_new_names), 0)
|
||||
|
@ -29,7 +29,7 @@ class TestDAP_output(lldbdap_testcase.DAPTestCaseBase):
|
||||
self.continue_to_breakpoints(breakpoint_ids)
|
||||
|
||||
# Ensure partial messages are still sent.
|
||||
output = self.collect_stdout(timeout_secs=1.0, pattern="abcdef")
|
||||
output = self.collect_stdout(timeout=1.0, pattern="abcdef")
|
||||
self.assertTrue(output and len(output) > 0, "expect program stdout")
|
||||
|
||||
self.continue_to_exit()
|
||||
@ -37,14 +37,14 @@ class TestDAP_output(lldbdap_testcase.DAPTestCaseBase):
|
||||
# Disconnecting from the server to ensure any pending IO is flushed.
|
||||
self.dap_server.request_disconnect()
|
||||
|
||||
output += self.get_stdout(timeout=self.DEFAULT_TIMEOUT)
|
||||
output += self.get_stdout()
|
||||
self.assertTrue(output and len(output) > 0, "expect program stdout")
|
||||
self.assertIn(
|
||||
"abcdefghi\r\nhello world\r\nfinally\0\0",
|
||||
output,
|
||||
"full stdout not found in: " + repr(output),
|
||||
)
|
||||
console = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
console = self.get_console()
|
||||
self.assertTrue(console and len(console) > 0, "expect dap messages")
|
||||
self.assertIn(
|
||||
"out\0\0\r\nerr\0\0\r\n", console, f"full console message not found"
|
||||
|
@ -21,7 +21,7 @@ class TestDAP_progress(lldbdap_testcase.DAPTestCaseBase):
|
||||
expected_not_in_message=None,
|
||||
only_verify_first_update=False,
|
||||
):
|
||||
self.dap_server.wait_for_event("progressEnd")
|
||||
self.dap_server.wait_for_event(["progressEnd"])
|
||||
self.assertTrue(len(self.dap_server.progress_events) > 0)
|
||||
start_found = False
|
||||
update_found = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user