Commit Graph

116503 Commits

Author SHA1 Message Date
Jaydeep Patil
1c37b30945 sim/riscv: fix JALR instruction simulation
Fix 32bit 'jalr rd,ra,imm' integer instruction, where RD was written
before using it to calculate destination address.

This commit also improves testutils.inc for riscv; make use of
pushsection and popsection when adding things to .data, and setup the
%gp global pointer register within the 'start' macro.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-10-18 17:55:31 +01:00
Nick Alcock
29736fc507 libctf: check for problems with error returns
We do this as a writable test because the only known-affected platforms
(with ssize_t longer than unsigned long) use PE, and we do not have support
for CTF linkage in the PE linker yet.

	PR libctf/30836
	* libctf/testsuite/libctf-writable/libctf-errors.*: New test.
2023-10-18 12:41:00 +01:00
Lancelot Six
fded0fb898 gdb/testsuite/gdb.rocm: Check value returned by hipDeviceSynchronize
Functions of the hip runtime returning a hipError_t can be marked
nodiscard depending on the configuration[1] (when compiled with C++17).

This patch makes sure that we always check the value returned by
hipDeviceSynchronize and friends, and print an error message when
appropriate.  This avoid a wall of warnings when running the testsuite
if the compiler defaults to using C++17.

It is always a good practice to check the return values anyway.

[1] https://github.com/ROCm-Developer-Tools/HIP/blob/docs/5.7.1/include/hip/hip_runtime_api.h#L203-L218

Change-Id: I2a819a8ac45f4bcf814efe9a2ff12c6a7ad22f97
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-10-18 08:26:23 +00:00
Torbjörn SVENSSON
0f79aa900f libctf: Return CTF_ERR in ctf_type_resolve_unsliced PR 30836
In commit 998a4f589d, all but one return
statement was updated to return the error proper value. This commit
rectifies that missed return statement.

libctf/
	ctf-types.c (ctf_type_resolve_unsliced): Return CTF_ERR on error.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2023-10-18 09:39:59 +02:00
Tom de Vries
b6d3616fb3 [gdb/testsuite] Fix gdb.base/jit-bfd-name.exp
When running test-case gdb.base/jit-bfd-name.exp, I run into:
...
ERROR: tcl error sourcing gdb/testsuite/gdb.base/jit-bfd-name.exp.
ERROR: can't read "start": no such variable
...

