Commit Graph

110563 Commits

Author SHA1 Message Date
Jan Beulich
d0e0f9c87a ld/x86: skip p_align-1 tests with unsuitable compiler
When the compiler doesn't properly arrange for foo's alignment, there's
no point even trying these tests. Report the situation as a single
"unsupported" test.
2022-06-28 08:56:06 +02:00
Alan Modra
f40bb390bb PowerPC64: align plt_branch stubs
plt_branch stubs are similar to plt_call stubs in that they branch
via bctr.  Align them too.

bfd/
	* elf64-ppc.c (ppc_size_one_stub): Align plt_branch stubs as for
	plt_call stubs.
ld/
	* testsuite/ld-powerpc/elfv2exe.d: Adjust for plt_branch changes.
	* testsuite/ld-powerpc/notoc.d: Likewise.
	* testsuite/ld-powerpc/notoc.wf: Likewise.
	* testsuite/ld-powerpc/notoc3.d: Likewise.
	* testsuite/ld-powerpc/pr23937.d: Likewise.
2022-06-28 13:02:26 +09:30
Alan Modra
0f0d9373a3 PowerPC64: plt_stub_pad
* elf64-ppc.c (plt_stub_pad): Simplify parameters and untangle
	from plt_stub_size.
	(ppc_size_one_stub): Call plt_stub_size before plt_stub_pad to
	provide size.  Recalculate size if it might change.
2022-06-28 13:02:26 +09:30
Alan Modra
04cb922ade PowerPC64: Tidy stub type changes
It made sense before I started using separate fields for main type and
sub type to add a difference in main type to the type (thus keeping
sub type unchanged).  Not so much now.

	* elf64-ppc.c (ppc_merge_stub): Simplify stub type change.
	(ppc_size_one_stub): Likewise.
2022-06-28 13:02:26 +09:30
Jiangshuai Li
e3940312c1 gdb:csky add pseudo regs for float and vector regs
In the existing CSKY architecture, there are at most 32 floating
and 16 vector registers. Float registers's count can be configured
as 16 or 32. In the future, the vector registers's count may be
extended to 32.

The bit width of floating-point register is 64bits, and the bit
width of vector register is 128bit.

Special points: in fr0~fr15 and vr0~vr15, each FRx is the lower
64 bits of the corresponding VRx.

Here, we will split each floating-point and vector register to
32bits wide, add the corresponding pseudo registers, and finally
use them for the dwarf registers.

There are 128 pseudo registers in total, s0~s127, including:
1. s0 and s1 correspond to fr0, s4 and s5 correspond to fr1, and so on.
Every two separated pseudo registers correspond to a float register.
2. s0, s1, s2 and s3 correspond to vr0; s4, s5, s6 and s7 correspond to vr1,
and so on. Every four pseudo registers corresponds to a vector register.

Therefore, in s64~s127, there are general registers that are not actually
used. This part is to prepare for the expansion of vector registers to 32

Therefore, in s64~s127, half of the registers are actually unused. This
part is to prepare for the expansion of the vector register to 32.
2022-06-28 11:05:30 +08:00
Pekka Seppänen
7c24bdc583 PR29293, elfnn-aarch64.c: def_protected member unintialized
PR 29293
	* elfnn-aarch64.c (elfNN_aarch64_link_hash_newfunc): Init def_protected.
2022-06-28 11:14:58 +09:30
Tsukasa OI
766077c173 RISC-V: Add 'Sstc' extension and its CSRs
This commit adds "stimecmp / vstimecmp" Extension (Sstc) and its CSRs.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_supported_std_s_ext): Add 'Sstc'
	extension to valid 'S' extension list.

gas/ChangeLog:

	* config/tc-riscv.c (enum riscv_csr_class): Add CSR classes for
	'Sstc' extension. (riscv_csr_address): Add handling for new CSR
	classes.
	* testsuite/gas/riscv/csr-dw-regnums.s: Add new CSRs.
	* testsuite/gas/riscv/csr-dw-regnums.d: Likewise.
	* testsuite/gas/riscv/csr.s: Add new CSRs.
	* testsuite/gas/riscv/csr-version-1p9p1.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p9p1.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p10.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.l: Likewise.

include/ChangeLog:

	* opcode/riscv-opc.h (CSR_STIMECMP, CSR_STIMECMPH,
	CSR_VSTIMECMP, CSR_VSTIMECMPH): New CSR macros.
2022-06-28 09:08:42 +08:00
Tsukasa OI
713f370809 RISC-V: Add 'Sscofpmf' extension with its CSRs
This commit adds Count Overflow and Mode-Based Filtering Extension
(Sscofpmf) and its CSRs.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_supported_std_s_ext): Add 'Sscofpmf'
	extension to valid 'S' extension list.

gas/ChangeLog:

	* config/tc-riscv.c (enum riscv_csr_class): Add CSR classes for
	'Sscofpmf' extension. (riscv_csr_address): Add handling for new
	CSR classes.
	* testsuite/gas/riscv/csr-dw-regnums.s: Add new CSRs.
	* testsuite/gas/riscv/csr-dw-regnums.d: Likewise.
	* testsuite/gas/riscv/csr.s: Add new CSRs.
	* testsuite/gas/riscv/csr-version-1p9p1.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p9p1.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p10.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.l: Likewise.

