Revert "[lldb-dap] Test Gardening, improving DebugCommunication. (#141689)"

This reverts commit 8a49db35f4.

Due to failures on Arm and AArch64 Linux:
https://lab.llvm.org/buildbot/#/builders/59/builds/18540
https://lab.llvm.org/buildbot/#/builders/18/builds/16759

  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py", line 22, in assertEvaluateFailure
    self.assertNotIn(
AssertionError: 'result' unexpectedly found in {'memoryReference': '0xFFFFF7CB3060', 'result': '0x0000000000000000', 'type': 'int *', 'variablesReference': 7}

FAIL: test_generic_evaluate_expressions (TestDAP_evaluate.TestDAP_evaluate)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py", line 228, in test_generic_evaluate_expressions
    self.run_test_evaluate_expressions(enableAutoVariableSummaries=False)
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py", line 117, in run_test_evaluate_expressions
    self.assertEvaluateFailure("list")  # local variable of a_function
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py", line 22, in assertEvaluateFailure
    self.assertNotIn(
AssertionError: 'result' unexpectedly found in {'memoryReference': '0xFFFFF7CB3060', 'result': '0x0000000000000000', 'type': 'int *', 'variablesReference': 7}
Config=aarch64-/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang

The second one is because our bots have the libc debug info package installed,
the first, no idea.
This commit is contained in:
David Spickett
2025-05-30 08:32:09 +00:00
parent 85f791d9cd
commit 114192f586
6 changed files with 422 additions and 469 deletions

View File

@@ -1,20 +1,10 @@
import os
import time
from typing import Dict, Optional, TYPE_CHECKING
from typing import Optional
import uuid
if TYPE_CHECKING:
# FIXME: Add mypy and typing_extensions to the requirements.txt once all
# build bots support the library.
from typing_extensions import Unpack
from dap_server import (
DebugAdapterServer,
Source,
Response,
AttachArguments,
LaunchArguments,
)
import dap_server
from dap_server import Source
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbplatformutil
import lldbgdbserverutils
@@ -28,7 +18,7 @@ class DAPTestCaseBase(TestBase):
def create_debug_adapter(
self,
env: Optional[Dict[str, str]] = None,
lldbDAPEnv: Optional[dict[str, str]] = None,
connection: Optional[str] = None,
):
"""Create the Visual Studio Code debug adapter"""
@@ -36,21 +26,21 @@ class DAPTestCaseBase(TestBase):
is_exe(self.lldbDAPExec), "lldb-dap must exist and be executable"
)
log_file_path = self.getBuildArtifact("dap.txt")
self.dap_server = DebugAdapterServer(
self.dap_server = dap_server.DebugAdapterServer(
executable=self.lldbDAPExec,
connection=connection,
init_commands=self.setUpCommands(),
log_file=log_file_path,
env=env,
env=lldbDAPEnv,
)
def build_and_create_debug_adapter(
self,
adapter_env: Optional[Dict[str, str]] = None,
dictionary: Optional[Dict] = None,
lldbDAPEnv: Optional[dict[str, str]] = None,
dictionary: Optional[dict] = None,
):
self.build(dictionary=dictionary)
self.create_debug_adapter(adapter_env)
self.create_debug_adapter(lldbDAPEnv)
def build_and_create_debug_adapter_for_attach(self):
"""Variant of build_and_create_debug_adapter that builds a uniquely
@@ -114,18 +104,6 @@ class DAPTestCaseBase(TestBase):
time.sleep(0.5)
return False
def assertResponseSuccess(self, response: Response):
self.assertIsNotNone(response)
self.assertIn("success", response)
if not response.get("success", False):
cmd = response.get("command", "<not set>")
msg = f"command ({cmd}) failed"
if "message" in response:
msg += " " + str(response["message"])
if "body" in response and response["body"] and "error" in response["body"]:
msg += " " + str(response["body"]["error"]["format"])
self.fail(msg)
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.
@@ -403,7 +381,7 @@ class DAPTestCaseBase(TestBase):
disconnectAutomatically=True,
sourceInitFile=False,
expectFailure=False,
**kwargs: "Unpack[AttachArguments]",
**kwargs,
):
"""Build the default Makefile target, create the DAP debug adapter,
and attach to the process.
@@ -430,13 +408,12 @@ class DAPTestCaseBase(TestBase):
def launch(
self,
program: str,
/,
program=None,
*,
sourceInitFile=False,
disconnectAutomatically=True,
expectFailure=False,
**kwargs: "Unpack[LaunchArguments]",
**kwargs,
):
"""Sending launch request to dap"""
@@ -452,8 +429,7 @@ class DAPTestCaseBase(TestBase):
# Initialize and launch the program
self.dap_server.request_initialize(sourceInitFile)
kwargs["program"] = program
response = self.dap_server.request_launch(**kwargs)
response = self.dap_server.request_launch(program, **kwargs)
if expectFailure:
return response
if not (response and response["success"]):
@@ -464,17 +440,17 @@ class DAPTestCaseBase(TestBase):
def build_and_launch(
self,
program: str,
/,
program,
*,
adapter_env: Optional[Dict[str, str]] = None,
**kwargs: "Unpack[LaunchArguments]",
lldbDAPEnv: Optional[dict[str, str]] = None,
**kwargs,
):
"""Build the default Makefile target, create the DAP debug adapter,
and launch the process.
"""
self.build_and_create_debug_adapter(adapter_env)
self.build_and_create_debug_adapter(lldbDAPEnv)
self.assertTrue(os.path.exists(program), "executable must exist")
return self.launch(program, **kwargs)
def getBuiltinDebugServerTool(self):

View File

@@ -11,14 +11,15 @@ import lldbdap_testcase
class TestDAP_cancel(lldbdap_testcase.DAPTestCaseBase):
def send_async_req(self, command: str, arguments={}) -> int:
return self.dap_server.send_packet(
seq = self.dap_server.sequence
self.dap_server.send_packet(
{
"type": "request",
"seq": 0,
"command": command,
"arguments": arguments,
}
)
return seq
def async_blocking_request(self, duration: float) -> int:
"""
@@ -53,17 +54,21 @@ 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)
self.assertResponseSuccess(blocking_resp)
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)
self.assertResponseSuccess(cancel_resp)
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)
self.continue_to_exit()
def test_inflight_request(self):
@@ -81,12 +86,14 @@ class TestDAP_cancel(lldbdap_testcase.DAPTestCaseBase):
)
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)
self.assertResponseSuccess(cancel_resp)
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)
self.continue_to_exit()

View File

@@ -44,10 +44,10 @@ class TestDAP_commands(lldbdap_testcase.DAPTestCaseBase):
commands = ["?!" + command_quiet, "!" + command_abort_on_error]
self.build_and_launch(
program,
initCommands=commands if use_init_commands else [],
launchCommands=commands if use_launch_commands else [],
preRunCommands=commands if use_pre_run_commands else [],
postRunCommands=commands if use_post_run_commands else [],
initCommands=commands if use_init_commands else None,
launchCommands=commands if use_launch_commands else None,
preRunCommands=commands if use_pre_run_commands else None,
postRunCommands=commands if use_post_run_commands else None,
expectFailure=True,
)
full_output = self.collect_console(

View File

@@ -16,7 +16,7 @@ class TestDAP_redirection_to_console(lldbdap_testcase.DAPTestCaseBase):
"""
program = self.getBuildArtifact("a.out")
self.build_and_launch(
program, adapter_env={"LLDB_DAP_TEST_STDOUT_STDERR_REDIRECTION": "1"}
program, lldbDAPEnv={"LLDB_DAP_TEST_STDOUT_STDERR_REDIRECTION": ""}
)
source = "main.cpp"

View File

@@ -104,7 +104,7 @@ class TestDAP_variables(lldbdap_testcase.DAPTestCaseBase):
)
self.verify_values(verify_dict[name], variable, varref_dict)
def darwin_dwarf_missing_obj(self, initCommands=[]):
def darwin_dwarf_missing_obj(self, initCommands):
self.build(debug_info="dwarf")
program = self.getBuildArtifact("a.out")
main_obj = self.getBuildArtifact("main.o")
@@ -791,13 +791,13 @@ class TestDAP_variables(lldbdap_testcase.DAPTestCaseBase):
"""
Test that if we build a binary with DWARF in .o files and we remove
the .o file for main.cpp, that we get a variable named "<error>"
whose value matches the appropriate error. Errors when getting
whose value matches the appriopriate error. Errors when getting
variables are returned in the LLDB API when the user should be
notified of issues that can easily be solved by rebuilding or
changing compiler options and are designed to give better feedback
to the user.
"""
self.darwin_dwarf_missing_obj([])
self.darwin_dwarf_missing_obj(None)
@no_debug_info_test
@skipUnlessDarwin