The problem is that commit c96ceed9dc ("gdb: include the end address in
in-memory bfd filenames") introduced a use of variable start, but not a
definition.

Fix this by adding the missing definition.

Tested on x86_64-linux.
2023-10-18 08:26:20 +02:00
Tom de Vries
8bb3d8b1f9 [gdb/symtab] Fix two style issues in gdb/dwarf2/index-write.c
While reviewing gdb/dwarf2/index-write.c I noticed two style issues.

Fix these.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2023-10-18 07:45:39 +02:00
Tom de Vries
729d066794 [gdb/symtab] Fix style issues in v9 .gdb_index section support
Post-commit review pointed out a few style issues in commit 8b9c08edda
("[gdb/symtab] Add name_of_main and language_of_main to the DWARF index").

Fix these.

Tested on x86_64-linux.

Reported-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-18 07:45:39 +02:00
Nelson Chu
4352c0ac04 RISC-V: Make sure rv32q conflict won't affect the zfa gas testcases.
According to the commit 51498ab9ab, the q extension was no longer allowed
for rv32 since version 2.2.  Therefore, make sure the version of q is larger
than 2.2, in case the new extension conflict breaks the toolchain regressions,
which built with the old -misa-spec.

gas/
	* testsuite/gas/riscv/zfa-zvfh.d: Set q to v2.2.
	* testsuite/gas/riscv/zfa.d: Likewise.
2023-10-18 09:48:35 +08:00
caiyinyu
85ad846e72 LoongArch: Correct comments. 2023-10-18 08:58:05 +08:00
GDB Administrator
cc45b28991 Automatic date update in version.in 2023-10-18 00:00:14 +00:00
Neal Frager
1a5e256f20 gas: testsuite: microblaze: Add new bit-field tests
This patch adds new gas tests for the
microblaze bsefi and bsifi instructions.

Signed-off-by: Neal Frager <neal.frager@amd.com>
Signed-off-by: Michael J. Eager <eager@eagercon.com>
2023-10-17 15:57:24 -07:00
Markus Metzger
c96ceed9dc gdb: include the end address in in-memory bfd filenames
Commit

    66984afd29 gdb: include the base address in in-memory bfd filenames

added the base address to in-memory bfd filenames.  Also add the end
address to allow dumping the in-memory bfd using the 'dump memory'
command.
2023-10-17 15:46:05 +00:00
Torbjörn SVENSSON
998a4f589d libctf: Sanitize error types for PR 30836
Made sure there is no implicit conversion between signed and unsigned
return value for functions setting the ctf_errno value.
An example of the problem is that in ctf_member_next, the "offset" value
is either 0L or (ctf_id_t)-1L, but it should have been 0L or -1L.
The issue was discovered while building a 64 bit ld binary to be
executed on the Windows platform.
Example object file that demonstrates the issue is attached in the PR.

libctf/
	Affected functions adjusted.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
2023-10-17 17:31:20 +02:00
Nick Clifton
22bfda88f8 Update the documentation of the LINKER_VERSIOn script command to actually mention the name of the command. 2023-10-17 10:42:44 +01:00
Tom de Vries
dcbdb080ed [gdb/cli] Keep track of styling failures in source_cache
In source_cache::ensure, keep track of which files failed to be styled, and
don't attempt to style them again in case the file dropped out of the cache.

Tested on x86_64-linux.

Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-17 11:38:06 +02:00
Tom de Vries
62dfd02e30 [gdb/cli] Factor out try_source_highlight
Function source_cache::ensure contains some code using the GNU
source-highlight library.

The code is a sizable part of the function, and contains conditional
compilation in a slightly convoluted way:
...
       if (!already_styled)
 #endif /* HAVE_SOURCE_HIGHLIGHT */
       {
...

Fix this by factoring out the code into new function try_source_highlight,
such that:
- source_cache::ensure is easier to read, and
- the conditional compilation is at the level of the function body.

Tested on x86_64-linux.

Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-17 11:38:06 +02:00
Tom de Vries
7e56491567 [gdb/cli] Skip string copy in source_cache::ensure
In function source_cache::ensure we have:
...
 	      std::ostringstream output;
	      ...
	      contents = output.str ();
...
The last line causes an unnecessary string copy.

C++20 allows us to skip it, like this:
...
	      contents = std::move (output).str ();
...

Use the more efficient solution.

Tested on x86_64-linux.

Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-10-17 11:38:06 +02:00
mengqinggang
3233ad1e4e LoongArch: readelf -d RELASZ excludes .rela.plt size
Before, readelf -d RELASZ is the sum of .rela.dyn size and .rela.plt size.
To consistent with LoongArch lld, RELASZ chang to only the size of .rela.dyn.
2023-10-17 14:57:04 +08:00
Alan Modra
84f24adc5b asan: Invalid free in alpha_ecoff_get_relocated_section_contents
This fixes an ancient bug in commit a3a33af390 (which makes me think
this code has never been used).

	* coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Iterate
	through reloc_vector using a temp.
2023-10-17 15:17:25 +10:30
Tsukasa OI
f46ff02f18 RISC-V: Fix typo
include/ChangeLog:

	* opcode/riscv-opc.h: Fix typo.
2023-10-17 02:09:44 +00:00
John Baldwin
2b6cdc46a2 nat/x86-cpuid.h: Remove non-x86 fallbacks
This header is only suitable for use on x86 hosts and is only included
there, so these fallbacks should not be needed.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-10-16 17:36:58 -07:00
GDB Administrator
43b1a3cb34 Automatic date update in version.in 2023-10-17 00:00:45 +00:00
Simon Marchi
8375fdfe4c gdb: remove unnecessary declarations in target.c
I found that these local declarations were not needed, remove them.
Tested by rebuilding.

Change-Id: I8d4fd0839ee1063b91dc002216d683aee0d4be22
2023-10-16 15:49:56 -04:00
Tom Tromey
41ab08f84b Have DAP handle non-Value results from 'children'
A pretty-printer's 'children' method may return values other than a
gdb.Value -- it may return any value that can be converted to a
gdb.Value.

I noticed that this case did not work for DAP.  This patch fixes the
problem.
2023-10-16 09:40:11 -06:00
Tom Tromey
ee81567c7c Handle gdb.LazyString in DAP
Andry pointed out that the DAP code did not properly handle
gdb.LazyString results from a pretty-printer, yielding:

    TypeError: Object of type LazyString is not JSON serializable

This patch fixes the problem, partly with a small patch in varref.py,
but mainly by implementing tp_str for LazyString.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-10-16 09:27:28 -06:00
Tom Tromey
138c7d2661 Fix register-setting response from DAP
Andry noticed that given a DAP setExpression request, where the
expression to set is a register, DAP will return the wrong value -- it
will return the old value, not the updated one.

This happens because gdb.Value.assign (which was recently added for
DAP) does not update the value.

In this patch, I chose to have the assign method update the Value
in-place.  It's also possible to have it return a new value, but this
didn't seem very useful to me.
2023-10-16 09:27:28 -06:00
Nick Clifton
fd00374fc7 Fix: GNU-ld: ARM: Issues when trying to set target output architecture
PR 28910
  * elf32-arm.c (elf32_arm_merge_private_bfd_data): Do not set output flags if the input flags have not been set.
2023-10-16 16:11:49 +01:00
Nick Clifton
a79e9a07a0 Fix: GNU-ld: ARM: Issues when trying to set target output architecture
PR 28910
  * lexsup.c (ld_options): Require that the --architecture option is given exactly two dashes, so that it does not become confused with the -a option.
2023-10-16 15:48:26 +01:00
Tom Tromey
ed5504c7b6 Add DAP scope cache
Andry Ogorodnik, a co-worker, noticed that multiple "scopes" requests
with the same frame would yield different variableReference values in
the response.

This patch adds a regression test for this, and adds a scope cache in
scopes.py, ensuring that multiple identical requests will get the same
response.

Tested-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
2023-10-16 08:40:18 -06:00
Tom de Vries
1d45d90934 [gdb/symtab] Work around PR gas/29517
When using glibc debuginfo generated with gas 2.39, we run into PR gas/29517:
...
$ gdb -q -batch a.out -ex start -ex "p (char *)strstr (\"haha\", \"ah\")"
Temporary breakpoint 1 at 0x40051b: file hello.c, line 6.

Temporary breakpoint 1, main () at hello.c:6
6	  printf ("hello\n");
Invalid cast.
...
while without glibc debuginfo installed we get the expected result:
...
$n = 0x7ffff7daa1b1 "aha"
...
and likewise with glibc debuginfo generated with gas 2.40.

The strstr ifunc resolves to __strstr_sse2_unaligned.  The problem is that gas
generates dwarf that states that the return type is void:
...
<1><3e1e58>: Abbrev Number: 2 (DW_TAG_subprogram)
    <3e1e59>   DW_AT_name        : __strstr_sse2_unaligned
    <3e1e5d>   DW_AT_external    : 1
    <3e1e5e>   DW_AT_low_pc      : 0xbbd2e
    <3e1e66>   DW_AT_high_pc     : 0xbc1c3
...
while the return type should be a DW_TAG_unspecified_type, as is the case
with gas 2.40.

We can still use the workaround of casting to another function type for both
__strstr_sse2_unaligned:
...
(gdb) p ((char * (*) (const char *, const char *))__strstr_sse2_unaligned) \
  ("haha", "ah")
$n = 0x7ffff7daa211 "aha"
...
and strstr (which requires using *strstr to dereference the ifunc before we
cast):
...
gdb) p ((char * (*) (const char *, const char *))*strstr) ("haha", "ah")
$n = 0x7ffff7daa251 "aha"
...
but that's a bit cumbersome to use.

Work around this in the dwarf reader, such that we have instead:
...
(gdb) p (char *)strstr ("haha", "ah")
$n = 0x7ffff7daa1b1 "aha"
...

This also requires fixing producer_is_gcc to stop returning true for
producer "GNU AS 2.39.0".

Tested on x86_64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>

PR symtab/30911
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30911
2023-10-16 16:32:28 +02:00
Luis Machado
5d4a870e05 Only allow closure lookup by address if there are threads displaced-stepping
Since commit 1e5ccb9c5f, we have an assertion in
displaced_step_buffers::copy_insn_closure_by_addr that makes sure a closure
is available whenever we have a match between the provided address argument and
the buffer address.

That is fine, but the report in PR30872 shows this assertion triggering when
it really shouldn't. After some investigation, here's what I found out.

The 32-bit Arm architecture is the only one that calls
gdbarch_displaced_step_copy_insn_closure_by_addr directly, and that's because
32-bit Arm needs to figure out the thumb state of the original instruction
that we displaced-stepped through the displaced-step buffer.

Before the assertion was put in place by commit
1e5ccb9c5f, there was the possibility of
getting nullptr back, which meant we were not doing a displaced-stepping
operation.

Now, with the assertion in place, this is running into issues.

It looks like displaced_step_buffers::copy_insn_closure_by_addr is
being used to return a couple different answers depending on the
state we're in:

1 - If we are actively displaced-stepping, then copy_insn_closure_by_addr
is supposed to return a valid closure for us, so we can determine the
thumb mode.

2 - If we are not actively displaced-stepping, then copy_insn_closure_by_addr
should return nullptr to signal that there isn't any displaced-step buffers
in use, because we don't have a valid closure (but we should always have
this).

