Commit Graph

118857 Commits

Author SHA1 Message Date
Cui, Lili
3a8ecbdade x86: Split REX/REX2 old registers judgment.
Split "REX/REX2 old register checking" and "add empty rex prefix"
into two separate branches.

gas/ChangeLog:

        * config/tc-i386.c (establish_rex): Split the judgments.
2024-05-22 09:18:38 +08:00
GDB Administrator
92f59183ab Automatic date update in version.in 2024-05-22 00:00:12 +00:00
Indu Bhagat
002ccda0ef gas: ginsn: remove unnecessary buffer allocation and free
A previous commit 80ec235 fixed the memory leaks, but brought to light
that the code should ideally make consistent use of snprintf and not
allocate/free more buffers than necessary.

gas/
	* ginsn.c (ginsn_dst_print): Use snprintf consistently.
2024-05-21 12:59:55 -07:00
Srinath Parvathaneni
e63b1d5950 aarch64: Fix the hyphenated disassembly comment.
This patch fixes the following comment.

-  /* The hyphenated form is preferred for disassembly if there are
-     more than two registers in the list, and the register numbers
      are monotonically increasing in increments of one.  */

+  /* The hyphenated form is preferred for disassembly if there is
+     more than one register in the list, and the register numbers
      are monotonically increasing in increments of one.  */
2024-05-21 14:59:10 +01:00
Tom Tromey
f56e1c8c86 Clarify documentation for pretty_printer.child
An Ada pretty-printer had a bug where its 'child' method returned a
gdb.Value rather than a tuple.  Kévin suggested that the documentation
for this method could be improved to clarify this.

Reviewed-By: Kévin Le Gouguec <legouguec@adacore.com>
Approved-By: Eli Zaretskii <eliz@gnu.org>
2024-05-21 06:59:57 -06:00
Jan Beulich
c924b84f20 gas: drop remnants of ia64-*-aix*
With BFD not supporting that target anymore, GAS can't possibly support
it either.
2024-05-21 13:43:08 +02:00
Jan Beulich
b3fcf65991 ld: silence makeinfo warnings
Older tool versions (4.12 in my case) demand . or , after @xref{};
arrange for this to be the case.
2024-05-21 13:42:25 +02:00
Nick Alcock
6f0fe858b8
include, libctf: improve documentation
Some review comments came in after I pushed the last lot of ctf-api.h
comment improvements.  They were good, so I've incorporated them.
Mostly: better _next iterator usage info, better info on ctf_*open
functions, and better info on ctf_type_aname and ctf_type_name_raw.

include/
	* ctf-api.h: improve documentation.
2024-05-21 11:15:19 +01:00
GDB Administrator
05887e360a Automatic date update in version.in 2024-05-21 00:00:25 +00:00
Kévin Le Gouguec
752e03a7c1 gdb: Fix Windows build after #include shuffle
Without this patch, the build chokes on:

    ../../src/gdb/windows-nat.c:384:21: error: field 'm_debug_event_pending' has incomplete type 'std::atomic<bool>'
      384 |   std::atomic<bool> m_debug_event_pending { false };
          |                     ^~~~~~~~~~~~~~~~~~~~~
    In file included from […gcc tree…]/include/c++/13.2.1/bits/shared_ptr_atomic.h:33,
                     from […gcc tree…]/include/c++/13.2.1/memory:81,
                     from ../../src/gdb/../gdbsupport/gdb_unique_ptr.h:23,
                     from ../../src/gdb/../gdbsupport/common-utils.h:26,
                     from ../../src/gdb/../gdbsupport/common-defs.h:199,
                     from ./../../src/gdb/defs.h:26,
                     from <command-line>:
    […gcc tree…]/include/c++/13.2.1/bits/atomic_base.h:174:12: note: declaration of 'struct std::atomic<bool>'
      174 |     struct atomic;
          |            ^~~~~~
    make.exe[2]: *** [Makefile:1947: windows-nat.o] Error 1

