print-symbol-loading.exp: Allow libc symbols to be already loaded
authorKevin Buettner <kevinb@redhat.com>
Thu, 10 Jun 2021 02:31:18 +0000 (19:31 -0700)
committerKevin Buettner <kevinb@redhat.com>
Fri, 11 Jun 2021 21:56:20 +0000 (14:56 -0700)
One consequence of changing libpthread_name_p() in solib.c to (also)
match libc is that the symbols for libc will now be loaded by
solib_add() in solib.c.  I think this is mostly harmless because
we'll likely want these symbols to be loaded anyway, but it did cause
two failures in gdb.base/print-symbol-loading.exp.

Specifically...

1)

sharedlibrary .*
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib

now looks like this:

sharedlibrary .*
Symbols already loaded for /lib64/libc.so.6
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib

2)

sharedlibrary .*
Loading symbols for shared libraries: .*
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib

now looks like this:

sharedlibrary .*
Loading symbols for shared libraries: .*
Symbols already loaded for /lib64/libc.so.6
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib

Fixing case #2 ended up being easier than #1.  #1 had been using
gdb_test_no_output to correctly match this no-output case.  I
ended up replacing it with gdb_test_multiple, matching the exact
expected output for each of the two now acceptable cases.

For case #2, I simply added an optional non-capturing group
for the potential new output.

gdb/testsuite/ChangeLog:

* gdb.base/print-symbol-loading.exp (proc test_load_shlib):
Allow "Symbols already loaded for..." messages.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/print-symbol-loading.exp

index fa22fc3bae9b43716502c900d7f9700ea790f962..5f9db54ad02a6dba8a2764d20bd380ad3334eb09 100644 (file)
@@ -1,3 +1,8 @@
+2021-06-11  Kevin Buettner  <kevinb@redhat.com>
+
+       * gdb.base/print-symbol-loading.exp (proc test_load_shlib):
+       Allow "Symbols already loaded for..." messages.
+
 2021-06-11  Kevin Buettner  <kevinb@redhat.com>
 
        * gdb.base/execl-update-breakpoints.exp: Add regular
index b8eb1c844bdab4cd7f7145b70c941abf5ffad02f..93ec43a3855d048174a548c2632c0079f5c25cec 100644 (file)
@@ -96,6 +96,7 @@ test_load_core full
 
 proc test_load_shlib { print_symbol_loading } {
     global binfile
+    global gdb_prompt
     with_test_prefix "shlib ${print_symbol_loading}" {
        clean_restart ${binfile}
        gdb_test_no_output "set auto-solib-add off"
@@ -106,12 +107,20 @@ proc test_load_shlib { print_symbol_loading } {
        set test_name "load shared-lib"
        switch ${print_symbol_loading} {
            "off" {
-               gdb_test_no_output "sharedlibrary .*" \
-                   ${test_name}
+               set cmd "sharedlibrary .*"
+               set cmd_regex [string_to_regexp $cmd]
+               gdb_test_multiple $cmd $test_name {
+                   -re "^$cmd_regex\r\n$gdb_prompt $" {
+                       pass $test_name
+                   }
+                   -re "^$cmd_regex\r\nSymbols already loaded for\[^\r\n\]*\\/libc\\.\[^\r\n\]*\r\n$gdb_prompt $" {
+                       pass $test_name
+                   }
+               }
            }
            "brief" {
                gdb_test "sharedlibrary .*" \
-                   "Loading symbols for shared libraries: \\.\\*" \
+                   "Loading symbols for shared libraries: \\.\\*.*?(?:Symbols already loaded for .*?libc)?" \
                    ${test_name}
            }
            "full" {