Since the displaced-step buffers are always allocated, but not always used,
that means the buffers will always contain data. In particular, the buffer
addr field cannot be used to determine if the buffer is active or not.

For instance, we cannot set the buffer addr field to 0x0, as that can be a
valid PC in some cases.

My understanding is that the current_thread field should be a good candidate
to signal that a particular displaced-step buffer is active or not. If it is
nullptr, we have no threads using that buffer to displaced-step.  Otherwise,
it is an active buffer in use by a particular thread.

The following fix modifies the displaced_step_buffers::copy_insn_closure_by_addr
function so we only attempt to return a closure if the buffer has an assigned
current_thread and if the buffer address matches the address argument.

Alternatively, I think we could use a function to answer the question of
whether we're actively displaced-stepping (so we have an active buffer) or
not.

I've also added a testcase that exercises the problem. It should reproduce
reliably on Arm, as that is the only architecture that faces this problem
at the moment.

Regression-tested on Ubuntu 20.04. OK?

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30872
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-10-16 11:56:26 +01:00
Andrew Burgess
4b2f71e6c6 gdb: replace architecture_changed with new_architecture observer
This commit replaces the architecture_changed observer with a
new_architecture observer.

Currently the only user of the architecture_changed observer is the
Python code, which uses this observer to register the Python unwinder
with the architecture.

