Bruno Larsen [Tue, 21 Feb 2023 16:10:31 +0000 (17:10 +0100)]
gdb/testsuite: Improve testing of GDB's completion functions
When looking at some failures of gdb.linespec/cp-completion-aliases.exp,
I noticed that when a completion test will fail, it always fails with a
timeout. This is because most completion tests use gdb_test_multiple
and only add a check for the correct output. This commit adds new
options for both, tab and command completion.
For command completion, the new option will check if the prompt was
printed, and fail in this case. This is enough to know that the test has
failed because the check comes after the PASS path. For tab completion,
we have to check if GDB outputted more than just the input line, because
sometimes GDB would have printed a partial line before finishing with
the correct completion.
Tom Tromey [Fri, 16 Dec 2022 19:50:29 +0000 (12:50 -0700)]
Remove struct buffer
I've long wanted to remove 'struct buffer', and thanks to Simon's
earlier patch, I was finally able to do so. My feeling has been that
gdb already has several decent structures available for growing
strings: std::string of course, but also obstack and even objalloc
from BFD and dyn-string from libiberty. The previous patches in this
series removed all the uses of struct buffer, so this one can remove
the code and the remaining #includes.
Tom Tromey [Fri, 16 Dec 2022 19:53:20 +0000 (12:53 -0700)]
Don't use struct buffer in top.c
This changes top.c to use std::string rather than struct buffer. Like
the event-top.c change, this is not completely ideal in that it
requires a copy of the string.
Tom Tromey [Fri, 16 Dec 2022 19:45:40 +0000 (12:45 -0700)]
Don't use struct buffer in event-top.c
This changes event-top.c to use std::string rather than struct buffer.
This isn't completely ideal, in that it requires a copy of the string
to be made.
Tom Tromey [Wed, 13 Apr 2022 17:25:53 +0000 (11:25 -0600)]
Write the DWARF index in the background
The new DWARF cooked indexer interacts poorly with the DWARF index
cache. In particular, the cache will require gdb to wait for the
cooked index to be finalized. As this happens in the foreground, it
means that users with this setting enabled will see a slowdown.
This patch changes gdb to write the cache entry a worker thread. (As
usual, in the absence of threads, this work is simply done immediately
in the main thread.)
Some care is taken to ensure that this can't crash, and that gdb will
not exit before the task is complete.
To avoid use-after-free problems, the DWARF per-BFD object explicitly
waits for the index cache task to complete.
To avoid gdb exiting early, an exit observer is used to wait for all
such pending tasks.
In normal use, neither of these waits will be very visible. For users
using "-batch" to pre-generate the index, though, it would be.
However I don't think there is much to be done about this, as it was
the status quo ante.
Tom Tromey [Wed, 13 Apr 2022 17:21:20 +0000 (11:21 -0600)]
Only use the per-BFD object to write a DWARF index
The DWARF index does not need access to the objfile or per-objfile
objects when writing -- it's entirely based on the objfile-independent
per-BFD data.
This patch implements this idea by changing the entire API to only be
passed the per-BFD object. This simplifies some lifetime reasoning
for the next patch.
This patch removes some code that ensures that the BFD came from a
file. It seems to me that checking for the existence of a build-id is
good enough for the index cache.
Clément Chigot [Tue, 21 Feb 2023 14:07:58 +0000 (15:07 +0100)]
testsuite: prune DOS drive letter in test outputs
On DOS systems, absolute paths start with the drive letter. This can
trigger failures in the regexp from dump tests, especially for those
checking for warnings or errors. They are usually skipping everything
before the first ":" as it has to be the file path.
| [^:]*: warning: ...
In order to avoid modifying many regexps to allow such drive letters,
prune them from all the outputs if they are found at the beginning of
a line.
binutils/ChangeLog:
* testsuite/lib/binutils-common.exp (prune_dump_output): New
(run_dump_test): Use it.
ld/ChangeLog:
* testsuite/ld-elf/noinit-sections-2.l: Remove DOS drive letter
handler.
Jan Beulich [Fri, 24 Feb 2023 13:00:11 +0000 (14:00 +0100)]
x86: allow to request ModR/M encoding
Several insns have a (typically shorter) non-ModR/M and a (typically
longer) ModR/M encoding. In most cases the former is used by default.
This isn't too dissimilar from register-only insns sometimes having two
encoding forms. In those cases {load} or {store} can be used to control
the encoding used. Extend this to ModR/M-less encodings which have a
ModR/M counterpart (note that BSWAP hasn't). For insn reading and
writing their (explicit) memory operand, both prefixes are honored;
otherwise only the applicable one is.
Note that for some forms of XCHG, {store} has already been performing
this function, apparently as an unnoticed side effect of adding D to
the template.
Jan Beulich [Fri, 24 Feb 2023 12:58:35 +0000 (13:58 +0100)]
x86-64: don't permit LAHF/SAHF with "generic64"
The feature isn't universally available on 64-bit CPUs.
Note that in i386-gen.c:isa_dependencies[] I'm only adding it to models
where I'm certain the functionality exists. For Nocona and Core I'm
uncertain in particular.
Jan Beulich [Fri, 24 Feb 2023 12:57:31 +0000 (13:57 +0100)]
x86: have insns acting on segment selector values allow for consistent operands
While MOV to/from segment register as well as selector storing insns
already permit 32- and 64-bit GPR operands, selector loading insns and
ARPL do not. Split templates accordingly.
For shifts (but not ordinary rotates) and other cases where an immediate
describes e.g. a bit count or position, allowing negative operands is at
best confusing. An extreme example would be the two rotate-through-carry
insns, where a negative value would _not_ mean rotating the
corresponding number of bits in the other direction. To refuse such,
give meaning to the combination of Imm8 and Imm8S in templates (so far
these weren't used together anywhere). The issue was with
smallest_imm_type() blindly setting .imm8 for signed numbers determined
to fit in a byte.
VPROT{B,W,D,Q} is a little special: The rotate count there is a signed
quantity, so Imm8 is replaced by Imm8S. Adjust affected testcases
accordingly as well.
Another small adjustment to the testsuite is necessary: AAM and AAD were
never sensible to use with 0xffffff90 operands. This should have been an
error.
Tom de Vries [Fri, 24 Feb 2023 12:52:12 +0000 (13:52 +0100)]
[gdb/testsuite] Cleanup unnecessary expr from require line
In a recent commit I've added:
...
require {expr [have_compile_flag -fsplit-stack]}
...
but actually the expr bit is unnecessary, and we can just use:
...
require {have_compile_flag -fsplit-stack}
...
GDB: Fix out of bounds accesses with limited-length values
Fix accesses to limited-length values in `contents_copy_raw' and
`contents_copy_raw_bitwise' so that they observe the limit of the
original allocation.
Reported by Simon Marchi as a heap-buffer-overflow AddressSanitizer
issue triggered with gdb.ada/limited-length.exp.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Alan Modra [Thu, 23 Feb 2023 07:53:12 +0000 (18:23 +1030)]
PR30155, ld segfault in _bfd_nearby_section
The segfault was a symptom of messing with the absolute section next
field, confusing bfd_section_removed_from_list in linker.c:fix_syms.
That's not all that was going wrong. The INSERT list of output
sections was being inserted into itself, ie. lost from the main
list of linker statements.
PR 30155
* ldlang.c (process_insert_statements): Handle pathological
case of the insert script being inserted before the first
output section statement in the default script.
(output_prev_sec_find): Don't test section owner here.
(insert_os_after): Change parameter to a list union pointer.
(lang_insert_orphan): Test section owner here and adjust
insert_os_after call.
Palmer Dabbelt [Thu, 26 Jan 2023 23:09:29 +0000 (15:09 -0800)]
gdb/doc: The RISC-V vector registers didn't change
When we merged the GDB vector register support we did it a bit early,
just eating the risk in the very unlikely case that the vector register
names changed. They didn't, so we can now remove the caveat in the docs
that they might.
Simon Marchi [Tue, 14 Feb 2023 16:13:43 +0000 (11:13 -0500)]
gdb: remove --disable-gdbmi configure option
I noticed that the --disable-gdbmi option was broken for almost a year
(since 740b42ceb7c "gdb/python/mi: create MI commands using python").
The problem today is the python/py-cmd.c file. It is included in the
build if Python support is enabled, and it calls into some MI functions
(e.g. insert_mi_cmd_entry). If MI support is disabled, we get some
undefined symbols like:
The python/py-cmd.c file should be included in the build if both Python
and MI support are enabled. It is not a case we support today, but it
could be done with a bit more configure code. However, I think we
should just remove the --disable-gdbmi option, and just include MI
support unconditionally.
Tom Tromey proposed a while ago to remove this option, but it ended
staying:
However, there was no strong opposition to remove it. The argument was
just "bah, it doesn't hurt anybody".
But given today's case, I would rather remove complexity rather than add
some. I couldn't find anybody caring deeply for that option, and it's
not like MI adds any external dependency. It's just a bit more code.
Removing the option will not break anybody using --disable-gdbmi (it can
be found in many build scripts [1]), since we don't flag invalid
configure flags.
So, remove the option from configure.ac, and adjust Makefile.in
accordingly to always include the MI objects in the build.
Simon Marchi [Thu, 23 Feb 2023 16:27:23 +0000 (11:27 -0500)]
gdb: add AMDGPU header files to HFILES_NO_SRCDIR
Commit 18b4d0736bc5 ("gdb: initial support for ROCm platform (AMDGPU)
debugging") missed adding these header files to the HFILES_NO_SRCDIR
list in the Makefile. Fix that now.
Hui Li [Thu, 16 Feb 2023 00:59:10 +0000 (08:59 +0800)]
gdb: LoongArch: Modify the result of the info reg command
The "info register" command should only display general registers,
but it shows the information of all registers in the current code,
add loongarch_register_reggroup_p() so that we can get the expected
result.
Signed-off-by: Hui Li <lihui@loongson.cn> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Nick Clifton [Thu, 23 Feb 2023 09:44:50 +0000 (09:44 +0000)]
Fix the BFD library's find_nearest_line feature to produce consistent results.
PR 30150
* dwarf2.c (comp_unit_contains_address): Renamed to ... (comp_unit_may_contain_address): this,
and added code to return true if the CU's ranges have not yet been computed.
(_bfd_dwarf2_find_nearest_line_with_alt): Use the renamed function, simplifying code in the process.
Alan Modra [Tue, 21 Feb 2023 21:17:36 +0000 (07:47 +1030)]
Test SEC_HAS_CONTENTS before reading section contents
bfd_malloc_and_get_section does size sanity checking before allocating
memory and reading contents. These size checks are not done for bss
style sections, because they typically don't occupy file space and
thus can't be compared against file size. However, if you are
expecting to look at something other than a whole lot of zeros, don't
allow fuzzers to avoid the size checking.
Pedro Alves [Wed, 22 Feb 2023 15:40:58 +0000 (15:40 +0000)]
gdb.reverse/time-reverse.exp: test both time syscall and C time function
Instead of only testing this on systems that have a SYS_time syscall,
test it everywhere using the time(2) C function, and in addition, run
the tests again using the SYS_time syscall.
The C variant ensures that if some platform uses some syscall we are
not aware of yet, we'll still exercise it, and likely fail, at which
point we should teach GDB about the syscall.
The explicit syscall variant is useful on platforms where the C
function does not call a syscall at all by default, e.g., on some
systems the C time function wraps an implementation provided by the
vDSO.
Approved-By: Tom de Vries <tdevries@suse.de>
Change-Id: Id4b755d76577d02c46b8acbfa249d9c31b587633
Jan Beulich [Wed, 22 Feb 2023 13:12:52 +0000 (14:12 +0100)]
x86-64: LAR and LSL don't need REX.W
Just like we suppress emitting REX.W for e.g. MOV from/to segment
register, there's also no need for it for LAR and LSL - these can only
ever return 32-bit values and hence always zero-extend their results
anyway.
While there also drop the redundant Word from the first operand of
the second template each - this is already implied by Reg16.
Jan Beulich [Wed, 22 Feb 2023 13:12:24 +0000 (14:12 +0100)]
x86: optimize BT{,C,R,S} $imm,%reg
In 64-bit mode BT can have REX.W or a data size prefix dropped in
certain cases. Outside of 64-bit mode all 4 insns can have the data
size prefix dropped in certain cases.
Alan Modra [Tue, 21 Feb 2023 22:34:57 +0000 (09:04 +1030)]
Re: objdump read_section_stabs
Commit f9c36cc99518 changed (and renamed) read_section_stabs with one
difference in overall behaviour. Previously read_section_stabs would
return a NULL for an empty section, which was then treated the same as
a missing section. Now an empty section is recognized and dumped.
This leads to NULL stabp and stabs_end in print_section_stabs. Since
stabs_end - STABSIZE is then a pointer to a very large address, the
test "stabp < stabs_end - STABSIZE" succeeds.
Philippe Blain [Sun, 19 Feb 2023 22:37:35 +0000 (17:37 -0500)]
gdb: add --with-curses to --configuration output
'gdb --configuration' does not mention if GDB was built with curses.
Since b5075fb68d4 (Rename to allow_tui_tests, 2023-01-08) it does show
--enable-tui (or --disable-tui), but one might want to know if GDB was
built with curses independently of the availability of the TUI.
Since configure.ac uses AC_SEARCH_LIBS to check for the curses library,
we do not get an automatically defined HAVE_LIBCURSES symbol in
config.in. We do have symbols defined by AC_CHECK_HEADERS
(HAVE_CURSES_H, etc.) but it would be cumbersome to use those in
print_gdb_configuration because we would have to check for all 6 symbols
corresponding the 6 headers listed. This would also increase the
maintenance burden if support for other variations of curses are added.
Instead, define 'HAVE_LIBCURSES' ourselves by adding an
'action-if-found' argument to AC_SEARCH_LIBS, and use it in
print_gdb_configuration.
While at it, remove the condition on 'ac_cv_search_waddstr' and set
'curses_found' directly in 'action-if-found'.
Change-Id: Id90e3d73990e169cee51bcc3e1d52072cfacd5b8 Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom de Vries [Tue, 21 Feb 2023 14:26:24 +0000 (15:26 +0100)]
[gdb/testsuite] Require compilation flags in two gdb.arch/aarch64 test-cases
With test-cases gdb.arch/aarch64-mte-core.exp and gdb.arch/aarch64-pauth.exp I
run into compilation errors due to unsupported compilation flags.
Fix this by requiring the compilation flags, such that I have instead:
...
UNSUPPORTED: gdb.arch/aarch64-mte-core.exp: require failed: \
have_compile_flag -march=armv8.5-a+memtag
UNSUPPORTED: gdb.arch/aarch64-pauth.exp: require failed: \
have_compile_flag -mbranch-protection=pac-ret+leaf
...
Tom de Vries [Tue, 21 Feb 2023 14:06:50 +0000 (15:06 +0100)]
[gdb/testsuite] Require istarget x86* in gdb.reverse/step-indirect-call-thunk.exp
On aarch64-linux, I run into:
...
Running gdb.reverse/step-indirect-call-thunk.exp ...
gdb compile failed, gcc: error: unrecognized command line option \
'-mindirect-branch=thunk'; did you mean '-findirect-inlining'?
gcc: error: unrecognized command line option '-mfunction-return=thunk'; \
did you mean '-Wfunction-elimination'?
UNTESTED: gdb.reverse/step-indirect-call-thunk.exp: failed to prepare
...
Fix this by requiring istarget "x86*", similar to what was added in
gdb.base/step-indirect-call-thunk.exp by commit 43127ae5714 ("Fix
gdb.base/step-indirect-call-thunk.exp"), such that we have instead:
...
UNSUPPORTED: gdb.reverse/step-indirect-call-thunk.exp: require failed: \
istarget "x86*
...
Tom de Vries [Tue, 21 Feb 2023 13:41:14 +0000 (14:41 +0100)]
[gdb/testsuite] Require -fsplit-stack in gdb.base/morestack.exp
On aarch64-linux, I run into:
...
gdb compile failed, cc1: error: '-fsplit-stack' is not supported by this \
compiler configuration
UNTESTED: gdb.base/morestack.exp: failed to prepare
...
Fix this by requiring -fsplit-stack, such that we have instead:
...
UNSUPPORTED: gdb.base/morestack.exp: require failed: \
expr [have_compile_flag -fsplit-stack]
...
Tom de Vries [Tue, 21 Feb 2023 13:10:12 +0000 (14:10 +0100)]
[gdb/testsuite] Require syscall time in gdb.reverse/time-reverse.exp
On aarch64-linux, I run into:
...
Running gdb.reverse/time-reverse.exp ...
gdb compile failed, gdb.reverse/time-reverse.c: In function 'main':
gdb.reverse/time-reverse.c:39:12: error: 'SYS_time' undeclared \
(first use in this function); did you mean 'SYS_times'?
syscall (SYS_time, &time_global);
^~~~~~~~
SYS_times
gdb.reverse/time-reverse.c:39:12: note: each undeclared identifier is \
reported only once for each function it appears in
UNTESTED: gdb.reverse/time-reverse.exp: failed to prepare
...
Fix this by adding a new proc have_syscall, and requiring syscall time, such
that we have instead:
...
UNSUPPORTED: gdb.reverse/time-reverse.exp: require failed: \
expr [have_syscall time]
...
Clément Chigot [Wed, 11 Jan 2023 14:12:47 +0000 (15:12 +0100)]
gas/testsuite: adjust a test for case insensitive file systems
When dealing with case insensitive file systems, ".file line.s" and
".file Line.s" are identical and thus gas won't change the current
input file.
However, in line.l test, it's expecting to trigger an input file switch.
As the second filename doesn't matter in it, change it to fit for those
file systems.
gas/ChangeLog:
* testsuite/gas/elf/line.l: Change Line.s to Line2.s.
* testsuite/gas/elf/line.s: Adjust output.
Luis Machado [Sun, 11 Sep 2022 19:47:18 +0000 (20:47 +0100)]
[aarch64] Enable pointer authentication support for aarch64 bare metal/kernel mode addresses
At the moment GDB only handles pointer authentication (pauth) for userspace
addresses and if we're debugging a Linux-hosted program.
The Linux Kernel can be configured to use pauth instructions for some
additional security hardening, but GDB doesn't handle this well.
To overcome this limitation, GDB needs a couple things:
1 - The target needs to advertise pauth support.
2 - The hook to remove non-address bits from a pointer needs to be registered
in aarch64-tdep.c as opposed to aarch64-linux-tdep.c.
There is a patch for QEMU that addresses the first point, and it makes
QEMU's gdbstub expose a couple more pauth mask registers, so overall we will
have up to 4 pauth masks (2 masks or 4 masks):
pauth_dmask and pauth_cmask are the masks used to remove pauth signatures
from userspace addresses. pauth_dmask_high and pauth_cmask_high masks are used
to remove pauth signatures from kernel addresses.
The second point is easily addressed by moving code around.
When debugging a Linux Kernel built with pauth with an unpatched GDB, we get
the following backtrace:
#0 __fput (file=0xffff0000c17a6400) at /repos/linux/fs/file_table.c:296
#1 0xffff8000082bd1f0 in ____fput (work=<optimized out>) at /repos/linux/fs/file_table.c:348
#2 0x30008000080ade30 [PAC] in ?? ()
#3 0x30d48000080ade30 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
With a patched GDB, we get something a lot more meaningful:
#0 __fput (file=0xffff0000c1bcfa00) at /repos/linux/fs/file_table.c:296
#1 0xffff8000082bd1f0 in ____fput (work=<optimized out>) at /repos/linux/fs/file_table.c:348
#2 0xffff8000080ade30 [PAC] in task_work_run () at /repos/linux/kernel/task_work.c:179
#3 0xffff80000801db90 [PAC] in resume_user_mode_work (regs=0xffff80000a96beb0) at /repos/linux/include/linux/resume_user_mode.h:49
#4 do_notify_resume (regs=regs@entry=0xffff80000a96beb0, thread_flags=4) at /repos/linux/arch/arm64/kernel/signal.c:1127
#5 0xffff800008fb9974 [PAC] in prepare_exit_to_user_mode (regs=0xffff80000a96beb0) at /repos/linux/arch/arm64/kernel/entry-common.c:137
#6 exit_to_user_mode (regs=0xffff80000a96beb0) at /repos/linux/arch/arm64/kernel/entry-common.c:142
#7 el0_svc (regs=0xffff80000a96beb0) at /repos/linux/arch/arm64/kernel/entry-common.c:638
#8 0xffff800008fb9d34 [PAC] in el0t_64_sync_handler (regs=<optimized out>) at /repos/linux/arch/arm64/kernel/entry-common.c:655
#9 0xffff800008011548 [PAC] in el0t_64_sync () at /repos/linux/arch/arm64/kernel/entry.S:586
Backtrace stopped: Cannot access memory at address 0xffff80000a96c0c8
Clément Chigot [Fri, 13 Jan 2023 09:21:07 +0000 (10:21 +0100)]
ld/testsuite: don't output to /dev/null
Mingw doesn't have /dev/null and thus "-o /dev/null" will fail.
Currently, all the options are checked using this "-o /dev/null",
resulting in them being disabled on mingw hosts.
Fix that by outputting to a real file for all targets.
ld/ChangeLog:
* testsuite/config/default.exp: Replace "-o /dev/null" by a
file.
Alan Modra [Mon, 20 Feb 2023 23:27:49 +0000 (09:57 +1030)]
alpha-*-vms missing libraries
For this:
./ld-new: cannot find -limagelib: No such file or directory
./ld-new: cannot find -lstarlet: No such file or directory
./ld-new: cannot find -lsys$public_vectors: No such file or directory
the logs showed
creating dummy tmpdir/libimagelib:
creating dummy No
creating dummy such
etc.
So rubbish instead of tmpdir/libimagelib.a and the other required libs.
Tom Tromey [Fri, 17 Feb 2023 19:12:11 +0000 (12:12 -0700)]
Don't use chew comments for static functions
I found a few static functions in the BFD manual. These can't be
called by any user of the library, so I don't think it's useful to put
them in the manual. This patch removes the chew markup from their
comments.
Tom Tromey [Fri, 17 Feb 2023 19:12:11 +0000 (12:12 -0700)]
Fix formatting of long function description in chew output
Currently, if a function description spans a line, the resulting info
can look like this:
-- Function: long bfd_canonicalize_reloc
(bfd *abfd, asection *sec, arelent **loc, asymbol **syms); Call the
back end associated with the open BFD ABFD and translate the
external form of the relocation information attached to SEC into
the internal canonical form. Place the table into memory at LOC,
That is, the function prototype runs together with the text in an ugly
way. This patch fixes this by introducing a new primitive, so that
the generated Texinfo can be a bit nicer. Now this output looks like:
-- Function: long bfd_canonicalize_reloc (bfd *abfd, asection *sec,
arelent **loc, asymbol **syms);
Call the back end associated with the open BFD ABFD and translate
the external form of the relocation information attached to SEC
2023-02-17 Tom Tromey <tom@tromey.com>
* doc/doc.str (SYNOPSIS): Use collapse_whitespace.
* doc/chew.c (collapse_whitespace): New function.
(main): Register collapse_whitespace.
Simon Marchi [Mon, 20 Feb 2023 16:52:40 +0000 (11:52 -0500)]
gdb: revert one erroneous bool-ification change
Commit 42c13555ff88 ("Change value::m_stack to bool") erroneously
changed a `0` to `false` in this call to read_value_memory. This
parameter is `LONGEST bit_offset`, it should stay `0`.
Clément Chigot [Wed, 18 Jan 2023 13:44:39 +0000 (14:44 +0100)]
ld/testsuite: handle Windows drive letter in a noinit test
The regexp in "noinit sections (ld -r)" is skipping the file path before
the first ":". However, on Windows, a path can start with "C:". Adjust
the regexp to allow such cases.
ld/ChangeLog:
* testsuite/ld-elf/noinit-sections-2.l: Allow Windows paths
(starting with C:).
Clément Chigot [Thu, 12 Jan 2023 10:02:25 +0000 (11:02 +0100)]
ld/testsuite: adjust to Windows path separator.
In some tests, the path reported on Windows will have a \ instead of a
/. This occurs when a file is concatened with the search path in
ldfile.c.: "ld -Ltmpdir -ltext" will result into "tmpdir\libtext.a".
Andrew Burgess [Thu, 16 Feb 2023 09:22:43 +0000 (09:22 +0000)]
gdb/doc: Consistency fixes for GDB/MI documentation
I noticed two inconsistencies in the GDB/MI documentation, which this
commit addresses:
1. Each MI command is introduced like this:
@subheading The @code{-command-name} Command
Except for a few of the tracing command, which just use:
@subheading -command-name
In this commit I've updated all these trace commands to use the
more common format.
2. Each MI command starts with a @subheading, and then the details
of that command are split up using multiple @subsubheading
entries.
Except for a few commands which use @subheading for the top-level
command, and then continue to use @subheading for each part of
the command description.
In this commit I've updated these to use @subsubheading where
appropriate.
Tom de Vries [Mon, 20 Feb 2023 11:20:14 +0000 (12:20 +0100)]
[gdb/symtab] Trust epilogue unwind info for unknown or non-gcc producer
Currently we only trust epilogue unwind info only for gcc >= 4.5.0.
This has the effect that we don't trust epilogue unwind info for:
- unknown producers (CU without DW_AT_producer attribute)
- non-gcc producers (say, clang).
Instead, only distrust epilogue unwind info only for gcc < 4.5.0.
Tom de Vries [Mon, 20 Feb 2023 11:20:14 +0000 (12:20 +0100)]
[gdb/symtab] Trust epilogue unwind info for unknown producer (-g0 case)
For a -g0 -fasynchronous-unwind-tables exec (without .debug_info but with
.eh_frame section), start using the dwarf2 unwinder instead of the
"amd64 epilogue override" unwinder, by returning true in
compunit_epilogue_unwind_valid for cust == nullptr.
This has effect both on the amd64 and i386 targets, but only add amd64
test-case gdb.base/unwind-on-each-insn-amd64-2.exp.
For amd64 the current frame-unwinders are:
...
$ gdb -q -batch -ex "set arch i386:x86-64" -ex "maint info frame-unwinders"
The target architecture is set to "i386:x86-64".
dummy DUMMY_FRAME
dwarf2 tailcall TAILCALL_FRAME
inline INLINE_FRAME
python NORMAL_FRAME
amd64 epilogue NORMAL_FRAME
dwarf2 NORMAL_FRAME
dwarf2 signal SIGTRAMP_FRAME
amd64 sigtramp SIGTRAMP_FRAME
amd64 prologue NORMAL_FRAME
...
For a -g0 -fasynchronous-unwind-tables exec (without .debug_info but with
.eh_frame section), we'd like to start using the dwarf2 unwinder instead of
the "amd64 epilogue" unwinder, by returning true in
compunit_epilogue_unwind_valid for cust == nullptr.
But we'd run into the following problem for a -g0
-fno-asynchronous-unwind-tables (without .debug_info and .eh_frame section)
exec:
- the "amd64 epilogue" unwinder would not run
(because compunit_epilogue_unwind_valid () == true)
- the dwarf2 unwinder would also not run
(because there's no .eh_frame info).
Fix this by:
- renaming the "amd64 epilogue" unwinder to "amd64 epilogue override", and
- adding a fallback "amd64 epilogue" after the dwarf unwinders,
while making sure that only one of the two is active. Likewise for i386. NFC.
For amd64, this results in this change:
...
$ gdb -q -batch -ex "set arch i386:x86-64" -ex "maint info frame-unwinders"
The target architecture is set to "i386:x86-64".
dummy DUMMY_FRAME
dwarf2 tailcall TAILCALL_FRAME
inline INLINE_FRAME
python NORMAL_FRAME
-amd64 epilogue NORMAL_FRAME
+amd64 epilogue override NORMAL_FRAME
dwarf2 NORMAL_FRAME
dwarf2 signal SIGTRAMP_FRAME
+amd64 epilogue NORMAL_FRAME
amd64 sigtramp SIGTRAMP_FRAME
amd64 prologue NORMAL_FRAME
...
And for i386:
...
$ gdb -q -batch -ex "set arch i386" -ex "maint info frame-unwinders"
The target architecture is set to "i386".
dummy DUMMY_FRAME
dwarf2 tailcall TAILCALL_FRAME
iline INLINE_FRAME
-i386 epilogue NORMAL_FRAME
+i386 epilogue override NORMAL_FRAME
dwarf2 NORMAL_FRAME
dwarf2 signal SIGTRAMP_FRAME
+i386 epilogue NORMAL_FRAME
i386 stack tramp NORMAL_FRAME
i386 sigtramp SIGTRAMP_FRAME
i386 prologue NORMAL_FRAME
...
Tom de Vries [Mon, 20 Feb 2023 11:20:14 +0000 (12:20 +0100)]
[gdb/tdep] Fix amd64/i386_stack_frame_destroyed_p
The use of compunit_epilogue_unwind_valid in both amd64_stack_frame_destroyed_p
and i386_stack_frame_destroyed_p is problematic, in the sense that the
functions no longer match their documented behaviour.
Fix this by moving the use of compunit_epilogue_unwind_valid to
amd64_epilogue_frame_sniffer and i386_epilogue_frame_sniffer. No functional
changes.
Tom de Vries [Mon, 20 Feb 2023 10:16:02 +0000 (11:16 +0100)]
[gdb/testsuite] Fix gdb.threads/schedlock.exp for gcc 4.8.5
Since commit 9af467b8240 ("[gdb/testsuite] Fix gdb.threads/schedlock.exp on
fast cpu"), the test-case fails for gcc 4.8.5.
The problem is that for gcc 4.8.5, the commit turned a two-line loop:
...
(gdb) next
78 while (*myp > 0)
(gdb) next
81 MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb) next
78 while (*myp > 0)
...
into a three-line loop:
...
(gdb) next
83 MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb) next
84 cnt++;
(gdb) next
85 }
(gdb) next
83 MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb)
...
and the test-case doesn't expect this.
Fix this by reverting back to the original loop shape as much as possible by:
- removing the cnt++ line
- replacing "while (1)" with "while (one)", where one is a volatile variable
set to 1.
Tested on x86_64-linux, using compilers:
- gcc 4.8.5, 7.5.0, 12.2.1
- clang 4.0.1, 13.0.1
Alan Modra [Mon, 20 Feb 2023 00:44:59 +0000 (11:14 +1030)]
In-memory nested archives
alpha-linuxecoff has compressed archives that are decompressed to a
bfd-in-memory. We'd need to handle quite a lot of corner cases to
support nesting of such archives, so just stop it before we run into
segfaults later.
* opncls.c (_bfd_new_bfd_contained_in): Prohibit nested
archives in memory.