Commit Graph

118468 Commits

Author SHA1 Message Date
Tom de Vries
e6a0a281a0 [gdb/testsuite] Fix gdb.threads/threadcrash.exp with glibc debuginfo
After installing glibc debuginfo, I ran into:
...
FAIL: gdb.threads/threadcrash.exp: test_live_inferior: \
  $thread_count == [llength $test_list]
...

This happens because the clause:
...
	-re "^\r\n${hs}main$hs$eol" {
...
which is intended to match only:
...
 #1  <hex> in main () at threadcrash.c:423^M
...
also matches "remaining" in:
...
 #1  <hex> in __GI___nanosleep (requested_time=<hex>, remaining=<hex>) at \
   nanosleep.c:27^M
...

Fix this by checking for "in main" instead.

Tested on x86_64-linux.
2024-04-24 15:36:02 +02:00
Nick Clifton
3b3e209011 Update readelf's display of RELR sections to include the number of locations relocated 2024-04-24 12:45:04 +01:00
Simon Marchi
1a7f925ea2 gdb: include extract-store-integer.h in charset.c when PHONY_ICONV
When building on a system where "phony iconv" is used (NetBSD in this
case, not sure why), I get:

      CXX    charset.o
    /home/smarchi/src/binutils-gdb/gdb/charset.c: In function 'size_t phony_iconv(int, const char**, size_t*, char**, size_t*)':
    /home/smarchi/src/binutils-gdb/gdb/charset.c:140:8: error: 'extract_unsigned_integer' was not declared in this scope
          = extract_unsigned_integer ((const gdb_byte *)*inbuf, 4, endian);
            ^~~~~~~~~~~~~~~~~~~~~~~~
    /home/smarchi/src/binutils-gdb/gdb/charset.c:140:8: note: suggested alternative: 'btrace_insn_number'
          = extract_unsigned_integer ((const gdb_byte *)*inbuf, 4, endian);
            ^~~~~~~~~~~~~~~~~~~~~~~~
            btrace_insn_number

Add the necessary include.

Change-Id: I10b967584645961c86167a8395d88929a42bef03
2024-04-24 03:01:21 +00:00
Alan Modra
bfe6fb329a PPC maintainers
I'm retiring from IBM, and Geoff hasn't been active for a very long
time.

	* MAINTAINERS (ppc): Remove myself and Geoff Keating.  Add
	Geoff to past maintainers.
2024-04-24 11:08:01 +09:30
Alan Modra
122f6f14b1 buffer overflow in libctf tests
* testsuite/libctf-regression/gzrewrite.c (main): Don't overflow
       "a" buffer in "after adding types" check.
       * testsuite/libctf-regression/zrewrite.c (main): Likewise.
2024-04-24 09:33:03 +09:30
GDB Administrator
d65decae83 Automatic date update in version.in 2024-04-24 00:00:07 +00:00
Simon Marchi
c527001f38 gdb: adjust copyright years of extract-store-integer.{c,h}
The contents of these files was copied from defs.h and findvar.  Copy
over the copyright years (1986-2024).

Change-Id: Idfb0f255fbcfda7e107e9a82804cece3d81ed5fc
2024-04-23 16:16:37 -04:00
Claudio Bantaloukas
3e562e4be8 arm: Fix MVE vmla encoding 2024-04-23 17:59:57 +01:00
Olivier Hainque
9b441c415c bfd: Remove duplicate word in elf-vxworks.c
PR ld/31652
	* elf-vxworks.c  (elf_vxworks_emit_relocs): Drop duplicate word.
2024-04-23 08:53:42 -07:00
H.J. Lu
6c2119acf7 objcopy.c: Fix bfd_copy_private_symbol_data on 32-bit hosts
Use long with bfd_copy_private_symbol_data to fix

.../binutils/objcopy.c: In
function ‘copy_object’:
.../binutils/objcopy.c:3383:17: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘long int’ [-Werror=sign-compare]
 3383 |   for (i = 0; i < symcount; i++)
      |                 ^

on 32-bit hosts.

	PR binutils/14493
	* objcopy.c (copy_object): Use long with
	bfd_copy_private_symbol_data.
2024-04-23 08:30:20 -07:00
Simon Marchi
9085a018ca gdb: move symbol_file_command declaration to symfile.h
Move it out of defs.h, the corresponding definition is in symfile.c.

Change-Id: I984666c3bcd213f8574e9ec91462e1d61f77f16b
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-23 11:26:14 -04:00
Simon Marchi
cbf58b22f7 gdb: remove enum precision_type
It is unused.

Change-Id: Ic49a3ef03c21b209594cd567ae80b5441606bef6
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-23 11:26:14 -04:00
Simon Marchi
dcff5e80e6 gdb: move annotation_level declaration/definition to annotate.{h,c}
The declaration of annotation_level is currently in defs.h, while the
definition is in stack.c.  I don't really understand why that variable
would live in stack.c, it seems completely unrelated.  Move it to
annotate.c, and move the declaration to annotate.h.

Change-Id: I6cf8e9bd20e83959bdf5ad58dd008b6e1187d7d8
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-23 11:26:14 -04:00
Simon Marchi
e5dc0d5d04 gdb: move a bunch of quit-related things to event-top.{c,h}
Move some declarations related to the "quit" machinery from defs.h to
event-top.h.  Most of the definitions associated to these declarations
are in event-top.c.  The exceptions are `quit()` and `maybe_quit()`,
that are defined in utils.c.  For consistency, move these two
definitions to event-top.c.

Include "event-top.h" in many files that use these things.

Change-Id: I6594f6df9047a9a480e7b9934275d186afb14378
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-23 11:26:14 -04:00
Simon Marchi
4111db1af3 gdb: change type of quit_flag to bool
Change-Id: I7dc5189ee172e82ef5b2c4a739c011f43a84258b
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-23 11:26:14 -04:00
Simon Marchi
1487293966 gdb: change return type of check_quit_flag to bool
Change the return type of the check_quit_flag function to bool.  Update
a few related spots.

Change-Id: I9d3a15d3f8651efb02c7d211f06222a592bd4184
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-23 11:26:14 -04:00
Simon Marchi
7d21eff944 gdb: move declarations of check_quit_flag and set_quit_flag to extension.h
Move them out of defs.h, to extension.h, since the implementations are
in extension.c.

Change-Id: Ie7321468bd7fecc684d70b09f72c3ee8ac75d8f4
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-23 11:26:14 -04:00
Simon Marchi
eb97e68430 gdb: remove unused include in infrun.c
Remove the gdbcmd.h, which is reported as unused by clangd.  Add
cli/cli-cmds.h instead, to get access to `cmdlist` and friends.

Change-Id: Ic0c60d2f6d3618f1bd9fd80b95ffd7c33c692a04
2024-04-23 11:19:03 -04:00
Waqar Hameed
0de4ba0269 objdump: Round ASCII art lines in jump visualization 2024-04-23 16:10:50 +01:00
Simon Marchi
ff191ddf80 gdb/dwarf2/read.c: remove pessimizing std::move
When building with this clang:

    $ c++ --version
    FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)

