Commit Graph

117575 Commits

Author SHA1 Message Date
Tom Tromey
7737b13364 Handle DW_AT_endianity on enumeration types
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.html
    https://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>
2024-01-24 07:45:04 -07:00
Thiago Jung Bauermann
44acb01769 gdb/arm: Fix epilogue frame id
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.
2024-01-24 11:41:01 -03:00
Guinevere Larsen
8669a8b674 gdb/testsuite: add test for backtracing for threaded inferiors from a corefile
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>
2024-01-24 13:53:34 +01:00
Andrew Carlotti
f895041bb9 aarch64: Eliminate unused variable warnings with -DNDEBUG 2024-01-24 12:14:59 +00:00
mengqinggang
601c741d5c LoongArch: gas: Start a new frag after instructions that can be relaxed
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.
2024-01-24 16:32:40 +08:00
mengqinggang
27a750dd89 LoongArch: gas: Don't define LoongArch .align
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.
2024-01-24 16:32:34 +08:00
Paul Iannetta
ab9bb4101c Add myself as the KVX port maintainer
binutils/ChangeLog:

	* MAINTAINERS: Add myself as the KVX port maintainer.
2024-01-24 09:25:57 +01:00
GDB Administrator
f11786a195 Automatic date update in version.in 2024-01-24 00:00:33 +00:00
Andrew Carlotti
9c51c34002 aarch64: Update Architecture Extensions documentation
Restructure the architecture extensions table, add a new table for architecture
version dependencies, add missing architecture extensions, and improve some
extension descriptions.
2024-01-23 17:33:44 +00:00
Andrew Carlotti
b0104cdbff aarch64: Include +predres2 in -march=armv8.9-a
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.
2024-01-23 17:33:05 +00:00
Xi Ruoyao
36176c5d90 [PATCH v2] gas/NEWS, ld/NEWS: Announce LoongArch changes in 2.42 2024-01-23 16:00:32 +00:00
Guinevere Larsen
0068bd6fb3 gdb: fix "list ." related crash
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>
2024-01-23 16:58:55 +01:00
Mike Frysinger
047fa8cc1c sim: sh: fix nested braces in struct init
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.
2024-01-23 03:15:02 -05:00
Jaydeep Patil
b783d068d9 sim: riscv: Fix crash during instruction decoding
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
2024-01-22 20:16:27 -05:00
Mike Frysinger
8fed036bef sim: frv: fix -Wincompatible-function-pointer-types warnings [PR sim/29752]
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
2024-01-22 20:12:08 -05:00
GDB Administrator
48a121f83c Automatic date update in version.in 2024-01-23 00:00:49 +00:00
Simon Marchi
3a49585ad5 gdb/testsuite: avoid duplicate test names in gdb.dwarf2/dw2-zero-range.exp (and more)
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
2024-01-22 14:54:38 -05:00
Vladimir Mezentsev
c37ad9ea16 Fix 31252 gprofng causes testsuite parallel jobs fail
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.
2024-01-22 09:56:42 -08:00
Nick Clifton
e97522312b Updated Serbian translations for th bfd, gold and opcodes directories 2024-01-22 17:26:36 +00:00
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