The problem is that the architecture_changed observer is triggered
from inferior::set_arch(), which only sees the inferior-wide gdbarch
value.  For targets that use thread-specific architectures, these
never trigger the architecture_changed observer, and so never have the
Python unwinder registered with them.

When it comes to unwinding GDB makes use of the frame's gdbarch, which
is based on the thread's regcache gdbarch, which is set in
get_thread_regcache to the value returned from
target_thread_architecture, which is not always the inferiors gdbarch
value, it might be a thread-specific gdbarch which has not passed
through inferior::set_arch().

The new_architecture observer will be triggered from
gdbarch_find_by_info, whenever a new gdbarch is created and
initialised.  As GDB caches and reuses gdbarch values, we should
expect to see each new architecture trigger the new_architecture
observer just once.

After this commit, targets that make use of thread-specific
architectures should be able to make use of Python unwinders.

As I don't have access to a machine that makes use of thread-specific
architectures right now, I asked Luis to confirm that an AArch64
target that uses SVE/SME can't use the Python unwinders in threads
that are using a thread-specific architectures, and he confirmed that
this is indeed the case, see this discussion:

  https://inbox.sourceware.org/gdb/87wmvsat8i.fsf@redhat.com

Tested-By: Lancelot Six <lancelot.six@amd.com>
Tested-By: Luis Machado <luis.machado@arm.com>
Reviewed-By: Luis Machado <luis.machado@arm.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-10-16 10:01:22 +01:00
Clément Chigot
9f9073e5b8 objcopy: Fix name of the field modified by pe_stack_reserve. 2023-10-16 10:37:23 +02:00
Tsukasa OI
6674b23fe6 RISC-V: Add "lp64e" ABI support
Since RV32E and RV64E are now ratified, this commit prepares the ABI
support for LP64E (LP64 with reduced GPRs).