I see:

    $ gmake
      CXX    dwarf2/read.o
    /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:4890:6: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
                                            std::move (thread_storage.release_parent_map ()));
                                            ^
    /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:4890:6: note: remove std::move call here
                                            std::move (thread_storage.release_parent_map ()));
                                            ^~~~~~~~~~~                                    ~

The compiler seems right, there is not need to std::move the result of
`release_parent_map ()`, it's already going to be an rvalue.  Remove the
std::move.

The issue isn't FreeBSD-specific, I see it on Linux as well when
building hwith clang, I just noticed it on a FreeBSD build first.

Change-Id: I7aa20a4db56c799f20d838ad08099a01653bba19
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-23 10:40:12 -04:00
Simon Marchi
6a7d971a8a gdb: bump black version to 24.4.0
Run `pre-commit autoupdate`, this is the outcome.  There is no change in
formatting of Python files.

Change-Id: I977781fa6cc924c398cc3b9d9954dc0fbb95d082
2024-04-23 09:20:42 -04:00
Alan Modra
e79ee36b5a PR31667, objcopy/strip corrupts solaris binaries
Using want_p_paddr_set_to_zero in commit 45d92439ae was wrong.  Even
solaris targets don't have want_p_paddr_set_to_zero, but we should
handle them at least somewhat reasonably.

	PR 31667
	* elf.c (IS_SECTION_IN_INPUT_SEGMENT): Remove bed arg, add
	paddr_valid.  Don't use bed->want_p_paddr_set_to_zero.
	(INCLUDE_SECTION_IN_SEGMENT): Likewise.
	(rewrite_elf_program_header): Adjust to suit.
