Commit Graph

122224 Commits

Author SHA1 Message Date
Keith Seitz
a19c78180e [PATCH] Add syscall tests when following/detaching from fork
breakpoints/13457 discusses issues with syscall catchpoints when
following forks, lamenting that there is no coverage for the
various permutations of `follow-fork-mode' and `detach-on-fork'.

This is an attempt to try and cover some of this ground. Unfortunately
the state of syscall support when detaching after the fork is
very, very inconsistent across various architectures. [I've tested
extensively Fedora/RHEL platforms.]

Right now, the only reliable platform to run tests on is x86_64/i?86
for the specific case where we do not detach from the fork. Consequently,
this patch limits testing to those architectures.

I have updated breakpoints/13457 with my findings on failures with the
detaching case.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=13457
Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-05-12 09:28:02 -07:00
Ezra Sitorus
f891d8e69d aarch64: Support for FEAT_RME_GPC3
FEAT_RME_GPC3 - RME Granule Protection Check 3 Extension - introduces
a method for defining a set of windows in the memory map for which
Granule Protection Checks are skipped, and instead applies a set of
default settings associated with the window.

This patch introduces the sysreg gpcbw_el3. Add -march=armv9.5-a to
access this sysreg since this feature is optional from armv9.5-a.
2025-05-12 17:07:53 +01:00
Ezra Sitorus
720e45f92a aarch64: Support for FEAT_OCCMO
FEAT_OCCMO - Outer Cacheable Cache Maintenance Operation - introduces
system instructions that provides software with a mechanism to publish
writes to the Outer cache level.
2025-05-12 16:54:36 +01:00
Patrick Monnerat
5cceef276f gdbsupport/event-loop: do not truncate poll timeouts to lower second
In update_wait_timeout function, microseconds were not taken into account
in poll timeout computation, resulting in 100% cpu time consumption in
the event loop while waiting for a sub-second timeout.

The bug has been introduced in commit c2c6d25.

This patch adds the microseconds converted to milliseconds in poll
timeout computation. Conversion by excess (ceil) is performed to
avoid the same problem with sub-millisecond timeouts too.
2025-05-12 17:47:35 +02:00
Andrew Burgess
4e16a47049 gdb: pass std::string from linux_find_memory_regions_full
Update linux_find_memory_region_ftype to take 'const std::string &'
instead of 'const char *', update the two functions which are passed
as callbacks to linux_find_memory_regions_full.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-05-12 16:27:23 +01:00
Andrew Burgess
9db56c74db gdb: remove unnecessary function declaration
There's no need to declare a function immediately before its
definition.  Lets not do that.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-05-12 16:27:09 +01:00
Andrew Burgess
ddce0e6e0c gdb: move extra checks into dump_note_entry_p
Now that dump_note_entry_p is always called (see previous commit), we
can move some of the checks out of linux_make_mappings_callback into
dump_note_entry_p.

The checks only exist in linux_make_mappings_callback because, before
the previous commit, we couldn't be sure that dump_note_entry_p would
be called or not, so linux_make_mappings_callback had to run its own
checks.

Now that dump_note_entry_p is always called we can rely on that
function to filter out which mappings should result in an NT_FILE
entry, and linux_make_mappings_callback can just create an entry for
everything it is passed.

As a result of this change I was able to remove the inode argument
from linux_make_mappings_callback and
linux_find_memory_regions_thunk.  The inode check has now moved to
dump_note_entry_p.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-05-12 16:24:36 +01:00
Andrew Burgess
dcbcfc9a52 gdb: always call should_dump_mapping_p during core file creation
This commit moves the logic for whether should_dump_mapping_p is
called out of linux_find_memory_regions_full and pushes it down into
the two callback functions that are used as the should_dump_mapping_p
callback; `dump_mapping_p` and `dump_note_entry_p`.

Older Linux kernels don't make the 'Anonymous' information available
in the smaps file, and currently, GDB handles this by not calling the
should_dump_mapping_p callback in linux_find_memory_regions_full,
instead the answer is hard-coded to true.

This is (maybe) fine for dump_mapping_p, but for dump_note_entry_p,
this choice makes little sense.  The dump_note_entry_p function
doesn't even use the anonymous mapping information.

I propose that the 'has_anonymous' check should be moved out of
linux_find_memory_regions_full, and pushed into dump_mapping_p.  Then
in dump_note_entry_p there will be no has_anonymous check; it just
isn't needed.

This allows linux_find_memory_regions_full to be simplified a little,
and will allow some additional clean ups in
linux_make_mappings_callback, which is the partner function to
dump_note_entry_p (see linux_make_mappings_corefile_notes), now that
we know dump_note_entry_p is always called.  This follow on clean up
will be done in a later commit in this series.

