diff options
author | Kevin Buettner <kevinb@redhat.com> | 2024-05-01 18:37:58 -0700 |
---|---|---|
committer | Kevin Buettner <kevinb@redhat.com> | 2024-05-31 14:37:22 -0700 |
commit | 7f34450b75b6c4f63565aa06857aa3c824094e4b (patch) | |
tree | cdb7f4fc3435fe6c3db2ebeddff0672452846af4 /elfcpp | |
parent | cc80485f45cc983370327b50d4310927bb77b7bb (diff) | |
download | gdb-7f34450b75b6c4f63565aa06857aa3c824094e4b.zip gdb-7f34450b75b6c4f63565aa06857aa3c824094e4b.tar.gz gdb-7f34450b75b6c4f63565aa06857aa3c824094e4b.tar.bz2 |
[gdb/testsuite] New test: gdb.base/errno.exp
Printing the value of 'errno' from GDB is sometimes problematic. The
situation has improved in recent years, though there are still
scenarios for which "print errno" doesn't work.
The test, gdb.base/errno.exp, introduced by this commit, tests whether
or not GDB can print errno using a binary compiled in the following
different ways:
- default: no switches aside from -g (and whatever else is added by the
testing framework)
- macros: macro info is included in the debuginfo; this is enabled by
using -g3 when using gcc or clang
- static: statically linked binary
- static-macros: statically linked binary w/ macro definitions included
in debuginfo
- pthreads: libpthread linked binary
- pthreads-macros: libpthread linked binary w/ macro definitions included
in debuginfo
- pthreads-static: Statically linked against libpthread
- pthreads-static-macros: Statically linked against libpthread w/ macro
definitions
For each of these, the test also creates a corefile, then loads the
corefile and attempts to print errno again.
Additionally, the test checks that a "masking" errno declared as a
local variable will print correctly.
On Linux, if the machine is missing glibc debuginfo (or you have
debuginfod disabled), it's likely you'll see:
(gdb) print errno
'errno' has unknown type; cast it to its declared type
But if you add a cast, the value of errno is often available:
(gdb) print (int) errno
$1 = 42
The test detects this situation along with several others and does
'setup_xfail' for tests that will almost certainly fail. It could be
argued that some of these ought to be KFAILs due to deficiencies in
GDB, but I'm not entirely certain which, if any, are fixable yet.
On Fedora 39, without glibc debuginfo, there are no failures, but
I do see the following XFAILS:
XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: print errno
XFAIL: gdb.base/errno.exp: macros: print (int) errno
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: print errno
XFAIL: gdb.base/errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads: print errno
XFAIL: gdb.base/errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile
On Fedora 39, with glibc debug info, but without libc.a (for static
linking), there are 2 XFAILs, 2 UNSUPPORTED tests, and 4 UNTESTED
tests.
So, even when testing in less than ideal conditions, either due to lack
of glibc debuginfo or lack of a libc to link against to make a static
binary, there are no failures.
With glibc debuginfo installed, on Fedora 38, Fedora 39, Fedora 40,
Fedora rawhide (41), and Ubuntu 22.04.1 LTS, I see these XFAILs:
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: print errno
XFAIL: gdb.base/errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile
On FreeBSD 13.1, the total number of XFAILs are fewer, and could be
even better still if it had debug info for glibc:
XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: print errno
XFAIL: gdb.base/errno.exp: macros: print (int) errno
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads: print errno
XFAIL: gdb.base/errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile
Starting with glibc-2.34, most of the pthreads library has been
incorporated into libc, so finding thread-local variables using
libthread_db is possible for several scenarios in which it previously
wasn't. But, prior to this, accessing errno for the default scenario
was a problem. This is borne out by running this new test on Fedora
34, which uses glibc-2.33:
XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: print (int) errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: print errno
XFAIL: gdb.base/errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile
In the v3 version of this test, Tom de Vries tested on openSUSE Leap
15.5 and found a number of cases which showed a FAIL instead of an
XFAIL. The v4 version of this test fixed those problems. On Leap
15.5, which uses glibc-2.31, with glibc debug info, I now see:
XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: print (int) errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile
On Leap 15.5, with glibc debuginfo missing, the results are a little
worse:
XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: print (int) errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: print errno
XFAIL: gdb.base/errno.exp: macros: print (int) errno
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads: print errno
XFAIL: gdb.base/errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile
The v5 version of this test fixed failures when testing with
check-read1. (Thanks to Linaro CI for finding these.) I revised the
regular expressions being used so that the failures were eliminated,
but the results mentioned above have not changed.
The v6 version of this test fixes some nits pointed out by both Tom
de Vries and Pedro Alves. One of Pedro's suggestions was to rename the
test from check-errno.exp to errno.exp, so in v5, the name has
changed. Tom also noticed that there were failures when using
--target_board=native-extended-gdbserver. For v6, I've tested on 10
different Linux machines (F38, F39, F39 w/o glibc debuginfo, F39 w/o
static glibc, F40, rawhide, Ubuntu 22.04, Leap 15.5, Leap 15.5 w/o
glibc debuginfo, and Fedora 34) using "make check" and "make check-read1"
using target boards "unix", "native-extended-gdbserver", and
"native-gdbserver", with CC_FOR_TARGET set to both gcc and clang, for
a total of 12 distinct test runs on each machine. I've also tested the
native-only cases on FreeBSD. (Attempting to test against gdbserver
on FreeBSD resulted in hangs while running the test suite.)
The v7 version of this test simplifies the REs used in the uses of
gdb_test_multiple by adding -wrap and removing parts of the REs which
match the GDB prompt. In cases where there was a leading '.*', those
were removed too. Thanks to Pedro for explaining how to use -wrap.
So, bottom line, this test does not introduce any new failures on the
platforms on which I've tested, but the XFAILs are certainly unfortunate.
Some aren't fixable - e.g. when attempting to make a function call while
debugging a core file - but I think that some of them are. I'm using
this new test case as a starting point for investigating problems with
printing errno.
Co-Authored-By: Jan Kratochvil
Approved-By: Tom de Vries <tdevries@suse.de>
Diffstat (limited to 'elfcpp')
0 files changed, 0 insertions, 0 deletions