Commit Graph

119606 Commits

Author SHA1 Message Date
H.J. Lu
93ea177e95 gold: Remove duplicated rules for ifuncmain[12457]picstatic
When HAVE_STATIC and IFUNC_STATIC both are false, "make" reports:

Makefile:3796: warning: overriding recipe for target 'ifuncmain1picstatic'
Makefile:3788: warning: ignoring old recipe for target 'ifuncmain1picstatic'
Makefile:3900: warning: overriding recipe for target 'ifuncmain2picstatic'
Makefile:3892: warning: ignoring old recipe for target 'ifuncmain2picstatic'
Makefile:3932: warning: overriding recipe for target 'ifuncmain4picstatic'
Makefile:3924: warning: ignoring old recipe for target 'ifuncmain4picstatic'
Makefile:3972: warning: overriding recipe for target 'ifuncmain5picstatic'
Makefile:3964: warning: ignoring old recipe for target 'ifuncmain5picstatic'
Makefile:4048: warning: overriding recipe for target 'ifuncmain7picstatic'
Makefile:4040: warning: ignoring old recipe for target 'ifuncmain7picstatic'

due to duplicated rules for ifuncmain[12457]picstatic:

@GCC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@HAVE_STATIC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@IFUNC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@IFUNC_STATIC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@NATIVE_LINKER_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@GCC_TRUE@@HAVE_STATIC_TRUE@@IFUNC_STATIC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1picstatic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld

Make rules for ifuncmain[12457]picstatic independent of HAVE_STATIC and
IFUNC_STATIC:

@GCC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@IFUNC_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@NATIVE_LINKER_FALSE@ifuncmain1picstatic$(EXEEXT): $(ifuncmain1picstatic_OBJECTS) $(ifuncmain1picstatic_DEPENDENCIES) $(EXTRA_ifuncmain1picstatic_DEPENDENCIES)
@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ifuncmain1picstatic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld

	PR gold/32116
	* testsuite/Makefile.am (ifuncmain1picstatic): Make it independent
	of HAVE_STATIC and IFUNC_STATIC.
	(ifuncmain2picstatic): Likewise.
	(ifuncmain4picstatic): Likewise.
	(ifuncmain5picstatic): Likewise.
	(ifuncmain7picstatic): Likewise.
	* testsuite/Makefile.in: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-28 05:38:19 -07:00
H.J. Lu
903ae63656 x86: Report invalid TLS operator
Report invalid TLS operator, instead of relocation.

	PR gas/28595
	* config/tc-i386.c (gotrel): Replace int with unsigned int.
	(i386_assemble): Report invalid TLS operator.
	* testsuite/gas/i386/inval-tls.l: updated.
	* testsuite/gas/i386/x86-64-inval-tls.l: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-28 05:01:34 -07:00
Guinevere Larsen
2e3759c260 gdb/testsuite: fix gdb.btrace/non-stop.exp end of history check
The recent commit 0891970109 changed the
warnings when GDB reaches the end of the recorded history, and updated
tests to expect the new messages. The pattern used for
gdb.btrace/non-stop.exp, however, was too broad and could cause the
following test result:

    ...
    (gdb) PASS: gdb.btrace/non-stop.exp: no progress: all: thread apply all continue: prompt
    ^M
    Reached end of recorded history; stopping.^M
    Following forward execution will be added to history.^M
    test (arg=0x0) at /data/vries/gdb/src/gdb/testsuite/gdb.btrace/non-stop.c:30^M
    30        return arg; /* bp.2 */^M
    ^M
    Reached end of recorded history; stopping.^M
    Following forward execution will be added to history.^M
    test (arg=0x0) at /data/vries/gdb/src/gdb/testsuite/gdb.btrace/non-stop.c:30^M
    30        return arg; /* bp.2 */^M
    PASS: gdb.btrace/non-stop.exp: no progress: all: thread apply all continue: thread 0
    FAIL: gdb.btrace/non-stop.exp: no progress: all: thread apply all continue: thread 1 (timeout)
    ...

This happens because the pattern looks like one of these 2:
    "Reached end of recorded.*Backwards execution.*"
    "Reached end of recorded.*Following forward.*"

What seems to have happened is that all the output came at once, and
most of it was consumed by the first '.*' pattern when checking for
thread 0, so there was no output left for checking thread 1. This commit
fixes that by making the expected outputs more exact.

I also fixed the whitespace errors in gdb_cont_to_no_history_backwards
that pre-dated the commit above, since I was already touching that proc.

Approved-By: Tom de Vries <tdevries@suse.de>
2024-08-28 08:41:05 -03:00
Andrew Burgess
0e64306335 gdb/testsuite: add no-delete-breakpoints option to 'runto' proc
New 'no-delete-breakpoints' option for the 'runto' proc.  This option
disables the delete_breakpoints call early on in this proc.

There are a couple of places in the testsuite where I have used:

  proc no_delete_breakpoints {} {}

  with_override delete_breakpoints no_delete_breakpoints {
    if {![runto_main]} {
      return
    }
 }

In order to avoid the deleting all breakpoints when I call
runto_main.  I was about to add yet another instance of this pattern
and I figured that it's time to do this properly.

This commit adds the new option to 'runto' which causes the
delete_breakpoints call to be skipped.

And, we now forward any arguments from 'runto_main' through to
'runto', this means I can now just do:

  if {![runto_main no-delete-breakpoints]} {
    return
  }

which I think is cleaner and easier to understand.

I've updated the two tests I found that use the old with_override
approach.

There should be no change in what is tested after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-28 10:39:21 +01:00
Andrew Burgess
be85cdf415 gdb: add 'maint info blocks' command
While reviewing a patch I wanted to understand which blocks existed at
a given address.

The 'maint print symbols' command does provide some of this
information, but that command displays all blocks within a given
symtab.  If I want to know which blocks are at a given address I have
to figure that out for myself based on the output of 'maint print
symbols' ... and I'm too lazy for that!

So this command lists just those blocks at a given address, along with
information about the blocks type.  This new command doesn't list the
symbols within each block, for that my expectation is that you'd cross
reference the output with that of 'maint print symbols'.

The new command format is:

  maintenance info blocks
  maintenance info blocks ADDRESS

This lists the blocks at ADDRESS, or at the current $pc if ADDRESS is
not given.  Blocks are listed starting at the global block, then the
static block, and then the progressively narrower scoped blocks.

For each block we list the internal block pointer (which allows easy
cross referencing with 'maint print symbols'), the inferior address
range, along with other useful information.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-08-28 10:30:31 +01:00
Andrew Burgess
56260065c8 gdb: Add 'maint info inline-frames' command
While reviewing a patch I wanted to view GDB's inline frame state.  I
don't believe there's currently a maintenance command to view this
information, so in this commit I've added one.

The new command is:

  maintenance info inline-frames
  maintenance info inline-frames ADDRESS

The command lists the inline frames that start at ADDRESS, or at the
current $pc if no ADDRESS is given.  The command also displays the
"outer" function in which the inline functions are present.

An example of the command output:

  (gdb) maintenance info inline-frames
  Cached inline state information for thread 1.
  program counter = 0x401137
  skipped frames = 1
    bar
  > foo
    main
  (gdb)

This tells us that function 'main' called 'foo' which called 'bar'.
The functions 'foo' and 'bar' are both inline and both start at the
address 0x401137.  Currently GDB considers the inferior to be stopped
in frame 'foo' (note the '>' marker), this means that there is 1
skipped frame (function 'bar').

The function 'main' is the outer function.  The outer function might
not start at 0x401137, it is simply the function that contains the
inline functions.

If the user does a 'step' then GDB will not actually move the inferior
forward, but will instead simply tell the user that the inferior
entered 'bar'.  The output of 'maint info inline-frames' will change
like this:

  (gdb) step
  bar () at inline.c:6
  6	  ++global_counter;
  (gdb) maintenance info inline-frames
  Cached inline state information for thread 1.
  program counter = 0x401137
  skipped frames = 0
  > bar
    foo
    main
  (gdb)

Now GDB is in function 'bar' and there are no skipped frames.

I have renamed skipped_symbols to function symbols within the
inline_state class.  We are now going to carry the "outer"
function (the function that contains all the inlined functions) within
this list (as the last entry), so the old name didn't really make
sense.  As a consequence of this rename I've updated some comments.

I've changed stopped_by_user_bp_inline_frame to take a symbol rather
than a block.  Previously we just used the block to access the
associated function symbol.  After this commit we can just pass in the
function symbol directly, so lets do that.

New function gather_inline_frames contains some of the logic pulled
from skip_inline_frames.  This new function builds the list of all
symbols of inlined functions that start at a given $pc value and also
the "outer" function that contains all of the inlined functions.

In skip_inline_frames I've split the loop logic into two.  The loop to
build the function symbol list has moved to gather_inline_frames.  The
loop to figure out how many of the inlined functions we are skipping
remains in skip_inline_frames and uses the result of calling
gather_inline_frames.

In inline_skipped_symbol there are some minor updates to the comment,
and I've tweaked one of the asserts now that the function symbols list
also contains the "outer" function (a <= becomes <).

The maintenance_info_inline_frames function is now and implements the
new maintenance command.

And _initialize_inline_frame is updated to register the new command.

