Thomas Weißschuh [Thu, 21 Sep 2023 06:03:09 +0000 (08:03 +0200)]
ld: write resolved path to included file to dependency-file
In ldfile_open_command_file_1() name written to the dependency files is
the name as specified passed to the "INCLUDE" directive.
This is before include-path processing so the tracked dependency
location is most likely wrong.
Instead track the opened file at the point where the resolved path is
actually available, in try_open().
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
GDB Administrator [Thu, 21 Sep 2023 00:01:00 +0000 (00:01 +0000)]
Automatic date update in version.in
Tom Tromey [Wed, 20 Sep 2023 23:08:28 +0000 (17:08 -0600)]
Remove stray trailing "," from DAP breakpoint.py
The buildbot pointed out that the last DAP series I checked in had an
issue. Looking into it, it seems there is a stray trailing "," in
breakpoint.py. This patch removes it.
This seems to point out a test suite deficiency. I will look into
fixing that.
Tom Tromey [Wed, 20 Sep 2023 02:34:23 +0000 (20:34 -0600)]
Remove explanatory comments from includes
I noticed a comment by an include and remembered that I think these
don't really provide much value -- sometimes they are just editorial,
and sometimes they are obsolete. I think it's better to just remove
them. Tested by rebuilding.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Gregory Anders [Fri, 1 Sep 2023 21:02:20 +0000 (16:02 -0500)]
gdb/dap: only include sourceReference if file path does not exist
According to the DAP specification if the "sourceReference" field is
included in a Source object, then the DAP client _must_ make a "source"
request to the debugger to retrieve file contents, even if the Source
object also includes path information.
If the Source's path field is a valid path that the DAP client is able
to read from the filesystem, having to make another request to the
debugger to get the file contents is wasteful and leads to incorrect
results (DAP clients will try to get the contents from the server and
display those contents as a file with the name in "source.path", but
this will conflict with the _acutal_ existing file at "source.path").
Instead, only set "sourceReference" if the source file path does not
exist.
Approved-By: Tom Tromey <tom@tromey.com>
Gregory Anders [Fri, 1 Sep 2023 21:02:19 +0000 (16:02 -0500)]
gdb/dap: use breakpoint fullname to resolve source
If the breakpoint has a fullname, use that as the source path when
resolving the breakpoint source information. This is consistent with
other callers of make_source which also use "fullname" if it exists (see
e.g. DAPFrameDecorator which returns the symtab's fullname).
Approved-By: Tom Tromey <tom@tromey.com>
Gregory Anders [Fri, 1 Sep 2023 21:02:18 +0000 (16:02 -0500)]
gdb/dap: ignore unused keyword args in step_out
Some DAP clients may send additional parameters in the stepOut command
(e.g. "granularity") which are not used by GDB, but should nonetheless
be accepted without error.
Approved-By: Tom Tromey <tom@tromey.com>
Gregory Anders [Fri, 1 Sep 2023 21:02:17 +0000 (16:02 -0500)]
gdb/dap: check for breakpoint source before unpacking
Not all breakpoints have a source location. For example, a breakpoint
set on a raw address will have only the "address" field populated, but
"source" will be None, which leads to a RuntimeError when attempting to
unpack the filename and line number.
Before attempting to unpack the filename and line number from the
breakpoint, ensure that the source information is not None. Also
populate the source and line information separately from the
"instructionReference" field, so that breakpoints that include only an
address are still included.
Approved-By: Tom Tromey <tom@tromey.com>
Tom Tromey [Wed, 20 Sep 2023 16:43:04 +0000 (10:43 -0600)]
Run 'black' on printing.py
The buildbot pointed out that I neglected to re-run 'black' after
making some changes. This patch fixes the oversight.
Matthew "strager" Glazar [Sat, 28 Jan 2023 00:19:45 +0000 (16:19 -0800)]
gdb/tui: add 'set tui mouse-events off' to restore mouse selection
Rationale:
I use the mouse with my terminal to select and copy text. In gdb, I use
the mouse to select a function name to set a breakpoint, or a variable
name to print, for example.
When gdb is compiled with ncurses mouse support, gdb's TUI mode
intercepts mouse events. Left-clicking and dragging, which would
normally select text, seems to do nothing. This means I cannot select
text using my mouse anymore. This makes it harder to set breakpoints,
print variables, etc.
Solution:
I tried to fix this issue by editing the 'mousemask' call to only enable
buttons 4 and 5. However, this still caused my terminal (gnome-terminal)
to not allow text to be selected. The only way I could make it work is
by calling 'mousemask (0, NULL);'. But doing so disables the mouse code
entirely, which other people might want.
I therefore decided to make a setting in gdb called 'tui mouse-events'.
If enabled (the default), the behavior is as it is now: terminal mouse
events are given to gdb, disabling the terminal's default behavior.
If disabled (opt-in), the behavior is as it was before the year 2020:
terminal mouse events are not given to gdb, therefore the mouse can be
used to select and copy text.
Notes:
I am not attached to the setting name or its description. Feel free to
suggest better wording.
Testing:
I tested this change in gnome-terminal by performing the following steps
manually:
1. Run: gdb --args ./myprogram
2. Enable TUI: press ctrl-x ctrl-a
3. Click and drag text with the mouse. Observe no selection.
4. Input: set tui mouse-events off
5. Click and drag text with the mouse. Observe that selection works now.
6. Input: set tui mouse-events on.
7. Click and drag text with the mouse. Observe no selection.
Tom de Vries [Wed, 20 Sep 2023 14:05:55 +0000 (16:05 +0200)]
[gdb/symtab] Error out for .debug_types section in dwz file
There are two methods to factor out type information in a dwarf4 executable:
- use -fdebug-info-types to generate type units in a .debug_types section, and
- use dwz to create partial units.
The dwz method has an extra benefit: it also allows to factor out information
between executables into a newly created .dwz file, pointed to by a
.gnu_debugaltlink section.
There is nothing prohibiting a .gnu_debugaltlink file to contain a
.debug_types section.
It's just not generated by dwz or any other tool atm, and consequently gdb has
no support for it. Enhancement PR symtab/30838 is open about the lack of
support.
Make the current situation explicit by emitting a dwarf error:
...
(gdb) file struct-with-sig-2^M
Reading symbols from struct-with-sig-2...^M
Dwarf Error: .debug_types section not supported in dwz file^M
...
and add an assert in write_gdbindex:
...
+ /* See enhancement PR symtab/30838. */
+ gdb_assert (!(per_cu->is_dwz && per_cu->is_debug_types));
...
to clarify why we can use:
...
data_buf &cu_list = (per_cu->is_debug_types
? types_cu_list
: per_cu->is_dwz ? dwz_cu_list : objfile_cu_list);
...
The test-case is a modified copy from gdb.dwarf2/struct-with-sig.exp, so it
keeps the copyright years range.
Tested on x86_64-linux.
Tested-By: Guinevere Larsen <blarsen@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30838
Song Mengzhi [Tue, 19 Sep 2023 07:13:46 +0000 (07:13 +0000)]
PR30870, VMS_DEBUG compilation error
Introduced by
8169954446.
PR 30870
* vms-alpha.c (image_write): Remove extraneous parenthesis.
GDB Administrator [Wed, 20 Sep 2023 00:00:48 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Tue, 19 Sep 2023 00:20:57 +0000 (09:50 +0930)]
readelf.c 'ext' may be used uninitialized
* readelf.c (display_lto_symtab): Init ext.
Alan Modra [Tue, 19 Sep 2023 00:09:31 +0000 (09:39 +0930)]
elf-attrs.c memory allocation fail
Report errors rather than segfaulting.
bfd/
* elf-attrs.c (elf_new_obj_attr): Return NULL on bfd_alloc fail.
(bfd_elf_add_obj_attr_int): Handle NULL return from the above,
and propagate return to callers.
(elf_add_obj_attr_string, elf_add_obj_attr_int_string): Likewise.
(bfd_elf_add_obj_attr_string): Similarly.
(_bfd_elf_copy_obj_attributes): Report error on alloc fails.
(_bfd_elf_parse_attributes): Likewise.
* elf-bfd.h (bfd_elf_add_obj_attr_int): Update prototype.
(bfd_elf_add_obj_attr_string): Likewise.
(bfd_elf_add_obj_attr_int_string): Likewise.
gas/
* config/obj-elf.c (obj_elf_vendor_attribute): Report fatal
error on out of memory from bfd attribute functions.
* config/tc-arc.c (arc_set_attribute_int): Likewise.
(arc_set_attribute_string, arc_set_public_attributes): Likewise.
* config/tc-arm.c (aeabi_set_attribute_int): Likewise.
(aeabi_set_attribute_string): Likewise.
* config/tc-mips.c (mips_md_finish): Likewise.
* config/tc-msp430.c (msp430_md_finish): Likewise.
* config/tc-riscv.c (riscv_write_out_attrs): Likewise.
* config/tc-sparc.c (sparc_md_finish): Likewise.
* config/tc-tic6x.c (tic6x_set_attribute_int): Likewise.
* config/tc-csky.c (md_begin): Likewise.
(set_csky_attribute): Return ok status.
Tom Tromey [Tue, 5 Sep 2023 15:13:14 +0000 (09:13 -0600)]
Handle pointers and references correctly in DAP
A user pointed out that the current DAP variable code does not let the
client deference a pointer. Oops!
Fixing this oversight is simple enough -- adding a new no-op
pretty-printer for pointers and references is quite simple.
However, doing this naive caused a regession in scopes.exp, which
expected there to be no children of a 'const char *' variable. This
problem was fixed by the preceding patches in the series, which ensure
that a C type of this kind is recognized as a string.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30821
Tom Tromey [Tue, 5 Sep 2023 18:29:23 +0000 (12:29 -0600)]
Give a language to a type
This changes main_type to hold a language, and updates the debug
readers to set this field. This is done by adding the language to the
type-allocator object.
Note that the non-DWARF readers are changed on a "best effort" basis.
This patch also reimplements type::is_array_like to use the type's
language, and it adds a new type::is_string_like as well. This in
turn lets us change the Python implementation of these methods to
simply defer to the type.
Tom Tromey [Tue, 5 Sep 2023 19:08:29 +0000 (13:08 -0600)]
Add is_array_like and to_array to language_defn
This adds new is_array_like and to_array methods to language_defn.
This will be used in a subsequent patch that generalizes the new
Python array- and string-handling code.
Tom Tromey [Tue, 5 Sep 2023 18:54:40 +0000 (12:54 -0600)]
Regularize some DWARF type initialization
In one spot, it will be convenient for a subsequent patch if the CU is
passed to a type-creation helper function. In another spot, remove
the redundant 'objfile' parameter to another such function.
Tom Tromey [Tue, 5 Sep 2023 18:43:50 +0000 (12:43 -0600)]
Pass a type allocator to init_fixed_point_type
init_fixed_point_type currently takes an objfile and creates its own
type allocator. However, for a later patch it is more convenient if
this function accepts a type allocator. This patch makes this change.
Tom Tromey [Fri, 15 Sep 2023 18:22:47 +0000 (12:22 -0600)]
Use gdb::checked_static_cast for catchpoints
This replaces some casts to various kinds of catchpoint with
checked_static_cast.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Fri, 15 Sep 2023 18:19:57 +0000 (12:19 -0600)]
Use gdb::checked_static_cast for code_breakpoint
This replaces some casts to 'code_breakpoint *' with
checked_static_cast.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Fri, 15 Sep 2023 18:05:57 +0000 (12:05 -0600)]
Use gdb::checked_static_cast for tracepoints
This replaces some casts to 'tracepoint *' with checked_static_cast.
Some functions are changed to accept a 'tracepoint *' now, for better
type safety.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Fri, 15 Sep 2023 17:56:35 +0000 (11:56 -0600)]
Use gdb::checked_static_cast for watchpoints
This replaces some casts to 'watchpoint *' with checked_static_cast.
In one spot, an unnecessary block is also removed.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Mohamed Bouhaouel [Fri, 30 Jun 2023 08:10:15 +0000 (10:10 +0200)]
gdb, breakpoint: add a destructor to the watchpoint struct
Make sure to unlink the related breakpoint when the watchpoint instance
is deleted. This prevents having a wp-related breakpoint that is
linked to a NULL watchpoint (e.g. the watchpoint instance is being
deleted when the 'watch' command fails). With the below scenario,
having such a left out breakpoint will lead to a GDB hang, and this
is due to an infinite loop when deleting all inferior breakpoints.
Scenario:
(gdb) set can-use-hw-watchpoints 0
(gdb) awatch <SCOPE VAR>
Can't set read/access watchpoint when hardware watchpoints are disabled.
(gdb) rwatch <SCOPE VAR>
Can't set read/access watchpoint when hardware watchpoints are disabled.
(gdb) <continue the program until the end>
>> HANG <<
Signed-off-by: Mohamed Bouhaouel <mohamed.bouhaouel@intel.com>
Reviewed-by: Bruno Larsen <blarsen@redhat.com>
Guinevere Larsen [Tue, 19 Sep 2023 12:06:49 +0000 (14:06 +0200)]
gdb/cli: fixes to newly added "list ." command
After the series that added this command was pushed, Pedro mentioned
that the news description could easily be misinterpreted, as well as
some code and test improvements that should be made.
While fixing the test, I realized that code repetition wasn't
happening as it should, so I took care of that too.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
GDB Administrator [Tue, 19 Sep 2023 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Sat, 16 Sep 2023 21:00:13 +0000 (15:00 -0600)]
More type safety for symbol_search
This patch changes class symbol_search to store a block_enum rather
than an int.
Regression tested on x86-64 Fedora 38.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Tue, 5 Sep 2023 18:30:08 +0000 (12:30 -0600)]
Move val_prettyformat to valprint.h
I stumbled across an ancient FIXME comment that was easy to fix --
val_prettyformat does not need to be in defs.h, and is easily moved to
valprint.h, where (despite what the comment says) it belongs.
Tested by rebuilding.
Jacob Navia [Mon, 18 Sep 2023 11:03:58 +0000 (12:03 +0100)]
Fix: Use of uninitialized memory
* config/tc-riscv.c (riscv_ip_hardcode): Fully initialise the allocated riscv_opcode structure.
Simon Marchi [Mon, 18 Sep 2023 00:42:05 +0000 (20:42 -0400)]
gdb: remove unused free_actions declaration
This appears to be a leftover from a past change.
Change-Id: I8e747edbf291400e4f417f5c6875049479a1669a
GDB Administrator [Mon, 18 Sep 2023 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 17 Sep 2023 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Sat, 16 Sep 2023 02:10:53 +0000 (04:10 +0200)]
[gdb/symtab] Fix overly large gdb-index file check for 32-bit
Add a unit test which checks that write_gdb_index_1 will throw
an error when the size of the file would exceed the maximum value
capable of being represented by 'offset_type'.
The unit test fails on 32-bit systems due to wrapping overflow. Fix this by
changing the type of total_len in write_gdbindex_1 from size_t to uint64_t.
Tested on x86_64-linux.
Co-Authored-By: Kevin Buettner <kevinb@redhat.com>
Approved-by: Kevin Buettner <kevinb@redhat.com>
GDB Administrator [Sat, 16 Sep 2023 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Fri, 15 Sep 2023 16:25:04 +0000 (12:25 -0400)]
gdb: remove -Werror annotations from MAINTAINERS file
I don't think these are useful nowadays, since we now expect all code to
be -Werror clean (it's the default in development branches).
Change-Id: I8c3b86c70d683bd41344d27add0ac2627a474d20
Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Wed, 6 Sep 2023 13:41:45 +0000 (09:41 -0400)]
gdb/amdgpu: add precise-memory support
The amd-dbgapi library exposes a setting called "memory precision" for
AMD GPUs [1]. Here's a copy of the description of the setting:
The AMD GPU can overlap the execution of memory instructions with other
instructions. This can result in a wave stopping due to a memory violation
or hardware data watchpoint hit with a program counter beyond the
instruction that caused the wave to stop.
Some architectures allow the hardware to be configured to always wait for
memory operations to complete before continuing. This will result in the
wave stopping at the instruction immediately after the one that caused the
stop event. Enabling this mode can make execution of waves significantly
slower.
Expose this option through a new "amdgpu precise-memory" setting.
The precise memory setting is per inferior. The setting is transferred
from one inferior to another when using the clone-inferior command, or
when a new inferior is created following an exec or a fork.
It can be set before starting the inferior, in which case GDB will
attempt to apply what the user wants when attaching amd-dbgapi. If the
user has requested to enable precise memory, but it can't be enabled
(not all hardware supports it), GDB prints a warning.
If precise memory is disabled, GDB prints a warning when hitting a
memory exception (translated into GDB_SIGNAL_SEGV or GDB_SIGNAL_BUS),
saying that the stop location may not be precise.
Note that the precise memory setting also affects memory watchpoint
reporting, but the watchpoint support for AMD GPUs hasn't been
upstreamed to GDB yet. When we do upstream watchpoint support, GDB will
produce a similar warning message when stopping due to a watchpoint if
precise memory is disabled.
Add a handful of tests. Add a util proc
"hip_devices_support_precise_memory", which indicates if all devices
used for testing support that feature.
[1] https://github.com/ROCm-Developer-Tools/ROCdbgapi/blob/
687374258a27b5aab1309a7e8ded719e2f1ed3b1/include/amd-dbgapi.h.in#L6300-L6317
Change-Id: Ife1a99c0e960513da375ced8f8afaf8e47a61b3f
Approved-By: Lancelot Six <lancelot.six@amd.com>
Simon Marchi [Thu, 14 Sep 2023 15:09:46 +0000 (11:09 -0400)]
gdb/testsuite: add linux target check in allow_hipcc_tests
ROCm / HIP tests should only run on Linux for now, existing gdb.rocm
tests miss such a check. Add an "istarget linux" check in
allow_hipcc_tests.
Change-Id: I71f69e510a754f2fdadc32de53b923ebb9835ab5
Approved-By: Lancelot Six <lancelot.six@amd.com>
Simon Marchi [Thu, 13 Apr 2023 20:18:34 +0000 (16:18 -0400)]
gdb: add inferior_cloned observable
The following patch makes the amdgpu port transfer a property from the
original inferior to the new inferior when using the clone-inferior
command. Add the inferior_cloned observable to help with this.
Change-Id: Id845a799813ec49b1b7b2fcb97b07d0a1e5e2631
Approved-By: Tom Tromey <tom@tromey.com>
Tom Tromey [Fri, 15 Sep 2023 16:13:24 +0000 (10:13 -0600)]
Fix build failure with GCC 4.8
A user pointed out that the build failed with GCC 4.8. The problem
was that the form used by the std::hash specialization of ptid_t was
not accepted. This patch rewrites this code into a form that is
acceptable to the older compiler.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Laurent Morichetti [Thu, 7 Sep 2023 18:00:53 +0000 (11:00 -0700)]
gdb/amdgpu: Silence wave termination messages
After commit
9d7d58e7262, the amdgpu target started printing
"thread exited" messages when pruning waves that had terminated.
...
[AMDGPU Wave ?:?:?:2045 (?,?,?)/? exited]
[AMDGPU Wave ?:?:?:2046 (?,?,?)/? exited]
[AMDGPU Wave ?:?:?:2047 (?,?,?)/? exited]
[AMDGPU Wave ?:?:?:2048 (?,?,?)/? exited]
...
The issue was that before commit
9d7d58e7262, delete_thread was silent
by default due to a bug that the commit fixed.
Replaced the amdgpu target call to delete_thread with a call to
delete_thread_silent.
Change-Id: Ie5d5a4c5be851f092d2315b2afa6a36a30a05245
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Fri, 15 Sep 2023 15:56:18 +0000 (11:56 -0400)]
gdb: add Lancelot Six as maintainer of the AMD GPU port
Lancelot has accepted to take the role of maintainer for the AMD GPU
port. The AMD GPU port (amdgpu as I've written in the MAINTAINERS file)
is an umbrella term for everything needed to make this work: the amdgcn
arch, the amd-dbgapi target, solib-rocm, etc.
Thanks for accepting the role, and congratulations!
Change-Id: I4c898042fda49b45dcb0d54ca94731bb57287f71
Tom Tromey [Thu, 31 Aug 2023 13:33:34 +0000 (07:33 -0600)]
Rename split_style::DOT
This renames split_style::DOT, to avoid name clashes when building gdb
with an old version of Bison (2.3, the version available on macOS).
In particular the error looks like:
./split-name.h:34:3: error: expected identifier
DOT,
^
m2-exp.c:163:13: note: expanded from macro 'DOT'
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30286
Claudiu Zissulescu [Fri, 15 Sep 2023 09:57:22 +0000 (12:57 +0300)]
arc: Fix alignment of the TLS Translation Control Block
The R_ARC_TLS_LE_32 is defined as S + A + TLS_TBSS - TLS_REL, where
- S is the base address of the symbol in the memory
- A is the symbol addendum
- TLS_TBSS is the TLS Translation Control Block size (aligned)
- TLS_REL is the base of the TLS section
Given the next code snip:
__thread int data_var = 12;
__attribute__((__aligned__(128))) __thread int data_var_128 = 128;
__thread int bss_var;
__attribute__((__aligned__(256))) __thread int bss_var_256;
int __start(void)
{
return data_var + data_var_128 + bss_var + bss_var_256;
}
The current code returns different TLS_TBSS values for .tdata and
.tbss. This patch fixes this by using the linker provided tls_sec.
bfd/
* elf32-arc.c (TLS_REL): Clean up.
(TLS_TBSS): Use tls_sec alignment.
(arc_do_relocation): Check if we have valid tls_sec.
Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
Andrew Burgess [Fri, 8 Sep 2023 10:20:25 +0000 (11:20 +0100)]
gdb: small cleanup in symbol_file_add_with_addrs
While looking at how gdb::observers::new_objfile was used, I found
some code in symbol_file_add_with_addrs that I thought could be
improved.
Instead of:
if (condition)
{
...
return;
}
...
return;
Where some parts of '...' identical between the two branches. I think
it would be nicer if the duplication is removed, and we just use:
if (!condition)
...
to guard the one statement that should only happen when the condition
is not true.
There is one change in this commit though that is (possibly)
significant, there is a call to bfd_cache_close_all() that was only
present in the second block. After this commit we now call that
function for both paths.
The call to bfd_cache_close_all was added in commit:
commit
ce7d45220e4ed342d4a77fcd2f312e85e1100971
Date: Fri Jul 30 12:05:45 2004 +0000
with the purpose of ensuring that GDB doesn't hold the BFDs open
unnecessarily, thus preventing the files from being updated on some
hosts (e.g. Win32).
In the early exit case we previously didn't call bfd_cache_close_all,
with the result that GDB would continue to hold open some BFD objects
longer than needed.
After this commit, but calling bfd_cache_close_all for both paths this
problem is solved.
I'm not sure how this change could be tested, I don't believe there's
any GDB (maintenance) command that displays the BFD cache contents, so
we can't check the cache contents easily. Ideas are welcome though.
Approved-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Tue, 29 Aug 2023 13:48:56 +0000 (14:48 +0100)]
gdb: add some missing filename styling
Spotted a few places where we can add filename styling.
Approved-By: Tom Tromey <tom@tromey.com>
Jinyang He [Fri, 11 Aug 2023 08:10:40 +0000 (16:10 +0800)]
LoongArch: Enable gas sort relocs
The md_pre_output_hook creating fixup is asynchronous, causing relocs
may be out of order in .eh_frame. Define GAS_SORT_RELOCS so that reorder
relocs when write_relocs.
Reported-by: Rui Ueyama <rui314@gmail.com>
Jan Beulich [Fri, 15 Sep 2023 07:57:05 +0000 (09:57 +0200)]
x86: fold CpuLM and Cpu64
Now that CpuLM is used solely in cpu_arch_flags and cpu_arch[] while
Cpu64 is solely used in insn templates, they no longer need to be
treated different from other "ordinary" flags; the only "unusual" one
left if CpuNo64. Fold both, leaving just Cpu64.
Jan Beulich [Fri, 15 Sep 2023 07:56:33 +0000 (09:56 +0200)]
x86: don't play with cpu_arch_flags.cpu{,no}64
A total four places exists where we set the two bits from flag_code, but
these values are never used. The two bits are evaluated only when coming
from insn templates.
Drop these assignments. Also make obvious that cpu_flags_check_cpu64()
is only ever used against insn templates.
Jan Beulich [Fri, 15 Sep 2023 07:56:02 +0000 (09:56 +0200)]
x86: make code size vs CPU arch checking consistent
While update_code_flag() checks for LM / i386, set_cpu_arch() so far
didn't, allowing e.g. 64-bit code to be emitted after ".arch generic32".
Oddly enough a few of our testcases actually exhibit bad behavior (and
hence need minor adjustments).
Jan Beulich [Fri, 15 Sep 2023 07:55:34 +0000 (09:55 +0200)]
x86: re-order update_code_flag()
Do checks before updating state, and bail upon failure of either of the
checks. While moving the code, eliminate some redundancy.
Guinevere Larsen [Fri, 14 Jul 2023 15:43:41 +0000 (17:43 +0200)]
gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp
As mentioned in commit
3f5bbc3e2075ef5061a815c73fdc277218489f22, some
compilers such as clang don't add debug information about stderr by
default, leaving it to external debug packages.
This commit adds a way to check if GDB has access to stderr information
when in MI mode, and uses this new mechanism to skip the related section
of the test gdb.mi/mi-dprintf.exp. It also fixes an incorrect name for a
test in that file.
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Kevin Buettner <kevinb@redhat.com>
GDB Administrator [Fri, 15 Sep 2023 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
Kevin Buettner [Sat, 9 Sep 2023 01:15:53 +0000 (18:15 -0700)]
Throw error when creating an overly large gdb-index file
The header in a .gdb_index section uses 32-bit unsigned offsets to
refer to other areas of the section. Thus, there is a size limit of
2^32-1 which is currently unaccounted for by GDB's code for outputting
these sections.
At the moment, when GDB creates an overly large section, it will exit
abnormally due to an internal error, which is caused by a failed
assert in assert_file_size, which in turn is called from
write_gdbindex_1, both of which are in gdb/dwarf2/index-write.c.
This is what happens when that assert fails:
$ gdb -q -nx -iex 'set auto-load no' -iex 'set debuginfod enabled off' -ex file ./libgraph_tool_inference.so -ex "save gdb-index `pwd`/"
Reading symbols from ./libgraph_tool_inference.so...
No executable file now.
Discard symbol table from `libgraph_tool_inference.so'? (y or n) n
Not confirmed.
../../gdb/dwarf2/index-write.c:1069: internal-error: assert_file_size: Assertion `file_size == expected_size' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
0x55fddb4d78b0 gdb_internal_backtrace_1
../../gdb/bt-utils.c:122
0x55fddb4d78b0 _Z22gdb_internal_backtracev
../../gdb/bt-utils.c:168
0x55fddb98b5d4 internal_vproblem
../../gdb/utils.c:396
0x55fddb98b8de _Z15internal_verrorPKciS0_P13__va_list_tag
../../gdb/utils.c:476
0x55fddbb71654 _Z18internal_error_locPKciS0_z
../../gdbsupport/errors.cc:58
0x55fddb5a0f23 assert_file_size
../../gdb/dwarf2/index-write.c:1069
0x55fddb5a1ee0 assert_file_size
/usr/include/c++/13/bits/stl_iterator.h:1158
0x55fddb5a1ee0 write_gdbindex_1
../../gdb/dwarf2/index-write.c:1119
0x55fddb5a51be write_gdbindex
../../gdb/dwarf2/index-write.c:1273
[...]
---------------------
../../gdb/dwarf2/index-write.c:1069: internal-error: assert_file_size: Assertion `file_size == expected_size' failed.
This problem was encountered while building the python-graph-tool
package on Fedora. The Fedora bugzilla bug can be found here:
https://bugzilla.redhat.com/show_bug.cgi?id=
1773651
This commit prevents the internal error from occurring by calling error()
when the file size exceeds 2^32-1.
Using a gdb built with this commit, I now see this behavior instead:
$ gdb -q -nx -iex 'set auto-load no' -iex 'set debuginfod enabled off' -ex file ./libgraph_tool_inference.so -ex "save gdb-index `pwd`/"
Reading symbols from ./libgraph_tool_inference.so...
No executable file now.
Discard symbol table from `/mesquite2/fedora-bugs/
1773651/libgraph_tool_inference.so'? (y or n) n
Not confirmed.
Error while writing index for `/mesquite2/fedora-bugs/
1773651/libgraph_tool_inference.so': gdb-index maximum file size of
4294967295 exceeded
(gdb)
I wish I could provide a test case, but due to the sizes of both the
input and output files, I think that testing resources would be
strained or exceeded in many environments.
My testing on Fedora 38 shows no regressions.
Approved-by: Tom Tromey <tom@tromey.com>
Andrew Burgess [Thu, 14 Sep 2023 12:06:26 +0000 (13:06 +0100)]
gdb: fix buffer overflow in DWARF reader
In this commit:
commit
48ac197b0c209ccf1f2de9704eb6cdf7c5c73a8e
Date: Fri Nov 19 10:12:44 2021 -0700
Handle multiple addresses in call_site_target
a buffer overflow bug was introduced when the following code was
added:
CORE_ADDR *saved = XOBNEWVAR (&objfile->objfile_obstack, CORE_ADDR,
addresses.size ());
std::copy (addresses.begin (), addresses.end (), saved);
The definition of XOBNEWVAR is (from libiberty.h):
#define XOBNEWVAR(O, T, S) ((T *) obstack_alloc ((O), (S)))
So 'saved' is going to point to addresses.size () bytes of memory,
however, the std::copy will write addresses.size () number of
CORE_ADDR sized entries to the address pointed to by 'saved', this is
going to result in memory corruption.
The mistake is that we should have used XOBNEWVEC, which allocates a
vector of entries, the definition of XOBNEWVEC is:
#define XOBNEWVEC(O, T, N) \
((T *) obstack_alloc ((O), sizeof (T) * (N)))
Which means we will have set aside enough space to create a copy of
the contents of the addresses vector.
I'm not sure how to create a test for this problem, this issue cropped
up when debugging a particular i686 built binary, which just happened
to trigger a glibc assertion (likely due to random memory corruption),
debugging the same binary built for x86-64 appeared to work just fine.
Using valgrind on the failing GDB binary pointed straight to the cause
of the problem, and with this patch in place there are no longer
valgrind errors in this area.
If anyone has ideas for a test I'm happy to work on something.
Co-Authored-By: Keith Seitz <keiths@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
Tom de Vries [Thu, 14 Sep 2023 18:34:00 +0000 (20:34 +0200)]
[gdb/exp] Clean up asap in value_print_array_elements
I've been running the test-suite on an i686-linux laptop with 1GB of memory,
and 1 GB of swap, and noticed problems after running gdb.base/huge.exp: gdb
not being able to spawn for a large number of test-cases afterwards.
So I investigated the memory usage, on my usual x86_64-linux development
platform.
The test-case is compiled with -DCRASH_GDB=
2097152, so this:
...
static int a[CRASH_GDB], b[CRASH_GDB];
...
with sizeof (int) == 4 represents two arrays of 8MB each.
Say we add a loop around the "print a" command and print space usage
statistics:
...
gdb_test "maint set per-command space on"
for {set i 0} {$i < 100} {incr i} {
gdb_test "print a"
}
...
This gets us:
...
(gdb) print a^M
$1 = {0 <repeats
2097152 times>}^M
Space used:
478248960 (+
469356544 for this command)^M
(gdb) print a^M
$2 = {0 <repeats
2097152 times>}^M
Space used:
486629376 (+
8380416 for this command)^M
(gdb) print a^M
$3 = {0 <repeats
2097152 times>}^M
Space used:
495009792 (+
8380416 for this command)^M
...
(gdb) print a^M
$100 = {0 <repeats
2097152 times>}^M
Space used:
1308721152 (+
8380416 for this command)^M
...
In other words, we start out at 8MB, and the first print costs us about 469MB,
and subsequent prints 8MB, which accumulates to 1.3 GB usage. [ On the
i686-linux laptop, the first print costs us 335MB. ]
The subsequent 8MBs are consistent with the values being saved into the value
history, but the usage for the initial print seems somewhat excessive.
There is a PR open about needing sparse representation of large arrays
(PR8819), but this memory usage points to an independent problem.
The function value_print_array_elements contains a scoped_value_mark to free
allocated values in the outer loop, but it doesn't prevent the inner loop from
allocating a lot of values.
Fix this by adding a scoped_value_mark in the inner loop, after which we have:
...
(gdb) print a^M
$1 = {0 <repeats
2097152 times>}^M
Space used:
8892416 (+0 for this command)^M
(gdb) print a^M
$2 = {0 <repeats
2097152 times>}^M
Space used:
8892416 (+0 for this command)^M
(gdb) print a^M
$3 = {0 <repeats
2097152 times>}^M
Space used:
8892416 (+0 for this command)^M
...
(gdb) print a^M
$100 = {0 <repeats
2097152 times>}^M
Space used:
8892416 (+0 for this command)^M
...
Note that the +0 here just means that the mallocs did not trigger an sbrk.
This is dependent on malloc (which can use either mmap or sbrk or some
pre-allocated memory) and will likely vary between different tunings, versions
and implementations, so this does not give us a reliable way detect the
problem in a minimal way.
A more reliable way of detecting the problem is:
...
void
value_free_to_mark (const struct value *mark)
{
+ size_t before = all_values.size ();
auto iter = std::find (all_values.begin (), all_values.end (), mark);
if (iter == all_values.end ())
all_values.clear ();
else
all_values.erase (iter + 1, all_values.end ());
+ size_t after = all_values.size ();
+ if (before - after >= 1024)
+ fprintf (stderr, "value_free_to_mark freed %zu items\n", before - after);
...
which without the fix tells us:
...
+print a
value_free_to_mark freed
2097152 items
$1 = {0 <repeats
2097152 times>}
...
Fix a similar problem for Fortran:
...
+print array1
value_free_to_mark freed
4194303 items
$1 = (0, <repeats
2097152 times>)
...
in fortran_array_printer_impl::process_element.
The problem also exists for Ada:
...
+print Arr
value_free_to_mark freed
2097152 items
$1 = (0 <repeats
2097152 times>)
...
but is fixed by the fix for C.
Add Fortran and Ada variants of the test-case. The *.exp files are similar
enough to the original to keep the copyright years range.
While writing the Fortran test-case, I ran into needing an additional print
setting to print the entire array in repeat form, filed as PR exp/30817.
I managed to apply the compilation loop for the Ada variant as well, but with
a cumbersome repetition style. I noticed no other test-case uses gnateD, so
perhaps there's a better way of implementing this.
The regression test included in the patch is formulated in its weakest
form, to avoid false positive FAILs, which also means that smaller regressions
may not get detected.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
Tom de Vries [Thu, 14 Sep 2023 18:34:00 +0000 (20:34 +0200)]
[gdb/testsuite] Modernize gdb.base/huge.exp
Rewrite test-case gdb.base/huge.exp:
- use build_executable rather than gdb_compile,
- use save_vars,
- factor out hardcoded loop limits min and max,
- handle compilation failure using require, and
- avoid using . in regexp to match $, {} and <>.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
Jan Beulich [Thu, 14 Sep 2023 06:44:13 +0000 (08:44 +0200)]
x86: Vxy naming correction
Looking at the VEX and EVEX forms of vcvtneps2bf16 I noticed that
operand purpose isn't properly reflected in Vxy's definition. Rename
"dst" to "src", thus bringing things in line with Exy.
Jan Beulich [Thu, 14 Sep 2023 06:43:45 +0000 (08:43 +0200)]
x86: support AVX10.1 vector size restrictions
Recognize "/<number>" suffixes on both -march=+avx10.1 and the
corresponding .arch directive, setting an upper bound on the vector size
that insns may use. Such a restriction can be reset by setting a new base
architecture, by using a suffix-less form, by disabling AVX10, or by
enabling any other VEX/EVEX-based vector extension.
While for most insns we can suppress their use with too wide operands
via registers becoming unavailable (or in Intel syntax memory operand
size specifiers not being recognized), mask register insns have to have
their minimum required vector size specified in a new attribute. (Of
course this new attribute could also be used on other insns.)
Note that .insn continues to be permitted to emit EVEX{512,256} (and
VEX256 ones) encodings regardless of vector size restrictions in place.
Of course these can't be expressed using zmm (or ymm) operands then,
but need using the EVEX.512.* forms (broadcast forms may be usable right
now, but this may go away so shouldn't be relied upon). This is why no
assertions should be added to build_{e,}vex_prefix().
Jan Beulich [Thu, 14 Sep 2023 06:42:43 +0000 (08:42 +0200)]
x86: support AVX10.1/512
Since this is merely a re-branding of certain AVX512* features, there's
little code to be added.
The main aspect here are new testcases. In order to be able to re-use
some of the existing testcases, several of them need their start symbols
adjusted. Note that 256- and 128-bit tests want adding here, as these
need to work right away. Subsequently they'll gain vector length
constraints.
Since it was missing and is wanted here, also add an AVX512VL+VPOPCNTDQ
test.
Jan Beulich [Thu, 14 Sep 2023 06:40:58 +0000 (08:40 +0200)]
x86: make AES/PCMULQDQ respectively prereqs of VAES/VPCMULQDQ
These probably should have been put in place already anyway, but they're
very much wanted in order to then put AVX10.1 support on top. Note that
to avoid reverse dependencies towards SSE (just like we already do for
AVX and XOP), add_isa_dependencies() needs some further tweaking.
While there also address a related anomaly: Disabling AES but neither
AVX nor VAES (similarly for {,V}PCLMULQDQ) would better keep the 128-bit
VEX-encoded forms available. Note that for this the VAES insns are moved
past the AVX+AES ones, to avoid the property-11 test suddenly failing.
The test really is wrong, but let's not also make things inconsistent:
Without the movement, YMM use would be correctly recorded for the
128-bit forms simply because the first template already matches, as long
as VAES wasn't disabled. Yet it still wouldn't be if only AVX+AES were
enabled. Nor would behavior here then be the same as for VPCLMUL* insns.
GDB Administrator [Thu, 14 Sep 2023 00:00:44 +0000 (00:00 +0000)]
Automatic date update in version.in
Jacob Navia [Wed, 13 Sep 2023 10:41:03 +0000 (11:41 +0100)]
Fix: "Missing NULL check"
* elf.c (_bfd_elf_init_reloc_shdr): Don't segfault on alloc fail.
Alan Modra [Wed, 13 Sep 2023 10:38:33 +0000 (11:38 +0100)]
Fix: "Possible Memory leak in bed hash.c"
* elf-strtab.c (_bfd_elf_strtab_init): In the event of memory allocation failure, make sure that the hash table is freed.
GDB Administrator [Wed, 13 Sep 2023 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Tue, 12 Sep 2023 17:37:06 +0000 (13:37 -0400)]
gdb/mi: remove warning about mi1
Remove a warning about mi1. mi1 was removed in
975249ff4e26 ("Remove MI
version 1"). It is no longer possible to reach this warning, since
trying to use interpreter mi1 bails out before:
$ ./gdb -nx -q --data-directory=data-directory -i mi1
Interpreter `mi1' unrecognized
Change-Id: Ie43b21e01bca1407995150c729531a70ee662003
Approved-By: Tom Tromey <tom@tromey.com>
Tom Tromey [Tue, 5 Sep 2023 12:55:54 +0000 (06:55 -0600)]
Avoid spurious breakpoint-setting failure in DAP
A user pointed out that if a DAP setBreakpoints request has a 'source'
field in a SourceBreakpoint object, then the gdb DAP implementation
will throw an exception.
While SourceBreakpoint does not allow 'source' in the spec, it seems
better to me to accept it. I don't think we should fully go down the
"Postel's Law" path -- after all, we have the type-checker -- but at
the same time, if we do send errors, they should be intentional and
not artifacts of the implementation.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30820
Enze Li [Tue, 12 Sep 2023 13:40:05 +0000 (21:40 +0800)]
gdb: Fix -Wuninitialized issue
I see the following warning when building GDB on FreeBSD/amd64 with
Clang 14,
======================================================================
CXX mdebugread.o
mdebugread.c:1069:3: error: variable 'f' is uninitialized when used here [-Werror,-Wuninitialized]
f->set_loc_enumval (tsym.value);
^
mdebugread.c:836:17: note: initialize the variable 'f' to silence this warning
struct field *f;
^
= nullptr
======================================================================
after digging a little, I realized that we can not simply do what
Clang 14 says.
The root cause of this issue is that we lost the initialization of
the variable 'f' in this commit,
commit
2774f2dad5f05e68771c07df6ab0fb23baa2118e
Date: Thu Aug 31 09:37:44 2023 +0200
[gdb/symtab] Factor out type::{alloc_fields,copy_fields}
we have made these modifications,
---------------------------------------------------------------------
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -1034,9 +1034,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
t->set_code (type_code);
t->set_length (sh->value);
- t->set_num_fields (nfields);
- f = ((struct field *) TYPE_ALLOC (t, nfields * sizeof (struct field)));
- t->set_fields (f);
+ t->alloc_fields (nfields, false);
---------------------------------------------------------------------
The problem is that the variable 'f' is used in the second half of
parse_symbol, that's why Clang complained.
To fix this issue we need to ensure that the varibale 'f' is
initialized. Calling the fields method is an obvious way to fix this
issue.
Tested on FreeBSD/amd64 by rebuilding.
Approved-By: Tom de Vries <tdevries@suse.de>
Lancelot Six [Mon, 11 Sep 2023 14:54:59 +0000 (14:54 +0000)]
gdb/testsuite/rocm: fix rocm-multi-inferior-gpu.cpp
The gdb/testsuite/gdb.rocm/multi-inferior-gpu.cpp testcase contains a
call to execl which does not have NULL as a last argument. This is
an invalid use of execl. This patch fixes this oversight.
Change-Id: I03b60abe30468d71ba5089b240c6d00f9b8883b2
Approved-By: Tom Tromey <tom@tromey.com>
GDB Administrator [Tue, 12 Sep 2023 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Mon, 11 Sep 2023 14:45:37 +0000 (08:45 -0600)]
Specialize std::hash for ptid_t
This changes hash_ptid to instead be a specialization of std::hash.
This makes it a little easier to use with standard containers.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Mon, 11 Sep 2023 15:21:26 +0000 (09:21 -0600)]
Update Python signal-handling documentation
I noticed a typo in the "Basic Python" node, and when fixing it
realized that the paragraph could use a link to the block_signals
function. This patch is the result.
Approved-By: Eli Zaretskii <eliz@gnu.org>
Simon Marchi [Mon, 11 Sep 2023 02:13:26 +0000 (22:13 -0400)]
gdb/testsuite: use foreach_with_prefix in gdb.guile/scm-ports.exp
Simplify things a bit using foreach_with_prefix. The only expected
change is in the naming of tests.
Change-Id: Icb5e55207e0209e0d44d9e7c16a2f5e11aa29017
Approved-By: Andrew Burgess <aburgess@redhat.com>
Ijaz, Abdul B [Fri, 8 Sep 2023 20:56:18 +0000 (22:56 +0200)]
testsuite, fortran: Fix regression due to fix for ifort's 'start' behavior
Got a regression email due to merge of commit in CI config
tcwg_gdb_check/master-aarch64 :
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=
41439185cd0075bbb1aedf9665685dba0827cfec
Begining of test "gdb.fortran/array-slices-bad.exp" was updated in above
commit to start the test from running to line with tag "First Breakpoint"
instead of "fortran_runto_main". Reason of the regression is shared
libraries are still loaded after hitting the breakpoint as "nosharedlibrary"
is already called before hitting the breakpoint.
So now after this change test is updated accordingly to disable and unload
shared libraries symbols after hitting the first breakpoint.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Markus Metzger [Thu, 17 Aug 2023 10:17:26 +0000 (10:17 +0000)]
gdb: c++ify btrace_target_info
Following the example of private_thread_info and private_inferior, turn
struct btrace_target_info into a small class hierarchy.
Also merge btrace_tinfo_bts with btrace_tinfo_pt and inline into
linux_btrace_target_info.
Fixes PR gdb/30751.
Markus Metzger [Thu, 17 Aug 2023 15:29:26 +0000 (15:29 +0000)]
gdb, btrace: move xml parsing into remote.c
The code is only used in remote.c and all functions can be declared static.
Simon Marchi [Fri, 8 Sep 2023 02:26:59 +0000 (22:26 -0400)]
gdb/testsuite: fix gdb.arch/amd64-init-x87-values.exp on AMD CPUs
I see the following failure when running this test on an AMD machine:
p/x $fioff^M
$24 = 0x0^M
(gdb) FAIL: gdb.arch/amd64-init-x87-values.exp: check_x87_regs_around_init: check post FLD1 value of $fioff
The register that GDB calls fioff normally contains the address of the
last instruction executed by the x87 unit. It is available through the
FSAVE/FXSAVE/XSAVE instructions, at offset 0x8 of the FSAVE/FXSAVE/XSAVE
area. You can read about it in the Intel manual [1] at section "10.5.1
FXSAVE Area" (and equivalent sections for FSAVE and XSAVE) or in the AMD
manual [2] at section "11.4.4 Saving Media and x87 Execution Unit
State".
The test therefore expects that after executing the FLD1 instruction,
the fioff register contains the address of the FLD1 instruction.
However, the FXSAVE and XSAVE instructions (which the kernel uses to
dump x87 register state which it provides GDB through ptrace) behave
differently on AMD CPUs. In section "11.4.4.3 FXSAVE and FXRSTOR
Instructions" of the AMD manual, we read:
The FXSAVE and FXRSTOR instructions save and restore the entire
128-bit media, 64-bit media, and x87 state. These instructions
usually execute faster than FSAVE/FNSAVE and FRSTOR because they do
not normally save and restore the x87 exception pointers
(last-instruction pointer, last data-operand pointer, and last
opcode). The only case in which they do save the exception pointers
is the relatively rare case in which the exception-summary bit in
the x87 status word (FSW.ES) is set to 1, indicating that an
unmasked exception has occurred.
So, unless a floating point exception happened and that exception is
unmasked in the x87 FPU control register (which isn't by default on
Linux, from what I saw), the "last instruction address" register (or
fioff as GDB calls it) will always be 0 on an AMD CPU.
For this reason, I think it's fine to change the test to accept the
value 0 - that's just how the processor works.
I toyed with the idea of changing the test program to make it so the CPU
would generate a non-zero fioff. That is by unmasking an FPU exception
and executing an instruction to raise that kind exception. It worked,
but then I would have to change the test more extensively, and it didn't
seem to be worth it.
[1] https://cdrdv2.intel.com/v1/dl/getContent/671200
[2] https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/24593.pdf
Change-Id: If2e1d932f600ca01b15f30b14b8d38bf08a3e00b
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
GDB Administrator [Mon, 11 Sep 2023 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 10 Sep 2023 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sat, 9 Sep 2023 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Jinyang He [Thu, 10 Aug 2023 02:21:40 +0000 (10:21 +0800)]
Make sure DW_CFA_advance_loc4 is in the same frag
Do the same as commit
b9d8f5601bcf in another place generating
DW_CFA_advance_loc4. The idea behind commit
b9d8f5601bcf was that
when a DW_CFA_advance_loc4 of zero is seen in eh_frame_relax_frag and
eh_frame_convert_frag we want to remove the opcode entirely, not just
convert to a nop. If the opcode was split over two frags then a size
adjustment would need to be done to the first frag, not just the
second as is correct for other cases with split frags. This would
complicate the eh relaxation. It's easier to ensure the frag is not
split.
* ehopt.c (check_eh_frame): Don't allow DW_CFA_advance_loc4
to be placed in a different frag to the rs_cfa.
Tom Tromey [Fri, 8 Sep 2023 19:06:47 +0000 (13:06 -0600)]
Run 'black' on recent test case
The auto-builders pointed out that I neglected to run 'black' after a
rest testcase change. This patch fixes the oversight.
Vladimir Mezentsev [Thu, 7 Sep 2023 21:50:15 +0000 (14:50 -0700)]
Set insn_type for branch instructions on aarch64
gprofng uses insn_type in print_address_func().
But insn_type is always zero on aarch64.
opcodes/ChangeLog:
2023-09-07 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
* opcodes/aarch64-dis.c (print_insn_aarch64_word): Set insn_type for
branch instructions.
Simon Marchi [Fri, 8 Sep 2023 15:20:58 +0000 (11:20 -0400)]
gdb/doc: describe x87 registers
While investigating this [1], I initially had no idea what register
"fioff" stood for, making it difficult to map it to something in the
Intel or AMD manuals. Similarly, I can imaging someone familiar with
x87 to want to print the "x87 last instruction address", and have no
clue that GDB makes it available as register "fioff". The names of the
x87 state fields don't seem to be standardized, they even change between
sections of the Intel manual (between the FSAVE, FXSAVE and XSAVE area
descriptions).
Add some details to the doc to help one map GDB register names to x87
state fields.
[1] https://inbox.sourceware.org/gdb-patches/
20230908022722.430741-1-simon.marchi@efficios.com/T/#u
Change-Id: I0ea1eb648358e62da4aa87eea3515ee8a09f2762
Approved-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Pedro Alves <pedro@palves.net>
Simon Marchi [Fri, 8 Sep 2023 15:20:57 +0000 (11:20 -0400)]
gdb/doc: rename "x86 Architecture-specific Issues" section to "x86"
I'm looking to add some x86-specific information to the doc, but I find
the naming of this section odd. It doesn't really talk about issues, it
just gives generally useful information. Also, the sections about other
architectures don't mention "issues", just the architecture name.
Also, at least in the HTML version of the doc, the name is inconsistent
between the main table of content, where it appears as "x86
Architecture-specific Issues", and the sub-table of contents of the
"Architectures" section, where it appears as "i386".
Rename the section to just "x86".
Change-Id: I0a119ff1ab5e7b83c9afa3c3977eb085e88f52ca
Approved-By: Eli Zaretskii <eliz@gnu.org>
Richard Sandiford [Fri, 8 Sep 2023 16:20:56 +0000 (17:20 +0100)]
aarch64: Remove unused function
set_expected_error is no longer used. It has been replaced by
more specific error messages.
Tom de Vries [Fri, 8 Sep 2023 10:27:02 +0000 (12:27 +0200)]
[gdb/testsuite] Make gdb.dwarf2/dwzbuildid.exp more robust
I ran test-case gdb.dwarf2/dwzbuildid.exp with target board cc-with-gdb-index,
and noticed that compilation failure for one exec prohibited testing of all
execs.
Fix this by restructuring the test-case, such that we have:
...
PASS: gdb.dwarf2/dwzbuildid.exp: testname=ok: set debug-file-directory
PASS: gdb.dwarf2/dwzbuildid.exp: testname=ok: print the_int
UNSUPPORTED: gdb.dwarf2/dwzbuildid.exp: testname=mismatch: compilation failed
UNSUPPORTED: gdb.dwarf2/dwzbuildid.exp: testname=fallback: compilation failed
...
Tested on x86_64-linux.
Tom de Vries [Fri, 8 Sep 2023 10:27:02 +0000 (12:27 +0200)]
[gdb/testsuite] Add kfail in gdb.dwarf2/dwzbuildid.exp
When running test-case gdb.dwarf2/dwzbuildid.exp using target board readnow, I
get:
...
(gdb) file dwzbuildid-mismatch^M
Reading symbols from dwzbuildid-mismatch...^M
warning: File "dwzbuildid5.o" has a different build-id, file skipped^M
could not find '.gnu_debugaltlink' file for dwzbuildid-mismatch^M
(gdb) delete breakpoints^M
(gdb) info breakpoints^M
No breakpoints or watchpoints.^M
(gdb) break -qualified main^M
No symbol table is loaded. Use the "file" command.^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) FAIL: gdb.dwarf2/dwzbuildid.exp: mismatch: gdb_breakpoint: set breakpoint at main
...
This is PR symtab/26797: when using readnow, a failure in reading the dwarf
results in the minimal symbols not being available.
Add a corresponding KFAIL.
Tested on x86_64-linux.
Tom de Vries [Fri, 8 Sep 2023 10:27:02 +0000 (12:27 +0200)]
[gdb/testsuite] Add aranges in gdb.dwarf2/dwzbuildid.exp
While investigating the execs of gdb.dwarf2/dwzbuildid.exp using readelf I ran
into a warning:
...
$ readelf -w dwzbuildid-ok > READELF
readelf: Warning: .debug_info offset of 0x2e in .debug_aranges section does not
point to a CU header.
...
AFAICT, the warning is incorrect, I've filed PR binutils/30835 about that.
While looking at the .debug_aranges section, I noticed that the entries for
the CUs generated by the dwarf assembler are missing.
Fix this by adding the missing .debug_aranges entries.
Tested on x86_64-linux.
Tom de Vries [Fri, 8 Sep 2023 10:27:02 +0000 (12:27 +0200)]
[gdb/testsuite] Fix build-ids in gdb.dwarf2/dwzbuildid.exp
When looking at the execs from test-case gdb.dwarf2/dwzbuildid.exp using
readelf, I run into:
...
$ readelf -w dwzbuildid-ok > READELF
readelf: Warning: Corrupt debuglink section: .gnu_debugaltlink
readelf: Warning: Build-ID is too short (0x6 bytes)
...
Fix this by ensuring the Build-IDs are the required 20 bytes.
Tested on x86_64-linux.
Andrew Burgess [Fri, 8 Sep 2023 09:45:08 +0000 (10:45 +0100)]
gdb/testsuite: fix gdb.mi/mi-condbreak-throw.exp failure
In commit:
commit
3ce8f906be7a55d8c0375e6d360cc53b456d86ae
Date: Tue Aug 8 10:45:20 2023 +0100
gdb: MI stopped events when unwindonsignal is on
a new test, gdb.mi/mi-condbreak-throw.exp, was added. Unfortunately,
this test would fail when using the native-gdbserver board (and other
similar boards).
The problem was that one of the expected output patterns included some
output from the inferior. When using the native-gdbserver board, this
output is not printed to GDB's tty, but is instead printed to
gdbserver's tty, the result is that the expected output no longer
matches, and the test fails.
Additionally, as the output is actually from the C++ runtime, rather
than the test's source file, changes to the C++ runtime could cause
the output to change.
To solve both of these issues, in this commit, I'm removing the
reference to the inferior's output, and replacing it with '.*', which
will skip the output if it is present, but is equally happy if the
output is not present.
After this commit gdb.mi/mi-condbreak-throw.exp now passes on all
boards, including native-gdbserver.
Jan Beulich [Fri, 8 Sep 2023 06:45:11 +0000 (08:45 +0200)]
x86: restrict prefix use with .insn VEX/XOP/EVEX
Avoid triggering the respective abort() in output_insn().
Simon Marchi [Wed, 6 Sep 2023 19:29:10 +0000 (15:29 -0400)]
gdb: remove interp_supports_command_editing
It is a trivial wrapper around the supports_command_editing method,
remove it.
Change-Id: I0fe3d7dc69601b3b89f82e055f7fe3d4af1becf7
Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Wed, 6 Sep 2023 19:29:09 +0000 (15:29 -0400)]
gdb: remove interp_pre_command_loop
It is a trivial wrapper around the pre_command_loop method, remove it.
Change-Id: Idb2c61f9b68988528006a9a9b2b528f43781eef4
Approved-By: Tom Tromey <tom@tromey.com>
GDB Administrator [Fri, 8 Sep 2023 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Nils-Christian Kempke [Tue, 31 May 2022 16:10:18 +0000 (18:10 +0200)]
testsuite, fortran: make kfail gfortran specific
The modified test in function-calls.exp actually passes with ifort and
ifx. The particular fail seems to be specific to gfortran. When the
test was introduced it was only tested with gfortran (actually the
whole patch was written with gfortran and the GNU Fortran argument
passing convention in mind).
Approved-by: Tom Tromey <tom@tromey.com>
Nils-Christian Kempke [Fri, 20 May 2022 08:25:57 +0000 (10:25 +0200)]
testsuite, fortran: adapt tests for ifort's 'start' behavior
The modified tests array-slices-bad.exp and vla-type.exp both set a
breakpoint at the first real statement in the respective executables.
Normally, the expected behavior of fortran_runto_main for these would be
the stopping of the debugger at exactly the first statment in the code.
Strangely, neither gfortran nor ifx seem to do this for these tests.
Instead, issuing 'start' in ifx (for either of the 2 tests) lets GDB
stop at the 'program ...' line and gfortran stops at a variable
declaration line. E.g. for vla-type it stops at
41 type(five) :: fivearr (2)
So, actually, ifort's behavior can be considered to be a bit more
'correct' here. This patch remove the fortran_runto_main in the
two tests and instead uses runto to directly run to the first breakpoint
set at the first program statement. This works with both compiler
behaviors and makes the tests more robust.
Approved-by: Kevin Buettner <kevinb@redhat.com>
Nils-Christian Kempke [Fri, 20 May 2022 15:15:44 +0000 (17:15 +0200)]
testsuite, fortran: Remove self assignment non-statements
There were a couple of places in the testsuite where instructions like
var = var
were written in the source code of tests. These were usually dummy
statements meant to generate a line table entry at that line on which
to break later on.
This worked fine for gfortran and ifx, but it seems that, when compiled
with ifort (2021.6.0) these statements do not actually create any
assmbler instructions and especially no line table entries. Consider
the program
program test
Integer var :: var = 1
var = var
end program
compiled with gfortran (13.0.0, -O0 -g). The linetable as emitted by
'objdump --dwarf=decodedline ./a.out' looks like
test.f90:
File name Line number Starting address View Stmt
test.f90 1 0x401172 x
test.f90 3 0x401176 x
test.f90 4 0x401182 x
test.f90 4 0x401185 x
test.f90 4 0x401194 x
test.f90 - 0x4011c0
actually containing line table info for line 3. Running gdb, breaking
at 3 and checking the assembly we see
0x0000000000401172 <+0>: push %rbp
0x0000000000401173 <+1>: mov %rsp,%rbp
=> 0x0000000000401176 <+4>: mov 0x2ebc(%rip),%eax # 0x404038 <var.1>
0x000000000040117c <+10>: mov %eax,0x2eb6(%rip) # 0x404038 <var.1>
0x0000000000401182 <+16>: nop
0x0000000000401183 <+17>: pop %rbp
0x0000000000401184 <+18>: ret
so two mov instructions are being issued for this assignment one copying
the value into a register and one writing it back to the same memory.
Ifort (2021.6.0, -O0 -g) on the other hand does not emit anything here
and also has no line table entry:
test.f90:
File name Line number Starting address View Stmt
test.f90 1 0x4040f8 x
test.f90 4 0x404109 x
test.f90 4 0x40410e x
test.f90 - 0x404110
As I do not think that this is really a bug (on either side, gfortran/ifx or
ifort), and as I don't think this behavior is covered in the Fortran
standard, I changed these lines to become actual value assignments.
This removes a few FAILs in the testsuite when ran with ifort.
Approved-by: Tom Tromey <tom@tromey.com>
Nils-Christian Kempke [Fri, 20 May 2022 15:44:31 +0000 (17:44 +0200)]
testsuite, fortran: make mixed-lang-stack less compiler dependent
In the gdb.fortran/mixed-lang-stack.exp test when somewhere deep in a
bunch of nested function calls we issue and test a 'info args' command
for the mixed_func_1b function (when in that function's frame).
The signature of the function looks like
subroutine mixed_func_1b(a, b, c, d, e, g)
use type_module
implicit none
integer :: a
real(kind=4) :: b
real(kind=8) :: c
complex(kind=4) :: d
character(len=*) :: e
character(len=:), allocatable :: f
TYPE(MyType) :: g
and usually one would expect arguments a, b, c, d, e, and g to be
emitted here. However, due to some compiler dependent treatment of the
e array the actual output in the test (with gfortran/ifx) is
(gdb) info args
a = 1
b = 2
c = 3
d = (4,5)
e = 'abcdef'
g = ( a = 1.5, b = 2.5 )
_e = 6
where the compiler generated '_e' is emitted as the length of e. While
ifort also generates an additional length argument, the naming (which is
up to the compilers here I think, I could not find anything in the
Fortran standard about this) is different and we see
(gdb) info args
a = 1
b = 2
c = 3
d = (4,5)
e = 'abcdef'
g = ( a = 1.5, b = 2.5 )
.tmp.E.len_V$4a = 6
To make both outputs pass the test, I kept the additional argument for now and
made the regex for the emitted name of the last variable match any
arbitrary name.
Approved-by: Tom Tromey <tom@tromey.com>
Ijaz, Abdul B [Thu, 7 Sep 2023 08:23:44 +0000 (10:23 +0200)]
gdb: add Abdul Basit Ijaz to gdb/MAINTAINERS
Signed-off-by: Ijaz, Abdul B <abdul.b.ijaz@intel.com>