include/ChangeLog:

	* opcode/riscv-opc.h (CSR_SCOUNTOVF, CSR_MHPMEVENT3H,
	CSR_MHPMEVENT4H, CSR_MHPMEVENT5H, CSR_MHPMEVENT6H,
	CSR_MHPMEVENT7H, CSR_MHPMEVENT8H, CSR_MHPMEVENT9H,
	CSR_MHPMEVENT10H, CSR_MHPMEVENT11H, CSR_MHPMEVENT12H,
	CSR_MHPMEVENT13H, CSR_MHPMEVENT14H, CSR_MHPMEVENT15H,
	CSR_MHPMEVENT16H, CSR_MHPMEVENT17H, CSR_MHPMEVENT18H,
	CSR_MHPMEVENT19H, CSR_MHPMEVENT20H, CSR_MHPMEVENT21H,
	CSR_MHPMEVENT22H, CSR_MHPMEVENT23H, CSR_MHPMEVENT24H,
	CSR_MHPMEVENT25H, CSR_MHPMEVENT26H, CSR_MHPMEVENT27H,
	CSR_MHPMEVENT28H, CSR_MHPMEVENT29H, CSR_MHPMEVENT30H,
	CSR_MHPMEVENT31H): New CSR macros.
2022-06-28 09:08:06 +08:00
Tsukasa OI
6af47b081e RISC-V: Add 'Smstateen' extension and its CSRs
This commit adds State Enable Extension (Smstateen) and its CSRs.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_supported_std_s_ext): Add 'Smstateen'
	extension to valid 'S' extension list.

gas/ChangeLog:

	* config/tc-riscv.c (enum riscv_csr_class): Add CSR classes for
	'Smstateen' extension. (riscv_csr_address): Add handling for
	new CSR classes.
	* testsuite/gas/riscv/csr-dw-regnums.s: Add new CSRs.
	* testsuite/gas/riscv/csr-dw-regnums.d: Likewise.
	* testsuite/gas/riscv/csr.s: Add new CSRs.
	* testsuite/gas/riscv/csr-version-1p9p1.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p9p1.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p10.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.l: Likewise.

include/ChangeLog:

	* opcode/riscv-opc.h (CSR_MSTATEEN0, CSR_MSTATEEN1,
	CSR_MSTATEEN2, CSR_MSTATEEN3, CSR_SSTATEEN0, CSR_SSTATEEN1,
	CSR_SSTATEEN2, CSR_SSTATEEN3, CSR_HSTATEEN0, CSR_HSTATEEN1,
	CSR_HSTATEEN2, CSR_HSTATEEN3, CSR_MSTATEEN0H, CSR_MSTATEEN1H,
	CSR_MSTATEEN2H, CSR_MSTATEEN3H, CSR_HSTATEEN0H, CSR_HSTATEEN1H,
	CSR_HSTATEEN2H, CSR_HSTATEEN3H): New CSR macros.
2022-06-28 09:07:25 +08:00
Tsukasa OI
39590abd65 RISC-V: Add new CSR feature gate handling (RV32,H)
To support feature gate like Smstateen && H, this commit adds certain
CSR feature gate handling.  It also changes how RV32-only CSRs are
handled for cleanliness.

gas/ChangeLog:

	* config/tc-riscv.c (riscv_csr_address): Add CSR feature gate
	handling for H.  Change handling on RV32.
2022-06-28 09:05:54 +08:00
Alan Modra
8bddb52eb9 Re: Disable execstack and rwx segments warnings for MIPS targets.
PR 29263
	* configure.ac: Fix typo.
	* testsuite/ld-elf/elf.exp: Add mips to targets that need
	--warn-execstack to pass first pr29072 test.
2022-06-28 09:52:36 +09:30
GDB Administrator
f0cb8284cf Automatic date update in version.in 2022-06-28 00:00:24 +00:00
Bruno Larsen
e1692475fd gdb/testsuite: update bug numbers from Gnats to bugzilla
Some tests link to outdated bug numbers when an XFAIL or a KFAIL happen.

gdb.base/macscp.exp was referencing bug number 555, and the bug 7660
mentions that it used to be 555 on the Gnats system and seems to relate
to the issue at hand.

gdb.base/annota1.exp was referencing bug number 1270, and bug 8375
mentions being number 1270 on Gnats, and mentions annota1 specifically,
so it seemed pretty obvious.
2022-06-27 17:03:03 -03:00
Tom de Vries
95127faf50 [gdb/build] Fix build breaker with --enable-shared
When building gdb with --enable-shared, I run into:
...
ld: build/zlib/libz.a(libz_a-inffast.o): relocation R_X86_64_32S against \
  `.rodata' can not be used when making a shared object; recompile with -fPIC
ld: build/zlib/libz.a(libz_a-inflate.o): warning: relocation against \
  `inflateResetKeep' in read-only section `.text'
collect2: error: ld returned 1 exit status
make[3]: *** [libbfd.la] Error 1
...