gas/ChangeLog:

	* config/tc-riscv.c (riscv_set_abi_by_arch): Update the error
	message.  (md_parse_option): Accept "lp64e".
	* doc/c-riscv.texi: Update the documentation to allow "lp64e".
	* testsuite/gas/riscv/mabi-fail-rv32e-lp64f.l:
	Change error message.
	* testsuite/gas/riscv/mabi-fail-rv32e-lp64d.l: Likewise.
	* testsuite/gas/riscv/mabi-fail-rv32e-lp64q.l: Likewise.
2023-10-16 04:11:07 +00:00
Tsukasa OI
f1a0961ee0 RISC-V: Remove RV64E conflict
Since RV32E *and* RV64E are ratified, RV64E is no longer invalid.

This commit removes a restriction that prevents making base ISA with
reduced GPRs with XLEN > 32.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_parse_check_conflicts): Remove RV64E
	conflict since the ratified 'E' base ISAs include RV64E.

gas/ChangeLog:

	* testsuite/gas/riscv/march-fail-base-02.d: Removed.
	* testsuite/gas/riscv/march-fail-base-02.l: Removed.
2023-10-16 04:11:07 +00:00
GDB Administrator
de59d50076 Automatic date update in version.in 2023-10-16 00:00:38 +00:00
Mike Frysinger
edabd37834 sim: add distclean dep for gnulib 2023-10-15 23:00:33 +05:45
Neal Frager
bb0d05ff74 opcodes: microblaze: Add new bit-field instructions
This patches adds new bsefi and bsifi instructions.
BSEFI- The instruction shall extract a bit field from a
register and place it right-adjusted in the destination register.
The other bits in the destination register shall be set to zero.
BSIFI- The instruction shall insert a right-adjusted bit field
from a register at another position in the destination register.
The rest of the bits in the destination register shall be unchanged.

Further documentation of these instructions can be found here:
https://docs.xilinx.com/v/u/en-US/ug984-vivado-microblaze-ref

With version 6 of the patch, no new relocation types are added as
this was unnecessary for adding the bsefi and bsifi instructions.

FIXED: Segfault caused by incorrect termination of microblaze_opcodes.

Signed-off-by: nagaraju <nagaraju.mekala@amd.com>
Signed-off-by: Ibai Erkiaga <ibai.erkiaga-elorza@amd.com>
Signed-off-by: Neal Frager <neal.frager@amd.com>
Signed-off-by: Michael J. Eager <eager@eagercon.com>
2023-10-15 09:28:10 -07:00
Mike Frysinger
30ebc4310b sim: mips: fix printf string 2023-10-15 16:25:13 +05:45
GDB Administrator
cd09b5ddef Automatic date update in version.in 2023-10-15 00:00:40 +00:00
GDB Administrator
5e2c9ce9c0 Automatic date update in version.in 2023-10-14 00:00:37 +00:00
Luis Machado
bf4fcf8bc5 [aarch64] Use SVE_VQ_BYTES instead of __SVE_VQ_BYTES
__SVE_VQ_BYTES is only available if SVE definitions are available in
the system's headers, and this is not true for all systems.

