Skip to content

[lldb-dap] Improving tests logging to understand CI failures. #139311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import socket
import string
import subprocess
import signal
import sys
import threading
import time
Expand Down Expand Up @@ -1263,7 +1264,7 @@ def launch(cls, /, executable, env=None, log_file=None, connection=None):
args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stderr=sys.stderr,
env=adapter_env,
)

Expand Down Expand Up @@ -1296,13 +1297,38 @@ def get_pid(self):
def terminate(self):
super(DebugAdapterServer, self).terminate()
if self.process is not None:
self.process.terminate()
process = self.process
self.process = None
try:
self.process.wait(timeout=20)
# When we close stdin it should signal the lldb-dap that no
# new messages will arrive and it should shutdown on its own.
process.stdin.close()
process.wait(timeout=20)
except subprocess.TimeoutExpired:
self.process.kill()
self.process.wait()
self.process = None
process.kill()
process.wait()
if process.returncode != 0:
raise DebugAdapterProcessError(process.returncode)


class DebugAdapterError(Exception):
pass


class DebugAdapterProcessError(DebugAdapterError):
"""Raised when the lldb-dap process exits with a non-zero exit status."""

def __init__(self, returncode):
self.returncode = returncode

def __str__(self):
if self.returncode and self.returncode < 0:
try:
return f"lldb-dap died with {signal.Signals(-self.returncode).name}."
except ValueError:
return f"lldb-dap died with unknown signal {-self.returncode}."
else:
return f"lldb-dap returned non-zero exit status {self.returncode}."


def attach_options_specified(options):
Expand Down
7 changes: 5 additions & 2 deletions lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ def test_diagnositcs(self):
f"target create --core {core}", context="repl"
)

output = self.get_important(timeout=2.0)
diagnostics = self.collect_important(
timeout_secs=self.timeoutval, pattern="minidump file"
)

self.assertIn(
"warning: unable to retrieve process ID from minidump file",
output,
diagnostics,
"diagnostic found in important output",
)
4 changes: 0 additions & 4 deletions lldb/test/API/tools/lldb-dap/io/TestDAP_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ def cleanup():
process.terminate()
process.wait()
stdout_data = process.stdout.read().decode()
stderr_data = process.stderr.read().decode()
print("========= STDOUT =========", file=sys.stderr)
print(stdout_data, file=sys.stderr)
print("========= END =========", file=sys.stderr)
print("========= STDERR =========", file=sys.stderr)
print(stderr_data, file=sys.stderr)
print("========= END =========", file=sys.stderr)
print("========= DEBUG ADAPTER PROTOCOL LOGS =========", file=sys.stderr)
with open(log_file_path, "r") as file:
print(file.read(), file=sys.stderr)
Expand Down
Loading