The type struct compunit_symtab contains two fields (disregarding field next)
that express relations with other compunit_symtabs: user and includes.
These fields are currently not printed with "maint info symtabs" and
"maint print symbols".
Fix this such that for "maint info symtabs" we print:
...
{ ((struct compunit_symtab *) 0x23e8450)
debugformat DWARF 2
producer (null)
dirname (null)
blockvector ((struct blockvector *) 0x23e8590)
+ user ((struct compunit_symtab *) 0x2336280)
+ ( includes
+ ((struct compunit_symtab *) 0x23e85e0)
+ ((struct compunit_symtab *) 0x23e8960)
+ )
{ symtab <unknown> ((struct symtab *) 0x23e85b0)
fullname (null)
linetable ((struct linetable *) 0x0)
}
}
...
And for "maint print symbols" we print:
...
-Symtab for file <unknown>
+Symtab for file <unknown> at 0x23e85b0
Read from object file /data/gdb_versions/devel/a.out (0x233ccf0)
Language: c
Blockvector:
block #000, object at 0x23e8530, 0 syms/buckets in 0x0..0x0
block #001, object at 0x23e84d0 under 0x23e8530, 0 syms/buckets in 0x0..0x0
+Compunit user: 0x2336300
+Compunit include: 0x23e8900
+Compunit include: 0x23dd970
...
Note: for user and includes we don't list the actual compunit_symtab address,
but instead the corresponding symtab address, which allows us to find that
symtab elsewhere in the output (given that we also now print the address of
symtabs).
gdb/ChangeLog:
2020-03-25 Tom de Vries <tdevries@suse.de>
* symtab.h (is_main_symtab_of_compunit_symtab): New function.
* symmisc.c (dump_symtab_1): Print user and includes fields.
(maintenance_info_symtabs): Same.
When setting up function parameters we already perform NaN boxing, as
required by the RISC-V ABI, however, we don't do this when writing
values into registers as part of setting up a return value.
This commit moves the NaN boxing code into a small helper function,
and then makes use of this function when setting up function
parameters, and also when setting up return values.
This should resolve this failure:
FAIL: gdb.base/return-nodebug.exp: float: full width of the returned result
gdb/ChangeLog:
PR gdb/25489
* riscv-tdep.c (riscv_arg_info::c_offset): Update comment.
(riscv_regcache_cooked_write): New function.
(riscv_push_dummy_call): Use new function.
(riscv_return_value): Likewise.
PRINT_DEBUG_RELOC_INFO_BEFORE() macro prints bunch of parameters
for debugging purposes. Due to a seemingly copy/paste mistake,
the "input_section->vma" is printed under the field name
"symbol_section->vma". This commit fixes that.
This fix is a courtesy of xiangzhai.
* elf32-arc.c (PRINT_DEBUG_RELOC_INFO_BEFORE): Use the
correct field name in the output string.
PR 25681
* elf.c (_bfd_elf_map_sections_to_segments): When looking for a
segment to use for PT_GNU_RELRO, ignore empty sections in a
segment's current list.
elf.c failed with to with GCC 10 as of
commit 906b3eb9df6c577d3f6e9c3ea5c9d7e4d1e90536
Author: Martin Liska <mliska@suse.cz>
Date: Tue Mar 24 11:40:10 2020 +0100
Improve endianess detection.
PR lto/94249
* plugin-api.h: Add more robust endianess detection.
binutils-gdb/bfd/elf.c: In function ‘setup_group’:
binutils-gdb/bfd/elf.c:740:35: error: overflow in conversion from ‘unsigned int’ to ‘int’ changes value from ‘num_group = 4294967295’ to ‘-1’ [-Werror=overflow]
740 | elf_tdata (abfd)->num_group = num_group = -1;
| ^~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:1608: elf.lo] Error 1
Change num_group in elf_obj_tdata to unsigned int to compile with GCC 10.
PR binutils/25717
* elf-bfd.h (elf_obj_tdata): Change num_group to unsigned int.
Extend _bfd_elf_get_symbol_version_string for nm -D to display symbol
version. _bfd_elf_get_symbol_version_name is added to avoid updating
all XXX_get_symbol_version_string functions.
bfd/
PR binutils/25708
* elf-bfd.h (_bfd_elf_get_symbol_version_name): New.
* elf.c (_bfd_elf_get_symbol_version_name): New function. Based
on the previous _bfd_elf_get_symbol_version_string.
(_bfd_elf_get_symbol_version_string): Use it.
binutils/
PR binutils/25708
* nm.c (SYM_NAME): Removed.
(print_symname): Add a pointer to struct extended_symbol_info
argument. Call _bfd_elf_get_symbol_version_name to get symbol
version.
(print_symdef_entry): Pass NULL to print_symname.
(print_symbol_info_bsd): Update call to print_symname.
(print_symbol_info_sysv): Likewise.
(print_symbol_info_posix): Likewise.
ld/
PR binutils/25708
* testsuite/ld-elf/pr25708.d: New file.
The type struct partial_symtab contains two fields (disregarding field next)
that express relations with other symtabs: user and dependencies.
When using "maint print psymbols", we see both the dependencies and the user
fields:
...
Partial symtab for source file (object 0x35ef270)
...
Depends on 0 other partial symtabs.
Shared partial symtab with user 0x35d5f40
...
But with "maint info psymtabs", we only see dependencies:
...
{ psymtab ((struct partial_symtab *) 0x35ef270)
...
dependencies (none)
}
...
Add printing of the user field for "maint info psymtabs", such that we have:
...
{ psymtab ((struct partial_symtab *) 0x35ef270)
...
+ user hello.c ((struct partial_symtab *) 0x35d5f40)
dependencies (none)
}
...
Tested on x86_64-linux.
gdb/ChangeLog:
2020-03-24 Tom de Vries <tdevries@suse.de>
* psymtab.c (maintenance_info_psymtabs): Print user field.
* ecoff.c (_bfd_ecoff_slurp_armap): Sanity check parsed_size and
symbol count. Allocate an extra byte to ensure name strings
are terminated. Sanity check name offsets. Release memory on
error return.
Also reinstate ld i386aout for i386-msdos target, which doesn't build
otherwise.
bfd/
* i386msdos.c (msdos_object_p): Don't access e_lfanew when that
field hasn't been read. Remove unnecessary casts.
ld/
* Makefile.am (ALL_EMULATION_SOURCES): Reinstate ei386aout.c.
Include ei386aout dep file.
* Makefile.in: Regenerate.
* po/BLD-POTFILES.in: Regenerate.
In commit:
commit 6b8c53f2f1
Date: Sat Feb 8 21:26:31 2020 +0000
gdb/testsuite/fortran: Add mixed language stack test
The test incorrectly included two hard coded addresses in the expected
output, this commit replaces them with the $hex pattern.
gdb/testsuite/ChangeLog:
* gdb.fortran/mixed-lang-stack.exp: Replace two hard coded address
with $hex.
* arc-dis.c (find_format): Use ISO C string concatenation rather
than line continuation within a string. Don't access needs_limm
before testing opcode != NULL.
git commit d1e304bc27 was aimed at stopping uninitialised memory
access to the index_offset array. Unfortunately that patch resulted
in a different array being uninitialised for all instructions with
more than two arguments.
* ns32k-dis.c (print_insn_arg): Update comment.
(print_insn_ns32k): Reduce size of index_offset array, and
initialize, passing -1 to print_insn_arg for args that are not
an index. Don't exit arg loop early. Abort on bad arg number.
Fix comma at end of enumerator list seen with -std=c++98.
* plugin-api.h (enum ld_plugin_symbol_type): Remove
comma after last value of an enum.
* lto-symtab.h (enum gcc_plugin_symbol_type): Likewise.
dwarf2_evaluate_property should not modify its "addr_stack"
parameter's contents. This patch makes this part of the API, by
marking it const.
gdb/ChangeLog
2020-03-20 Tom Tromey <tromey@adacore.com>
* dwarf2/loc.h (dwarf2_evaluate_property): Make "addr_stack"
const.
* dwarf2/loc.c (dwarf2_evaluate_property): Make "addr_stack"
const.
When running test-case gdb.threads/omp-par-scope.exp, I get this XPASS:
...
XPASS: gdb.threads/omp-par-scope.exp: nested_parallel: outer_threads: \
outer stop: get valueof "num"
...
for test:
...
set thread_num [get_valueof "" "num" "unknown"]
...
The intention of the test is to get the value of local variable num, which
has been set to:
...
int num = omp_get_thread_num ();
...
but the actually printed value is 'num':
...
(gdb) print num^M
$76 = num^M
...
This is due to the fact that num is missing in the locals, so instead we find
the enum member 'num' of enum expression_operator in glibc/intl/plural-exp.h.
Fix this by getting the value using a new proc get_local_valueof, which uses
the "info locals" commands to get the value.
Tested on x86_64-linux, with gcc 7.5.0 (where the test xfails) and gcc
10.0.1 (where the test passes).
I stumbled on this snippet in nat/gdb_ptrace.h:
/* Some systems, in particular DEC OSF/1, Digital Unix, Compaq Tru64
or whatever it's called these days, don't provide a prototype for
ptrace. Provide one to silence compiler warnings. */
#ifndef HAVE_DECL_PTRACE
extern PTRACE_TYPE_RET ptrace();
#endif
I believe this is unnecessary today and should be removed. First, the
comment only mentions OSes we don't support (and to be honest, I had
never even heard of).
But most importantly, in C++, a declaration with empty parenthesis
declares a function that accepts no arguments, unlike in C. So if this
declaration was really used, GDB wouldn't build, since all ptrace call
sites pass some arguments. Since we haven't heard anything about this
causing some build failures since we have transitioned to C++, I
conclude that it's not used.
This patch removes it as well as the corresponding configure check.
gdb/ChangeLog:
* ptrace.m4: Don't check for ptrace declaration.
* config.in: Re-generate.
* configure: Re-generate.
* nat/gdb_ptrace.h: Don't declare ptrace if HAVE_DECL_PTRACE is
not defined.
gdbserver/ChangeLog:
* config.in: Re-generate.
* configure: Re-generate.
gdbsupport/ChangeLog:
* config.in: Re-generate.
* configure: Re-generate.
Linux returns long from ptrace(2) and BSDs int.
gdb/ChangeLog:
* amd64-bsd-nat.c (gdb_ptrace): Change return type from `int' to
`PTRACE_TYPE_RET'.
* i386-bsd-nat.c (gdb_ptrace): Likewise.
* sparc-nat.c (gdb_ptrace): Likewise.
* x86-bsd-nat.c (gdb_ptrace): Likewise.
The "restrict" patch added some asserts to c-exp.y, but one spot was
copy-pasted and referred to the wrong table. This was pointed out by
-fsanitize=address. This patch fixes the bug.
gdb/ChangeLog
2020-03-20 Tom Tromey <tromey@adacore.com>
* c-exp.y (lex_one_token): Fix assert.
I configured with -fsanitize=address and built gdb. linux-tdep.c and
ada-tasks.c failed to build due to some stringop-truncation errors,
e.g.:
In function ‘char* strncpy(char*, const char*, size_t)’,
inlined from ‘int linux_fill_prpsinfo(elf_internal_linux_prpsinfo*)’ at ../../binutils-gdb/gdb/linux-tdep.c:1742:11,
inlined from ‘char* linux_make_corefile_notes(gdbarch*, bfd*, int*)’ at ../../binutils-gdb/gdb/linux-tdep.c:1878:27:
/usr/include/bits/string_fortified.h:106:34: error: ‘char* __builtin_strncpy(char*, const char*, long unsigned int)’ specified bound 81 equals destination size [-Werror=stringop-truncation]
This patch fixes the problem by using "sizeof - 1" in the call to
strndup, as recommended in the GCC manual. This doesn't make a
difference here because the next line, in all cases, sets the final
element to '\0' anyway.
gdb/ChangeLog
2020-03-20 Tom Tromey <tromey@adacore.com>
* ada-tasks.c (read_atcb): Use smaller length in strncpy call.
* linux-tdep.c (linux_fill_prpsinfo): Use smaller length in
strncpy call.
Andrew Burgess pointed out on irc that "maint info line-table" doesn't
properly align the table headers. This patch fixes the problem by
switching the table to use ui-out.
This required a small tweak to one test case, as ui-out will pad a
field using spaces, even at the end of a line.
gdb/ChangeLog
2020-03-20 Tom Tromey <tromey@adacore.com>
* symmisc.c (maintenance_print_one_line_table): Use ui_out.
gdb/testsuite/ChangeLog
2020-03-20 Tom Tromey <tromey@adacore.com>
* gdb.dwarf2/dw2-ranges-base.exp: Update regular expressions.
The removal of val_print caused a regression in the Ada code. In one
scenario, a variant type would not be properly printed, because the
address of a component was lost. This patch fixes the bug by changing
this API to be value-based. This is cleaner and fixes the bug as a
side effect.
gdb/ChangeLog
2020-03-20 Tom Tromey <tromey@adacore.com>
* ada-valprint.c (print_variant_part): Remove parameters; switch
to value-based API.
(print_field_values): Likewise.
(ada_val_print_struct_union): Likewise.
(ada_value_print_1): Update.
gdb/testsuite/ChangeLog
2020-03-20 Tom Tromey <tromey@adacore.com>
* gdb.ada/sub_variant/subv.adb: New file.
* gdb.ada/sub_variant.exp: New file.
gdb/ChangeLog:
* ppc-nbsd-nat.c (ppc_nbsd_nat_target): Inherit from
nbsd_nat_target instead of inf_ptrace_target.
* ppc-nbsd-nat.c: Include "nbsd-nat.h", as we are now using
nbsd_nat_target.
NetBSD ptrace(2) accepts thread id (LWP) as the 4th argument for threads.
gdb/ChangeLog:
* hppa-nbsd-nat.c (fetch_registers): New variable lwp and pass
it to the ptrace call.
* (store_registers): Likewise.
When running test-cases gdb.threads/step-over-lands-on-breakpoint.exp and
gdb.threads/step-over-trips-on-watchpoint.exp with target board
unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects, we run into timeouts
due not being able to set a breakpoint and then trying to continue to that
breakpoint.
In total, we run into 186 timeouts, which roughly corresponds to half an hour:
...
$ grep "FAIL.*(timeout)" gdb.sum \
| awk '{print $2}' \
| sort \
| uniq -c
66 gdb.threads/step-over-lands-on-breakpoint.exp:
120 gdb.threads/step-over-trips-on-watchpoint.exp:
...
Fix this by bailing out if the first break fails.
Tested on x86_64-linux, both with native and with target board mentioned above.
gdb/testsuite/ChangeLog:
2020-03-20 Tom de Vries <tdevries@suse.de>
* gdb.threads/step-over-lands-on-breakpoint.exp (do_test): Bail out if
first break fails.
* gdb.threads/step-over-trips-on-watchpoint.exp: (do_test): Same.
NetBSD ptrace(2) accepts thread id (LWP) as the 4th argument for threads.
gdb/ChangeLog:
* ppc-nbsd-nat.c (fetch_registers): New variable lwp and pass
it to the ptrace call.
* (store_registers): Likewise.
Since LTO plugin may generate more than one ltrans.o file from one input
IR object as LTO wrapper ignores -flto-partition=none:
lto-wrapper.c:608:
604 /* Drop arguments that we want to take from the link line. */
605 case OPT_flto_:
606 case OPT_flto:
607 case OPT_flto_partition_:
608 continue;
the LTO wrapper approach is not only slow but also unreliable. Since
the LTO plugin API has been extended to add LDPT_ADD_SYMBOLS_V2 with
symbol type and section kind, we can use LDPT_ADD_SYMBOLS_V2 to get
symbol type, instead of invoking the LTO wrapper.
PR binutils/25640
* plugin.c (plugin_list_entry): Add has_symbol_type.
(add_symbols_v2): New function.
(bfd_plugin_open_input): Don't invoke LTO wrapper if LTO plugin
provides symbol type.
(try_load_plugin): Add LDPT_ADD_SYMBOLS_V2.
(bfd_plugin_canonicalize_symtab): Use LTO plugin symbol type if
available.