Presumably windows-nat.c relied on objfiles.h including <atomic>,
which was undone in 2024-05-16 "gdb: remove unused includes in
objfiles.{c,h}" (f617661c11).
2024-05-20 18:47:33 +02:00
Luca Boccassi
762910fbd1 readelf: add pretty printing for FDO Dlopen Metadata note 2024-05-20 16:47:00 +01:00
Nick Clifton
4af0542142 Add extra files found in etc/ sub-directory to ETC_SUPPORT in src-release.sh
PR 31726
2024-05-20 16:12:53 +01:00
Tom de Vries
9839849c0c [gdb/testsuite] Fix can_spawn_for_attach_1 consistency check
When running test-case gdb.testsuite/gdb-caching-proc-consistency.exp with
target board native-gdbserver, we run into:
...
(gdb) ERROR: tcl error sourcing gdb.testsuite/gdb-caching-proc-consistency.exp.
ERROR: gdbserver does not support attach 4827 without extended-remote
    while executing
"error "gdbserver does not support $command without extended-remote""
    (procedure "gdb_test_multiple" line 51)
    invoked from within
"gdb_test_multiple "attach $test_pid" "can spawn for attach" {
        -re -wrap "$attaching_re\r\n.*ptrace: Operation not permitted\\." {
            # Not permitte..."
    (procedure "gdb_real__can_spawn_for_attach_1" line 27)
    invoked from within
"gdb_real__can_spawn_for_attach_1"
...

The problem is that:
- can_spawn_for_attach_1 is a helper function for can_spawn_for_attach,
  designed to be called only from that function, and
- can_spawn_for_attach_1 is a gdb_caching_proc, and consequently
  test-case gdb.testsuite/gdb-caching-proc-consistency.exp calls
  can_spawn_for_attach_1 directly.

Fix this by copying the early-outs from can_spawn_for_attach to
can_spawn_for_attach_1.

Tested on x86_64-linux.

Reported-By: Simon Marchi <simark@simark.ca>
Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
2024-05-20 16:42:08 +02:00
Claudio Bantaloukas
e390d876ab aarch64: Add support for the fpmr system register 2024-05-20 15:18:10 +01:00
Georg-Johann Lay
e8c83191cc Include .rodata size in avr-objdump -P mem-usage.
PR 31687
2024-05-20 13:33:55 +01:00
Georg-Johann Lay
f65d4a2f81 Let avr-objdump show .note.gnu.avr.deviceinfo
PR 31704
2024-05-20 12:12:10 +01:00
Sung-hun Kim
3ce12d6d4a RISC-V: PR31733, Change initial CFI operation from DW_CFA_def_cfa_register to DW_CFA_def_cfa
The DWARF specification (especially, DWARF4 and 5 [1,2]) states that
DW_CFA_def_cfa_register cannot be used as the first CFI operation.
It said DW_CFA_def_cfa_register as follows:

  ... This operation is valid only if the current CFA rule is defined
  to use a register and offset.

So, DW_CFA_def_cfa_register can be used after that other definition
operation such as DW_CFA_def_cfa is called. However, the current gas
code emits DW_CFA_def_cfa_register as an initial CFI operation for RISCV.

In the libgcc, the unwinding function does not care about it, so it can
unwind the call stack. However, on the third party library such as
libunwindstack in Android, it causes a fatal error.

This patch changes the initial CFI operation to DW_CFA_def_cfa with
offset 0. It works as same as the previous one, but it does not have
any limitation so it satisfies the DWARF spec. This change resolves
the compatibility issue while preserving the original behaviour.

[1] DWARF4 specification, https://dwarfstd.org/doc/DWARF4.pdf
[2] DWARF5 specification, https://dwarfstd.org/doc/DWARF5.pdf

Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Nelson Chu <nelson@rivosinc.com>

gas/
	PR 31733
	config/tc-riscv.c (riscv_cfi_frame_initial_instructions): Use
	DW_CFA_def_cfa rather than DW_CFA_def_cfa_register.
2024-05-20 10:50:20 +08:00
GDB Administrator
fe9f9ff5a0 Automatic date update in version.in 2024-05-20 00:00:26 +00:00
GDB Administrator
84f7f89407 Automatic date update in version.in 2024-05-19 00:00:15 +00:00
Tom Tromey
ac38857074 Remove unnecessary block from execute_fn_to_ui_file
I noticed that execute_fn_to_ui_file has an extra, unnecessary block.
This patch removes it.
2024-05-18 11:00:10 -06:00
Vladimir Mezentsev
ee7af0e710 gprofng: add hardware counters for AMD Zen3
Historically, we have used several APIs (perfctr, libcpc, perf_event_open) for profiling.
For each hardware we have several tables of hardware counters.
Some information is duplicated in these tables.
Some of the information is no longer used.
I did not touch the existing hwc tables.
I added a new hwc table for an AMD Zen3 machine.

ChangeLog
2024-05-16  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/31123
	* common/core_pcbe.c (core_pcbe_get_events): Add new argument.
	* common/hwc_cpus.h: New constants for AMD hardware.
	* common/hwcdrv.c: Add new argument to hwcdrv_get_descriptions.
	Clean up the code.
	* common/hwcdrv.h: Likewise.
	* common/hwcfuncs.c (hwcdrv_get_descriptions): Add new argument.
	* common/hwctable.c: Add the hwc table for AMD Zen3.
	* src/hwc_amd_zen3.h: New file.
	* common/opteron_pcbe.c: Add new argument to opt_pcbe_get_events.
	* src/collctrl.cc: Remove unused variable.
	* src/collctrl.h: Likewise.
2024-05-17 18:28:05 -07:00
Vladimir Mezentsev
663741df74 gprofng: remove old interface with libcpc
interface with libcpc was used on Solaris.
gprofng doesn't support profiling on Solaris.
I removed this old code and other unused macros and variables.

gprofng/ChangeLog
2024-04-29  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/31123
	* common/hwcdrv.c: remove old interface with libcpc.
	* common/hwcdrv.h: Likewise.
	* common/hwcentry.h: Likewise.
	* common/hwcfuncs.c: Likewise.
	* common/hwcfuncs.h: Likewise.
	* common/hwctable.c: Likewise.
	* src/Dbe.cc: Likewise.
	* src/collctrl.cc: Likewise.
2024-05-17 18:28:03 -07:00
GDB Administrator
f74ba96bb0 Automatic date update in version.in 2024-05-18 00:00:20 +00:00
Indu Bhagat
7922c42688 bfd: sframe: minor code adjustments and fix typos
bfd/
	* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Use local
	variable.
	(_bfd_x86_elf_size_dynamic_sections): Fix typos.
2024-05-17 11:24:28 -07:00
Tom Tromey
f2e4bd45d9 Remove gdb_stdtargerr
This patch removes gdb_stdtargerr.  There doesn't seem to be a need
for this -- it is always the same as stdtarg, and (I believe) has been
for many years.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-05-17 10:01:13 -06:00
Tom Tromey
5c51acfcce Don't allow new-ui to start the TUI
The TUI can't really work properly with new-ui, at least not as
currently written.  This patch changes new-ui to reject an attempt.
Attempting to make a DAP ui this way is also now rejected.

Regression tested on x86-64 Fedora 38.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29273
Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-05-17 09:39:41 -06:00
Tom Tromey
650a81d87b Inline some ui_out methods
I noticed a few ui_out methods that are just trivial wrappers.  This
patch moves these to ui-out.h, as it seems like they should be
inlineable.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-05-17 09:23:25 -06:00
Dmitry Neverov
1f8243f039 gdb/symtab: use symbol name matcher for all segments in a qualified name 2024-05-17 08:02:30 -06:00
Dmitry Neverov
1cd542c8e9 gdb/symtab: compute match_type outside the loop
It will be used for all segments in a qualified name,
not only the last one.

Approved-By: Tom Tromey <tom@tromey.com>
2024-05-17 08:02:30 -06:00
Dmitry Neverov
5d0e164203 gdb/symtab: reuse last segment lookup name info by creating it outside the loop 2024-05-17 08:02:29 -06:00
Dmitry.Neverov
3a0fae3129 gdb/symtab: check name matches before expanding a CU
The added check fixes the case when an unqualified lookup
name without template arguments causes expansion of many CUs
which contain the name with template arguments.

This is similar to what dw2_expand_symtabs_matching_symbol does
before expanding the CU.

In the referenced issue the lookup name was wxObjectDataPtr and many
CUs had names like wxObjectDataPtr<wxBitmapBundleImpl>. This caused
their expansion and the lookup took around a minute. The added check
helps to avoid the expansion and makes the symbol lookup to return in
a second or so.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30520
2024-05-17 08:02:29 -06:00
Nick Alcock
9ea82bfdd6
include, libctf: add a bunch of documentation to ctf-api.h
Hopefully this library is no longer quite so much a "you have to look
in the source to understand anything" library.

No semantic changes, though some functions have been moved around for
clarity.

include/
	ctf-api.h: Add comments.
2024-05-17 12:58:18 +01:00
Nick Alcock
37ed36fc8b
libctf: fix leak of entire dict when dict opening fails
Ever since commit 1fa7a0c24e ("libctf: sort out potential refcount
loops") ctf_dict_close has only freed anything if the refcount on entry
to the function is precisely 1.  >1 obviously just decrements the
refcount, but the linker machinery can sometimes cause freeing to recurse
from a dict to another dict and then back to the first dict again, so
we interpret a refcount of 0 as an indication that this is a recursive call
and we should just return, because a caller is already freeing this dict.

Unfortunately there is one situation in which this is not true: the bad:
codepath in ctf_bufopen entered when opening fails.  Because the refcount is
bumped only at the very end of ctf_bufopen, any failure causes
ctf_dict_close to be entered with a refcount of zero, and it frees nothing
and we leak the entire dict.

The solution is to bump the refcount to 1 right before freeing... but this
codepath is clearly delicate enough that we need to properly validate it,
so we add a test that uses malloc interposition to count allocations and
frees, creates a dict, writes it out, intentionally corrupts it (by setting
a bunch of bytes after the header to a value high enough that it is
definitely not a valid CTF type kind), then tries to open it again and
counts the malloc/free pairs to make sure they're matched.  (Test run only
on *-linux-gnu, because malloc interposition is not a thing you can rely
upon working everywhere, and this test is not arch-dependent so if it
passes on one arch it can be assumed to pass on all of them.)

libctf/
	* ctf-open.c (ctf_bufopen): Bump the refcount on failure.
	* testsuite/libctf-regression/open-error-free.*: New test.
2024-05-17 12:58:18 +01:00
Nick Alcock
8c59ec7006
libctf: test: add wrapper
This .lk option lets you run the lookup program via a wrapper executable.
For example, to run under valgrind and check for leaks (albeit noisily
because of the libtool shell script wrapper):

libctf/
	* testsuite/lib/ctf-lib.exp (run_lookup_test): Add wrapper.
2024-05-17 12:58:18 +01:00
Nick Alcock
e449709833
libctf: test: add host
This .lk option lets you execute particular tests only on specific host
architectures.

libctf/
	* testsuite/lib/ctf-lib.exp (run_lookup_test): Add host.
2024-05-17 12:58:18 +01:00
Nick Alcock
26f0f80b6f
libctf: test: add lookup_link
This .lk option lets you link the lookup program with extra libraries
in addition to -lctf.

libctf/
	* testsuite/lib/ctf-lib.exp (run_lookup_test): Add lookup_link.
2024-05-17 12:58:18 +01:00
Nick Alcock
2dd3fd0de4
libctf: ctf_archive_iter: fix tiny leak
If iteration fails because opening a dict has failed, ctf_archive_next does
not destroy the iterator, so the caller can keep going and try to open other
dicts further into the archive.  ctf_archive_iter just returns, though, so
it should free the iterator rather than leaking it.

libctf/
	* ctf-archive.c (ctf_archive_iter): Don't leak the iterator on
	failure.
2024-05-17 12:58:17 +01:00
Nick Alcock
61914bb699
libctf: failure to open parent dicts that exist should be an error
CTF archive member opening (via ctf_arc_open_by_name, ctf_archive_iter, et
al) attempts to be helpful and auto-open and import any needed parent dict
in the same archive.  But if this fails, the error is not reported but
simply discarded, and you silently get back a dict with no parent, that
*you* suddenly have to remember to import.

This is not helpful behaviour: if the parent is corrupted or we run out of
memory or something, the caller is going to want to know!  Split it in two:
if the dict cites a parent that doesn't exist at all (a lot of historic
dicts name "PARENT" as their parent, even when they're not even children, or
perhaps the parent dict is stored separately and you plan to manually
associate it), we skip it as now, but if the import fails with an actual
error other than ECTF_ARNNAME, return the error and fail the open.

