[binutils-gdb] [gdb/testsuite] Handle debuginfod output in gdb.debuginfod/solib-with-dwz.exp

Tom de Vries via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7e85a00d62afabe7fc29580527d799334fa45643

commit 7e85a00d62afabe7fc29580527d799334fa45643
Author: Tom de Vries <[email protected]>
Date:   Thu Mar 12 21:16:59 2026 +0100

    [gdb/testsuite] Handle debuginfod output in gdb.debuginfod/solib-with-dwz.exp
    
    I ran into a timeout in test-case gdb.debuginfod/solib-with-dwz.exp.
    
    GDB times out like this:
    ...
    Download failed: Timer expired. \
      Continuing without source file solib-with-dwz-bar.c.
    ...
    
    My theory is that the download fails because debuginfod becomes unresponsive,
    because it's stuck trying to write output into some buffer that is already
    full.
    
    Fix this by regularly draining debuginfod output in the test-case, using a new
    proc drain_debuginfod.
    
    Debuginfod is run with "-vvvv", which makes it rather verbose, and dropping
    that also fixes the timeouts, but it might be useful for debugging, so I went
    with the output draining method, and left the "-vvvv" as is.
    
    Reviewed-By: Keith Seitz <[email protected]>
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33901

Diff:
---
 gdb/testsuite/gdb.debuginfod/solib-with-dwz.exp |  6 ++++++
 gdb/testsuite/lib/debuginfod-support.exp        | 11 +++++++++++
 2 files changed, 17 insertions(+)

diff --git a/gdb/testsuite/gdb.debuginfod/solib-with-dwz.exp b/gdb/testsuite/gdb.debuginfod/solib-with-dwz.exp
index 15ad13a68ad..9808f6c3e87 100644
--- a/gdb/testsuite/gdb.debuginfod/solib-with-dwz.exp
+++ b/gdb/testsuite/gdb.debuginfod/solib-with-dwz.exp
@@ -201,6 +201,7 @@ proc run_test { cache db debug_dir use_filename } {
 	unresolved "start debuginfod server"
 	return
     }
+    drain_debuginfod
 
     # Point the client to the server.
     setenv DEBUGINFOD_URLS $url
@@ -225,10 +226,12 @@ proc run_test { cache db debug_dir use_filename } {
 
     # Now GDB is configured, load the executable.
     gdb_load $::binfile
+    drain_debuginfod
 
     if { ![runto_main] } {
 	return
     }
+    drain_debuginfod
 
     # This test relies on reading address zero triggering a SIGSEGV.
     # If address zero is readable then give up now.
@@ -241,6 +244,7 @@ proc run_test { cache db debug_dir use_filename } {
 
     gdb_test "continue" \
 	"\r\n$crash_line_num\\s+[string_to_regexp {*ptr = 0;	/* Crash here.  */}]"
+    drain_debuginfod
 
     set call_line_num [gdb_get_line_number "Call line" $::srcfile3]
 
@@ -250,6 +254,7 @@ proc run_test { cache db debug_dir use_filename } {
     gdb_test "list" \
 	"\r\n$call_line_num\\s+[string_to_regexp {cb ();	/* Call line.  */}]\r\n.*" \
 	"list default location in $::srcfile3"
+    drain_debuginfod
 
     set list_line_num [gdb_get_line_number "Second line to list" $::srcfile3]
 
@@ -304,6 +309,7 @@ proc run_test { cache db debug_dir use_filename } {
 	    exp_continue
 	}
     }
+    drain_debuginfod
 
     # Use 'maint info symtabs' to list all symtabs and find the
     # symtabs that are associated with libbar.so (actually with the
diff --git a/gdb/testsuite/lib/debuginfod-support.exp b/gdb/testsuite/lib/debuginfod-support.exp
index 57a880ff177..66b4098d4f9 100644
--- a/gdb/testsuite/lib/debuginfod-support.exp
+++ b/gdb/testsuite/lib/debuginfod-support.exp
@@ -185,6 +185,17 @@ proc start_debuginfod { db debugdir } {
     return $url
 }
 
+# Drain output from debuginfod.
+
+proc drain_debuginfod {} {
+    verbose -log "drain debuginfod output --- start"
+    expect {
+	-i $::debuginfod_spawn_id ".*" {
+	}
+    }
+    verbose -log "drain debuginfod output --- end"
+}
+
 # If the global debuginfod_spawn_id exists, then kill that process and unset
 # the debuginfod_spawn_id global.  This can be used to shutdown the
 # debuginfod server.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.