binutils-gdb.git
21 months agogdb: LoongArch: Modify the result of the info reg command
Hui Li [Thu, 16 Feb 2023 00:59:10 +0000 (08:59 +0800)]
gdb: LoongArch: Modify the result of the info reg command

The "info register" command should only display general registers,
but it shows the information of all registers in the current code,
add loongarch_register_reggroup_p() so that we can get the expected
result.

Signed-off-by: Hui Li <lihui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
21 months agobfd: xtensa: fix __stop_SECTION literal drop
Alexey Lapshin [Thu, 23 Feb 2023 10:48:16 +0000 (10:48 +0000)]
bfd: xtensa: fix __stop_SECTION literal drop

21 months agoFix the BFD library's find_nearest_line feature to produce consistent results.
Nick Clifton [Thu, 23 Feb 2023 09:44:50 +0000 (09:44 +0000)]
Fix the BFD library's find_nearest_line feature to produce consistent results.

 PR 30150
 * dwarf2.c (comp_unit_contains_address): Renamed to ... (comp_unit_may_contain_address): this,
 and added code to return true if the CU's ranges have not yet been computed.
 (_bfd_dwarf2_find_nearest_line_with_alt): Use the renamed function, simplifying code in the process.

21 months agodwarf1 .line SEC_HAS_CONTENTS
Alan Modra [Thu, 23 Feb 2023 02:24:09 +0000 (12:54 +1030)]
dwarf1 .line SEC_HAS_CONTENTS

* dwarf1.c (parse_line_table): Ignore .line without SEC_HAS_CONTENTS.
Formatting.

21 months agoip2k: don't look at stab sections without relocs
Alan Modra [Wed, 22 Feb 2023 07:41:25 +0000 (18:11 +1030)]
ip2k: don't look at stab sections without relocs

No need to read contents if we won't do anything.

* elf32-ip2k.c (adjust_all_relocations): Skip stab sections
without relocs.

21 months agoTest SEC_HAS_CONTENTS in relax routines
Alan Modra [Wed, 22 Feb 2023 07:07:26 +0000 (17:37 +1030)]
Test SEC_HAS_CONTENTS in relax routines

More places that generally expect instructions, so not zeros.

* coff-sh.c (sh_relax_section, sh_relax_delete_bytes): Exclude
sections without SEC_HAS_CONTENTS set.
* elf-m10200.c (mn10200_elf_relax_section): Likewise.
* elf32-arc.c (arc_elf_relax_section): Likewise.
* elf32-avr.c (elf32_avr_relax_section): Likewise.
* elf32-cr16.c (elf32_cr16_relax_section): Likewise.
* elf32-crx.c (elf32_crx_relax_section): Likewise.
* elf32-epiphany.c (epiphany_elf_relax_section): Likewise.
* elf32-ft32.c (ft32_elf_relax_section): Likewise.
* elf32-h8300.c (elf32_h8_relax_section): Likewise.
* elf32-ip2k.c (ip2k_elf_relax_section): Likewise.
* elf32-m32c.c (m32c_elf_relax_section): Likewise.
* elf32-m68hc11.c (m68hc11_elf_relax_section): Likewise.
* elf32-msp430.c (msp430_elf_relax_section): Likewise.
* elf32-pru.c (pru_elf32_relax_section): Likewise.
* elf32-rl78.c (rl78_elf_relax_section): Likewise.
* elf32-rx.c (elf32_rx_relax_section): Likewise.
* elf32-sh.c (sh_elf_relax_section): Likewise.
(sh_elf_relax_delete_bytes): Likewise.
* elf32-v850.c (v850_elf_relax_section): Likewise.
* elf64-alpha.c (elf64_alpha_relax_section): Likewise.
* elf64-ia64-vms.c (elf64_ia64_relax_section): Likewise.
* elfnn-ia64.c (elfNN_ia64_relax_section): Likewise.
* elfnn-riscv.c (_bfd_riscv_relax_section): Likewise.
* elfxx-mips.c (_bfd_mips_elf_relax_section): Likewise.

21 months agoTest SEC_HAS_CONTENTS before reading section contents
Alan Modra [Tue, 21 Feb 2023 21:17:36 +0000 (07:47 +1030)]
Test SEC_HAS_CONTENTS before reading section contents

bfd_malloc_and_get_section does size sanity checking before allocating
memory and reading contents.  These size checks are not done for bss
style sections, because they typically don't occupy file space and
thus can't be compared against file size.  However, if you are
expecting to look at something other than a whole lot of zeros, don't
allow fuzzers to avoid the size checking.

* cofflink.c (process_embedded_commands): Don't look at
sections without SEC_HAS_CONTENTS set.
* cpu-arm.c (bfd_arm_update_notes): Likewise.
(bfd_arm_get_mach_from_notes): Likewise.
* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Likewise.
* elf-hppa.h (elf_hppa_sort_unwind): Likewise.
* elf-m10300.c (mn10300_elf_relax_section): Likewise.
* elf-sframe.c (_bfd_elf_parse_sframe): Likewise.
* elf.c (_bfd_elf_print_private_bfd_data): Likewise.
* elf32-arm.c (bfd_elf32_arm_process_before_allocation): Likewise.
* elf32-avr.c (avr_elf32_load_property_records): Likewise.
* elf32-ppc.c (_bfd_elf_ppc_set_arch): Likewise.
(ppc_elf_get_synthetic_symtab, ppc_elf_relax_section): Likewise.
* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Likewise.
(opd_entry_value, ppc64_elf_edit_opd, ppc64_elf_edit_toc): Likewise.
* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.
* elflink.c (elf_link_add_object_symbols): Likewise.
(bfd_elf_get_bfd_needed_list): Likewise.
* elfnn-aarch64.c (get_plt_type): Likewise.
* elfxx-mips.c (_bfd_mips_elf_get_synthetic_symtab): Likewise.
* linker.c (_bfd_handle_already_linked): Likewise.
* opncls.c (bfd_get_debug_link_info_1): Likewise.
(bfd_get_alt_debug_link_info, get_build_id): Likewise.
* peXXigen.c (pe_print_idata, pe_print_pdata): Likewise.
(_bfd_XX_print_ce_compressed_pdata, pe_print_reloc): Likewise.
* pei-x86_64.c (pex64_bfd_print_pdata_section): Likewise.
* stabs.c (_bfd_link_section_stabs): Likewise.
(_bfd_discard_section_stabs): Likewise.
* xcofflink.c (_bfd_xcoff_get_dynamic_symtab_upper_bound): Likewise.
(_bfd_xcoff_canonicalize_dynamic_symtab): Likewise.
(_bfd_xcoff_get_dynamic_reloc_upper_bound): Likewise.
(_bfd_xcoff_canonicalize_dynamic_reloc): Likewise.
(xcoff_link_add_dynamic_symbols): Likewise.
(xcoff_link_check_dynamic_ar_symbols): Likewise.
(bfd_xcoff_build_dynamic_sections): Likewise.