libctf/
	* ctf-archive.c (ctf_arc_import_parent):  Return failure if
        parent opening fails for reasons other thnn nonexistence.
	(ctf_dict_open_sections): Adjust.
2024-05-17 12:58:17 +01:00
Nick Alcock
7bc376bb97
libctf: typos
Some functions were renamed without the comments catching up.

libctf/
	* ctf-open.c (upgrade_types_v1): Fix comment typos.
2024-05-17 12:58:17 +01:00
Jan Beulich
44fc9616c2 aarch64: correct SVE2.1 ld2q (scalar plus scalar)
It's opcode was wrong, as was e.g. easily visible from the inappropriate
testcase expectation.
2024-05-17 10:52:53 +02:00
Jan Beulich
132a0b0d77 aarch64: correct SVE2.1 ld{3,4}q / st{3,4}q (scalar plus immediate)
Like their byte, half, word, and doubleword counterparts their
immediates are multiples of 3 / 4 respectively.
2024-05-17 10:52:36 +02:00
mengqinggang
de203ed568 LoongArch: gas: Adjust DWARF CIE alignment factors
Set DWARF2_CIE_DATA_ALIGNMENT (data alignment factors) to -8.
It helps to save space.

Data Alignment Factor
A signed LEB128 encoded value that is factored out of all offset
instructions that are associated with this CIE or its FDEs. This value
shall be multiplied by the register offset argument of an offset
instruction to obtain the new offset value.
2024-05-17 15:38:29 +08:00
GDB Administrator
d7218dbb20 Automatic date update in version.in 2024-05-17 00:00:26 +00:00
Indu Bhagat
c6af2c1c2d gas: sframe: fix typo to use FP instead of BP
gas/
	* gen-sframe.c (output_sframe_internal): Use BP instead of FP.
