https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/131917

This should ensure we have the full logs prior to dumping the logs. 
Additionally, printing log dumps to stderr so they are adjacent to assertion 
failures.



>From ca59812b9b23c96354982b6c696fb2b129bf117d Mon Sep 17 00:00:00 2001
From: John Harrison <harj...@google.com>
Date: Tue, 18 Mar 2025 14:01:44 -0700
Subject: [PATCH] [lldb-dap] Waiting for the test binary to exit prior to
 dumping logs.

This should ensure we have the full logs prior to dumping the logs. 
Additionally, printing log dumps to stderr so they are interspersed with 
assertion failures.
---
 .../lldbsuite/test/tools/lldb-dap/dap_server.py      | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 0fea3419d9725..a9a47e281e829 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -88,13 +88,13 @@ def packet_type_is(packet, packet_type):
 
 
 def dump_dap_log(log_file):
-    print("========= DEBUG ADAPTER PROTOCOL LOGS =========")
+    print("========= DEBUG ADAPTER PROTOCOL LOGS =========", file=sys.stderr)
     if log_file is None:
-        print("no log file available")
+        print("no log file available", file=sys.stderr)
     else:
         with open(log_file, "r") as file:
-            print(file.read())
-    print("========= END =========")
+            print(file.read(), file=sys.stderr)
+    print("========= END =========", file=sys.stderr)
 
 
 def read_packet_thread(vs_comm, log_file):
@@ -107,6 +107,10 @@ def read_packet_thread(vs_comm, log_file):
             # termination of lldb-dap and stop waiting for new packets.
             done = not vs_comm.handle_recv_packet(packet)
     finally:
+        # Wait for the process to fully exit before dumping the log file to
+        # ensure we have the entire log contents.
+        if vs_comm.process is not None:
+            vs_comm.process.wait()
         dump_dap_log(log_file)
 
 

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to