[Lldb-commits] [lldb] 2cfea14 - [lldb-dap] Add timestamps to protocol logs (#93540)
via lldb-commits
lldb-commits at lists.llvm.org
Wed May 29 00:27:36 PDT 2024
Author: Pavel Labath
Date: 2024-05-29T09:27:32+02:00
New Revision: 2cfea14a57ad8443c6898d2310abb4346dc92ad2
URL: https://github.com/llvm/llvm-project/commit/2cfea14a57ad8443c6898d2310abb4346dc92ad2
DIFF: https://github.com/llvm/llvm-project/commit/2cfea14a57ad8443c6898d2310abb4346dc92ad2.diff
LOG: [lldb-dap] Add timestamps to protocol logs (#93540)
I've found them very useful as a rudimentary form of benchmark.
Added:
Modified:
lldb/tools/lldb-dap/DAP.cpp
Removed:
################################################################################
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