This revision was automatically updated to reflect the committed changes.
Closed by commit rG165f45a87774: [lldb][lldb-vscode] Pretty print JSON to log
files (authored by DavidSpickett).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156979/new/
https://reviews.llvm.org/D156979
Files:
lldb/tools/lldb-vscode/VSCode.cpp
Index: lldb/tools/lldb-vscode/VSCode.cpp
===================================================================
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -89,12 +89,6 @@
output.write_full(llvm::utostr(json_str.size()));
output.write_full("\r\n\r\n");
output.write_full(json_str);
-
- if (log) {
- *log << "<-- " << std::endl
- << "Content-Length: " << json_str.size() << "\r\n\r\n"
- << json_str << std::endl;
- }
}
// Serialize the JSON value into a string and send the JSON packet to
@@ -105,7 +99,14 @@
strm << json;
static std::mutex mutex;
std::lock_guard<std::mutex> locker(mutex);
- SendJSON(strm.str());
+ std::string json_str = strm.str();
+ SendJSON(json_str);
+
+ if (log) {
+ *log << "<-- " << std::endl
+ << "Content-Length: " << json_str.size() << "\r\n\r\n"
+ << llvm::formatv("{0:2}", json).str() << std::endl;
+ }
}
// Read a JSON packet from the "in" stream.
@@ -129,11 +130,8 @@
if (!input.read_full(log.get(), length, json_str))
return json_str;
- if (log) {
- *log << "--> " << std::endl
- << "Content-Length: " << length << "\r\n\r\n"
- << json_str << std::endl;
- }
+ if (log)
+ *log << "--> " << std::endl << "Content-Length: " << length << "\r\n\r\n";
return json_str;
}
@@ -523,6 +521,11 @@
}
return PacketStatus::JSONMalformed;
}
+
+ if (log) {
+ *log << llvm::formatv("{0:2}", *json_value).str() << std::endl;
+ }
+
llvm::json::Object *object_ptr = json_value->getAsObject();
if (!object_ptr) {
if (log)
Index: lldb/tools/lldb-vscode/VSCode.cpp
===================================================================
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -89,12 +89,6 @@
output.write_full(llvm::utostr(json_str.size()));
output.write_full("\r\n\r\n");
output.write_full(json_str);
-
- if (log) {
- *log << "<-- " << std::endl
- << "Content-Length: " << json_str.size() << "\r\n\r\n"
- << json_str << std::endl;
- }
}
// Serialize the JSON value into a string and send the JSON packet to
@@ -105,7 +99,14 @@
strm << json;
static std::mutex mutex;
std::lock_guard<std::mutex> locker(mutex);
- SendJSON(strm.str());
+ std::string json_str = strm.str();
+ SendJSON(json_str);
+
+ if (log) {
+ *log << "<-- " << std::endl
+ << "Content-Length: " << json_str.size() << "\r\n\r\n"
+ << llvm::formatv("{0:2}", json).str() << std::endl;
+ }
}
// Read a JSON packet from the "in" stream.
@@ -129,11 +130,8 @@
if (!input.read_full(log.get(), length, json_str))
return json_str;
- if (log) {
- *log << "--> " << std::endl
- << "Content-Length: " << length << "\r\n\r\n"
- << json_str << std::endl;
- }
+ if (log)
+ *log << "--> " << std::endl << "Content-Length: " << length << "\r\n\r\n";
return json_str;
}
@@ -523,6 +521,11 @@
}
return PacketStatus::JSONMalformed;
}
+
+ if (log) {
+ *log << llvm::formatv("{0:2}", *json_value).str() << std::endl;
+ }
+
llvm::json::Object *object_ptr = json_value->getAsObject();
if (!object_ptr) {
if (log)
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits