Commit Graph

112135 Commits

Author SHA1 Message Date
Simon Marchi
9df9cfe23c gdb/testsuite/gdb.base/break.exp: split test_break_default
One special thing here is that the part just above this one, that sets
catchpoints and verifies they are not hit, requires that we resume
execution to verify that the catchpoints are indeed not hit.   I guess
it was previously achieved by the until command, but it doesn't happen
now that the until is moved into test_break_default.  Add a
gdb_continue_to_end after setting the catchpoints.  If any catchpoint
were to be hit, it would catch the problem.

Change-Id: I5d4b43da91886b1beda9f6e56b05aa04331a9c05
Approved-By: Kevin Buettner <kevinb@redhat.com>
2022-11-24 10:22:40 -05:00
Simon Marchi
c8a48df4f1 gdb/testsuite/gdb.base/break.exp: split test_break_silent_and_more
This one is a bit tricky.  The clear tests seem to depend on the various
breakpoints that have been set before, starting with the "silent"
breakpoints.  So, move all this in a single chunk, it can always be
split later if needed.

Change-Id: I7ba61a5b130ade63eda0c4790534840339f8a72f
Approved-By: Kevin Buettner <kevinb@redhat.com>
2022-11-24 10:22:40 -05:00
Simon Marchi
e89425fec2 gdb/testsuite/gdb.base/break.exp: split test_break_line_convenience_var
Change-Id: I593002373da971a0a4d6b5355d3fe321873479ab
Approved-By: Kevin Buettner <kevinb@redhat.com>
2022-11-24 10:22:40 -05:00
Simon Marchi
3ad8183797 gdb/testsuite/gdb.base/break.exp: split test_break_user_call
Change-Id: I9151ce9db9435722b758f41c6606b461bf15f320
Approved-By: Kevin Buettner <kevinb@redhat.com>
2022-11-24 10:22:40 -05:00
Simon Marchi
2994ead4a0 gdb/testsuite/gdb.base/break.exp: split test_finish_arguments
Change-Id: Id84babed1eeb3ce7d14b94ff332795964e8ead51
Approved-By: Kevin Buettner <kevinb@redhat.com>
2022-11-24 10:22:40 -05:00
Simon Marchi
13375d621e gdb/testsuite/gdb.base/break.exp: use proc_with_prefix for test_next_with_recursion
This one is already in a proc, just make the proc use proc_with_prefix,
for consistency.

Change-Id: I313ecf5097ff04526c29396529baeba84e37df5a
Approved-By: Kevin Buettner <kevinb@redhat.com>
2022-11-24 10:22:40 -05:00
Simon Marchi
01e43c20bb gdb/testsuite/gdb.base/break.exp: split test_break_optimized_prologue
Change-Id: Ibf17033c8ce72aa5cfe1b739be2902e84a5e945d
Approved-By: Kevin Buettner <kevinb@redhat.com>
2022-11-24 10:22:40 -05:00
Simon Marchi
45c4b4bc12 gdb/testsuite/gdb.base/break.exp: split test_rbreak_shlib
Change-Id: I130e8914c2713095aab03e84aba1481b4c7af978
Approved-By: Kevin Buettner <kevinb@redhat.com>
2022-11-24 10:22:40 -05:00
Simon Marchi
b6cb5e17b8 gdb/testsuite/gdb.base/break.exp: split test_break_file_line_convenience_var
Change-Id: I0c31b037669b2917e062bf431372fb6531f8f53c
Approved-By: Kevin Buettner <kevinb@redhat.com>
2022-11-24 10:22:40 -05:00
Simon Marchi
4d70f72ee0 gdb/testsuite/gdb.base/break.exp: split test_break_commands_clear
Change-Id: Ia58f90117d52fc419fc494836d9b4ed5d902fe9b
Approved-By: Kevin Buettner <kevinb@redhat.com>
2022-11-24 10:22:40 -05:00
Nick Clifton
0075c53724 Impport libiberty commit: 885b6660c17f from gcc mainline. Fix gas's acinclude.m4 to stop a potwntial configure time warning message. 2022-11-24 12:31:46 +00:00
Martin Liska
ffbbab0b3a readelf: Do not require EI_OSABI for IFUNC.
PR 29718

binutils/ChangeLog:

	* readelf.c (get_symbol_type): Consider STT_GNU_IFUNC as
	reserved name.
2022-11-24 13:18:36 +01:00
Jan Beulich
8ee52bcf39 x86: widen applicability and use of CheckRegSize
First of all make operand_type_register_match() apply to all sized
operands, i.e. in Intel Syntax also to respective memory ones. This
addresses gas wrongly accepting certain SIMD insns where register and
memory operand sizes should match but don't. This apparently has
affected all templates with one memory-only operand and one or more
register ones, both permitting at least two sizes, due to CheckRegSize
not taking effect.

Then also add CheckRegSize to a couple of non-SIMD templates matching
that same pattern of memory-only vs register operands. This replaces
bogus (for Intel Syntax) diagnostics referring to a wrong suffix (when
none was used at all) by "type mismatch" ones, just like already emitted
for insns where the template allows a register operand alongside a
memory one at any particular position.

This also is a prereq to limiting (ideally eliminating in the long run)
suffix "derivation" in Intel Syntax mode.

While making the code adjustment also flip order of checks to do the
cheaper one first in both cases.
2022-11-24 09:35:51 +01:00
Jan Beulich
a122baf523 x86: add missing CheckRegSize
To properly and predictably determine operand size encoding (operand
size or REX.W prefixes), consistent operand sizes need to be specified.
Add CheckRegSize where this was previously missing.
2022-11-24 09:35:17 +01:00
Jan Beulich
c9f5b96bda x86: correct handling of LAR and LSL
Both uniformly only ever take 16-bit memory operands while at the same
time requiring matching (in size) register operands, which then also
should disassemble that way. This in particular requires splitting each
of the templates for the assembler and separating decode of the
register and memory forms in the disassembler.
2022-11-24 09:34:52 +01:00
Alan Modra
bde9f9d7e9 Tidy objdump printing of section size
* objdump.c (load_specific_debug_section): Use PRIx64 format.
2022-11-24 17:45:52 +10:30
Alan Modra
5ee755fabb Constify nm format array
* nm.c (formats, format): Make const.
2022-11-24 17:45:52 +10:30
Alan Modra
0b075f1902 PR16995, m68k coldfire emac immediate to macsr incorrect disassembly
Mode/reg bits for these insns are 000 Dy, 001 Ay, and 111 100 for the
move immediate.

	* m68k-opc.c (m68k_opcodes): Only accept 000 and 001 as mode
	for move reg to macsr/mask insns.
2022-11-24 17:45:52 +10:30
Mark Harmstone
0b7186b9e8 gas: Disable --gcodeview on PE targets with no O_secrel 2022-11-24 03:20:14 +00:00
GDB Administrator
26314ac7ad Automatic date update in version.in 2022-11-24 00:00:46 +00:00
Torbjörn SVENSSON
8db533e7d6 gdb/arm: Include FType bit in EXC_RETURN pattern on v8m
For v8m, the EXC_RETURN pattern, without security extension, consists of
FType, Mode and SPSEL.  These are the same bits that are used in v7m.
This patch extends the list of patterns to include also the FType bit
and not just Mode and SPSEL bits for v8m targets without security
extension.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2022-11-23 14:19:04 +01:00
Alan Modra
9bd83c444e regen POTFILES.in 2022-11-23 22:38:48 +10:30
Alan Modra
e6b6fad2fe PR22509 - Null pointer dereference on coff_slurp_reloc_table
This extends the commit 4581a1c7d3 fix to more targets, which
hardens BFD a little.  I think the real underlying problem was the
bfd_canonicalize_reloc call in load_specific_debug_section which
passed a NULL for "symbols".  Fix that too.

	PR 22509
bfd/
	* aoutx.h (swap_ext_reloc_out): Gracefully handle NULL symbols.
	* i386lynx.c (swap_ext_reloc_out): Likewise.
	* pdp11.c (pdp11_aout_swap_reloc_out): Likewise.
	* coff-tic30.c (reloc_processing): Likewise.
	* coff-tic4x.c (tic4x_reloc_processing): Likewise.
	* coff-tic54x.c (tic54x_reloc_processing): Likewise.
	* coff-z80.c (reloc_processing): Likewise.
	* coff-z8k.c (reloc_processing): Likewise.
	* ecoff.c (ecoff_slurp_reloc_table): Likewise.
	* som.c (som_set_reloc_info): Likewise.
binutils/
	* objdump.c (load_specific_debug_section): Pass syms to
	bfd_canonicalize_reloc.
2022-11-23 22:38:48 +10:30
Alan Modra
d499fb8944 asan: NULL deref in filter_symbols
If tdata->symbols is NULL, make tdata->symcount zero too.  This makes
wasm_get_symtab_upper_bound return the proper result and stops
cascading errors.

	* wasm-module.c (wasm_scan_name_function_section): Clear
	tdata->symcount on error.
