[Lldb-commits] [lldb] [lldb-dap] Add timestamps to protocol logs (PR #93540)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue May 28 05:18:54 PDT 2024
https://github.com/labath created https://github.com/llvm/llvm-project/pull/93540
I've found them very useful as a rudimentary form of benchmark.
>From 2f3cb04a141d39c184afcb0d59acb7ea6cbb16d9 Mon Sep 17 00:00:00 2001
From: Pavel Labath <pavel at labath.sk>
Date: Tue, 28 May 2024 12:16:49 +0000
Subject: [PATCH] [lldb-dap] Add timestamps to protocol logs
I've found them very useful as a rudimentary form of benchmark.
---
lldb/tools/lldb-dap/DAP.cpp | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index c7eb3db4304a9..d419f821999e6 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -103,7 +103,9 @@ void DAP::SendJSON(const llvm::json::Value &json) {
SendJSON(json_str);
if (log) {
- *log << "<-- " << std::endl
+ auto now = std::chrono::duration<double>(
+ std::chrono::system_clock::now().time_since_epoch());
+ *log << llvm::formatv("{0:f9} <-- ", now.count()).str() << std::endl
<< "Content-Length: " << json_str.size() << "\r\n\r\n"
<< llvm::formatv("{0:2}", json).str() << std::endl;
}
@@ -130,9 +132,12 @@ std::string DAP::ReadJSON() {
if (!input.read_full(log.get(), length, json_str))
return json_str;
- if (log)
- *log << "--> " << std::endl << "Content-Length: " << length << "\r\n\r\n";
-
+ if (log) {
+ auto now = std::chrono::duration<double>(
+ std::chrono::system_clock::now().time_since_epoch());
+ *log << llvm::formatv("{0:f9} --> ", now.count()).str() << std::endl
+ << "Content-Length: " << length << "\r\n\r\n";
+ }
return json_str;
}
More information about the lldb-commits
mailing list