For this purpose, we define SVE_VQ_BYTES.  This patch fixes the
name of the constant being used.
2023-10-13 16:27:19 +01:00
Clément Chigot
b5248d602e ld: replace wrong bfd_malloc in nto.em
xmalloc should be called in ld instead of bfd_malloc.

ld/ChangeLog:

	* emultempl/nto.em (nto_lookup_QNX_note_section): Replace
	bfd_malloc by xmalloc.
2023-10-13 16:50:23 +02:00
Clément Chigot
4f6f3bea52 ld: warn when duplicated QNX stack note are detected
This warning is triggered only when a stack parameter is given to
the linker.

ld/ChangeLog:

        * emultempl/nto.em: Add warning when several QNX .note are
        detected.
2023-10-13 16:23:39 +02:00
Clément Chigot
1eba15a501 ld: correctly handle QNX --lazy-stack without -zstack-size
The warning was skipped if -zstack-size is not provided.

ld/ChangeLog:

        * emultempl/nto.em: Move --lazy-stack warning before missing
        -zstack-size skip.
2023-10-13 16:23:39 +02:00
Clément Chigot
318d83e658 ld: allow update of existing QNX stack note
Up to now, the linker would always create a QNX stack note from scratch.
However, object files could already have such note, ending up into
duplicates. QNX loader doesn't handle that.

Update the mechanism to first search through the input files for a .note
section holding a QNX stack note. If none are found, then a new section
is created into the stub file as before. This requires this search to be
done once the file have been opened, moving the whole logic a bit later
in the emulation process.

As part for this update, also allow to request an executable stack
without necessarily having to provide its size as well.  In this case, s
etup a default lazy stack of 0x1000.

ld/ChangeLog:

        * emultempl/nto.em (nto_create_QNX_note_section): New Function.
        (nto_lookup_QNX_note_section): New Function.
        (nto_add_note_section): Move the creation of the note section
        in the above new functions.
        (nto_create_output_section_statements): rename nto_after_open
        * testsuite/ld-aarch64/aarch64-nto.exp: add new test.
        * testsuite/ld-aarch64/nto-stack-note-3.d: New test.
        * testsuite/ld-aarch64/nto-stack-note.s: New test.
2023-10-13 16:23:39 +02:00
Joseph Faulls
9326300e4d RISC-V: Add support for numbered ISA mapping strings
The elf psabi allows for mapping symbols to be of the form $x<ISA>.<any>

opcodes/
	* riscv-dis.c (riscv_get_map_state): allow mapping symbol to
	be suffixed by a unique identifier .<any>
2023-10-13 09:00:52 +08:00
Tom Tromey
5772d79823 Move -lsocket check to common.m4
A user pointed out that the -lsocket check in gdb should also apply to
gdbserver -- otherwise it can't find the Solaris socketpair.  This
patch makes the change.  It also removes a couple of redundant
function checks from gdb's configure.ac.

This was tested by the person who reported the bug.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30927
Approved-By: Pedro Alves <pedro@palves.net>
2023-10-12 18:23:13 -06:00
GDB Administrator
59fed66dce Automatic date update in version.in 2023-10-13 00:00:30 +00:00
Tom Tromey
07c833f99c Fix test suite failure in file-then-restart.exp
Simon pointed out that the new file-then-restart.exp test fails with
the extended-remote target board.

The problem is that the test suite doesn't use gdb_file_cmd -- which
handles things like "set remote exec-file".  This patch changes
gdb_file_cmd to make the "kill" command optional, and then switches
the test case to use it.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30933
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-10-12 07:44:52 -06:00