2022-11-23 22:38:48 +10:30
Luis Machado
8181f0045d Document the memory_tagged argument for memory region callbacks
There were no comments in some instances (gdb/defs.h, gdb/core.c and
gdb/linux-tdep.c), so address that by adding comments where those are missing.
2022-11-23 09:45:48 +00:00
Tom de Vries
829b6b3736 Fix gdb.cp/gdb2495.exp on powerpc64le
On powerpc64le-linux I ran into this FAIL:
...
(gdb) p exceptions.throw_function()^M
terminate called after throwing an instance of 'int'^M
^M
Program received signal SIGABRT, Aborted.^M
0x00007ffff7979838 in raise () from /lib64/libc.so.6^M
The program being debugged was signaled while in a function called from GDB.^M
GDB remains in the frame where the signal was received.^M
To change this behavior use "set unwindonsignal on".^M
Evaluation of the expression containing the function^M
(SimpleException::throw_function()) will be abandoned.^M
When the function is done executing, GDB will silently stop.^M
(gdb) FAIL: gdb.cp/gdb2495.exp: call a function that raises an exception \
  without a handler.
...

The following happens:
- we start an inferior call
- an internal breakpoint is set on the global entry point of std::terminate
- the inferior call uses the local entry point
- the breakpoint is not triggered
- we run into std::terminate

We can fix this by simply adding the missing gdbarch_skip_entrypoint call in
create_std_terminate_master_breakpoint, but we try to do this a bit more
generic, by:
- adding a variant of function create_internal_breakpoint which takes a
  minimal symbol instead of an address as argument
- in the new function:
  - using both gdbarch_convert_from_func_ptr_addr and gdbarch_skip_entrypoint
  - documenting why we don't need to use gdbarch_addr_bits_remove
  - adding a note about possibly
    needing gdbarch_deprecated_function_start_offset.
- using the new function in:
  - create_std_terminate_master_breakpoint
  - create_exception_master_breakpoint_hook, which currently uses only
    gdbarch_convert_from_func_ptr_addr.

Note: we could use the new function in more locations in breakpoint.c, but
as we're not aware of any related failures, we declare this out of scope for
this patch.

Tested on x86_64-linux, powerpc64le-linux.

Co-Authored-By: Ulrich Weigand <uweigand@de.ibm.com>
Tested-by: Carl Love <cel@us.ibm.com>
PR tdep/29793
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29793
2022-11-23 06:52:42 +01:00
Xiao Zeng
06f0a892a5 RISC-V: Make R_RISCV_SUB6 conforms to riscv ABI standard
According to the riscv psabi, R_RISCV_SUB6 only allows 6 least significant
bits are valid, but since binutils implementation, we usually get 8 bits
field for it.  That means, the high 2 bits could be other field and have
different purpose.  Therefore, we should filter the 8 bits to 6 bits before
calculate, and then only encode the valid 6 bits back.  By the way, we also
need the out-of-range check for R_RISCV_SUB6, and the overflow checks for
all R_RISCV_ADD/SUB/SET relocations, but we can add them in the future patches.

Passing riscv-gnu-toolchain regressions.

bfd/ChangeLog:

        * elfnn-riscv.c (riscv_elf_relocate_section): Take the R_RISCV_SUB6
	lower 6 bits as the significant bit.
        * elfxx-riscv.c (riscv_elf_add_sub_reloc): Likewise.
2022-11-23 10:46:16 +08:00
Mark Harmstone
ba64682044 gas: Add --gcodeview option 2022-11-23 02:22:48 +00:00
Mark Harmstone
e2a1b0a0d1 ld: Add section contributions substream to PDB files 2022-11-23 01:13:35 +00:00
GDB Administrator
c392c0e0ae Automatic date update in version.in 2022-11-23 00:00:43 +00:00
John Baldwin
d818c7ad8c aarch64-fbsd: Use a static regset for the TLS register set.
This uses custom collect/supply regset handlers which pass the TLS
register number from the gdbarch_tdep as the base register number.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-11-22 14:42:17 -08:00
John Baldwin
759bbcb917 arm-fbsd: Use a static regset for the TLS register set.
This uses custom collect/supply regset handlers which pass the TLS
register number from the gdbarch_tdep as the base register number.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-11-22 14:39:53 -08:00
John Baldwin
a141d32c6e fbsd-nat: Pass an optional register base to the register set helpers.
This is needed to permit using the helpers for register sets with a
variable base.  In particular regnum needs to be converted into a
relative register number before passed to regcache_map_supplies.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-11-22 14:35:31 -08:00
John Baldwin
5dd6c79a32 fbsd-nat: Use regset supply/collect methods.
fbsd-nat includes various helper routines for fetching and storing
register sets via ptrace where the register set is described by a
regset.  These helper routines directly invoke the
supply/collect_regset regcache methods which doesn't permit a regset
to provide custom logic when fetching or storing a register set.
Instead, just use the function pointers from the struct regset
directly.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-11-22 14:34:46 -08:00
John Baldwin
0ee9f16cf9 regcache: Add collect/supply_regset variants that accept a register base.
Some register sets described by an array of regcache_map_entry
structures do not have fixed register numbers in their associated
architecture but do describe a block of registers whose numbers are at
fixed offsets relative to some base register value.  An example of
this are the TLS register sets for the ARM and AArch64 architectures.