I've added a basic test for the new command.  Please excuse the file
name for the new test, in the next commit I'll be adding additional
tests and at that point the file name will make sense.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-08-28 10:30:31 +01:00
Andrew Burgess
3e9907d849 gdb: make symbols const in struct inline_state
Make the inline_state::skipped_symbols a vector of 'const symbol *',
adding the const qualifier.

There's only a couple of places this leaks into the rest of GDB and in
both places its fine for the symbol to become const.

There should be no functional change after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-08-28 10:29:43 +01:00
Andrew Burgess
a6feefa6eb Revert "gdb: remove inline_frame::skipped_frames"
This reverts commit 713e89012e.

Having inline_state::skipped_frames back will make a later patch in
this series easier.
2024-08-28 10:29:43 +01:00
GDB Administrator
934fcc7c91 Automatic date update in version.in 2024-08-28 00:00:09 +00:00
H.J. Lu
24e3920d1d x86: Report invalid TLS relocation name
Get TLS relocation name from its lex_got entry when reporting invalid
instructions with TLS relocations.

	PR gas/28595
	* config/tc-i386.c (gotrel): Moved from ...
	(lex_got): There.
	(i386_assemble): Get invalid TLS relocation name from its lex_got
	entry when reporting TLS relocation error.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-27 13:16:49 -07:00
H.J. Lu
d660d20c0c x86: Allow R_386_TLS_LE_32 with KMOVD
Since there is no TLS IE transition, allow R_386_TLS_LE_32 with KMOVD.

gas/

	PR gas/28595
	* config/tc-i386.c (i386_assemble): Remove BFD_RELOC_386_TLS_LE_32
	from TLS code check.
	* testsuite/gas/i386/inval-tls.s: Remove foo@tpoff(%eax).
	* testsuite/gas/i386/inval-tls.l: Updated.

ld/

	PR gas/28595
	* testsuite/ld-i386/i386.exp: Run tlsle1.
	* testsuite/ld-i386/tlsle1.d: New file.
	* testsuite/ld-i386/tlsle1.s: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-27 13:16:40 -07:00