2024-05-16 14:59:23 -07:00
Tom de Vries
e75d765e2b [gdb/testsuite] Add missing terminator in Dwarf::_macro_unit
When printing complaints with one of the execs from test-case
gdb.dwarf2/macro-source-path.exp, we run into:
...
$ gdb -q -batch \
    -iex "set complaints 100" \
    macro-source-path-clang14-dw4-absolute-cwd-32 \
    -ex "p main"
During symbol reading: debug info runs off end of .debug_macro section \
  [in module macro-source-path-clang14-dw4-absolute-cwd-32]
$1 = {int ()} 0x4004b7 <main>
...
and readelf complains more specifically:
...
Contents of the .debug_macro section:

  Offset:                      0
  Version:                     5
  Offset size:                 4
  Offset into .debug_line:     0xe3

 DW_MACRO_define - lineno : 0 macro : ONE 1
 DW_MACRO_define_strp - lineno : 0 macro : THREE 3
 DW_MACRO_start_file - lineno: 0 filenum: 1 filename: test.c
 DW_MACRO_define - lineno : 1 macro : TWO 2
 DW_MACRO_end_file
readelf: Error: .debug_macro section not zero terminated
...

Fix this by adding the missing terminator in Dwarf::_macro_unit.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-05-16 22:28:07 +02:00
Simon Marchi
f617661c11 gdb: remove unused includes in objfiles.{c,h}
Remove some includes reported as unused by clangd.