2024-04-23 22:07:04 +09:30
Alan Modra
ef1c830f00 ignore some symbols in elf.c:swap_out_syms
The reason behind this patch was noticing that generic ELF targets
fail to remove "bar" in the recently committed ld-elf/undefweak-1
test.  (Despite that, those targets pass the test due to it being too
strict when matching symbols.  "bar" gets turned into a local weak
defined absolute symbol.)

swap_out_syms currently drops local section syms that are defined in
discarded sections.  Extend that to also drop other symbols in
discarded sections too, even global symbols.  The linker goes to quite
a lot of effort to ensure globals in discarded section take a
definition from the kept linkonce or comdat group section.  So the
global sym change should only affect cases where something is quite
wrong about the set of linkonce or comdat group sections.  However
that change to elf_map_symbols meant we dropped _DYNAMIC_LINK /
_DYNAMIC_LINKING for mips, a global absolute symbol given STT_SECTION
type for some reason.  That problem is fixed by reverting the pr14493
change which is no longer needed due to a) BSF_SECTION_SYM_USED on
x86, and b) fixing objcopy to use copy_private_symbol_data.

bfd/
	PR 14493
	* elf.c (ignore_sym): Rename from ignore_section_sym.  Return
	true for any symbol without a section or in a discarded section.
	Revert pr14493 change.
	(elf_map_symbols): Tidy.  Use ignore_sym on all symbols.
	(swap_out_syms): Tidy.
ld/
	* testsuite/ld-elf/undefweak-1.rd: Match any "bar".
2024-04-23 22:07:00 +09:30
Alan Modra
6197c6f3a6 xfail undefweak-1 test for alpha
".set" has a different meaning on alpha.  Changing it to ".equ" runs
into ".equ" having a different meaning on hppa, and changing it to "="
runs into trouble on bfin.

	* testsuite/ld-elf/elf.exp (undefweak-1): xfail on alpha,
	don't xfail for genelf.
2024-04-23 22:06:41 +09:30
Alan Modra
e13e2ba45f use copy_private_symbol_data in objcopy
osympp appearing twice here is not a bug.

	PR 14493
	* objcopy.c (copy_object): Run the symbols through
	bfd_copy_private_symbol_data.
2024-04-23 11:20:41 +09:30
Alan Modra
6705e14a99 copy_private_symbol_data
bfd_copy_private_symbol_data is a bfd function that appeared in
commit 89665c8562 a long time ago, but seemingly wasn't used
anywhere until Jan added it to gas/symbols.c in commit 6a2b6326c2.

The function is used to modify ELF symbol st_shndx for symbols defined
in odd sections like .symtab, so that they get the corresponding
section st_shndx in an output file.  This patch fixes some bitrot in
the function.  After commit c03551323c which introduced
output_elf_obj_tdata, elf_strtab_sec and elf_shstrtab_sec will
segfault if used on an input bfd.

	PR 14493
	* elf.c (_bfd_elf_copy_private_symbol_data): Don't use
	elf_strtab_sec and elf_shstrtab_sec.
2024-04-23 11:19:35 +09:30
Simon Marchi
6bfde7e33e gdb: don't include gdbsupport/array-view.h in defs.h
Nothing in defs.h actually uses this.  Everything that I (and the
buildbot) can compile still compiles, so I guess that all users of
array_view already include it one way or another.  Worst case, if this
causes some build failure, the fix will be one #include away.

Change-Id: I981be98b0653cc18c929d85e9afd8732332efd15
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-22 21:34:19 -04:00
Simon Marchi
740ccea39e gdb: don't include hashtab.h in defs.h
Nothing in defs.h actually uses this.

Add some includes for some spots using things from hashtab.h.  Note that
if the GDB build doesn't use libxxhash, hashtab.h is included by
gdbsupport/common-utils.h, so all files still see hashtab.h.  It puzzled
me for some time why I didn't see build failures in my build (which
didn't use libxxhash) but the buildbot gave build failures (it uses
libxxhash).

Change-Id: I8efd68decdaf579f048941c7537cd689885caa2a
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-22 21:34:19 -04:00
Simon Marchi
6e7c49c2dd gdb: move RequireLongest to gdbsupport/traits.h
Move it out of defs.h.

