[llvm] [Dexter] Add timestamps to DAP logging (PR #193705)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 23 02:58:25 PDT 2026
https://github.com/SLTozer created https://github.com/llvm/llvm-project/pull/193705
DAP logs are currently optionally output by Dexter to assist in debugging or analyzing Dexter sessions. The output currently includes the contents of every DAP message sent to/from the debug adapter, but for some long-running programs it can also be useful to know when messages have been sent and received; to assist, this patch adds timestamps to DAP messages in the log.
>From 63fa329609a94a380b9839dc614a27188f364c22 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <stephen.tozer at sony.com>
Date: Wed, 22 Apr 2026 13:27:26 +0100
Subject: [PATCH] [Dexter] Add timestamps to DAP logging
DAP logs are currently optionally output by Dexter to assist in debugging
or analyzing Dexter sessions. The output currently includes the contents of
every DAP message sent to/from the debug adapter, but for some long-running
programs it can also be useful to know when messages have been sent and
received; to assist, this patch adds timestamps to DAP messages in the log.
---
.../debuginfo-tests/dexter/dex/debugger/DAP.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DAP.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DAP.py
index c09950b91b273..b3d0bfeb47db8 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DAP.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DAP.py
@@ -51,6 +51,7 @@ def __init__(self, context):
self.out_handle = None
self.open = False
self.lock = threading.Lock()
+ self.start_time: None | float = None
def _custom_enter(self):
self.open = True
@@ -63,6 +64,7 @@ def _custom_enter(self):
self.out_handle = sys.stderr
return
self.out_handle = open(self.log_file, "w+", encoding="utf-8")
+ self.start_time = time.time()
def _custom_exit(self):
if (
@@ -94,6 +96,13 @@ def _colorize_dap_message(self, message: dict) -> dict:
def write_message(self, message: dict, incoming: bool):
prefix = self.prefix_recv if incoming else self.prefix_send
+ if self.start_time is not None:
+ message_time = time.time() - self.start_time
+ minutes = int(message_time / 60)
+ seconds = int(message_time % 60)
+ milliseconds = int((message_time % 1) * 1000)
+ prefix += f" {minutes}:{seconds:02d}:{milliseconds:03d}"
+
# ANSI escape codes get butchered by json.dumps(), so we fix them up here.
message_str = json.dumps(
self._colorize_dap_message(message), indent=self.indent
More information about the llvm-commits
mailing list