Looking at dump_mapping_p, I do wonder if the ::has_anonymous check
could be moved later in the function.  The first few checks in
dump_mapping_p don't rely on the anonymous information, so running
them might give better results.  However, the lack of the anonymous
information is only for older kernels, so testing any changes in this
area would likely require spinning up an older kernel, and as the
years pass, we likely care about this case less.  So for now I've left
the ::has_anonymous check as the first thing in dump_mapping_p as this
keeps the existing behaviour.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-05-12 16:23:36 +01:00
Andrew Burgess
3c60c38bc9 gdb: pass struct smaps_data to linux_dump_mapping_p_ftype
Simplify the argument passing in linux_find_memory_regions_full when
calling the should_dump_mapping_p callback.  Instead of pulling all
the components from the smaps_data object and passing them separately,
just pass the smaps_data object.

I think this change is justified on its own; the code seems cleaner,
and easier to read to my eye.  But additionally, in a later commit in
this series I want to pass smaps_data::has_anonymous to the
should_dump_mapping_p callback, which would mean adding yet another
argument, and I think the argument list is already long enough.
Changing the function now to pass the smaps_data object means that I
will already have the ::has_anonymous field available in the later
commit.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-05-12 16:23:11 +01:00
Andrew Burgess
6703aa6c7d gdb: use bool more in linux-tdep.c
Convert linux_dump_mapping_p_ftype to return a bool, and then update
everything that is needed to handle the fallout from this change.

There should be no user visible changes from this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-05-12 16:03:57 +01:00
Tankut Baris Aktemur
be437614a1 gdb: add '-stopped' and '-running' options to "info threads"
Add two options to "info threads": `-stopped` and `-running`.

The purpose of these options is to filter the output of the command.
The `-stopped` option means "print stopped threads only" and,
similarly, `-running` means "print the running threads only".  When
both options are provided by the user, the indication is that the user
wants the union.  That is, the output contains both stopped and
running threads.

Suppose we have an application with 5 threads, 2 of which have hit a
breakpoint.  The "info threads" command in the non-stop mode gives:

  (gdb) info threads
    Id   Target Id             Frame
  * 1    Thread 0x7ffff7d99740 (running)
    2    Thread 0x7ffff7d98700 something () at file.c:30
    3    Thread 0x7ffff7597700 (running)
    4    Thread 0x7ffff6d96700 something () at file.c:30
    5    Thread 0x7ffff6595700 (running)
  (gdb)

Using the "-stopped" flag, we get

  (gdb) info threads -stopped
    Id   Target Id             Frame
    2    Thread 0x7ffff7d98700 something () at file.c:30
    4    Thread 0x7ffff6d96700 something () at file.c:30
  (gdb)

Using the "-running" flag, we get

  (gdb) info threads -running
    Id   Target Id             Frame
  * 1    Thread 0x7ffff7d99740 (running)
    3    Thread 0x7ffff7597700 (running)
    5    Thread 0x7ffff6595700 (running)
  (gdb)

Using both flags prints all:

  (gdb) info threads -stopped -running
    Id   Target Id             Frame
  * 1    Thread 0x7ffff7d99740 (running)
    2    Thread 0x7ffff7d98700 something () at file.c:30
    3    Thread 0x7ffff7597700 (running)
    4    Thread 0x7ffff6d96700 something () at file.c:30
    5    Thread 0x7ffff6595700 (running)
  (gdb)

When combined with a thread ID, filtering applies to those threads that
are matched by the ID.

  (gdb) info threads 3
    Id   Target Id             Frame
    3    Thread 0x7ffff7597700 (running)
  (gdb) info threads -stopped 3
  No threads matched.
  (gdb)

Regression-tested on X86_64 Linux.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Approved-by: Pedro Alves <pedro@palves.net
2025-05-12 09:11:25 +02:00
Tankut Baris Aktemur
0ea1e5df96 gdb: update "info threads" output when no threads match the arguments
If "info threads" is provided with the thread ID argument but no such
threads matching the thread ID(s) are found, GDB prints

  No threads match '<ID...>'.

Update this output to the more generalized

  No threads matched.