Tom de Vries
fd8ec8ed82 [gdb/testsuite] Fix regexp in gdb.dwarf2/dw2-inter-cu-error.exp
In commit b5070480d7 ("[gdb/symtab] Change DWARF_ERROR from Dwarf Error to
DWARF Error") I changed the dwarf error prefix, but failed to update test-case
gdb.dwarf2/dw2-inter-cu-error.exp.

Fix this by updating the corresponding regexp in the test-case.

Tested on x86_64-linux.
2024-08-27 11:49:34 +02:00
Tom de Vries
fbf8e4c35c [gdb/python] Use GDB_PY_SET_HANDLE_EXCEPTION more often
I found a few more places where we can use GDB_PY_SET_HANDLE_EXCEPTION.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-27 09:20:18 +02:00
Tom de Vries
2f8cd40c37 [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often
I found a few more places where we can use GDB_PY_HANDLE_EXCEPTION.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-27 09:20:18 +02:00
Tom de Vries
b5070480d7 [gdb/symtab] Change DWARF_ERROR from Dwarf Error to DWARF Error
It was suggested here [1] that the canonical prefix for dwarf errors
should not be "Dwarf Error: ", given that the canonical spelling is DWARF
instead of Dwarf.

Fix this by using "DWARF Error: " instead.

Given the use of DWARF_ERROR_PREFIX, that needs to be changed only in a single
location.

Tested on x86_64-linux.

Suggested-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>

[1] https://sourceware.org/pipermail/gdb-patches/2024-August/211258.html
2024-08-27 09:08:41 +02:00
Tom de Vries
408dac3f45 [gdb/symtab] Use DWARF_ERROR_PREFIX
Result of:
...
$ sed -i 's/"Dwarf Error: /DWARF_ERROR_PREFIX\n"/' gdb/dwarf2/*
...
and manually fixing indentation.

No functional changes.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-27 09:08:41 +02:00
Tom de Vries
25cd029a62 [gdb/symtab] Add gdb/dwarf2/error.h
Add a new header file gdb/dwarf2/error.h, containing macros:
- DWARF_ERROR, and
- DWARF_ERROR_PREFIX.

The DWARF_ERROR_PREFIX is to be used in dwarf errors in a follow-up patch.

No functional changes.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-27 09:08:41 +02:00
Tom de Vries
f6f07a0b92 [gdb/symtab] Use [in module %s] notation more consistently in dwarf errors
In gdb/dwarf2/read.c, I found a few strings "in module %s":
...
$ grep "in module %s" gdb/dwarf2/read.c | fgrep -v '['
		     "DIE at %s in module %s"),
      error (_("Dwarf Error: Dummy CU at %s referenced in module %s"),
    error (_("Dwarf Error: Cannot find DIE at %s referenced in module %s"),
	error (_("Dwarf Error: DIE at %s referenced in module %s "
      error (_("Dwarf Error: Dummy CU at %s referenced in module %s"),
    error (_("Dwarf Error: Cannot find DIE at %s referenced in module %s"),
...
that are not using the commonly used "[in module %s]" notation.  Fix these.

In one case, the string was also used in the middle rather than at the end of
the message, so fix that as well.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-27 09:08:41 +02:00
Jiawei
ca2590d780 RISC-V: PR32036, Support Zcmp cm.mva01s and cm.mvsa01 instructions.
This patch supports Zcmp instruction 'cm.mva01s' and 'cm.mvsa01'.
All disassemble instructions use the sreg format.

Co-Authored by: Charlie Keaney <charlie.keaney@embecosm.com>
Co-Authored by: Mary Bennett <mary.bennett@embecosm.com>
Co-Authored by: Nandni Jamnadas <nandni.jamnadas@embecosm.com>
Co-Authored by: Sinan Lin <sinan.lin@linux.alibaba.com>
Co-Authored by: Simon Cook <simon.cook@embecosm.com>
Co-Authored by: Shihua Liao <shihua@iscas.ac.cn>
Co-Authored by: Yulong Shi <yulong@iscas.ac.cn>

gas/ChangeLog:
	PR 32036
	* NEWS: Updated.
        * config/tc-riscv.c (validate_riscv_insn): New operators.
        (riscv_ip): Ditto.
        * testsuite/gas/riscv/zcmp-mv.d: New test.
        * testsuite/gas/riscv/zcmp-mv.s: New test.

include/ChangeLog:
	PR 32036
        * opcode/riscv-opc.h (MATCH_CM_MVA01S): New opcode.
        (MASK_CM_MVA01S): New mask.
        (MATCH_CM_MVSA01): New opcode.
        (MASK_CM_MVSA01): New mask.
        (DECLARE_INSN): New declarations.
        * opcode/riscv.h (OP_MASK_SREG1): New mask.
        (OP_SH_SREG1): New operand code.
        (OP_MASK_SREG2): New mask.
        (OP_SH_SREG2): New operand code.
        (X_A0): New reg number.
        (X_A1): Ditto.
        (X_S7): Ditto.
        (RISCV_SREG_0_7): New macro function.

opcodes/ChangeLog:
	PR 32036
        * riscv-dis.c (riscv_zcmp_get_sregno): New function.
        (print_insn_args): New operators.
        * riscv-opc.c (match_sreg1_not_eq_sreg2): New match function.
2024-08-27 10:25:49 +08:00
GDB Administrator
47649afc96 Automatic date update in version.in 2024-08-27 00:00:09 +00:00
Vladimir Mezentsev
abb27dd124 Disable gprofng build for *musl*
I disable gprofng until gprofng is ported to musl.

gprofng/ChangeLog
2024-08-22  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>.

	PR gprofng/30779
	PR gprofng/29593
	PR gprofng/29477
	* configure.ac: Disable gprofng build for *musl*.
	* configure: Rebuild.
2024-08-26 13:48:29 -07:00
Tom Tromey
16ffddc6b9 Simplify ada_identical_enum_types_p
This patch changes ada_identical_enum_types_p to reuse the field names
that are computed earlier in the loop.  This is a simple cleanup, but
also is useful for a larger change that I'm working on.

Tested on x86-64 Fedora 38.
2024-08-26 13:29:04 -06:00
Mark Harmstone
91555eddd4 ld/PDB: handle pointers to members
If the CV_PTR_MODE_PMEM or CV_PTR_MODE_PMFUNC flags were set in an
LF_POINTER entry's attributes, there's a few extra bytes on the end that
we weren't accounting for.

Change handle_type so that we remap the containing_class field if it's
present, and add a test for this.
2024-08-26 16:12:52 +01:00
William Ferreira
a733b2c904 gdb: imply --once if connecting via stdio
Currently, gdbserver hangs after stdin is closed while it tries to
write: "Remote side has terminated connection.  GDBserver will reopen
the connection." This hang disappears if --once is also given. Since
the stdin connection won't ever reopen if it's closed, it's safe to
assume --once is desired.

The gdb.server/server-pipe.exp test was also updated to reflect this
change. There is now a second disconnect at the end of the proc,
with a tighter-than-normal timeout to catch if the command hangs as
it used to.

Co-Authored-By: Guinevere Larsen <blarsen@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29796

Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-26 15:45:01 +01:00
Guinevere Larsen
0891970109 Change message when reaching end of reverse history.
In a record session, when we move backward, GDB switches from normal
execution to simulation. Moving forward again, the emulation continues
until the end of the reverse history. When the end is reached, the
execution stops, and a warning message is shown. This message has been
modified to indicate that the forward emulation has reached the end, but
the execution can continue as normal, and the recording will also continue.

Before this patch, the warning message shown in that case was the same as
in the reverse case. This meant that when the end of history was reached in
either backward or forward emulation, the same message was displayed:

"No more reverse-execution history."

This message has changed for these two cases. Backward emulation:

"Reached end of recorded history; stopping.
Backward execution from here not possible."

Forward emulation:

"Reached end of recorded history; stopping.
Following forward execution will be added to history."

The reason for this change is that the initial message was deceiving, for
the forward case, making the user believe that forward debugging could not
continue.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31224
Reviewed-By: Markus T. Metzger <markus.t.metzger@intel.com> (btrace)
Approved-By: Guinevere Larsen <blarsen@redhat.com>
2024-08-26 10:33:57 -03:00
Lulu Cai
05b3e96495 LoongArch: Fix wrong relocation handling of symbols defined by PROVIDE
If the symbol defined by PROVIDE in the link script is not in SECTION,
the symbol is placed in the ABS section. The linker considers that
symbols in the ABS section do not need to calculate PC relative offsets.

Symbols in ABS sections should calculate PC relative offsets normally
based on relocations.
2024-08-26 17:25:45 +08:00
Felix Willgerodt
387f97a1b2 gdb, btrace: Fix clang build
Simon pointed out to me that there are some failures when building with clang,
that were caused by my commit

commit d894edfcc4
Author: Felix Willgerodt <felix.willgerodt@intel.com>
Date:   Mon Feb 18 13:49:25 2019 +0100

    btrace: Introduce auxiliary instructions.

The errors are:

  CXX    btrace.o
gdb/btrace.c:1203:11: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
 1203 |   return {(CORE_ADDR) insn.ip, (gdb_byte) insn.size,
      |           ^~~~~~~~~~~~~~~~~~~
      |           {                  }
gdb/btrace.c:1218:21: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
 1218 |   btrace_insn insn {btinfo->aux_data.size () - 1, 0,
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                     {                           }
gdb/btrace.c:1323:34: error: variable 'bfun' is uninitialized when used here [-Werror,-Wuninitialized]
 1323 |             handle_pt_aux_insn (btinfo, bfun, *ptw_string, pc);
      |                                         ^~~~
gdb/btrace.c:1236:35: note: initialize the variable 'bfun' to silence this warning
 1236 |       struct btrace_function *bfun;
      |                                   ^
      |                                    = nullptr
3 errors generated.
make[1]: *** [Makefile:1961: btrace.o] Error 1

This fixes those errors and switches two casts to C++ casts while we
are at it.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-08-26 09:06:42 +02:00
Alan Modra
db856d4100 PR32109, aborting at bfd/bfd.c:1236 in int _bfd_doprnt
Since bfd_section for .strtab isn't set, print the section index
instead.  Also, don't return NULL on this error as that results in
multiple mmap/read of the string table.  (We could return NULL if we
arranged to set sh_size zero first, but just what we do with fuzzed
object files is of no concern, and terminating the table might make a
faulty object file usable.)

	PR 32109
	* elf.c (bfd_elf_get_str_section): Remove outdated comment, and
	tweak shstrtabsize test to suit.  Don't use string tab bfd_section
	in error message, use index instead.  Don't return NULL on
	unterminated string section, terminate it.
	(_bfd_elf_get_dynamic_symbols): Similarly terminate string table
	section.
2024-08-26 09:40:55 +09:30
GDB Administrator
d188dec6ee Automatic date update in version.in 2024-08-26 00:00:08 +00:00
Dmitry Neverov
e814012b2b Recognize -2 as a tombstone value in .debug_line
Commit a8caed5d7f handled the tombstone
value -1 used by lld (https://reviews.llvm.org/D81784).  The
referenced lld commit also uses the tombstone value -2 for
pre-DWARF-v5
(e618ccbf43).

If not handled, -2 breaks the pc step range calculation and triggers
the assertion:

  gdb/infrun.c:2794: internal-error: resume_1: Assertion
  `pc_in_thread_step_range (pc, tp)' failed.

This commit adds -2 tombstone value and handles it in the same way as -1.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31727
Approved-By: Tom Tromey <tom@tromey.com>
2024-08-25 10:43:05 +02:00
GDB Administrator
80f2ae843a Automatic date update in version.in 2024-08-25 00:00:08 +00:00
GDB Administrator
6179272353 Automatic date update in version.in 2024-08-24 00:00:09 +00:00
Aaron Merey
aa35682ce5 gdb/dwarf2: Check for null abbrev_info ptr
A corrupt debuginfo file can result in a null abbrev_info pointer
being passed to cooked_indexer::scan_attributes.  This pointer
is set to nullptr by peek_die_abbrev when an abbrev of 0 is found.

There is no check for whether the abbrev pointer is null and
SIGSEGV occurs when attempting to dereference the pointer.

An abbrev of 0 normally indicates that the corresponding DIE is a
null entry, but scan_attributes expects a non-null DIE.

Fix this by throwing an error in cooked_indexer::scan_attributes
when peek_die_abbrev returns a nullptr in order to avoid
scan_attributes calling itself with a null abbrev.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31478
Co-authored-by: Tom de Vries <tdevries@suse.de>
Approved-By: Tom Tromey <tom@tromey.com>
2024-08-23 16:10:36 -04:00
Jan Beulich
5637daa206 x86: simplify SAE checking
To determine whether SAE (with or without StaticRounding) is permitted
there's no need to iterate over all operands. Even less so starting at
the front (thus needlessly inspecting immediate operands as well).
Leverage the pattern across all relevant templates and check only the
last two operands, and also only for non-512 ones (besides the non-LIG
case that was already checked for).
2024-08-23 09:24:10 +02:00
Jan Beulich
b67ed45877 gas: update lex_type[] also for .mri directives
Doing this just from read_begin(), i.e. merely based on command line
options, can't be sufficient (assuming it's really relevant).
2024-08-23 09:23:34 +02:00
Jan Beulich
b994624fa5 RISC-V: process rs_align_code also when relaxing
riscv_handle_align() runs after all input was processed. Whether
relaxation is enabled for any particular piece of code is not recorded
anywhere. (This issue was even "worked around" in a gas testcase, which
is adjusted accordingly.) Furthermore, as demonstrated by an ld
testcase, tail padding in an object file's executable sections depended
on whether relaxation was enabled at the end of assembly: NOPs were
emitted only when relaxation was off; zeroes were emitted with
relaxation enabled. (It could probably be either way, but it should be
independent of relaxation state at the end of assembly. Except of course
write.c, in a comment ahead of #define-ing SUB_SEGMENT_ALIGN(),
explicitly says "proper nop-filling".)

While re-indenting, drop the "odd_padding" variable. It's used exactly
once, and having the actual expression right in the if() is imo helping
readers to understand what the intentions are.

While touching the ld testcase, also tighten the expectations for the
addresses of the two symbols: The last two digits have to have fixed
values.
2024-08-23 09:22:30 +02:00
GDB Administrator
57db1af8ba Automatic date update in version.in 2024-08-23 00:00:29 +00:00
H.J. Lu
eb53cbeca8 lto: Add a test for PR ld/32083
Add a test for PR ld/32083 and xfail the test for GCC without the fix:

commit a98dd536b1017c2b814a3465206c6c01b2890998
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Aug 21 07:25:25 2024 -0700

    Update LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook

	PR ld/32083
	* testsuite/ld-plugin/common-2a.c: New file.
	* testsuite/ld-plugin/common-2b.c: Likewise.
	* testsuite/ld-plugin/lto.exp: Run PR ld/32083 test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-22 06:34:53 -07:00
Tom de Vries
573d8bb08b [gdb/symtab] Return correct reader for top-level CU in cooked_indexer::ensure_cu_exists
With the test-case included in this patch, we run into:
...
$ gdb -q -batch $exec
Dwarf Error: Could not find abbrev number 3 in CU at offset 0xdb \
  [in module $exec]
...

The debug info consists of two CUs:
...
  Compilation Unit @ offset 0xb2:
   Length:        0x25 (32-bit)
   Version:       4
   Abbrev Offset: 0x6c
   Pointer Size:  8
 <0><bd>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <be>   DW_AT_language    : 2	(non-ANSI C)
 <1><bf>: Abbrev Number: 2 (DW_TAG_subprogram)
    <c0>   DW_AT_low_pc      : 0x4004a7
    <c8>   DW_AT_high_pc     : 0x4004b2
    <d0>   DW_AT_specification: <0xe8>
 <1><d4>: Abbrev Number: 3 (DW_TAG_subprogram)
    <d5>   DW_AT_name        : main
 <1><da>: Abbrev Number: 0
  Compilation Unit @ offset 0xdb:
   Length:        0xf (32-bit)
   Version:       4
   Abbrev Offset: 0x86
   Pointer Size:  8
 <0><e6>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <e7>   DW_AT_language    : 2	(non-ANSI C)
 <1><e8>: Abbrev Number: 2 (DW_TAG_subprogram)
    <e9>   DW_AT_specification: <0xd4>
 <1><ed>: Abbrev Number: 0
...
where:
- DIE 0xbf in CU@0xb2 contains an inter-CU reference to
- DIE 0xe8 in CU@0xdb, which contains an inter-CU reference to
- DIE 0xd4 back in CU@0xb2.

The dwarf error is caused by this bit of code in
cooked_indexer::ensure_cu_exists:
...
  if (per_cu == m_per_cu)
    return reader;
...

The dwarf error happens as follows:
- a cutu_reader A is created for CU@0xb2
- using cutu_reader A, the cooked index reader starts indexing dies, with
  m_per_cu set to CU@0xb2
- while indexing it scans the attributes of DIE 0xbf and encounters the
  inter-CU reference to DIE 0xe8
- it calls cooked_indexer::ensure_cu_exists, which creates a cutu_reader B for
  CU@0xdb and returns it
- using cutu_reader B, it continues scanning attributes of DIE 0xe8 and
  encounters the inter-CU reference to DIE 0xd4
- it calls cooked_indexer::ensure_cu_exists, the problematic bit is triggered
  and cutu_reader B is returned
- using cutu_reader B, it continues scanning attributes of DIE 0xd4
- this goes wrong because:
  - the attributes of the DIE are encoded using the abbreviation table at
    offset 0x6c, while
  - the decoding is done using cutu_reader B which uses the abbreviation table
    at offset 0x86.

Fix this by removing the problematic if clause.

Since cutu_reader A is not preserved in m_index_storage,
cooked_indexer::ensure_cu_exists cannot find it there and creates a duplicate
cutu_reader C for CU@0xb2.  Fix this in process_psymtab_comp_unit by preserving
the cutu_reader A as well in m_index_storage.

Tested on x86_64-linux and aarch64-linux.

PR symtab/32081
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32081

Approved-By: Tom Tromey <tom@tromey.com>
Reported-By: Andreas Schwab <schwab@linux-m68k.org>
2024-08-22 10:00:27 +02:00
Tom de Vries
50f8a39878 [gdb] Add const to catch gdb_exception
I did a review of lines containing "catch (gdb_exception" and found a few
where we can add const.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-22 09:49:53 +02:00
Tom de Vries
365b32b9c7 [gdb/python] Eliminate catch(...) in type_to_type_object
In type_to_type_object we have:
...
  try
    {
      if (type->is_stub ())
	type = check_typedef (type);
    }
  catch (...)
    {
      /* Just ignore failures in check_typedef.  */
    }
...

The catch is supposed to ignore gdb_exception_error, but it ignores any
exception.

Fix that by only ignoring gdb_exception_error, and handling
gdb_exception_quit / gdb_exception_forced_quit using GDB_PY_HANDLE_EXCEPTION.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-22 09:49:53 +02:00
Tom de Vries
7812541722 [gdb] Add & in catch in svr4_handle_solib_event
In svr4_handle_solib_event I noticed:
...
	catch (const gdb_exception_error)
...

This seems to be the only place were we do this, elsewhere we have:
...
	catch (const gdb_exception_error &)
...

I suppose the intent of adding '&' is to avoid a copy.  I'm not sure if it's
necessary given that it's an unnamed const parameter, but I suppose it can't
hurt either.

Add the '&' here as well.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-22 09:49:53 +02:00
Tom de Vries
a16c032a5c [gdb] Eliminate catch(...) in get_test_insn
In get_test_insn in gdb/disasm-selftests.c, we find this code:
...
            try
              {
                kind = gdbarch_breakpoint_kind_from_pc (gdbarch, &pc);
                insn = gdbarch_sw_breakpoint_from_kind (gdbarch, kind, &bplen);
              }
            catch (...)
              {
                continue;
              }
...

The catch is there to catch memory errors, but it swallows all exceptions, including
gdb_exception_quit and gdb_exception_forced_quit.

Fix this by limiting the catch to gdb_exception_error.

Tested on x86_64-linux, by rebuilding and running gdb.gdb/unittest.exp.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-22 09:49:53 +02:00
Sam James
1ebf4606c2
gprofng: testsuite: fix 'wrapper' typo
gprofng/ChangeLog
            * testsuite/config/default.exp: Fix 'wrapper' typo.
2024-08-22 04:15:16 +01:00
GDB Administrator
622be1889a Automatic date update in version.in 2024-08-22 00:00:35 +00:00
Simon Marchi
57a91ca28f gdb: some global_block improvements
Some refactors around struct global_block, all in one patch because they
all tie in together and are relatively trivial.

 - Make block::global_block() and blockvector::global_block() return
   `global_block *`, instead of `block *`.  There is no cost in doing
   so, and it's a bit more precise.  Callers of these methods that need
   a `global_block *` won't need to cast themselves.

 - Add some block::as_global_block methods, as a way to get a
   `global_block *` from a `block *` when you know it's a global block.
   This is basically a static cast with an assert.

 - Move set_compunit_symtab to global_block, since it requires the
   block to be a global block anyway.  Rename to just `set_compunit` (I
   think that compunit_symtab should just be renamed compunit...).

 - Move the get_block_compunit_symtab free function to be a method of
   global_block.

 - Make global_block::compunit_symtab private and rename.

 - Simplify initialize_block_iterator.

Change-Id: I1667a86b5c1a02d0d460cfad55b5d3d48867583d
Approved-By: Tom Tromey <tom@tromey.com>
2024-08-21 15:38:11 -04:00
Tom Tromey
5d683ae3da Do not assume ELF in dwarf2/read.c
dwarf2/read.c has this code:

  else if (elf_section_data (sectp)->this_hdr.sh_size
	   > bfd_get_file_size (abfd))

This assumes that the BFD is an ELF, which is an invalid assumption.
A user noticed that this can sometimes cause a crash.

This patch fixes the problem by changing this code to use
bfd_section_size_insane.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32104
Reviewed-By: Tom de Vries <tdevries@suse.de>
Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-21 10:33:46 -06:00
GDB Administrator
28c3bf55f0 Automatic date update in version.in 2024-08-21 00:00:30 +00:00
Andrew Burgess
40a1603112 gdb/testsuite: track nested caching proc calls
It was pointed out in this email:

  https://inbox.sourceware.org/gdb-patches/97973506-79f4-4216-9c0b-57401b3933f5@arm.com

that this commit:

  commit 0726729d34
  Date:   Mon Jun 3 13:56:54 2024 +0100

      gdb/testsuite: track if a caching proc calls gdb_exit or not

had broken some AArch64 tests.

What is going on is that there are two caching procs:

  allow_aarch64_sme_tests
  aarch64_initialize_sme_information

the allow_aarch64_sme_tests proc makes a call to
aarch64_initialize_sme_information, but
aarch64_initialize_sme_information is also called from other
non-caching procs, like aarch64_supports_sme_svl.

Both of the caching procs mentioned above compile and run a helper
program, and both of them call gdb_exit.

After the above commit, the first call to any caching proc, the body
of which calls gdb_exit, will result in a gdb_exit call even if the
body is not executed and the result is fetched from the cache.

What was observed is that in the first test script
allow_aarch64_sme_tests is called, the body of this caching proc is
run which calls gdb_exit.  Then allow_aarch64_sme_tests calls
aarch64_initialize_sme_information, the body of which is run and
gdb_exit is called again.  The results from both procs are added to
the cache.

In the next test script allow_aarch64_sme_tests is called.  This
results in a cache hit, but gdb_exit is also called as this is the
first call in this second test script.

Later in the test script aarch64_supports_sme_svl is called which
calls aarch64_initialize_sme_information.  As this is the first call
to aarch64_initialize_sme_information in this second test
script (remember the body of allow_aarch64_sme_tests was never run)
then gdb_exit is called.  This call to gdb_exit is new after the above
commit and is unexpected.

I think the idea behind the above commit is still sound.  If the call
to allow_aarch64_sme_tests was removed from the second test script
then we would want the extra gdb_exit call as this would expose a real
bug in the test.  The problem is that after the above commit the
nested nature of the caching proc calls becomes important: a call to
allow_aarch64_sme_tests should mean that we've also called
aarch64_initialize_sme_information, and that relationship isn't
currently captured.

So in this commit I'm adding another field to the global
gdb_data_cache (in lib/cache.exp).  This new field is 'also_called'.
For every caching proc we populate this field with a list of names,
these are the names of any nested caching procs that are called when
the body of a caching proc is executed.

Now when we get a cache hit in gdb_data_cache we mark every proc in
the 'also_called' list as having been called.  This means that further
calls to these procs will no longer trigger a gdb_exit call.

Approved-By: Luis Machado <luis.machado@arm.com>
Tested-By: Luis Machado <luis.machado@arm.com>
2024-08-20 15:44:51 +01:00
Tom Tromey
be14b683af Fix Windows regression
commit cb9f919f ("gdb: add program_space parameter to
lookup_minimal_symbol_text") caused a crash on Windows.  In this
function, section can be nullptr, but it is unconditionally
dereferenced by the change introduced by the patch.

I tested this using the AdaCore internal test suite.

v2: always use current_program_space, reverting to be behavior before
cb9f919f.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-08-20 08:31:35 -06:00