Tom Tromey [Wed, 5 Jan 2022 15:43:59 +0000 (08:43 -0700)]
Do not print anything when self-backtrace unavailable
Right now, gdb's self-backtrace feature will still print something
when a backtrace is unavailable:
sig_write (_("----- Backtrace -----\n"));
[...]
sig_write (_("Backtrace unavailable\n"));
sig_write ("---------------------\n");
However, if GDB_PRINT_INTERNAL_BACKTRACE is undefined, it seems better
to me to print nothing at all.
This patch implements this change. It also makes a couple of other
small changes in this same module: it adds a header guard to
bt-utils.h, and it protects the definitions of
gdb_internal_backtrace_1 with a check of GDB_PRINT_INTERNAL_BACKTRACE.
Tom Tromey [Mon, 3 Jan 2022 16:48:37 +0000 (09:48 -0700)]
Fix pager regression
The patch to fix paging with redirection caused a regression in the
internal AdaCore test suite. The problem occurs when running an MI
command from the CLI using interpreter-exec, when paging is enabled.
This scenario isn't covered by the current test suite, so this patch
includes a new test.
The problem is that, in this situation, MI does:
fputs_unfiltered (strcmp (context->command, "target-select") == 0
? "^connected" : "^done", mi->raw_stdout);
Here raw_stdout is a stdio_file wrapping stdout, so the pager thinks
that it is ok to buffer the output. However, in this setup, it isn't
ok, and flushing the wrap buffer doesn't really work properly. Also,
MI next does:
mi_out_put (uiout, mi->raw_stdout);
... but this uses ui_file::write, which also doesn't flush the wrap
buffer.
I think all this will be fixed by the pager rewrite series I'm working
on. However, in the meantime, adding the old gdb_stdout check back to
the pager fixes this problem.
Regression tested on x86-64 Fedora 34.
H.J. Lu [Tue, 14 Dec 2021 03:46:04 +0000 (19:46 -0800)]
elf: Set p_align to the minimum page size if possible
Currently, on 32-bit and 64-bit ARM, it seems that ld generates p_align
values of 0x10000 even if no section alignment is greater than 0x1000.
The issue is more general and probably affects other targets with multiple
page sizes.
While file layout absolutely must take 64K page size into account, that
does not have to be reflected in the p_align value. If running on a 64K
kernel, the file will be loaded at a 64K page boundary by necessity. On
a 4K kernel, 64K alignment is not needed.
The glibc loader has been fixed to honor p_align:
https://sourceware.org/bugzilla/show_bug.cgi?id=28676
similar to kernel:
commit
ce81bb256a224259ab686742a6284930cbe4f1fa
Author: Chris Kennelly <ckennelly@google.com>
Date: Thu Oct 15 20:12:32 2020 -0700
fs/binfmt_elf: use PT_LOAD p_align values for suitable start address
This means that on 4K kernels, we will start to do extra work for 64K
p_align, but this pointless for pretty much all binaries (whose section
alignment rarely exceeds 16).
The minimum page size is used, instead of the maximum section alignment
due to this glibc bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=28688
It has been fixed in glibc 2.35. But linker output must work on existing
glibc binaries.
1. Set p_align to the minimum page size while laying out segments aligning
to the maximum page size or section alignment. The run-time loader can
align segments to the minimum page size or above, depending on system page
size.
2. If -z max-page-size=NNN is used, p_align will be set to the maximum
page size or the largest section alignment.
3. If a section requires alignment higher than the minimum page size,
don't set p_align to the minimum page size.
4. If a section requires alignment higher than the maximum page size,
set p_align to the section alignment.
5. For objcopy, when the minimum page size != the maximum page size,
p_align may be set to the minimum page size while segments are aligned
to the maximum page size. In this case, the input p_align will be
ignored and the maximum page size will be used to align the ouput
segments.
6. Update linker to disallow the common page size > the maximum page size.
7. Update linker to avoid the common page size > the maximum page size.
8. Adjust pru_irq_map-1.d to expect p_align == sh_addralign:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL
00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS
20000000 00007c 000004 00 AX 0 0 4
...
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000074 0x00000000 0x00000000 0x00008 0x00008 RW 0x1
LOAD 0x00007c 0x20000000 0x20000000 0x00004 0x00004 R E 0x4
vs.
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL
00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS
20000000 00007c 000004 00 AX 0 0 4
...
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000074 0x00000000 0x00000000 0x00008 0x00008 RW 0x1
LOAD 0x00007c 0x20000000 0x20000000 0x00004 0x00004 R E 0x1
To enable this linker optimization, the backend should define ELF_P_ALIGN
to ELF_MINPAGESIZE.
bfd/
PR ld/28689
PR ld/28695
* elf-bfd.h (elf_backend_data): Add p_align.
* elf.c (assign_file_positions_for_load_sections): Set p_align
to the default p_align value while laying out segments aligning
to maximum page size or section alignment.
(elf_is_p_align_valid): New function.
(copy_elf_program_header): Call elf_is_p_align_valid to determine
if p_align is valid.
* elfxx-target.h (ELF_P_ALIGN): New. Default to 0.
(elfNN_bed): Add ELF_P_ALIGN.
* elfxx-x86.h (ELF_P_ALIGN): New. Set to ELF_MINPAGESIZE.
include/
PR ld/28689
PR ld/28695
* bfdlink.h (bfd_link_info): Add maxpagesize_is_set.
ld/
PR ld/28689
PR ld/28695
* emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Set
link_info.maxpagesize_is_set for -z max-page-size=NNN.
* ldelf.c (ldelf_after_parse): Disallow link_info.commonpagesize
> link_info.maxpagesize.
* testsuite/ld-elf/elf.exp: Pass -z max-page-size=0x4000 to
linker to build mbind2a and mbind2b.
* testsuite/ld-elf/header.d: Add -z common-page-size=0x100.
* testsuite/ld-elf/linux-x86.exp: Add PR ld/28689 tests.
* testsuite/ld-elf/p_align-1.c: New file.
* testsuite/ld-elf/page-size-1.d: New test.
* testsuite/ld-elf/pr26936.d: Add -z common-page-size=0x1000.
* testsuite/ld-elf/seg.d: Likewise.
* testsuite/ld-scripts/rgn-at5.d: Likewise.
* testsuite/ld-pru/pru_irq_map-1.d: Append 1 to name. Adjust
expected PT_LOAD segment alignment.
* testsuite/ld-pru/pru_irq_map-2.d: Append 2 to name.
* testsuite/ld-scripts/pr23571.d: Add -z max-page-size=0x1000.
Alan Modra [Wed, 5 Jan 2022 08:36:27 +0000 (19:06 +1030)]
Adjust quoted-sym-names test
Some targets restrict symbol addresses in .text to instruction
boundaries.
* testsuite/gas/all/quoted-sym-names.s: Define syms in .data.
* testsuite/gas/all/quoted-sym-names.d: Adjust to suit.
Alan Modra [Wed, 5 Jan 2022 01:09:12 +0000 (11:39 +1030)]
infinite recursion detected in gold testcase
gold/testsuite/icf_test.cc:32:5: error: infinite recursion detected [-Werror=infinite-recursion]
32 | int kept_func()
| ^~~~~~~~~
* testsuite/icf_test.cc: Avoid infinite recursion error.
GDB Administrator [Wed, 5 Jan 2022 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Tue, 4 Jan 2022 19:07:50 +0000 (11:07 -0800)]
ld/x86: Update -z report-relative-reloc
Use 0x%v, instead of bfd_sprintf_vma, to report relative relocations.
Change linker relative relocations report from
tmpdir/dump: R_X86_64_IRELATIVE (offset: 0x0000000000002000, info: 0x0000000000000025, addend: 0x0000000000001007) against 'ifunc' for section '.data.rel.ro.local' in tmpdir/report-reloc-1.o
to
tmpdir/dump: R_X86_64_IRELATIVE (offset: 0x2000, info: 0x25, addend: 0x1007) against 'ifunc' for section '.data.rel.ro.local' in tmpdir/report-reloc-1.o
bfd/
* elfxx-x86.c (_bfd_x86_elf_link_report_relative_reloc): Use
0x%v instead of bfd_sprintf_vma.
ld/
* testsuite/ld-i386/report-reloc-1.l: Updated.
* testsuite/ld-x86-64/report-reloc-1.l: Likewise.
H.J. Lu [Sat, 25 Dec 2021 00:04:03 +0000 (16:04 -0800)]
ld: Improve thin archive member error message
Improve thin archive member error message with:
ld: libbar.a(bar.o): error opening thin archive member: No such file or directory
instead of
ld: libbar.a: error adding symbols: No such file or directory
PR ld/28722
* archive.c (_bfd_get_elt_at_filepos): Add a pointer argument
for struct bfd_link_info. Call linker callback when failing to
open thin archive member.
(_bfd_generic_get_elt_at_index): Pass NULL to
_bfd_get_elt_at_filepos.
(bfd_generic_openr_next_archived_file): Likewise.
* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Add a pointer
argument for struct bfd_link_info and pass it to
_bfd_get_elt_at_filepos.
(alpha_ecoff_openr_next_archived_file): Pass NULL to
_bfd_get_elt_at_filepos.
(alpha_ecoff_get_elt_at_index): Likewise.
* coff-rs6000.c (_bfd_xcoff_openr_next_archived_file): Likewise.
* ecoff.c (ecoff_link_add_archive_symbols): Pass info to
backend->get_elt_at_filepos.
* elflink.c (elf_link_is_defined_archive_symbol): info to
_bfd_get_elt_at_filepos.
* libbfd-in.h (_bfd_get_elt_at_filepos): Add a pointer argument
for struct bfd_link_info.
* libbfd.h: Regenerate.
* libecoff.h (ecoff_backend_data): Add a pointer argument for
struct bfd_link_info to get_elt_at_filepos.
* linker.c (_bfd_generic_link_add_archive_symbols): Pass info to
_bfd_get_elt_at_filepos.
Lancelot SIX [Wed, 29 Dec 2021 14:01:25 +0000 (09:01 -0500)]
gdb/testsuite: fix inferior-clone.exp for native-extended-gdbserver
003aae076207dbf32f98ba846158fc32669ef85f (gdb: Copy inferior properties
in clone-inferior) introduced a testcase that fails when testing with
the native-extended-gdbserver board:
Running ../gdb/testsuite/gdb.base/inferior-clone.exp ...
FAIL: gdb.base/inferior-clone.exp: inferior 2: clone-inferior
FAIL: gdb.base/inferior-clone.exp: inferior 3: clone-inferior
The error is as follows:
clone-inferior
[New inferior 2]
Added inferior 2 on connection 1 (extended-remote localhost:2346)
(gdb) FAIL: gdb.base/inferior-clone.exp: inferior 2: clone-inferior
This fails because the testcase only expect the 'Added inferior 2' part
of the message. The 'on connection 1 [...]' part is unexpected.
Fix by adjusting the testcase to a account for the possible trailing
part of the message.
Tested on x86_64-linux with native-extende-gdbserver and unix boards.
Change-Id: Ie3d6f04c9ffe9cab1fbda8ddf4935ee09b858c7a
Nick Clifton [Tue, 4 Jan 2022 10:33:11 +0000 (10:33 +0000)]
Add ATTRIBUTE_UNUSED to load_build_id_debug_file()'s main_filename parameter.
Andrew Burgess [Wed, 29 Dec 2021 11:53:49 +0000 (11:53 +0000)]
gdb: don't pass nullptr to sigwait
I tried building GDB on GNU/Hurd, and ran into this warning:
gdbsupport/scoped_ignore_signal.h:78:16: error: null argument where non-null required (argument 2) [-Werror=nonnull]
This is because in this commit:
commit
99624310dd82542c389c89c2e55d8cae36bb74e1
Date: Sun Jun 27 15:13:14 2021 -0400
gdb: fall back on sigpending + sigwait if sigtimedwait is not available
A call to sigwait was introduced that passes nullptr as the second
argument, this call is only reached if sigtimedwait is not supported.
The original patch was written for macOS, I assume on that target
passing nullptr as the second argument is fine.
On my GNU/Linux box, the man-page for sigwait doesn't mention that
nullptr is allowed for the second argument, so my assumption would be
that nullptr is not OK, and, if I change the '#ifdef
HAVE_SIGTIMEDWAIT' introduced by the above patch to '#if 0', and
rebuild on GNU/Linux, I see the same warning that I see on GNU/Hurd.
I propose that we stop passing nullptr as the second argument to
sigwait, and instead pass a valid int pointer. The value returned in
the int can then be used in an assert.
For testing, I (locally) made the change to the #ifdef I mentioned
above, compiled GDB, and ran the usual tests, this meant I was using
sigwait instead on sigtimedwait on GNU/Linux, I saw no regressions.
Nick Clifton [Tue, 4 Jan 2022 10:26:15 +0000 (10:26 +0000)]
Remove a spurious debugging message.
PR 28716
* dwarf.c (load_build_id_debug_file): Remove spurious printf.
Tom de Vries [Tue, 4 Jan 2022 09:24:36 +0000 (10:24 +0100)]
[gdb/build] Fix build breaker in gdb/cli/cli-logging.c
Fix build breaker in gdb/cli/cli-logging.c:
...
gdb/cli/cli-logging.c: In function \
‘void show_logging_enabled(ui_file*, int, cmd_list_element*, const char*)’:
gdb/gdbsupport/gdb_locale.h:28:28: error: cannot convert ‘char*’ to ‘ui_file*’
28 | # define _(String) gettext (String)
| ~~~~~~~~^~~~~~~~
| |
| char*
gdb/cli/cli-logging.c:202:25: note: in expansion of macro ‘_’
202 | fprintf_unfiltered (_("on: Logging is enabled.\n"));
| ^
...
Build and tested on x86_64-linux.
Fixes: 45aec4e5ed8 ("[gdb/cli] Improve show logging output")
Jan Beulich [Tue, 4 Jan 2022 09:05:53 +0000 (10:05 +0100)]
x86/Intel: correct VFPCLASSP{S,D} handling when displacement is present
fits_in_disp8() can be called before ambiguous operands get resolved
or rejected (in process_suffix()), which requires that i.memshift be
non-negative to avoid an internal error. This case wasn't covered by
6c0946d0d28d ("x86: correct VFPCLASSP{S,D} operand size handling").
Jan Beulich [Tue, 4 Jan 2022 09:05:17 +0000 (10:05 +0100)]
gas: rework handling of backslashes in quoted symbol names
Strange effects can result from the present handling, e.g.:
.if 1
"backslash\\":
.endif
yields first (correctly) "missing closing `"'" but then also "invalid
character '\' in mnemonic" and further "end of file inside conditional".
Symbols names ending in \ are in principle not expressable with that
scheme.
Instead of recording whether a backslash was seen, inspect the
subsequent character right away. Only accept \\ (meaning a single
backslash in the resulting symbol name) and \" (meaning an embedded
double quote in the resulting symbol name) for now, warning about any
other combination.
While perhaps not necessary immediately, also permit concatenated
strings to form a symbol name. This may become useful if going forward
we would want to support \<octal> or \x<hex> sequences, where closing
and re-opening quotes can be useful to delimit such sequences.
The ELF "Multibyte symbol names" test gets switched away from using
.set, as that would now also mean excluding nios2 and pru. By using
.equiv instead, even the existing #notarget can be dropped. (For h8300
the .section directive additionally needs attributes specified, to avoid
a target specific warning.)
GDB Administrator [Tue, 4 Jan 2022 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Mon, 3 Jan 2022 22:59:30 +0000 (23:59 +0100)]
[gdb/cli] Improve show logging output
Before commit
3b6acaee895 "Update more calls to add_prefix_cmd" we had the
following output for "show logging":
...
$ gdb -q -batch -ex "set trace-commands on" \
-ex "set logging off" \
-ex "show logging" \
-ex "set logging on" \
-ex "show logging"
+set logging off
+show logging
Future logs will be written to gdb.txt.
Logs will be appended to the log file.
Output will be logged and displayed.
Debug output will be logged and displayed.
+set logging on
+show logging
Currently logging to "gdb.txt".
Logs will be appended to the log file.
Output will be logged and displayed.
Debug output will be logged and displayed.
...
After that commit we have instead:
...
+set logging off
+show logging
debugredirect: The logging output mode is off.
file: The current logfile is "gdb.txt".
overwrite: Whether logging overwrites or appends to the log file is off.
redirect: The logging output mode is off.
+set logging on
+show logging
debugredirect: The logging output mode is off.
file: The current logfile is "gdb.txt".
overwrite: Whether logging overwrites or appends to the log file is off.
redirect: The logging output mode is off.
...
which gives less clear output for some subcommands.
OTOH, it's explicit about whether boolean values are on or off.
The new text seems to have been chosen to match the set/show help texts:
...
(gdb) help show logging
Show logging options.
List of show logging subcommands:
show logging debugredirect -- Show the logging debug output mode.
show logging file -- Show the current logfile.
show logging overwrite -- \
Show whether logging overwrites or appends to the log file.
show logging redirect -- Show the logging output mode.
...
Make the show logging messages more clear, while still keep the boolean
values explicit, such that we have:
...
$ ./gdb.sh -q -batch -ex "show logging"
logging debugredirect: off: \
Debug output will go to both the screen and the log file.
logging enabled: off: Logging is disabled.
logging file: The current logfile is "gdb.txt".
logging overwrite: off: Logging appends to the log file.
logging redirect: off: Output will go to both the screen and the log file.
...
Tested on x86_64-linux.
Tom Tromey [Mon, 3 Jan 2022 18:04:01 +0000 (11:04 -0700)]
Fix use of 'printf' in gdbtypes.c
An earlier patch of mine, commit
64b7cc50 ("Remove
gdb_print_host_address") inadvertently changed a function in
gdbtypes.c to use printf rather than printf_filtered. This patch
fixes the problem.
Tom Tromey [Mon, 3 Jan 2022 16:03:55 +0000 (09:03 -0700)]
Fix regression in page-logging.exp
Simon and Tom pointed out that page-logging.exp failed on their
machines. Tom tracked this down to the "width" setting. Since
there's no need in the test to change the width, it seems simplest to
remove the setting. I confirmed that the test still fails if the fix
is backed out, ensuring that the test is still testing what it
purports to.
Tom Tromey [Mon, 3 Jan 2022 14:55:20 +0000 (07:55 -0700)]
Small indentation fix in eval.c
I noticed that the AdaCore tree had a small divergence in eval.c -- it
had a fix for an indentation problem in binop_promote. I'm checking
in this small fix as obvious.
Tom de Vries [Mon, 3 Jan 2022 14:36:36 +0000 (15:36 +0100)]
[gdb/testsuite] Handle for loop initial decl with gcc 4.8.5
When running test-case gdb.threads/schedlock-thread-exit.exp on a system with
system compiler gcc 4.8.5, I run into:
...
src/gdb/testsuite/gdb.threads/schedlock-thread-exit.c:33:3: error: \
'for' loop initial declarations are only allowed in C99 mode
...
Fix this by:
- using -std=c99, or
- using -std=gnu99, in case that's required, or
- in the case of the jit test-cases, rewriting the for loops.
Tested on x86_64-linux, both with gcc 4.8.5 and gcc 7.5.0.
GDB Administrator [Mon, 3 Jan 2022 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Sun, 2 Jan 2022 19:16:37 +0000 (12:16 -0700)]
Update copying.awk for _initialize declaration patch
Commit
6c265988 ("gdb: add back declarations for _initialize
functions") modified copying.c, but not copying.awk. This patch
updates copying.awk to backport the appropriate fix. This way, if
copying.awk is run again, it will create the correct output.
I'm checking this in as obvious.
Tom Tromey [Sun, 2 Jan 2022 17:40:35 +0000 (10:40 -0700)]
Use filtered output in print_i387_ext
print_i387_ext mostly uses filtered output, but one call in the middle
of the function uses the _unfiltered form. This patch fixes this
call. I'm checking this in as obvious.
Alan Modra [Sat, 1 Jan 2022 22:30:17 +0000 (09:00 +1030)]
Update year range in copyright notice of binutils files
The result of running etc/update-copyright.py --this-year, fixing all
the files whose mode is changed by the script, plus a build with
--enable-maintainer-mode --enable-cgen-maint=yes, then checking
out */po/*.pot which we don't update frequently.
The copy of cgen was with commit
d1dd5fcc38ead reverted as that commit
breaks building of bfp opcodes files.
GDB Administrator [Sun, 2 Jan 2022 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Sat, 1 Jan 2022 18:48:25 +0000 (13:48 -0500)]
gdb: copyright: fix a few comment typos
Mike Frysinger [Mon, 6 Dec 2021 07:39:42 +0000 (02:39 -0500)]
sim: ppc: drop natural types
These are almost entirely unused. For the very few places using them,
replace with explicit signed types. This matches what was done in the
common sim code.
Mike Frysinger [Sat, 13 Aug 2016 07:25:06 +0000 (15:25 +0800)]
sim: mips: clean up bad style/whitespace
This doesn't fix all the problems, but grabs a bunch of the more
obvious ones.
Mike Frysinger [Sat, 1 Jan 2022 18:13:18 +0000 (13:13 -0500)]
sim: tweak copyright lines for gnulib update-copyright
The regex it uses does not like so many leading spaces which causes
it to think the files lack copyright. Trim them down so the script
can find & update them accordingly.
Mike Frysinger [Sat, 1 Jan 2022 18:03:51 +0000 (13:03 -0500)]
gdb: update sim mips testsuite copyright exemption
The sim testsuite was reorganized last year, so update the path.
Mike Frysinger [Sat, 4 Dec 2021 05:28:14 +0000 (00:28 -0500)]
unify 64-bit bfd checks
Move the 64-bit bfd logic out of bfd/configure.ac and into bfd64.m4
under config so it can be shared between all the other subdirs.
This replaces want64 with enable_64_bit_bfd which was already being
declared, but not used directly.
Joel Brobecker [Sat, 1 Jan 2022 15:09:20 +0000 (19:09 +0400)]
Update Copyright year in gdb/testsuite/gdb.arch/powerpc-power10.exp
This commit updates the copyright year range in the script
gdb/testsuite/gdb.arch/powerpc-power10.exp. The update was
performed by running gdb/copyright.py again, to make sure
that the copyright year range will be automatically updated
in years forward.
Joel Brobecker [Sat, 1 Jan 2022 15:07:32 +0000 (19:07 +0400)]
Fix copyright header in gdb/testsuite/gdb.arch/powerpc-power10.exp
The copyright year and holder line is slight malformed, missing
a space after a comma, and this is sufficient for gdb's
copyright.py script to miss this file during its automated
copyright year update.
This commit fixes this.
Joel Brobecker [Sat, 1 Jan 2022 15:03:38 +0000 (19:03 +0400)]
gdb/copyright.py: Add update-netbsd.sh to MULTIPLE_COPYRIGHT_HEADERS
Add gdb/syscalls/update-netbsd.sh to the reminder printed
at the end of the execution listing all the files where
a manual update of the copyright header is needed. This
scripts contains some inline code which includes a copyright
header.
Joel Brobecker [Sat, 1 Jan 2022 15:01:48 +0000 (19:01 +0400)]
Manual copyright year update of various GDB files
This commit updates the copyright year in some files where
we have a copyright year outside of the copyright year,
and thus are not included in gdb's copyright.py script.
Joel Brobecker [Sat, 1 Jan 2022 14:56:03 +0000 (18:56 +0400)]
Copyright Year update after running gdb/copyright.py
This commit brings all the changes made by running gdb/copyright.py
as per GDB's Start of New Year Procedure.
For the avoidance of doubt, all changes in this commits were
performed by the script.
Joel Brobecker [Sat, 1 Jan 2022 14:52:31 +0000 (18:52 +0400)]
Update Copyright Year in gdb, gdbserver and gdbreplay version output
This commit changes the copyright year printed by gdb, gdbserver
and gdbreplay when printing the tool's version.
Alan Modra [Sat, 1 Jan 2022 03:23:32 +0000 (13:53 +1030)]
ubsan: next_char_of_string signed integer overflow
Squash another totally useless fuzz report that I should have ignored.
* read.c (next_char_of_string): Avoid integer overflow.
Alan Modra [Sat, 1 Jan 2022 03:23:06 +0000 (13:53 +1030)]
ubsan: bfd_mach_o_build_commands shift exponent 64 is too large
* mach-o.c (bfd_mach_o_read_section_32): Limit alignment further.
(bfd_mach_o_read_section_64): Likewise.
Alan Modra [Sat, 1 Jan 2022 03:22:53 +0000 (13:52 +1030)]
ubsan: signed integer multiply overflow
9223371018427387904 * 2 cannot be represented in type 'long', yes, but
we don't care.
* expr.c (expr): Avoid signed overflow.
Alan Modra [Sat, 1 Jan 2022 03:22:38 +0000 (13:52 +1030)]
asan: Null-dereference in _bfd_xcoff_copy_private_bfd_data
sec->output_section will be NULL when objcopy removes sections.
* coff-rs6000.c (_bfd_xcoff_copy_private_bfd_data): Protect against
objcopy removing sections.
Alan Modra [Sat, 1 Jan 2022 03:22:26 +0000 (13:52 +1030)]
ubsan: integer overflow in section filepos subtraction
* elf.c (assign_file_positions_for_non_load_sections): Avoid
signed integer overflow.
Alan Modra [Sat, 1 Jan 2022 03:20:37 +0000 (13:50 +1030)]
Remove unnecessary ELF_MINPAGESIZE defines
The idea of this patch is to make it easy to see which targets (just
sparc) have ELF_MINPAGESIZE != ELF_COMMONPAGESIZE.
* elf32-arm.c (ELF_MINPAGESIZE): Don't define.
* elf32-metag.c: Likewise.
* elfnn-aarch64.c: Likewise.
* elf64-x86-64.c: Likewise. Also don't redefine a bunch of other
macros for l1om elf64-target.h use that are unchanged from default.
H.J. Lu [Sat, 1 Jan 2022 03:42:44 +0000 (19:42 -0800)]
ld-x86-64: Pass options to linker with "-Wl,"
* testsuite/ld-x86-64/x86-64.exp: Pass options to linker with
"-Wl,".
GDB Administrator [Sat, 1 Jan 2022 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Fri, 31 Dec 2021 20:28:26 +0000 (13:28 -0700)]
Do not call reinitialize_more_filter from avr_io_reg_read_command
avr_io_reg_read_command is an ordinary gdb command, and so should not
be calling reinitialize_more_filter. This patch removes it. I'm
checking this in as obvious. Tested by rebuilding.
H.J. Lu [Fri, 31 Dec 2021 15:16:32 +0000 (07:16 -0800)]
x86: Define check_relocs_failed in elfxx-x86.h
* elf32-i386.c (check_relocs_failed): Moved to ...
* elfxx-x86.h (check_relocs_failed): Here. New.
* elf64-x86-64.c (check_relocs_failed): Removed.
H.J. Lu [Fri, 31 Dec 2021 14:49:19 +0000 (06:49 -0800)]
Define X86_PCREL_TYPE_P/X86_SIZE_TYPE_P in elfxx-x86.h
* elf32-i386.c: Don't include "elf/i386.h".
(X86_PCREL_TYPE_P): Removed.
(X86_SIZE_TYPE_P): Likewise.
(elf_i386_check_relocs): Pass false to NEED_DYNAMIC_RELOCATION_P.
(elf_i386_relocate_section): Pass false to
GENERATE_DYNAMIC_RELOCATION_P and COPY_INPUT_RELOC_P.
* elf64-x86-64.c: Don't include "elf/x86-64.h".
(X86_PCREL_TYPE_P): Removed.
(X86_SIZE_TYPE_P): Likewise.
(elf_x86_64_check_relocs): Pass true to NEED_DYNAMIC_RELOCATION_P
and X86_PCREL_TYPE_P.
(elf_x86_64_relocate_section): Pass true to X86_PCREL_TYPE_P,
X86_SIZE_TYPE_P, GENERATE_DYNAMIC_RELOCATION_P and
COPY_INPUT_RELOC_P.
* elfxx-x86.c: Don't include "elf/i386.h" nor "elf/x86-64.h".
* elfxx-x86.h (X86_64_PCREL_TYPE_P): New.
(I386_PCREL_TYPE_P): Likewise.
(X86_PCREL_TYPE_P): Likewise.
(X86_64_SIZE_TYPE_P): Likewise.
(I386_SIZE_TYPE_P): Likewise.
(X86_SIZE_TYPE_P): Likewise.
(NEED_DYNAMIC_RELOCATION_P): Add IS_X86_64 and pass it to
X86_PCREL_TYPE_P.
(COPY_INPUT_RELOC_P): Likewise.
(GENERATE_DYNAMIC_RELOCATION_P): Add IS_X86_64, pass it to
X86_PCREL_TYPE_P and X86_SIZE_TYPE_P.
Tamar Christina [Fri, 31 Dec 2021 11:42:07 +0000 (11:42 +0000)]
ld: fix coff PE SEH
COFF_WITH_pex64 and COFF_WITH_peAArch64 can't be true at the same time.
That means that two conditionals that control the sorting of the .pdata section
became a falsum.
The testsuite doesn't catch this because the linker does the sorting and to link
you require library support from the unwinder so we can't test from binutils in
isolation.
bfd/ChangeLog:
2021-12-31 Tamar Christina <tamar.christina@arm.com>
PR ld/28682
* peXXigen.c: Fix conditional.
GDB Administrator [Fri, 31 Dec 2021 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Thu, 30 Dec 2021 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Wed, 29 Dec 2021 18:05:51 +0000 (11:05 -0700)]
Use filtered output in show callbacks
"show" command callbacks, like most ordinary gdb commands, should use
filtered output. I found a few that did not, so this patch changes
them to use the filtered form.
Tom Tromey [Tue, 28 Dec 2021 21:10:11 +0000 (14:10 -0700)]
Consistently Use ui_file parameter to show callbacks
I happened to notice that one "show" callback was printing to
gdb_stdout rather than to the passed-in ui_file parameter. I went
through all such callbacks and fixed them to consistently use the
ui_file.
Regression tested on x86-64 Fedora 34.
Tom Tromey [Mon, 27 Dec 2021 06:23:57 +0000 (23:23 -0700)]
Use gdb_stdlog for MI debugging
When MI debugging is enabled, the logging output should be sent to
gdb_stdlog. This is part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
Tom Tromey [Mon, 27 Dec 2021 01:36:36 +0000 (18:36 -0700)]
Use debug_prefixed_printf_cond_nofunc in index-cache
This changes index-cache.c to use debug_prefixed_printf_cond_nofunc.
As a side effect, logs are now written to gdb_stdlog. This is part of
PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
Tom Tromey [Mon, 27 Dec 2021 01:37:58 +0000 (18:37 -0700)]
Send minsym logging to gdb_stdlog
This changes minsyms.c to send logging output to gdb_stdlog. This is
part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
Tom Tromey [Sun, 26 Dec 2021 21:10:05 +0000 (14:10 -0700)]
Use gdb_stdlog for separate debug file logging
This changes the separate debug file logging code (spread across two
files) to use gdb_stdlog for its output. This is part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
Tom Tromey [Sun, 26 Dec 2021 21:03:41 +0000 (14:03 -0700)]
Use debug_prefixed_printf_cond_nofunc in machoread
This changes machoread.c to use debug_prefixed_printf_cond_nofunc. As
a side effect, the logs are now written to gdb_stdlog. This is part
of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
Tom Tromey [Sat, 25 Dec 2021 05:19:10 +0000 (22:19 -0700)]
Use debug_prefixed_printf_cond_nofunc in microblaze.c
This changes microblaze.c to use the standard logging macro. As a
side effect, logs will now go to gdb_stdlog. This is part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
Tom Tromey [Sat, 25 Dec 2021 05:08:18 +0000 (22:08 -0700)]
Send debugging data to gdb_stdlog in mips-linux-nat.c
This changes mips-linux-nat.c to send some logging output to
gdb_stdlog, rather than stdout. This is part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
Tom Tromey [Mon, 27 Dec 2021 04:51:25 +0000 (21:51 -0700)]
Send arch-utils error messages to gdb_stderr
This changes arch-utils.c to send some error messages to gdb_stderr.
This is part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
Tom Tromey [Sun, 26 Dec 2021 20:41:36 +0000 (13:41 -0700)]
Use correct stream for process record output
The process record code often emits unfiltered output. In some cases,
this output ought to go to gdb_stderr (but see below). In other
cases, the output is guarded by a logging variable and so ought to go
to gdb_stdlog. This patch makes these changes.
Note that in many cases, the output to stderr is followed by a
"return -1", which is how process record indicates an error. It seems
to me that calling error here would be preferable, because, in many
cases, that's all the caller does when it sees a -1. However, I
haven't made this change.
This is part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
Tom Tromey [Sat, 25 Dec 2021 05:11:06 +0000 (22:11 -0700)]
Send jit.c errors to gdb_stderr
jit.c writes some error messages to gdb_stdout, but using gdb_stderr
is better. This is part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
Tom Tromey [Mon, 27 Dec 2021 17:53:16 +0000 (10:53 -0700)]
Fix logging redirection bug with pager
I noticed yesterday that if gdb output is redirected to a file, the
pager will still be active. This is irritating, because the output
isn't actually visible -- just the pager prompt. Looking in bugzilla,
I found that this had been filed 17 years ago, as PR cli/8798.
This patch fixes the bug. It changes the pagination code to query the
particular ui-file to see if paging is allowable. The ui-file
implementations are changed so that only the stdout implementation and
a tee (where one sub-file is stdout) can page.
Regression tested on x86-64 Fedora 34.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=8798
Tom Tromey [Wed, 22 Dec 2021 17:30:16 +0000 (10:30 -0700)]
Remove unusual use of core_addr_eq and core_addr_hash
gdbtypes.h uses core_addr_eq and core_addr_hash in a weird way: taking
the address of a member and then passing this (as a void*) to these
functions.
It seems better to simply inline the ordinary code here. CORE_ADDR is
a scalar so it can be directly compared, and the identity hash
function seems safe to assume as well.
After this, core_addr_eq and core_addr_hash are unused, so this patch
removes them.
Lancelot SIX [Mon, 6 Dec 2021 10:23:42 +0000 (05:23 -0500)]
gdb: Copy inferior properties in clone-inferior
This commit ensures that the following settings are cloned from one
inferior to the new one when processing the clone-inferior command:
- inferior-tty
- environment variables
- cwd
- args
Some of those parameters can be passed as command line arguments to GDB
(-args and -tty), so one could expect the clone-inferior to respect
those flags. The following debugging session illustrates that:
gdb -nx -quiet -batch \
-ex "show args" \
-ex "show inferior-tty" \
-ex "clone-inferior" \
-ex "inferior 2" \
-ex "show args" \
-ex "show inferior-tty" \
-tty=/some/tty \
-args echo foo bar
Argument list to give program being debugged when it is started is "foo bar".
Terminal for future runs of program being debugged is "/some/tty".
[New inferior 2]
Added inferior 2.
[Switching to inferior 2 [<null>] (/bin/echo)]
Argument list to give program being debugged when it is started is "".
Terminal for future runs of program being debugged is "".
The other properties this commit copies on clone (i.e. CWD and the
environment variables) are included since they are related (in the sense
that they influence the runtime behavior of the program) even if they
cannot be directly set using command line switches.
There is a chance that this patch changes existing user workflow. I
think that this change is mostly harmless. If users want to start a new
inferior based on an existing one, they probably already propagate those
settings to the new inferior in some way.
Tested on x86_64-linux.
Change-Id: I3b1f28b662f246228b37bb24c2ea1481567b363d
GDB Administrator [Wed, 29 Dec 2021 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Tue, 28 Dec 2021 17:51:50 +0000 (09:51 -0800)]
elf32-i386: Fix a typo in GOT comments
Entry offsets in the global offset table are multiples of 4, not 8.
* elf32-i386.c (elf_i386_relocate_section): Fix a typo in GOT
comments.
H.J. Lu [Fri, 24 Dec 2021 23:42:43 +0000 (15:42 -0800)]
bfd: Don't check non-thin archive member file size
There is no need to check member file size for thin archive member.
* bfdio.c (bfd_bread): Don't check non-thin archive member file
size.
Alan Modra [Mon, 20 Dec 2021 14:39:13 +0000 (01:09 +1030)]
gas reloc sorting
In some cases, eg. riscv_pre_output_hook, gas generates out-of-order
relocations. Various places in the linker assume relocs are sorted
by increasing r_offset, which is normally the case. Provide
GAS_SORT_RELOCS to handle unsorted relocs.
bfd/
PR 28709
* elf32-nds32.c (nds32_insertion_sort): Make static.
* elf32-nds32.h (nds32_insertion_sort): Delete declaration.
gas/
PR 28709
* write.c (write_relocs): Implement reloc sorting by r_offset
when GAS_SORT_RELOCS.
* config/tc-nds32.c (compar_relent, nds32_set_section_relocs): Delete.
* config/tc-nds32.h (nds32_set_section_relocs): Don't declare.
(SET_SECTION_RELOCS): Don't define.
(GAS_SORT_RELOCS): Define.
* config/tc-riscv.h (GAS_SORT_RELOCS): Define.
jiawei [Thu, 23 Dec 2021 06:19:58 +0000 (14:19 +0800)]
ld: Fix testcase errors due to -shared not support.
Reviewed-by: Jim Wilson <jim.wilson.gcc@gmail.com>
ld/ChangeLog:
* testsuite/ld-ctf/ctf.exp: Add shared lib check.
* testsuite/ld-plugin/lto.exp: Add lto shared check.
GDB Administrator [Tue, 28 Dec 2021 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Mon, 27 Dec 2021 21:31:19 +0000 (13:31 -0800)]
elf: Update comments for check_relocs in elf_backend_data
Since
commit
5c3261b0e834647cf9eb555320e20871b7854f98
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Oct 16 03:49:54 2017 -0700
ELF: Call check_relocs after opening all inputs
check_relocs is called after opening all inputs.
* elf-bfd.h (elf_backend_data::check_relocs): Update comments.
H.J. Lu [Mon, 27 Dec 2021 18:06:57 +0000 (10:06 -0800)]
ld: Remove emultempl/linux.em
Remove emultempl/linux.em whose last usage was removed by
commit
c65c21e1ffd1e02d9970a4bca0b7e384788a50f0
Author: Alan Modra <amodra@gmail.com>
Date: Mon Apr 16 22:14:01 2018 +0930
various i386-aout and i386-coff target removal
Also tidies some other aout leftovers in binutils-common.exp.
GDB Administrator [Mon, 27 Dec 2021 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 26 Dec 2021 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sat, 25 Dec 2021 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Wed, 22 Dec 2021 17:28:37 +0000 (10:28 -0700)]
Remove gdb_print_host_address
gdb_print_host_address is just a simple wrapper around
fprintf_filtered. However, it is readily replaced in all callers by a
combination of %s and call to host_address_to_string. This also
simplifies the code, so I think it's worthwhile to remove this
function.
Regression tested on x86-64 Fedora 64.
Tom Tromey [Tue, 21 Dec 2021 23:24:16 +0000 (16:24 -0700)]
Move gdb_bfd_errmsg to gdb_bfd.c
gdb_bfd.c contains most of gdb's BFD-related utility functions.
However, gdb_bfd_errmsg is in utils.c. It seemed better to me to move
this out of util.[ch] and into the BFD-related file instead.
Tested by rebuilding.
Nelson Chu [Fri, 24 Dec 2021 07:10:38 +0000 (15:10 +0800)]
RISC-V: Rewrite the csr testcases.
Maskray (Fangrui Song) had suggested me before that we should combine
multiple testcases into one file as possible as we can. So that we can
more easily understand what these test cases are testing, and easier to
maintain. Therefore, this patch rewrites all csr testcases, to make them
more clean.
gas/
* testsuite/gas/riscv/csr-fail-nonexistent.d: Renamed from
priv-reg-fail-nonexistent testcase.
* testsuite/gas/riscv/csr-fail-nonexistent.: Likewise.
* testsuite/gas/riscv/csr-fail-nonexistent.s: Likewise.
* testsuite/gas/riscv/csr-insns-pseudo-noalias.d: Renamed from
priv-reg-pseudo testcase.
* testsuite/gas/riscv/csr-insns-pseudo.d: Likewise.
* testsuite/gas/riscv/csr-insns-pseudo.s: Likewise.
* testsuite/gas/riscv/csr-insns-read-only.d: Renamed from
priv-reg-fail-read-only-02 testcase.
* testsuite/gas/riscv/csr-insns-read-only.l: Likewise.
* testsuite/gas/riscv/csr-insns-read-only.s: Likewise.
* testsuite/gas/riscv/h-ext-32.d: Moved hypervisor csrs to csr.s.
* testsuite/gas/riscv/h-ext-32.s: Likewise.
* testsuite/gas/riscv/h-ext-64.d: Likewise.
* testsuite/gas/riscv/h-ext-64.s: Likewise.
* testsuite/gas/riscv/csr.s: Renamed from priv-reg.s, and then
added the hypervisor csrs.
* testsuite/gas/riscv/csr-version-1p9p1.d: The csr testcase when
the privileged spec is 1.9.1. Also tested all invalid csr warnings
when -mcsr-check is enabled.
* testsuite/gas/riscv/csr-version-1p9p1.l: Likewise.
* testsuite/gas/riscv/csr-version-1p10.d: Likewise, but the
privileged spec is 1.10..
* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
* testsuite/gas/riscv/csr-version-1p11.d: Likewise, but the
privileged spec is 1.11.
* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
* testsuite/gas/riscv/csr-version-1p12.d: Likewise, but the
privileged spec is 1.12.
* testsuite/gas/riscv/csr-version-1p12.l: Likewise.
* testsuite/gas/riscv/priv-reg*: Removed or Renamed.
Vineet Gupta [Tue, 21 Dec 2021 02:34:13 +0000 (18:34 -0800)]
RISC-V: Hypervisor ext: support Privileged Spec 1.12
This is the Hypervisor Extension 1.0
- Hypervisor Memory-Management Instructions
HFENCE.VVMA, HFENCE.GVMA,
- Hypervisor Virtual Machine Load and Store Instructions
HLV.B, HLV.BU, HSV.B,
HLV.H, HLV.HU, HLVX.HU, HSB.H,
HLV.W, HLV.WU, HLVX.WU, HSV.W,
HLV.D, HSV.D
- Hypervisor CSRs (some new, some address changed)
hstatus, hedeleg, hideleg, hie, hcounteren, hgeie, htval, hip, hvip,
htinst, hgeip, henvcfg, henvcfgh, hgatp, hcontext, htimedelta, htimedeltah,
vsstatus, vsie, vstvec, vsscratch, vsepc, vscause, vstval, vsip, vsatp,
Note that following were added already as part of svinval extension
support:
HINVAL.GVMA, HINVAL.VVMA
Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Reviewed-by: Nelson Chu <nelson.chu@sifive.com>
bfd/
* cpu-riscv.c (riscv_priv_specs): Added entry for 1.12.
* cpu-riscv.h (enum riscv_spec_class): Added PRIV_SPEC_CLASS_1P12.
gas/
* config/tc-riscv.c (abort_version): Updated comment.
(validate_riscv_insn): Annotate switch-break.
* testsuite/gas/riscv/h-ext-32.d: New testcase for hypervisor.
* testsuite/gas/riscv/h-ext-32.s: Likewise.
* testsuite/gas/riscv/h-ext-64.d: Likewise.
* testsuite/gas/riscv/h-ext-64.s: Likewise.
include/
* opcode/riscv-opc.h: Added encodings for hypervisor csrs and
instrcutions.
opcodes/
* riscv-opc.c (riscv_opcodes): Added hypervisor instrcutions.
Vineet Gupta [Tue, 21 Dec 2021 02:34:12 +0000 (18:34 -0800)]
RISC-V: Hypervisor ext: drop Privileged Spec 1.9.1 implementation/tests
This makes way for a clean 1.12 based Hypervisor Ext support.
There are no known implementors of 1.9.1 H-ext. (Per Jim, kendryte k210
is based on priv spec 1.9.1, but it seems unlikely that they implemented
H-ext).
Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Reviewed-by: Nelson Chu <nelson.chu@sifive.com>
gas/
* testsuite/gas/riscv/csr-dw-regnums.d: Drop the hypervisor csrs
defined in the privileged spec 1.9.1.
* testsuite/gas/riscv/csr-dw-regnums.s: Likewise.
* testsuite/gas/riscv/priv-reg-fail-read-only-01.s: Likewise.
* testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise.
* testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise.
* testsuite/gas/riscv/priv-reg-version-1p10.d: Likewise.
* testsuite/gas/riscv/priv-reg-version-1p11.d: Likewise.
* testsuite/gas/riscv/priv-reg-version-1p9p1.d: Likewise.
* testsuite/gas/riscv/priv-reg.s: Likewise.
include/
* opcode/riscv-opc.h: Drop the hypervisor csrs defined in the
privileged spec 1.9.1.
GDB Administrator [Fri, 24 Dec 2021 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Thu, 23 Dec 2021 15:48:47 +0000 (15:48 +0000)]
gdb/testsuite: resolve some duplicate testnames in gdb.mi
Set of fixes to resolve some duplicate test names in the gdb.mi/
directory. There should be no real test changes after this set of
fixes, they are all either:
- Adding with_test_prefix type constructs to make test names unique,
or
- Changing the test name to be more descriptive, or better reflect
the test being run.
Andrew Burgess [Mon, 4 Oct 2021 14:48:11 +0000 (15:48 +0100)]
gdb/remote: handle attach when stop packet lacks thread-id
Bug PR gdb/28405 reports a regression when using attach with an
extended-remote target. In this case the target is not including a
thread-id in the stop packet it sends back after the attach.
The regression was introduced with this commit:
commit
8f66807b98f7634c43149ea62e454ea8f877691d
Date: Wed Jan 13 20:26:58 2021 -0500
gdb: better handling of 'S' packets
The problem is that when GDB processes the stop packet, it sees that
there is no thread-id and so has to "guess" which thread the stop
should apply to.
In this case the target only has one thread, so really, there's no
guessing needed, but GDB still runs through the same process, this
shouldn't cause us any problems.
However, after the above commit, GDB now expects itself to be more
internally consistent, specifically, only a thread that GDB thinks is
resumed, can be a candidate for having stopped.
It turns out that, when GDB attaches to a process through an
extended-remote target, the threads of the process being attached too,
are not, initially, marked as resumed.
And so, when GDB tries to figure out which thread the stop might apply
too, it finds no threads in the processes marked resumed, and so an
assert triggers.
In extended_remote_target::attach we create a new thread with a call
to add_thread_silent, rather than remote_target::remote_add_thread,
the reason is that calling the latter will result in a call to
'add_thread' rather than 'add_thread_silent'. However,
remote_target::remote_add_thread includes additional
actions (i.e. calling remote_thread_info::set_resumed and set_running)
which are missing from extended_remote_target::attach. These missing
calls are what would serve to mark the new thread as resumed.
In this commit I propose that we add an extra parameter to
remote_target::remote_add_thread. This new parameter will force the
new thread to be added with a call to add_thread_silent. We can now
call remote_add_thread from the ::attach method, the extra
actions (listed above) will now be performed, and the thread will be
left in the correct state.
Additionally, in PR gdb/28405, a segfault is reported. This segfault
triggers when 'set debug remote 1' is used before trying to reproduce
the original assertion failure. The cause of this is in
remote_target::select_thread_for_ambiguous_stop_reply, where we do
this:
remote_debug_printf ("first resumed thread is %s",
pid_to_str (first_resumed_thread->ptid).c_str ());
remote_debug_printf ("is this guess ambiguous? = %d", ambiguous);
gdb_assert (first_resumed_thread != nullptr);
Notice that when debug printing is on we dereference
first_resumed_thread before we assert that the pointer is not
nullptr. This is the cause of the segfault, and is resolved by moving
the assert before the debug printing code.
I've extended an existing test, ext-attach.exp, so that the original
test is run multiple times; we run in the original mode, as normal,
but also, we now run with different packets disabled in gdbserver. In
particular, disabling Tthread would trigger the assertion as it was
reported in the original bug. I also run the test in all-stop and
non-stop modes now for extra coverage, we also run the tests with
target-async enabled, and disabled.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28405
Andrew Burgess [Mon, 13 Dec 2021 16:56:16 +0000 (16:56 +0000)]
gdb: on x86-64 non-trivial C++ objects are returned in memory
Fixes PR gdb/28681. It was observed that after using the `finish`
command an incorrect value was displayed in some cases. Specifically,
this behaviour was observed on an x86-64 target.
Consider this test program:
struct A
{
int i;
A ()
{ this->i = 0; }
A (const A& a)
{ this->i = a.i; }
};
A
func (int i)
{
A a;
a.i = i;
return a;
}
int
main ()
{
A a = func (3);
return a.i;
}
And this GDB session:
$ gdb -q ex.x
Reading symbols from ex.x...
(gdb) b func
Breakpoint 1 at 0x401115: file ex.cc, line 14.
(gdb) r
Starting program: /home/andrew/tmp/ex.x
Breakpoint 1, func (i=3) at ex.cc:14
14 A a;
(gdb) finish
Run till exit from #0 func (i=3) at ex.cc:14
main () at ex.cc:23
23 return a.i;
Value returned is $1 = {
i = -19044
}
(gdb) p a
$2 = {
i = 3
}
(gdb)
Notice how after the `finish` the contents of $1 are junk, but, when I
immediately ask for the value of `a`, I get back the correct value.
The problem here is that after the finish command GDB calls the
function amd64_return_value to figure out where the return value can
be found (on x86-64 targets anyway).
This function makes the wrong choice for the struct A in our case, as
sizeof(A) <= 8, then amd64_return_value decides that A will be
returned in a register. GDB then reads the return value register an
interprets the contents as an instance of A.
Unfortunately, A is not trivially copyable (due to its copy
constructor), and the sys-v specification for argument and return
value passing, says that any non-trivial C++ object should have space
allocated for it by the caller, and the address of this space is
passed to the callee as a hidden first argument. The callee should
then return the address of this space as the return value.
And so, the register that GDB is treating as containing an instance of
A, actually contains the address of an instance of A (in this case on
the stack), this is why GDB shows the incorrect result.
The call stack within GDB for where we actually go wrong is this:
amd64_return_value
amd64_classify
amd64_classify_aggregate
And it is in amd64_classify_aggregate that we should be classifying
the type as AMD64_MEMORY, instead of as AMD64_INTEGER as we currently
do (via a call to amd64_classify_aggregate_field).
At the top of amd64_classify_aggregate we already have this logic:
if (TYPE_LENGTH (type) > 16 || amd64_has_unaligned_fields (type))
{
theclass[0] = theclass[1] = AMD64_MEMORY;
return;
}
Which handles some easy cases where we know a struct will be placed
into memory, that is (a) the struct is more than 16-bytes in size,
or (b) the struct has any unaligned fields.
All we need then, is to add a check here to see if the struct is
trivially copyable. If it is not then we know the struct will be
passed in memory.
I originally structured the code like this:
if (TYPE_LENGTH (type) > 16
|| amd64_has_unaligned_fields (type)
|| !language_pass_by_reference (type).trivially_copyable)
{
theclass[0] = theclass[1] = AMD64_MEMORY;
return;
}
This solved the example from the bug, and my small example above. So
then I started adding some more extensive tests to the GDB testsuite,
and I ran into a problem. I hit this error:
gdbtypes.h:676: internal-error: loc_bitpos: Assertion `m_loc_kind == FIELD_LOC_KIND_BITPOS' failed.
This problem is triggered from:
amd64_classify_aggregate
amd64_has_unaligned_fields
field::loc_bitpos
Inside the unaligned field check we try to get the bit position of
each field. Unfortunately, in some cases the field location is not
FIELD_LOC_KIND_BITPOS, but is FIELD_LOC_KIND_DWARF_BLOCK.
An example that shows this bug is:
struct B
{
short j;
};
struct A : virtual public B
{
short i;
A ()
{ this->i = 0; }
A (const A& a)
{ this->i = a.i; }
};
A
func (int i)
{
A a;
a.i = i;
return a;
}
int
main ()
{
A a = func (3);
return a.i;
}
It is the virtual base class, B, that causes the problem. The base
class is represented, within GDB, as a field within A. However, the
location type for this field is a DWARF_BLOCK.
I spent a little time trying to figure out how to convert the
DWARF_BLOCK to a BITPOS, however, I realised that, in this case at
least, conversion is not needed.
The C++ standard says that a class is not trivially copyable if it has
any virtual base classes. And so, in this case, even if I could
figure out the BITPOS for the virtual base class fields, I know for
sure that I would immediately fail the trivially_copyable check. So,
lets just reorder the checks in amd64_classify_aggregate to:
if (TYPE_LENGTH (type) > 16
|| !language_pass_by_reference (type).trivially_copyable
|| amd64_has_unaligned_fields (type))
{
theclass[0] = theclass[1] = AMD64_MEMORY;
return;
}
Now, if we have a class with virtual bases we will fail quicker, and
avoid the unaligned fields check completely.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28681
Andrew Burgess [Thu, 11 Nov 2021 15:17:27 +0000 (15:17 +0000)]
gdb: make use of SCOPE_EXIT to manage thread executing state
While working on another patch relating to how GDB manages threads
executing and resumed state, I spotted the following code in
record-btrace.c:
executing = tp->executing ();
set_executing (proc_target, inferior_ptid, false);
id = null_frame_id;
try
{
id = get_frame_id (get_current_frame ());
}
catch (const gdb_exception &except)
{
/* Restore the previous execution state. */
set_executing (proc_target, inferior_ptid, executing);
throw;
}
/* Restore the previous execution state. */
set_executing (proc_target, inferior_ptid, executing);
return id;
I notice that we only catch the exception so we can call
set_executing, and this is the same call to set_executing that we need
to perform in the non-exception return path.
This would be much cleaner if we could use SCOPE_EXIT to avoid the
try/catch, so lets do that.
While cleaning this up, I also applied a similar patch to
record-full.c, though there's no try/catch in that case, but using
SCOPE_EXIT makes the code safe if, in the future, we do start throwing
exceptions.
There should be no user visible changes after this commit.
GDB Administrator [Thu, 23 Dec 2021 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Tue, 7 Dec 2021 10:43:38 +0000 (10:43 +0000)]
gdb/doc: add some index entries relating to mi-async setting
I noticed that the mi-async setting was not referenced from the index
in any way, this commit tries to rectify that a bit.
The @cindex lines I think are not controversial, these same index
entries are used elsewhere in the manual for async related topics (see
@node Background Execution).
The only bit that might be controversial is that I've added a @kindex
entry for 'set mi-async' when the command is documented as '-gdb-set
mi-async' (with a similar difference for the show/-gdb-show).
My reasoning here is that nothing else is indexed under -gdb-set or
-gdb-show, and as -gdb-set/-gdb-show are just the MI equivalent for
set/show anything that is documented under set/show can be adjusted
using -gdb-set/-gdbshow, and so, I've tried to keep the index
consistent for mi-async.
Andrew Burgess [Sat, 11 Dec 2021 10:35:36 +0000 (10:35 +0000)]
gdb: convert 'set debug lin-lwp' to a boolean command
Convert the 'set debug lin-lwp' command to a boolean. Adds a new
LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT macro, and makes use of it in one
place (linux_nat_target::stop).
The manual entry for 'set debug lin-lwp' is already vague about
exactly what arguments this command takes, and the description talks
about turning debug on and off, so I don't think there's any updates
required there.
I have updated the doc strings shown when the users enters 'help show
debug lin-lwp' or 'help show debug lin-lwp'. The old title lines used
to talk about the 'GNU/Linux lwp module', but this debug flag is now
used for any native linux target debug, so we now talk about
'GNU/Linux native target'. The body string for this setting has been
changed from 'Enables printf debugging output.' to 'When on, print
debug messages relating to the GNU/Linux native target.', the old
value looks like a cut&paste error to me.
Andrew Burgess [Fri, 12 Nov 2021 10:30:27 +0000 (10:30 +0000)]
gdb: add threads debugging switch
Add new commands:
set debug threads on|off
show debug threads
Prints additional debug information relating to thread creation and
deletion.
GDB already announces when threads are created of course.... most of
the time, but sometimes threads are added silently, in which case this
debug message is the only mechanism to see the thread being added.
Also, though GDB does announce when a thread exits, it doesn't
announce when the thread object is deleted, I've added a debug message
for that.
Additionally, having message printed through the debug system will
cause the messages to be nested to an appropriate depth when other
debug sub-systems are turned on (especially things like `infrun` and
`lin-lwp`).
jiawei [Wed, 22 Dec 2021 09:23:02 +0000 (17:23 +0800)]
RISC-V: Update Scalar Crypto testcases.
Add opcodes in testcases to make sure every instruction generate
right opcode after disassemble.
gas/ChangeLog:
* testsuite/gas/riscv/k-ext-64.d: Add opcode detect.
* testsuite/gas/riscv/k-ext.d: Ditto.
* testsuite/gas/riscv/zbkb-32.d: Ditto.
* testsuite/gas/riscv/zbkb-64.d: Ditto.
* testsuite/gas/riscv/zbkc-32.d: Ditto.
* testsuite/gas/riscv/zbkc-64.d: Ditto.
* testsuite/gas/riscv/zbkx-32.d: Ditto.
* testsuite/gas/riscv/zbkx-64.d: Ditto.
* testsuite/gas/riscv/zknd-32.d: Ditto.
* testsuite/gas/riscv/zknd-64.d: Ditto.
* testsuite/gas/riscv/zkne-32.d: Ditto.
* testsuite/gas/riscv/zkne-64.d: Ditto.
* testsuite/gas/riscv/zknh-32.d: Ditto.
* testsuite/gas/riscv/zknh-64.d: Ditto.
* testsuite/gas/riscv/zksed-32.d: Ditto.
* testsuite/gas/riscv/zksed-64.d: Ditto.
* testsuite/gas/riscv/zksh-32.d: Ditto.
* testsuite/gas/riscv/zksh-64.d: Ditto.
Simon Marchi [Tue, 21 Dec 2021 03:30:37 +0000 (22:30 -0500)]
gdbarch-components.py: change empty "params" tuples to empty lists
During review, it was suggested to change the "params" parameter from a
tuple to a list, for esthetic reasons. The empty ones are still tuples
though, they should probably be changed to be empty lists, for
consistency. It does not change anything in the script result.
Change-Id: If13c6c527aa167a5ee5b45740e5f1bda1e9517e4
GDB Administrator [Wed, 22 Dec 2021 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in
Luis Machado [Tue, 21 Dec 2021 18:05:52 +0000 (15:05 -0300)]
[AArch64] Fix typo in error messages
Fix mispelling of PROT_ME to PROT_MTE in the error messages.
Joel Sherrill [Mon, 20 Dec 2021 15:39:14 +0000 (09:39 -0600)]
Obsolete m32c-rtems and m32r-rtems
2020-12-20 Joel Sherrill <joel@rtems.org>
bfd/
* config.bfd (m32c-*-rtems*): Remove target.
ld/
* configure.tgt (m32c-*-rtems*): Remove target.
* configure.tgt (m32r-*-rtems*): Remove target.
Jan Beulich [Tue, 21 Dec 2021 08:31:04 +0000 (09:31 +0100)]
x86: -mfence-as-lock-add=yes doesn't work for 16-bit mode
Rather than trying to fix this (which would require making an assumption
on the upper half of %esp being zero), simply issue an error. While at
it, since the generated code is in conflict with -momit-lock-prefix=yes,
issue an error in that case as well.
Jan Beulich [Tue, 21 Dec 2021 08:30:03 +0000 (09:30 +0100)]
gas/ELF: avoid below-base ref in obj_elf_parse_section_letters()
We would better be prepared for 'm' being the first character of the
incoming string.
Alan Modra [Tue, 21 Dec 2021 06:27:28 +0000 (16:57 +1030)]
Typo fixes in binutils doc
* doc/binutils.texi: Fix typos.