Maciej W. Rozycki [Fri, 28 Jul 2023 05:00:36 +0000 (06:00 +0100)]
MIPS/LD/testsuite: Fix unaligned JALX failures with OpenBSD targets
There are only n64 linker emulations included with `mips64*-*-openbsd*'
targets, however the unaligned JALX tests insist on running across all
targets and force the n32 ABI, causing link errors with the targets
concerned, e.g.:
./ld-new: tmpdir/unaligned-jalx-0.o: ABI is incompatible with that of the selected emulation
./ld-new: failed to merge target specific data of file tmpdir/unaligned-jalx-0.o
./ld-new: tmpdir/unaligned-insn.o: ABI is incompatible with that of the selected emulation
./ld-new: failed to merge target specific data of file tmpdir/unaligned-insn.o
Convert the tests then to use the per-ABI framework and run them for the
o32 and n32 ABIs, removing these regressions:
mips64-openbsd -FAIL: MIPS JALX to unaligned symbol 0
mips64-openbsd -FAIL: MIPS JALX to unaligned symbol 1
mips64-openbsd -FAIL: MIPS JALX to unaligned symbol 2
mips64-openbsd -FAIL: MIPS JALX to unaligned symbol 3
mips64-openbsd -FAIL: MIPS16 JALX to unaligned symbol 0
mips64-openbsd -FAIL: MIPS16 JALX to unaligned symbol 1
mips64-openbsd -FAIL: microMIPS JALX to unaligned symbol 0
mips64-openbsd -FAIL: microMIPS JALX to unaligned symbol 1
mips64el-openbsd -FAIL: MIPS JALX to unaligned symbol 0
mips64el-openbsd -FAIL: MIPS JALX to unaligned symbol 1
mips64el-openbsd -FAIL: MIPS JALX to unaligned symbol 2
mips64el-openbsd -FAIL: MIPS JALX to unaligned symbol 3
mips64el-openbsd -FAIL: MIPS16 JALX to unaligned symbol 0
mips64el-openbsd -FAIL: MIPS16 JALX to unaligned symbol 1
mips64el-openbsd -FAIL: microMIPS JALX to unaligned symbol 0
mips64el-openbsd -FAIL: microMIPS JALX to unaligned symbol 1
Similar tests for the n64 ABI can be added separately, using suitable
dump patterns.
ld/
* testsuite/ld-mips-elf/unaligned-jalx-0.d: Remove `-32' from
the `as' tag.
* testsuite/ld-mips-elf/unaligned-jalx-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-2.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-3.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-micromips-0.d: Likewise.
* testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d: Likewise.
* testsuite/ld-mips-elf/mips-elf.exp: Run unaligned JALX tests
with `run_dump_test_o32' and `run_dump_test_n32' rather than
`run_dump_test'.
Maciej W. Rozycki [Fri, 28 Jul 2023 05:00:36 +0000 (06:00 +0100)]
MIPS/GAS/testsuite: Disable compact EH #7 tests with OpenBSD targets
Compact EH #7 tests use output templates that are not suitable for the
n64 ABI, which `mips64*-*-openbsd*' targets use by default, because the
contents of the sections examined are expected to be differnt. Disable
the tests then, removing these regressions:
mips64-openbsd -FAIL: Compact EH EB #7 with personality id and fallback FDE
mips64-openbsd -FAIL: Compact EH EL #7 with personality id and fallback FDE
mips64el-openbsd -FAIL: Compact EH EB #7 with personality id and fallback FDE
mips64el-openbsd -FAIL: Compact EH EL #7 with personality id and fallback FDE
Suitable corresponding tests for the n64 ABI can be added separately.
gas/
* testsuite/gas/mips/compact-eh-eb-7.d: Exclude for
`mips64*-*-openbsd*'.
* testsuite/gas/mips/compact-eh-el-7.d: Likewise.
YunQiang Su [Fri, 28 Jul 2023 05:00:36 +0000 (06:00 +0100)]
MIPS/LD: Include n64 `.interp' with INITIAL_READONLY_SECTIONS
In ld/emulparams/elf64bmip-defs.sh there is no explicit handling of the
`.interp' section, which causes it to be positioned in output at an odd
place.
Let's include it with INITIAL_READONLY_SECTIONS, just like o32/n32 do,
fixing a regression from commit
5a8e7be242f3 ("INITIAL_READONLY_SECTIONS
in elf.sc"), where the handling of n64 was missed due to an unfortunate
sequence of events where ld/emulparams/elf64bmip-defs.sh was only added
with commit
94bb04b3c611 ("Use .reginfo rather than .MIPS.options in n32
linker scripts") the day before.
Add test cases covering section ordering across the three ABIs. This
change also fixes ld/pr23658-2:
FAIL: Build pr23658-2
Co-Authored-By: Maciej W. Rozycki <macro@orcam.me.uk>
ld/ChangeLog:
* emulparams/elf64bmip-defs.sh: Include `.interp' with
INITIAL_READONLY_SECTIONS.
* testsuite/ld-mips-elf/pie-n64.d: Adjust addresses.
* testsuite/ld-mips-elf/sections-1-o32.rd: New test.
* testsuite/ld-mips-elf/sections-1-o32t.rd: New test.
* testsuite/ld-mips-elf/sections-1-n32.rd: New test.
* testsuite/ld-mips-elf/sections-1-n32t.rd: New test.
* testsuite/ld-mips-elf/sections-1-n32p.rd: New test.
* testsuite/ld-mips-elf/sections-1-n64.rd: New test.
* testsuite/ld-mips-elf/sections-1-n64t.rd: New test.
* testsuite/ld-mips-elf/sections-2-o32.rd: New test.
* testsuite/ld-mips-elf/sections-2-o32t.rd: New test.
* testsuite/ld-mips-elf/sections-2-n32.rd: New test.
* testsuite/ld-mips-elf/sections-2-n32t.rd: New test.
* testsuite/ld-mips-elf/sections-2-n32p.rd: New test.
* testsuite/ld-mips-elf/sections-2-n64.rd: New test.
* testsuite/ld-mips-elf/sections-2-n64t.rd: New test.
* testsuite/ld-mips-elf/sections.s: New test source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Maciej W. Rozycki [Fri, 28 Jul 2023 05:00:36 +0000 (06:00 +0100)]
Revert "MIPS: support mips*64 as CPU and gnuabi64 as ABI"
This reverts commit
32f1c80375ebe8ad25d9805ee5889f0006c51e59. It had
two unrelated changes lumped together, one of which changed the meaning
of the `mipsisa64*-*-linux*' target triplets, which was not properly
evaluated.
Alan Modra [Fri, 28 Jul 2023 03:36:17 +0000 (13:06 +0930)]
ldscripts/empty-address vs. xcoff
The empty-address tests check that if a section is removed by ld due
to being empty then properties of that section don't affect following
addresses. The xcoff backend doesn't remove the empty .data section
created by empty-address-2* and empty-address-3* for some reason, and
therefore fails the test.
* testsuite/ld-scripts/empty-address-1.d: Accept more symbols.
* testsuite/ld-scripts/empty-address-2a.d: xfail for xcoff.
* testsuite/ld-scripts/empty-address-2b.d: Likewise.
* testsuite/ld-scripts/empty-address-3a.d: Likewise.
* testsuite/ld-scripts/empty-address-3b.d: Likewise.
Alan Modra [Fri, 28 Jul 2023 03:33:46 +0000 (13:03 +0930)]
Fix recent x86 pe/coff testsuite regressions
* testsuite/gas/i386/sha512-intel.d: Accept section nop padding.
* testsuite/gas/i386/sha512.d: Likewise.
* testsuite/gas/i386/sm3-intel.d: Likewise.
* testsuite/gas/i386/sm3.d: Likewise.
* testsuite/gas/i386/x86-64-pbndkb-intel.d: Likewise.
* testsuite/gas/i386/x86-64-pbndkb.d: Likewise.
* testsuite/gas/i386/x86-64-sha512-intel.d: Likewise.
* testsuite/gas/i386/x86-64-sha512.d: Likewise.
* testsuite/gas/i386/x86-64-sm3-intel.d: Likewise.
* testsuite/gas/i386/x86-64-sm3.d: Likewise.
Alan Modra [Fri, 28 Jul 2023 03:14:17 +0000 (12:44 +0930)]
coff/pe/xcoff and --extract-symbols
This fixes failure of the "extract symbols" test for rs6000, where
--extract-symbols generates a non-zero sized .text. By the look of
coffcode.h the same problem might occur for coff/pe too, but doesn't
happen to trigger a test failure.
bfd/
* coffcode.h (coff_compute_section_file_positions): Don't
adjust size of !SEC_LOAD sections.
binutils/
* objcopy.c (setup_section): Clear SEC_LOAD for --extract-symbol.
Tsukasa OI [Wed, 26 Jul 2023 01:39:44 +0000 (01:39 +0000)]
RISC-V: Add actual 'Zvkt' extension support
The 'Zvkt' extension is listed on the added extensions in the GNU Binutils
version 2.41 (see binutils/NEWS). However, the support of this extension
was actually missing.
This commit adds actual support of this extension and adds implications
from 'Zvkn' and 'Zvks' superset extensions.
bfd/ChangeLog:
* elfxx-riscv.c (riscv_implicit_subsets) Add implications from
'Zvkn' and 'Zvks'. (riscv_supported_std_z_ext): Add 'Zvkt' to
the supported extension list.
Tsukasa OI [Fri, 28 Jul 2023 03:33:39 +0000 (03:33 +0000)]
Fix typo in riscv-dis.c comment
Don't go "past" the start of the section.
GDB Administrator [Fri, 28 Jul 2023 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Thu, 27 Jul 2023 17:32:38 +0000 (13:32 -0400)]
gdb: remove trailing empty line in target-delegates.c
In a review [1], I pointed out that applying the patch, git would say:
.git/rebase-apply/patch:147: new blank line at EOF.
However, since the empty line is in target-delegates.c (a generated
file), there's nothing the author can do about it. To avoid this
comment coming up again in the future, change make-target-delegates.py
to avoid the trailing empty line. Do this by making it output empty
lines before each entity, not after.
Since this needs removing a newline output in gdbcopyright, adjust
ada-unicode.py and gdbarch.py to avoid changes in the files they
generate.
[1] https://inbox.sourceware.org/gdb-patches/
20230427210113.45380-1-jhb@FreeBSD.org/T/#m083598405bef19157f67c9d97846d3dd90dc7d1c
Change-Id: Ic4c648f06443b432168cb76603402c918aa6e5d2
Approved-By: Tom Tromey <tom@tromey.com>
Tom Tromey [Thu, 27 Jul 2023 16:31:32 +0000 (10:31 -0600)]
Report supportsBreakpointLocationsRequest
While looking at the DAP spec, I noticed that the breakpointLocations
request is gated behind a capability. This patch changes gdb to
report this capability.
I've also added a comment to explain the fact that arguments to
breakpointLocations are not optional, even though the spec says they
are.
Alan Modra [Thu, 27 Jul 2023 08:33:49 +0000 (18:03 +0930)]
/DISCARD/ in ld testsuite
The canonical form to discard all sections not mentioned earlier in
the script is
/DISCARD/ : { *(*) }
not
/DISCARD/ : { *(.*) }
".*" happens to work with the usual section names starting with a dot,
but let's not promote something not quite right.
Alan Modra [Wed, 26 Jul 2023 23:43:56 +0000 (09:13 +0930)]
sh: uninitialised sh_operand_info.type in get_specific
Seen when running gas/testsuite/gas/sh/err-at.s
* config/tc-sh.c (get_operands): Always init operand type.
* testsuite/gas/sh/err-at.s: Expect unnecessary extra errors.
Hu, Lin1 [Mon, 24 Jul 2023 03:10:03 +0000 (11:10 +0800)]
Support Intel PBNDKB
gas/ChangeLog:
* NEWS: Support Intel PBNDKB.
* config/tc-i386.c: Add pbndkb.
* doc/c-i386.texi: Document .pbndkb.
* testsuite/gas/i386/i386.exp: Add PBNDKB tests.
* testsuite/gas/i386/x86-64.exp: Ditto.
* testsuite/gas/i386/pbndkb-inval.l: New test.
* testsuite/gas/i386/pbndkb-inval.s: Ditto.
* testsuite/gas/i386/x86-64-pbndkb-intel.d: Ditto.
* testsuite/gas/i386/x86-64-pbndkb.d: Ditto.
* testsuite/gas/i386/x86-64-pbndkb.s: Ditto.
opcodes/ChangeLog:
* i386-dis.c (X86_64_0F01_REG_0_MOD_3_RM_7): New.
(X86_64_0F01_REG_0_MOD_3_RM_7_P_0): Ditto.
(prefix_table): Add PREFIX_0F01_REG_0_MOD_3_RM_7.
(x86_64_table): Add X86_64_0F01_REG_0_MOD_3_RM_7_P_0.
(rm_table): New entry for pbndkb.
* i386-gen.c (cpu_flag): Add PBNDKB.
* i386-init.h: Regenerated.
* i386-mnem.h: Ditto.
* i386-opc.h (CpuPBNDKB): New.
(i386_cpu_flags): Add cpupbndkb.
* i386-opc.tbl: Add PBNDKB instructions.
* i386-tbl.h: Regenerated.
Haochen Jiang [Mon, 24 Jul 2023 03:09:57 +0000 (11:09 +0800)]
Support Intel SM4
gas/ChangeLog:
* NEWS: Support Intel SM4.
* config/tc-i386.c: Add sm4.
* doc/c-i386.texi: Document .sm4.
* testsuite/gas/i386/i386.exp: Run SM4 tests.
* testsuite/gas/i386/x86-64.exp: Ditto.
* testsuite/gas/i386/sm4-intel.d: Add SM4 tests.
* testsuite/gas/i386/sm4.d: Ditto.
* testsuite/gas/i386/sm4.s: Ditto.
* testsuite/gas/i386/x86-64-sm4-intel.d: Ditto.
* testsuite/gas/i386/x86-64-sm4.d: Ditto.
* testsuite/gas/i386/x86-64-sm4.s: Ditto.
opcodes/ChangeLog:
* i386-dis.c (prefix_table): Add SM4 instructions.
* i386-gen.c (isa_dependencies): Add SM4.
(cpu_flags): Ditto.
* i386-init.h: Regenerated.
* i386-mnem.h: Ditto.
* i386-opc.h (CpuSM4): New.
(i386_cpu_flags): Add cpusm4.
* i386-opc.tbl: Add SM4 instructions.
* i386-tbl.h: Regenerated.
Haochen Jiang [Mon, 24 Jul 2023 03:09:49 +0000 (11:09 +0800)]
Support Intel SM3
gas/ChangeLog:
* NEWS: Support Intel SM3.
* config/tc-i386.c: Add sm3.
* doc/c-i386.texi: Document .sm3.
* testsuite/gas/i386/i386.exp: Run sm3 tests.
* testsuite/gas/i386/x86-64.exp: Ditto.
* testsuite/gas/i386/sm3-intel.d: New test.
* testsuite/gas/i386/sm3.d: Ditto.
* testsuite/gas/i386/sm3.s: Ditto.
* testsuite/gas/i386/x86-64-sm3-intel.d: Ditto.
* testsuite/gas/i386/x86-64-sm3.d: Ditto.
* testsuite/gas/i386/x86-64-sm3.s: Ditto.
opcodes/ChangeLog:
* i386-dis.c (PREFIX_VEX_0F38DA_W_0): New.
(VEX_LEN_0F38DA_W_0_P_0): Ditto.
(VEX_LEN_0F38DA_W_0_P_2): Ditto.
(VEX_LEN_0F3ADE_W_0): Ditto.
(VEX_W_0F38DA): Ditto.
(VEX_W_0F3ADE): Ditto.
(prefix_table): Add PREFIX_VEX_0F38DA_W_0.
(vex_len_table): Add VEX_LEN_0F38DA_W_0_P_0,
VEX_LEN_0F38DA_W_0_P_2, VEX_LEN_0F3ADE_W_0.
(vex_w_table): Add VEX_W_0F38DA, VEX_W_0F3ADE.
* i386-gen.c (isa_dependencies): Add SM3.
(cpu_flags): Ditto.
* i386-init.h: Regenerated.
* i386-mnem.h: Ditto.
* i386-opc.h (CpuSM3): New.
(i386_cpu_flags): Add cpusm3.
* i386-opc.tbl: Add SM3 instructions.
* i386-tbl.h: Regenerated.
Haochen Jiang [Mon, 24 Jul 2023 03:09:43 +0000 (11:09 +0800)]
Support Intel SHA512
gas/ChangeLog:
* NEWS: Support Intel SHA512.
* config/tc-i386.c: Add sha512.
* doc/c-i386.texi: Document .sha512.
* testsuite/gas/i386/disassem.d: Add SHA512 tests.
* testsuite/gas/i386/disassem.s: Ditto.
* testsuite/gas/i386/i386.exp: Run SHA512 tests.
* testsuite/gas/i386/x86-64.exp: Ditto.
* testsuite/gas/i386/sha512-intel.d: New test.
* testsuite/gas/i386/sha512-inval.l: Ditto.
* testsuite/gas/i386/sha512-inval.s: Ditto.
* testsuite/gas/i386/sha512.d: Ditto.
* testsuite/gas/i386/sha512.s: Ditto.
* testsuite/gas/i386/x86-64-sha512-intel.d: Ditto.
* testsuite/gas/i386/x86-64-sha512-inval.l: Ditto.
* testsuite/gas/i386/x86-64-sha512-inval.s: Ditto.
* testsuite/gas/i386/x86-64-sha512.d: Ditto.
* testsuite/gas/i386/x86-64-sha512.s: Ditto.
opcodes/ChangeLog:
* i386-dis.c (Rxmmq): New.
(Rymm): Ditto.
(PREFIX_VEX_0F38CB): Ditto.
(PREFIX_VEX_0F38CC): Ditto.
(PREFIX_VEX_0F38CD): Ditto.
(VEX_LEN_0F38CB_P_3_W_0): Ditto.
(VEX_LEN_0F38CC_P_3_W_0): Ditto.
(VEX_LEN_0F38CD_P_3_W_0): Ditto.
(VEX_W_0F38CB_P_3): Ditto.
(VEX_W_0F38CC_P_3): Ditto.
(VEX_W_0F38CD_P_3): Ditto.
(prefix_table): Add PREFIX_VEX_0F38CB, PREFIX_VEX_0F38CC,
PREFIX_VEX_0F38CD.
(vex_len_table): Add VEX_LEN_0F38CB_P_3_W_0,
VEX_LEN_0F38CC_P_3_W_0, VEX_LEN_0F38CD_P_3_W_0.
(vex_w_table): Add VEX_W_0F38CB_P_3, VEX_W_0F38CC_P_3, VEX_W_0F38CD_P_3.
* i386-gen.c (isa_dependencies): Add SHA512.
(cpu_flags): Ditto.
* i386-init.h: Regenerated.
* i386-mnem.h: Ditto.
* i386-opc.h (CpuSHA512): New.
(i386_cpu_flags): Add cpusha512.
* i386-opc.tbl: Add SHA512 instructions.
* i386-tbl.h: Regenerated.
konglin1 [Mon, 24 Jul 2023 03:09:35 +0000 (11:09 +0800)]
Support Intel AVX-VNNI-INT16
gas/ChangeLog:
* NEWS: Support Intel AVX-VNNI-INT16.
* config/tc-i386.c: Add avx_vnni_int16.
* doc/c-i386.texi: Document avx_vnni_int16.
* testsuite/gas/i386/i386.exp: Run AVX VNNI INT16 tests.
* testsuite/gas/i386/x86-64.exp: Ditto.
* testsuite/gas/i386/avx-vnni-int16-intel.d: New test.
* testsuite/gas/i386/avx-vnni-int16.d: New test.
* testsuite/gas/i386/avx-vnni-int16.s: New test.
* testsuite/gas/i386/x86-64-avx-vnni-int16-intel.d: New test.
* testsuite/gas/i386/x86-64-avx-vnni-int16.d: New test.
* testsuite/gas/i386/x86-64-avx-vnni-int16.s: New test.
opcodes/ChangeLog:
* i386-dis.c (PREFIX_VEX_0F38D2_W_0): New.
(PREFIX_VEX_0F38D3_W_0): Ditto.
(VEX_W_0F38D2_P_0): Ditto.
(VEX_W_0F38D2_P_1): Ditto.
(VEX_W_0F38D2_P_2): Ditto.
(VEX_W_0F38D3_P_0): Ditto.
(VEX_W_0F38D3_P_1): Ditto.
(VEX_W_0F38D3_P_2): Ditto.
(prefix_table): Add PREFIX_VEX_0F38D2_W_0 and
PREFIX_VEX_0F38D3_W_0.
(vex_table): Add VEX_W_0F38D2 and VEX_W_0F38D3.
(vex_w_table): Ditto.
* i386-gen.c (isa_dependencies): Add AVX_VNNI_INT16.
(cpu_flag): Ditto.
* i386-init.h: Regenerated.
* i386-mnem.h: Ditto.
* i386-opc.h: (CpuAVX_VNNI_INT16): New.
* i386-opc.tbl: Add Intel AVX_VNNI_INT16 instructions.
* i386-tbl.h: Regenerated.
GDB Administrator [Thu, 27 Jul 2023 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Wed, 26 Jul 2023 19:40:01 +0000 (21:40 +0200)]
[gdb/testsuite] Fix gdb.python/py-thread-exited.exp
Two fixes in gdb.python/py-thread-exited.exp:
- fix the copyright notice validity range (PR testsuite/30687):
2022-202 -> 2022-2023, and
- add missing "require allow_python_tests".
Tested on x86_64-linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30687
David Faust [Mon, 24 Jul 2023 21:57:35 +0000 (14:57 -0700)]
bpf: accept # as an inline comment char
This little patch makes the BPF assembler accept '#' as an inline
comment character, which clang -S seems to use.
gas/
* config/tc-bpf.c (comment_chars): Add '#'.
* doc/c-bpf.texi (BPF Special Characters): Add note that '#' may
be used for inline comments.
Tom de Vries [Wed, 26 Jul 2023 15:06:23 +0000 (17:06 +0200)]
[gdb/build] Fix Wstringop-truncation in coff_getfilename
When building gdb with -O2 -fsanitize-threads, I ran into
a Werror=stringop-truncation.
The problem is here in coff_getfilename in coffread.c:
...
strncpy (buffer, aux_entry->x_file.x_n.x_fname, FILNMLEN);
buffer[FILNMLEN] = '\0';
...
The constant FILNMLEN is expected to designate the size of
aux_entry->x_file.x_n.x_fname, but that's no longer the case since commit
60ebc257517 ("Fixes a buffer overflow when compiling assembler for the MinGW
targets.").
Fix this by using "sizeof (aux_entry->x_file.x_n.x_fname)" instead.
Likewise in xcoffread.c.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
PR build/30669
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30669
Jose E. Marchesi [Wed, 26 Jul 2023 13:02:08 +0000 (15:02 +0200)]
bpf: gas: add negi and neg32i tests
gas/ChangeLog:
2023-07-26 Jose E. Marchesi <jose.marchesi@oracle.com>
* testsuite/gas/bpf/alu.s: Add test for NEGI and NEG32I.
* testsuite/gas/bpf/alu32.s: Likewise.
* testsuite/gas/bpf/alu-pseudoc.s: Likewise.
* testsuite/gas/bpf/alu32-pseudoc.s: Likewise.
* testsuite/gas/bpf/alu.d: Add expected results.
* testsuite/gas/bpf/alu-be.d: Likewise.
* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu32.d: Likewise.
* testsuite/gas/bpf/alu32-be.d: Likewise.
* testsuite/gas/bpf/alu32-be-pseudoc.d: Likewise.
Tom de Vries [Wed, 26 Jul 2023 11:42:32 +0000 (13:42 +0200)]
[gdb/testsuite] Drop -nostdlib in gdb.dwarf2/typeddwarf.exp
As reported in PR testsuite/30633, when running test-case
gdb.dwarf2/typeddwarf.exp with target board native-gdbserver on Ubuntu
22.04.2, we run into:
...
(gdb) continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0x0000000000000001 in ?? ()^M
(gdb) FAIL: gdb.dwarf2/typeddwarf.exp: runto: run to main
...
We run into the FAIL as follows:
- due to using gdbserver, we attach at the point of the first instruction, in
_start
- we then set a breakpoint at main
- the test-case is a .s file, that has main renamed to _start in the assembly,
but not in the debuginfo
- setting a breakpoint at main sets the breakpoint at the same instruction
we're currently stopped at
- continue doesn't hit the breakpoint, and we return out of _start, which
causes a sigsegv
Note that this is for the amd64 case (using gdb.dwarf2/typeddwarf-amd64.S).
For the i386 case (using gdb.dwarf2/typeddwarf.S), setting a breakpoint in
main sets it one insn after function entry, and consequently the problem does
not occur.
The FAIL is a regression since commit
90cce6c0551 ("[gdb/testsuite] Add nopie
in a few test-cases").
Without nopie the executable is PIE, with nopie it's static instead.
In the PIE case, we attach at the point of _start in the dynamic linker, and
consequently we do not skip the breakpoint in main, and also don't run into
the FAIL.
Fix this by:
- removing the -nostdlib setting, and
- renaming _start to main in both .S files.
The change to use -nostdlib and rename main to _start was originally added
in commit
6edba76fe8b (submitted here:
https://sourceware.org/pipermail/gdb-patches/2011-May/082657.html ) , I assume
to fix the problem now fixed by using nopie.
Tested on x86_64-linux.
Reported-By: Simon Marchi <simon.marchi@efficios.com>
Tested-By: Simon Marchi <simon.marchi@efficios.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30633
Tom de Vries [Wed, 26 Jul 2023 11:31:53 +0000 (13:31 +0200)]
[gdb/tui] Fix secondary prompt
With CLI, a session defining a command looks like:
...
(gdb) define foo
Type commands for definition of "foo".
End with a line saying just "end".
>bar
>end
(gdb)
...
With TUI however, we get the same secondary prompts, and type the same, but
are left with:
...
(gdb) define foo
Type commands for definition of "foo".
End with a line saying just "end".
(gdb)
...
Fix this by calling tui_inject_newline_into_command_window in
gdb_readline_wrapper_line, as is done in tui_command_line_handler.
Tested on x86_64-linux.
PR tui/30636
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30636
Tom de Vries [Wed, 26 Jul 2023 11:28:15 +0000 (13:28 +0200)]
[gdb/testsuite] Fix gdb.gdb/python-helper.exp with -O2 -flto=auto and gcc 7.5.0 some more
With a gdb build with -O2 -flto=auto and gcc 7.5.0 and test-case
gdb.gdb/python-helper.exp I run into:
...
(outer-gdb) continue^M
Continuing.^M
print 1^M
^M
Thread 1 "xgdb" hit Breakpoint 2, \
_Z11value_printP5valueP7ui_filePK19value_print_options (val=0x22e2590, \
stream=0x1f65480, options=0x7fffffffcdc0) at gdb/valprint.c:1193^M
1193 {^M
(outer-gdb) FAIL: gdb.gdb/python-helper.exp: hit breakpoint in outer gdb
...
This is the "value_print" variant of the problem with "c_print_type" I fixed
in commit
0d332f11122 ("[gdb/testsuite] Fix gdb.gdb/python-helper.exp with -O2
-flto=auto and gcc 7.5.0").
Fix this likewise.
Tested on x86_64-linux.
Tom de Vries [Wed, 26 Jul 2023 10:29:28 +0000 (12:29 +0200)]
[gdb/tui] Fix assert in ~gdbpy_tui_window_maker
In gdb/tui/tui-layout.c, we have:
...
static window_types_map known_window_types;
...
and in gdb/python/py-tui.c:
...
/* A global list of all gdbpy_tui_window_maker objects. */
static intrusive_list<gdbpy_tui_window_maker> m_window_maker_list;
};
/* See comment in class declaration above. */
intrusive_list<gdbpy_tui_window_maker>
gdbpy_tui_window_maker::m_window_maker_list;
...
With a gdb build with -O0 or -O2, the static destructor calling order seems to be:
- first gdb/tui/tui-layout.c,
- then gdb/python/py-tui.c.
So when running test-case gdb.python/tui-window-factory.exp, we see the
following order of events:
- the destructor for known_window_types is called, which triggers calling the
destructor for the only element E of m_window_maker_list. The destructor
destroys E, and also removes E from m_window_maker_list, leaving it empty.
- the destructor for m_window_maker_list is called. It's empty, so it's a nop.
However, when building gdb with -O2 -flto=auto, the static destructor calling
order seems to be reversed.
Instead, we have these events:
- the destructor for m_window_maker_list is called. This doesn't destroy it's
only element E, but it does make m_window_maker_list empty.
- the destructor for known_window_types is called, which triggers calling the
destructor for E. An attempt is done to remove E from m_window_maker_list,
but we run into an assertion failure, because the list is empty.
Fix this by checking is_linked () before attempting to remove from
m_window_maker_list, similar to how things were addressed in commit
995a34b1772
("Guard against frame.c destructors running before frame-info.c's").
Tested on x86_64-linux.
PR tui/30646
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30646
Tom de Vries [Wed, 26 Jul 2023 09:53:31 +0000 (11:53 +0200)]
[gdb/testsuite] Fix regexps in gdb.base/step-over-syscall.exp
When running test-case gdb.base/step-over-syscall.exp without glibc debuginfo
installed, I get:
...
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, 0x00007ffff7d4405e in vfork () from /lib64/libc.so.6^M
(gdb) PASS: gdb.base/step-over-syscall.exp: vfork: displaced=off: \
continue to vfork (1st time)
...
but with glibc debuginfo installed I get instead:
...
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, 0x00007ffff7d4405e in __libc_vfork () at \
../sysdeps/unix/sysv/linux/x86_64/vfork.S:44^M
44 ENTRY (__vfork)^M
(gdb) FAIL: gdb.base/step-over-syscall.exp: vfork: displaced=off: \
continue to vfork (1st time)
...
The FAIL is due to a mismatch with regexp:
...
"Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*"
...
because it cannot match both ".* in " and the __libc_ prefix.
Fix this by using instead the regexp:
...
"Breakpoint \[0-9\]+, (.* in )?(__libc_)?$syscall \\(\\).*"
...
Tested on x86_64-linux.
Jose E. Marchesi [Wed, 26 Jul 2023 09:44:20 +0000 (11:44 +0200)]
bpf: fix neg and neg32 BPF instructions in simulator
This patch fixes the semantics of the neg and neg32 BPF instructions
in the simulator, and also updates the corresponding tests
accordingly.
Tested in target bpf-unknown-none.
Jose E. Marchesi [Wed, 26 Jul 2023 09:38:04 +0000 (11:38 +0200)]
bpf: fix register NEG[32] instructions
This patch fixes the BPF_INSN_NEGR and BPF_INSN_NEG32R BPF
instructions to not use their source registers.
Tested in bpf-unknown-none.
opcodes/ChangeLog:
2023-07-26 Jose E. Marchesi <jose.marchesi@oracle.com>
* bpf-opc.c (bpf_opcodes): Fix BPF_INSN_NEGR to not use a src
register.
gas/ChangeLog:
2023-07-26 Jose E. Marchesi <jose.marchesi@oracle.com>
* testsuite/gas/bpf/alu.s: The register neg instruction gets only
one argument.
* testsuite/gas/bpf/alu32-be-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu32-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu32-pseudoc.s: Likewise.
* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu-pseudoc.s: Likewise.
* testsuite/gas/bpf/alu-be.d: Likewise.
* testsuite/gas/bpf/alu.d: Likewise.
* testsuite/gas/bpf/alu32-be.d: Likewise.
* testsuite/gas/bpf/alu32.d: Likewise.
* testsuite/gas/bpf/alu32.s: Likewise.
* doc/c-bpf.texi (BPF Instructions): Update accordingly.
Alan Modra [Wed, 26 Jul 2023 00:24:03 +0000 (09:54 +0930)]
PR30657, gprof heap buffer overflow
PR 30657
* cg_arcs.c (cg_assemble): Sanity check find_call addresses.
* i386.c (i386_find_call): Don't access past end of core_text_space.
* aarch64.c (aarch64_find_call): Round up lowpc, round down highpc.
* alpha.c (alpha_find_call): Likewise.
* mips.c (mips_find_call): Likewise.
* sparc.c (sparc_find_call): Likewise.
* vax.c (vax_find_call): Sanity check core_text_space accesses.
Alan Modra [Fri, 21 Jul 2023 07:27:18 +0000 (16:57 +0930)]
[GOLD] reporting local symbol names
get_symbol_name currently returns "" for the usual STT_SECTION symbols
generated by gas. That's not very helpful, return the section name.
Demangle local symbols too, fixing an inconsistency in
issue_discarded_error where global symbols are demangled.
* object.cc (Sized_relobj_file::get_symbol_name): Return a
std::string. Return section name for STT_SECTION symbols with
zero st_name. Sanity check st_name, and don't run off the end
of an improperly terminated .strtab. Demangle sym names.
* object.h (Sized_relobj_file::get_symbol_name): Update decl.
* target-reloc.h (issue_discarded_error): Adjust.
* powerpc.cc (Target_powerpc::Relocate::relocate): Report reloc
type and symbol for relocation overflows.
Alan Modra [Fri, 21 Jul 2023 22:44:38 +0000 (08:14 +0930)]
Don't warn on .attach_to_group to same group
* config/obj-elf.c (obj_elf_attach_to_group): Don't warn if
group name matches current group for section.
Alan Modra [Tue, 25 Jul 2023 06:41:51 +0000 (16:11 +0930)]
bpf: format not a string literal
* config/tc-bpf.c (md_assemble): Correct as_bad call.
Alan Modra [Fri, 21 Jul 2023 12:19:27 +0000 (21:49 +0930)]
Regen bpf opcodes POTFILE
GDB Administrator [Wed, 26 Jul 2023 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in
David Faust [Mon, 24 Jul 2023 21:50:34 +0000 (14:50 -0700)]
bpf: Add atomic compare-and-exchange instructions
This patch adds the two remaining BPF v3 atomic instructions:
- BPF_INSN_ACMP{,32}: atomic compare-and-swap
- BPF_INSN_AXCHG{,32}: atomic (non-conditional) exchange
Tests and documentation are also updated.
gas/
* doc/c-bpf.texi (BPF Instructions): Document atomic exchange and
atomic compare-and-swap instructions.
* testsuite/gas/bpf/atomic.s: Test ACMP, ACMP32, AXCHG, AXCGH32
instructions.
* testsuite/gas/bpf/atomic.d: Likewise.
* testsuite/gas/bpf/atomic-be.d: Likewise.
* testsuite/gas/bpf/atomic-pseudoc.s: Likewise.
* testsuite/gas/bpf/atomic-pseudoc.d: Likewise.
* testsuite/gas/bpf/atomic-be-pseudoc.d: Likewise.
include/
* opcode/bpf.h (BPF_IMM32_ACMP): Fix typo.
(enum bpf_insn_id): New entries for BPF_INSN_ACMP{,32} and
BPF_INSN_AXCHG{,32}.
opcodes/
* bpf-opc.c (bpf_opcodes): Add entries for ACMP{,32} and
AXCHG{,32} instructions.
David Faust [Tue, 25 Jul 2023 19:51:47 +0000 (12:51 -0700)]
bpf: Update atomic instruction pseudo-C syntax
This patch updates the pseudo-C dialect templates for the BPF v3 atomic
instructions. The templates match the strings emitted by clang -S for
these instructions.
The tests and documentation are updated accordingly.
gas/
* doc/c-bpf.texi (BPF Instructions): Update entries for atomic
and 32-bit atomic instructions.
* testsuite/gas/bpf/atomic.s: Test AAND, AAND32, AOR, AOR32,
AXOR, AXOR32, AFADD,
AFADD32, AFAND, AFAND32, AFOR, AFOR32,
AFXOR and AFXOR32 instructions.
* testsuite/gas/bpf/atomic.d: Likewise.
* testsuite/gas/bpf/atomic-be.d: Likewise.
* testsuite/gas/bpf/atomic-pseudoc.s: Likewise.
* testsuite/gas/bpf/atomic-pseudoc.d: Likewise.
* testsuite/gas/bpf/atomic-be-pseudoc.d: Likewise.
* testsuite/gas/bpf/atomic-v1.s: New test.
* testsuite/gas/bpf/atomic-v1.d: Likewise.
* testuiste/gas/bpf/atomic-v1-be.d: Likewise.
* testuiste/gas/bpf/bpf.exp: Run new tests.
opcodes/
* bpf-opc.c (bpf_opcodes): Update pseudo-C dialect templates for:
BPF_INSN_AADD, BPF_INSN_AOR, BPF_INSN_AAND, BPF_INSN_AXOR,
BPF_INSN_AFADD, BPF_INSN_AFOR, BPF_INSN_AFAND, BPF_INSN_AFXOR,
BPF_INSN_AADD32, BPF_INSN_AOR32, BPF_INSN_AAND32,
BPF_INSN_AXOR32, BPF_INSN_AFADD32, BPF_INSN_AFOR32,
BPF_INSN_AFAND32, and BPF_INSN_AFXOR32 instructions.
Tsukasa OI [Tue, 25 Jul 2023 01:40:09 +0000 (01:40 +0000)]
RISC-V: Enable RVC on ".option arch, +zca" etc.
Since the 'Zca' extension is the new base of the compressed instructions,
this commit enables RVC *also* when the 'Zca' extension is enabled
via ".option arch" directive.
gas/ChangeLog:
* config/tc-riscv.c (s_riscv_option): Enable RVC also when the
'Zca' extension is enabled after an ".option arch" directive.
GDB Administrator [Tue, 25 Jul 2023 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in
Tsukasa OI [Mon, 24 Jul 2023 05:09:39 +0000 (05:09 +0000)]
RISC-V: Implications from 'Zc[fd]' extensions
The version 1.0.4-1 of the code size reduction specification clarifies
that 'Zcf' implies 'F' and 'Zcd' implies 'D'.
cf:
<https://github.com/riscv/riscv-code-size-reduction/releases/tag/v1.0.4-1>
This commit adds those implications.
bfd/ChangeLog:
* elfxx-riscv.c (riscv_implicit_subsets): Add two implications,
'Zcf' -> 'F' and 'Zcd' -> 'D'.
gas/ChangeLog:
* testsuite/gas/riscv/march-imply-zcd.d: New test.
* testsuite/gas/riscv/march-imply-zcf.d: New test.
Tsukasa OI [Mon, 24 Jul 2023 05:01:12 +0000 (05:01 +0000)]
RISC-V: Prohibit the 'Zcf' extension on RV64
As per:
<https://github.com/riscv/riscv-code-size-reduction/issues/221>,
the 'Zcf' extension does not exist on RV64. This is reflected on the
version 1.0.4-1 of the code size reduction specification:
<https://github.com/riscv/riscv-code-size-reduction/releases/tag/v1.0.4-1>.
This commit prohibits the combination: RV64 (or any ISA with XLEN > 32)
and the 'Zcf' extension.
bfd/ChangeLog:
* elfxx-riscv.c (riscv_parse_check_conflicts): Prohibit
combination of RV64 and 'Zcf'.
gas/ChangeLog:
* testsuite/gas/riscv/march-fail-rv64i_zcf.d: New test.
* testsuite/gas/riscv/march-fail-rv64i_zcf.l: Likewise.
Johannes Schauer Marin Rodrigues [Mon, 24 Jul 2023 15:59:19 +0000 (16:59 +0100)]
objcopy embeds the current time and ignores SOURCE_DATE_EPOCH making the output unreproducible.
bfd
* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined.
binutils
* doc/binutils.texi (objcopy): Document change in behaviour of objcopy's --preserve-dates command line option.
ld
* pe-dll.c (fill_edata): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined.
* ld.texi (--insert-timestamp): Document change in behaviour.
Nick Clifton [Mon, 24 Jul 2023 08:13:29 +0000 (09:13 +0100)]
Updated translations for bfd, gold and opcodes
mengqinggang [Tue, 11 Jul 2023 03:21:18 +0000 (11:21 +0800)]
LoongArch: ld: Simplify inserting IRELATIVE relocations to .rela.dyn
In LoongArch, the R_LARCH_IRELATIVE relocations for local ifunc symbols are
in .rela.dyn. Before, this is done by loongarch_elf_finish_dynamic_sections.
But this function is called after elf_link_sort_relocs, it need to find a
null slot to insert IRELATIVE relocation.
Now, it is processed by elf_loongarch_output_arch_local_syms before
elf_link_sort_relocs, just need to call loongarch_elf_append_rela to
insert IRELATIVE relocation.
bfd/ChangeLog:
* elfnn-loongarch.c (elfNN_allocate_local_ifunc_dynrelocs): Return
type change to int.
(loongarch_elf_size_dynamic_sections): Delete (void *).
(loongarch_elf_finish_dynamic_symbol): Use loongarch_elf_append_rela
insert IRELATIVE relocation to .rela.dyn.
(elfNN_loongarch_finish_local_dynamic_symbol): Return type change to
int.
(loongarch_elf_finish_dynamic_sections): Delete process of local
ifunc symbols.
(elf_backend_output_arch_local_syms): New.
ld/ChangeLog:
* testsuite/ld-loongarch-elf/local-ifunc-reloc.d: Regenerated.
mengqinggang [Sat, 15 Jul 2023 09:56:07 +0000 (17:56 +0800)]
LoongArch: Fix immediate overflow check bug
For B16/B21/B26/PCREL20_S2 relocations, if immediate overflow check after
rightshift, and the mask need to include sign bit.
Now, the immediate overflow check before rightshift for easier understand.
bfd/ChangeLog:
* elfxx-loongarch.c (reloc_bits_pcrel20_s2): Delete.
(reloc_bits_b16): Delete.
(reloc_bits_b21): Delete.
(reloc_bits_b26): Delete.
(reloc_sign_bits): New.
mengqinggang [Sat, 15 Jul 2023 09:17:12 +0000 (17:17 +0800)]
LoongArch: Fix instruction immediate bug caused by sign-extend
For extreme code mode, the instruction sequences is
pcalau12i $t0, hi20
addi.d $t1, $zero, lo12
lu32i.d $t1, lo20
lu52i.d $t1, hi12
add.d $t1, $t0, $t1
If lo12 > 0x7ff, hi20 need to add 0x1, lo20 need to sub 0x1.
If hi20 > 0x7ffff, lo20 need to add 0x1.
bfd/ChangeLog:
* elfnn-loongarch.c (RELOCATE_CALC_PC32_HI20): Redefined.
(RELOCATE_CALC_PC64_HI32): Redefined.
Jose E. Marchesi [Mon, 24 Jul 2023 00:54:06 +0000 (02:54 +0200)]
bpf: gas,include,opcode: add suppor for instructions BSWAP{16,32,64}
This patch adds support for the BPF V4 ISA byte swap instructions to
opcodes, assembler and disassembler.
Tested in bpf-unknown-none.
include/ChangeLog:
2023-07-24 Jose E. Marchesi <jose.marchesi@oracle.com>
* opcode/bpf.h (BPF_IMM32_BSWAP16): Define.
(BPF_IMM32_BSWAP32): Likewise.
(BPF_IMM32_BSWAP64): Likewise.
(enum bpf_insn_id): New entries BPF_INSN_BSWAP{16,32,64}.
opcodes/ChangeLog:
2023-07-24 Jose E. Marchesi <jose.marchesi@oracle.com>
* bpf-opc.c (bpf_opcodes): Add entries for the BSWAP*
instructions.
gas/ChangeLog:
2023-07-24 Jose E. Marchesi <jose.marchesi@oracle.com>
* doc/c-bpf.texi (BPF Instructions): Document BSWAP* instructions.
* testsuite/gas/bpf/alu.s: Test BSWAP{16,32,64} instructions.
* testsuite/gas/bpf/alu.d: Likewise.
* testsuite/gas/bpf/alu-be.d: Likewise.
* testsuite/gas/bpf/alu-pseudoc.s: Likewise.
* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
Jose E. Marchesi [Mon, 24 Jul 2023 00:20:55 +0000 (02:20 +0200)]
bpf: gas: fix in manual that MOVS* pseudoc syntax uses = instead of s=
gas/ChangeLog:
2023-07-24 Jose E. Marchesi <jose.marchesi@oracle.com>
* doc/c-bpf.texi (BPF Instructions): The pseudoc syntax for MOVS*
doesn't use `s=' but `='.
Jose E. Marchesi [Mon, 24 Jul 2023 00:11:34 +0000 (02:11 +0200)]
bpf: gas,opcodes: fix pseudoc syntax for MOVS* and LDXS* insns
This patch fixes the pseudoc syntax of the V4 instructions MOVS* and
LDXS* in order to reflect https://reviews.llvm.org/
D144829.
opcodes/ChangeLog:
2023-07-24 Jose E. Marchesi <jose.marchesi@oracle.com>
* bpf-opc.c (bpf_opcodes): Fix pseudo-c syntax for MOVS* and LDXS*
instructions.
gas/ChangeLog:
2023-07-24 Jose E. Marchesi <jose.marchesi@oracle.com>
* doc/c-bpf.texi (BPF Instructions): Fix pseudoc syntax for MOVS*
and LDXS* instructions.
* testsuite/gas/bpf/mem-pseudoc.d: Likewise.
* testsuite/gas/bpf/mem-be-pseudoc.d: Likewise.
* testsuite/gas/bpf/mem-pseudoc.s: Likewise.
* testsuite/gas/bpf/alu-pseudoc.s: Likewise.
* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu32-pseudoc.s: Likewise.
* testsuite/gas/bpf/alu32-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu32-be-pseudoc.d: Likewise.
GDB Administrator [Mon, 24 Jul 2023 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in
Jose E. Marchesi [Sun, 23 Jul 2023 23:15:08 +0000 (01:15 +0200)]
bpf: add support for jal/gotol jump instruction with 32-bit target
This patch adds support for the V4 BPF instruction jal/gotol, which is
like ja/goto but it supports a signed 32-bit PC-relative (in number of
64-bit words minus one) target operand instead of the 16-bit signed
operand of the other instruction. This greatly increases the jump
range in BPF programs.
Tested in bpf-unkown-none.
bfd/ChangeLog:
2023-07-24 Jose E. Marchesi <jose.marchesi@oracle.com>
* reloc.c: New reloc BFD_RELOC_BPF_DISPCALL32.
* elf64-bpf.c (bpf_reloc_type_lookup): Handle the new reloc.
* libbfd.h (bfd_reloc_code_real_names): Regenerate.
gas/ChangeLog:
2023-07-24 Jose E. Marchesi <jose.marchesi@oracle.com>
* config/tc-bpf.c (struct bpf_insn): New field `id'.
(md_assemble): Save the ids of successfully parsed instructions
and use the new BFD_RELOC_BPF_DISPCALL32 whenever appropriate.
(md_apply_fix): Adapt to the new BFD reloc.
* testsuite/gas/bpf/jump.s: Test JAL.
* testsuite/gas/bpf/jump.d: Likewise.
* testsuite/gas/bpf/jump-pseudoc.d: Likewise.
* testsuite/gas/bpf/jump-be.d: Likewise.
* testsuite/gas/bpf/jump-be-pseudoc.d: Likewise.
* doc/c-bpf.texi (BPF Instructions): Document new instruction
jal/gotol.
Document new operand type disp32.
include/ChangeLog:
2023-07-24 Jose E. Marchesi <jose.marchesi@oracle.com>
* opcode/bpf.h (enum bpf_insn_id): Add entry BPF_INSN_JAL.
(enum bpf_insn_id): Remove spurious entry BPF_INSN_CALLI.
opcodes/ChangeLog:
2023-07-23 Jose E. Marchesi <jose.marchesi@oracle.com>
* bpf-opc.c (bpf_opcodes): Add entry for jal.
Tom Tromey [Wed, 28 Jun 2023 21:23:54 +0000 (15:23 -0600)]
Use 'name' in DAP start_thread function
The DAP start_thread helper function has a 'name' parameter that is
unused. Apparently I forgot to hook it up to the thread constructor.
This patch fixes the oversight.
Tom Tromey [Tue, 4 Jul 2023 15:15:54 +0000 (09:15 -0600)]
Export gdb.block_signals and create gdb.Thread
While working on an experiment, I realized that I needed the DAP
block_signals function. I figured other developers may need it as
well, so this patch moves it from DAP to the gdb module and exports
it.
I also added a new subclass of threading.Thread that ensures that
signals are blocked in the new thread.
Finally, this patch slightly rearranges the documentation so that
gdb-side threading issues and functions are all discussed in a single
node.
Andrew Burgess [Sat, 22 Jul 2023 14:28:28 +0000 (15:28 +0100)]
gdb: two changes to linux_nat_debug_printf calls in linux-nat.c
This commit adjusts some of the debug output in linux-nat.c, but makes
no other functional changes to GDB.
In resume_lwp I've added the word "sibling" to one of the debug
messages. All the other debug messages in this function talk about
operating on the sibling thread, so I think it makes sense, for
consistency, if the message I've updated also talks about the sibling
thread.
In resume_stopped_resumed_lwps I've reordered the condition checks so
that the vfork-parent check now happens after the checks for whether
the thread is already resumed or not. This makes no functional
difference to GDB, but does, I think, mean we see more helpful debug
messages first.
Consider the situation where a vfork-parent thread is already resumed,
and resume_stopped_resumed_lwps is called. Previously the message
saying that the thread was not being resumed due to being a
vfork-parent, was printed. This might give the impression that the
thread is left in a not resumed state, which is misleading.
After this change we now get a message saying that the thread is not
being resumed due to it not being stopped (i.e. is already resumed).
With this message the already resumed nature of the thread is much
clearer.
I found this change helpful when debugging some vfork related issues.
Andrew Burgess [Sat, 22 Jul 2023 14:33:23 +0000 (15:33 +0100)]
gdb/testsuite: replace $testfile with $binfile in one case
For *reasons* I was hacking on gdb.base/foll-vfork.exp and wanted to
change the name of the binary that was created. Should be easy, I
adjusted the global $binfile variable .... but that didn't work.
In one place the script uses $testfile instead of $binfile.
Fixed this to use $binfile, now I can easily change the name of the
generated binary, and the test still works.
There's no change in what is tested after this commit.
GDB Administrator [Sun, 23 Jul 2023 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Sat, 22 Jul 2023 09:00:25 +0000 (11:00 +0200)]
[gdb/testsuite] Improve gdb.arch/arm-pthread_cond_timedwait-bt.exp
I noticed in test-case gdb.arch/arm-pthread_cond_timedwait-bt.exp that
prepare_for_testing is used, followed by a clean_restart.
This calls clean_restart twice in a row.
Fix this by using build_executable instead.
Also, I noticed that the test-case requires an SVC instruction, so add a
require to limit the test-case to supported architectures.
While we're at it, run M-x indent-region in emacs to fix indentation.
Tested on x86_64-linux.
Tom de Vries [Sat, 22 Jul 2023 09:00:25 +0000 (11:00 +0200)]
[gdb/testsuite] Use proc readnow in two test-cases
Use "require !readnow" in two test-cases, instead of the written-out variant.
Tested on x86_64-linux, with target boards unix and readnow.
GDB Administrator [Sat, 22 Jul 2023 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Thu, 20 Jul 2023 21:48:46 +0000 (15:48 -0600)]
Fix crash with DW_FORM_implicit_const
Jakub pointed out that using DW_FORM_implicit_const with
DW_AT_bit_size would cause gdb to crash. This happened because
DW_FORM_implicit_const is not an "unsigned" form, causing as_unsigned
to assert. This patch fixes the problem.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30651
Approved-By: Andrew Burgess <aburgess@redhat.com>
David Faust [Fri, 21 Jul 2023 18:41:43 +0000 (11:41 -0700)]
bpf: disasemble offsets of value 0 as "+0"
This tiny patch makes the BPF disassembler to emit, e.g.
ldxdw %r1, [%r0+0]
instead of
ldxdw %r1, [%r00]
when the offset is 0, to avoid confusion.
opcodes/
* bpf-dis.c (print_insn_bpf): Print offsets with value 0 as "+0".
gas/
* testsuite/gas/bpf/mem.s: Add tests with offset 0.
* testsuite/gas/bpf/mem-pseudoc.s: Likewise.
* testsuite/gas/bpf/mem.d: Update accordingly.
* testsuite/gas/bpf/mem-be.d: Likewise.
* testsuite/gas/bpf/mem-pseudoc.d: Likewise.
* testsuite/gas/bpf/mem-be-pseudoc.d: Likewise.
Tom Tromey [Mon, 22 May 2023 14:09:18 +0000 (08:09 -0600)]
Implement DAP modules request
This implements the DAP "modules" request, and also arranges to add
the module ID to stack frames.
Tom Tromey [Mon, 22 May 2023 17:40:10 +0000 (11:40 -0600)]
Add Progspace.objfile_for_address
This adds a new objfile_for_address method to gdb.Progspace. This
makes it easy to find the objfile for a given address.
There's a related PR; and while this change would have been sufficient
for my original need, it's not clear to me whether I should close the
bug. Nevertheless I think it makes sense to at least mention it here.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19288
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Tom Tromey [Mon, 22 May 2023 19:43:31 +0000 (13:43 -0600)]
Remove unused imports
I noticed an unused import in dap/evaluate.py; and also I found out
that my recent changes to use frame filters from DAP left some unused
imports in dap/bt.py.
Tom Tromey [Tue, 18 Jul 2023 14:38:56 +0000 (08:38 -0600)]
Document array indexing for Python gdb.Value
I noticed that the documentation for gdb.Value doesn't mention array
indexing.
Approved-By: Eli Zaretskii <eliz@gnu.org>
Jose E. Marchesi [Fri, 21 Jul 2023 17:47:49 +0000 (19:47 +0200)]
bpf: opcodes, gas: support for signed load V4 instructions
This commit adds the signed load to register (ldxs*) instructions
introduced in the BPF ISA version 4, including opcodes and assembler
tests.
Tested in bpf-unknown-none.
include/ChangeLog:
2023-07-21 Jose E. Marchesi <jose.marchesi@oracle.com>
* opcode/bpf.h (enum bpf_insn_id): Add entries for signed load
instructions.
(BPF_MODE_SMEM): Define.
opcodes/ChangeLog:
2023-07-21 Jose E. Marchesi <jose.marchesi@oracle.com>
* bpf-opc.c (bpf_opcodes): Add entries for LDXS{B,W,H,DW}
instructions.
gas/ChangeLog:
2023-07-21 Jose E. Marchesi <jose.marchesi@oracle.com>
* testsuite/gas/bpf/mem.s: Add signed load instructions.
* testsuite/gas/bpf/mem-pseudoc.s: Likewise.
* testsuite/gas/bpf/mem.d: Likewise.
* testsuite/gas/bpf/mem-pseudoc.d: Likewise.
* testsuite/gas/bpf/mem-be.d: Likewise.
* doc/c-bpf.texi (BPF Instructions): Document the signed load
instructions.
Jose E. Marchesi [Fri, 21 Jul 2023 15:22:58 +0000 (17:22 +0200)]
bpf: opcodes, gas: support for signed register move V4 instructions
This commit adds the signed register move (movs) instructions
introduced in the BPF ISA version 4, including opcodes and assembler
tests.
Tested in bpf-unknown-none.
include/ChangeLog:
2023-07-21 Jose E. Marchesi <jose.marchesi@oracle.com>
* opcode/bpf.h (BPF_OFFSET16_MOVS8): Define.
(BPF_OFFSET16_MOVS16): Likewise.
(BPF_OFFSET16_MOVS32): Likewise.
(enum bpf_insn_id): Add entries for MOVS{8,16,32}R and
MOVS32{8,16,32}R.
opcodes/ChangeLog:
2023-07-21 Jose E. Marchesi <jose.marchesi@oracle.com>
* bpf-opc.c (bpf_opcodes): Add entries for MOVS{8,16,32}R and
MOVS32{8,16,32}R instructions. and MOVS32I instructions.
gas/ChangeLog:
2023-07-21 Jose E. Marchesi <jose.marchesi@oracle.com>
* testsuite/gas/bpf/alu.s: Test movs instructions.
* testsuite/gas/bpf/alu-pseudoc.s: Likewise.
* testsuite/gas/bpf/alu32.s: Likewise for movs32 instruction.
* testsuite/gas/bpf/alu32-pseudoc.s: Likewise.
* testsuite/gas/bpf/alu.d: Add expected results.
* testsuite/gas/bpf/alu32.d: Likewise.
* testsuite/gas/bpf/alu-be.d: Likewise.
* testsuite/gas/bpf/alu32-be.d: Likewise.
* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu32-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
* testsuite/gas/bpf/alu32-be-pseudoc.d: Likewise.
Tom Tromey [Fri, 21 Jul 2023 16:02:13 +0000 (10:02 -0600)]
Remove redundant @findex from python.texi
In a review, Eli pointed out that @findex is redundant when used with
@defun. This patch removes all such uses from python.texi, plus a
couple uses before @defvar that are also unnecessary.
Approved-By: Eli Zaretskii <eliz@gnu.org>
Tom Tromey [Fri, 21 Jul 2023 16:33:07 +0000 (10:33 -0600)]
Fix typo in py-type.c docstring
I noticed that a doc string py-type.c says "an signed".
This patch corrects it to "a signed".
Tom Tromey [Fri, 23 Jun 2023 12:38:55 +0000 (06:38 -0600)]
Implement Ada target name symbol
Ada 2022 adds the "target name symbol", which can be used on the right
hand side of an assignment to refer to the left hand side. This
allows for convenient updates. This patch implements this for gdb's
Ada expression parser.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Tom Tromey [Wed, 28 Jun 2023 12:57:16 +0000 (06:57 -0600)]
Add instruction bytes to DAP disassembly response
The DAP disassemble command lets the client return the underlying
bytes of the instruction in an implementation-defined format. This
patch updates gdb to return this, and simply uses a hex string of the
bytes as the format.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Tom Tromey [Tue, 18 Jul 2023 16:45:14 +0000 (10:45 -0600)]
Remove ancient Ada workaround
I ran across this very old code in gdb's Ada support. After a bit of
archaeology, we couldn't determine what bug this might have been
working around. It is no longer needed, so this patch removes it.
As this is entirely Ada-specific and was reviewed and tested at
AdaCore, I'm checking it in.
Jose E. Marchesi [Fri, 21 Jul 2023 12:38:19 +0000 (14:38 +0200)]
bpf: add missing bpf-dis.c to opcodes/Makefile.am
This was breaking --enable-targets=all builds.
opcodes/ChangeLog:
2023-07-21 Jose E. Marchesi <jose.marchesi@oracle.com>
* Makefile.am (TARGET64_LIBOPCODES_CFILES): Add missing bpf-dis.c
* Makefile.in: Regenerate.
Jose E. Marchesi [Mon, 17 Jul 2023 16:35:22 +0000 (18:35 +0200)]
sim/bpf: desCGENization of the BPF simulator
The BPF port in binutils has been rewritten (commit
d218e7fedc74d67837d2134120917f4ac877454c) in order to not be longer
based on CGEN. Please see that commit log for more information.
This patch updates the BPF simulator accordingly. The new
implementation is much simpler and it is based on the new BPF opcodes.
Tested with target bpf-unknown-none with both 64-bit little-endian
host and 32-bit little-endian host.
Note that I have not tested in a big-endian host yet. I will do so
once this lands upstream so I can use the GCC compiler farm.
Jose E. Marchesi [Fri, 14 Jul 2023 22:50:14 +0000 (00:50 +0200)]
DesCGENization of the BPF binutils port
CGEN is cool, but the BPF architecture is simply too bizarre for it.
The weird way of BPF to handle endianness in instruction encoding, the
weird C-like alternative assembly syntax, the weird abuse of
multi-byte (or infra-byte) instruction fields as opcodes, the unusual
presence of opcodes beyond the first 32-bits of some instructions, are
all examples of what makes it a PITA to continue using CGEN for this
port. The bpf.cpu file is becoming so complex and so nested with
p-macros that it is very difficult to read, and quite challenging to
update. Also, every time we are forced to change something in CGEN to
accommodate BPF requirements (which is often) we have to do extensive
testing to make sure we do not break any other target using CGEN.
This is getting un-maintenable.
So I have decided to bite the bullet and revamp/rewrite the port so it
no longer uses CGEN. Overall, this involved:
* To remove the cpu/bpf.{cpu,opc} descriptions.
* To remove the CGEN generated files.
* To replace the CGEN generated opcodes table with a new hand-written
opcodes table for BPF.
* To replace the CGEN generated disassembler wih a new disassembler
that uses the new opcodes.
* To replace the CGEN generated assembler with a new assembler that uses the
new opcodes.
* To replace the CGEN generated simulator with a new simulator that uses the
new opcodes. [This is pushed in GDB in another patch.]
* To adapt the build systems to the new situation.
Additionally, this patch introduces some extensions and improvements:
* A new BPF relocation BPF_RELOC_BPF_DISP16 plus corresponding ELF
relocation R_BPF_GNU_64_16 are added to the BPF BFD port. These
relocations are used for section-relative 16-bit offsets used in
load/store instructions.
* The disassembler now has support for the "pseudo-c" assembly syntax of
BPF. What dialect to use when disassembling is controlled by a command
line option.
* The disassembler now has support for dumping instruction immediates in
either octal, hexadecimal or decimal. The used output base is controlled
by a new command-line option.
* The GAS BPF test suite has been re-structured and expanded in order to
test the disassembler pseudoc syntax support. Minor bugs have been also
fixed there. The assembler generic tests that were disabled for bpf-*-*
targets due to the previous implementation of pseudoc syntax are now
re-enabled. Additional tests have been added to test the new features of
the assembler. .dump files are no longer used.
* The linker BPF test suite has been adapted to the command line options
used by the new disassembler.
The result is very satisfactory. This patchs adds 3448 lines of code
and removes 10542 lines of code.
Tested in:
* Target bpf-unknown-none with 64-bit little-endian host and 32-bit
little-endian host.
* Target x86-64-linux-gnu with --enable-targets=all
Note that I have not tested in a big-endian host yet. I will do so
once this lands upstream so I can use the GCC compiler farm.
I have not included ChangeLog entries in this patch: these would be
massive and not very useful, considering this is pretty much a rewrite
of the port. I beg the indulgence of the global maintainers.
Lancelot Six [Thu, 20 Jul 2023 10:15:50 +0000 (10:15 +0000)]
gdb/solib-rocm: limit the number of opened file descriptors
ROCm programs can load a high number of compute kernels on GPU devices,
especially if lazy code-object loading have been disabled. Each code
object containing such program is loaded once for each device available,
and each instance is reported by GDB as an individual shared library.
We came across situations where the number of shared libraries opened by
GDB gets higher than the allowed number of opened files for the process.
Increasing the opened files limit works around the problem, but there is a
better way this patch proposes to follow.
Under the hood, the GPU code objects are embedded inside the host
application binary and shared library binaries. GDB currently opens the
underlying file once for each shared library it sees. That means that
the same file is re-opened every time a code object is loaded on a GPU.
This patch proposes to only open each underlying file once. This is
done by implementing a reference counting mechanism so the underlying
file is opened when the underlying file first needs to be opened, and
closed when the last BFD using the underlying file is closed.
On a program where GDB used to open about 1500 files to load all shared
libraries, this patch makes it so only 54 opened file descriptors are
needed.
I have tested this patch on downstream ROCgdb's full testsuite and
upstream GDB testsuite with no regression.
Approved-By: Pedro Alves <pedro@palves.net>
Jan Beulich [Fri, 21 Jul 2023 06:57:24 +0000 (08:57 +0200)]
x86: adjust disassembly of insns operating on selector values
Bring disassembly back in line with what the assembler accepts, thus
also making it self-consistent (with, in particular selector load/store
insns). While there further add D to all affected insns except ARPL
(where S is used, matching LAR/LSL), to also behave correctly in suffix-
always mode.
While there also hook up the Intel variant of the LKGS test.
Jan Beulich [Fri, 21 Jul 2023 06:56:49 +0000 (08:56 +0200)]
x86: simplify disassembly of LAR/LSL
For whatever reason in
c9f5b96bdab0 ("x86: correct handling of LAR and
LSL") I didn't realize that we can easily use Sv instead of going
through mod_table[]. Redo this aspect of that change.
Tom de Vries [Fri, 21 Jul 2023 06:25:25 +0000 (08:25 +0200)]
[gdb/symtab] Add optimized out static var to cooked index
Consider the test-case:
...
$ cat main.c
int main (void) { return 0; }
$ cat static-optimized-out.c
static int aaa;
...
compiled like this:
...
$ gcc-12 static-optimized-out.c main.c -g -O2 -flto
...
There's a difference in behaviour depending on symtab expansion state:
...
$ gdb -q -batch a.out -ex "print aaa"
No symbol "aaa" in current context.
$ gdb -q -batch a.out -ex "maint expand-symtab" -ex "print aaa"
$1 = <optimized out>
...
The reason for the difference is that the optimized out variable aaa:
...
<1><104>: Abbrev Number: 2 (DW_TAG_variable)
<105> DW_AT_name : aaa
<109> DW_AT_decl_file : 1
<10a> DW_AT_decl_line : 18
<10b> DW_AT_decl_column : 12
<10c> DW_AT_type : <0x110>
...
is not added to the cooked index because of this clause in abbrev_table::read:
...
else if (!has_location && !has_specification_or_origin && !has_external
&& cur_abbrev->tag == DW_TAG_variable)
cur_abbrev->interesting = false;
...
Fix this inconsistency by making sure that the optimized out variable is added
to the cooked index.
Regression tested on x86_64-linux.
Add two test-cases, a C test-case gdb.opt/static-optimized-out.exp and a dwarf
assembly test-case gdb.dwarf2/static-optimized-out.exp.
Tested gdb.opt/static-optimized-out.exp with gcc-8 to gcc-12, for which we now
consistently get:
...
(gdb) print aaa^M
$1 = <optimized out>^M
...
and with gcc 7.5.0 and clang 13.0.1, for which we still consistently get:
...
(gdb) print aaa^M
No symbol "aaa" in current context.^M
...
due to missing debug info for the variable.
PR symtab/30656
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30656
Approved-By: Tom Tromey <tom@tromey.com>
Tom de Vries [Fri, 21 Jul 2023 06:17:51 +0000 (08:17 +0200)]
[gdb/tui] Fix superfluous newline for long prompt
In test-case gdb.tui/long-prompt.exp, with a prompt of 40 chars, the same size
as the terminal width, we get a superfluous newline at line 19:
...
16 (gdb) set prompt
123456789A123456789B123
17
456789C123456789>
18
123456789A123456789B123456789C123456789>
19
20
123456789A123456789B123456789C123456789>
21 set prompt (gdb)
22 (gdb)
...
as well as a superfluous repetition of the prompt at line 20 once we type the
's' starting "set prompt".
I traced the superfluous newline back to readline's readline_internal_setup,
that does:
...
/* If we're not echoing, we still want to at least print a prompt, because
rl_redisplay will not do it for us. If the calling application has a
custom redisplay function, though, let that function handle it. */
if (_rl_echoing_p == 0 && rl_redisplay_function == rl_redisplay)
...
else
{
if (rl_prompt && rl_already_prompted)
rl_on_new_line_with_prompt ();
else
rl_on_new_line ();
(*rl_redisplay_function) ();
...
and then we hit the case that calls rl_on_new_line_with_prompt, which does:
...
/* If the prompt length is a multiple of real_screenwidth, we don't know
whether the cursor is at the end of the last line, or already at the
beginning of the next line. Output a newline just to be safe. */
if (l > 0 && (l % real_screenwidth) == 0)
_rl_output_some_chars ("\n", 1);
...
This doesn't look like a readline bug, because the behaviour matches the
comment.
[ And the fact that the output of the newline doesn't happen in the scope of
tui_redisplay_readline means it doesn't get the prompt wrap detection
treatment, causing start_line to be incorrect, which causes the superfluous
repetition of the prompt. ]
I looked at ways to work around this, and managed by switching off
rl_already_prompted, which we set to 1 in tui_rl_startup_hook:
...
/* Readline hook to redisplay ourself the gdb prompt.
In the SingleKey mode, the prompt is not printed so that
the command window is cleaner. It will be displayed if
we temporarily leave the SingleKey mode. */
static int
tui_rl_startup_hook (void)
{
rl_already_prompted = 1;
if (tui_current_key_mode != TUI_COMMAND_MODE
&& !gdb_in_secondary_prompt_p (current_ui))
tui_set_key_mode (TUI_SINGLE_KEY_MODE);
tui_redisplay_readline ();
return 0;
}
...
Then I started looking at why rl_already_prompted is set to 1.
The use case for rl_already_prompted seems to be:
- app (application, the readline user) outputs prompt,
- app sets rl_already_prompted to 1, and
- app calls readline, which calls rl_on_new_line_with_prompt, which figures
out how long the prompt is, and sets a few readline variables accordingly,
which can be used in the following call to rl_redisplay_function.
AFAICT, TUI does not fit this pattern. It does not output an initial prompt,
rather it writes the prompt in every rl_redisplay_function. It doesn't use
the variables set by rl_on_new_line_with_prompt, instead it figures stuff out
by itself.
Fix this by removing the rl_already_prompted setting.
Also remove the call to tui_redisplay_readline, it's not necessary, the
function is called anyway.
Tested on x86_64-linux, no regressions.
GDB Administrator [Fri, 21 Jul 2023 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Thu, 20 Jul 2023 08:25:38 +0000 (17:55 +0930)]
MIPS: Don't move __gnu_lto_slim to .scommon
* elfxx-mips.c (_bfd_mips_elf_symbol_processing): Don't treat
__gnu_lto_slim as SHN_MIPS_SCOMMON.
(_bfd_mips_elf_add_symbol_hook): Likewise.
GDB Administrator [Thu, 20 Jul 2023 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in
Hui Li [Thu, 6 Jul 2023 03:22:37 +0000 (11:22 +0800)]
gdb: LoongArch: Update status of the entire regset in regcache
In the current code, when a register is fetched, the entire regset
are fetched via ptrace, but only this register status is updated in
regcache, it needs to fetch the same regset through ptrace again if
another register in this regset is fetched later, this is obviously
unnecessary. It is proper to update the status of the entire regset
in regcache when fetching a register via ptrace.
Signed-off-by: Hui Li <lihui@loongson.cn>
Reviewed-By: Tom Tromey <tom@tromey.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Pedro Alves [Mon, 17 Jul 2023 17:31:02 +0000 (18:31 +0100)]
Fix gdb.Inferior.read_memory without execution (PR dap/30644)
Andrew reported that the previous change to gdb.Inferior.read_memory &
friends introducing scoped_restore_current_inferior_for_memory broke
gdb.dap/stop-at-main.exp. This is also reported as PR dap/30644.
The root of the problem is that all the methods that now use
scoped_restore_current_inferior_for_memory cause GDB to crash with a
failed assert if they are run on an inferior that is not yet started.
E.g.:
(gdb) python i = gdb.selected_inferior ()
(gdb) python i.read_memory (4,4)
gdb/thread.c:626: internal-error: any_thread_of_inferior: Assertion `inf->pid != 0' failed.
This patch fixes the problem by removing
scoped_restore_current_inferior_for_memory's ctor ptid parameter and
the any_thread_of_inferior calls completely, and making
scoped_restore_current_inferior_for_memory switch inferior_ptid to a
pid ptid.
I was a little worried that some port might be assuming inferior_ptid
points at a thread in the xfer_partial memory access routines. We
know that anything that supports forks must not assume that, due to
how detach_breakpoints works. I looked at a number of xfer_partial
implementations, and didn't see anything that is looking at
inferior_ptid in a way that would misbehave. I'm thinking that we
could go forward with this and just fix ports if they break.
While on some ports like on AMD GPU we have thread-specific address
spaces, and so when accessing memory for those address spaces, we must
have the right thread context (via inferior_ptid) selected, in
Inferior.read_memory, we only have the inferior to work with, so this
API as is can't be used to access thread-specific address spaces.
IOW, it can only be used to access the global address space that is
visible to both the CPU and the GPUs.
In proc-service.c:ps_xfer_memory, the other spot using
scoped_restore_current_inferior_for_memory, we're always accessing
per-inferior memory.
If we end up using scoped_restore_current_inferior_for_memory later to
set up the context to read memory from a specific thread, then we can
add an alternative ctor that takes a thread_info pointer, and make
inferior_ptid point to the thread, for example.
New test added to gdb.python/py-inferior.exp, exercising
Inferior.read_memory without execution.
No regressions on native and extended-gdbserver x86_64 GNU/Linux.
Reviewed-By: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30644
Change-Id: I11309c5ddbbb51a4594cf63c21b3858bfd9aed19
Nick Clifton [Wed, 19 Jul 2023 10:55:30 +0000 (11:55 +0100)]
Updated Romainian translation for the opcodes directory
Lancelot SIX [Fri, 10 Mar 2023 15:34:26 +0000 (15:34 +0000)]
gdb/amd-dbgapi-target: Use inf param in detach
Current implementation of amd_dbgapi_target::detach (inferior *, int)
does the following:
remove_breakpoints_inf (current_inferior ());
detach_amd_dbgapi (inf);
beneath ()->detach (inf, from_tty);
I find that using a mix of `current_inferior ()` and `inf` disturbing.
At this point, we know that both are the same (target_detach does assert
that `inf == current_inferior ()` before calling target_ops::detach).
To improve consistency, this patch replaces `current_inferior ()` with
`inf` in amd_dbgapi_target::detach.
Change-Id: I01b7ba2e661c25839438354b509d7abbddb7c5ed
Approved-By: Pedro Alves <pedro@palves.net>
Tom de Vries [Wed, 19 Jul 2023 07:18:29 +0000 (09:18 +0200)]
[gdb/testsuite] Fix gdb.gdb/python-helper.exp with -O2 -flto=auto and gcc 7.5.0
With a gdb build with -O2 -flto=auto using gcc 7.5.0, I run into:
...
(gdb) ptype global_c^M
^M
Thread 1 "xgdb" hit Breakpoint 3, \
_Z12c_print_typeP4typePKcP7ui_fileii8languagePK18type_print_options () at \
gdb/c-typeprint.c:175^M
175 {^M
(outer-gdb) FAIL: gdb.gdb/python-helper.exp: hit breakpoint in outer gdb again
...
This is a problem with the debug info, which marks the CU containing the
function declaration as C rather than C++. This is fixed in gcc 8 and later.
Work around this compiler problem by allowing the mangled name.
Tested on x86_64-linux.
PR testsuite/30648
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30648
Alan Modra [Wed, 19 Jul 2023 00:56:04 +0000 (10:26 +0930)]
[GOLD, PowerPC64] Debug info relocation overflow
It is possible to build huge binaries on powerpc64, where 32-bit
addresses in debug info are insufficient to descibe locations in the
binary. Help out the user, and only warn about debug overflows.
* powerpc.cc (Target_powerpc::Relocate::relocate): Warn on
relocation overflows in debug info.
Alan Modra [Wed, 19 Jul 2023 00:41:49 +0000 (10:11 +0930)]
Tidy binutils configure
Separate out some of the defines from the block handling windows
support, so they don't get lost. Delete an unused variable.
Alan Modra [Tue, 18 Jul 2023 02:59:56 +0000 (12:29 +0930)]
Build all the objdump extensions with --enable-targets=all
Only the xcoff and pe extensions were enabled. Build the lot, and fix
some more printf format problems when the host is 32-bit.
* configure.ac (od_vectors): Set up for --enable-targets=all.
* configure: Regenerate.
* od-elf32_avr.c (elf32_avr_dump_mem_usage): Correct format
specifier vs. arg mismatch.
(elf32_avr_dump_avr_prop): Likewise.
Alan Modra [Tue, 18 Jul 2023 02:59:21 +0000 (12:29 +0930)]
gas 32-bit host compile warnings
* config/tc-d10v.c (find_opcode): Correct format specifier vs.
arg mismatch.
* config/tc-m68hc11.c (fixup8, fixup16, fixup24, fixup8_xg): Likewise.
* config/tc-vax.c (md_assemble): Likewise.
* config/tc-xtensa.c (dump_litpools): Likewise.
* config/tc-z80.c (emit_data_val, emit_byte): Likewise.
GDB Administrator [Wed, 19 Jul 2023 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in
Nick Clifton [Tue, 18 Jul 2023 16:12:25 +0000 (17:12 +0100)]
Updated Swedish translation for the binutils subdirectory
Pter Chubb [Tue, 18 Jul 2023 16:04:43 +0000 (17:04 +0100)]
PR 30632 - ld segfaults if linker script includes a STARTUP line.
Jiawei [Wed, 12 Jul 2023 12:40:36 +0000 (20:40 +0800)]
RISC-V: Supports Zcb extension.
This patch support Zcb extension, contains new compressed instructions,
some instructions depend on other existed extension, like 'zba', 'zbb'
and 'zmmul'. Zcb also imply Zca extension to enable the compressing
features.
Co-Authored by: Charlie Keaney <charlie.keaney@embecosm.com>
Co-Authored by: Mary Bennett <mary.bennett@embecosm.com>
Co-Authored by: Nandni Jamnadas <nandni.jamnadas@embecosm.com>
Co-Authored by: Sinan Lin <sinan.lin@linux.alibaba.com>
Co-Authored by: Simon Cook <simon.cook@embecosm.com>
Co-Authored by: Shihua Liao <shihua@iscas.ac.cn>
Co-Authored by: Yulong Shi <yulong@iscas.ac.cn>
bfd/ChangeLog:
* elfxx-riscv.c (riscv_multi_subset_supports): New extension.
(riscv_multi_subset_supports_ext): Ditto.
gas/ChangeLog:
* config/tc-riscv.c (validate_riscv_insn): New operators.
(riscv_ip): Ditto.
* testsuite/gas/riscv/zcb.d: New test.
* testsuite/gas/riscv/zcb.s: New test.
include/ChangeLog:
* opcode/riscv-opc.h (MATCH_C_LBU): New opcode.
(MASK_C_LBU): New mask.
(MATCH_C_LHU): New opcode.
(MASK_C_LHU): New mask.
(MATCH_C_LH): New opcode.
(MASK_C_LH): New mask.
(MATCH_C_SB): New opcode.
(MASK_C_SB): New mask.
(MATCH_C_SH): New opcode.
(MASK_C_SH): New mask.
(MATCH_C_ZEXT_B): New opcode.
(MASK_C_ZEXT_B): New mask.
(MATCH_C_SEXT_B): New opcode.
(MASK_C_SEXT_B): New mask.
(MATCH_C_ZEXT_H): New opcode.
(MASK_C_ZEXT_H): New mask.
(MATCH_C_SEXT_H): New opcode.
(MASK_C_SEXT_H): New mask.
(MATCH_C_ZEXT_W): New opcode.
(MASK_C_ZEXT_W): New mask.
(MATCH_C_NOT): New opcode.
(MASK_C_NOT): New mask.
(MATCH_C_MUL): New opcode.
(MASK_C_MUL): New mask.
(DECLARE_INSN): New opcode.
* opcode/riscv.h (EXTRACT_ZCB_BYTE_UIMM): New inline func.
(EXTRACT_ZCB_HALFWORD_UIMM): Ditto.
(ENCODE_ZCB_BYTE_UIMM): Ditto.
(ENCODE_ZCB_HALFWORD_UIMM): Ditto.
(VALID_ZCB_BYTE_UIMM): Ditto.
(VALID_ZCB_HALFWORD_UIMM): Ditto.
(enum riscv_insn_class): New extension class.
opcodes/ChangeLog:
* riscv-dis.c (print_insn_args): New operators.
* riscv-opc.c: New instructions.
Jiawei [Tue, 11 Jul 2023 08:32:14 +0000 (16:32 +0800)]
RISC-V: Support Zca/f/d extensions.
This patch add Zca/f/d extensions support, since all ZC*
extensions will imply Zca extension, just enabled compress
feature when Zca extension is available.
Co-Authored by: Charlie Keaney <charlie.keaney@embecosm.com>
Co-Authored by: Mary Bennett <mary.bennett@embecosm.com>
Co-Authored by: Nandni Jamnadas <nandni.jamnadas@embecosm.com>
Co-Authored by: Sinan Lin <sinan.lin@linux.alibaba.com>
Co-Authored by: Simon Cook <simon.cook@embecosm.com>
Co-Authored by: Shihua Liao <shihua@iscas.ac.cn>
Co-Authored by: Yulong Shi <yulong@iscas.ac.cn>
bfd/ChangeLog:
* elfxx-riscv.c (riscv_multi_subset_supports): New extensions.
(riscv_multi_subset_supports_ext): Ditto.
gas/ChangeLog:
* config/tc-riscv.c (riscv_set_arch): Extend compress check.
* testsuite/gas/riscv/zca.d: New test.
* testsuite/gas/riscv/zca.s: New test.
* testsuite/gas/riscv/zcd.d: New test.
* testsuite/gas/riscv/zcd.s: New test.
* testsuite/gas/riscv/zcf.d: New test.
* testsuite/gas/riscv/zcf.s: New test.
GDB Administrator [Tue, 18 Jul 2023 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in