public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/8] [gdb/testsuite] Set up dap log file in gdb.dap/type_checker.exp
@ 2024-02-19  8:23 Tom de Vries
  2024-02-19  8:23 ` [PATCH 2/8] [gdb/dap] Factor out thread_log Tom de Vries
                   ` (7 more replies)
  0 siblings, 8 replies; 22+ messages in thread
From: Tom de Vries @ 2024-02-19  8:23 UTC (permalink / raw)
  To: gdb-patches

While debugging a slow-down in test-case gdb.dap/type_checker.exp due to a WIP
patch, I noticed that test-case gdb.dap/type_checker.exp doesn't have a dap
log file.

This is normally set up by dap_gdb_start, but the test-case doesn't use it.

Fix this by doing "set debug dap-log-file $logfile" in the test-case.

To make it easy to do so, I've factored out a new proc new_dap_log_file, and
while at likewise a new proc current_dap_log_file.

Note that the log file is currently empty.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.dap/type_check.exp |  3 +++
 gdb/testsuite/lib/dap-support.exp    | 22 +++++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/gdb.dap/type_check.exp b/gdb/testsuite/gdb.dap/type_check.exp
index cda01299925..e6c9d73d871 100644
--- a/gdb/testsuite/gdb.dap/type_check.exp
+++ b/gdb/testsuite/gdb.dap/type_check.exp
@@ -26,6 +26,9 @@ set remote_python_file \
     [gdb_remote_download host ${srcdir}/${subdir}/${gdb_test_file_name}.py]
 gdb_test_no_output "source ${remote_python_file}" "load python file"
 
+set logfile [new_dap_log_file]
+gdb_test_no_output "set debug dap-log-file $logfile" "set dap log file"
+
 gdb_test_multiple "python check_everything()" "type checker" {
     -re -wrap "OK" {
 	pass $gdb_test_name
diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp
index 979dfa2cd73..31f036eddf2 100644
--- a/gdb/testsuite/lib/dap-support.exp
+++ b/gdb/testsuite/lib/dap-support.exp
@@ -26,6 +26,19 @@ set dap_gdb_instance 0
 # is restarted.
 set dap_seq 1
 
+# Return the current DAP log file.
+proc current_dap_log_file {} {
+    global dap_gdb_instance
+    return [standard_output_file "dap.log.$dap_gdb_instance"]
+}
+
+# Return a new DAP log file.
+proc new_dap_log_file {} {
+    global dap_gdb_instance
+    incr dap_gdb_instance
+    return [current_dap_log_file]
+}
+
 # Start gdb using the DAP interpreter.
 proc dap_gdb_start {} {
     # Keep track of the number of times GDB has been launched.
@@ -34,13 +47,10 @@ proc dap_gdb_start {} {
 
     gdb_stdin_log_init
 
-    global dap_gdb_instance
-    incr dap_gdb_instance
-
     global GDBFLAGS stty_init
     save_vars { GDBFLAGS stty_init } {
 	set stty_init "-echo raw"
-	set logfile [standard_output_file "dap.log.$dap_gdb_instance"]
+	set logfile [new_dap_log_file]
 	append GDBFLAGS " -iex \"set debug dap-log-file $logfile\" -q -i=dap"
 	set res [gdb_spawn]
 	if {$res != 0} {
@@ -337,9 +347,7 @@ proc dap_target_remote {target} {
 
 # Read the most recent DAP log file and check it for exceptions.
 proc dap_check_log_file {} {
-    global dap_gdb_instance
-
-    set fd [open [standard_output_file "dap.log.$dap_gdb_instance"]]
+    set fd [open [current_dap_log_file]]
     set contents [read $fd]
     close $fd
 

base-commit: d1648ffe809ad288d989cd4f6794c01f524471f2
-- 
2.35.3


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-02-21 13:39 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19  8:23 [PATCH 1/8] [gdb/testsuite] Set up dap log file in gdb.dap/type_checker.exp Tom de Vries
2024-02-19  8:23 ` [PATCH 2/8] [gdb/dap] Factor out thread_log Tom de Vries
2024-02-20 15:30   ` Tom Tromey
2024-02-21 13:30     ` Tom de Vries
2024-02-19  8:23 ` [PATCH 3/8] [gdb/dap] Flush after printing in log_stack Tom de Vries
2024-02-20 15:30   ` Tom Tromey
2024-02-19  8:23 ` [PATCH 4/8] [gdb/dap] Make dap log printing thread-safe Tom de Vries
2024-02-20 15:32   ` Tom Tromey
2024-02-21 13:31     ` Tom de Vries
2024-02-19  8:23 ` [PATCH 5/8] [gdb/dap] Fix race between dap startup and dap log file Tom de Vries
2024-02-20 15:38   ` Tom Tromey
2024-02-19  8:23 ` [PATCH 6/8] [gdb/dap] Don't let dap log string grow indefinitely Tom de Vries
2024-02-20 15:41   ` Tom Tromey
2024-02-21 13:34     ` Tom de Vries
2024-02-19  8:23 ` [PATCH 7/8] [gdb/dap] Join JSON reader and writer threads with DAP thread Tom de Vries
2024-02-20 15:47   ` Tom Tromey
2024-02-20 20:01   ` Tom Tromey
2024-02-21 13:35     ` Tom de Vries
2024-02-19  8:23 ` [PATCH 8/8] [gdb/dap] Fix race between dap exit and gdb exit Tom de Vries
2024-02-20 15:51   ` Tom Tromey
2024-02-21 13:39     ` Tom de Vries
2024-02-20 15:29 ` [PATCH 1/8] [gdb/testsuite] Set up dap log file in gdb.dap/type_checker.exp Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).