A user found that gdb would not correctly print a field from an Ada
record using the scalar storage order feature. We tracked this down
to a combination of problems.
First, GCC did not emit DW_AT_endianity on the enumeration type.
DWARF does not specify this, but it is an obvious and harmless
extension. This was fixed in GCC recently:
https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642347.htmlhttps://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5d8b60effc7268448a94fbbbad923ab6871252cd
Second, GDB did not handle this attribute on enumeration types. This
patch makes this change and adds a test case that will pass with the
patched GCC.
So far, the GCC patch isn't on the gcc-13 branch; but if it ever goes
in, the test case in this patch can be updated to reflect that.
Reviewed-By: Keith Seitz <keiths@redhat.com>
arm_epilogue_frame_this_id has a comment saying that it fall backs to using
the current PC if the function start address can't be identified, but it
actually uses only the PC to make the frame id.
This patch makes the code match the comment. Another hint that it's what
is intended is that arm_prologue_this_id, a function almost identical to
it, does that.
The problem was found by code inspection. It fixes the following testsuite
failures:
FAIL: gdb.base/unwind-on-each-insn.exp: foo: instruction 9: check frame-id matches
FAIL: gdb.reverse/solib-reverse.exp: reverse-next third shr1
FAIL: gdb.reverse/solib-reverse.exp: reverse-next second shr1
FAIL: gdb.reverse/solib-reverse.exp: reverse-next first shr1
FAIL: gdb.reverse/solib-reverse.exp: reverse-next generic
FAIL: gdb.reverse/solib-reverse.exp: reverse-step into solib function one
FAIL: gdb.reverse/solib-reverse.exp: reverse-step within solib function one
FAIL: gdb.reverse/solib-reverse.exp: reverse-step into solib function two
FAIL: gdb.reverse/solib-reverse.exp: reverse-step within solib function two
Tested on arm-linux-gnueabi-hf.
This patch is based on an out-of-tree patch that fedora has been
carrying for a while. It tests if GDB is able to properly unwind a
threaded program in the following situations:
* regular threads
* in a signal handler
* in a signal handler executing on an alternate stack
And the final frame can either be in a syscall or in an infinite loop.
The test works by running the inferior until a crash to generate a
corefile, or until right before the crash. Then applies a backtrace to
all threads to see if any frame can't be identified, and the order of
the threads in GDB. Finally, it goes thread by thread and tries to
collect a large part of the backtrace, to confirm that everything is
being unwound correctly.
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Reviewed-By: Luis Machado <luis.machado@arm.com>
Approved-By: Luis Machado <luis.machado@arm.com>
For R_LARCH_TLS_{LE_HI20_R,LE_ADD_R,LD_PC_HI20,GD_PC_HI20, DESC_PC_HI20}
relocations, start a new frag to get correct eh_frame Call Frame Information
FDE DW_CFA_advance_loc info.
Gcc may generate "\t.align\t%d,54525952,4\n" before commit
b20c7ee066cb7d952fa193972e8bc6362c6e4063. To write 54525952 (NOP) to object
file, we call s_align_ptwo (-4). It result in alignment padding must be a
multiple of 4 if .align has second parameter.
Use default s_align_ptwo for .align.
Restructure the architecture extensions table, add a new table for architecture
version dependencies, add missing architecture extensions, and improve some
extension descriptions.
This matches the dependencies in the architecture, in LLVM, and even in the
original Binutils commit message that mistakenly included it only in armv9.4-a.
When a user attempts to use the "list ." command with an inferior that
doesn't have debug symbols, GDB would crash. This was reported as PR
gdb/31256.
The crash would happen when attempting to get the current symtab_and_line
for the stop location, because the symtab would return a null pointer
and we'd attempt to dereference it to print the line.
This commit fixes that by checking for an empty symtab and erroring out
of the function if it happens.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31256
Approved-By: Tom Tromey <tom@tromey.com>
The op struct includes an array of strings, but doesn't use braces
around that array when initializing. This causes a ton of warnings
when using -Wmissing-braces. Add them to fix.
The code this tool generates is the same before & after.
The match_never() function has been removed and thus step_once() crashes
during instruction decoding. Fixed it by checking for null pointer before
invoking function attached to match_func member of riscv_opcode structure
Some compilers warn in the frv code:
sem.c:24343:41: error: incompatible function pointer types passing
'void (SIM_CPU *, UINT, UDI)' (aka 'void (struct _sim_cpu *, unsigned int, unsigned long)')
to parameter of type
'void (*)(SIM_CPU *, UINT, DI)' (aka 'void (*)(struct _sim_cpu *, unsigned int, long)') [-Wincompatible-function-pointer-types]
This is due to frvbf_h_acc40U_set using UDI for setting the new value,
but using the common sim_queue_fn_di_write API which uses DI. The same
size, but different sign. We could change frvbf_h_acc40U_set to take a
DI without changing behavior in practice: the UDI is already passed via
the queue function which accepts a DI, and frvbf_h_acc40U_set already
casts the input to UDI before running any operations on it. However,
these files are all generated, so manual changes here would be reverted.
Seems like we can only change the register type for all APIs in the cpu
definition. This builds cleanly, and passes sim unittests. Not sure if
it's 100% the answer, but seems to be the best we have currently.
Bug: https://sourceware.org/PR29752
Tom Tromey noticed that dw2-zero-range.exp reported a duplicate test
name. This happens because have_index calls get_index_type with the
default test name. Refactor the test to avoid this, while cleaning a
few other things, the most important being:
- factor out the relocated and unrelocated parts in their own procs
- give different names to generated binaries in different variations,
such that all binaries are left in the test output directory (this
makes it easier to debug a specific variation)
Change-Id: I7cdf7a344834852fbb035d7e0434559eab6b1e94
Before running our tests, we made a fake installation into ./tmpdir.
This installation changes libopcodes.la in the build area.
Gas testing may fail if gas and gprofng tests are run in parallel.
I create a script to run gprofng. Inside this script, LD_LIBRARY_PATH,
GPROFNG_SYSCONFDIR are set.
putenv_libcollector_ld_misc() first uses $GPROFNG_PRELOAD_LIBDIRS to create
directories for SP_COLLECTOR_LIBRARY_PATH ($SP_COLLECTOR_LIBRARY_PATH is used
to set up LD_PRELOAD).
gprofng/ChangeLog
2024-01-19 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
PR gprofng/31252
PR gprofng/30808
* src/envsets.cc (putenv_libcollector_ld_misc): Use
$GPROFNG_PRELOAD_LIBDIRS first to build SP_COLLECTOR_LIBRARY_PATH.
* testsuite/config/default.exp: Create a script to run gprofng.
* testsuite/lib/display-lib.exp: Fix typo.
GCC 14 will warn about calling calloc with swapped size and count
arguments.
binutils/srconv.c: In function ‘nints’:
binutils/srconv.c:598:36: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
598 | return (int *) (xcalloc (sizeof (int), x));
| ^~~
binutils/srconv.c:598:36: note: earlier argument should specify number of elements, later size of each element
binutils/
* srconv.c (nints): Swap xcalloc arguments.
(wr_du): Likewise.
(wr_dus): Likewise.
GCC 14 will warn about calling calloc with swapped size and count
arguments.
binutils-gdb/binutils/coffgrok.c: In function ‘do_sections_p1’:
binutils-gdb/binutils/coffgrok.c:116:72: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
116 | struct coff_section *all = (struct coff_section *) (xcalloc (sizeof (struct coff_section),
| ^~~~~~
binutils-gdb/binutils/coffgrok.c:116:72: note: earlier argument should specify number of elements, later size of each element
binutils/
* coffgrok.c (empty_scope): Swap xcalloc arguments.
(empty_symbol): Likewise.
(do_lines): Likewise.
(doit): Likewise.
(coff_grok): Likewise.
GCC14 warns about the order of the arguments to calloc
libsframe/sframe-dump.c: In function ‘dump_sframe_header’:
libsframe/sframe-dump.c:70:39: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
70 | flags_str = (char*) calloc (sizeof (char), SFRAME_HEADER_FLAGS_STR_MAX_LEN);
| ^~~~
libsframe/sframe-dump.c:70:39: note: earlier argument should specify number of elements, later size of each element
Fix this by swapping the size and count arguments.
libsframe/
* sframe-dump.c (dump_sframe_header): Swap arguments to calloc
GCC 14 will detect when the size and count arguments of calloc are
swapped.
binutils-gdb/opcodes/tic4x-dis.c: In function ‘tic4x_disassemble’:
binutils-gdb/opcodes/tic4x-dis.c:710:32: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
710 | optab = xcalloc (sizeof (tic4x_inst_t *), (1 << TIC4X_HASH_SIZE));
| ^~~~~~~~~~~~
binutils-gdb/opcodes/tic4x-dis.c:710:32: note: earlier argument should specify number of elements, later size of each element
binutils-gdb/opcodes/tic4x-dis.c:712:40: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
712 | optab_special = xcalloc (sizeof (tic4x_inst_t *), TIC4X_SPESOP_SIZE);
| ^~~~~~~~~~~~
binutils-gdb/opcodes/tic4x-dis.c:712:40: note: earlier argument should specify number of elements, later size of each element
opcodes/ChangeLog:
* /tic4x-dis.c (tic4x_disassemble): Swap size and count xcalloc
arguments.
A user pointed out that gdb will print a Python exception when it gets
an EOF in DAP mode. And, it turns out that an EOF like this also
causes gdb not to exit. This is due to the refactoring that moved the
JSON reader to its own thread -- previously this caused an exception
to propagate and cause an exit, but now it just leaves the reader
hung.
This patch fixes these problems by arranging to handle EOF more
gracefully.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31217
In one spot, DW_OP_GNU_push_tls_address is handled differently from
DW_OP_form_tls_address. However, I think they should always be
treated identically.
Approved-by: Kevin Buettner <kevinb@redhat.com>
m32c/cpu.h defines mem as enum value, which causes GCC 14 to emit
sim/m32c/gdb-if.c: In function ‘sim_read’:
sim/m32c/gdb-if.c:162:33: error: declaration of ‘mem’ shadows a previous local [-Werror=shadow=local]
162 | sim_read (SIM_DESC sd, uint64_t mem, void *buf, uint64_t length)
| ~~~~~~~~~^~~
In file included from ../../binutils-gdb/sim/m32c/gdb-if.c:38:
sim/m32c/cpu.h:83:3: note: shadowed declaration is here
83 | mem,
| ^~~
Fix this by renaming mem to addr in all sim_read and sim_write functions.
Most already used addr instead of mem. In one file, sim/rx/gdb-if.c, this
also meant renaming the local addr variable to vma.
With GCC 14 -Werror=shadow=compatible-local flags the reuse of single
capital letters used in aarch64/cpustate.h enums
88 | expand_logical_immediate (uint32_t S, uint32_t R, uint32_t N)
| ~~~~~~~~~^
In file included from ../../binutils-gdb/sim/aarch64/aarch64-sim.h:27,
from ../../binutils-gdb/sim/aarch64/simulator.c:33:
217 | N = 1 << N_IDX
| ^
sim/aarch64/simulator.c: In function ‘expand_logical_immediate’:
sim/aarch64/simulator.c:88:60: error: declaration of ‘N’ shadows a previous local [-Werror=shadow=compatible-local]
sim/aarch64/cpustate.h:217:3: note: shadowed declaration is here
include/opcode/cr16.h defines cc as an enum value, which causes GCC 14
to warn
sim/cr16/simops.c: In function ‘cond_stat’:
sim/cr16/simops.c:138:26: error: declaration of ‘cc’ shadows a previous local [-Werror=shadow=local]
138 | static int cond_stat(int cc)
| ~~~~^~
In file included from ../../binutils-gdb/sim/cr16/cr16-sim.h:26,
from ../../binutils-gdb/sim/cr16/simops.c:39:
sim/../include/opcode/cr16.h:149:3: note: shadowed declaration is here
149 | cc,
| ^~
Fix this by renaming cc in cr16/simops.c to cond.
The test gdb.btrace/tailcall.exp has multiple tests that include the
filename in the output. When testing with gcc, only a relative path is
printed, but when using clang, the full file path is printed instead.
This makes most of those tests fail, with the exception of "record goto
4" which allows for more characters before the file name. The test
gdb.btrace/recod_goto.exp suffers with the same issue
This commit allows for text before the filename. However, instead of how
the aforementioned "record goto 4", it uses a regexp that doesn't allow
for newlines, just in case some off output happens.
Approved-By: Tom Tromey <tom@tromey.com>
The test gdb.dwarf2/dw2-noloc.exp predates the dwarf assembler, and uses
some unreliable assumptions about where global labels get put.
Specifically, when using clang to compile the test, both labels it uses
to gauge the adresses of the main function get reshuffled to be side-by-side,
and the debug information ends up making it look like main's high pc is equal
to low pc, meaning we never enter the main function's scope, and that leads to
22 failures because the "main_*" variables are technically never in scope.
This patch modernizes the aforementioned test to use the dwarf
assembler, which removes all failures when using clang. It also renames
the .c file to be more inline with current standard.
Approved-By: Tom Tromey <tom@tromey.com>
There are two issues causing 11 test failures:
1. The TLS desc tests are matching the entire disassemble of a linked
executable. But if ld is configured --enable-default-hash-style=gnu
(note that most modern distros use this option), the layout of the
linked executables will be different and the immediate operands in
the linked executables will also be different. So we add
"--hash-style=both" for these tests to cancel the effect of
--enable-default-hash-style=gnu, like [x86_64 mark-plt tests].
2. By default objdump disassemble uses [pseudo-instructions] so "addi.w"
is outputed as "li.w", causing mismatches in TLS relaxation tests.
We can turn off the pseudo-instruction usage in objdump using "-M
no-aliases" to fix them.
[x86_64 mark-plt tests]: 16666ccc91
[pseudo-instructions]: 17f9439038
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
A recent(ish) change in gdb/infrun.c made process_event_stop_test load
debug information where it would not have done so previously. The
change is:
commit bf2813aff8
AuthorDate: Fri Sep 1 13:47:32 2023 +0200
CommitDate: Mon Nov 20 10:54:03 2023 +0100
gdb/record: print frame information when exiting a recursive call
Currently, when GDB is reverse stepping out of a function into the same
function due to a recursive call, it doesn't print frame information, as
reported by PR record/29178. This happens because when the inferior
leaves the current frame, GDB decides to refresh the step information,
clobbering the original step_frame_id, making it impossible to figure
out later on that the frame has been changed.
This commit changes GDB so that, if we notice we're in this exact
situation, we won't refresh the step information.
Because of implementation details, this change can cause some debug
information to be read when it normally wouldn't before, which showed up
as a regression on gdb.dwarf2/dw2-out-of-range-end-of-seq. Since that
isn't a problem, the test was changed to allow for the new output.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29178
Although there is nothing wrong with this change in principle, it
happens to break most of the tests in gdb/testsuite/gdb.rocm/*.exp.
This is because those tests do rely on GDB not loading debug
information. This is necessary because the debug information produced
for AMDGPU code is using DWARF extensions which are not supported by GDB
at this point.
In this patch, I propose to use a lazy loading mechanism so the frame_id
for the current frame is only computed when required instead of when
entering process_event_stop_test. The lazy_loader class is currently
defined locally in infrun.c, but if it turns out to be useful elsewhere,
it could go somewhere under gdbsupport.
This patch should restore the behavior GDB had before
bf2813aff8 when it comes to load debug
info.
Another approach could have been to revert
fb84fbf8a5 (gdb/infrun: simplify
process_event_stop_test) and adjust the implementation of
bf2813aff8 (gdb/record: print frame
information when exiting a recursive call). However, I think that the
lazy loading works well with the simplification done recently, so I went
down that route.
Regression tested on x86_64-linux (Ubuntu 22.04) with AMDGPU support.
Change-Id: Ib63a162128130d1786a77c98623e9e3dcbc363b7
Approved-by: Kevin Buettner <kevinb@redhat.com>
Remove SYMBOL_BLOCK_OPS, SYMBOL_COMPUTED_OPS and SYMBOL_REGISTER_OPS, in
favor of methods on struct symbol. More changes could be done here to
improve the design and make things safer, but I just wanted to do a
straightforward change to remove the macros for now.
Change-Id: I27adb74a28ea3c0dc9a85c2953413437cd95ad21
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
In the past, dwarf2_per_cu_data was allocated using malloc, so special
handling was needed for the vector used for symtab handling. We
changed this to use 'new' a while back, so this code can now be
greatly simplified.
Regression tested on x86-64 Fedora 38.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit removes deprecated_exec_file_display_hook and the
associated specify_exec_file_hook.
The specify_exec_file_hook is used to add a new hook function to
deprecated_exec_file_display_hook, but is only used from the insight
debugger.
I posted a patch to remove the use of specify_exec_file_hook from
insight, and instead use gdb::observers::executable_changed, this
patch can be found here (it has now been merged):
https://inbox.sourceware.org/insight/6abeb45e97d9004ec331e94cf2089af00553de76.1702379379.git.aburgess@redhat.com/T/#u
With this merged we can now cleanup the GDB side as this code is now
unused.
There should be no user visible changes after this commit.
Approved-By: Tom Tromey <tom@tromey.com>
After closing "Bug 30770 - serial.c does not preserve errno correctly"
https://sourceware.org/bugzilla/show_bug.cgi?id=30770
remote debugging became impossible due to an attempt to recv() by a call intended for the socket, and not for the character device file. The
documentation implicitly states that it is possible to use the read() call to work with a socket. But this does not mean in the general case that it is
permissible to use recv in the case of a non-socket.
condition:
os: Distributor ID: Ubuntu
Description: Ubuntu 23.10
Release: 23.10
Codename: mantic
libc:
ldd (Ubuntu GLIBC 2.38-1ubuntu6) 2.38
kernel:
Linux klen-dev-um790pro 6.5.0-14-generic #14-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:59:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
gdb: build from trank at 15.0.50.20231226-git
GDB output:
$ arm-kgp-eabi-gdb
GNU gdb (Klen's_GNU_package_(KGP)_for_target::arm-kgp-eabi<rmprofile/lto>_host::x86_64-kgp-linux-gnu_znver4-avx512<<ílex>>)
15.0.50.20231226-git
....
(gdb) tar ext /dev/ttyACM1
Remote debugging using /dev/ttyACM1
Remote communication error. Target disconnected: error while reading: Socket operation on non-socket.
(gdb)
after fix gdb work fine
$ arm-kgp-eabi-gdb -q
(gdb) tar ext /dev/ttyACM0
Remote debugging using /dev/ttyACM0
(gdb) mon swd
Target voltage: 0.0V
Available Targets:
No. Att Driver
STM32F40x M4
(gdb) att 1
Attaching to Remote target
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x08020c80 in ?? ()
(gdb)
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770
Replace throw with throw_exeception in do_with_buffered_output.
This patch fixes regressions in gdb.dwarf2/dw2-dir-file-name.exp
caused by commit 519d63439.
do_with_buffered_output needs to use throw_exception instead of
throw to ensure that exceptions of the correct type are thrown.
If using throw, gdb_exception_error may be wrongly converted into
gdb_exception during print_frame_info. This prevents the exception
from being caught in print_stack_frame.
With test-case gdb.threads/attach-many-short-lived-threads.exp, I run into:
...
(gdb) attach 7773^M
Attaching to program: attach-many-short-lived-threads, process 7773^M
Cannot attach to lwp 7776: Operation not permitted (1)^M
(gdb) PASS: $exp: iter 1: attach
info threads^M
No threads.^M
(gdb) PASS: $exp: iter 1: no new threads
set breakpoint always-inserted on^M
(gdb) PASS: $exp: iter 1: set breakpoint always-inserted on
break break_fn^M
Breakpoint 1 at 0x400b4d: file attach-many-short-lived-threads.c, line 57.^M
(gdb) PASS: $exp: iter 1: break break_fn
continue^M
The program is not being run.^M
(gdb) FAIL: $exp: iter 1: break at break_fn: 1 \
(the program is no longer running)
...
There's some code in the test-case dealing with a similar warning:
...
-re "warning: Cannot attach to lwp $decimal: Operation not permitted" {
...
But since commit c6f7f9c80c ("Bail out of "attach" if a thread cannot be
traced"), the warning has been changed into an error.
Fix the FAIL by updating the test-case to expect an error instead of a
warning.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
Remove hosts/mipsbsd.h and scripttempl/mipsbsd.sc which are unused
after
commit 3596d8ceb2
Author: Alan Modra <amodra@gmail.com>
Date: Wed Apr 18 15:39:34 2018 +0930
Remove mips aout, coff, and pe support
bfd/
* hosts/mipsbsd.h: Removed.
ld/
* scripttempl/mipsbsd.sc: Removed.
I think there's a bug in ld on 32-bit Windows. Here is a tiny project for reproducing the problem:
https://github.com/oltolm/ld-mingw32-bug
A 32-bit DLL exports two stdcall functions "myfunc" and "myfunc64". The functions would normally get
exported as "myfunc@0" and "myfunc64@0". The "DEF" file exports them as "myfunc" and "myfunc64"
without the decorations. When you run the executable it shows an error message saying that it cannot
find "myfunc64".
I think it happens because the sorting in ld is wrong. I think it should use the exported names
"myfunc" and "myfunc64", but instead it uses the decorated names "myfunc@0" or "myfunc65@0". The
ordering of functions in the DLL is different depending on which names you use.
My patch changes ld to use undecorated exported names for sorting and it seems to fix the problem.
When I execute ctest in my project, it runs successfully.
Append "#pass" to APX tests for targets which pad text sections with NOPs.
* testsuite/gas/i386/x86-64-apx-evex-promoted-intel.d: Append
"#pass".
* testsuite/gas/i386/x86-64-apx-evex-promoted.d: Likewise.