Change-Id: I7768232c28b9b86b0a03628a1d15dede2b30c76a
2024-05-16 15:54:37 -04:00
Ijaz, Abdul B
3396d197b7 gdb, testsuite: Handle unused compiler option fdiagnostics-color=never.
The 'univeral_compile_options' in gdb.exp file only verifies the support
of '-fdiagnostics-color=never' for the "C" source file.  So while running
tests with assembly source file (.s), many of them are not able to run
on icx/clang compilers because '-fdiagnostics-color=never' option is not
supported.  This problem is not seen for the ".S" assembly source files so
these files are not handled separately.  After this change, this function
is split into multiple functions to check the support for different type
of sources individually.

Before this change, in the case of clang and ICX compiler, this error is
shown for assembly source files (.s):

'''
icx -fdiagnostics-color=never -Wno-unknown-warning-option -fno-pie -c -O0 -o
amd64-entry-value0.o gdb/testsuite/gdb.arch/amd64-entry-value.s (timeout = 300)

icx: warning: argument unused during compilation: '-fdiagnostics-color=never'
[-Wunused-command-line-argument]

gdb compile failed, icx: warning: argument unused during compilation:
'-fdiagnostics-color=never' [-Wunused-command-line-argument]

UNTESTED: gdb.arch/amd64-entry-value.exp: failed to prepare
'''

