diff options
author | Tom de Vries <tdevries@suse.de> | 2023-03-02 10:56:40 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-03-02 10:56:40 +0100 |
commit | 0d5adb56c85da38a0f95e872fda05cc6446010c3 (patch) | |
tree | c72c25208ea040b0662f5015b5b9d90d1b848506 /gdb/testsuite/gdb.ctf/dwarf2-and-ctf.c | |
parent | 14ade916606152d67689842eef8b4b4f2a5eadf7 (diff) | |
download | binutils-0d5adb56c85da38a0f95e872fda05cc6446010c3.zip binutils-0d5adb56c85da38a0f95e872fda05cc6446010c3.tar.gz binutils-0d5adb56c85da38a0f95e872fda05cc6446010c3.tar.bz2 |
[gdb/symtab] Add set/show always-read-ctf on/off
[ This is a simplified rewrite of an earlier submission "[RFC][gdb/symtab] Add
maint set symbol-read-order", submitted here (
https://sourceware.org/pipermail/gdb-patches/2022-September/192044.html
). ]
With the test-case included in this patch, we run into:
...
(gdb) file dwarf2-and-ctf
(gdb) print var_ctf^M
'var_ctf' has unknown type; cast it to its declared type^M
...
The problem is that the executable contains both ctf and dwarf2, so the ctf
info (which contains the type information about var_ctf) is ignored.
GDB has support for handling multiple debug formats, but the common use case
for ctf is to be used when dwarf2 is not present, and gdb reflects that,
assuming that by reading ctf in addition there won't be any extra information,
so it's not worth the additional cycles and memory.
Add a new command "set/show always-read-ctf on/off", that when on forces
unconditional reading of ctf, allowing us to do:
...
(gdb) set always-read-ctf on
(gdb) file dwarf2-and-ctf
(gdb) print var_ctf^M
$2 = 2^M
...
The setting is off by default, preserving current behaviour.
A bit of background on the relevance of reading order: the formats have a
priority relationship between them, where reading earlier means lower
priority. By reading the format with the most detail last, we ensure it has
the highest priority, which makes sure that in case there is overlapping info,
the most detailed info is found. This explains the current reading order of
mdebug, stabs and dwarf2.
Add the unconditional reading of ctf before dwarf2, because it's less detailed
than dwarf2. The conditional reading of ctf is still done after the attempt to
read dwarf2, necessarily so because we only know whether there's dwarf2 after
we've tried to read it.
The new command allow us to replace uses of -Wl,--strip-debug added in commit
908a926ec4e ("[gdb/testsuite] Fix ctf test-cases on openSUSE Tumbleweed") by
uses of "set always-read-ctf on", but I've left that for another commit.
Tested on x86_64-linux.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite/gdb.ctf/dwarf2-and-ctf.c')
-rw-r--r-- | gdb/testsuite/gdb.ctf/dwarf2-and-ctf.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.c b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.c new file mode 100644 index 0000000..436ebcc --- /dev/null +++ b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.c @@ -0,0 +1,26 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2023 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +int var_dwarf = 1; + +extern int foo (); + +int +main (void) +{ + return var_dwarf + foo (); +} |