[binutils-gdb] [gdb/testsuite] Fix gdb.gdb/python-helper.exp with gdb built with -flto

Tom de Vries vries@sourceware.org
Thu Jul 31 07:58:49 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c7c272f06d2d456d1d99762325fd0dd7db31d540

commit c7c272f06d2d456d1d99762325fd0dd7db31d540
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Jul 31 09:58:47 2025 +0200

    [gdb/testsuite] Fix gdb.gdb/python-helper.exp with gdb built with -flto
    
    With a gdb build with gcc 7.5.0 and "-O2 -flto=auto -g", I run into:
    ...
    (outer-gdb) PASS: gdb.gdb/python-helper.exp: print varobj_table
    print inferior_list
    $5 = {m_front = 0x212e830, m_back = 0x2e39aa0}
    (outer-gdb) FAIL: gdb.gdb/python-helper.exp: print inferior_list
    ...
    
    The problem is that the type of inferior_list:
    ...
    (outer-gdb) what inferior_list^M
    type = intrusive_list^M
    (outer-gdb)
    ...
    is not descriptive enough to trigger the pretty pretter.
    
    Note that with a gdb build with -O0, we'd get instead:
    ...
    (outer-gdb) what inferior_list^M
    type = intrusive_list<inferior, intrusive_base_node<inferior> >
    (outer-gdb)
    ...
    
    Fix this by detecting this situation, and declaring the test unsupported.
    
    Tested on x86_64-linux.

Diff:
---
 gdb/testsuite/gdb.gdb/python-helper.exp | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp
index 4b9adb044e1..8126740c301 100644
--- a/gdb/testsuite/gdb.gdb/python-helper.exp
+++ b/gdb/testsuite/gdb.gdb/python-helper.exp
@@ -264,10 +264,28 @@ proc test_python_helper {} {
     gdb_test -prompt $outer_prompt_re "print varobj_table" \
 	"htab_t with ${::decimal} elements"
 
+    set inferior_list_supported 1
+    set inferior_list_unsupported_re "type = intrusive_list"
+    gdb_test_multiple "what inferior_list" "" -prompt $outer_prompt_re {
+	-re -wrap $inferior_list_unsupported_re {
+	    set inferior_list_supported 0
+	    pass $gdb_test_name
+	}
+	-re -wrap "" {
+	    pass $gdb_test_name
+	}
+    }
+
     # Test the intrusive_list pretty-printer.  A bug occurred in the
     # pretty-printer for lists with more than one element.  Verify that
     # we see both elements of the inferior_list list being printed.
-    gdb_test -prompt $outer_prompt_re "print inferior_list" "intrusive list of inferior = {.*, num = 1,.*, num = 2,.*}"
+    set test "print inferior_list"
+    if { $inferior_list_supported } {
+	gdb_test -prompt $outer_prompt_re $test \
+	    "intrusive list of inferior = {.*, num = 1,.*, num = 2,.*}"
+    } else {
+	unsupported $test
+    }
 
     return 0
 }


More information about the Gdb-cvs mailing list