diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/NEWS | 5 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 11 | ||||
-rw-r--r-- | gdb/elfread.c | 24 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ctf/dwarf2-and-ctf-2.c | 24 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ctf/dwarf2-and-ctf.c | 26 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ctf/dwarf2-and-ctf.exp | 54 |
6 files changed, 143 insertions, 1 deletions
@@ -68,6 +68,11 @@ maintenance info frame-unwinders List the frame unwinders currently in effect, starting with the highest priority. +set always-read-ctf on|off +show always-read-ctf + When off, CTF is only read if DWARF is not present. When on, CTF is + read regardless of whether DWARF is present. Off by default. + * New convenience function "$_shell", to execute a shell command and return the result. This lets you run shell commands in expressions. Some examples: diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index c1ca455..bfda7ed 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -20365,6 +20365,17 @@ location to represent a line or a statement. The @samp{PROLOGUE-END} column indicates that a given address is an adequate place to set a breakpoint at the first instruction following a function prologue. +@kindex set always-read-ctf [on|off] +@kindex show always-read-ctf +@cindex always-read-ctf +@cindex CTF info, when to read +@item set always-read-ctf [on|off] +@itemx show always-read-ctf + +When off, CTF debug info is only read if DWARF debug info is not +present. When on, CTF debug info is read regardless of whether DWARF +debug info is present. The default value is off. + @kindex maint set symbol-cache-size @cindex symbol cache size @item maint set symbol-cache-size @var{size} diff --git a/gdb/elfread.c b/gdb/elfread.c index ca684aa..00939a0 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -51,6 +51,10 @@ #include "gdbsupport/scoped_fd.h" #include "debuginfod-support.h" #include "dwarf2/public.h" +#include "cli/cli-cmds.h" + +/* Whether ctf should always be read, or only if no dwarf is present. */ +static bool always_read_ctf; /* The struct elfinfo is available only during ELF symbol table and psymtab reading. It is destroyed at the completion of psymtab-reading. @@ -1349,10 +1353,16 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) bfd_section_size (str_sect)); } + /* Read the CTF section only if there is no DWARF info. */ + if (always_read_ctf && ei.ctfsect) + { + elfctf_build_psymtabs (objfile); + } + bool has_dwarf2 = elf_symfile_read_dwarf2 (objfile, symfile_flags); /* Read the CTF section only if there is no DWARF info. */ - if (!has_dwarf2 && ei.ctfsect) + if (!always_read_ctf && !has_dwarf2 && ei.ctfsect) { elfctf_build_psymtabs (objfile); } @@ -1449,4 +1459,16 @@ _initialize_elfread () add_symtab_fns (bfd_target_elf_flavour, &elf_sym_fns); gnu_ifunc_fns_p = &elf_gnu_ifunc_fns; + + /* Add "set always-read-ctf on/off". */ + add_setshow_boolean_cmd ("always-read-ctf", class_support, &always_read_ctf, + _("\ +Set whether CTF is always read."), + _("\ +Show whether CTF is always read."), + _("\ +When off, CTF is only read if DWARF is not present. When on, CTF is read\ + regardless of whether DWARF is present."), + nullptr /* set_func */, nullptr /* show_func */, + &setlist, &showlist); } diff --git a/gdb/testsuite/gdb.ctf/dwarf2-and-ctf-2.c b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf-2.c new file mode 100644 index 0000000..daa45be --- /dev/null +++ b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf-2.c @@ -0,0 +1,24 @@ +/* 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_ctf = 2; + +int +foo (void) +{ + return var_ctf; +} 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 (); +} diff --git a/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.exp b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.exp new file mode 100644 index 0000000..22162cf --- /dev/null +++ b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.exp @@ -0,0 +1,54 @@ +# 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/>. + +require allow_ctf_tests + +standard_testfile .c -2.c + +set objfile [standard_output_file ${testfile}.o] +set objfile2 [standard_output_file ${testfile}-2.o] + +set s1 ${srcdir}/${subdir}/${srcfile} +set s2 ${srcdir}/${subdir}/${srcfile2} + +set opts {} +lappend opts debug +if { [gdb_compile $s1 ${objfile} object $opts] != "" } { + untested "failed to compile" + return -1 +} + +set opts {} +lappend opts "additional_flags=-gctf" +if { [gdb_compile $s2 ${objfile2} object $opts] != "" } { + untested "failed to compile" + return -1 +} + +set opts {} +lappend opts "additional_flags=-Wl,-ctf-variables" +if { [gdb_compile [list ${objfile} ${objfile2}] $binfile executable $opts] != "" } { + unsupported "failed to link" + return -1 +} + +clean_restart + +gdb_test_no_output "set always-read-ctf on" + +gdb_load $binfile + +gdb_test "print var_dwarf" " = 1" +gdb_test "print var_ctf" " = 2" |