Similarly this error is shown for the clang compiler:

'''
clang  -fdiagnostics-color=never -Wno-unknown-warning-option -fno-pie -c -O0
-o amd64-entry-value0.o gdb/testsuite/gdb.arch/amd64-entry-value.s

clang: warning: argument unused during compilation:
 '-fdiagnostics-color=never' [-Wunused-command-line-argument]
'''

Approved-By: Tom Tromey <tom@tromey.com>
2024-05-16 21:29:02 +02:00
Simon Marchi
108f22e4eb gdb: define type aliases for fork_inferior() callbacks
The `fork_inferior()` function accepts multiple callbacks, making its
signature a bit hard to read.  Define some type aliases to make it a bit
clearer.  Use function view for all, while at it.

Change-Id: Ide8d1fa533d0c5eaf3249860f8c0d339baa09bce
Approved-By: Tom Tromey <tom@tromey.com>
2024-05-16 15:09:48 -04:00
Simon Marchi
89457440e4 gdb: initialize packet_result::m_textual_err_msg
When building GDB with -O2 and --enable-ubsan, I get some random errors
in the packet_result self test:

  /home/smarchi/src/binutils-gdb/gdb/remote.c:161:7: runtime error: load of value 92, which is not a valid value for type 'bool'

This happens because packet_result::m_textual_err_msg is uninitialized
when using the second constructor.  When such a packet_result object
gets copied, an invalid value for m_textual_err_msg (a bool field) is
loaded, which triggers ubsan.

Avoid this by initializing m_textual_err_msg.

Change-Id: I3ce44816bb0bfc6e442067292f993e5c17301b85
Approved-By: Tom Tromey <tom@tromey.com>
2024-05-16 13:25:49 -04:00
Simon Marchi
e2e6bf023e gdb: remove unused include in infcmd.c
clangd reports this header as unused.

Change-Id: I7bf413f57b2840a52d83bd4f8b9415728bc0917b
2024-05-16 12:56:25 -04:00