The intention is that the next patch, and potentially future ones,
will extend the command with more filter/match arguments.  We cannot
customize the output to each such argument.  Hence, be more generic.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-by: Pedro Alves <pedro@palves.net
2025-05-12 09:11:19 +02:00
Tankut Baris Aktemur
32c39bab07 gdb: pass info_threads_opts to print_thread_info_1
The "info threads" command tracks its options in a struct named
'info_threads_opts', which currently has only one option.  Pass the
whole options object to helper functions, instead of passing
the option value individually.  This is a refactoring to make adding
more options easier.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Approved-by: Pedro Alves <pedro@palves.net
2025-05-12 09:11:10 +02:00
GDB Administrator
8dc4e62fc9 Automatic date update in version.in 2025-05-12 00:00:12 +00:00
Alan Modra
07cf922195 ubsan: size_inc_line_addr integer overflow
Fix a fuzzer testcase where a large positive line_delta causes signed
overflow when subtracting -5.  Signed overflow is perfectly OK here.
2025-05-11 22:52:32 +09:30
Alan Modra
f7b623952a msan: use of uninitialised data in get_cie_info
This completely bogus oss-fuzz x86 testcase results in a read from an
uninitialised (at the time check_eh_frame is called) part of an insn
frag:
 .section .debug_frame
 orl $1,x
 .long x
 .uleb128 0,x,0
x:

Fix the problem by verifying the assumption in get_cie_info that a CIE
starts at the beginning of .eh_frame or .debug_frame.  Or at least
exclude silliness involving instructions placed there.  That seems a
useful sanity check.  Also sanity check sizes of initial FDE fields.

Yes, this doesn't completely stop the problem since you could place an
insn with a relocated field later in the CIE.  If fuzzers find such a
testcase I'll ignore it.

	* ehopt.c (struct cie_info): Add "f" field.
	(get_cie_info): Return a bool.  Verify frag at start of chain
	is one with the CIE size found by check_eh_frame.
	(check_eh_frame): Save CIE start frag.  Only accept 4 or 8
	byte fields in state_saw_size, state_saw_cie_offset and
	state_saw_pc_begin.  Formatting.  Localise "fix" variable.
2025-05-11 22:51:14 +09:30
GDB Administrator
04b8dfff70 Automatic date update in version.in 2025-05-11 00:00:09 +00:00
Tiezhu Yang
7593801b17 gdb: LoongArch: Emulate floating-point branch instructions
Add bceqz and bcnez cases in loongarch_insn_is_cond_branch() and
loongarch_next_pc() to emulate floating-point branch instructions.

Here are the references:

https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#_bceqz_bcnez
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#table-table-of-instruction-encoding

Approved-by: Kevin Buettner <kevinb@redhat.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2025-05-10 21:25:52 +08:00
GDB Administrator
e264ce6ff0 Automatic date update in version.in 2025-05-10 00:00:07 +00:00
Peter Bergner
61a6e3c7bf MAINTAINERS: Update my email address
Update my email address and move up Surya's name as the main PPC contact.

Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
2025-05-09 18:01:15 -05:00
Tom Tromey
3fabf85b5c Fix two comments in cli-style.c
I noticed that a couple of new comments in cli-style.c mentioned the
wrong command name.  This patch fixes the comments.
2025-05-09 13:43:17 -06:00
Tom Tromey
c263ba026a Move "show style sources" documentation
I noticed that I had inadvertently put the "set style warning-prefix"
documentation between the paragraph for "set style sources" and the
paragraph for "show style sources".  This patch moves the latter up a
bit to clean this up.
2025-05-09 13:39:55 -06:00
Alice Carlotti
fd45b1c1aa aarch64: Mark predicate-as-counter pseudo instructions
Using explicit pseudo aliases is clearer and more consistent with other
instruction aliases.

This does not change behaviour.  For the non-alias instructions
(everything except mov) we already picked the first matching entry for
disassembly by default.  For mov we picked the last matching aliased
entry, which remained the original alias since do_misc_decoding doesn't
recognise OP_MOV_PN_PN.
2025-05-09 20:27:22 +01:00
Alice Carlotti
f20bd95af0 aarch64: Mark clearbhb as a pseudo instruction
This was an early name for the clrbhb hint instruction.  Some software
was written with the old name before it was renamed, so we support it
for assembly but should never use it in disassembly.