Currently OS-specific architectures create register maps and register
sets dynamically using the register base number.  However, this
requires duplicating the code to create the register map and register
set.  To reduce duplication, add variants of the collect_regset and
supply_regset regcache methods which accept a base register number.
For valid register map entries (i.e. not REGCACHE_MAP_SKIP), add this
base register number to the value from the map entry to determine the
final register number.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-11-22 14:33:17 -08:00
H.J. Lu
04ad71937f x86: Don't define _TLS_MODULE_BASE_ for ld -r
bfd/

	PR ld/29820
	* elfxx-x86.c (_bfd_x86_elf_always_size_sections): Don't define
	 _TLS_MODULE_BASE_ for ld -r.

ld/

	PR ld/29820
	* testsuite/ld-x86-64/pr29820.d: New file.
	* testsuite/ld-x86-64/pr29820.s: Likewise.
	* testsuite/ld-x86-64/x86-64.ex: Run pr29820.
2022-11-22 14:03:16 -08:00
Alan Modra
26c527e62e Don't use "long" in readelf for file offsets
The aim here is to improve readelf handling of large 64-bit object
files on LLP64 hosts (Windows) where long is only 32 bits.  The patch
changes more than just file offsets.  Addresses and sizes are also
changed to avoid "long".  Most places get to use uint64_t even where
size_t may be more appropriate, because that allows some overflow
checks to be implemented easily (*alloc changes).

	* dwarf.c (cmalloc, xcmalloc, xcrealloc, xcalloc2): Make nmemb
	parameter uint64_t.
	* dwarf.h: Update prototypes.
	(struct dwarf_section): Make num_relocs uint64_t.
	* elfcomm.c (setup_archive): Update error format.
	* elfcomm.h (struct archive_info): Make sym_size, longnames_size,
	nested_member_origin, next_arhdr_offset uint64_t.
	* readelf.c (struct filedata): Make archive_file_offset,
	archive_file_size, string_table_length, dynamic_addr,
	dynamic_nent, dynamic_strings_length, num_dynamic_syms,
	dynamic_syminfo_offset uint64_t.
	(many functions): Replace uses of "unsigned long" with
	"uint64_t" or "size_t".
2022-11-23 07:53:13 +10:30
Alan Modra
63cf857e24 Re: readelf: use fseeko64 or fseeko if possible
Replace the macros with a small wrapper function that verifies the fseek
offset arg isn't overlarge.

	* readelf.c (FSEEK_FUNC): Delete, replace uses with..
	(fseek64): ..this new function.
	(process_program_headers): Don't cast p_offset to long.
2022-11-23 07:51:41 +10:30
Torbjörn SVENSSON
f3f7ecc942 gdb/arm: Fix obvious typo in b0b23e06c3
As part of the rebase of the patch, I managed to loose the local
changes I had for the comments from Tomas in
https://sourceware.org/pipermail/gdb-patches/2022-November/193413.html
This patch corrects the obvious two typos.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2022-11-22 19:17:27 +01:00
Michael Matz
d7229d6a56 binutils/configure.ac: integrate last change
Integrate back checks for fseeko{,64} into configure.ac, so
that regeneration works.

binutils/
	* configure.ac: Add fseeko, fseeko64 checks.
	* configure: Regenerate.
2022-11-22 14:39:39 +01:00
Shahab Vahedi
b2059307d8 opcodes: Correct address for ARC's "isa_config" aux reg
This patch changes the address for "isa_config" auxiliary register
from 0xC2 to the correct value 0xC1.  Moreover, it only exists in
arc700+ and not all ARCs.

