Blame SOURCES/gdb-rhbz1971095-libthread_db-update-4of5.patch

405ea9
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
405ea9
From: Kevin Buettner <kevinb@redhat.com>
405ea9
Date: Wed, 9 Jun 2021 19:31:18 -0700
405ea9
Subject: gdb-rhbz1971095-libthread_db-update-4of5.patch
405ea9
405ea9
;; Backport "print-symbol-loading.exp: Allow libc symbols to be already loaded"
405ea9
;; (Kevin Buettner, RH BZ 1971095)
405ea9
405ea9
One consequence of changing libpthread_name_p() in solib.c to (also)
405ea9
match libc is that the symbols for libc will now be loaded by
405ea9
solib_add() in solib.c.  I think this is mostly harmless because
405ea9
we'll likely want these symbols to be loaded anyway, but it did cause
405ea9
two failures in gdb.base/print-symbol-loading.exp.
405ea9
405ea9
Specifically...
405ea9
405ea9
1)
405ea9
405ea9
sharedlibrary .*
405ea9
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib
405ea9
405ea9
now looks like this:
405ea9
405ea9
sharedlibrary .*
405ea9
Symbols already loaded for /lib64/libc.so.6
405ea9
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib
405ea9
405ea9
2)
405ea9
405ea9
sharedlibrary .*
405ea9
Loading symbols for shared libraries: .*
405ea9
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib
405ea9
405ea9
now looks like this:
405ea9
405ea9
sharedlibrary .*
405ea9
Loading symbols for shared libraries: .*
405ea9
Symbols already loaded for /lib64/libc.so.6
405ea9
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib
405ea9
405ea9
Fixing case #2 ended up being easier than #1.  #1 had been using
405ea9
gdb_test_no_output to correctly match this no-output case.  I
405ea9
ended up replacing it with gdb_test_multiple, matching the exact
405ea9
expected output for each of the two now acceptable cases.
405ea9
405ea9
For case #2, I simply added an optional non-capturing group
405ea9
for the potential new output.
405ea9
405ea9
gdb/testsuite/ChangeLog:
405ea9
405ea9
	* gdb.base/print-symbol-loading.exp (proc test_load_shlib):
405ea9
	Allow "Symbols already loaded for..." messages.
405ea9
405ea9
diff --git a/gdb/testsuite/gdb.base/print-symbol-loading.exp b/gdb/testsuite/gdb.base/print-symbol-loading.exp
405ea9
--- a/gdb/testsuite/gdb.base/print-symbol-loading.exp
405ea9
+++ b/gdb/testsuite/gdb.base/print-symbol-loading.exp
405ea9
@@ -96,6 +96,7 @@ test_load_core full
405ea9
 
405ea9
 proc test_load_shlib { print_symbol_loading } {
405ea9
     global binfile
405ea9
+    global gdb_prompt
405ea9
     with_test_prefix "shlib ${print_symbol_loading}" {
405ea9
 	clean_restart ${binfile}
405ea9
 	gdb_test_no_output "set auto-solib-add off"
405ea9
@@ -106,12 +107,20 @@ proc test_load_shlib { print_symbol_loading } {
405ea9
 	set test_name "load shared-lib"
405ea9
 	switch ${print_symbol_loading} {
405ea9
 	    "off" {
405ea9
-		gdb_test_no_output "sharedlibrary .*" \
405ea9
-		    ${test_name}
405ea9
+		set cmd "sharedlibrary .*"
405ea9
+		set cmd_regex [string_to_regexp $cmd]
405ea9
+		gdb_test_multiple $cmd $test_name {
405ea9
+		    -re "^$cmd_regex\r\n$gdb_prompt $" {
405ea9
+			pass $test_name
405ea9
+		    }
405ea9
+		    -re "^$cmd_regex\r\nSymbols already loaded for\[^\r\n\]*\\/libc\\.\[^\r\n\]*\r\n$gdb_prompt $" {
405ea9
+			pass $test_name
405ea9
+		    }
405ea9
+		}
405ea9
 	    }
405ea9
 	    "brief" {
405ea9
 		gdb_test "sharedlibrary .*" \
405ea9
-		    "Loading symbols for shared libraries: \\.\\*" \
405ea9
+		    "Loading symbols for shared libraries: \\.\\*.*?(?:Symbols already loaded for .*?libc)?" \
405ea9
 		    ${test_name}
405ea9
 	    }
405ea9
 	    "full" {