This patch has no functional change, because we already pick (by
default) the last matching alias in the opcode table, and clrbhb is
listed later than clearbhb.
2025-05-09 20:27:22 +01:00
Alice Carlotti
2068792484 aarch64: Merge dgh tests into system.d 2025-05-09 20:27:22 +01:00
Alice Carlotti
f1c037989a aarch64: Fix dgh disassembly 2025-05-09 20:27:22 +01:00
Alice Carlotti
51df25b00f aarch64: Mark SME mova aliases
This will only change behaviour during disassembly with -M no-aliases.
2025-05-09 20:27:22 +01:00
Alice Carlotti
a8d71f52d0 aarch64: Mark rev64 as a pseudo instruction
This is more natural than raising the priority of rev with F_P1, and
is functionally equivalent.
2025-05-09 20:27:22 +01:00
Alice Carlotti
db36339860 aarch64: Add new test original-missing-misc.d
This test file includes all the remaining untested instructions that
weren't part of a larger group of new or existing tests.
2025-05-09 20:27:21 +01:00
Alice Carlotti
e82ff7a581 aarch64: Add new test mov-wide.d
Only movn was previously untested.
2025-05-09 20:27:21 +01:00
Alice Carlotti
f495cce645 aarch64: Add new test exception-generation.d
svc and dcps* were already tested, but are included here as part of the
same encoding group.
2025-05-09 20:27:21 +01:00
Alice Carlotti
87d10eecf9 aarch64: Add new test conditional-compare.d
The register form of ccmp was already tested.
2025-05-09 20:27:21 +01:00
Alice Carlotti
a240a27f3a aarch64: Add new test branch-cond-pseudos.d
beq, bne, bcs and bcc were already tested, and bge and ble are also used
in scfi tests.
2025-05-09 20:27:21 +01:00
Alice Carlotti
37c162f51a aarch64: Add new test ldst-unpriv.d
All instructions were previously untested.
2025-05-09 20:27:21 +01:00
Alice Carlotti
a56def47ec aarch64: Add new test ldst-extend-general.d
All instructions were previously untested.
2025-05-09 20:27:21 +01:00
Alice Carlotti
c7fa4b95bb aarch64: Add new test dp-general-two-source.d
lsl was already tested but is included here as part of the same encoding
group.
2025-05-09 20:27:21 +01:00
Alice Carlotti
0d0437c738 aarch64: Add new test dp-general-one-source.d
rev16 and the 64-bit rev/rev64 instructions were already tested, but are
included here as part of the same encoding group.
2025-05-09 20:27:21 +01:00
Alice Carlotti
7e5de6cc92 aarch64: Add new test addsub-carry.d
All instructions were previously untested.
2025-05-09 20:27:20 +01:00
Alice Carlotti
4b80ebc02f aarch64: Add new test advsimd-scalar-doubling-mul.d
All instructions were previously untested.
2025-05-09 20:27:20 +01:00
Alice Carlotti
0a5c7a15d5 aarch64: Add new test advsimd-scalar-two-reg-misc.d
sqabs, sqneg, abs and neg were already tested, but are included here as
part of the same encoding group.
2025-05-09 20:27:20 +01:00
Alice Carlotti
c9b4c14636 aarch64: Add new test advsimd-scalar-shift-immediate.d
All instructions were previously untested.
2025-05-09 20:27:20 +01:00
Alice Carlotti
20a594d430 aarch64: Add new test advsimd-scalar-three-same.d
All instructions were previously untested.
2025-05-09 20:27:20 +01:00
Alice Carlotti
6fb41cbeeb aarch64: Add new test advsimd-copy.d
Only smov and the second dup variant were previously untested.  However,
the only test for umov was a disassembly test with -M no-aliases, and
the first dup variant was only tested in assembly in diagnostic.d with
the non-architectural syntax `dup v0.2d, v1.2d[0]`.
2025-05-09 20:27:20 +01:00
Alice Carlotti
5ec5c4e0f4 aarch64: Add new test advsimd-permute.d
All instructions were previously untested.
2025-05-09 20:27:20 +01:00
Alice Carlotti
42ebdfe15d aarch64: Add new test advsimd-modified-immediate.d
All instructions (7 opcode table entries) were previously untested.
2025-05-09 20:27:20 +01:00
Alice Carlotti
1e4e46b650 aarch64: Add new test advsimd-two-reg-misc-hilo.d
All instructions were previously untested.
2025-05-09 20:27:20 +01:00
Alice Carlotti
1bd53f5409 aarch64: Add new test advsimd-two-reg-misc.d
sqabs, abs, not, mvn, sqneg and neg were already tested, and cmeq was
already assembled in an error test (sve-reg-diagnostic.d), but they are
all included here as part of the same encoding group.
2025-05-09 20:27:19 +01:00
Alice Carlotti
75fb645880 aarch64: Add new test advsimd-mul-element.d
All instructions were previously untested.
2025-05-09 20:27:19 +01:00
Alice Carlotti
60d6304505 aarch64: Add new test advsimd-widening-narrowing.d
All instructions were previously untested.
2025-05-09 20:27:19 +01:00
Alice Carlotti
9c4a56f1db aarch64: Add new test advsimd-three-same.d
All instructions except orr/mov were previously untested.
2025-05-09 20:27:19 +01:00