opcodes/ChangeLog:

	* arc-regs.h: Change isa_config address to 0xc1.
	isa_config exists for ARC700 and ARCV2 and not ARCALL.
2022-11-22 12:59:32 +01:00
Bruno Larsen
dc95ee260c gdb/testsuite: remove gcc restriction from gdb.dwarf2/clang-cli-macro.exp
With the recent changes to the dwarf assembler, there is no longer a
need to test for gcc in gdb.dwarf2/clang-cli-macro.exp and mark it as
untested. This commit removes that logic.
2022-11-22 11:23:08 +01:00
Jan Beulich
3238a75075 gas/sframe: avoid "shadowing" of glibc function name
Once again: Old enough glibc has an (unguarded) declaration of index()
in string.h, which triggers a "shadows a global declaration" warning
with our choice of wanring level and with at least some gcc versions.
2022-11-22 09:39:44 +01:00
GDB Administrator
31c1130f35 Automatic date update in version.in 2022-11-22 00:00:39 +00:00
Brett Werling
d82e33decc readelf: use fseeko64 or fseeko if possible
Changes readelf to make use first of fseeko64 and then fseeko,
depending on which of those is available. If neither is available,
reverts to the previous behavior of using fseek.

This is necessary when building readelf for LLP64 systems, where a
long will only be 32 bits wide. If the elf file in question is >= 2 GiB,
that is greater than the max long value and therefore fseek will fail
indicating that the offset is negative. On such systems, making use of
fseeko64 or fseeko will result in the ability so seek past the 2 GiB
max long boundary.

Note that large archive handling in readelf remains to be fixed.
2022-11-22 08:19:27 +10:30
Alan Modra
38c917d808 PR29807, SIGSEGV when linking fuzzed PE object
PR 29807
	* cofflink.c (_bfd_coff_generic_relocate_section): Skip relocs
	against symbols with a NULL section.
2022-11-22 08:18:49 +10:30
Alan Modra
e9a20a419b Re: ld: Always output local symbol for relocatable link
Remove this code dating back to commit 98790d3a95 entirely, what it
was trying to do is done elsewhere.

	PR ld/29761
	* elflink.c (elf_link_output_symstrtab): Don't handle symbols
	in SEC_EXCLUDE sections here.
2022-11-22 07:49:23 +10:30
Philippe Waroquiers
28a072f4af When getting the locno of a bpstat, handle the case of bp with null locations.
The test py-objfile.exp unloads the current file while debugging the process.
This results in bpstat bs->b->loc to become nullptr.
Handle this case in breakpoint.c:bpstat_locno.

Note: GDB crashes on this problem with an internal error,
but the end of gdb summary shows:
  ...
                  === gdb Summary ===

  # of expected passes		36

The output also does not contain a 'FAIL:'.
After the fix, the nr of expected passes increased.

In the gdb.log output, one can see:
  ...
  Fatal signal: Segmentation fault
  ----- Backtrace -----
  0x55698905c5b9 gdb_internal_backtrace_1
          ../../binutils-gdb/gdb/bt-utils.c:122
  0x55698905c5b9 _Z22gdb_internal_backtracev
  ...

  ERROR: Couldn't send python print(objfile.filename) to GDB.
  ERROR: : spawn id exp9 not open
      while executing
  "expect {
  -i exp9 -timeout 10
          -re ".*A problem internal to GDB has been detected" {
              fail "$message (GDB internal error)"
              gdb_internal_error..."
      ("uplevel" body line 1)
      invoked from within
  ....

Wondering if it might be possible to improve gdb_test to have
  gdb_test "python print(objfile.filename)" "None" \
      "objfile.filename after objfile is unloaded"
reporting a failed result instead of just producing the internal error.
2022-11-21 21:16:12 +01:00
Philippe Waroquiers
83f350830e Fix use after free introduced by $_hit_bpnum/$_hit_locno variables.
If the commands of the bpstat bs contain commands such as step or next or
continue, the BS and its commands are freed by execute_control_command.

So, we cannot remember the BS that was printed. Instead, remember
the bpnum and locno.

Regtested on debian/amd64 and re-run a few tests under valgrind.
2022-11-21 21:15:20 +01:00
Philippe Waroquiers
e66c9edea3 Fix step-over-syscall.exp matching regexp for $bpnum.$locno matching
step-over-syscall.exp has some specific tests for gdbserver.
The regexp matching breakpoint hit must take the added locno into account.

Test re-run in 3 modes (normal, native-gdbserver and native-extended-gdbserver).
2022-11-21 21:06:26 +01:00