This is a regression since commit a08bdb159b ("[gdb/build] Fix gdbserver
build with -fsanitize=thread").

The problem is that a single case statement in configure is shared to handle
special requirements for both the host libiberty and host zlib, which has the
effect that only one is handled.

Fix this by handling libiberty and zlib each in its own case statement.

Build on x86_64-linux, with and without --enable-shared.

ChangeLog:

2022-06-27  Tom de Vries  <tdevries@suse.de>

	* configure.ac: Set extra_host_libiberty_configure_flags and
	extra_host_zlib_configure_flags in separate case statements.
	* configure: Regenerate.
2022-06-27 15:36:19 +02:00
Pedro Alves
171fba11ab Make GDBserver abort on internal error in development mode
Currently, if GDBserver hits some internal assertion, it exits with
error status, instead of aborting.  This makes it harder to debug
GDBserver, as you can't just debug a core file if GDBserver fails an
assertion.  I've had to hack the code to make GDBserver abort to debug
something several times before.

I believe the reason it exits instead of aborting, is to prevent
potentially littering the filesystem of smaller embedded targets with
core files.  I think I recall Daniel Jacobowitz once saying that many
years ago, but I can't be sure.  Anyhow, that seems reasonable to me.

Since we nowadays have a distinction between development and release
modes, I propose to make GDBserver abort on internal error if in
development mode, while keeping the status quo when in release mode.

Thus, after this patch, in development mode, you get:

 $ ../gdbserver/gdbserver
 ../../src/gdbserver/server.cc:3711: A problem internal to GDBserver has been detected.
 captured_main: Assertion `0' failed.
 Aborted (core dumped)
 $

while in release mode, you'll continue to get:

 $ ../gdbserver/gdbserver
 ../../src/gdbserver/server.cc:3711: A problem internal to GDBserver has been detected.
 captured_main: Assertion `0' failed.
 $ echo $?
 1

I do not think that this requires a separate configure switch.

A "--target_board=native-extended-gdbserver" run on Ubuntu 20.04 ends
up with:

		 === gdb Summary ===

 # of unexpected core files      29
 ...

for me, of which 8 are GDBserver core dumps, 7 more than without this
patch.

Change-Id: I6861e08ad71f65a0332c91ec95ca001d130b0e9d
2022-06-27 13:55:36 +01:00
Nick Clifton
e3e5ae0493 Replace a run-time assertion failure with a warning message when parsing corrupt DWARF data.
PR 29289
	* dwarf.c (display_debug_names): Replace assert with a warning
	message.
2022-06-27 13:43:02 +01:00
Nick Clifton
e98e7d9a70 Fix NULL pointer indirection when parsing corrupt DWARF data.
PR 29290
	* dwarf.c (read_and_display_attr_value): Check that debug_info_p
	is set before dereferencing it.
2022-06-27 13:30:35 +01:00
Nick Clifton
2a4fc266db Have gold's File_read::do_read() function check the start parameter
PR 23765
	* fileread.cc (File_read::do_read): Check start parameter before
	computing number of bytes to read.
2022-06-27 13:07:40 +01:00
Yvan Roux
8c9ae6df3c gdb/arm: Unwind Non-Secure callbacks from Secure
Without this changeset, the unwinding doesn't take into account
Non-Secure to Secure stack unwinding enablement status and
doesn't choose the proper SP to do the unwinding.

This patch only unwinds the stack when Non-Secure to Secure
unwinding is enabled, previous SP is set w/r to the current mode
(Handler -> msp_s, Thread -> psp_s) and then the Secure stack is
unwound.  Ensure thumb bit is set in PSR when needed.  Also, drop
thumb bit from PC if set.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Signed-off-by: Yvan ROUX <yvan.roux@foss.st.com>
2022-06-27 13:28:07 +02:00
Nick Clifton
a3f1431a50 Stop bogus warnings about DWARF indexed string offsets being too big.
* dwarf.c (fetch_indexed_string): Do not use length of first table
	in string section as the length of every table in the section.
	* testsuite/binutils-all/pr26112.r: Update expected output.
2022-06-27 11:49:14 +01:00
Tom de Vries
2135495484 [gdb/testsuite] Handle older python in gdb.python/py-send-packet.py
With python 3.4, I run into:
...
Traceback (most recent call last):^M
  File "<string>", line 1, in <module>^M
  File
  "outputs/gdb.python/py-send-packet/py-send-packet.py", line 128, in \
    run_set_global_var_test^M
    res = conn.send_packet(b"X%x,4:\x02\x02\x02\x02" % addr)^M
TypeError: Could not convert Python object: b'X%x,4:\x02\x02\x02\x02'.^M
Error while executing Python code.^M
...
while with python 3.6 this works fine.

The type of addr is <class 'gdb.Value'>, so the first thing to try is whether
changing it into a string works:
...
    addr_str = "%x" % addr
    res = conn.send_packet(b"X%s,4:\x02\x02\x02\x02" % addr_str)
...
which gets us the more detailed:
...
TypeError: unsupported operand type(s) for %: 'bytes' and 'str'
...

Fix this by avoiding the '%' operator in the byte literal, and use instead:
...
def xpacket_header (addr):
    return ("X%x,4:" % addr).encode('ascii')
  ...
    res = conn.send_packet(xpacket_header(addr) + b"\x02\x02\x02\x02")
...

Tested on x86_64-linux, with python 3.4 and 3.6, and a backported version was
tested on the gdb-12-branch in combination with python 2.7.
2022-06-27 12:47:26 +02:00
Tom de Vries
772f8196d6 [gdb/testsuite] Fix gdb.reverse/i387-env-reverse.exp for -pie
When running test-case gdb.reverse/i387-env-reverse.exp for x86_64-linux with
target board unix/-m32/-fPIE/-pie, we run into:
...
(gdb) PASS: gdb.reverse/i387-env-reverse.exp: push st0
info register eax^M
eax            0x56550000          1448411136^M
(gdb) FAIL: gdb.reverse/i387-env-reverse.exp: verify eax == 0x8040000
...

The problem is that the tested instruction (fstsw) only sets $ax, not $eax.

Fix this by verifying $ax instead of $eax.

Tested on x86_64-linux with target boards unix/-m32 and unix/-m32/-fPIE/-pie.
2022-06-27 12:47:26 +02:00
Tom de Vries
7d476bd555 [gdb/testsuite] Enable some test-cases for x86_64 -m32
When trying to run test-case gdb.reverse/i387-env-reverse.exp for x86_64-linux
with target board unix/-m32, it's skipped.

Fix this by using is_x86_like_target instead of istarget "i?86-*linux*".

This exposes a number of duplicates, fix those by making the test names unique.

Likewise in a couple of other test-cases.

Tested on x86_64-linux with target boards unix/-m32.
2022-06-27 12:47:26 +02:00
Tom de Vries
cdcec216b4 [gdb/testsuite] Workaround unnecessary .s file with gfortran 4.8
After running test-case gdb.fortran/namelist.exp with gfortran 4.8.5, I'm left
with:
...
$ git sti
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        gdb/testsuite/lib/compiler.s

nothing added to commit but untracked files present (use "git add" to track)
...

We're running into PR gcc/60447, which was fixed in gcc 4.9.0.

Workaround this by first copying the source file to the temp dir, such that
the .s file is left there instead:
...
$ ls build/gdb/testsuite/temp/<runtest pid>/
compiler.c  compiler.F90  compiler.s
...

Tested on x86_64-linux.
2022-06-27 12:47:26 +02:00
Tom de Vries
2043638bf9 [gdb/testsuite] Skip gdb.fortran/namelist.exp for gfortran 4.8
The test-case gdb.fortran/namelist.exp uses a gfortran feature (emitting
DW_TAG_namelist in the debug info) that has been supported since gfortran 4.9,
see PR gcc/37132.

Skip the test for gfortran 4.8 and earlier.  Do this using gcc_major_version,
and update it to be able to handle "gcc_major_version {gfortran-*} f90".

Tested on x86_64-linux, with gfortran 4.8.5, 7.5.0, and 12.1.1.
2022-06-27 12:47:26 +02:00
Tom de Vries
65067f1c2c [gdb/symtab] Fix parsing of .debug_str_offsets header
When running test-case gdb.dwarf2/fission-mix.exp with target board dwarf64
and gcc-12 (defaulting to DWARF5), I run into:
...
(gdb) break func2^M
Offset from DW_FORM_GNU_str_index or DW_FORM_strx pointing outside of \
  .debug_str.dwo section in CU at offset 0x0 [in module fission-mix]^M
(gdb) FAIL: gdb.dwarf2/fission-mix.exp: break func2
...

The .debug_str_offsets section has version 5, so as per the standard it has
it's own header, with initial length and version:
...
Contents of the .debug_str_offsets.dwo section (loaded from fission-mix2.dwo):

    Length: 0x1c
    Version: 0x5
       Index   Offset [String]
           0        0 build/gdb/testsuite
           1       33 GNU C17
           2       8f src/gdb/testsuite/gdb.dwarf2/fission-mix-2.c
...

But when trying to read the string offset at index 0 in the table (which
is 0), we start reading at offset 8, which points in the header, at the last
4 bytes of the initial length (it's 12 bytes because of 64-bit dwarf), as well
at the 2-byte version field and 2 bytes of padding, so we get:
...
(gdb) p /x str_offset
$1 = 0x500000000
...
which indeed is an offset that doesn't fit in the .debug_str section.

The offset 8 is based on reader->cu->header.addr_size:
...
static const char *
read_dwo_str_index (const struct die_reader_specs *reader, ULONGEST str_index)
{
 ULONGEST str_offsets_base = reader->cu->header.version >= 5
                             ? reader->cu->header.addr_size : 0;
...
which doesn't in look in agreement with the standard.

Note that this happens to give the right answer for 32-bit dwarf and
addr_size == 8, because then we have header size ==
(initial length (4) + version (2) + padding (2)) == 8.

Conversely, for 32-bit dwarf and addr_size == 4 (target board unix/-m32)
we run into a similar problem.  It just happens to not trigger the warning,
instead we get the wrong strings, like "func2" for DW_AT_producer and
"build/gdb/testsuite" for DW_AT_name of the DW_TAG_compile_unit DIE.

Fix this by parsing the .debug_str_offsets header in read_dwo_str_index.

Add a FIXME that we should not parse this for every call.

Tested on x86_64-linux.
2022-06-27 12:47:26 +02:00
Tom de Vries
a08bdb159b [gdb/build] Fix gdbserver build with -fsanitize=thread
[ Copied from gcc commit 153689603fd ("[gdb/build] Fix gdbserver build with
-fsanitize=thread"). ]

When building gdbserver with -fsanitize=thread (added to CFLAGS/CXXFLAGS) we
run into:
...
ld: ../libiberty/libiberty.a(safe-ctype.o): warning: relocation against \
  `__tsan_init' in read-only section `.text'
ld: ../libiberty/libiberty.a(safe-ctype.o): relocation R_X86_64_PC32 \
  against symbol `__tsan_init' can not be used when making a shared object; \
  recompile with -fPIC
ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[1]: *** [libinproctrace.so] Error 1
...
which looks similar to what is described in commit 78e4948694 ("[gdb/build]
Fix gdbserver build with -fsanitize=address").

The gdbserver component builds a shared library libinproctrace.so, which uses
libiberty and therefore requires the pic variant.  The gdbserver Makefile is
setup to use this variant, if available, but it's not there.

Fix this by listing gdbserver in the toplevel configure alongside libcc1, as a
component that needs the libiberty pic variant, setting:
...
extra_host_libiberty_configure_flags=--enable-shared
...

Tested on x86_64-linux.

ChangeLog:

2022-06-27  Tom de Vries  <tdevries@suse.de>

	* configure.ac: Build libiberty pic variant for gdbserver.
	* configure: Regenerate.
2022-06-27 12:47:26 +02:00
Nick Clifton
ed1c7ad8e3 Disable execstack and rwx segments warnings for MIPS targets.
PR 29263
	* configure.ac: Move HPPA specific code from here...
	* configure.tgt: ... to here.  Add similar code for MIPS.
	Move code for CRIS, MIPS and HPPA to block at start of file.
	* configure: Regenerate.
2022-06-27 11:39:27 +01:00
Jan Beulich
4f6c04da69 bfd: prune config.bfd's setting of targ_archs
The final "match all" case can take care of a few explicit entries:
Purge those. Also move s12z* into proper position (the table is
otherwise sorted, after all).
2022-06-27 11:12:57 +02:00
Jan Beulich
ddd7bf3e28 drop XC16x bits
Commit 04f096fb9e ("Move the xc16x target to the obsolete list") moved
the architecture from the "obsolete but still available" to the
"obsolete / support removed" list in config.bfd, making the architecture
impossible to enable (except maybe via "enable everything" options").

Note that I didn't touch */po/*.po{,t} on the assumption that these
would be updated by some (half)automatic means.
2022-06-27 11:11:46 +02:00
Bhuvanendra Kumar N
2d1388e73c Fix location list offset address dump under DW_AT_location (dwarf-5)
For clang compiled objects with dwarf-5, location list offset address dump
under DW_AT_location is corrected, where DW_FORM_loclistx is used. While
dumping the location list offset, the address dumped is wrong where it was
refering to .debug_addr instead of .debug_loclists

      * dwarf.c (fetch_indexed_value): Add base_address as parameter and
      use it to access the section offset.
      (read_and_display_attr_value): Handle DW_FORM_loclistx form separately.
      Pass loclists_base to fetch_indexed_value().
2022-06-27 13:34:09 +05:30
Alan Modra
0d8fb090a7 PowerPC64 .branch_lt address
.branch_lt is really an extension of .plt, as is .iplt.  We'd like all
of the PLT sections to be fixed relative to .TOC. after stub sizing,
because changes in offset to PLT entries might mean a change in stub
sizes.  When -z relro, the relro layout does this by laying out
sections from the end of the relro segment.  So for example, a change
in .eh_frame (which happens after stub sizing) will keep the same GOT
to PLT offset when -z relro.  Not so when -z norelro, because then the
usual forward layout of section is done and .got is more aligned than
.branch_lt.

	* emulparams/elf64ppc.sh: Set .branch_lt address fixed relative
	to .got.
	* testsuite/ld-powerpc/elfv2exe.d: Adjust to suit.
2022-06-27 12:28:59 +09:30
Alan Modra
648f6099d4 -z relro relaxation and ld script SIZEOF
A number of targets use assignments like:
. = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 12 ? 12 : 0, .);
(from i386) in linker scripts to put the end of the relro segment past
the header in .got.plt.  Examination of testcases like those edited by
this patch instead sees the end of the relro segment being placed at
the start of .got.plt.  For the i386 pie1 test:

  [ 9] .got.plt          PROGBITS        00002000 001000 00000c 04  WA  0   0  4

  GNU_RELRO      0x000f90 0x00001f90 0x00001f90 0x00070 0x00070 R   0x1

A map file shows:

.dynamic        0x0000000000001f90       0x70
 *(.dynamic)
 .dynamic       0x0000000000001f90       0x70 tmpdir/pie1.o
                0x0000000000001f90                _DYNAMIC

.got            0x0000000000002000        0x0
 *(.got)
 .got           0x0000000000002000        0x0 tmpdir/pie1.o
 *(.igot)
                0x0000000000002ff4                . = DATA_SEGMENT_RELRO_END (., (SIZEOF (.got.plt) >= 0xc)?0xc:0x0)

.got.plt        0x0000000000002000        0xc
 *(.got.plt)
 .got.plt       0x0000000000002000        0xc tmpdir/pie1.o
                0x0000000000002000                _GLOBAL_OFFSET_TABLE_

The DATA_SEGMENT_RELRO_END value in the map file is weird too.  All of
this is triggered by SIZEOF (.got.plt) being evaluated wrongly as
zero.  Fix it by taking into account the action of
lang_reset_memory_regions during relaxation.

	* ldexp.c (fold_name <SIZEOF>): Use rawsize if size has been reset.
	* ldlang.c (lang_size_sections_1): Don't reset processed_vma here.
	* testsuite/ld-i386/pie1.d: Adjust to suit.
	* testsuite/ld-x86-64/pr20830a.d: Likewise.
	* testsuite/ld-x86-64/pr20830b.d: Likewise.
	* testsuite/ld-x86-64/pr21038a.d: Likewise.
	* testsuite/ld-x86-64/pr21038b.d: Likewise.
	* testsuite/ld-x86-64/pr21038c.d: Likewise.
2022-06-27 12:28:59 +09:30
GDB Administrator
b4eb841afe Automatic date update in version.in 2022-06-27 00:00:25 +00:00
GDB Administrator
9544899f28 Automatic date update in version.in 2022-06-26 00:00:10 +00:00
Fangrui Song
af9bf9cb47 arm: Define elf_backend_extern_protected_data to 0 [PR 18705]
Similar to commit 4fb55bf6a9 for aarch64.

Commit b68a20d667 changed ld to produce
R_ARM_GLOB_DAT but that defeated the purpose of protected visibility
as an optimization.  Restore the previous behavior (which matches
ld.lld) by defining elf_backend_extern_protected_data to 0.
2022-06-25 10:27:49 -07:00
Tom Tromey
1fa2e2287e Fix corrupt DWARF in dw2-double-set-die-type
The dw2-double-set-die-type.exp test case caused an AddressSanitizer
failure in the new DWARF scanner.

The immediate cause was bad DWARF in the test -- in particular, the
the sibling attribute here:

     <2><181>: Abbrev Number: 33 (DW_TAG_subprogram)
	<182>   DW_AT_external    : 1
	<183>   DW_AT_name        : address
	<18b>   DW_AT_type        : <0x171>
	<18f>   DW_AT_declaration : 1
	<190>   DW_AT_sibling     : <0x1a1>
    ...
     <1><1a1>: Abbrev Number: 23 (DW_TAG_pointer_type)
	<1a2>   DW_AT_byte_size   : 4
	<1a3>   DW_AT_type        : <0x1a7>

...points to a "sibling" DIE that is at a different child depth.

Because this test case doesn't really require sibling attributes, this
patch fixes the problem by removing them from the test.

Note that gdb is not generally robust against malformed DWARF.
Detecting and compensating for this problem would probably be
expensive and, IMO, is better left to some (still hypothetical) DWARF
linter.
2022-06-25 11:11:51 -06:00
Tom Tromey
a858187afd Fix end of CU calculation in cooked_indexer::index_dies
cooked_indexer::index_dies incorrect computes the end of the current
CU in the .debug_info.  This isn't readily testable without writing
intentionally corrupt DWARF, but it's apparent through observation: it
is currently based on 'info_ptr', which does not always point to the
start of the CU.  This patch fixes the expression.  Tested on x86-64
Fedora 34.
2022-06-25 10:58:16 -06:00
Tiezhu Yang
af6e3f77e9 gdb: LoongArch: Implement loongarch_linux_syscall_next_pc()
When FRAME is at a syscall instruction, return the PC of the next
instruction to be executed.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-06-25 10:12:55 +08:00
Tiezhu Yang
0757a50396 gdb: LoongArch: Define register numbers and clean up code
This commit defines register numbers of various important registers,
we can use them directly in the related code, and also clean up some
code to make them more clear and readable.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-06-25 10:12:48 +08:00
GDB Administrator
c3467df4ac Automatic date update in version.in 2022-06-25 00:00:12 +00:00
Pedro Alves
5227abd299 Eliminate TUI/CLI observers duplication
For historical reasons, the CLI and the TUI observers are basically
exact duplicates, except for the downcast:

 cli:
       struct cli_interp *cli = as_cli_interp (interp);
 tui:
       struct interp *tui = as_tui_interp (interp);

and how they get at the interpreter's ui_out:

 cli:
       cli->cli_uiout
 tui:
       tui->interp_ui_out ()

Since interp_ui_out() is a virtual method that also works for the CLI
interpreter, and, both the CLI and the TUI interpreters inherit from
the same base class (cli_interp_base), we can convert the CLI
observers to cast to cli_interp_base instead and use interp_ui_out()
too.  With that, the CLI observers will work for the TUI interpreter
as well.  This lets us completely eliminate the TUI observers.  That's
what this commit does.

Change-Id: Iaf6cf12dfa200ed3ab203a895a72b69dfedbd6e0
2022-06-24 19:49:08 +01:00
Pedro Alves
86be3050a6 Revert "Delete delete_thread_silent"
Turns out we'll be gaining a new use of this function very soon, the
incoming AMDGPU port needs it.  Let's add it back, as it isn't really
hurting anything.

This reverts commit 39b8a8090e.
2022-06-24 17:20:16 +01:00
Yvan Roux
10245fe817 gdb/arm: Update the value of active sp when base sp changes
For Arm Cortex-M33 with security extensions, there are 4 different
stacks pointers (msp_s, msp_ns, psp_s, psp_ns).
When plain "sp" is updated during unwinding of the stack, the active
stack pointer of the 4 stack pointers needs to be kept in sync.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
2022-06-24 17:16:54 +02:00
Andrew Burgess
9704b8b4bc gdb/testsuite: remove unneeded calls to get_compiler_info
It is not necessary to call get_compiler_info before calling
test_compiler_info, and, after recent commits that removed setting up
the gcc_compiled, true, and false globals from get_compiler_info,
there is now no longer any need for any test script to call
get_compiler_info directly.

As a result every call to get_compiler_info outside of lib/gdb.exp is
redundant, and this commit removes them all.

There should be no change in what is tested after this commit.
2022-06-24 15:07:29 +01:00
Andrew Burgess
ef7a6b977b gdb/testsuite: remove global gcc_compiled from gdb.exp
After this commit the gcc_compiled global is no longer exported from
lib/gdb.exp.  In theory we could switch over all uses of gcc_compiled
to instead call test_compiler_info directly, however, I have instead
added a new proc to gdb.exp: 'is_c_compiler_gcc'.  I've then updated
the testsuite to call this proc instead of using the global.

Having a new proc specifically for this task means that we have a
single consistent pattern for detecting gcc.  By wrapping this logic
within a proc that calls test_compiler_info, rather than using the
global, means that test scripts don't need to call get_compiler_info
before they read the global, simply calling the new proc does
everything in one go.

As a result I've been able to remove the get_compiler_info calls from
all the test scripts that I've touched in this commit.

In some of the tests e.g. gdb.dwarf2/*.exp, the $gcc_compiled flag was
being checked at the top of the script to decide if the whole script
should be skipped or not.  In these cases I've called the new proc
directly and removed all uses of gcc_compiled.

In other cases, e.g. most of the gdb.base scripts, there were many
uses of gcc_compiled.  In these cases I set a new global gcc_compiled
near the top of the script, and leave the rest of the script
unchanged.

There should be no changes in what is tested after this commit.
2022-06-24 15:07:28 +01:00
Pedro Alves
e83907ff5f Include count of unexpected core files in gdb.sum summary
If GDB, GDBserver, a testcase program, Valgrind, etc. unexpectedly
crash while running the GDB testsuite, and you've setup your machine
such that core files are dumped in the current directory instead of
being shoved somewhere by abrt, apport, or similar (as you should for
proper GDB testing), you'll end up with an unexpected core file in the
$build/gdb/testsuite/ directory.

It can happen that GDB, GDBserver, etc. even crashes _after_ gdb_exit,
during teardown, and thus such a crash won't be noticed by looking at
the gdb.sum file at all.  This commit aims at improving that, by
including a new "unexpected core files" line in the testrun summary.

For example, here's what I get on x86-64 Ubuntu 20.04, with this
patch:

		 === gdb Summary ===

 # of unexpected core files      12          << new info
 # of expected passes            107557
 # of unexpected failures        35
 # of expected failures          77
 # of unknown successes          2
 # of known failures             114
 # of untested testcases         31
 # of unsupported tests          139

I have my core pattern setup like this:

 $ cat /proc/sys/kernel/core_pattern
 core.%e.%p.%h.%t

That's:

 %e: executable filename
 %p: pid
 %h: hostname
 %t: UNIX time of dump

and so I get these core files:

 $ ls -1 testsuite/core.*
 testsuite/core.connect-with-no.216191.nelson.1656002431
 testsuite/core.connect-with-no.217729.nelson.1656002431
 testsuite/core.gdb.194247.nelson.1656002423
 testsuite/core.gdb.226014.nelson.1656002435
 testsuite/core.gdb.232078.nelson.1656002438
 testsuite/core.gdb.352268.nelson.1656002441
 testsuite/core.gdb.4152093.nelson.1656002337
 testsuite/core.gdb.4154515.nelson.1656002338
 testsuite/core.gdb.4156668.nelson.1656002339
 testsuite/core.gdb.4158871.nelson.1656002341
 testsuite/core.gdb.468495.nelson.1656002444
 testsuite/core.vgdb.4192247.nelson.1656002366

where we can see that GDB crashed a number of times, but also
Valgrind's vgdb, and a couple testcase programs.  Neither of which is
good.

If your core_pattern is just "core" (but why??), then I guess that you
may end up with just a single core file in testsuite/.  Still, that is
one core file too many.

Above, we see a couple cores for "connect-with-no", which are the
result of gdb.server/connect-with-no-symbol-file.exp.  This is a case
mentioned above -- while the program crashed, that happens during
testcase teardown, and it goes unnoticed (without this commit) by
gdb.sum results.  Vis:

 $ make check TESTS="gdb.server/connect-with-no-symbol-file.exp"
 ...
		 === gdb Summary ===

 # of unexpected core files      2
 # of expected passes            8

 ...
 $

The tests fully passed, but still the testcase program crashed
somehow:

 $ ls -1 testsuite/core.*
 testsuite/core.connect-with-no.941561.nelson.1656003317
 testsuite/core.connect-with-no.941682.nelson.1656003317

Against --target_board=native-extended-gdbserver it's even worse.  I
get:

 # of unexpected core files      26

and note that when GDBserver hits an assertion failure, it exits with
error, instead of crashing with SIGABRT.  I think that should be
changed, at least on development builds, but that would be for another
patch.  After such patch, I suspect the number of unexpected cores
will be higher, as there are likely teardown GDBserver assertions that
we're not noticing.

I decided to put this new info in the "gdb Summary" section, as that's
a place people already are used to looking at, either when looking at
the tail of gdb.sum, or when diffing gdb.sum files, and we've already
extended this section before, to include the count of DUPLICATE and
PATH problems, so there's precedent.

Implementation-wise, the new line is appended after DejaGnu is
finished, with a shell script that is invoked by the Makefile.  It is
done this way so that serial and parallel testing work the same way.
My initial cut at an implementation was in TCL, straight in
testsuite/lib/check-test-names.exp, where DUPLICATES and PATH are
handled, like so:

 @@ -148,6 +159,10 @@ namespace eval ::CheckTestNames {
	     $counts(paths,$which)
	 maybe_show_count "# of duplicate test names\t" \
	     $counts(duplicates,$which)
 +
 +       set cores [glob -nocomplain -directory $::objdir core*]
 +       maybe_show_count "# of unexpected core files\t" \
 +           [llength $cores]
      }

But that would only work for serial testing, as in parallel testing,
the final gdb.sum is generated by aggregating the results of all the
individual gdb.sum files, and dg-extract-results.sh doesn't know about
our new summary line.  And I don't think that dg-extract-results.sh
should be taught about it, since the count of core files is not
something that we want to count many times, once per testcase, and
then add up the subcounts at the end.  Every time we count the core
files, we're already counting the final count.

I considered using the Tcl implementation in serial mode, and the
script approach for parallel testing, but that has the obvious
downside of implementing and maintaining the same thing twice.  In the
end, I settled on the script approach for serial mode too, which
requires making the "check-single" rule print the tail end of the
gdb.sum file, with a side effect being that if you look at the
terminal after a run (instead of at the gdb.sum file), you'll see the
"gdb Summary" section twice, once without the unexpected core lines
printed, and then another with.  IMO, this isn't an issue; when
testing in parallel mode, if you look at the terminal after "make -jN
check", you'll also see multiple "gdb Summary" sections printed.

Change-Id: I190b8d41856d49ad143854b6e3e6ccd7caa04491
2022-06-24 14:14:49 +01:00
Pedro Alves
c715d0732a Improve core file path detection & put cores in output dir
After a testrun, I noticed that I have some kernel-produced cores for
testcase programs, under build/gdb/testsuite/, which shouldn't be
there:

 $ ls -1 testsuite/core.*
 testsuite/core.annota1.1274351.nelson.1656004407
 testsuite/core.annota3.1288474.nelson.1656004414
 testsuite/core.exitsignal.1240674.nelson.1656004391

I have my core pattern setup like this:

 $ cat /proc/sys/kernel/core_pattern
 core.%e.%p.%h.%t

That's:

 %e: executable filename
 %p: pid
 %h: hostname
 %t: UNIX time of dump

so it's easy to tell which program produced the core from the core
file name.

From above, we can tell that the corresponding testcases are
gdb.base/annota1.exp, gdb.base/annota3.exp and
gdb.base/exitsignal.exp.

At least gdb.base/annota1.exp and gdb.base/annota3.exp have code in
them to delete the core file.  However, that isn't working for me,
because said code only looks for cores named exactly either "core" or
"core.PID", and my core_pattern doesn't match that.

Another issue I noticed, is that I have not been running
gdb.base/bigcore.exp, for a similar reason.  I get:

  Program terminated with signal SIGABRT, Aborted.
  The program no longer exists.
  (gdb) PASS: gdb.base/bigcore.exp: signal SIGABRT
  UNTESTED: gdb.base/bigcore.exp: can't generate a core file

But I actually have a core file under the testcase's output dir:

 $ find . -name "core.*"
 ./testsuite/outputs/gdb.base/bigcore/core.bigcore.2306705.nelson.1656005213
 $

This commit fixes these things, by adding a find_core_file routine
that searches core files in a way that works with my core pattern as
well.  This then also adds a convenience remove_core routine as a
wrapper around find_core_file that removes the found core file.

In addition, it changes some testcases that expect to have their
program dump core, to switch the inferior's cwd to the testcase's
output dir, so that the core is dumped there instead of in
build/gdb/testsuite/.  Some testcases were already doing that, but not
all.  The idea is that any core file dumped in build/gdb/testsuite/ is
an unexpected core file.  The next patch will add a count of such
unexpected core files to gdb.sum.

Another change is that the directory changing is now done with "set
cwd" instead of with "cd".  "set cwd" only affects the inferior cwd,
while "cd" affects GDB's cwd too.  By using "set cwd" instead of "cd",
if GDB dumps core in these testcases, the GDB core dump will still end
up in build/gdb/testsuite/, and can thus be detected as an unexpected
core.

Change-Id: I45068f21ffd4814350aaa8a3cc65cad5e3107607
2022-06-24 14:14:45 +01:00
Andrew Burgess
a32c1a92d5 gdb: make use of RAII in run_inferior_call
In passing I noticed that there are three local variables in
run_inferior_call that are used to save, and then restore some state,
I think these could all be replaced with a RAII style scoped_restore
instead.

Of the three locals that I've changed, the only one that I believe is
now restored in a different location is ui::async, before this commit
the async field was restored after a call to either delete_file_handle
or ui_register_input_event_handler, and after this commit, the field
is restored before these calls.  However, I don't believe that either
of these functions depend on the value of the async field, so I
believe the commit is fine.

Tested on x86-64/Linux passes with no regressions.
2022-06-24 12:04:40 +01:00
Pedro Alves
39b8a8090e Delete delete_thread_silent
delete_thread_silent is no longer used anywhere.  Delete it.

Change-Id: Iafcec12339861d5ab2e29c14d7b1f884c9e11c0f
2022-06-24 11:24:02 +01:00