Commit graph

117556 commits

Author SHA1 Message Date
Mark Wielaard
91e9420f18 binutils: Fix calloc argument order in srconv.c
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.
2024-01-22 18:20:21 +01:00
Mark Wielaard
dd0c018e72 binutils: Fix calloc argument order in coffgrok.c
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.
2024-01-22 18:19:43 +01:00
Mark Wielaard
aa5a36b118 libsframe: Fix calloc argument order in dump_sframe_header
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
2024-01-22 18:19:03 +01:00
Mark Wielaard
5bc519bf0c opcodes: tic4x_disassemble swap xcalloc arguments
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.
2024-01-22 18:16:42 +01:00
Tom Tromey
46bdb64164 Handle EOF more gracefully in DAP
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
2024-01-22 08:54:27 -07:00
Tom Tromey
8f42049a82 Fix handling of DW_OP_GNU_push_tls_address
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>
2024-01-22 06:59:47 -07:00
Mark Wielaard
cbbcd7fd10 sim: Fix -Werror=shadow=local by changing mem to addr in sim_{read,write}
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.
2024-01-22 14:22:30 +01:00
Mark Wielaard
c2625a463f sim: Fix some -Werror=shadow=compatible-local issues in aarch64/simulator.c
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
2024-01-22 12:10:23 +01:00
Mark Wielaard
865e469c60 sim: Fix cc -Werror=shadow=local in cr16/simops.c
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.
2024-01-22 12:04:49 +01:00
Guinevere Larsen
06ceae57ed gdb/testsuite: relax filename restriction in some gdb.btrace tests
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>
2024-01-22 11:42:27 +01:00
Guinevere Larsen
b9bdebba83 gdb/testsuite: modernize gdb.dwarf2/dw2-noloc.exp
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>
2024-01-22 11:30:07 +01:00
Xi Ruoyao
7b0b94b7b9 LoongArch: Fix some test failures about TLS desc and TLS relaxation
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>
2024-01-22 17:14:36 +08:00
Tatsuyuki Ishi
d5e68872d0 LoongArch: Do not add DF_STATIC_TLS for TLS LE
TLS LE is exclusively for executables, while DF_STATIC_TLS is for DLLs.
DF_STATIC_TLS should only be set for TLS IE (and when it's DLL), not LE.
2024-01-22 17:14:29 +08:00
Tatsuyuki Ishi
2ae49bc16f LoongArch: Use tab to indent assembly in TLSDESC test suite
The usual convention is to use tabs. Not all test are following this,
but at least when using tabs, let's use it consistently throughout the
file.
2024-01-22 17:14:22 +08:00
Jan Beulich
6498d4829c x86/APX: also amend the PUSH2/POP2 testcase
Commit f530d5f1ba ("Update x86/APX: VROUND{P,S}{S,D} can generally be
encoded") took care of only half of the remaining issue. Add #pass here
as well.
2024-01-22 08:52:30 +01:00
GDB Administrator
58ce812559 Automatic date update in version.in 2024-01-22 00:00:13 +00:00
Lancelot SIX
5266f5c25b gdb/infrun: lazily load curr_frame_id in process_event_stop_test
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>
2024-01-21 15:25:51 +00:00
mengqinggang
32ee2b4b71 LoongArch: Do not emit R_LARCH_RELAX for two register macros
For two register macros (e.g. la.local $t0, $t1, symbol) used in extreme code
model, do not emit R_LARCH_RELAX relocations.
2024-01-21 10:05:38 +08:00
GDB Administrator
5a75433a12 Automatic date update in version.in 2024-01-21 00:00:09 +00:00
Simon Marchi
7ae2432746 gdb: remove SYMBOL_*_OPS macros
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>
2024-01-19 21:51:56 -05:00
Tom Tromey
4a2318c985 Simplify DWARF symtab inclusion handling
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>
2024-01-19 17:41:36 -07:00
GDB Administrator
40ca2746ce Automatic date update in version.in 2024-01-20 00:00:13 +00:00
Andrew Burgess
81b6f191f7 gdb: remove deprecated_exec_file_display_hook and associated code
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>
2024-01-19 22:20:59 +00:00
Сергей Чернов
74d8fa2df7 Fix remote serial read
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
2024-01-19 11:07:07 -07:00
Aaron Merey
9323e42f58 gdb/ui-out.h: Fix exception handling in do_with_buffered_output
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.
2024-01-19 12:18:58 -05:00
Tom de Vries
92517d01fe [gdb/testsuite] Update xfail in gdb.threads/attach-many-short-lived-threads.exp
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>
2024-01-19 17:40:03 +01:00
Simon Marchi
a332b7c7d0 gdb: remove unnecessary NULL checks for return value of value_from_register
value_from_register can't return nullptr, remove some NULL checks.

Change-Id: Ia6b32b8f86e593c535e3678a89dffe5544eb7ab0
Approved-By: Tom Tromey <tom@tromey.com>
2024-01-19 11:29:20 -05:00
H.J. Lu
c873acc5fe ld: Remove scripttempl/elf_chaos.sc
scripttempl/elf_chaos.sc is unused.  Remove it.

	* scripttempl/elf_chaos.sc: Removed.
2024-01-19 08:05:49 -08:00
H.J. Lu
dbca3300ea Remove hosts/mipsbsd.h and scripttempl/mipsbsd.sc
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.
2024-01-19 07:25:31 -08:00
Oleg Tolmatcev
d544a1dca2 ld: fix 32-bit mingw DLL symbol export bug
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.
2024-01-19 15:02:45 +00:00
H.J. Lu
f530d5f1ba Update x86/APX: VROUND{P,S}{S,D} can generally be encoded
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.
2024-01-19 06:44:23 -08:00
Nick Clifton
1878f44b70 Update readelf's and objdump's debug frame displaying feature to include the contents of the .eh_frame_hdr section, if present. 2024-01-19 14:39:08 +00:00
H.J. Lu
8d10083c23 ld: Put all emulation options in ldlex.h
For each command line option, parse_args() calls ldemul_parse_args()
to check if the command line option is an emulation option.  But when
there is a conflict between the emulation option value and the default
option value, the default command line option will be processed as if
the emulation option is used.  Remove PARSE_AND_LIST_PROLOGUE and move
all emulation options to ldlex.h to avoid conflicts.

	PR ld/31247
	* ldlex.h (option_values): Add all emulation options.
	* emulparams/elf32mcore.sh (PARSE_AND_LIST_PROLOGUE): Removed.
	* emulparams/plt_unwind.sh (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/aarch64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/alphaelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/armelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/avrelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/bfin.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/cskyelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/hppaelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/ia64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/m68hc1xelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/m68kelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/metagelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/mipself.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/nds32elf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/nto.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/ppc32elf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/ppc64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/riscvelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/rxelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/s390.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/scoreelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/spuelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/tic6xdsbt.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/vxworks.em (PARSE_AND_LIST_PROLOGUE): Likewise.
	* emultempl/aix.em: Include "ldlex.h".
	(OPTION_XXX): Removed.
	(gld${EMULATION_NAME}_read_file): Replace lineno with linenumber.
	* emultempl/beos.em (OPTION_XXX): Removed.
	* emultempl/elf.em: Include "ldlex.h".
	Don't check PARSE_AND_LIST_PROLOGUE.
	(OPTION_XXX): Removed.
	* emultempl/msp430.em: Include "ldlex.h".
	(OPTION_XXX): Removed.
	* emultempl/pe.em (OPTION_XXX): Removed.
	* emultempl/pep.em (OPTION_XXX): Likewise.
	* emultempl/ticoff.em: Include "ldlex.h".
	(OPTION_XXX): Removed.
	* emultempl/vms.em: Include "ldlex.h".
	(OPTION_XXX): Removed.
	* emultempl/xtensaelf.em (elf32xtensa_size_opt,
	elf32xtensa_no_literal_movement, elf32xtensa_abi): Moved out of
	PARSE_AND_LIST_PROLOGUE.
	(PARSE_AND_LIST_PROLOGUE): Removed.
2024-01-19 05:35:16 -08:00
Nick Clifton
3b6a6fd9c0 Add multilib.am to the list of top level files included in any release created by the src-release.sh script 2024-01-19 11:45:10 +00:00
Jan Beulich
633789901c x86-64: Dwarf2 register numbers for %bnd<N>
I don't see why we shouldn't record them when they have been allocated,
even if they're (bogusly) named as reserved in the ABI right now.
2024-01-19 10:19:15 +01:00
Jan Beulich
eea4357967 x86/APX: VROUND{P,S}{S,D} can generally be encoded
VRNDSCALE{P,S}{S,D} is the AVX512 generalization of these AVX insns. As
long as the immediate has the top 4 bits clear, they are equivalent to
the earlier VEX-encoded insns, and hence can be used to permit use of
eGPR-s in the memory operand. Since this is the normal way of using
these insns, also alter the resulting diagnostic to complain about the
immediate, not the eGPR use.
2024-01-19 10:18:32 +01:00
Jan Beulich
2519809009 x86/APX: be consistent with insn suffixes
When there's a suitably disambiguating register operand, suffixes are
generally omitted (unless in suffix-always mode). All NDD insns have a
suitable register operand, so they shouldn't have suffixes by default.
2024-01-19 10:17:44 +01:00
Jan Beulich
4945a0c46c x86: drop redundant EVex128 from PUSH2/POP2
EVexMap4 already covers that.
2024-01-19 10:16:28 +01:00
Jan Beulich
5190fa3828 x86: support APX forms of U{RD,WR}MSR
This was missed in 6177c84d5e ("Support APX GPR32 with extend evex
prefix").
2024-01-19 10:16:00 +01:00
Aaron Merey
519d634396 gdb: Buffer output streams during events that might download debuginfo
Introduce new ui_file buffering_file to temporarily collect output
written to gdb_std* output streams during print_thread, print_frame_info
and print_stop_event.

This ensures that output during these functions is not interrupted
by debuginfod progress messages.

With the addition of deferred debuginfo downloading it is possible
for download progress messages to print during these events.
Without any intervention we can end up with poorly formatted output:

    (gdb) backtrace
    [...]
    #8  0x00007fbe8af7d7cf in pygi_invoke_c_callable (Downloading separate debug info for /lib64/libpython3.11.so.1.0
    function_cache=0x561221b224d0, state=<optimized out>...

To fix this we buffer writes to gdb_std* output streams while allowing
debuginfod progress messages to skip the buffers and print to the
underlying output streams immediately.  Buffered output is then written
to the output streams.  This ensures that progress messages print first,
followed by uninterrupted frame/thread/stop info:

    (gdb) backtrace
    [...]
    Downloading separate debug info for /lib64/libpython3.11.so.1.0
    #8  0x00007fbe8af7d7cf in pygi_invoke_c_callable (function_cache=0x561221b224d0, state=<optimized out>...

Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-01-19 00:18:00 -05:00
GDB Administrator
64db3e4d88 Automatic date update in version.in 2024-01-19 00:00:54 +00:00
Tom Tromey
91a42a6180 Rewrite .debug_names writer
This rewrites GDB's .debug_names writer.  It is now closer to the form
imagined in the DWARF spec.  In particular, names are emitted exactly
as they appear in the original DWARF.

In order to make the reader work nicely, some extensions were needed.
These were all documented in an earlier patch.  Note that in
particular this writer solves the "main name" problem by putting a
flag into the table.

GDB does not use the .debug_names hash table, so it also does not
write one.  I consider this hash table to be essentially useless in
general, due to the name canonicalization problem -- while DWARF says
that writers should use the system demangling style, (1) this style
varies across systems, so it can't truly be relied on; and (2) at
least GCC and one other compiler don't actually follow this part of
the spec anyway.

It's important to note, though, that even if the hash was somehow
useful, GDB probably still would not use it -- a sorted list of names
is needed for completion and performs reasonably well for other
lookups, so a hash table is just overhead, IMO.

String emission is also simplified.  There's no need in this writer to
ingest the contents of .debug_str.

A couple of tests are updated to reflect the fact that they now "fail"
because the tests don't include .debug_aranges in the .S file.
Arguably the .debug_names writer should also create this section; but
I did not implement that in this series, and there is a separate bug
about it.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24820
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24549
2024-01-18 08:51:06 -07:00
Tom Tromey
2d34b0ea1a Export dwarf5_augmentation
I don't know why gdb had the .debug_names augmentation string in two
separate places; this patch exports it in one spot, to be used in
another.
2024-01-18 08:20:17 -07:00
Tom Tromey
b371f07c47 Rewrite .debug_names reader
This rewrites the .debug_names reader to follow the spec.

Since it was first written, gdb's .debug_names writer has been
incorrect -- while the form of the section has been ok, the contents
have been very gdb-specific.

This patch fixes the reader side of this equation, rewriting the
reader to create a cooked index internally -- an important detail
because it allows for the deletion of a lot of code, and it means the
various readers will agree more often.

This reader checks for a new augmentation string.  For the time being,
all other producers are ignored -- the old GDB ones because they are
wrong, and clang because it does not emit DW_IDX_parent.  (If there
are any other producers, I'm unaware of them.)

While the new reader mostly runs in a worker thread, it does not try
to distribute its work.  This could be done by partitioning the name
table.  The parent computations could also be done in parallel after
all names have been read.  I haven't attempted this.

Note that this patch temporarily regresses gdb.base/gdb-index-err.exp.
This test writes an index using gdb -- but at this particular stage,
gdb cannot read the indexes it creates.  Rather than merge the patches
into a mega-patch, I've chosen to just accept this temporary
regression.

In v1 of this patch, I made the new reader more strict about requiring
.debug_aranges.  In v2, I've backed this out and kept the previous
logic.  This solved a few test failures, though it's arguably not the
right approach.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25950
2024-01-18 08:20:17 -07:00
Tom Tromey
9b63bc4644 Allow other results in DW_TAG_entry_point test
DW_TAG_entry_point is implemented by adding a new LOC_BLOCK symbol --
that is, another function symbol.  However, the test case assumes that
"bt" will never pick this symbol.

This assumption seems unwarranted to me, and in fact this test will
regress with the debug-names target board after the .debug_names
rewrite.

This patch changes the test to allow either answer in the backtrace.
If only the main entry point is desired, then it seems that more work
must be done to handle DW_TAG_entry_point properly, as nothing
currently guarantees this property.
2024-01-18 08:20:17 -07:00
Tom Tromey
f8c024dcef Remove some .debug_names tests
These .debug_names tests were hand-written to mimic clang.  However,
they are difficult to update, and in any case the new reader won't
accept clang-generated indices.  Therefore this patch removes these
tests.
2024-01-18 08:20:17 -07:00
Tom Tromey
07e98a5ad3 Explicitly expand CUs in dw2-inline-with-lexical-scope.exp
dw2-inline-with-lexical-scope.exp relies on the main CU being
expanded.  However, it doesn't guarantee that this actually happens,
and with the new .debug_names reader, it won't, because the "main"
program will be found in the index without requiring CU expansion.

This patch fixes the problem by explicitly expanding the CU in
question.

Note that this is an artificial bug -- it occurs because the generated
.debug_aranges isn't correct.
2024-01-18 08:20:17 -07:00
Tom Tromey
d2cc8bd228 Fix dw2-zero-range.exp when an index is in use
dw2-zero-range.exp looks for a certain complaint, but this won't be
issued when an index is in use.  This patch changes the test to not
fail in this case.
2024-01-18 08:20:17 -07:00
Tom Tromey
3a86215295 Empty hash table fix in .debug_names reader
The handling of an empty hash table in the .debug_names reader is
slightly wrong.

Currently the code assumes there is always an array of hashes.
However, section 6.1.1.4.5 Hash Lookup Table says:

    The optional hash lookup table immediately follows the list of
    type signatures.

and then:

    The hash lookup table is actually two separate arrays: an array of
    buckets, followed immediately by an array of hashes.

My reading of this is that the hash table as a whole is optional, and
so the hashes will not exist in this case.  (This also makes sense
because the hashes are not useful without the buckets anyway.)

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25950
2024-01-18 08:20:17 -07:00
Tom Tromey
36cde74bd8 Remove cooked_index_worker::start_reading
I noticed that cooked_index_worker::start_reading isn't really needed.
This patch removes it, and also removes the SCOPED_EXIT, in favor of a
direct call.
2024-01-18 08:20:17 -07:00