Skip to content

[lldb-dap] Add timestamps to protocol logs #93540

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 1 commit into from
May 29, 2024
Merged
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
13 changes: 9 additions & 4 deletions lldb/tools/lldb-dap/DAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be better to use steady_clock? that's more stable for benchmarking

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for a benchmark yes, but this is only a "benchmark" (with very large quotes). Like, I won't be using this during daylight savings switchover, and I don't think it's suitable for anything automated. And it's kinda nice it matches the time stamps for regular lldb logs (I literally copied this code from there).

*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;
}
Expand All @@ -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;
}

Expand Down
Loading