]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
4 months agoCR16: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:58:49 +0000 (11:58 +0100)] 
CR16: use is_whitespace()

Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input). Also switch ISSPACE() uses over.

4 months agoC-Sky: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:58:32 +0000 (11:58 +0100)] 
C-Sky: use is_whitespace()

Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input). Also switch ISSPACE() uses over. At the same time
use is_end_of_stmt() instead of kind-of-open-coded checks.

4 months agodlx: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:56:25 +0000 (11:56 +0100)] 
dlx: use is_whitespace()

Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input). Also convert open-coded checks where tabs were
already included.

4 months agod30v: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:56:13 +0000 (11:56 +0100)] 
d30v: use is_whitespace()

Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input). Also convert open-coded checks where tabs were
already included. At the same time use is_end_of_stmt() instead of open-
coded checks in adjacent code.

4 months agod10v: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:56:04 +0000 (11:56 +0100)] 
d10v: use is_whitespace()

Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input). Also convert open-coded checks where tabs were
already included. At the same time use is_end_of_stmt() instead of open-
coded checks in adjacent code.

4 months agobpf: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:55:54 +0000 (11:55 +0100)] 
bpf: use is_whitespace()

Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input). Various redundant nul char checks are also dropped,
where adjacent. At the same time use is_end_of_stmt() instead of an
open-coded nul char check.

4 months agobfin: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:55:40 +0000 (11:55 +0100)] 
bfin: use is_whitespace()

Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input).

4 months agogas/obj-*.c: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:55:23 +0000 (11:55 +0100)] 
gas/obj-*.c: use is_whitespace()

... for consistency of recognition of what is deemed whitespace.

In obj_elf_section_name() also generalize end-of-statement recognition
at the same time. Conversely drop the unused SKIP_SEMI_COLON() for COFF.

4 months agoavr: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:50:43 +0000 (11:50 +0100)] 
avr: use is_whitespace()

Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input).

4 months agoaarch64: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:50:30 +0000 (11:50 +0100)] 
aarch64: use is_whitespace()

Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input).

4 months agoArm: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:50:20 +0000 (11:50 +0100)] 
Arm: use is_whitespace()

Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input). At the same time use is_end_of_stmt() instead of an
open-coded nul char check.

In parse_neon_type() be more aggressive and remove the special casing of
certain characters altogether. The original default case simply having
"break" can't have been correct.

4 months agoarc: use is_whitespace()
Jan Beulich [Mon, 3 Feb 2025 10:50:03 +0000 (11:50 +0100)] 
arc: use is_whitespace()

Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input). At the same time use is_end_of_stmt() instead of
open-coded nul char checks.

4 months agoAlpha/EVAX: use is_whitespace() / is_end_of_stmt()
Jan Beulich [Mon, 3 Feb 2025 10:49:48 +0000 (11:49 +0100)] 
Alpha/EVAX: use is_whitespace() / is_end_of_stmt()

Don't open-code checking for ' ', '\t', and statement ending chars.

4 months agogas: consolidate whitespace recognition
Jan Beulich [Mon, 3 Feb 2025 10:48:55 +0000 (11:48 +0100)] 
gas: consolidate whitespace recognition

Let's extend lex_type[] to also cover whitespace, then having a simple
macro to uniformly recognize both blanks and tabs (and \r when it's not
EOL) as such.

In macro.c use sb_skip_white() as appropriate, instead of open-coding
it.