Change-Id: Ie1743d41a57f81667650048563e66073c72230cf
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-22 21:34:19 -04:00
Simon Marchi
ec45252592 gdb: move store/extract integer functions to extract-store-integer.{c,h}
Move the declarations out of defs.h, and the implementations out of
findvar.c.

I opted for a new file, because this functionality of converting
integers to bytes and vice-versa seems a bit to generic to live in
findvar.c.

Change-Id: I524858fca33901ee2150c582bac16042148d2251
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-22 21:34:19 -04:00
Simon Marchi
15afb100ea gdb: remove extract_long_unsigned_integer
It is unused.

Change-Id: I5d4091368c4dfc29752b12061e38f1df8353ba74
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-22 21:34:19 -04:00
Simon Marchi
5d2c2c84f2 gdb: move enum compile_i_scope_types to compile/compile.h
Move it out of defs.h, adjust the includes here and there.

Change-Id: I11901fdce55d54f5e51723e123cef154cfb1bbc5
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-22 21:34:19 -04:00
Simon Marchi
7b21ae941e gdb: move two declarations out of defs.h
Move declarations of initialize_progspace and initialize_inferiors to
progspace.h and inferior.h, respectively.

Change-Id: I62292ffda429861b9f27d8c836a56d161dfa548d
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-22 21:34:19 -04:00
GDB Administrator
5b4c41267f Automatic date update in version.in 2024-04-23 00:00:13 +00:00
Thiago Jung Bauermann
fdaa4939e5 gdb/testsuite: Use default gdb_expect timeout in runto
runto uses a hard-coded timeout of 30s in its invocation of gdb_expect.
This is normally fine, but for very a slow system (e.g., an emulator) it
may not be enough time for GDB to reach the intended breakpoint.

gdb_expect can obtain a timeout value from user-configurable variables
when it's not given one explicitly, so use that mechanism instead since
the user will have already adjusted the timeout variable to account for
the slow system.

Approved-By: Tom Tromey <tom@tromey.com>
2024-04-22 13:10:33 -03:00
Andrew Burgess
39f0ac3831 gdb: fix unknown variable typo in c-exp.y
Fix 'val' -> 'value' typo in c-exp.y which was breaking the build.
Introduced in commit:

  commit e6375bc8eb
  Date:   Wed Apr 17 16:17:33 2024 -0600

      Remove some alloca uses
2024-04-22 10:39:37 +01:00
Victor Do Nascimento
911cb006bf aarch64: Fix coding style issue in `aarch64-dis.c'
Fix integer value being returned from boolean function, as introduced
in `aarch64: Remove asserts from operand qualifier decoders [PR31595]'.
2024-04-22 10:32:45 +01:00
Tom Tromey
1f984aabf1 Use std::vector in event-loop.cc
In my occasional and continuing campaign against realloc, this patch
changes event-loop.cc to use std::vector to keep track of pollfd
objects.  Regression tested on x86-64 Fedora 38.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-21 19:54:27 -06:00
Cui, Lili
b5247082c4 x86/APX: Add invalid check for APX EVEX.X4.
gas/ChangeLog:

        * config/tc-i386.c (build_apx_evex_prefix): Added invalid check for APX
        X4.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d: Added invalid
        testcase.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s: Ditto.

opcodes/ChangeLog:

        * i386-dis.c (get_valid_dis386): Added invalid check for APX X4.
2024-04-22 09:25:56 +08:00
GDB Administrator
80fa407f9f Automatic date update in version.in 2024-04-22 00:00:10 +00:00
Tom Tromey
6e4be957f7 Remove a couple of VLAs
I found a couple of spots where VLAs are in use but where they can
easily be removed.

In one spot, adding 'const' is enough -- and is already done in
similar code elsewhere in the file.

In another spot, one of two arrays will be used, so making the buffer
large enough for both works.

Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-21 12:33:56 -06:00
Tom Tromey
e6375bc8eb Remove some alloca uses
A few spots (mostly in the parsers) use alloca to ensure that a string
is terminated before passing it to a printf-like function (mostly
'error').  However, this isn't needed as the "%.*s" format can be used
instead.

This patch makes this change.

In one spot the alloca is dead code and is simply removed.

