Revert "[lldb-dap] Re-land refactor of DebugCommunication. (#147787)"
This reverts commit 13eca5248c7bf625af9c7af898d48e8c0a441496. This change broke greendragon lldb test: lldb-api.tools/lldb-dap/moduleSymbols.TestDAP_moduleSymbols.py
This commit is contained in:
parent
424521f599
commit
0f33b90b61
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
import os
|
||||
import time
|
||||
from typing import Optional, Callable, Any, List, Union
|
||||
from typing import Optional
|
||||
import uuid
|
||||
|
||||
import dap_server
|
||||
@ -67,10 +67,7 @@ class DAPTestCaseBase(TestBase):
|
||||
self, source_reference, lines, data=None, wait_for_resolve=True
|
||||
):
|
||||
return self.set_source_breakpoints_from_source(
|
||||
Source.build(source_reference=source_reference),
|
||||
lines,
|
||||
data,
|
||||
wait_for_resolve,
|
||||
Source(source_reference=source_reference), lines, data, wait_for_resolve
|
||||
)
|
||||
|
||||
def set_source_breakpoints_from_source(
|
||||
@ -123,19 +120,11 @@ class DAPTestCaseBase(TestBase):
|
||||
f"Expected to resolve all breakpoints. Unresolved breakpoint ids: {unresolved_breakpoints}",
|
||||
)
|
||||
|
||||
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():
|
||||
def waitUntil(self, condition_callback):
|
||||
for _ in range(20):
|
||||
if condition_callback():
|
||||
return True
|
||||
time.sleep(delay)
|
||||
time.sleep(0.5)
|
||||
return False
|
||||
|
||||
def assertCapabilityIsSet(self, key: str, msg: Optional[str] = None) -> None:
|
||||
@ -148,16 +137,13 @@ 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: List[Union[int, str]], timeout: float = DEFAULT_TIMEOUT
|
||||
):
|
||||
def verify_breakpoint_hit(self, breakpoint_ids, timeout=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"]
|
||||
@ -168,16 +154,22 @@ class DAPTestCaseBase(TestBase):
|
||||
and body["reason"] != "instruction breakpoint"
|
||||
):
|
||||
continue
|
||||
if "hitBreakpointIds" not in body:
|
||||
if "description" not in body:
|
||||
continue
|
||||
hit_breakpoint_ids = body["hitBreakpointIds"]
|
||||
for bp in hit_breakpoint_ids:
|
||||
if str(bp) in normalized_bp_ids:
|
||||
# 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:
|
||||
return
|
||||
self.assertTrue(
|
||||
False,
|
||||
f"breakpoint not hit, wanted breakpoint_ids {breakpoint_ids} in stopped_events {stopped_events}",
|
||||
)
|
||||
self.assertTrue(False, f"breakpoint not hit, 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
|
||||
@ -221,7 +213,7 @@ class DAPTestCaseBase(TestBase):
|
||||
return True
|
||||
return False
|
||||
|
||||
def verify_commands(self, flavor: str, output: str, commands: list[str]):
|
||||
def verify_commands(self, flavor, output, commands):
|
||||
self.assertTrue(output and len(output) > 0, "expect console output")
|
||||
lines = output.splitlines()
|
||||
prefix = "(lldb) "
|
||||
@ -234,11 +226,10 @@ class DAPTestCaseBase(TestBase):
|
||||
found = True
|
||||
break
|
||||
self.assertTrue(
|
||||
found,
|
||||
f"Command '{flavor}' - '{cmd}' not found in output: {output}",
|
||||
found, "verify '%s' found in console output for '%s'" % (cmd, flavor)
|
||||
)
|
||||
|
||||
def get_dict_value(self, d: dict, key_path: list[str]) -> Any:
|
||||
def get_dict_value(self, d, key_path):
|
||||
"""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
|
||||
@ -307,34 +298,28 @@ class DAPTestCaseBase(TestBase):
|
||||
return (source["path"], stackFrame["line"])
|
||||
return ("", 0)
|
||||
|
||||
def get_stdout(self):
|
||||
return self.dap_server.get_output("stdout")
|
||||
def get_stdout(self, timeout=0.0):
|
||||
return self.dap_server.get_output("stdout", timeout=timeout)
|
||||
|
||||
def get_console(self):
|
||||
return self.dap_server.get_output("console")
|
||||
def get_console(self, timeout=0.0):
|
||||
return self.dap_server.get_output("console", timeout=timeout)
|
||||
|
||||
def get_important(self):
|
||||
return self.dap_server.get_output("important")
|
||||
def get_important(self, timeout=0.0):
|
||||
return self.dap_server.get_output("important", timeout=timeout)
|
||||
|
||||
def collect_stdout(
|
||||
self, timeout: float = DEFAULT_TIMEOUT, pattern: Optional[str] = None
|
||||
) -> str:
|
||||
def collect_stdout(self, timeout_secs, pattern=None):
|
||||
return self.dap_server.collect_output(
|
||||
"stdout", timeout=timeout, pattern=pattern
|
||||
"stdout", timeout_secs=timeout_secs, pattern=pattern
|
||||
)
|
||||
|
||||
def collect_console(
|
||||
self, timeout: float = DEFAULT_TIMEOUT, pattern: Optional[str] = None
|
||||
) -> str:
|
||||
def collect_console(self, timeout_secs, pattern=None):
|
||||
return self.dap_server.collect_output(
|
||||
"console", timeout=timeout, pattern=pattern
|
||||
"console", timeout_secs=timeout_secs, pattern=pattern
|
||||
)
|
||||
|
||||
def collect_important(
|
||||
self, timeout: float = DEFAULT_TIMEOUT, pattern: Optional[str] = None
|
||||
) -> str:
|
||||
def collect_important(self, timeout_secs, pattern=None):
|
||||
return self.dap_server.collect_output(
|
||||
"important", timeout=timeout, pattern=pattern
|
||||
"important", timeout_secs=timeout_secs, 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=10, pattern=stopCommands[-1])
|
||||
output = self.collect_console(timeout_secs=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=10, pattern=stopCommands[-1])
|
||||
output = self.collect_console(timeout_secs=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=10.0,
|
||||
timeout_secs=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=1.0,
|
||||
timeout_secs=1.0,
|
||||
pattern=terminateCommands[0],
|
||||
)
|
||||
self.verify_commands("terminateCommands", output, terminateCommands)
|
||||
|
@ -2,6 +2,7 @@
|
||||
Test lldb-dap setBreakpoints request in assembly source references.
|
||||
"""
|
||||
|
||||
|
||||
from lldbsuite.test.decorators import *
|
||||
from dap_server import Source
|
||||
import lldbdap_testcase
|
||||
@ -51,7 +52,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.build(source_reference=-1), [1]
|
||||
Source(source_reference=-1), [1]
|
||||
)
|
||||
self.assertIsNotNone(response)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
@ -68,7 +69,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.build(source_reference=200), [1]
|
||||
Source(source_reference=200), [1]
|
||||
)
|
||||
self.assertIsNotNone(response)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
@ -115,7 +116,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,
|
||||
@ -138,7 +139,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(persistent_breakpoint_source),
|
||||
Source(raw_dict=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.build(path=main_source_path), [main_bp_line]
|
||||
Source(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.build(path=foo_source_path), [foo_bp1_line]
|
||||
Source(foo_source_path), [foo_bp1_line]
|
||||
)
|
||||
self.assertTrue(response["success"])
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
|
@ -2,6 +2,7 @@
|
||||
Test lldb-dap setBreakpoints request
|
||||
"""
|
||||
|
||||
|
||||
from dap_server import Source
|
||||
import shutil
|
||||
from lldbsuite.test.decorators import *
|
||||
@ -57,7 +58,7 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
# breakpoint in main.cpp
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source.build(path=new_main_path), [main_line]
|
||||
Source(new_main_path), [main_line]
|
||||
)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(len(breakpoints), 1)
|
||||
@ -69,7 +70,7 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
# 2nd breakpoint, which is from a dynamically loaded library
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source.build(path=new_other_path), [other_line]
|
||||
Source(new_other_path), [other_line]
|
||||
)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
breakpoint = breakpoints[0]
|
||||
@ -84,7 +85,7 @@ class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
# 2nd breakpoint again, which should be valid at this point
|
||||
response = self.dap_server.request_setBreakpoints(
|
||||
Source.build(path=new_other_path), [other_line]
|
||||
Source(new_other_path), [other_line]
|
||||
)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
breakpoint = breakpoints[0]
|
||||
@ -128,9 +129,7 @@ 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.build(path=self.main_path), lines
|
||||
)
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
line_to_id = {}
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(
|
||||
@ -155,9 +154,7 @@ 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.build(path=self.main_path), lines
|
||||
)
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(
|
||||
len(breakpoints),
|
||||
@ -202,9 +199,7 @@ 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.build(path=self.main_path), lines
|
||||
)
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(
|
||||
len(breakpoints),
|
||||
@ -224,9 +219,7 @@ 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.build(path=self.main_path), lines
|
||||
)
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
if response:
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(
|
||||
@ -277,9 +270,7 @@ 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.build(path=self.main_path), lines
|
||||
)
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
line_to_id = {}
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(
|
||||
@ -295,9 +286,7 @@ 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.build(path=self.main_path), lines
|
||||
)
|
||||
response = self.dap_server.request_setBreakpoints(Source(self.main_path), lines)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(len(breakpoints), 0, "expect no source breakpoints")
|
||||
|
||||
@ -373,7 +362,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.build(path=self.main_path),
|
||||
Source(self.main_path),
|
||||
[loop_line, loop_line],
|
||||
list({"column": c} for c in columns),
|
||||
)
|
||||
|
@ -10,14 +10,16 @@ import lldbdap_testcase
|
||||
|
||||
|
||||
class TestDAP_cancel(lldbdap_testcase.DAPTestCaseBase):
|
||||
def send_async_req(self, command: str, arguments: dict = {}) -> int:
|
||||
return self.dap_server.send_packet(
|
||||
def send_async_req(self, command: str, arguments={}) -> int:
|
||||
seq = self.dap_server.sequence
|
||||
self.dap_server.send_packet(
|
||||
{
|
||||
"type": "request",
|
||||
"command": command,
|
||||
"arguments": arguments,
|
||||
}
|
||||
)
|
||||
return seq
|
||||
|
||||
def async_blocking_request(self, duration: float) -> int:
|
||||
"""
|
||||
@ -52,18 +54,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.receive_response(blocking_seq)
|
||||
blocking_resp = self.dap_server.recv_packet(filter_type=["response"])
|
||||
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.receive_response(pending_seq)
|
||||
pending_resp = self.dap_server.recv_packet(filter_type=["response"])
|
||||
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.receive_response(cancel_seq)
|
||||
cancel_resp = self.dap_server.recv_packet(filter_type=["response"])
|
||||
self.assertEqual(cancel_resp["request_seq"], cancel_seq)
|
||||
self.assertEqual(cancel_resp["command"], "cancel")
|
||||
self.assertEqual(cancel_resp["success"], True)
|
||||
@ -78,16 +80,19 @@ 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(pattern="starting sleep")
|
||||
self.collect_console(
|
||||
timeout_secs=self.DEFAULT_TIMEOUT,
|
||||
pattern="starting sleep",
|
||||
)
|
||||
cancel_seq = self.async_cancel(requestId=blocking_seq)
|
||||
|
||||
blocking_resp = self.dap_server.receive_response(blocking_seq)
|
||||
blocking_resp = self.dap_server.recv_packet(filter_type=["response"])
|
||||
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.receive_response(cancel_seq)
|
||||
cancel_resp = self.dap_server.recv_packet(filter_type=["response"])
|
||||
self.assertEqual(cancel_resp["request_seq"], cancel_seq)
|
||||
self.assertEqual(cancel_resp["command"], "cancel")
|
||||
self.assertEqual(cancel_resp["success"], True)
|
||||
|
@ -1,8 +1,8 @@
|
||||
"""
|
||||
Test lldb-dap command hooks
|
||||
"""
|
||||
import os
|
||||
|
||||
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=1.0,
|
||||
timeout_secs=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=1.0,
|
||||
timeout_secs=1.0,
|
||||
pattern=command_abort_on_error,
|
||||
)
|
||||
self.assertNotIn(command_quiet, full_output)
|
||||
@ -81,6 +81,9 @@ class TestDAP_commands(lldbdap_testcase.DAPTestCaseBase):
|
||||
expectFailure=True,
|
||||
)
|
||||
self.assertFalse(resp["success"], "expected 'attach' failure")
|
||||
full_output = self.collect_console(pattern=command_abort_on_error)
|
||||
full_output = self.collect_console(
|
||||
timeout_secs=1.0,
|
||||
pattern=command_abort_on_error,
|
||||
)
|
||||
self.assertNotIn(command_quiet, full_output)
|
||||
self.assertIn(command_abort_on_error, full_output)
|
||||
|
@ -139,7 +139,9 @@ class TestDAP_console(lldbdap_testcase.DAPTestCaseBase):
|
||||
process.wait()
|
||||
|
||||
# Get the console output
|
||||
console_output = self.collect_console(pattern="exited with status")
|
||||
console_output = self.collect_console(
|
||||
timeout_secs=10.0, pattern="exited with status"
|
||||
)
|
||||
|
||||
# Verify the exit status message is printed.
|
||||
self.assertRegex(
|
||||
@ -154,7 +156,9 @@ class TestDAP_console(lldbdap_testcase.DAPTestCaseBase):
|
||||
self.continue_to_exit()
|
||||
|
||||
# Get the console output
|
||||
console_output = self.collect_console(pattern="exited with status")
|
||||
console_output = self.collect_console(
|
||||
timeout_secs=10.0, pattern="exited with status"
|
||||
)
|
||||
|
||||
# Verify the exit status message is printed.
|
||||
self.assertIn(
|
||||
@ -173,7 +177,9 @@ class TestDAP_console(lldbdap_testcase.DAPTestCaseBase):
|
||||
f"target create --core {core}", context="repl"
|
||||
)
|
||||
|
||||
diagnostics = self.collect_important(pattern="minidump file")
|
||||
diagnostics = self.collect_important(
|
||||
timeout_secs=self.DEFAULT_TIMEOUT, 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.build(path=self.main_path), [main_line]
|
||||
Source(self.main_path), [main_line]
|
||||
)
|
||||
breakpoints = response["body"]["breakpoints"]
|
||||
self.assertEqual(len(breakpoints), 1)
|
||||
|
@ -2,9 +2,12 @@
|
||||
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
|
||||
|
||||
@ -205,7 +208,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, "", "expect no program output")
|
||||
self.assertEqual(output, None, "expect no program output")
|
||||
|
||||
@skipIfWindows
|
||||
@skipIfLinux # shell argument expansion doesn't seem to work on Linux
|
||||
@ -406,14 +409,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()
|
||||
output = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
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()
|
||||
output = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
self.verify_commands("stopCommands", output, stopCommands)
|
||||
|
||||
# Continue until the program exits
|
||||
@ -421,7 +424,10 @@ 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(pattern=terminateCommands[0])
|
||||
output = self.collect_console(
|
||||
timeout_secs=1.0,
|
||||
pattern=terminateCommands[0],
|
||||
)
|
||||
self.verify_commands("exitCommands", output, exitCommands)
|
||||
self.verify_commands("terminateCommands", output, terminateCommands)
|
||||
|
||||
@ -474,21 +480,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()
|
||||
output = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
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()
|
||||
output = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
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()
|
||||
output = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
self.verify_commands("exitCommands", output, exitCommands)
|
||||
|
||||
def test_failing_launch_commands(self):
|
||||
@ -552,7 +558,10 @@ 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(pattern=terminateCommands[0])
|
||||
output = self.collect_console(
|
||||
timeout_secs=1.0,
|
||||
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,9 +1,11 @@
|
||||
"""
|
||||
Test lldb-dap module request
|
||||
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 re
|
||||
|
||||
@ -53,7 +55,7 @@ class TestDAP_module(lldbdap_testcase.DAPTestCaseBase):
|
||||
|
||||
if expect_debug_info_size:
|
||||
self.assertTrue(
|
||||
self.wait_until(check_symbols_loaded_with_size),
|
||||
self.waitUntil(check_symbols_loaded_with_size),
|
||||
"expect has debug info size",
|
||||
)
|
||||
|
||||
@ -66,7 +68,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":
|
||||
@ -74,7 +76,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=1.0, pattern="abcdef")
|
||||
output = self.collect_stdout(timeout_secs=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()
|
||||
output += self.get_stdout(timeout=self.DEFAULT_TIMEOUT)
|
||||
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()
|
||||
console = self.get_console(timeout=self.DEFAULT_TIMEOUT)
|
||||
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