[gdb/testsuite] Fix gdb.fortran/call-no-debug.exp symbol search
authorTom de Vries <tdevries@suse.de>
Wed, 1 Sep 2021 09:38:02 +0000 (11:38 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 1 Sep 2021 09:38:02 +0000 (11:38 +0200)
On openSUSE Tumbleweed I ran into:
...
(gdb) ptype outstring_func.part^M
No symbol "outstring_func" in current context.^M
(gdb) FAIL: gdb.fortran/call-no-debug.exp: ptype outstring_func.part
...
while on openSUSE Leap 15.2 I have instead:
...
(gdb) ptype string_func_^M
type = <unknown return type> ()^M
(gdb) PASS: gdb.fortran/call-no-debug.exp: ptype string_func_
...

The difference is caused by the result for "info function string_func", which
is this for the latter:
...
(gdb) info function string_func^M
All functions matching regular expression "string_func":^M
^M
Non-debugging symbols:^M
0x000000000040089c  string_func_^M
...
but this for the former:
...
(gdb) info function string_func^M
All functions matching regular expression "string_func":^M
^M
Non-debugging symbols:^M
0x00000000004012bb  string_func_^M
0x00007ffff7bac5b0  outstring_func.part^M
0x00007ffff7bb1a00  outstring_func.part^M
...

The extra symbols are part of glibc:
...
$ nm /lib64/libc.so.6 | grep string_func
00000000000695b0 t outstring_func.part.0
000000000006ea00 t outstring_func.part.0
...

If glibc debug info is installed, we get instead:
...
(gdb) info function string_func^M
All functions matching regular expression "string_func":^M
^M
File /usr/src/debug/glibc-2.33-9.1.x86_64/stdio-common/vfprintf-internal.c:^M
236:    static int outstring_func(int, size_t, const unsigned int *, FILE *);^M
^M
File vfprintf-internal.c:^M
236:    static int outstring_func(int, size_t, const unsigned char *, FILE *);^M
^M
Non-debugging symbols:^M
0x00000000004012bb  string_func_^M
...
and the FAIL doesn't trigger.

Fix this by calling "info function string_func" before starting the exec, such
that only symbols of the exec are taken into account.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-09-01  Tom de Vries  <tdevries@suse.de>

* gdb.fortran/call-no-debug.exp: Avoid shared lib symbols for
find_mangled_name calls.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.fortran/call-no-debug.exp

index 436bcb4080b613a00f9a499ee60e2c02de9fe278..96a195ec4117196288fa804011538b62b428da83 100644 (file)
@@ -1,3 +1,8 @@
+2021-09-01  Tom de Vries  <tdevries@suse.de>
+
+       * gdb.fortran/call-no-debug.exp: Avoid shared lib symbols for
+       find_mangled_name calls.
+
 2021-08-30  Tom de Vries  <tdevries@suse.de>
 
        PR cli/28290
index 82bf32c82c701213218cbf4efd23f00a673da657..a5e982533fde12933e25489d5cae0e37cf4f70ca 100644 (file)
@@ -28,11 +28,6 @@ if {[prepare_for_testing_full "failed to prepare" \
     return -1
 }
 
-if ![fortran_runto_main] {
-    untested "could not run to main"
-    return -1
-}
-
 # Find a possibly mangled version of NAME, a function we want to call
 # that has no debug information available.  We hope that the mangled
 # version of NAME contains the pattern NAME, and so we use 'info
@@ -67,12 +62,22 @@ proc find_mangled_name { name } {
     return $symbol_name
 }
 
+# Sample before before starting the exec, in order to avoid picking up symbols
+# from shared libs.
+set some_func [find_mangled_name "some_func"]
+set string_func [find_mangled_name "string_func"]
+
+if ![fortran_runto_main] {
+    untested "could not run to main"
+    return -1
+}
+
 # Call the function SOME_FUNC, that takes a single integer and returns
 # an integer.  As the function has no debug information then we have
 # to pass the integer argument as '&1' so that GDB will send the
 # address of an integer '1' (as Fortran arguments are pass by
 # reference).
-set symbol_name [find_mangled_name "some_func"]
+set symbol_name $some_func
 if { $symbol_name == "" } {
     untested "couldn't find suitable name for 'some_func'"
 } else {
@@ -91,7 +96,7 @@ if { $symbol_name == "" } {
 # The compiled program is expecting the address of the string, so we
 # prefix that argument with '&', but the artificial length parameter
 # is pass by value, so there's no need for '&' in that case.
-set symbol_name [find_mangled_name "string_func"]
+set symbol_name $string_func
 if { $symbol_name == "" } {
     untested "couldn't find suitable name for 'string_func'"
 } else {
This page took 0.033178 seconds and 4 git commands to generate.