Regression tested on x86-64 Fedora 38.

Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-21 12:12:43 -06:00
GDB Administrator
7e9ef24e4a Automatic date update in version.in 2024-04-21 00:00:08 +00:00
mengqinggang
20eee7540b LoongArch: Add -mignore-start-align option
Ignore .align at the start of a section may result in misalignment when
partial linking. Manually add -mignore-start-align option without partial
linking.

Gcc -falign-functions add .align 5 to the start of a section, it causes some
error message mismatch. Set these testcases to xfail on LoongArch target.
2024-04-20 12:10:40 +08:00
Alan Modra
02fa4bbec1 Error compiling libctf-regression test
Seen on 64-bit targets.
ERROR: compilation of lookup program .../libctf-regression/gzrewrite.c failed

	* testsuite/libctf-regression/gzrewrite.c (main): Use %zu to
	print size_t values.
	* testsuite/libctf-regression/zrewrite.c (main): Likewise.
2024-04-20 10:36:37 +09:30
GDB Administrator
3716307682 Automatic date update in version.in 2024-04-20 00:00:13 +00:00
Simon Marchi
cb5dfff88e gdb: add target_debug_printf and target_debug_printf_nofunc
Add the `target_debug_printf` and `target_debug_printf_nofunc` macros
and use them when outputting debug messages depending on `targetdebug`.
I opted for `target_debug_printf_nofunc` to follow the current style
where the function name is already printed, along with the arguments.

Modify the debug printfs in the `debug_target` methods (generated by
`make-target-delegates.py`) to use `target_debug_printf_nofunc` as well.

This makes the "target" debug prints integrate nicely with the other
debug prints that use the "new" debug print system:

    [infrun] proceed: enter
      [infrun] follow_fork: enter
        [target] -> multi-thread->record_will_replay (...)
        [target] <- multi-thread->record_will_replay (-1, 0) = false
        [target] -> multi-thread->supports_multi_process (...)
        [target] <- multi-thread->supports_multi_process () = true
      [infrun] follow_fork: exit
      ...

Change-Id: Ide3c8c1b8a30e6d4c353a29cba911c7192de29ac
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-19 16:30:25 -04:00
Simon Marchi
8a8b6c53e1 gdb: make regcache::debug_print_register return a string
Rename the method to `register_debug_string`.

This makes it easier to introduce `target_debug_printf` in a subsequent
patch.

Change-Id: I5bb2d49476d17940d503e66f40762e3f1e3baabc
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-19 16:30:25 -04:00
Simon Marchi
b38f70086d gdb: make debug_target use one-liners
Turn the debug prints in debug_target's method to be one liners.  For
instance, change this:

    gdb_printf (gdb_stdlog, "<- %s->wait (", this->beneath ()->shortname ());
    gdb_puts (target_debug_print_ptid_t (arg0), gdb_stdlog);
    gdb_puts (", ", gdb_stdlog);
    gdb_puts (target_debug_print_target_waitstatus_p (arg1), gdb_stdlog);
    gdb_puts (", ", gdb_stdlog);
    gdb_puts (target_debug_print_target_wait_flags (arg2), gdb_stdlog);
    gdb_puts (") = ", gdb_stdlog);
    target_debug_print_ptid_t (result);
    gdb_puts ("\n", gdb_stdlog);

into this:

    gdb_printf (gdb_stdlog,
               "<- %s->wait (%s, %s, %s) = %s\n",
               this->beneath ()->shortname (),
               target_debug_print_ptid_t (arg0).c_str (),
               target_debug_print_target_waitstatus_p (arg1).c_str (),
               target_debug_print_target_wait_flags (arg2).c_str (),
               target_debug_print_ptid_t (result).c_str ());

This makes it possible for a subsequent patch to turn this gdb_printf
call into a `target_debug_printf` call.

Change-Id: I808202438972fac1bba2f8ccb63e66a4fcef20c9
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-19 16:30:25 -04:00
Simon Marchi
a887499c6b gdb: make target debug functions return std::string
Change the functions in target-debug.h to return string representations
in an std::string, such that they don't need to know how the printing
part is done.  This also helps the following patch that makes the debug
prints in debug_target one-liners.

Update target-delegates.c (through make-target-delegates.py) to do the
printing.

Add an overload of gdb_puts to avoid using `.c_str ()`.

Change-Id: I55cbff1c1b03a3b24a81740e34c6ad41ac4f8453
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-19 16:30:25 -04:00