21 months agoAutomatic date update in version.in
GDB Administrator [Thu, 23 Feb 2023 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agogdb.reverse/time-reverse.exp: test both time syscall and C time function
Pedro Alves [Wed, 22 Feb 2023 15:40:58 +0000 (15:40 +0000)]
gdb.reverse/time-reverse.exp: test both time syscall and C time function

Instead of only testing this on systems that have a SYS_time syscall,
test it everywhere using the time(2) C function, and in addition, run
the tests again using the SYS_time syscall.

The C variant ensures that if some platform uses some syscall we are
not aware of yet, we'll still exercise it, and likely fail, at which
point we should teach GDB about the syscall.

The explicit syscall variant is useful on platforms where the C
function does not call a syscall at all by default, e.g., on some
systems the C time function wraps an implementation provided by the
vDSO.

Approved-By: Tom de Vries <tdevries@suse.de>
Change-Id: Id4b755d76577d02c46b8acbfa249d9c31b587633

21 months agox86-64: LAR and LSL don't need REX.W
Jan Beulich [Wed, 22 Feb 2023 13:12:52 +0000 (14:12 +0100)]
x86-64: LAR and LSL don't need REX.W

Just like we suppress emitting REX.W for e.g. MOV from/to segment
register, there's also no need for it for LAR and LSL - these can only
ever return 32-bit values and hence always zero-extend their results
anyway.

While there also drop the redundant Word from the first operand of
the second template each - this is already implied by Reg16.

21 months agox86: optimize BT{,C,R,S} $imm,%reg
Jan Beulich [Wed, 22 Feb 2023 13:12:24 +0000 (14:12 +0100)]
x86: optimize BT{,C,R,S} $imm,%reg

In 64-bit mode BT can have REX.W or a data size prefix dropped in
certain cases. Outside of 64-bit mode all 4 insns can have the data
size prefix dropped in certain cases.

21 months agoset bfd_error on make_tempname or make_tempdir failure
Alan Modra [Wed, 22 Feb 2023 01:22:46 +0000 (11:52 +1030)]
set bfd_error on make_tempname or make_tempdir failure

* bucomm.c (make_tempname, make_tempdir): Set bfd_error on error.

21 months agoAutomatic date update in version.in
GDB Administrator [Wed, 22 Feb 2023 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoRe: objdump read_section_stabs
Alan Modra [Tue, 21 Feb 2023 23:27:53 +0000 (09:57 +1030)]
Re: objdump read_section_stabs

Also fix ubsan "applying zero offset to null pointer".

* objdump.c (print_section_stabs): Avoid ubsan warning.

21 months agoRe: objdump read_section_stabs
Alan Modra [Tue, 21 Feb 2023 22:34:57 +0000 (09:04 +1030)]
Re: objdump read_section_stabs

Commit f9c36cc99518 changed (and renamed) read_section_stabs with one
difference in overall behaviour.  Previously read_section_stabs would
return a NULL for an empty section, which was then treated the same as
a missing section.  Now an empty section is recognized and dumped.
This leads to NULL stabp and stabs_end in print_section_stabs.  Since
stabs_end - STABSIZE is then a pointer to a very large address, the
test "stabp < stabs_end - STABSIZE" succeeds.

* objdump.c (print_section_stabs): Correct STABSIZE comparison.

21 months agodebug_link duplicate file size checks
Alan Modra [Tue, 21 Feb 2023 21:45:26 +0000 (08:15 +1030)]
debug_link duplicate file size checks

bfd_malloc_and_get_section does these checks.

* opncls.c (bfd_get_debug_link_info_1): Don't check section
size against file size.
(bfd_get_alt_debug_link_info): Likewise.

21 months agoIssue error on erroneous expression
Tom Tromey [Sat, 18 Feb 2023 00:55:50 +0000 (19:55 -0500)]
Issue error on erroneous expression

A while back I discovered that this does not issue an error:

    (gdb) p $x = (void * ) 57
    $3 = (void *) 0x39
    (gdb) p $x + 7 = 3
    $6 = (void *) 0x3

This patch fixes the bug.
Regression tested on x86-64 Fedora 36.

Reviewed-By: Bruno Larsen <blarsen@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19312

21 months agogdb: add --with-curses to --configuration output
Philippe Blain [Sun, 19 Feb 2023 22:37:35 +0000 (17:37 -0500)]
gdb: add --with-curses to --configuration output

'gdb --configuration' does not mention if GDB was built with curses.
Since b5075fb68d4 (Rename to allow_tui_tests, 2023-01-08) it does show
--enable-tui (or --disable-tui), but one might want to know if GDB was
built with curses independently of the availability of the TUI.

Since configure.ac uses AC_SEARCH_LIBS to check for the curses library,
we do not get an automatically defined HAVE_LIBCURSES symbol in
config.in. We do have symbols defined by AC_CHECK_HEADERS
(HAVE_CURSES_H, etc.) but it would be cumbersome to use those in
print_gdb_configuration because we would have to check for all 6 symbols
corresponding the 6 headers listed. This would also increase the
maintenance burden if support for other variations of curses are added.

Instead, define 'HAVE_LIBCURSES' ourselves by adding an
'action-if-found' argument to AC_SEARCH_LIBS, and use it in
print_gdb_configuration.

While at it, remove the condition on 'ac_cv_search_waddstr' and set
'curses_found' directly in 'action-if-found'.

Change-Id: Id90e3d73990e169cee51bcc3e1d52072cfacd5b8
Approved-By: Simon Marchi <simon.marchi@efficios.com>
21 months ago[gdb/testsuite] Require compilation flags in two gdb.arch/aarch64 test-cases
Tom de Vries [Tue, 21 Feb 2023 14:26:24 +0000 (15:26 +0100)]
[gdb/testsuite] Require compilation flags in two gdb.arch/aarch64 test-cases

With test-cases gdb.arch/aarch64-mte-core.exp and gdb.arch/aarch64-pauth.exp I
run into compilation errors due to unsupported compilation flags.

Fix this by requiring the compilation flags, such that I have instead:
...
UNSUPPORTED: gdb.arch/aarch64-mte-core.exp: require failed: \
  have_compile_flag -march=armv8.5-a+memtag
UNSUPPORTED: gdb.arch/aarch64-pauth.exp: require failed: \
  have_compile_flag -mbranch-protection=pac-ret+leaf
...

Tested on aarch64-linux.

21 months ago[gdb/testsuite] Require istarget x86* in gdb.reverse/step-indirect-call-thunk.exp
Tom de Vries [Tue, 21 Feb 2023 14:06:50 +0000 (15:06 +0100)]
[gdb/testsuite] Require istarget x86* in gdb.reverse/step-indirect-call-thunk.exp

On aarch64-linux, I run into:
...
Running gdb.reverse/step-indirect-call-thunk.exp ...
gdb compile failed, gcc: error: unrecognized command line option \
  '-mindirect-branch=thunk'; did you mean '-findirect-inlining'?
gcc: error: unrecognized command line option '-mfunction-return=thunk'; \
  did you mean '-Wfunction-elimination'?
UNTESTED: gdb.reverse/step-indirect-call-thunk.exp: failed to prepare
...

Fix this by requiring istarget "x86*", similar to what was added in
gdb.base/step-indirect-call-thunk.exp by commit 43127ae5714 ("Fix
gdb.base/step-indirect-call-thunk.exp"), such that we have instead:
...
UNSUPPORTED: gdb.reverse/step-indirect-call-thunk.exp: require failed: \
  istarget "x86*
...

Tested on x86_64-linux and aarch64-linux.

21 months ago[gdb/testsuite] Require -fsplit-stack in gdb.base/morestack.exp
Tom de Vries [Tue, 21 Feb 2023 13:41:14 +0000 (14:41 +0100)]
[gdb/testsuite] Require -fsplit-stack in gdb.base/morestack.exp

On aarch64-linux, I run into:
...
gdb compile failed, cc1: error: '-fsplit-stack' is not supported by this \
  compiler configuration
UNTESTED: gdb.base/morestack.exp: failed to prepare
...

Fix this by requiring -fsplit-stack, such that we have instead:
...
UNSUPPORTED: gdb.base/morestack.exp: require failed: \
  expr [have_compile_flag -fsplit-stack]
...

Tested on x86_64-linux and aarch64-linux.

21 months ago[gdb/testsuite] Require syscall time in gdb.reverse/time-reverse.exp
Tom de Vries [Tue, 21 Feb 2023 13:10:12 +0000 (14:10 +0100)]
[gdb/testsuite] Require syscall time in gdb.reverse/time-reverse.exp

On aarch64-linux, I run into:
...
Running gdb.reverse/time-reverse.exp ...
gdb compile failed, gdb.reverse/time-reverse.c: In function 'main':
gdb.reverse/time-reverse.c:39:12: error: 'SYS_time' undeclared \
  (first use in this function); did you mean 'SYS_times'?
   syscall (SYS_time, &time_global);
            ^~~~~~~~
            SYS_times
gdb.reverse/time-reverse.c:39:12: note: each undeclared identifier is \
  reported only once for each function it appears in
UNTESTED: gdb.reverse/time-reverse.exp: failed to prepare
...

Fix this by adding a new proc have_syscall, and requiring syscall time, such
that we have instead:
...
UNSUPPORTED: gdb.reverse/time-reverse.exp: require failed: \
  expr [have_syscall time]
...

Tested on x86_64-linux and aarch64-linux.

21 months ago[gdb/testsuite] Require python in gdb.dap/basic-dap.exp
Tom de Vries [Tue, 21 Feb 2023 11:47:28 +0000 (12:47 +0100)]
[gdb/testsuite] Require python in gdb.dap/basic-dap.exp

When running test-case gdb.dap/basic-dap.exp with a gdb without python
support, I run into:
...
builtin_spawn gdb -nw -nx -iex set height 0 -iex set width 0 \
  -data-directory data-directory -iex set debug dap-log-file dap.log.1 -q \
  -i=dap
>>> {"seq": 1, "type": "request", "command": "initialize"}
Interpreter `dap' unrecognized
ERROR: eof reading json header
...

Fix this by requiring python in the test-case.

Tested on x86_64-linux, both with a gdb without and with python.

21 months agoUpdate the description of the bfd_fill_in_gnu_debuglink_section function
Nick Clifton [Tue, 21 Feb 2023 11:15:52 +0000 (11:15 +0000)]
Update the description of the bfd_fill_in_gnu_debuglink_section function

21 months agoUpdated translatios for the bfd and gprof directories.
Nick Clifton [Mon, 20 Feb 2023 12:31:56 +0000 (12:31 +0000)]
Updated translatios for the bfd and gprof directories.

21 months agogas/testsuite: adjust a test for case insensitive file systems
Clément Chigot [Wed, 11 Jan 2023 14:12:47 +0000 (15:12 +0100)]
gas/testsuite: adjust a test for case insensitive file systems

When dealing with case insensitive file systems, ".file line.s" and
".file Line.s" are identical and thus gas won't change the current
input file.
However, in line.l test, it's expecting to trigger an input file switch.
As the second filename doesn't matter in it, change it to fit for those
file systems.

gas/ChangeLog:

* testsuite/gas/elf/line.l: Change Line.s to Line2.s.
* testsuite/gas/elf/line.s: Adjust output.

21 months ago[aarch64] Enable pointer authentication support for aarch64 bare metal/kernel mode...
Luis Machado [Sun, 11 Sep 2022 19:47:18 +0000 (20:47 +0100)]
[aarch64] Enable pointer authentication support for aarch64 bare metal/kernel mode addresses

At the moment GDB only handles pointer authentication (pauth) for userspace
addresses and if we're debugging a Linux-hosted program.

The Linux Kernel can be configured to use pauth instructions for some
additional security hardening, but GDB doesn't handle this well.

To overcome this limitation, GDB needs a couple things:

1 - The target needs to advertise pauth support.
2 - The hook to remove non-address bits from a pointer needs to be registered
    in aarch64-tdep.c as opposed to aarch64-linux-tdep.c.

There is a patch for QEMU that addresses the first point, and it makes
QEMU's gdbstub expose a couple more pauth mask registers, so overall we will
have up to 4 pauth masks (2 masks or 4 masks):

pauth_dmask
pauth_cmask
pauth_dmask_high
pauth_cmask_high

pauth_dmask and pauth_cmask are the masks used to remove pauth signatures
from userspace addresses. pauth_dmask_high and pauth_cmask_high masks are used
to remove pauth signatures from kernel addresses.

The second point is easily addressed by moving code around.

When debugging a Linux Kernel built with pauth with an unpatched GDB, we get
the following backtrace:

 #0  __fput (file=0xffff0000c17a6400) at /repos/linux/fs/file_table.c:296
 #1  0xffff8000082bd1f0 in ____fput (work=<optimized out>) at /repos/linux/fs/file_table.c:348
 #2  0x30008000080ade30 [PAC] in ?? ()
 #3  0x30d48000080ade30 in ?? ()
 Backtrace stopped: previous frame identical to this frame (corrupt stack?)

With a patched GDB, we get something a lot more meaningful:

 #0  __fput (file=0xffff0000c1bcfa00) at /repos/linux/fs/file_table.c:296
 #1  0xffff8000082bd1f0 in ____fput (work=<optimized out>) at /repos/linux/fs/file_table.c:348
 #2  0xffff8000080ade30 [PAC] in task_work_run () at /repos/linux/kernel/task_work.c:179
 #3  0xffff80000801db90 [PAC] in resume_user_mode_work (regs=0xffff80000a96beb0) at /repos/linux/include/linux/resume_user_mode.h:49
 #4  do_notify_resume (regs=regs@entry=0xffff80000a96beb0, thread_flags=4) at /repos/linux/arch/arm64/kernel/signal.c:1127
 #5  0xffff800008fb9974 [PAC] in prepare_exit_to_user_mode (regs=0xffff80000a96beb0) at /repos/linux/arch/arm64/kernel/entry-common.c:137
 #6  exit_to_user_mode (regs=0xffff80000a96beb0) at /repos/linux/arch/arm64/kernel/entry-common.c:142
 #7  el0_svc (regs=0xffff80000a96beb0) at /repos/linux/arch/arm64/kernel/entry-common.c:638
 #8  0xffff800008fb9d34 [PAC] in el0t_64_sync_handler (regs=<optimized out>) at /repos/linux/arch/arm64/kernel/entry-common.c:655
 #9  0xffff800008011548 [PAC] in el0t_64_sync () at /repos/linux/arch/arm64/kernel/entry.S:586
 Backtrace stopped: Cannot access memory at address 0xffff80000a96c0c8

21 months agold/testsuite: don't output to /dev/null
Clément Chigot [Fri, 13 Jan 2023 09:21:07 +0000 (10:21 +0100)]
ld/testsuite: don't output to /dev/null

Mingw doesn't have /dev/null and thus "-o /dev/null" will fail.
Currently, all the options are checked using this "-o /dev/null",
resulting in them being disabled on mingw hosts.
Fix that by outputting to a real file for all targets.

ld/ChangeLog:

* testsuite/config/default.exp: Replace "-o /dev/null" by a
file.

21 months agoBoth FAIL and PASS "check sections 2"?
Alan Modra [Tue, 21 Feb 2023 05:45:59 +0000 (16:15 +1030)]
Both FAIL and PASS "check sections 2"?

* testsuite/ld-checks/checks.exp (check sections 2): Don't
continue on with rest of test past first fail.

21 months agold-libs test on alpha-vms
Alan Modra [Tue, 21 Feb 2023 05:49:51 +0000 (16:19 +1030)]
ld-libs test on alpha-vms

* testsuite/ld-libs/libs.exp: Don't run for alpha-vms.

21 months agoalpha-*-vms missing libraries
Alan Modra [Mon, 20 Feb 2023 23:27:49 +0000 (09:57 +1030)]
alpha-*-vms missing libraries

For this:
./ld-new: cannot find -limagelib: No such file or directory
./ld-new: cannot find -lstarlet: No such file or directory
./ld-new: cannot find -lsys$public_vectors: No such file or directory
the logs showed
creating dummy tmpdir/libimagelib:
creating dummy No
creating dummy such
etc.
So rubbish instead of tmpdir/libimagelib.a and the other required libs.

* testsuite/config/default.exp: Correct regex detecting missing
libraries automatically searched by alpha-dec-vms-ld.

21 months agoAutomatic date update in version.in
GDB Administrator [Tue, 21 Feb 2023 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoRedefine FUNCTION in doc.str
Tom Tromey [Fri, 17 Feb 2023 19:12:11 +0000 (12:12 -0700)]
Redefine FUNCTION in doc.str

FUNCTION is identical to func, so simplify doc.str.

2023-02-17  Tom Tromey  <tom@tromey.com>

* doc/doc.str (FUNCTION): Call func.

21 months agoHoist the SECTION comment in opncls.c
Tom Tromey [Fri, 17 Feb 2023 19:12:11 +0000 (12:12 -0700)]
Hoist the SECTION comment in opncls.c

The opening and closing node in BFD starts:

    File: bfd.info, [...]

 /* Set to N to open the next N BFDs using an alternate id space.  */
 extern unsigned int bfd_use_reserved_id;

    2.13 Opening and closing BFDs
    =============================

That is, there's a stray C comment and declaration before any other
text or subsections.

This occurs because the code fragment for bfd_use_reserved_id comes
before the SECTION comment.  Hoisting it makes this a little nicer.

2023-02-17  Tom Tromey  <tom@tromey.com>

* opncls.c: Hoist the SECTION comment.

21 months agoDon't use chew comments for static functions
Tom Tromey [Fri, 17 Feb 2023 19:12:11 +0000 (12:12 -0700)]
Don't use chew comments for static functions

I found a few static functions in the BFD manual.  These can't be
called by any user of the library, so I don't think it's useful to put
them in the manual.  This patch removes the chew markup from their
comments.

2023-02-17  Tom Tromey  <tom@tromey.com>

* opncls.c (bfd_get_debug_link_info_1, separate_debug_file_exists)
(separate_alt_debug_file_exists, find_separate_debug_file)
(get_build_id, get_build_id_name, check_build_id_file): Don't use
chew comments.

21 months agoFix formatting of long function description in chew output
Tom Tromey [Fri, 17 Feb 2023 19:12:11 +0000 (12:12 -0700)]
Fix formatting of long function description in chew output

Currently, if a function description spans a line, the resulting info
can look like this:

 -- Function: long bfd_canonicalize_reloc
     (bfd *abfd, asection *sec, arelent **loc, asymbol **syms); Call the
     back end associated with the open BFD ABFD and translate the
     external form of the relocation information attached to SEC into
     the internal canonical form.  Place the table into memory at LOC,

That is, the function prototype runs together with the text in an ugly
way.  This patch fixes this by introducing a new primitive, so that
the generated Texinfo can be a bit nicer.  Now this output looks like:

 -- Function: long bfd_canonicalize_reloc (bfd *abfd, asection *sec,
          arelent **loc, asymbol **syms);
     Call the back end associated with the open BFD ABFD and translate
     the external form of the relocation information attached to SEC

2023-02-17  Tom Tromey  <tom@tromey.com>

* doc/doc.str (SYNOPSIS): Use collapse_whitespace.
* doc/chew.c (collapse_whitespace): New function.
(main): Register collapse_whitespace.

21 months agoopcodes: style m68k disassembler output
Andreas Schwab [Tue, 14 Feb 2023 17:07:19 +0000 (18:07 +0100)]
opcodes: style m68k disassembler output

21 months agogdb: revert one erroneous bool-ification change
Simon Marchi [Mon, 20 Feb 2023 16:52:40 +0000 (11:52 -0500)]
gdb: revert one erroneous bool-ification change

Commit 42c13555ff88 ("Change value::m_stack to bool") erroneously
changed a `0` to `false` in this call to read_value_memory.  This
parameter is `LONGEST bit_offset`, it should stay `0`.

Change-Id: I128df6834cf8055ec6a7051e237e379978d3d651

21 months agold/testsuite: handle Windows drive letter in a noinit test
Clément Chigot [Wed, 18 Jan 2023 13:44:39 +0000 (14:44 +0100)]
ld/testsuite: handle Windows drive letter in a noinit test

The regexp in "noinit sections (ld -r)" is skipping the file path before
the first ":". However, on Windows, a path can start with "C:". Adjust
the regexp to allow such cases.

ld/ChangeLog:

* testsuite/ld-elf/noinit-sections-2.l: Allow Windows paths
(starting with C:).

21 months agold/testsuite: adjust to Windows path separator.
Clément Chigot [Thu, 12 Jan 2023 10:02:25 +0000 (11:02 +0100)]
ld/testsuite: adjust to Windows path separator.

In some tests, the path reported on Windows will have a \ instead of a
/. This occurs when a file is concatened with the search path in
ldfile.c.:  "ld -Ltmpdir -ltext" will result into "tmpdir\libtext.a".

ld/ChangeLog:

* testsuite/ld-elf/retain5.map: Allow \ path separator.
* testsuite/ld-plugin/plugin-10.d: Likewise.
* testsuite/ld-plugin/plugin-11.d: Likewise.
* testsuite/ld-plugin/plugin-18.d: Likewise.
* testsuite/ld-plugin/plugin-19.d: Likewise.
* testsuite/ld-plugin/plugin-20.d: Likewise.
* testsuite/ld-plugin/plugin-22.d: Likewise.

21 months agogdb/doc: Consistency fixes for GDB/MI documentation
Andrew Burgess [Thu, 16 Feb 2023 09:22:43 +0000 (09:22 +0000)]
gdb/doc: Consistency fixes for GDB/MI documentation

I noticed two inconsistencies in the GDB/MI documentation, which this
commit addresses:

  1. Each MI command is introduced like this:

     @subheading The @code{-command-name} Command

     Except for a few of the tracing command, which just use:

     @subheading -command-name

     In this commit I've updated all these trace commands to use the
     more common format.

  2. Each MI command starts with a @subheading, and then the details
     of that command are split up using multiple @subsubheading
     entries.

     Except for a few commands which use @subheading for the top-level
     command, and then continue to use @subheading for each part of
     the command description.

     In this commit I've updated these to use @subsubheading where
     appropriate.

21 months agoSo the linker from producing an export data table when run with --exclude-all-symbols.
Nick Clifton [Mon, 20 Feb 2023 11:32:52 +0000 (11:32 +0000)]
So the linker from producing an export data table when run with --exclude-all-symbols.

 PR 30004 * pe-dll.c (pe_dll_build_sections): Do not build an edata section if all symbols are being excluded.

21 months ago[gdb/symtab] Trust epilogue unwind info for unknown or non-gcc producer
Tom de Vries [Mon, 20 Feb 2023 11:20:14 +0000 (12:20 +0100)]
[gdb/symtab] Trust epilogue unwind info for unknown or non-gcc producer

Currently we only trust epilogue unwind info only for gcc >= 4.5.0.

This has the effect that we don't trust epilogue unwind info for:
- unknown producers (CU without DW_AT_producer attribute)
- non-gcc producers (say, clang).

Instead, only distrust epilogue unwind info only for gcc < 4.5.0.

21 months ago[gdb/symtab] Trust epilogue unwind info for unknown producer (-g0 case)
Tom de Vries [Mon, 20 Feb 2023 11:20:14 +0000 (12:20 +0100)]
[gdb/symtab] Trust epilogue unwind info for unknown producer (-g0 case)

For a -g0 -fasynchronous-unwind-tables exec (without .debug_info but with
.eh_frame section), start using the dwarf2 unwinder instead of the
"amd64 epilogue override" unwinder, by returning true in
compunit_epilogue_unwind_valid for cust == nullptr.

This has effect both on the amd64 and i386 targets, but only add amd64
test-case gdb.base/unwind-on-each-insn-amd64-2.exp.

21 months ago[gdb/tdep] Add amd64/i386 epilogue override unwinders
Tom de Vries [Mon, 20 Feb 2023 11:20:14 +0000 (12:20 +0100)]
[gdb/tdep] Add amd64/i386 epilogue override unwinders

For amd64 the current frame-unwinders are:
...
$ gdb -q -batch -ex "set arch i386:x86-64" -ex "maint info frame-unwinders"
The target architecture is set to "i386:x86-64".
dummy                   DUMMY_FRAME
dwarf2 tailcall         TAILCALL_FRAME
inline                  INLINE_FRAME
python                  NORMAL_FRAME
amd64 epilogue          NORMAL_FRAME
dwarf2                  NORMAL_FRAME
dwarf2 signal           SIGTRAMP_FRAME
amd64 sigtramp          SIGTRAMP_FRAME
amd64 prologue          NORMAL_FRAME
...

For a -g0 -fasynchronous-unwind-tables exec (without .debug_info but with
.eh_frame section), we'd like to start using the dwarf2 unwinder instead of
the "amd64 epilogue" unwinder, by returning true in
compunit_epilogue_unwind_valid for cust == nullptr.

But we'd run into the following problem for a -g0
-fno-asynchronous-unwind-tables (without .debug_info and .eh_frame section)
exec:
- the "amd64 epilogue" unwinder would not run
  (because compunit_epilogue_unwind_valid () == true)
- the dwarf2 unwinder would also not run
  (because there's no .eh_frame info).

Fix this by:
- renaming the "amd64 epilogue" unwinder to "amd64 epilogue override", and
- adding a fallback "amd64 epilogue" after the dwarf unwinders,
while making sure that only one of the two is active.  Likewise for i386.  NFC.

For amd64, this results in this change:
...
 $ gdb -q -batch -ex "set arch i386:x86-64" -ex "maint info frame-unwinders"
 The target architecture is set to "i386:x86-64".
 dummy                   DUMMY_FRAME
 dwarf2 tailcall         TAILCALL_FRAME
 inline                  INLINE_FRAME
 python                  NORMAL_FRAME
-amd64 epilogue          NORMAL_FRAME
+amd64 epilogue override NORMAL_FRAME
 dwarf2                  NORMAL_FRAME
 dwarf2 signal           SIGTRAMP_FRAME
+amd64 epilogue          NORMAL_FRAME
 amd64 sigtramp          SIGTRAMP_FRAME
 amd64 prologue          NORMAL_FRAME
...

And for i386:
...
 $ gdb -q -batch -ex "set arch i386" -ex "maint info frame-unwinders"
 The target architecture is set to "i386".
 dummy                   DUMMY_FRAME
 dwarf2 tailcall         TAILCALL_FRAME
 iline                  INLINE_FRAME
-i386 epilogue           NORMAL_FRAME
+i386 epilogue override  NORMAL_FRAME
 dwarf2                  NORMAL_FRAME
 dwarf2 signal           SIGTRAMP_FRAME
+i386 epilogue           NORMAL_FRAME
 i386 stack tramp        NORMAL_FRAME
 i386 sigtramp           SIGTRAMP_FRAME
 i386 prologue           NORMAL_FRAME
...

21 months ago[gdb/tdep] Fix amd64/i386_stack_frame_destroyed_p
Tom de Vries [Mon, 20 Feb 2023 11:20:14 +0000 (12:20 +0100)]
[gdb/tdep] Fix amd64/i386_stack_frame_destroyed_p

The use of compunit_epilogue_unwind_valid in both amd64_stack_frame_destroyed_p
and i386_stack_frame_destroyed_p is problematic, in the sense that the
functions no longer match their documented behaviour.

Fix this by moving the use of compunit_epilogue_unwind_valid to
amd64_epilogue_frame_sniffer and i386_epilogue_frame_sniffer.  No functional
changes.

21 months ago[gdb/symtab] Factor out compunit_epilogue_unwind_valid
Tom de Vries [Mon, 20 Feb 2023 11:20:14 +0000 (12:20 +0100)]
[gdb/symtab] Factor out compunit_epilogue_unwind_valid

Factor out compunit_epilogue_unwind_valid from both
amd64_stack_frame_destroyed_p and i386_stack_frame_destroyed_p.  No functional
changes.

Also add a comment in the new function about the assumption that in absence of
producer information, epilogue unwind info is invalid.

Approved-By: Tom Tromey <tom@tromey.com>
21 months ago[gdb/testsuite] Add xfail case in gdb.python/py-record-btrace.exp
Tom de Vries [Mon, 20 Feb 2023 10:16:02 +0000 (11:16 +0100)]
[gdb/testsuite] Add xfail case in gdb.python/py-record-btrace.exp

I came across:
...
gdb) PASS: gdb.python/py-record-btrace.exp: prepare record: stepi 100
python insn = r.instruction_history^M
warning: Non-contiguous trace at instruction 1 (offset = 0x3e10).^M
(gdb) FAIL: gdb.python/py-record-btrace.exp: prepare record: python insn = r.i\
nstruction_history
...

I'm assuming it's the same root cause as for the already present XFAIL.

Fix this by recognizing above warning in the xfail regexp.

Tested on x86_64-linux, although sofar I was not able to trigger the warning
again.

Approved-By: Markus T. Metzger <markus.t.metzger@intel.com>
21 months ago[gdb/testsuite] Fix gdb.threads/schedlock.exp for gcc 4.8.5
Tom de Vries [Mon, 20 Feb 2023 10:16:02 +0000 (11:16 +0100)]
[gdb/testsuite] Fix gdb.threads/schedlock.exp for gcc 4.8.5

Since commit 9af467b8240 ("[gdb/testsuite] Fix gdb.threads/schedlock.exp on
fast cpu"), the test-case fails for gcc 4.8.5.

The problem is that for gcc 4.8.5, the commit turned a two-line loop:
...
(gdb) next
78          while (*myp > 0)
(gdb) next
81              MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb) next
78          while (*myp > 0)
...
into a three-line loop:
...
(gdb) next
83              MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb) next
84              cnt++;
(gdb) next
85            }
(gdb) next
83              MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb)
...
and the test-case doesn't expect this.

Fix this by reverting back to the original loop shape as much as possible by:
- removing the cnt++ line
- replacing "while (1)" with "while (one)", where one is a volatile variable
  set to 1.

Tested on x86_64-linux, using compilers:
- gcc 4.8.5, 7.5.0, 12.2.1
- clang 4.0.1, 13.0.1

21 months agoIn-memory nested archives
Alan Modra [Mon, 20 Feb 2023 00:44:59 +0000 (11:14 +1030)]
In-memory nested archives

alpha-linuxecoff has compressed archives that are decompressed to a
bfd-in-memory.  We'd need to handle quite a lot of corner cases to
support nesting of such archives, so just stop it before we run into
segfaults later.

* opncls.c (_bfd_new_bfd_contained_in): Prohibit nested
archives in memory.

21 months agoAutomatic date update in version.in
GDB Administrator [Mon, 20 Feb 2023 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoConvert contained_in to method
Tom Tromey [Fri, 20 Jan 2023 14:46:51 +0000 (07:46 -0700)]
Convert contained_in to method

This converts contained_in to be a method of block.

21 months agoMake block members 'private'
Tom Tromey [Fri, 20 Jan 2023 14:20:38 +0000 (07:20 -0700)]
Make block members 'private'

This changes block to make the data members 'private'.

21 months agoRemove allocate_block and allocate_global_block
Tom Tromey [Fri, 20 Jan 2023 14:16:34 +0000 (07:16 -0700)]
Remove allocate_block and allocate_global_block

This removes allocate_block and allocate_global_block in favor of
simply calling 'new'.

21 months agoHave global_block inherit from block
Tom Tromey [Fri, 20 Jan 2023 14:14:46 +0000 (07:14 -0700)]
Have global_block inherit from block

This changes global_block to inherit from block, which is what was
always intended.

21 months agoUse 'new' for block and global_block
Tom Tromey [Fri, 20 Jan 2023 14:12:02 +0000 (07:12 -0700)]
Use 'new' for block and global_block

This changes block and global_block to add initializers, and then to
use 'new' for allocation.

21 months agoFix memory leak in mdebugread.c
Tom Tromey [Fri, 20 Jan 2023 14:11:46 +0000 (07:11 -0700)]
Fix memory leak in mdebugread.c

mdebugread.c allocates blocks on the heap.  However, this is a memory
leak if the corresponding objfile is ever destroyed.

This patch changes this code to use allocate_block instead, fixing a
FIXME from 2003.

I don't know how to test this patch.

21 months agoRemove ALL_BLOCK_SYMBOLS
Tom Tromey [Fri, 20 Jan 2023 03:25:55 +0000 (20:25 -0700)]
Remove ALL_BLOCK_SYMBOLS

This removes ALL_BLOCK_SYMBOLS in favor of foreach.

21 months agoRemove ALL_BLOCK_SYMBOLS_WITH_NAME
Tom Tromey [Fri, 20 Jan 2023 03:21:10 +0000 (20:21 -0700)]
Remove ALL_BLOCK_SYMBOLS_WITH_NAME

This removes ALL_BLOCK_SYMBOLS_WITH_NAME in favor of foreach.

21 months agoConvert explicit iterator uses to foreach
Tom Tromey [Fri, 20 Jan 2023 03:14:25 +0000 (20:14 -0700)]
Convert explicit iterator uses to foreach

This converts most existing explicit uses of block_iterator to use
foreach with the range iterator instead.

21 months agoIntroduce a block iterator wrapper
Tom Tromey [Fri, 20 Jan 2023 01:44:38 +0000 (18:44 -0700)]
Introduce a block iterator wrapper

This introduces a C++-style iterator that wraps the existing
block_iterator.  It also adds a range adapter.  These will be used in
a later patch.

21 months agoCombine both styles of block iterator
Tom Tromey [Fri, 20 Jan 2023 01:41:21 +0000 (18:41 -0700)]
Combine both styles of block iterator

This merges the two styles of block iterator, having the
initialization API decide which to use based on an optional parameter.

21 months agoStore 'name' in block_iterator
Tom Tromey [Fri, 20 Jan 2023 01:36:17 +0000 (18:36 -0700)]
Store 'name' in block_iterator

This changes the block_iterator to store the 'name' that is used by
block_iter_match_next.  This avoids any problem where the name could
be passed inconsistently, and also makes the subsequent patches easier
to understand.

21 months agoConvert block_static_link to method
Tom Tromey [Fri, 20 Jan 2023 00:50:30 +0000 (17:50 -0700)]
Convert block_static_link to method

This converts block_static_link to be a method.  This was mostly
written by script.

21 months agoConvert set_block_compunit_symtab to method
Tom Tromey [Tue, 17 Jan 2023 13:39:07 +0000 (06:39 -0700)]
Convert set_block_compunit_symtab to method

This converts set_block_compunit_symtab to be a method.  This was
mostly written by script.

21 months agoConvert block_static_block and block_global_block to methods
Tom Tromey [Tue, 17 Jan 2023 01:14:47 +0000 (18:14 -0700)]
Convert block_static_block and block_global_block to methods

This converts block_static_block and block_global_block to be methods.
This was mostly written by script.  It was simpler to convert them at
the same time because they're often used near each other.

21 months agoConvert block_containing_function to method
Tom Tromey [Tue, 17 Jan 2023 00:48:19 +0000 (17:48 -0700)]
Convert block_containing_function to method

This converts block_containing_function to be a method.  This was
mostly written by script.

21 months agoConvert block_linkage_function to method
Tom Tromey [Tue, 17 Jan 2023 00:44:20 +0000 (17:44 -0700)]
Convert block_linkage_function to method

This converts block_linkage_function to be a method.  This was mostly
written by script.

21 months agoConvert more block functions to methods
Tom Tromey [Tue, 17 Jan 2023 00:39:55 +0000 (17:39 -0700)]
Convert more block functions to methods

This converts block_scope, block_set_scope, block_using, and
block_set_using to be methods.  These are all done at once to make it
easier to also convert block_initialize_namespace at the same time.
This was mostly written by script.

21 months agoConvert block_inlined_p to method
Tom Tromey [Tue, 17 Jan 2023 00:27:28 +0000 (17:27 -0700)]
Convert block_inlined_p to method

This converts block_inlined_p to be a method.  This was mostly written
by script.

21 months agoConvert block_gdbarch to method
Tom Tromey [Tue, 17 Jan 2023 00:24:16 +0000 (17:24 -0700)]
Convert block_gdbarch to method

This converts block_gdbarch to be a method.  This was mostly written
by script.

21 months agoConvert block_objfile to method
Tom Tromey [Tue, 17 Jan 2023 00:16:44 +0000 (17:16 -0700)]
Convert block_objfile to method

This converts block_objfile to be a method.  This was mostly written
by script.

21 months agoDon't allow NULL as an argument to block_global_block
Tom Tromey [Fri, 20 Jan 2023 00:22:04 +0000 (17:22 -0700)]
Don't allow NULL as an argument to block_global_block

block_global_block has special behavior when the block is NULL.
Remove this and patch up the callers instead.

21 months agoDon't allow NULL as an argument to block_static_block
Tom Tromey [Fri, 20 Jan 2023 00:20:09 +0000 (17:20 -0700)]
Don't allow NULL as an argument to block_static_block

block_static_block has special behavior when the block is NULL.
Remove this and patch up the callers instead.

21 months agoDon't allow NULL as an argument to block_using
Tom Tromey [Fri, 20 Jan 2023 00:13:22 +0000 (17:13 -0700)]
Don't allow NULL as an argument to block_using

block_using has special behavior when the block is NULL.
Remove this.  No caller seems to be affected.

21 months agoDon't allow NULL as an argument to block_scope
Tom Tromey [Fri, 20 Jan 2023 00:37:15 +0000 (17:37 -0700)]
Don't allow NULL as an argument to block_scope

block_scope has special behavior when the block is NULL.
Remove this and patch up the callers instead.

21 months agoAvoid extra allocations in block
Tom Tromey [Tue, 17 Jan 2023 00:04:39 +0000 (17:04 -0700)]
Avoid extra allocations in block

block_set_scope and block_set_using unconditionally allocate the block
namespace object.  However, this isn't truly needed, so arrange to
only allocate when it is.

21 months agoRearrange block.c to avoid a forward declaration
Tom Tromey [Tue, 17 Jan 2023 00:04:55 +0000 (17:04 -0700)]
Rearrange block.c to avoid a forward declaration

Moving block_initialize_namespace before its callers lets us avoid a
forward declaration.

21 months agoBuffer overflow in evax_bfd_print_eobj
Alan Modra [Sat, 18 Feb 2023 04:01:45 +0000 (14:31 +1030)]
Buffer overflow in evax_bfd_print_eobj

* vms-alpha.c (evax_bfd_print_eobj): Rewrite header handling,
sanity checking rec_len.  Check bfd_malloc return.

21 months agoAvoid memory leak in chew
Tom Tromey [Wed, 15 Feb 2023 23:09:35 +0000 (16:09 -0700)]
Avoid memory leak in chew

An earlier patch of mine introduced a memory leak in chew.  The bug
was that the new "variable" word didn't free the following word.  This
patch fixes it by arranging to transfer ownership of the name to the
variable itself.

* doc/chew.c (add_variable): New function, from
add_intrinsic_variable.
(add_intrinsic_variable): Call add_variable.
(compile): Call add_variable.

21 months agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Feb 2023 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoFix "start" for D, Rust, etc
Tom Tromey [Tue, 14 Feb 2023 00:44:54 +0000 (17:44 -0700)]
Fix "start" for D, Rust, etc

The new DWARF indexer broke "start" for some languages.

For D, it is broken because, while the code in cooked_index_shard::add
specifically excludes Ada, it fails to exclude D.  This means that the
C "main" will be detected as "main" here -- whereas what is intended
is for the code in find_main_name to use d_main_name to find the name.

The Rust compiler, on the other hand, uses DW_AT_main_subprogram.
However, the code in dwarf2_build_psymtabs_hard fails to create a
fully-qualified name, so the name always ends up as plain "main".

For D and Ada, a very simple approach suffices: remove the check
against "main" from cooked_index_shard::add.  This also has the
benefit of slightly speeding up DWARF indexing.  I assume this
approach will work for Pascal and Modula-2 as well, but I don't have a
way to test those at present.

For Rust, though, this is not sufficient.  And, computing the
fully-qualified name in dwarf2_build_psymtabs_hard will crash, because
cooked_index_entry::full_name uses the canonical name -- and that is
not computed until after canonicalization.

However, we don't want to wait for canonicalization to be done before
computing the main name.  That would remove any benefit from doing
canonicalization is the background.

This patch solves this dilemma by noticing that languages using
DW_AT_main_subprogram are, currently, disjoint from languages
requiring canonicalization.  Because of this, we can add a parameter
to full_name to let us avoid crashes, slowdowns, and races here.

This is kind of tricky and ugly, so I've tried to comment it
sufficiently.

While doing this, I had to change gdb.dwarf2/main-subprogram.exp.  A
different possibility here would be to ignore the canonicalization
needs of C in this situation, because those only affect certain types.
However, I chose this approach because the test case is artificial
anyhow.

A long time ago, in an earlier threading attempt, I changed the global
current_language to be a function (hidden behind a macro) to let us
attempt lazily computing the current language.  Perhaps this approach
could still be made to work.  However, that also seemed rather tricky,
more so than this patch.

Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30116

21 months agoFix crash in go_symbol_package_name
Tom Tromey [Fri, 17 Feb 2023 00:52:07 +0000 (17:52 -0700)]
Fix crash in go_symbol_package_name

go_symbol_package_name package name asserts that it is only passed a
Go symbol, but this is not enforced by one caller.  It seems simplest
to just check and return early in this case.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17876
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
21 months agoAvoid manual memory management in go-lang.c
Tom Tromey [Fri, 17 Feb 2023 00:36:29 +0000 (17:36 -0700)]
Avoid manual memory management in go-lang.c

I noticed a couple of spots in go-lang.c that could be improved by
using unique_ptr.

Reviewed-By: Andrew Burgess <aburgess@redhat.com>
21 months agoAutomatic date update in version.in
GDB Administrator [Sat, 18 Feb 2023 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agogdb: fix regression in gdb.xml/maint_print_struct.exp
Andrew Burgess [Fri, 17 Feb 2023 10:15:27 +0000 (10:15 +0000)]
gdb: fix regression in gdb.xml/maint_print_struct.exp

A regression in gdb.xml/maint_print_struct.exp was introduced with
commit:

  commit 81b86eced24f905545b58aa6c27478104c364976
  Date:   Fri Jan 6 09:30:40 2023 -0700

      Do not record a rejected target description

The test relied on an invalid target description being stored within
the tdesc_info of the current inferior, the above commit stopped this
behaviour.

Update the test to check that the invalid architecture is NOT stored,
and then check printing the target description directly from the
file.

Approved-By: Tom Tromey <tromey@adacore.com>
21 months agogprofng: fix Dwarf reader for DW_TAG_subprogram
Vladimir Mezentsev [Fri, 17 Feb 2023 03:35:35 +0000 (19:35 -0800)]
gprofng: fix Dwarf reader for DW_TAG_subprogram

gprofng/ChangeLog
2023-02-16  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* src/Dwarf.cc: Skip DW_TAG_subprogram when DW_AT_declaration is 1.

21 months agogprofng: PR30036 Build failure on aarch64 w/ glibc: symbol `pwrite64' is already...
Vladimir Mezentsev [Fri, 17 Feb 2023 03:00:47 +0000 (19:00 -0800)]
gprofng: PR30036 Build failure on aarch64 w/ glibc: symbol `pwrite64' is already defined

gprofng/ChangeLog
2023-02-16  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/30036
* libcollector/iotrace.c: Define creat64 and pwrite64 only when
__USE_LARGEFILE64 and __USE_FILE_OFFSET64 are not defined.
* libcollector/mmaptrace.c: Likewise for mmap64.

21 months agoFix multi-threaded debugging under AIX
Aditya Vidyadhar Kamath [Fri, 17 Feb 2023 15:07:44 +0000 (09:07 -0600)]
Fix multi-threaded debugging under AIX

Multi-threaded debugging using the libpthdebug debug interface
is currently broken due to multiple issues.

When debugging a single inferior, we were getting assertion
failures in get_aix_thread_info as no tp->priv structure was
allocated for the main thread.

We fixed this by switching the main
thread from a (pid, 0, 0) ptid_t to a (pid, 0, tid) ptid_t and
allocaing the tp->priv structure in sync_threadlists.

As a result, the switch_to_thread call in pdc_read_data could
now fail since the main thread no longer uses (pid, 0, 0).

So we replaced the call by only switching inferior_ptid, the current
inferior, and the current address space (like proc-service.c).
Add similar switching to pdc_write_data where it was missing
completely.

When debugging multiple inferiors, an additional set of
problems prevented correct multi-threaded debugging:

First of all, aix-thread.c used to have a number of global
variables holding per-inferior information.

We switched hese
to a per-inferior data structure instead.

Also, sync_threadlists was getting confused as we were
comparing the list of threads returned by libpthdebug
for *one* process with GDB's list of threads for *all*
processes. Now we only use he GDB threads of the current
inferior instead.

We also skip calling pd_activate
from pd_enable if that in_initial_library_scan flag is
true for the current inferior.

Finally, the presence of the thread library in any but
the first inferior was not correctly detected due to a
bug in solib-aix.c, where the BFD file name for shared
library members was changed when the library was loaded
for the first time, which caused the library to no longer
be recognized by name when loaded a second time.

21 months agoRemove two unnecessary returns in ada-lang.c
Tom Tromey [Fri, 17 Feb 2023 17:24:16 +0000 (10:24 -0700)]
Remove two unnecessary returns in ada-lang.c

I found a couple of spots in ada-lang.c where a return follows a call
to error.  These are unnecessary because error never returns.

21 months ago[gdb/testsuite] Simplify gdb.arch/amd64-disp-step-avx.exp
Tom de Vries [Fri, 17 Feb 2023 14:33:18 +0000 (15:33 +0100)]
[gdb/testsuite] Simplify gdb.arch/amd64-disp-step-avx.exp

On SLE-11, with glibc 2.11.3, I run into:
...
(gdb) PASS: gdb.arch/amd64-disp-step-avx.exp: vex3: \
  var128 has expected value after
continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0x0000000000400283 in _exit (status=0) at \
  ../sysdeps/unix/sysv/linux/_exit.c:33^M
33      ../sysdeps/unix/sysv/linux/_exit.c: No such file or directory.^M
(gdb) FAIL: gdb.arch/amd64-disp-step-avx.exp: \
  continue until exit at amd64-disp-step-avx
...

This is not related to gdb, we get the same result by just running the exec.

The problem is that the test-case:
- calls glibc's _exit, and
- uses -nostartfiles -static, putting the burden for any necessary
  initialization for calling glibc's _exit on the test-case itself.

So, when we get to the second insn in _exit:
...
000000000040acb0 <_exit>:
  40acb0:       48 63 d7                movslq %edi,%rdx
  40acb3:       64 4c 8b 14 25 00 00    mov    %fs:0x0,%r10
...
no glibc-related initialization is done, and we run into the segfault.

Adding this (borrowed from __libc_start_main) in _start in the .S file is
sufficient to fix it:
...
         .rept 200
         nop
+        call __pthread_initialize_minimal
         .endr
...
But that already doesn't compile with say glibc 2.31, and regardless I think
this sort of fix is too fragile.

We could of course fix this by simply not running to exit.  But ideally we'd
have an exec that doesn't segfault when you just run it.

Alternatively, we could hand-code an _exit syscall and bypass glibc
all together.  But I'd rather fix this in a way that simplifies the test-case.

Taking a step back, the -nostartfiles -static was added to address that the
xmm registers were not zero at main (which AFAICT is a valid thing to happen).

[ The change itself silently broke the test-case, needing further fixing by
commit 40310f30a51 ("gdb: make gdb.arch/amd64-disp-step-avx.exp actually test
displaced stepping"). ]

Instead, simplify things by reverting to the original situation:
- no -nostartfiles -static compilation flags,
- no _start in the .S file,
- use exit instead of _exit in the .S file,
and fix the original problem by setting the xmm registers to zero rather than
checking that they're zero.

Now that we're no longer forcing -static, add nopie to the flags to prevent
compilation failure with target board unix/-fPIE/-pie.

Tested on x86_64-linux.

PR testsuite/30132
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30132

21 months agold test asciz and ascii fails
Alan Modra [Fri, 17 Feb 2023 03:20:18 +0000 (13:50 +1030)]
ld test asciz and ascii fails

Fix these fails:
alpha-dec-vms  +FAIL: ld-scripts/asciz
alpha-dec-vms  +FAIL: ld-scripts/ascii
i386-go32  +FAIL: ld-scripts/asciz
sh-coff  +FAIL: ld-scripts/asciz

It's better to positively select targets for .section support than to
try to exclude all targets that don't.  Make a new is_coff_format so
we can easily select such.

binutils/
* testsuite/lib/binutils-common.exp (is_coff_format): New.
ld/
* testsuite/ld-scripts/ascii.d: Use is_elf_format and
is_coff_format to select targets, exclude ti coff.
* testsuite/ld-scripts/asciz.d: Likewise.  Accept trailing zeros.

21 months agoWild pointer reads in _bfd_ecoff_locate_line
Alan Modra [Fri, 17 Feb 2023 01:56:13 +0000 (12:26 +1030)]
Wild pointer reads in _bfd_ecoff_locate_line

* ecofflink.c (mk_fdrtab): Sanity check fdr procedure descriptor
pointer and isymBase.  Set fdrtab_len after possible discards.
Use size_t vars and catch possible size overflows.

21 months agoAutomatic date update in version.in
GDB Administrator [Fri, 17 Feb 2023 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoPR30046, power cmpi leads to unknown architecture
Alan Modra [Thu, 16 Feb 2023 10:17:44 +0000 (20:47 +1030)]
PR30046, power cmpi leads to unknown architecture

PowerPC ELF always uses bfd_arch_powerpc, so we shouldn't allow the
gas -mpwr, -mpwr2 or -mpwrx options to choose bfd_arch_rs6000.
Given the possible values of ppc_cpu, I think the as_fatal at the end
of ppc_arch will never be reached, so it can be deleted and the code
simplified a little.

PR 30046
* config/tc-ppc.c (ppc_arch): Return bfd_arch_powerpc for ELF.
Delete dead code.

21 months agoRename parameter of create_ada_exception_catchpoint
Tom Tromey [Thu, 16 Feb 2023 17:27:26 +0000 (10:27 -0700)]
Rename parameter of create_ada_exception_catchpoint

create_ada_exception_catchpoint has a parameter named "disabled", but
both its callers and callees use it to mean "enabled".  This is
confusing, so this patch renames the parameter.

21 months agoUpdate the 'g' packet documentation
Tom Tromey [Wed, 11 Jan 2023 18:37:25 +0000 (11:37 -0700)]
Update the 'g' packet documentation

The 'g' packet documentation references a macro that no longer exists,
and it also claims that the 'x' response for an unavailable register
is limited to trace frames.  This patch updates the documentation to
reflect what I think is currently correct.

Co-Authored-By: Pedro Alves <pedro@palves.net>
Approved-By: Eli Zaretskii <eliz@gnu.org>
Change-Id: I863baa3b9293059cfd4aa3d534602cbcb693ba87

21 months agoAdd support for the ASCII directive inside linker scripts.
Nick Clifton [Thu, 16 Feb 2023 16:27:08 +0000 (16:27 +0000)]
Add support for the ASCII directive inside linker scripts.

 * ldlex.l: Add ASCII token.
 * ldgram.y: Add parsing of the ASCII command.
 * ldlang.c (lang_add_string): Add maximum size parameter.  Move escape character handling code into separate function.
 * ldlang.h (lang_add_string): Update prototype.
 * NEWS: Mention the new feature.
 * ld.texi (Output Section Data): Document the new directives.
 * testsuite/ld-scripts/asciz.t: Adjust to work on more architectures and to test more aspects of the ASCIZ directive.
 * testsuite/ld-scripts/asciz.d: Adjust to match the changes to the test linker script.
 * testsuite/ld-scripts/ascii.d: New test driver.
 * testsuite/ld-scripts/ascii.s: New test assembler source.
 * testsuite/ld-scripts/ascii.t: New test script.
 * testsuite/ld-scripts/script.exp: Run the new test.

21 months agoConstify ada_main_name
Tom Tromey [Thu, 16 Feb 2023 15:10:59 +0000 (08:10 -0700)]
Constify ada_main_name

Unlike the other *_main_name functions, ada_main_name returns a
non-const "char *".  This is strange, though, because the caller
should not in fact modify or free this pointer.  This patch changes
this function to constify its return type.

21 months agoRemove unused declaration from ada-lang.h
Tom Tromey [Thu, 16 Feb 2023 15:08:31 +0000 (08:08 -0700)]
Remove unused declaration from ada-lang.h

I stumbled across this declaration in ada-lang.h.  I don't know what
function did, but it no longer exists, so remove the declaration.
Tested by rebuilding.