[llvm] [Dexter] Add timestamps to DAP logging (PR #193705)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 02:58:52 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: Stephen Tozer (SLTozer)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/193705.diff


1 Files Affected:

- (modified) cross-project-tests/debuginfo-tests/dexter/dex/debugger/DAP.py (+9) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/193705


More information about the llvm-commits mailing list