4 months agoAutomatic date update in version.in
GDB Administrator [Mon, 3 Feb 2025 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 months agoAvoid "text file busy" in dw2-using-debug-str.exp
Tom Tromey [Sat, 1 Feb 2025 23:51:42 +0000 (16:51 -0700)] 
Avoid "text file busy" in dw2-using-debug-str.exp

When I run:

    runtest dw2-using-debug-str.exp

... if I examine the gdb.log, I see:

    objcopy: unable to copy file '[...]/dw2-using-debug-str'; reason: Text file busy

This happens because the inferior is still running, and objcopy --
despite the invocation seemingly not needing this -- tries to open it
for writing.

This patch works around the objcopy oddity by having gdb exit (killing
the inferior) before the invocation.

Fixing this points out that the test does not work in the
--target_board=cc-with-gdb-index case.  This patch also arranges to
issue an "untested" here.

4 months agoAutomatic date update in version.in
GDB Administrator [Sun, 2 Feb 2025 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 months agoRemove obsolete test from gdb.cp/var-tag.exp
Tom Tromey [Sat, 4 Jan 2025 17:48:07 +0000 (10:48 -0700)] 
Remove obsolete test from gdb.cp/var-tag.exp

There is a test in gdb.cp/var-tag.exp that is kfail'd.  I happened
across this while working on another series and found that the PR it
referenced was closed as invalid.  On that basis I think the test
should be deleted.

Reviewed-By: Keith Seitz <keiths@redhat.com>
4 months agoShow type- and function-domain in maint print psymbols
Tom Tromey [Mon, 20 Jan 2025 18:02:51 +0000 (11:02 -0700)] 
Show type- and function-domain in maint print psymbols

I neglected to update "maint print psymbols" when adding TYPE_DOMAIN
and FUNCTION_DOMAIN.  This would have been mildly helpful when
debugging a series I am working on.  This patch corrects the
oversight.

Approved-By: Andrew Burgess <aburgess@redhat.com>
4 months agoAutomatic date update in version.in
GDB Administrator [Sat, 1 Feb 2025 00:00:14 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 months agoUse "false" when setting cli_styling
Tom Tromey [Fri, 31 Jan 2025 21:23:32 +0000 (14:23 -0700)] 
Use "false" when setting cli_styling

I noticed a spot that uses 0 where "false" is more appropriate.

4 months agoAdd space in name of Rust tuple type
Tom Tromey [Sun, 19 Jan 2025 23:57:07 +0000 (16:57 -0700)] 
Add space in name of Rust tuple type

The Rust compiler emits tuple type names with a space after the comma,
like "(i32, f64)".  This changes rust-parse.c to follow.  This isn't
ideal -- probably the DWARF reader should canonicalize these names --
but it is a bit more robust if symbol lookup should change; and anyway
this feature of gdb is probably rarely used.

4 months agoaarch64: Support +sme+nosve permissively
Andrew Carlotti [Fri, 31 Jan 2025 05:07:30 +0000 (05:07 +0000)] 
aarch64: Support +sme+nosve permissively

There is inconsistency regarding whether or not +sme implies +sve2 and
whether +nosve2 implies +nosme.  In particular, GCC 14 assumes the
dependency exists, and canonicalises target strings accordingly, whereas
LLVM treats the features as independent.

This patch removes the positive implication while retaining the negative
implication.  This is the more permissive choice in each case, and
allows us to support target strings written with either interpretation
in mind.

This reduces our ability to detect invalid instructions, but we already
can't rely on this detection because gas doesn't know whether functions
might be executed in streaming mode and/or non-streaming mode.

The aarch64_feature_enable_set change is functionally redundant within
this patch.  It is included because the longer term intention is to
instead remove the workaround in aarch64_parse_features, once the
internal feature checks have been modified to support having both
AARCH64_FEATURE_SME set and AARCH64_FEATURE_SVE unset.

Similarly, the dependency from +sme to +fp16 is currently redundant, but
this redundancy relies upon an incorrect dependency from +fcma to +fp16.
This can be fixed in the future, but it might require modifying internal
feature checks for a few FCMA instructions, so it's left unchanged for
now.

4 months agoaarch64: Fix fp8 feature dependencies
Andrew Carlotti [Thu, 30 Jan 2025 19:14:46 +0000 (19:14 +0000)] 
aarch64: Fix fp8 feature dependencies

We agreed with LLVM that we shouldn't enforce the architectural
dependencies between fp8 muliplication features, so remove them.

Additionally, fix a typo in the gating for FEAT_SME_F8F16 instructions,
which were mistakenly gated by +sme-f8f32 instead.  Until now this
mistake had been masked by the dependency between the features.

4 months agoaarch64: Fix overly lax +frintts dependency
Andrew Carlotti [Thu, 30 Jan 2025 18:35:14 +0000 (18:35 +0000)] 
aarch64: Fix overly lax +frintts dependency

We agreed with LLVM that +frintts should only enable +fp, not +simd.
This also matches the dependency used in GCC.

4 months agoLoongArch: Do not relax against __[start|stop]_SECNAME symbol
Lulu Cai [Fri, 31 Jan 2025 10:37:50 +0000 (10:37 +0000)] 
LoongArch: Do not relax against __[start|stop]_SECNAME symbol

4 months agox86/APX: correct libbfd's EVEX Rn -> Bn transformations
Jan Beulich [Fri, 31 Jan 2025 09:07:54 +0000 (10:07 +0100)] 
x86/APX: correct libbfd's EVEX Rn -> Bn transformations

In the recent GOTPCREL addition I screwed up, in clearing the Rn bits
afterwards rather than setting them. While that ought to be benign (for
the bits being ignored in situations like this), we still want to leave
"canonical" encodings.

The pre-existing GOTTPOFF conversion wasn't doing quite correctly
either: We cannot assume the incoming Bn bits to be in a particular
state, as for the addressing form in question they're ignored as well.

To address both, introduce a helper function. This is then also an
overall reduction of (source) code size (and use of "magic" numbers).

4 months agox86/APX: GETSEC cannot be used with REX2
Jan Beulich [Fri, 31 Jan 2025 09:07:32 +0000 (10:07 +0100)] 
x86/APX: GETSEC cannot be used with REX2

It lives in a "forbidden" row, yet its disassembler table entry was
lacking a respective marker.

4 months agox86: support RMPREAD insn
Jan Beulich [Fri, 31 Jan 2025 09:06:02 +0000 (10:06 +0100)] 
x86: support RMPREAD insn

Like for RMPUPDATE documentation is about to change as far as operands
are concerned. They're merely the other way around here.

While adjustind gas documentation, also add the missing RMPQUERY
counterparts there.

4 months agox86: RMPUPDATE wants operands in different form
Jan Beulich [Fri, 31 Jan 2025 09:05:36 +0000 (10:05 +0100)] 
x86: RMPUPDATE wants operands in different form

AMD are about to update their doc, to help clarify that what we
currently do isn't quite right: In particular it is not %rax but %rcx
which is affected by address size. In fact, that's a normal memory
operand, just not expressed via ModR/M byte, but fixed to (%rcx) (or
(%ecx) with 32-bit addressing).

To support this in the assembler, generalize memory operand handling so
far specific to XLAT (which isn't really a string insn, but requires its
memory operand to be (%bx) / (%ebx) / (%rbx)).

In the disassembler mimic handling after XLAT's, too.

4 months agox86-64: omit "default" segment prefixes from string insn disassembly
Jan Beulich [Fri, 31 Jan 2025 09:04:45 +0000 (10:04 +0100)] 
x86-64: omit "default" segment prefixes from string insn disassembly

Printing implicit %ds: and %es: prefixes is pretty meaningless in 64-bit
mode. The SDM explicitly omits them for the 64-bit forms, and it
obviously has them for the other ones only to cover non-64-bit modes
(oddly enough the AMD PM has them present).

4 months agoRISC-V: widen LEB128 support
Jan Beulich [Fri, 31 Jan 2025 09:04:01 +0000 (10:04 +0100)] 
RISC-V: widen LEB128 support

Do away with at least one of the limitations - all other targets permit
multiple values to be specified with a single directive. Re-arrange the
logic further to also overcome an internal error in
riscv_insert_uleb128_fixes(), as e.g. observed by the all/sleb128-2
testcase. This way there's also no need to parse expressions twice,
thus also not raising the same diagnostics (if any) twice.

Note how this addresses a pre-existing XFAIL (where the comment wasn't
really applicable either for RISC-V).

Also update documentation, also to mention that differences between
symbols may be used with .uleb128 (albeit I'm uncertain whether there
are limitations).

4 months agoUse "require" a two gdb.dwarf2 test files
Tom Tromey [Fri, 31 Jan 2025 05:51:49 +0000 (22:51 -0700)] 
Use "require" a two gdb.dwarf2 test files

A couple of ".tcl" files in gdb.dwarf2 escaped notice during the
"require" refactoring.  This patch fixes these to use "require" rather
than if/return.

4 months agoAutomatic date update in version.in
GDB Administrator [Fri, 31 Jan 2025 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 months agogdb: add first gdbreplay test, connect.exp
Alexandra Hájková [Wed, 23 Oct 2024 12:18:43 +0000 (14:18 +0200)] 
gdb: add first gdbreplay test, connect.exp

When the changes on the remote protocol are made,
we want to test all the corner cases to prevent
regressions.  Currently it can be tricky to simulate
some corner case conditions that would expose possible
regressions.  When I want to add or change the remote
protocol packet, I need to hack gdbserver to send a
corrupted packet or an error to make sure GDB is able
to handle such a case.

This test makes it easy to send a corruped packet or
an error message to GDB using the gdbreplay tool and
check GDB deals with it as we expect it to.

This test starts a communication with gdbsever setting
the remotelog file.  Then, it modifies the remotelog with
update_log proc, injects an error message instead of
the expected replay to the vMustReplyEmpty packet in order
to test GDB reacts to the error response properly.  After
the remotelog modification, this test restarts GDB and starts
communication with gdbreply instead of the gdbserver using
the remotelog.

Add a lib/gdbreplay-support.exp.  update_log proc matches lines
from GDB to gdbserver in a remotelogfile.  Once a match is found then
the custom line is used to build a replacement line to send from
gdbserver to GDB.

Approved-By: Andrew Burgess <aburgess@redhat.com>
4 months agoRe-enable background reading
Tom Tromey [Thu, 12 Dec 2024 23:21:30 +0000 (16:21 -0700)] 
Re-enable background reading

All the reported races have been fixed, so this patch re-enabled
background DWARF reading.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31751
Tested-By: Tom de Vries <tdevries@suse.de>
4 months agogdb: remove unused includes from dwarf2/index-write.c
Simon Marchi [Tue, 28 Jan 2025 21:15:48 +0000 (16:15 -0500)] 
gdb: remove unused includes from dwarf2/index-write.c

These includes are reported as unused by clangd.

Change-Id: Ibf3cdc881abad5f5969edca623412ceac7212149

4 months agogdb: remove includes from dwarf2/mapped-index.h
Simon Marchi [Tue, 28 Jan 2025 20:17:19 +0000 (15:17 -0500)] 
gdb: remove includes from dwarf2/mapped-index.h

They are unused, according to clangd.

Add some includes to other files, which were relying on transitive
includes.

Change-Id: I3bcb4be93b3a18bf44a4068f4067e567f83e1d4f

4 months agogdb: remove unused include from dwarf2/read.c
Simon Marchi [Tue, 28 Jan 2025 20:16:38 +0000 (15:16 -0500)] 
gdb: remove unused include from dwarf2/read.c

It is unused, according to clangd.

Change-Id: Ieadb84a2b1953b70d82a28775472fd347a809a62

4 months agogdb: remove unused include, add forward declaration in dwarf2/parent-map.h
Simon Marchi [Tue, 28 Jan 2025 20:15:30 +0000 (15:15 -0500)] 
gdb: remove unused include, add forward declaration in dwarf2/parent-map.h

dwarf2_per_bfd is used but never declared in this file, forward-declare
it.

dwarf2/types.h is unused, according to clangd.

Change-Id: I324b68894008af20307030c9e36c5abe06e36a78

4 months agogdb: remove unused include in symtab.h
Simon Marchi [Tue, 28 Jan 2025 20:14:34 +0000 (15:14 -0500)] 
gdb: remove unused include in symtab.h

This include is unused, according to clangd.

Change-Id: Ifbc2fe75b02c9ae9b3e2f1184bbcc4dc7095a554

4 months agogdb: include symtab.h in quick-symbol.h
Simon Marchi [Tue, 28 Jan 2025 20:13:39 +0000 (15:13 -0500)] 
gdb: include symtab.h in quick-symbol.h

quick-symbol.h uses domain_search_flags, defined in symtab.h.

Change-Id: I5c4ae272da929eb6a8dd593bcd96a2aacf0ca99f

4 months agoRemove a couple of entries in the binutils MAINTAINERS file
Nick Clifton [Thu, 30 Jan 2025 16:01:02 +0000 (16:01 +0000)] 
Remove a couple of entries in the binutils MAINTAINERS file

4 months ago[gdb/testsuite] Handle unordered dict in gdb.python/py-mi-notify.exp
Tom de Vries [Thu, 30 Jan 2025 12:21:56 +0000 (13:21 +0100)] 
[gdb/testsuite] Handle unordered dict in gdb.python/py-mi-notify.exp

With test-case gdb.python/py-mi-notify.exp and python 3.4, I occasionally run
into:
...
python gdb.notify_mi('-test-notification', { 'data1' : 1 , 'data2' : 2 })
&"python gdb.notify_mi('-test-notification', { 'data1' : 1 , 'data2' : 2 })\n"
=-test-notification,data2="2",data1="1"
^done
(gdb)
FAIL: $exp: python notification, with additional data (unexpected output)
...

In contrast, a passing version looks like:
...
python gdb.notify_mi('-test-notification', { 'data1' : 1 , 'data2' : 2 })
&"python gdb.notify_mi('-test-notification', { 'data1' : 1 , 'data2' : 2 })\n"
=-test-notification,data1="1",data2="2"
^done
(gdb)
PASS: gdb.python/py-mi-notify.exp: python notification, with additional data
...

The python method "gdb.notify_mi(name, data)" has parameter data which is a
dictionary, and it iterates over that dictionary.

The problem is that dictionaries are only guaranteed to be iterating in
insertion order starting python 3.7 (though cpython does this starting python
3.6).

Fix this in the same way as in commit 362a867f2ac ("[gdb/testsuite] Handle
unordered dict in gdb.python/py-mi-cmd.exp"): by allowing the alternative
order.

Tested on x86_64-linux.

4 months agox86-64: Remove pr19609-4c.d and pr19609-4d.d
H.J. Lu [Thu, 30 Jan 2025 04:17:57 +0000 (12:17 +0800)] 
x86-64: Remove pr19609-4c.d and pr19609-4d.d

Remove pr19609-4c.d and pr19609-4d.d since they are identical to
pr19609-4a.d and pr19609-4b.d, respectively.

* testsuite/ld-x86-64/pr19609-4c.d: Removed.
* testsuite/ld-x86-64/pr19609-4d.d: Likewise.
* testsuite/ld-x86-64/pr19609-4e.d: Renamed to ...
* testsuite/ld-x86-64/pr19609-4c.d: This.
* testsuite/ld-x86-64/x86-64.exp: Updated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 months agoAutomatic date update in version.in
GDB Administrator [Thu, 30 Jan 2025 00:00:43 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 months agoUse command style in cmd_show_list
Tom Tromey [Sat, 11 Jan 2025 21:36:54 +0000 (14:36 -0700)] 
Use command style in cmd_show_list

cmd_show_list is a bit funny because it shows partial command names --
for a command like "show abc xyz", it will only show "abc xyz".

Nevertheless, I think it makes some sense to highlight these with the
command style.  That is what this patch does.

4 months agoRemove "enabled" output from show_index_cache_command
Tom Tromey [Sat, 11 Jan 2025 21:34:06 +0000 (14:34 -0700)] 
Remove "enabled" output from show_index_cache_command

show_index_cache_command prints whether the index-cache is enabled.
This text was added back in 2018 in commit 87d6a7aa (Add DWARF index
cache).  Then in 2021, the enabling option was changed via commit
7bc5c369 (gdb: introduce "set index-cache enabled", deprecate "set
index-cache on/off").

This latter change made this output, IMO, redundant.  That is,
currently gdb will show:

    (gdb) show index-cache
    ...
    index-cache enabled:  The index cache is off.
    ...
    The index cache is currently disabled.

This patch removes the redundant output.

4 months agoUse command style in "help" command
Tom Tromey [Sat, 11 Jan 2025 21:11:01 +0000 (14:11 -0700)] 
Use command style in "help" command

This changes the help command to use the new command style when
displaying text like:

    List of "catch" subcommands:

As a side effect, this mildly -- but not hugely -- cleans up some i18n
issues in help_list.  The header comment for that function is also
changed to the gdb style.

Finally, this function used to print something like:

    Type "help catch" followed by catch subcommand name for full documentation.

The second "catch" here seems redundant to me, so this patch removes
it.

4 months agoAvoid calling help_list in more places
Tom Tromey [Sat, 11 Jan 2025 20:50:50 +0000 (13:50 -0700)] 
Avoid calling help_list in more places

I think there is no need to have a prefix command that simply calls
help_list.  Instead, add_basic_prefix_cmd can be used.  This patch
changes the relevant instances.  In one spot, add_setshow_prefix_cmd
is used instead.

4 months agogdb: include cli/cli-style.h in darwin-nat.c
Simon Marchi [Wed, 29 Jan 2025 15:45:31 +0000 (10:45 -0500)] 
gdb: include cli/cli-style.h in darwin-nat.c

PR 32610 says:

  File gdb/darwin-nat.c is missing an #include statement of
  "cli/cli-style.h". It is needed because there is a reference to class
  object command_style in the .c file.

I'm not able to build-test this change (I only have access to arm64
macos machines, which GDB doesn't support yet), but I don't think I'm
doing things worse by adding this.

Change-Id: I2a169664ff91b92caf27cb084334f2eb4df46aa5

4 months agogdb/testsuite: add comments to line table from DWARF assembler
Andrew Burgess [Sat, 25 Jan 2025 11:51:43 +0000 (11:51 +0000)] 
gdb/testsuite: add comments to line table from DWARF assembler

Add comments to the assembler generated by the DWARF assembler that
builds the line table.  I found these comments useful when debugging
issues with the line table parsing.

This patch should make no difference to what is being tested.  The
test binaries should be unchanged after this commit.

Approved-By: Kevin Buettner <kevinb@redhat.com>
4 months agogdbserver: fix the declared type of register_status in regcache
Tankut Baris Aktemur [Wed, 29 Jan 2025 09:50:32 +0000 (10:50 +0100)] 
gdbserver: fix the declared type of register_status in regcache

The register_status field of regcache is declared as `unsigned char *`.
This is incorrect, because `enum register_status` from
gdbsupport/common-regcache.h is based on signed char and
REG_UNAVAILABLE is defined as -1.  Fix the declared type.

Now that we are modifying the declaration, also use a unique_ptr
and make the field private.

The get/set methods already use the correct type, but we update cast
operations in two places.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 months agogdbserver: refactor the definition and uses of supply_regblock
Tankut Baris Aktemur [Wed, 29 Jan 2025 09:50:31 +0000 (10:50 +0100)] 
gdbserver: refactor the definition and uses of supply_regblock

The supply_regblock function takes a pointer to a buffer as an
argument and implements two different behavior based on the pointer
being null.  There are two cases where we pass nullptr, all in
tracepoint.cc, where we are essentially doing a reset on the regcache.

In fast_tracepoint_ctx::regcache, register_status array does not
even exist.  Hence, that use simply boils down to zeroing of register
data.  Do this at the time of creating the buffer and remove the call
to supply_regblock.

In fetch_traceframe_registers, inline the use with a call to `reset`.

Hence, there are no more cases left, where a nullptr would be passed
to supply_regblock.  Assert that the buffer argument is non-null and
simplify the implementation.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 months agogdbserver: define and use regcache::reset
Tankut Baris Aktemur [Wed, 29 Jan 2025 09:50:31 +0000 (10:50 +0100)] 
gdbserver: define and use regcache::reset

Define a `reset` method for a regcache and use it for code
simplification.  This patch allows further simplification in the next
patch.

The reset method fills the register data with zeroes.  For the use in
get_thread_regcache, this is added behavior, making the patch not a
pure refactoring, and may look like extra overhead.  However, it is
better to avoid having arbitrary values left in the data buffer.
Hence, it is considered a behavioral improvement.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 months agogdbserver: use REG_UNKNOWN for a regcache's register statuses
Tankut Baris Aktemur [Wed, 29 Jan 2025 09:50:31 +0000 (10:50 +0100)] 
gdbserver: use REG_UNKNOWN for a regcache's register statuses

When a regcache is initialized, the values of registers are not
fetched yet.  Thus, initialize the register statuses to REG_UNKNOWN
instead of REG_UNAVAILABLE, because the latter rather means "we
attempted to fetch but could not obtain the value".

The definitions of the reg status enums (from
gdbsupport/common-regcache.h) as a reminder:

    /* The register value is not in the cache, and we don't know yet
       whether it's available in the target (or traceframe).  */
    REG_UNKNOWN = 0,

    /* The register value is valid and cached.  */
    REG_VALID = 1,

    /* The register value is unavailable.  E.g., we're inspecting a
       traceframe, and this register wasn't collected.  Note that this
       "unavailable" is different from saying the register does not
       exist in the target's architecture --- in that case, the target
       should have given us a target description that does not include
       the register in the first place.  */
    REG_UNAVAILABLE = -1

Similarly, when the regcache is invalidated, change all the statuses
back to REG_UNKNOWN.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 months agogdbserver: use unique_ptr for thread_info's regcache
Tankut Baris Aktemur [Wed, 29 Jan 2025 09:50:30 +0000 (10:50 +0100)] 
gdbserver: use unique_ptr for thread_info's regcache

Store the regcache pointer in thread_info as a unique_ptr.  This
allows us delete the thread_info destructor.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 months agogdbserver: convert free_register_cache into a destructor of regcache
Tankut Baris Aktemur [Wed, 29 Jan 2025 09:50:30 +0000 (10:50 +0100)] 
gdbserver: convert free_register_cache into a destructor of regcache

Convert the `free_register_cache` function into a destructor of the
regcache struct.  In one place, we completely remove the call to free
the regcache object by stack-allocating the object.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 months agogdbserver: convert init_register_cache and new_register_cache into constructors
Tankut Baris Aktemur [Wed, 29 Jan 2025 09:50:30 +0000 (10:50 +0100)] 
gdbserver: convert init_register_cache and new_register_cache into constructors

This is a refactoring that converts

  init_register_cache (struct regcache *regcache,
                       const struct target_desc *tdesc,
                       unsigned char *regbuf)

into the constructor

  regcache (const target_desc *tdesc, unsigned char *regbuf)

and converts

  new_register_cache (const struct target_desc *tdesc)

into the constructor

  regcache (const target_desc *tdesc)

Also use DISABLE_COPY_AND_ASSIGN for additional compile-time safety.

Tested by rebuilding gdbserver with '--enable-inprocess-agent=no' and
with '--enable-inprocess-agent=yes'.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 months agogdbserver: use inheritance more to define tracepoint contexts
Tankut Baris Aktemur [Wed, 29 Jan 2025 09:50:30 +0000 (10:50 +0100)] 
gdbserver: use inheritance more to define tracepoint contexts

This is a continuation of the previous refactoring to use inheritance
in the definition of tracepoints contexts.  Again, no behavioral change
is intended.

Different tracepoint contexts are identified by the `type` field.  The
field is used only in `get_context_regcache`, where we essentially
have 2 cases, each corresponding to a tracepoint context type.  Remove
the `type` field and split the `get_context_regcache` function into 2
virtual method implementations.

Tested by rebuilding gdbserver with '--enable-inprocess-agent=no' and
'--enable-inprocess-agent=yes'.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 months agogdbserver: use inheritance to define tracepoint contexts
Tankut Baris Aktemur [Wed, 29 Jan 2025 09:50:29 +0000 (10:50 +0100)] 
gdbserver: use inheritance to define tracepoint contexts

Use inheritance in the definition of tracepoint contexts.  This is a
refactoring that aims to improve the code.  No behavior should be
altered.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 months agogdbserver: add back lost comments in fast_tracepoint_ctx
Tankut Baris Aktemur [Wed, 29 Jan 2025 09:50:29 +0000 (10:50 +0100)] 
gdbserver: add back lost comments in fast_tracepoint_ctx

Before the removal of the UST/static-tracepoint support, the
`static_tracepoint_ctx` struct contained comments for its fields,
whereas `fast_tracepoint_ctx` did not.  Nevertheless, those comments
also applied to `fast_tracepoint_ctx`.  With the removal of
`static_tracepoint_ctx`, the comments were lost, making
`fast_tracepoint_ctx` data members completely commentless.  Add back
those comments.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 months agogdbserver: introduce and use new gdb::argv_vec class
Andrew Burgess [Tue, 28 Jan 2025 10:08:28 +0000 (10:08 +0000)] 
gdbserver: introduce and use new gdb::argv_vec class

In gdbserver there are a couple of places where we perform manual
memory management using a 'std::vector<char *>' with the vector owning
the strings within it.  We need to take care to call
free_vector_argv() before leaving the scope to cleanup the strings
within the vector.

This commit introduces a new class gdb::argv_vec which wraps around a
'std::vector<char *>' and owns the strings within the vector, taking
care to xfree() them when the gdb::argv_vec is destroyed.

Right now I plan to use this class in gdbserver.

But this class will also be used to address review feedback on this
commit:

  https://inbox.sourceware.org/gdb-patches/72227f1c5a2e350ca70b2151d1b91306a0261bdc.1736860317.git.aburgess@redhat.com

where I tried to introduce another 'std::vector<char *>' which owns
the strings.  That patch will be updated to use gdb::argv_vec instead.

The obvious question is, instead of introducing this new class, could
we change the APIs to avoid having a std::vector<char *> that owns the
strings?  Could we use 'std::vector<std::string>' or
'std::vector<gdb::unique_xmalloc_ptr<char>>' instead?

The answer is yes we could.

I originally posted this larger patch set:

  https://inbox.sourceware.org/gdb-patches/cover.1730731085.git.aburgess@redhat.com

however, getting a 14 patch series reviewed is just not possible, so
instead, I'm posting the patches one at a time.  The earlier patch I
mentioned is pulled from the larger series.

The larger series already includes changes to gdbserver which removes
the need for the 'std::vector<char *>', however, getting those changes
in depends (I think) on the patch I mention above.  Hence we have a
bit of a circular dependency.

My proposal is to merge this patch (adding gdb::argv_vec) and make use
of it in gdbserver.

Then I'll update the patch above to also use gdb::argv_vec, which will
allow the above patch to get reviewed and merged.

Then I'll post, and hopefully merge additional patches from my larger
inferior argument series, which will remove the need for gdb::argv_vec
from gdbserver.

At this point, the only use of gdb::argv_vec will be in the above
patch, where I think it will remain, as I don't think that location
can avoid using 'std::vector<char *>'.

Approved-By: Tom Tromey <tom@tromey.com>
4 months agogdb: move debug output inside block in dwarf_record_line_1
Andrew Burgess [Sat, 25 Jan 2025 13:05:46 +0000 (13:05 +0000)] 
gdb: move debug output inside block in dwarf_record_line_1

The debug output that says a line has been recorded is currently
outside the `if` block which decides if the line should be recorded or
not.  This means the debug output will claim the line was recorded,
when actually it wasn't!

Fixed by moving the debug output inside the `if` block.

Should be no user visible changes after this commit (except if debug
output is turned on).

Approved-By: Tom Tromey <tom@tromey.com>
4 months agoAutomatic date update in version.in
GDB Administrator [Wed, 29 Jan 2025 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 months agoMicroBlaze: Add features/microblaze-linux.xml
Michael J. Eager [Tue, 28 Jan 2025 21:20:52 +0000 (13:20 -0800)] 
MicroBlaze: Add features/microblaze-linux.xml

This is a preparatory patch to support native linux port
of gdbserver for MicroBlaze
* gdb/features/Makefile : Add microblaze-expedite
* gdb/features/microblaze-linux.xml : New
* gdb/features/microblaze-linux.c : New (generated)
* gdb/regformats/microblaze-linux.dat : New (generated)

Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
Signed-off-by: Gopi Kumar Bulusu <gopi@sankhya.com>
Signed-off-by: Michael J. Eager <eager@eagercon.com>
4 months ago[gdb/tui] Fix assert in tui_source_window_base::refresh_window
Tom de Vries [Tue, 28 Jan 2025 20:00:40 +0000 (21:00 +0100)] 
[gdb/tui] Fix assert in tui_source_window_base::refresh_window

Say we use the executable of test-case gdb.tui/tui-missing-src.exp like this:
...
$ gdb.sh -q -tui outputs/gdb.tui/tui-missing-src/tui-missing-src \
    -ex "b f2"\
    -ex run
...
(from a directory not containing a file called main.c to make sure that the
missing source stays missing) and then issue finish:
...
(gdb) finish
Run till exit from #0  f2 (x=4)
    at f2.c:5
0x0000000000400570 in main ()
    at main.c:7
Value returned is $1 = 13
(gdb)
...
and use control-<minus> to decrease the font size (IOW increase the $LINES and
$COLUMNS) on the terminal, we get:
...
gdb/tui/tui-winsource.c:340: internal-error: refresh_window: \
  Assertion `pad_x + view_width <= pad_width || m_pad.get () == nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...

The tui_source_window_base class has variable m_pad which keeps track of a
curses pad that is used to display the source code or disassembly efficiently.

The assert in tui_source_window_base::refresh_window triggers while preparing
to display part of the pad.

The problem is that the window is in a state in which the pad is not used,
because m_content.empty () == true.  Instead, it simply shows
"[ No Source Available ]".

Fix this by bailing out of tui_source_window_base::refresh_window before
accessing the m_pad variable, if m_content.empty () == true.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR tui/32592
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32592

4 months ago[gdb/guile] Use SCM_DEBUG_TYPING_STRICTNESS 0
Tom de Vries [Tue, 28 Jan 2025 19:56:17 +0000 (20:56 +0100)] 
[gdb/guile] Use SCM_DEBUG_TYPING_STRICTNESS 0

I build gdb with libguile v2.0.9, and ran into:
...
In file included from /usr/include/guile/2.0/libguile.h:56,
                 from ../../gdb/guile/guile-internal.h:30,
                 from ../../gdb/guile/scm-arch.c:26:
/usr/include/guile/2.0/libguile/inline.h: In function 'int scm_is_pair(SCM)':
/usr/include/guile/2.0/libguile/tags.h:97:53: error: \
  operation on '*0' may be undefined [-Werror=sequence-point]
 #   define SCM_UNPACK(x) ((scm_t_bits) (0? (*(SCM*)0=(x)): x))
                                            ~~~~~~~~~^~~~~
...

Fix this by using SCM_DEBUG_TYPING_STRICTNESS 0.

We were already using this for c++20 due to a Werror=volatile in SCM_UNPACK
when using libguile v2.0.10.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
4 months agoFix gdb.ada/import.exp when using mold
Tom Tromey [Mon, 13 Jan 2025 17:39:50 +0000 (10:39 -0700)] 
Fix gdb.ada/import.exp when using mold

We found that the gdb.ada/import.exp test fails when 'mold' is used as
the linker.  This happens because mold decides to mark most of the
symbols in the executable as being file-local.  I tend to think this
choice, while non-traditional, is probably fine.  So, this patch fixes
the problem by changing the relevant Ada code to look for file-local
symbols as well.

Furthermore, there are two overloads of lookup_minimal_symbol_linkage
that both have a final 'bool' parameter -- but with radically
different meanings.  This patch somewhat clears up this confusion as
well.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31378

4 months agoAdd translations for various sub-directories
Nick Clifton [Tue, 28 Jan 2025 16:33:47 +0000 (16:33 +0000)] 
Add translations for various sub-directories

4 months agogdb/remote: add 'binary-upload' feature to guard 'x' packet use
Andrew Burgess [Fri, 24 Jan 2025 16:12:55 +0000 (16:12 +0000)] 
gdb/remote: add 'binary-upload' feature to guard 'x' packet use

This mailing list discussion:

  https://inbox.sourceware.org/gdb-patches/CAOp6jLYD0g-GUsx7jhO3g8H_4pHkB6dkh51cbyDT-5yMfQwu+A@mail.gmail.com

highlighted the following issue with GDB's 'x' packet implementation.

Unfortunately, LLDB also has an 'x' packet, but their implementation
is different to GDB's and so targets that have implemented LLDB's 'x'
packet are incompatible with GDB.

The above thread is specifically about the 'rr' tool, but there could
be other remote targets out there that have this problem.

The difference between LLDB and GDB is that GDB expects a 'b' prefix
on the reply data, while LLDB does not.  The 'b' is important as it
allows GDB to distinguish between an empty reply (which will be a 'b'
prefix with no trailing data) and an unsupported packet (which will be
a completely empty packet).  It is not clear to me how LLDB
distinguishes these two cases.

See for discussion of the 'x' packet:

  https://inbox.sourceware.org/gdb-patches/cover.1710343840.git.tankut.baris.aktemur@intel.com/#r

with the part specific to the 'b' marker in:

  https://inbox.sourceware.org/gdb-patches/87msq82ced.fsf@redhat.com/

I propose that we add a new feature 'binary-upload' which can be
reported by a stub in its qSupported reply.  By default this feature
is "off", meaning GDB will not use the 'x' packet unless a stub
advertises this feature.

I have updated gdbserver to send 'binary-upload+', and when I examine
the gdbserver log I can see this feature being sent back, and then GDB
will use the 'x' packet.

When connecting to an older gdbserver, the feature is not sent, and
GDB does not try to use the 'x' packet at all.

I also built the latest version of `rr` and tested using current HEAD
of master, where I see problems like this:

  (rr) x/10i main
     0x401106 <main>:   Cannot access memory at address 0x401106

Then tested using this patched version of GDB, and now I see:

  (rr) x/10i main
     0x401106 <main>:   push   %rbp
     0x401107 <main+1>: mov    %rsp,%rbp
     0x40110a <main+4>: mov    0x2f17(%rip),%rax        # 0x404028 <global_ptr>
     ... etc ...

and looking in the remote log I see GDB is now using the 'm' packet
instead of the 'x' packet.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32593
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
4 months agogdb/configure: fail configure if all targets requested with 32bit bfd
Guinevere Larsen [Thu, 23 Jan 2025 19:42:53 +0000 (16:42 -0300)] 
gdb/configure: fail configure if all targets requested with 32bit bfd

As PR sim/28684 explains, it isn't possible to compile GDB with all
targets enabled and not enabling 64 bit bfd. In 64 bit hosts, 64 bit bfd
is forced, so the build works, but in 32 bit hosts, that has to be
explicitly enabled.

I ran into this when I tried compiling GDB on a mips64 machine running a
32 bit OS. Along with the errors in the PR, several other architectures
are also required, notably aarch64 and other explicitly 64bit targets.
Additionally, some 32 bit files required for the gdb mips target aren't
added to the makefile.

Considering the last comment in the bug says this isn't going to be
fixed on the binutils side, I didn't think it was worth trying to fix
the GDB side. Instead, this commit causes the configure script to fail
if all targets were requested and 64 bit bfd isn't enabled. If that is
ever fixed, we can revert this commit.

I considered adding this to the top level configure script, but couldn't
figure out how to detect the situation in there, so this was my next
best idea.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28684
Approved-by: Kevin Buettner <kevinb@redhat.com>
4 months ago[gdb/doc] Fix "Standard Replies" xref
Tom de Vries [Tue, 28 Jan 2025 07:01:46 +0000 (08:01 +0100)] 
[gdb/doc] Fix "Standard Replies" xref

When building gdb with an older makeinfo (4.13), I run into:
...
gdb/doc/gdb.texinfo:42613: warning: `.' or `,' must follow @xref, not `f'.
...

This is related to this line:
...
@xref{Standard Replies} for standard error responses, and how to
respond indicating a command is not supported.
...

Fix this by adding a comma.

Tested by rebuilding the docs.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Co-Authored-By: Eli Zaretskii <eliz@gnu.org>
4 months agoAutomatic date update in version.in
GDB Administrator [Tue, 28 Jan 2025 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 months agoMicroBlaze: Widen mask used in opcodes/microblaze-dis,c
Michael J. Eager [Mon, 27 Jan 2025 20:01:20 +0000 (12:01 -0800)] 
MicroBlaze: Widen mask used in opcodes/microblaze-dis,c

Instead of using 0xFFFF0000, or with (~0xFFFF) to sign extend
negative 16-bit value and with (~0xFFFF) to extract higher order
address bits

opcodes/
* microblaze-dis.c: (print_insn_microblaze): Widen mask
(microblaze_get_target_address): Likewis

Signed-off-by: Gopi Kumar Bulusu <gopi@sankhya.com>
Signed-off-by: Michael J. Eager <eager@eagercon.com>
4 months agos390: Error if vector index register omitted in assembly
Jens Remus [Mon, 27 Jan 2025 15:48:58 +0000 (16:48 +0100)] 
s390: Error if vector index register omitted in assembly

Vector index registers are currently only used in the VRV instruction
format.  Unlike general purpose index registers an operand value of
zero (e.g. %v0, 0, or omitted) does not imply a zero value:

"For VRV format instructions, a vector element is used in the formation
of the intermediate value.  This vector element is an unsigned binary
integer value that is added to the base address and 12-bit displacement
to form a 64-bit intermediate sum.  The vector element is designated by
a vector register and an element index.  A zero V field accesses the
element in vector register zero and does not imply a zero value." [1]

Therefore require vector index register operands to be specified in
assembler source.  That is do require coding of D(VX,B) instead of
allowing to omit VX=0 as D(,B), D(B), or D.  Emit an error message if
a mandatory vector index register is omitted:

  Error: operand <n>: missing vector index register operand

Note that this change is not backwards compatible.  But any code that
omitted the specification of the vector index register is likely to be
in error.  Therefore it is favorable to report an error than to stay
backward compatible.

[1]: IBM z/Architecture Principles of Operation, SA22-7832-13, IBM z16,
     https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf

gas/
* config/tc-s390.c (md_gather_operands): Do not allow
vector index register operands to be optionally omitted.

gas/testsuite/
* gas/s390/zarch-base-index-0.d (vgef): Remove tests with
omitted vector index register operands.
* gas/s390/zarch-base-index-0.s (vgef): Move tests with omitted
vector index register operands ...
* gas/s390/zarch-base-index-0-err.s (vgef): ... to here.
* gas/s390/zarch-base-index-0-err.l (vgef): Expect error
for omitted vector index register operands.
* gas/s390/zarch-omitted-base-index.d (vgef): Remove tests with
omitted vector index register operands.
* gas/s390/zarch-omitted-base-index.s (vgef): Move tests with
omitted vector index register operands ...
* gas/s390/zarch-omitted-base-index-err.s (vgef): ... to here.
* gas/s390/zarch-omitted-base-index-err.l (vgef): Expect error
for omitted vector index register operands.
* gas/s390/zarch-warn-areg-zero.l (vgef): Remove tests with
omitted vector index register operands.
* gas/s390/zarch-warn-areg-zero.s (vgef): Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 months agos390: Do not warn about vector index register 0 in assembly
Jens Remus [Mon, 27 Jan 2025 15:48:58 +0000 (16:48 +0100)] 
s390: Do not warn about vector index register 0 in assembly

Vector index registers are currently only used in the VRV instruction
format.  Unlike general purpose index registers an operand value of
zero (e.g. %v0, 0, or omitted) does not imply a zero value:

"For VRV format instructions, a vector element is used in the formation
of the intermediate value.  This vector element is an unsigned binary
integer value that is added to the base address and 12-bit displacement
to form a 64-bit intermediate sum.  The vector element is designated by
a vector register and an element index.  A zero V field accesses the
element in vector register zero and does not imply a zero value." [1]

Therefore when using s390-specific assembler option "-mwarn-areg-zero"
do not warn if vector index register 0 is specified.

[1]: IBM z/Architecture Principles of Operation, SA22-7832-13, IBM z16,
     https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf

gas/
* config/tc-s390.c (md_gather_operands): Do not warn about
vector index register 0.

gas/testsuite/
* gas/s390/zarch-warn-areg-zero.l (vgef): Do not expect warning
about vector index register 0.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 months agos390: Do not omit vector index register 0 in disassembly
Jens Remus [Mon, 27 Jan 2025 15:48:58 +0000 (16:48 +0100)] 
s390: Do not omit vector index register 0 in disassembly

Vector index registers are currently only used in the VRV instruction
format.  Unlike general purpose index registers an operand value of
zero (e.g. %v0, 0, or omitted) does not imply a zero value:

"For VRV format instructions, a vector element is used in the formation
of the intermediate value.  This vector element is an unsigned binary
integer value that is added to the base address and 12-bit displacement
to form a 64-bit intermediate sum.  The vector element is designated by
a vector register and an element index.  A zero V field accesses the
element in vector register zero and does not imply a zero value." [1]

Therefore do not omit vector index register 0 in disassembly, that is
disassemble D(VX,B) with VX=0 as D(VX,B) instead of D(B).  Also do not
disassemble index register 0 as "0", that is disassemble D(VX,B) with
VX=0 as D(%v0,B) instead of D(0,B).  Note that a base register 0 still
still gets disassembled as "0", that is D(VX,B) with B=0 disassembles
into D(VX,0).

[1]: IBM z/Architecture Principles of Operation, SA22-7832-13, IBM z16,
     https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf

opcodes/
* s390-dis.c (s390_print_insn_with_opcode): Do not omit vector
index register 0 in disassembly.  Disassemble it as %v0.

gas/testsuite/
* gas/s390/zarch-base-index-0.d (vgef): Expect vector index
register 0 in disassembly.
* gas/s390/zarch-omitted-base-index.d (vgef): Likewise.

Suggested-by: Florian Krohm <flo2030@eich-krohm.de>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 months agos390: Additional tests for omitted base register operands
Jens Remus [Mon, 27 Jan 2025 15:48:58 +0000 (16:48 +0100)] 
s390: Additional tests for omitted base register operands

This complements commit aacf780bca29 ("s390: Allow to explicitly omit
base register operand in assembly").

gas/testsuite/
* gas/s390/zarch-warn-areg-zero.l: Add tests for omitted base
register operands.
* gas/s390/zarch-warn-areg-zero.s: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 months agos390: Generate .eh_frame unwind information for .plt section
Jens Remus [Mon, 27 Jan 2025 15:47:10 +0000 (16:47 +0100)] 
s390: Generate .eh_frame unwind information for .plt section

Enable unwinding using .eh_frame information through PLT entries.  Based
on x86-64.

This enhances stack traces if the instruction pointer is in a PLT entry.
For instance perf call graphs, when using --call-graph=dwarf, and Glibc
backtraces, when using backtrace() e.g. from a signal handler.
Note that GDB could already unwind through PLT entries using its s390-
specific prologue unwinder.

Furthermore this lays the foundation to generate SFrame information for
the PLT section in the future.

bfd/
* elf64-s390.c: Include dwarf2.h.
(PLT_CIE_SIZE, PLT_FDE_SIZE,
PLT_FDE_START_OFFSET, PLT_FDE_LEN_OFFSET,
elf_s390x_eh_frame_plt): New .eh_frame template for .plt
section.
(elf_s390_link_hash_table): Add plt_eh_frame field.
(elf_s390_create_dynamic_sections): New s390-specific wrapper
around _bfd_elf_create_dynamic_sections.  Create .eh_frame
section for .plt section.
(elf_backend_create_dynamic_sections): Register s390-specific
elf_s390_create_dynamic_sections.
(elf_s390_late_size_sections): Fill in .eh_frame section for
.plt section.  Write .plt section size into .eh_frame FDE
covering .plt section.
(elf_s390_finish_dynamic_sections): Write .plt section start
into .eh_frame FDE covering .plt section.  Call
_bfd_elf_write_section_eh_frame on on htab->plt_eh_frame
section.

ld/
* NEWS: Add news entry.
* emulparams/elf64_s390.sh: Include plt_unwind.sh.

ld/testsuite/
* ld-s390/plt_64-1_eh.wf: New PLT .eh_frame generation test.
* ld-s390/s390.exp: Link some existing test cases with
--no-ld-generated-unwind-info so that they do not fail.  Run
new PLT .eh_frame generation test.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 months agos390: Add basic PLT generation tests
Jens Remus [Mon, 27 Jan 2025 15:47:10 +0000 (16:47 +0100)] 
s390: Add basic PLT generation tests

ld/testsuite/
* ld-s390/plt_31_non-pic-1.pd: New non-PIC/PIE PLT generation
test for 31-bit.
* ld-s390/plt_31_pic-1.pd: New PIC/PIE PLT generation test for
31-bit.
* ld-s390/plt_31-1.wf: New PLT generation test for 31-bit.
* ld-s390/plt_64-1.pd: New PLT generation test for 64-bit.
* ld-s390/plt_64-1.wf: Likewise.
* ld-s390/plt-1.s: New PLT generation test for 31/64-bit.
* ld-s390/pltlib.s: Likewise.
* ld-s390/s390.exp: Run new PLT generation tests.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 months agos390: Fix linker s390 emulation option parsing
Jens Remus [Mon, 27 Jan 2025 15:47:10 +0000 (16:47 +0100)] 
s390: Fix linker s390 emulation option parsing

Append s390-specific emulation options to the shell variables instead of
replacing their contents.

ld/
* emultempl/s390.em (PARSE_AND_LIST_LONGOPTS,
PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Append to
emulation options instead of replacing them.

Fixes: b4cbbe8f7294 ("S/390: Add support for pgste marker")
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 months agos390: s390_machine leak
Jens Remus [Mon, 27 Jan 2025 15:43:39 +0000 (16:43 +0100)] 
s390: s390_machine leak

Simplify the .machine directive parsing logic, so that cpu_string is
always xstrdup'd and can therefore always be xfree'd before returning
to the caller.

This resolves the following memory leak reported by ASAN:

Direct leak of 13 byte(s) in 3 object(s) allocated from:
    #0 0x3ff8aafbb1d in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x2aa338861cf in xmalloc ../../libiberty/xmalloc.c:149
    #2 0x2aa338868ff in xstrdup ../../libiberty/xstrdup.c:34
    #3 0x2aa320253cb in s390_machine ../../gas/config/tc-s390.c:2172
    #4 0x2aa31fddc7b in read_a_source_file ../../gas/read.c:1293
    #5 0x2aa31f4f7bf in perform_an_assembly_pass ../../gas/as.c:1223
    #6 0x2aa31f4f7bf in main ../../gas/as.c:1436
    #7 0x3ff8a02be35 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #8 0x3ff8a02bf33 in __libc_start_main_impl ../csu/libc-start.c:360
    #9 0x2aa31f5758f  (/home/jremus/git/binutils/build-asan/gas/as-new+0x2d5758f) (BuildId: ...)

While at it add tests with double quoted .machine
"<cpu>[+<extension>...]" values.

gas/
* config/tc-s390.c (s390_machine): Simplify parsing and free
cpu_string before returning.

gas/testsuite/
* gas/s390/machine-parsing-1.l: Add tests with double quoted
values.
* gas/s390/machine-parsing-1.s: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 months agos390: s390_machinemode leak
Jens Remus [Mon, 27 Jan 2025 15:43:39 +0000 (16:43 +0100)] 
s390: s390_machinemode leak

This resolves the following memory leak reported by ASAN:

Direct leak of 17 byte(s) in 1 object(s) allocated from:
    #0 0x3ffb32fbb1d in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x2aa149861cf in xmalloc ../../libiberty/xmalloc.c:149
    #2 0x2aa149868ff in xstrdup ../../libiberty/xstrdup.c:34
    #3 0x2aa1312391f in s390_machinemode ../../gas/config/tc-s390.c:2241
    #4 0x2aa130ddc7b in read_a_source_file ../../gas/read.c:1293
    #5 0x2aa1304f7bf in perform_an_assembly_pass ../../gas/as.c:1223
    #6 0x2aa1304f7bf in main ../../gas/as.c:1436
    #7 0x3ffb282be35 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #8 0x3ffb282bf33 in __libc_start_main_impl ../csu/libc-start.c:360
    #9 0x2aa1305758f  (/home/jremus/git/binutils/build-asan/gas/as-new+0x2d5758f) (BuildId: ...)

gas/
* config/tc-s390.c (s390_machinemode): Free mode_string before
returning.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 months ago[gdb/build] Fix build with gcc 7.5.0
Tom de Vries [Mon, 27 Jan 2025 15:38:32 +0000 (16:38 +0100)] 
[gdb/build] Fix build with gcc 7.5.0

When building gdb with gcc 7.5.0, I run into:
...
gdb/dwarf2/cooked-index.c: In lambda function:
gdb/dwarf2/cooked-index.c:104:5: error: \
  the value of ‘_sch_tolower’ is not usable in a constant expression
     };
     ^
In file included from gdbsupport/gdb-safe-ctype.h:47:0,
                 from gdb/dwarf2/cooked-index.c:34:
include/safe-ctype.h:111:29: note: ‘_sch_tolower’ was not declared ‘constexpr’
 extern const unsigned char  _sch_tolower[256];
                             ^~~~~~~~~~~~
...

This does not happen with gcc 8.2.1.

Fix this by dropping the constexpr on lambda function munge in
cooked_index_entry::compare for gcc 7.

Tested by completing the build on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
4 months ago[gdb/doc] Use more lower-case in @sc in the documentation
Tom de Vries [Mon, 27 Jan 2025 11:39:56 +0000 (12:39 +0100)] 
[gdb/doc] Use more lower-case in @sc in the documentation

When building gdb with an older makeinfo (4.13), I run into:
...
gdb/doc/gdb.texinfo:49064: warning: @sc argument all uppercase, thus no effect.
...

Using a grep, I found one more instance:
...
$ grep @sc gdb/doc/*.tex* | egrep -v  '@sc{[^A-Z]*}'
gdb/doc/gdb.texinfo:\
Bit 1 (@sc{ZA}) shows whether the @code{ZA} register state is active (in use) or
gdb/doc/python.texi:\
corresponding @sc{GDB/MI} command's output.  Refer to the
...

Fix this by using lowercase letters in the @sc argument, similar to how that
was done in commit c96452ad168 ("Use lower-case in @sc in the documentation").

Tested by rebuilding the documentation.

4 months ago[gdb/doc] Fix qIsAddressTagged anchor
Tom de Vries [Mon, 27 Jan 2025 10:22:12 +0000 (11:22 +0100)] 
[gdb/doc] Fix qIsAddressTagged anchor

When building gdb with an older makeinfo (4.13), I run into:
...
gdb/doc/gdb.texinfo:44159: @anchor expected braces.
gdb/doc/gdb.texinfo:44159: ` {qIsAddressTagged}
...

This is related to this line:
...
@anchor {qIsAddressTagged}
...

Fix this by removing the space before the left brace.

Tested by rebuilding the documentation.

4 months ago[gdb/doc] Fix gdb.unwinder docs
Tom de Vries [Mon, 27 Jan 2025 09:33:28 +0000 (10:33 +0100)] 
[gdb/doc] Fix gdb.unwinder docs

When building gdb with an older makeinfo (4.13), I run into:
...
gdb/doc/python.texi:3015: warning: `(' follows defined name \
  `gdb.unwinder.Unwinder.__init__' instead of whitespace.
gdb/doc/python.texi:3041: warning: `(' follows defined name \
  `gdb.unwinder.FrameId.__init__' instead of whitespace.
...

The warnings are related to these two lines:
...
@defun gdb.unwinder.Unwinder.__init__(name)
  ...
@defun gdb.unwinder.FrameId.__init__(sp, pc, special = @code{None})
...

Indeed, when checking the command and variable index, we can see that it
contains an incorrect entry:
...
  gdb.unwinder.FrameId.__init__(sp,:          Unwinding Frames in Python
...

Fix this by adding a space before the left parenthesis.

Tested by rebuilding the documentation and checking the command and variable
index.

4 months agoFix some broken links in docs and comments
Yury Khrustalev [Thu, 23 Jan 2025 15:24:31 +0000 (15:24 +0000)] 
Fix some broken links in docs and comments

Reviewed-By Richard Earnshaw <richard.earnshaw@arm.com>

4 months agoExclude libpthread from automatic export generation
Christopher Wellons [Sat, 25 Jan 2025 19:45:20 +0000 (14:45 -0500)] 
Exclude libpthread from automatic export generation

Before this change, static linking libwinpthread, commonly distributed
as part of Mingw-w64, while using automatic symbol exports would export
the entire threading API, which is never wanted. This is always the case
when static linking libstdc++ built against libpthread.

4 months agoAutomatic date update in version.in
GDB Administrator [Mon, 27 Jan 2025 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 months agold-x86-64/pr19609-2d.d: Move "#pass" to the end
H.J. Lu [Sun, 26 Jan 2025 08:52:26 +0000 (16:52 +0800)] 
ld-x86-64/pr19609-2d.d: Move "#pass" to the end

* testsuite/ld-x86-64/pr19609-2d.d:  Move "#pass" to the end.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 months agoloongson buffer overflow
Alan Modra [Sun, 26 Jan 2025 02:42:45 +0000 (13:12 +1030)] 
loongson buffer overflow

bfd_elfNN_loongarch_set_data_segment_info can be called from the target
after_allocation function with a non-ELF hash table.  This is seen in
the ld-elf pr21884 testcase.  Fix the problem by first checking the
hash table type before writing to a loongarch_elf_hash_table field.

5 months agoPR32599, objcopy -I ihex: invalid operation
Alan Modra [Sun, 26 Jan 2025 04:24:15 +0000 (14:54 +1030)] 
PR32599, objcopy -I ihex: invalid operation

Restores ihex get_symtab_upper_bound to what it was prior to commit
394a3f4f8d.  This will enable objcopy of other no-sym formats too.

PR 32599
* libbfd-in.h (_bfd_nosymbols_get_symtab_upper_bound): Define
as _bfd_long_bfd_0.
* libbfd.h: Regenerate.

5 months agoAutomatic date update in version.in
GDB Administrator [Sun, 26 Jan 2025 00:00:16 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoRe: ld plugin bfd_make_readable leak
Alan Modra [Fri, 24 Jan 2025 23:45:58 +0000 (10:15 +1030)] 
Re: ld plugin bfd_make_readable leak

Commit 3097045a18a8 runs into an abort in objalloc_free_block when the
memory being bfd_release'd wasn't bfd_alloc'd.  Fix that.

* coffgen.c (_bfd_coff_free_cached_info): Don't release
raw_syments when obj_coff_keep_raw_syms.
* libcoff-in.h (obj_coff_keep_raw_syms): Define.
(struct coff_tdata): Add keep_raw_syms.
* peicode.h (pe_ILF_build_a_bfd): Set obj_coff_keep_raw_syms.
* libcoff.h: Regenerate.

5 months agoAutomatic date update in version.in
GDB Administrator [Sat, 25 Jan 2025 00:00:24 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoFix C++ template function matching in cooked index
Tom Tromey [Sat, 28 Dec 2024 21:10:56 +0000 (14:10 -0700)] 
Fix C++ template function matching in cooked index

In commit 64a97606 ("Support template lookups in
strncmp_iw_with_mode"), gdb was changed so that a command like "break
func<templ>" would match instantiations like "func<templ<int>>".

The new indexer does not support this and so this is a regression.
This went unnoticed because gdb.linespec.cpcompletion.exp puts all
these functions into the main file, and this CU is expanded early.

This patch fixes the bug by changing the cooked index entry comparison
function.  It also updates the test to fail without this fix.

Regression tested on x86-64 Fedora 40.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32482

5 months agogdb/riscv: Add command to switch between numeric & abi register names
Ciaran Woodward [Wed, 13 Sep 2023 11:32:55 +0000 (12:32 +0100)] 
gdb/riscv: Add command to switch between numeric & abi register names

In RISC-V, the general registers can be shown in their abi
form (e.g. sp, a0) or their numeric form (e.g. x2, x10).
Depending on context/preference, someone may prefer to
see one form over the other. The disassembler already
supports this configuration, which can be changed using
the 'set disassembler-options numeric' command.

This commit adds a new set/show command to change gdb's
preference: 'set riscv numeric-registers-names on/off'.

If on, 'info registers' and other situations will print
the numeric register names, rather than the abi versions.
The alias generation has been modified so that the abi
versions are still available for access if specifically
requested such as 'print $ra'. This was done by changing
the behaviour of the code which adds the aliases: all
register names will be added as aliases, even if the name
is the primary one.

There is also no functional downside to adding aliases
which are surplus-to-requirement, since they will be
ignored if there is a 'true' register with the same
name.

Approved-By: Andrew Burgess <aburgess@redhat.com>
5 months ago[gdb/tdep] Fix gdb.ada/O2_float_param.exp on s390x-linux
Tom de Vries [Fri, 24 Jan 2025 15:43:52 +0000 (16:43 +0100)] 
[gdb/tdep] Fix gdb.ada/O2_float_param.exp on s390x-linux

With test-case gdb.ada/O2_float_param.exp on s390x-linux, I get:
...
 (gdb) frame^M
 #0  callee.increment (val=99.0, val@entry=<error reading variable: \
   register has not been saved in frame>, msg=...) at callee.adb:19^M
 19         procedure Increment (Val : in out Float; Msg: String) is^M
 (gdb) FAIL: $exp: scenario=all: frame
...

The frame command calls read_frame_arg to get:
- the current value of val, and
- the value of val at function entry.

The first scenario succeeds, and the second scenario fails.

For context and contrast, let's also investigate the first scenario: getting
the current value of val.

Function parameter val:
...
 <2><b51>: Abbrev Number: 4 (DW_TAG_formal_parameter)
    <b52>   DW_AT_name        : val
    <b58>   DW_AT_type        : <0xb86>
    <b5c>   DW_AT_location    : 0xab (location list)
...
has location list:
...
    000000ab 0000000001002928 0000000001002967
      (DW_OP_reg16 (f0))
    000000be 0000000001002967 0000000001002968
      (DW_OP_reg24 (f8))
    000000d1 0000000001002968 0000000001002974
      (DW_OP_GNU_regval_type: 24 (f8) <0xb29>;
       DW_OP_GNU_const_type: <0xb29>  4 byte block: 3f 80 0 0 ; DW_OP_plus;
       DW_OP_stack_value)
    000000ef 0000000001002974 0000000001002982
      (DW_OP_GNU_entry_value: (DW_OP_GNU_regval_type: 16 (f0) <0xb29>);
       DW_OP_GNU_const_type: <0xb29>  4 byte block: 3f 80 0 0 ; DW_OP_plus;
       DW_OP_stack_value)
    0000010f <End of list>
...
and since we're stopped at address 0x1002928:
...
(gdb) print $pc
$1 = (access procedure) 0x1002928 <callee.increment>
...
we get the value from dwarf register 16.

The s390x ABI [1] specifies that dwarf register 16 maps onto 8-byte register
f0 or 16-byte register v0 (where f0 is part of v0), and in this case (because
the v0 register is available) s390_dwarf_reg_to_regnum maps it to v0.

Val is only 4 bytes:
...
(gdb) ptype val
type = <4-byte float>
...
and s390_value_from_register takes care to get the value from the correct part
of v0.

The value of v0 is found in the prologue cache, and the value of parameter val
is printed.

Now the second scenario: getting the value of val at function entry.

FWIW, since we're stopped at function entry, we could simply return the same
value, reading the same register, but that's currently not implemented [2].

Instead we start from the fact that val is in dwarf reg 16 at function entry,
and then use call site information:
...
 <4><cf7>: Abbrev Number: 13 (DW_TAG_GNU_call_site)
    <cf8>   DW_AT_low_pc      : 0x1002a46
    <d00>   DW_AT_abstract_origin: <0xdda>
 <5><d04>: Abbrev Number: 12 (DW_TAG_GNU_call_site_parameter)
    <d05>   DW_AT_location    : 1 byte block: 60        (DW_OP_reg16 (f0))
    <d07>   DW_AT_GNU_call_site_value: 3 byte block: f5 18 2d   \
              (DW_OP_GNU_regval_type: 24 (f8) <0xc42>)
 <5><d0b>: Abbrev Number: 12 (DW_TAG_GNU_call_site_parameter)
...
to conclude that the value we're looking for is in dwarf reg 24, which
s390_dwarf_reg_to_regnum maps to v8.

As before, s390_value_from_register takes care to get the value from the
correct part of v8.

However, v8 is not available in the prologue cache, and we take a different
path and end up in s390_unwind_pseudo_register, where v8 and similar
(regnum_is_vxr_full) is unhandled, and we get:
...
   return value::allocate_optimized_out (type);
...
which eventually causes the "error reading variable: register has not been
saved in frame".

Fix this by handling the regnum_is_vxr_full case in
s390_unwind_pseudo_register, similar to how that is done in
s390_pseudo_register_read.

Tested on s390x-linux.

This also fixes test-case gdb.base/savedregs.exp.

[1] https://github.com/IBM/s390x-abi
[2] https://sourceware.org/pipermail/gdb-patches/2024-September/211589.html