Tom Tromey [Tue, 19 Apr 2022 13:41:44 +0000 (07:41 -0600)]
More const use and alloca avoidance in coff-pe-read.c
This changes another function in coff-pe-read.c to use 'const' more,
and to avoid the use of alloca by instead using std::string.
Tom Tromey [Tue, 19 Apr 2022 13:33:09 +0000 (07:33 -0600)]
Use std::string in coff-pe-read.c
coff-pe-read.c uses xsnprintf and alloca, but using std::string is
better, and just as easy. In general I think alloca is something to
be avoided, and unbounded uses especially so.
Tom Tromey [Tue, 19 Apr 2022 13:30:08 +0000 (07:30 -0600)]
Remove a const-removing cast from coff-pe-read.c
coff-pe-read.c casts away const at one spot, but this is easily
replaced by calling bfd_get_filename directly in a couple of debugging
prints.
Tom Tromey [Tue, 19 Apr 2022 13:27:48 +0000 (07:27 -0600)]
Simplify BFD section iteration in coff-pe-read.c
coff-pe-read.c iterates over BFD sections using bfd_map_over_sections,
but it's much simpler to use a for-each loop. This allows for the
removal of helper functions and types.
Tom Tromey [Thu, 21 Apr 2022 15:37:24 +0000 (09:37 -0600)]
Fix method naming bug in new DWARF indexer
Pedro pointed out that gdb-add-index is much slower with the new DWARF
indexer. He also noticed that, in some cases, the generated
.gdb_index would have the wrong fully-qualified name for a method.
I tracked this down to a bug in the indexer. If a type could have
methods but was marked as a declaration, the indexer was ignoring it.
However, this meant that the internal map to find the qualified name
was not updated for this container.
Christoph Muellner [Thu, 21 Apr 2022 22:31:27 +0000 (00:31 +0200)]
RISC-V: Add missing DECLARE_INSNs for Zicbo{m,p,z}
The recently added support for the Zicbo{m,p,z} extensions did not
include DECLARE_INSN() declarations for the instructions.
These declarations are needed by GDB's instruction detection code.
This patch adds them.
Signed-off-by: Christoph Muellner <cmuellner@gcc.gnu.org>
GDB Administrator [Fri, 22 Apr 2022 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
Carl Love [Tue, 22 Mar 2022 20:23:44 +0000 (15:23 -0500)]
Fix for gdb.base/solib-search.exp test.
The variable right_lib_flags is not being set correctly to define RIGHT.
The value RIGHT is needed to force the address of the library functions
lib1_func3 and lib2_func4 to occur at different address in the wrong and
right libraries.
With RIGHT defined correctly, functions lib1_func3 and lib2_func4 occur
at different addresses the test runs correctly on Powerpc.
The test needs the lib2 addresses to be different in the right and
wrong cases. That is the point of introducing function lib2_spacer
with the ifdef RIGHT compiler directive.
On Intel, the ARRAY_SIZE of 1 versus 8192 is sufficient to get the
dynamic linker to move the addresses of the library. You can also get
the same effect on PowerPC but you must use a value much larger than
8192.
The key thing is that the test was not properly setting RIGHT to
defined to get the lib2_spacer function on Intel and Powerpc.
Without the patch, we have the Intel backtrace for the bad libraries:
backtrace
#0 break_here () at /home/ ... /gdb/testsuite/gdb.base/solib-search.c:30
#1 0x00007ffff7fae156 in ?? ()
#2 0x00007fffffffc150 in ?? ()
#3 0x00007ffff7fbb156 in ?? ()
#4 0x00007fffffffc160 in ?? ()
#5 0x00007ffff7fae146 in ?? ()
#6 0x00007fffffffc170 in ?? ()
#7 0x00007ffff7fbb146 in ?? ()
#8 0x00007fffffffc180 in ?? ()
#9 0x0000555555555156 in main () at /home/ ... /binutils-gdb/gdb/testsuite/gdb.base/solib-search.c:23
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) PASS: gdb.base/solib-search.exp: backtrace (with wrong libs) (data collection)
The backtrace on Intel with the good libraries is:
backtrace
#0 break_here () at /.../binutils-gdb/gdb/testsuite/gdb.base/solib-search.c:30
#1 0x00007ffff7fae156 in lib2_func4 () at /.../binutils-gdb/gdb/testsuite/gdb.base/solib-search-lib2.c:49
#2 0x00007ffff7fbb156 in lib1_func3 () at /.../gdb.base/solib-search-lib1.c:49
#3 0x00007ffff7fae146 in lib2_func2 () at /.../testsuite/gdb.base/solib-search-lib2.c:30
#4 0x00007ffff7fbb146 in lib1_func1 () at /.../gdb.base/solib-search-lib1.c:30
#5 0x0000555555555156 in main () at /...solib-search.c:23
(gdb) PASS: gdb.base/solib-search.exp: backtrace (with right libs) (data collection)
PASS: gdb.base/solib-search.exp: backtrace (with right libs)
In one case the backtrace is correct and the other it
is wrong on Intel. This is due to the fact that the ARRAY_SIZE caused
the dynamic linker to move the library function addresses around. I
believe it has to do with the default size of the data and code
sections used by the dynamic linker.
So without the patch the backtrace on PowerPC looks like:
backtrace
#0 break_here () at /.../solib-search.c:30
#1 0x00007ffff7f007f4 in lib2_func4 () at /.../solib-search-lib2.c:49
#2 0x00007ffff7f307f4 in lib1_func3 () at /.../solib-search-lib1.c:49
#3 0x00007ffff7f007ac in lib2_func2 () at /.../solib-search-lib2.c:30
#4 0x00007ffff7f307ac in lib1_func1 () at /.../solib-search-lib1.c:30
#5 0x000000001000074c in main () at /.../solib-search.c:23
for both the good and bad libraries.
The patch fixes defining RIGHT in solib-search-lib1.c and solib-search-
lib2.c. Note, without the patch the lib1_spacer and lib2_spacer
functions do not show up in the object dump of the Intel or Powerpc
libraries as it should. The patch fixes that by making sure RIGHT gets
defined.
Now with the patch the backtrace for the bad library on PowerPC looks
like:
backtrace
#0 break_here () at /.../solib-search.c:30
#1 0x00007ffff7f0083c in __glink_PLTresolve () from /.../solib-search-lib2.so
Backtrace stopped: frame did not save the PC
And the backtrace for the good libraries on PowerPC looks like:
backtrace
#0 break_here () at /.../solib-search.c:30
#1 0x00007ffff7f0083c in lib2_func4 () at /.../solib-search-lib2.c:49
#2 0x00007ffff7f3083c in lib1_func3 () at /.../solib-search-lib1.c:49
#3 0x00007ffff7f007cc in lib2_func2 () at /.../solib-search-lib2.c:30
#4 0x00007ffff7f307cc in lib1_func1 () at /.../solib-search-lib1.c:30
#5 0x000000001000074c in main () at /.../solib-search.c:23
(gdb) PASS: gdb.base/solib-search.exp: backtrace (with right libs) (data collection)
PASS: gdb.base/solib-search.exp: backtrace (with right libs)
The issue then is on Power where the ARRAY_SIZE of 1 versus 8192 is not
sufficient to cause the dymanic linker to allocate the libraries at
different addresses. I don't claim to understand the specifics of how
the dynamic linker works and what the default size is for the data and
code sections are. My guess is by default PowerPC allocates a larger
data size by default, which is large enough to hold array[8192]. The
default size of the data section allocated by the dynamic linker on
Intel is not large enough to hold array[8192] thus causing the code
section on Intel to have to move when the large array is defined.
Note on PowerPC, if you make ARRAY_SIZE big enough, then you will cause
the library addresses to occur at different addresses as the larger
data section forces the code section to a different address. That was
actually my original fix for the program until I spoke with Doug Evans
who originally wrote the test. Doug noticed that RIGHT was not getting
defined as he originally intended in the test.
With the patch to fix the definition of RIGHT, PowerPC has a bad and a
good backtrace because the address of lib1_func3 and lib2_func4 both
move because lib1_spacer and lib2_spacer are now defined
before lib1_func3 and lib2_func4.
Without the patch, the lib1_spacer and lib2_spacer function doesn't show
up in the binary for the correct or incorrect library on Intel or PowerPC.
With the patch, RIGHT gets defined as originally intended for the test on
both architectures and lib1_spacer and lib2_spacer function show up in the
binaries on both architectures changing the other function addresses as
intended thus causing the test work as intended on PowerPC.
Simon Marchi [Tue, 12 Apr 2022 19:36:16 +0000 (15:36 -0400)]
gdb/dwarf: remove line_header::header_length field
This can be a local in dwarf_decode_line_header.
Change-Id: I2ecf4616d1a3197bd1e81ded9f999a2da9a685af
Simon Marchi [Tue, 12 Apr 2022 19:31:24 +0000 (15:31 -0400)]
gdb/dwarf: remove line_header::total_length field
This doesn' have to be a field, it can simply be a local variable in
dwarf_decode_line_header. Name the local variable "unit_length", since
that's what the field in called in DWARF 4 and 5. It's always easier to
follow the code with the standard on the side when we use the same
terminology.
Change-Id: I3ad1022afd9410b193ea11b9b5437686c1e4e633
Simon Marchi [Thu, 21 Apr 2022 19:05:32 +0000 (15:05 -0400)]
gdb/testsuite: fix "set temporary breakpoint" DUPLICATEs
Commit
c67f4e538 ("gdb/testsuite: make gdb.ada/mi_prot.exp stop at
expected location") introduced some DUPLICATEs in MI tests using
mi_continue_to_line, for example:
DUPLICATE: gdb.ada/mi_ref_changeable.exp: mi_continue_to_line: set temporary breakpoint
These test names were previously differentiated by the location passed
to mi_continue_to_line. Since the location can contain a path, that
commit removed the location from the test name, in favor of a hardcoded
string "set temporary breakpoint", hence removing the differentiator.
mi_continue_to_line receives a "test" parameter, containing a test
name. Add a "with_test_prefix" with that name, so that all tests
recorded during mi_continue_to_line have this in their name.
mi_continue_to_line passes that "test" string to mi_get_stop_line, that
is a bit superfluous. mi_get_stop_line only uses that string in case of
failures (it doesn't record a pass if everything goes fine). Since it's
not crucial, just remove it, and adjust all callers.
Adjust three gdb.mi/mi-var-*.exp tests to use prefixes to differentiate
the multiple calls to mi_run_inline_test (which calls
mi_continue_to_line).
Change-Id: I511c6caa70499f8657b1cde37d71068d74d56a74
Tom Tromey [Tue, 19 Apr 2022 17:32:04 +0000 (11:32 -0600)]
Always use dwarf2_initialize_objfile
Internally we noticed that some tests would fail like so on Windows:
warning: Section .debug_aranges in [...] has duplicate debug_info_offset 0x0, ignoring .debug_aranges.
Debugging showed that, in fact, a second CU was being created at this
offset. We tracked this down to the fact that, while the ELF reader
is careful to re-use the per-BFD data, other readers are not, and
could re-read the DWARF data multiple times.
However, since the change to allow an objfile to have multiple "quick
symbol" implementations, there's no reason for this approach -- it's
safe and easy for all symbol readers to reuse the per-BFD data when
reading DWARF.
This patch implements this idea, simplifying dwarf2_build_psymtabs and
making it private, and then switching to dwarf2_initialize_objfile as
the sole way to start the DWARF reader.
Note that, while I think the call to dwarf2_build_frame_info in
machoread.c is also obsolete, I haven't attempted to remove it here.
Andrew Burgess [Thu, 21 Apr 2022 10:16:18 +0000 (11:16 +0100)]
gdb: fix 'remote show FOO-packet' aliases
The following behaviour was observed in GDB:
(gdb) show remote X-packet
Support for the `p' packet is auto-detected, currently unknown.
Note the message mentions the 'p' packet. This is a regression since
this commit:
commit
8579fd136a614985bd27f20539c7bb7c5a51287d
Date: Mon Nov 8 14:58:46 2021 +0000
gdb/gdbsupport: make xstrprintf and xstrvprintf return a unique_ptr
Before this commit the behaviour was:
(gdb) show remote X-packet
Support for the `X' packet is auto-detected, currently unknown.
The problem was caused by a failed attempt to ensure that some
allocated strings were deleted when GDB exits. The code in the above
commit attempted to make use of 'static' to solve this problem,
however, the solution was just wrong.
In this new commit I instead allocate a static vector into which all
the allocated strings are stored, this ensures the strings are
released when GDB exits (which makes output from tools like valgrind
cleaner), but each string within the vector can be unique, which fixes
the regression.
Simon Marchi [Wed, 20 Apr 2022 21:03:25 +0000 (17:03 -0400)]
gdbsupport: add path_join function
In this review [1], Eli pointed out that we should be careful when
concatenating file names to avoid duplicated slashes. On Windows, a
double slash at the beginning of a file path has a special meaning. So
naively concatenating "/" and "foo/bar" would give "//foo/bar", which
would not give the desired results. We already have a few spots doing:
if (first_path ends with a slash)
path = first_path + second_path
else
path = first_path + slash + second_path
In general, I think it's nice to avoid superfluous slashes in file
paths, since they might end up visible to the user and look a bit
unprofessional.
Introduce the path_join function that can be used to join multiple path
components together (along with unit tests).
I initially wanted to make it possible to join two absolute paths, to
support the use case of prepending a sysroot path to a target file path,
or the prepending the debug-file-directory to a target file path. But
the code in solib_find_1 shows that it is more complex than this anyway
(for example, when the right hand side is a Windows path with a drive
letter). So I don't think we need to support that case in path_join.
That also keeps the implementation simpler.
Change a few spots to use path_join to show how it can be used. I
believe that all the spots I changed are guarded by some checks that
ensure the right hand side operand is not an absolute path.
Regression-tested on Ubuntu 18.04. Built-tested on Windows, and I also
ran the new unit-test there.
[1] https://sourceware.org/pipermail/gdb-patches/2022-April/187559.html
Change-Id: I0df889f7e3f644e045f42ff429277b732eb6c752
Lancelot SIX [Thu, 21 Apr 2022 08:28:21 +0000 (09:28 +0100)]
gdb_spawn_attach_cmdline: use unsupported instead of untested
In a previous commit (
b750766ac96: gdb/testsuite: Introduce and use
gdb_spawn_attach_cmdline), if gdb_spawn_attach_cmdline cannot have GDB
attach to the process because of ptrace restrictions (operation not
permitted), the proc issues UNTESTED. This should really be
UNSUPPORTED, as it is done in gdb_attach.
This patch fixes this oversight.
Change-Id: Ib87e33b9230f3fa7a85e06220ef4c63814b71f7d
Enze Li [Sat, 16 Apr 2022 07:36:29 +0000 (15:36 +0800)]
gdb/testsuite: add binary testcases to py-format-string.exp
We currently only test decimal and hexadecimal for the
gdb.Value.format_string() interface, this patch adds testcases for
binary format.
Tested on x86_64 openSUSE Tumbleweed(VERSION_ID="
20220413").
Pedro Alves [Thu, 21 Apr 2022 12:35:09 +0000 (13:35 +0100)]
gdb.debuginfod/fetch_src_and_symbols.exp: Fix "notice empty URL" test
The gdb_test_multiple pattern for the "notice empty URL" test in
gdb.debuginfod/fetch_src_and_symbols.exp misses expecting the prompt.
Fix it by using -re -wrap.
Also, by using "confirm off", the message GDB prints if Debuginfod
downloading is available doesn't contain "Enable debuginfod" any
longer. E.g.:
~~~
(gdb) file testsuite/outputs/gdb.debuginfod/fetch_src_and_symbols/fetch_src_and_symbols
Reading symbols from testsuite/outputs/gdb.debuginfod/fetch_src_and_symbols/fetch_src_and_symbols...
This GDB supports auto-downloading debuginfo from the following URLs:
<http://localhost:123>
Enable debuginfod for this session? (y or [n])
~~~
~~~
(gdb) with confirm off -- file testsuite/outputs/gdb.debuginfod/fetch_src_and_symbols/fetch_src_and_symbols
Reading symbols from testsuite/outputs/gdb.debuginfod/fetch_src_and_symbols/fetch_src_and_symbols...
This GDB supports auto-downloading debuginfo from the following URLs:
<http://127.0.0.1:8000>
<127.0.0.1:8000>
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
(No debugging symbols found in testsuite/outputs/gdb.debuginfod/fetch_src_and_symbols/fetch_src_and_symbols)
(gdb)
~~~
I handled that correctly in the other tests that use test_urls, but
had forgotten to update the "notice empty URL" one.
Change-Id: I00040c83466e1494b3875574eb009c571a1504bf
Alan Modra [Wed, 20 Apr 2022 23:19:30 +0000 (08:49 +0930)]
prune .note.GNU-stack warning from testsuite
binutils/
* testsuite/lib/binutils-common.exp (prune_warnings_extra): Remove
.note.GNU-stack warning.
(run_dump_test): Call prune_warnings for ld and objcopy output.
ld/
* testsuite/ld-elf/elf.exp: Disable prune_warnings_extra temporarily
around test for absent .note.GNU-stack
* testsuite/ld-cris/globsymw2.s,
* testsuite/ld-cris/warn3.d: Modify "is not implemented" message
to avoid dejagnu prune_warnings.
Alan Modra [Wed, 20 Apr 2022 23:20:02 +0000 (08:50 +0930)]
ld testsuite xcoff XPASS
* testsuite/ld-scripts/defined5.d: Don't xfail xcoff targets.
Alan Modra [Fri, 15 Apr 2022 23:15:42 +0000 (08:45 +0930)]
Delete unused COFF gas macro
* config/obj-coff.h (sy_obj): Don't define.
(OBJ_SYMFIELD_TYPE): Revise comments.
GDB Administrator [Thu, 21 Apr 2022 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in
Aaron Merey [Fri, 8 Apr 2022 22:50:56 +0000 (18:50 -0400)]
gdb/debuginfod: Prevent out_of_range exception
Trailing whitespace in the string of debuginfod URLs causes an
out_of_range exception during the printing of URLs for the first
use notice.
To fix this, stop printing URLs when the substring to be printed
consists only of whitespace.
Also add first use notice testcases.
Co-Authored-By: Pedro Alves <pedro@palves.net>
Lancelot SIX [Thu, 14 Apr 2022 09:41:48 +0000 (10:41 +0100)]
gdb/testsuite: Introduce and use gdb_spawn_attach_cmdline
Following
a7e6a19e87f3d719ea23c65b580a6d9bca4ccab3 "gdb: testsuite: add
new gdb_attach to check "attach" command", this commit proposes to
introduce the gdb_spawn_attach_cmdline helper and use it in
gdb.base/attach.exp.
This helper starts GDB and adds the "--pid=$PID" argument.
Also note that both the original and new implementation use
gdb_spawn_with_cmdline_opts, which in the end uses default_gdb_spawn.
This makes sure that we use $INTERNAL_GDBFLAGS, which by default already
contain "-iex \"set height 0\" -iex \"set width 0\"". To avoid
repetition of those arguments, gdb_spawn_attach_cmdline does not repeat
those arguments.
To maintain a behavior similat to what gdb.base/attach.exp used to do,
gdb_spawn_attach_cmdline keeps the -quiet flag.
Tested on x86_64-gnu-linux
Change-Id: I1fdcdb71c86d9c5d34bb28fc86fac68bcec37358
Tom Tromey [Mon, 18 Apr 2022 02:00:59 +0000 (20:00 -0600)]
Replace symbol_symtab with symbol::symtab
This turns symbol_symtab into a method on symbol. It also replaces
symbol_set_symtab with a method.
Tom Tromey [Mon, 18 Apr 2022 01:47:22 +0000 (19:47 -0600)]
Replace symbol_arch with symbol::arch
This turns symbol_arch into a method on symbol.
Tom Tromey [Mon, 18 Apr 2022 01:44:20 +0000 (19:44 -0600)]
Replace symbol_objfile with symbol::objfile
This turns symbol_objfile into a method on symbol.
Tom Tromey [Sat, 16 Apr 2022 18:49:50 +0000 (12:49 -0600)]
Remove symbol::aclass_index
Symbols have an aclass_index method, but this isn't needed, because
the aclass index isn't useful outside of the symbol implementation.
Tom Tromey [Sat, 16 Apr 2022 18:36:47 +0000 (12:36 -0600)]
Use array_view for symbol_impls
It seemed to me that using array_view for symbol_impls would give a
bit more error checking, at least when gdb is built in libstdc++ debug
mode.
Tom Tromey [Sat, 16 Apr 2022 18:33:56 +0000 (12:33 -0600)]
Add accessors for symbol's artificial field
For a series I'm experimenting with, it was handy to hide a symbol's
"artificial" field behind accessors. This patch is the result.
Tom Tromey [Tue, 23 Nov 2021 00:05:55 +0000 (17:05 -0700)]
Unify the DWARF index holders
The dwarf2_per_bfd object has a separate field for each possible kind
of index. Until an earlier patch in this series, two of these were
even derived from a common base class, but still had separate slots.
This patch unifies all the index fields using the common base class
that was introduced earlier in this series. This makes it more
obvious that only a single index can be active at a time, and also
removes some code from dwarf2_initialize_objfile.
Tom Tromey [Mon, 22 Nov 2021 23:53:34 +0000 (16:53 -0700)]
Add an ad hoc version check to dwarf_scanner_base
Some generic code in the DWARF reader has a special case for older
versions of .gdb_index. This patch adds an ad hoc version check
method so that these spots can work without specific knowledge of
which index is in use.
Tom Tromey [Mon, 22 Nov 2021 23:50:46 +0000 (16:50 -0700)]
Simplify version check in dw2_symtab_iter_next
This simplifies the index versio check in dw2_symtab_iter_next, by
passing a reference to the index object to this function. This avoids
an indirection via the per_bfd object.
Tom Tromey [Mon, 22 Nov 2021 23:43:47 +0000 (16:43 -0700)]
Introduce and use dwarf_scanner_base
This introduces dwarf_scanner_base, a base class for all the index
readers in the DWARF code. Then, it changes both mapped_index_base
and cooked_index_vector to derive from this new base class.
Tom Tromey [Tue, 30 Mar 2021 02:14:30 +0000 (20:14 -0600)]
Introduce readnow_functions
This introduces readnow_functions, a new subclass of
dwarf2_base_index_functions, and changes the DWARF reader to use it.
This lets us drop the "index is NULL" hack from the gdb index code.
Tom Tromey [Tue, 30 Mar 2021 00:31:31 +0000 (18:31 -0600)]
Remove some "OBJF_READNOW" code from dwarf2_debug_names_index
The dwarf2_debug_names_index code treats a NULL debug_names_table as
if it were from OBJF_READNOW. However, this trick is only done for
gdb_index, never for debug_names -- see dwarf2_initialize_objfile.
Tom Tromey [Mon, 29 Mar 2021 23:58:21 +0000 (17:58 -0600)]
Let mapped index classes create the quick_symbol_functions object
This changes the mapped index classes to create the
quick_symbol_functions objects. This is a step toward having a more
abstract interface to mapped indices.
Tom Tromey [Mon, 29 Mar 2021 23:44:57 +0000 (17:44 -0600)]
Give mapped_index_base a virtual destructor
This changes mapped_index_base to have a virtual destructor, so it can
be destroyed via its base class.
Tom Tromey [Mon, 29 Mar 2021 23:42:36 +0000 (17:42 -0600)]
Move mapped_index_base to new header file
This moves mapped_index_base and the helper struct name_component to a
new header file in gdb/dwarf2/.
Jan Beulich [Wed, 20 Apr 2022 14:56:05 +0000 (16:56 +0200)]
x86: reject all invalid SAE variants
So far an SAE-only specifier was accepted for static-rounding insns,
while SAE-only insns didn't accept static rounding specifiers. If
anything it would make sense the other way around, allowing SAE-only
insns to have the (ignored) rounding mode specified individually rather
than globally via -mevexrcig=. But for now make things match the SDM.
Alan Modra [Wed, 20 Apr 2022 14:26:08 +0000 (23:56 +0930)]
Re: xcoff: implement linker relaxation
* xcofflink.c (xcoff_stub_csect_name): Increase buffer size.
(xcoff_stub_get_csect_in_range, xcoff_build_one_stub): Whitespace.
(bfd_xcoff_size_stubs): Cast PRIx64 arg to required type.
Don't use freed stub_name.
Alan Modra [Wed, 20 Apr 2022 13:54:46 +0000 (23:24 +0930)]
Revert "as: Reject unknown -gXXX option" testsuite
This reverts the test committed as part of
6ea673e2d6.
Cl?ment Chigot [Wed, 20 Apr 2022 14:11:47 +0000 (15:11 +0100)]
xcoff: implement linker relaxation
bfd/ChangeLog:
* coff-rs6000.c (xcoff_reloc_type_noop): Add info argument.
(xcoff_reloc_type_fail): Likewise.
(xcoff_reloc_type_pos): Likewise.
(xcoff_reloc_type_neg): Likewise.
(xcoff_reloc_type_rel): Likewise.
(xcoff_reloc_type_toc): Likewise.
(xcoff_reloc_type_ba): Likewise.
(xcoff_reloc_type_crel): Likewise.
(xcoff_reloc_type_tls): Likewise.
(xcoff_reloc_type_br): Add stub handler.
(xcoff_ppc_relocate_section): Add info to
xcoff_calculate_relocation.
(xcoff_stub_indirect_call_code): New constant.
(xcoff_stub_shared_call_code): Likewise.
(bfd_xcoff_backend_data): Add stub code fields.
(bfd_pmac_xcoff_backend_data): Likewise.
* coff64-rs6000.c (xcoff64_reloc_type_br): Add stub handler.
(xcoff64_ppc_relocate_section): Add info to
xcoff64_calculate_relocation.
(xcoff64_stub_indirect_call_code): New constant.
(xcoff64_stub_shared_call_code): Likewise.
(bfd_xcoff_backend_data): Add stub code fields.
(bfd_xcoff_aix5_backend_data): Likewise.
* libxcoff.h (struct xcoff_backend_data_rec): Add stub fields.
(bfd_xcoff_stub_indirect_call_code): New define.
(bfd_xcoff_stub_indirect_call_size): New define.
(bfd_xcoff_stub_shared_call_code): New define.
(bfd_xcoff_stub_shared_call_size): New define.
(xcoff_reloc_function): Add info argument.
(enum xcoff_stub_type): New enum.
(struct xcoff_stub_hash_entry): New structure.
* xcofflink.c (struct xcoff_link_hash_table): Add stub hash
table and params fields.
(xcoff_stub_hash_entry): New define.
(xcoff_stub_hash_lookup): New define.
(stub_hash_newfunc): New function.
(_bfd_xcoff_bfd_link_hash_table_free): Free the new stub hash
table.
(_bfd_xcoff_bfd_link_hash_table_create): Create the new stub
hash table.
(xcoff_link_add_symbols): Save rawsize for XTY_SD.
(bfd_xcoff_link_init): New function.
(xcoff_stub_csect_name): New function.
(xcoff_stub_get_csect_in_range): New function.
(xcoff_stub_name): New function.
(bfd_xcoff_get_stub_entry): New function.
(bfd_xcoff_type_of_stub): New function.
(xcoff_add_stub): New function.
(xcoff_build_one_stub): New function.
(bfd_xcoff_size_stubs): New function.
(bfd_xcoff_build_stubs): New function.
(xcoff_stub_create_relocations): New function.
(xcoff_link_input_bfd): Adapt relocations to stub.
(xcoff_write_global_symbol): Adapt to new TOC entries generated
for stubs.
(_bfd_xcoff_bfd_final_link): Handle stub file.
* xcofflink.h (struct bfd_xcoff_link_params): New structure.
ld/ChangeLog:
* emultempl/aix.em (params): New variable.
(stub_file): New variable.
(xcoff_add_stub_section): New function.
(xcoff_layout_sections_again): New function
(hook_in_stub): New function.
(_after_allocation): Add stub creation.
(_create_output_section_statements): Allocate stub file and
pass params to backend.
Cl?ment Chigot [Wed, 20 Apr 2022 14:07:50 +0000 (15:07 +0100)]
Stubs (added in a later patch) will generate new .loader symbols, once the allocations have been done. Thus, the .loader section cannot be layout before that.
bfd/ChangeLog:
* coff-rs6000.c (_bfd_xcoff_put_ldsymbol_name): Write len in
ldinfo->strings instead of directly in the output_bfd.
* coff64-rs6000.c (_bfd_xcoff64_put_ldsymbol_name): Likewise.
* xcofflink.c (struct xcoff_link_hash_table): Remove ldrel_count
field. Add ldinfo field.
(xcoff_mark_symbol): Adjust to new ldinfo field.
(xcoff_mark): Likewise.
(bfd_xcoff_link_count_reloc): Likewise.
(xcoff_build_loader_section): Split into two functions: one that
build the loader section (this function) and one that only size
it...
(xcoff_size_loader_section): ... (this function).
(bfd_xcoff_size_dynamic_sections): Adapt to new ldinfo field.
Move the part where the dynamic sections are build to ...
(bfd_xcoff_build_dynamic_sections): ... this function.
* xcofflink.h: Add bfd_xcoff_build_dynamic_sections prototype.
include/ChangeLog:
* coff/xcoff.h (struct xcoff_loader_info): Add ldrel_count and
libpath fields.
ld/ChangeLog:
* emultempl/aix.em (_after_allocation): New function.
Tom Tromey [Sat, 16 Apr 2022 20:19:18 +0000 (14:19 -0600)]
Use symbol_symtab accessor in compile-object-load.c
I noticed that compile-object-load.c directly references owner.symtab
of a symbol. However, I think it's better for all users to call
symbol_symtab. This patch makes this change.
Nick Clifton [Wed, 20 Apr 2022 12:37:51 +0000 (13:37 +0100)]
Add linker warning for when it creates an executable stack.
PR 29072
Tom Tromey [Wed, 20 Apr 2022 05:44:50 +0000 (23:44 -0600)]
Micro-optimize cooked_index_entry::full_name
I noticed that cooked_index_entry::full_name can return the canonical
string when there is no parent entry.
Regression tested on x86-64 Fedora 34.
Tiezhu Yang [Wed, 20 Apr 2022 09:48:53 +0000 (17:48 +0800)]
gdb: LoongArch: Implement loongarch_scan_prologue()
If can't determine prologue from the symbol table, need to examine
instructions. Implement loongarch_scan_prologue() to analyze the
function prologue from START_PC to LIMIT_PC, return the address of
the first instruction past the prologue.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
GDB Administrator [Wed, 20 Apr 2022 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sat, 16 Apr 2022 17:46:05 +0000 (10:46 -0700)]
as: Reject unknown -gXXX option
* as.c (parse_args): Reject unknown -gXXX option.
* testsuite/gas/all/empty.s: New file.
* testsuite/gas/all/pr29067.d: Likewise.
* testsuite/gas/all/pr29067.err: Likewise.
* testsuite/gas/all/gas.exp: Run pr29067.
Lancelot SIX [Tue, 22 Mar 2022 14:02:54 +0000 (10:02 -0400)]
gdb/selftest-arch: Make register_test_foreach_arch generate arch tests lazily
The register_test_foreach_arch is used to instantiate a given selftest
for all architectures supported by GDB. It is used in many _initialize_*
functions (under initialize_all_files, called by gdb_init).
Because the call is done during GDB's initialization, and because there
is no guaranty about the order in which all the _initialize_* functions
are executed, when register_test_foreach_arch is called, GDB is not
fully initialized. Specifically, when a particular initialize function
is executed, only the architectures registered at that point are listed
by gdbarch_printable_names.
As a consequence, the list of selftest effectively executed depends on
the order the _initialize_* functions are called. This can be observed
with the following:
$ ./gdb/gdb \
-data-directory ./gdb/data-directory \
-quiet -batch -ex "maint selftest" 2>&1 \
| grep -E "Ran [0-9]+ unit tests"
Ran 145 unit tests, 0 failed
$ GDB_REVERSE_INIT_FUNCTIONS=1 ./gdb/gdb \
-data-directory ./gdb/data-directory \
-quiet -batch -ex "maint selftest" 2>&1 \
| grep -E "Ran [0-9]+ unit tests"
Ran 82 unit tests, 0 failed
To fix this, make register_test_foreach_arch register a lazy selftest
generator. This way when the test generator is eventually executed, all
architectures are registered and we do not have a dependency on the
order the initialize functions are executed in.
Tested on x86_64-linux
Change-Id: I88eefebf7d372ad672f42d3a103e89354bc8a925
Lancelot SIX [Tue, 22 Mar 2022 12:09:40 +0000 (08:09 -0400)]
gdbsupport/selftest: Allow lazy registration
This patch adds a way to delay the registration of tests until the
latest possible moment. This is intended for situations where GDB needs
to be fully initialized in order to decide if a particular selftest can
be executed or not.
This mechanism will be used in the next patch.
Change-Id: I7f6b061f4c0a6832226c7080ab4e3a2523e1b0b0
Lancelot SIX [Wed, 23 Mar 2022 15:29:53 +0000 (15:29 +0000)]
gdbsupport/selftest: Replace for_each_selftest with an iterator_range
Remove the callback-based selftests::for_each_selftest function and use
an iterator_range instead.
Also use this iterator range in run_tests so all iterations over the
selftests are done in a consistent way. This will become useful in a
later commit.
Change-Id: I0b3a5349a7987fbcb0071f11c394e353df986583
Jan Beulich [Tue, 19 Apr 2022 07:26:17 +0000 (09:26 +0200)]
x86: don't mistake ordinary immediates for SAE / rounding control
The way SAE templates are constructed was always puzzling me (including
the need for separate templates in the first place), and expressing the
extzra attribute via Imm8 actually has a bad effect: Ordinary immediates
would also be accepted, leading to an extra byte being added after the
instruction (i.e. generating bad code). Before re-working this (in
particular to accept proper Intel syntax there), fix the immediate issue
by adding the so far missing check.
Jan Beulich [Tue, 19 Apr 2022 07:25:25 +0000 (09:25 +0200)]
x86: VCMPSH is Evex.LLIG
These were mistakenly flagged as Evex.128. Getting the LLIG status right
for insns allowing for SAE is a prereq for planned further work.
Jan Beulich [Tue, 19 Apr 2022 07:24:53 +0000 (09:24 +0200)]
x86: drop stray CheckRegSize from VFPCLASSPH
Like VFPCLASSP{S,D} it has only a single operand allowing multiple
sizes, hence there are no pairs of operands to check for consistent
size.
Jan Beulich [Tue, 19 Apr 2022 07:24:24 +0000 (09:24 +0200)]
x86/Intel: test non-legacy VCVT{,U}SI2SH insn forms
For an unclear reason corresponding AVX512F tests were apparently not
cloned or used as reference here, and instead the bogus legacy forms of
the insns (with the embedded rounding specifier not last) were used.
Jan Beulich [Tue, 19 Apr 2022 07:23:49 +0000 (09:23 +0200)]
x86: correct and simplify NOP disassembly
It's not just REX.W which is ignored with opcode 0x90. The same goes for
REX.R and REX.X as well as empty REX. None of these are forms of
"xchg %eax,%eax" (which would mean zero-extending %eax to %rax), so they
also shouldn't be disassembled this way.
While there simplify things: A single hook function suffices, thus
making it unnecessary to keep two expressions in sync. And checking
ins->address_mode for mode_64bit also is unnecessary, as "rex" can be
non-zero only in that case anyway.
GDB Administrator [Tue, 19 Apr 2022 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Thu, 7 Apr 2022 01:51:56 +0000 (21:51 -0400)]
gdb/testsuite/dwarf: don't automatically add directory and file entry for DWARF 5
To support DWARF 5 in the DWARF assembler line tables, we currently copy
the first user-provided directory and the first user-provided files and
make them elements at indices 0 in the directory and file name tables.
That was a sufficient behavior at the time (see commit
44fda089397a
("[gdb/testsuite] Support .debug_line v5 in dwarf assembler")), but in
the following patches, I would need to have finer grained control on
what is generated exactly. For example, I'd like to generate a DWARF 5 line
table with just a single file and a single directory.
Get rid of this behavior, and implement what is suggested in
44fda089397a: make include_dir return the directory index that can be
used to refer to that directory entry (based on the DWARF version), and
use it afterwards.
Adjust dw2-lines.exp and dw2-prologue-end.exp accordingly. Their produced
DWARF5 binaries will change a bit, in that they will now have a single
directory and file, where they had two before. But it doesn't change
the expected GDB behavior.
Change-Id: I5459b16ac9b7f28c34c9693c35c9afd2ebb3aa3b
Simon Marchi [Thu, 14 Apr 2022 00:12:37 +0000 (20:12 -0400)]
gdb: use gdb_tilde_expand instead of gdb_tilde_expand_up in source_script_with_search
Since this is the latest use of gdb_tilde_expand_up, remove it.
Change-Id: I964c812ce55fe087876abf91e7a3577ad79c0425
Simon Marchi [Wed, 13 Apr 2022 21:39:06 +0000 (17:39 -0400)]
gdbsupport: make gdb_realpath_keepfile return an std::string
I'm trying to switch these functions to use std::string instead of char
arrays, as much as possible. Some callers benefit from it (can avoid
doing a copy of the result), while others suffer (have to make one more
copy).
Change-Id: I793aab17baaef8345488f4c40b9094e2695425bc
Simon Marchi [Wed, 13 Apr 2022 21:31:02 +0000 (17:31 -0400)]
gdbsupport: make gdb_abspath return an std::string
I'm trying to switch these functions to use std::string instead of char
arrays, as much as possible. Some callers benefit from it (can avoid
doing a copy of the result), while others suffer (have to make one more
copy).
Change-Id: Iced49b8ee2f189744c5072a3b217aab5af17a993
Simon Marchi [Thu, 14 Apr 2022 00:03:18 +0000 (20:03 -0400)]
gdb: call gdb_tilde_expand instead of gdb_tilde_expand_up in source_script_with_search
This removes a use of gdb_tilde_expand_up, which is removed later in
this series.
Change-Id: I5887d526cea987103e4ca24514a982b0a28e992a
Tom Tromey [Mon, 18 Apr 2022 15:44:18 +0000 (09:44 -0600)]
Update gnulib
This updates gnulib to a relatively recent commit. Most of this was
done by the gnulib import script; the only change I made was to
update-gnulib.sh.
Tested on x86-64 Fedora 34. I also did a mingw cross build.
Tom Tromey [Sat, 2 Apr 2022 15:54:40 +0000 (09:54 -0600)]
Fix C++ cast of derived class to base class
PR c++/28907 points out that casting from a derived class to a base
class fails in some situations. The problem turned out to be a
missing use of value_embedded_offset. One peculiarity here is that,
if you managed to construct a pointer-to-derived with an embedded
offset of 0, the cast would work -- for example, one of the two new
tests here passes without the patch.
This embedded offset stuff is an endless source of bugs. I wonder if
it's possible to get rid of it somehow.
Regression tested on x86-64 Fedora 34.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28907
Simon Marchi [Thu, 14 Apr 2022 16:26:33 +0000 (12:26 -0400)]
gdb/testsuite: make gdb.ada/mi_prot.exp stop at expected location
This test attempts to run until the line marked "STOP", which is at
prot.adb:34. It first runs until the "main" symbol, then tries to place
a breakpoint by line at line 34, without specifying the source file. When looking at the logs:
-break-insert -t 34^M
^done,bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x0000555555558a6c",func="adafinal",file="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_pro t/b~prot.adb",fullname="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb",line="44",thread-groups=["i1"],times="0",original-location="/home/simark/b uild/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb:34"}^M
... continues ...
*stopped,reason="breakpoint-hit",disp="del",bkptno="2",frame={addr="0x0000555555558a6c",func="adafinal",args=[],file="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/ mi_prot/b~prot.adb",fullname="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb",line="44",arch="i386:x86-64"},thread-id="1",stopped-threads="all",co re="8"^M
... we see that the breakpoint is placed in some generated file, not in
the test source file as we expect. The problem is that "b main" in Ada
does not place a breakpoint on the "Ada main", but on some symbol in a
generated source file. So when stopped at the "main" symbol, we are not
stopped in the file that contains the STOP marker at line 34.
The test passes anyway today, so it doesn't seem to matter that we are
stopped at an unexpected location. But it starts failing with this
patch [1], because b~prot.adb:34 happens to be between two functions, so
the breakpoint doesn't resolve.
Fix this by placing the breakpoint at "$srcfile:$line", which works
regardless of what is the current source file.
However, this ends up introducing a path in the test name. Modify
mi_tbreak and mi_continue_to_line to avoid that.
[1] https://sourceware.org/pipermail/gdb-patches/2022-April/187686.html
Change-Id: I742e2a9993046dcb5e30c64fe2ad920a363baf75
Vignesh Balasubramanian [Wed, 30 Mar 2022 10:59:43 +0000 (16:29 +0530)]
gdb/testsuite: add text_segment option to gdb_compile
LLVM's lld linker doesn't have the "-Ttext-segment" option, but
"--image-base" can be used instead.
To centralize the logic of checking which option is supported, add the
text_segment option to gdb_compile. Change tests that are currently
using -Ttext-segment to use that new option instead.
This patch fixes only compilation error, for example:
Before:
$ make check TESTS="gdb.base/jit-elf.exp" RUNTESTFLAGS="CC_FOR_TARGET=clang LDFLAGS_FOR_TARGET=-fuse-ld=ld"
Running /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jit-elf.exp ...
gdb compile failed, clang-13: warning: -Xlinker -Ttext-segment=0x7000000: 'linker' input unused [-Wunused-command-line-argument]
After:
$ make check TESTS="gdb.base/jit-elf.exp" RUNTESTFLAGS="CC_FOR_TARGET=clang LDFLAGS_FOR_TARGET=-fuse-ld=ld"
Running /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jit-elf.exp ...
FAIL: gdb.base/jit-elf.exp: one_jit_test-1: continue to breakpoint: break here 1
FAIL: gdb.base/jit-elf.exp: one_jit_test-1: continue to breakpoint: break here 2
FAIL: gdb.base/jit-elf.exp: one_jit_test-2: continue to breakpoint: break here 1
FAIL: gdb.base/jit-elf.exp: one_jit_test-2: info function ^jit_function
FAIL: gdb.base/jit-elf.exp: one_jit_test-2: continue to breakpoint: break here 2
FAIL: gdb.base/jit-elf.exp: attach: one_jit_test-2: continue to breakpoint: break here 1
FAIL: gdb.base/jit-elf.exp: attach: one_jit_test-2: break here 1: attach
FAIL: gdb.base/jit-elf.exp: PIE: one_jit_test-1: continue to breakpoint: break here 1
FAIL: gdb.base/jit-elf.exp: PIE: one_jit_test-1: continue to breakpoint: break here 2
=== gdb Summary ===
# of expected passes 26
# of unexpected failures 9
Change-Id: I3678c5c9bbfc2f80671698e28a038e6b3d14e635
Enze Li [Sun, 17 Apr 2022 07:09:46 +0000 (15:09 +0800)]
gdb: fix using clear command to delete non-user breakpoints(PR cli/7161)
The clear command shouldn't delete momentary and internal breakpoints,
nor internal breakpoints created via Python's gdb.Breakpoint.
This patch fixes this issue and adds a testcase.
Regression tested on x86_64 openSUSE Tumbleweed(VERSION_ID="
20220413").
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7161
GDB Administrator [Mon, 18 Apr 2022 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 17 Apr 2022 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Sat, 16 Apr 2022 19:58:34 +0000 (13:58 -0600)]
Add comments to dwarf2/abbrev-cache.h
This patch started when I noticed that the unordered_set include
wasn't needed in abbrev-cache.h. (That was probably leftover from
some earlier implementation of the class.) Then, I noticed that the
class itself was under-commented. This patch fixes both issues.
GDB Administrator [Sat, 16 Apr 2022 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Sat, 2 Apr 2022 01:04:48 +0000 (19:04 -0600)]
Return void from gdb_putc
I don't think it's very useful to return the character from gdb_putc,
so this patch changes it to return void.
Tom Tromey [Sun, 9 Jan 2022 02:37:38 +0000 (19:37 -0700)]
Handle "set height 1"
PR cli/17151 points out that "set height 1" has pathological behavior
in gdb. What I see is that gdb will endlessly print the pagination
prompt. This patch takes a simple and expedient approach to a fix:
pretend that the height is really 2.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17151
Tom Tromey [Sun, 9 Jan 2022 01:26:35 +0000 (18:26 -0700)]
Allow word wrapping even when paging is disabled
PR cli/20741 points out that when pagination is disabled, this also
disabled word wrapping. However, the manual documents that these
settings are separate -- if you intend to disable the wrapping, you
must use "set width unlimited".
This patch fixes the bug by letting the pagination-disabled case fall
through to the code that also handles word-wrapping.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20741
Tom Tromey [Sun, 27 Mar 2022 21:29:28 +0000 (15:29 -0600)]
Implement value_print for Rust
This adds an implementation of the value_print method to Rust. As
described in PR rust/22254, this removes a bit of weird-looking output
from some "print"s -- because c_value_print is bypassed. I don't have
a test for the bug that inspired this patch, because I only know how
to reproduce it when using a relatively old Rust compiler. However,
the new "cast-printing" code in value_print is required, because
omitting this causes some existing tests to fail.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22254
Tom Tromey [Fri, 25 Mar 2022 19:36:53 +0000 (13:36 -0600)]
Reimplement Rust slice printing
The current nightly Rust compiler (aka 1.61) added better DWARF
representation for unsized types. Fixing this is PR rust/21466; but
the code is actually the same as what is required to make slice
printing more useful, which is PR rust/23871. This patch implements
this. I tested this against various Rust compilers: 1.48, current
stable, current beta, and current nightly.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21466
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23871
Tom Tromey [Fri, 25 Mar 2022 19:43:27 +0000 (13:43 -0600)]
Remove some dead code from the Rust value printer
This removes a bit of dead code from the Rust value printer. This
code wasn't always dead -- it fixed a real bug, and a test case was
added for it. However, once val_print was removed, it became
unnecessary.
Tom Tromey [Fri, 25 Mar 2022 19:36:32 +0000 (13:36 -0600)]
Match rustc beta versions
The rust_compiler_version proc extracts the Rust compiler version from
the "rustc --version" output. For a beta compiler, the output looks
like:
rustc 1.60.0-beta.6 (
7bccde197 2022-03-22)
This patch slightly relaxes the regexp -- removing a space -- so that
this can be understood by this proc.
Tom de Vries [Fri, 15 Apr 2022 16:00:30 +0000 (18:00 +0200)]
[gdb/testsuite] Fix gdb.ada/float-bits.exp with -m32
With test-case gdb.ada/float-bits.exp and native we get:
...
(gdb) print 16llf#
7FFFF7FF4054A56FA5B99019A5C8#^M
$9 = 5.0e+25^M
(gdb) PASS: gdb.ada/float-bits.exp: print 16llf#
7FFFF7FF4054A56FA5B99019A5C8#
...
but with target board unix/-m32 we have instead:
...
(gdb) print 16llf#
7FFFF7FF4054A56FA5B99019A5C8#^M
Cannot export value
2596145952482202326224873165792712 as 96-bits \
unsigned integer (must be between 0 and
79228162514264337593543950335)^M
(gdb) FAIL: gdb.ada/float-bits.exp: print 16llf#
7FFFF7FF4054A56FA5B99019A5C8#
...
Fix this by testing whether 16llf is supported by doing ptype long_long_float
which gets us either:
...
type = <16-byte float>^M
...
or:
...
type = <12-byte float>^M
...
Tested on x86_64-linux with native and unix/-m32.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29041
Tom Tromey [Fri, 4 Mar 2022 20:35:37 +0000 (13:35 -0700)]
Remove WITH_SIM define
Since score-tdep.c was removed, the WITH_SIM define is not used in
gdb. This patch removes it.
Note that re-running autoheader shows a separate change that was
missed. I've kept it in this patch to avoid extra work.
Tom de Vries [Fri, 15 Apr 2022 14:53:08 +0000 (16:53 +0200)]
[gdb/testsuite] Fix gdb.go/methods.exp with check-readmore
When running test-case gdb.go/methods.exp with make check we have:
...
(gdb) break main.T.Foo^M
Function "main.T.Foo" not defined.^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) XFAIL: gdb.go/methods.exp: gdb_breakpoint: set breakpoint at main.T.Foo
...
but with make check-readmore the XFAIL fails to trigger:
...
(gdb) break main.T.Foo^M
Function "main.T.Foo" not defined.^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) FAIL: gdb.go/methods.exp: gdb_breakpoint: set breakpoint at main.T.Foo
...
This happens because this gdb_test_multiple "maintenance print symbols"
regexp:
...
-re "\r\n$gdb_prompt $" {
...
matches the entire command output.
Fix this by adding the missing ^ at the regexp start.
Tested on x86_64-linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29064
GDB Administrator [Fri, 15 Apr 2022 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Tue, 29 Mar 2022 12:32:48 +0000 (13:32 +0100)]
gdbserver: Eliminate prepare_to_access_memory
Given:
- The prepare_to_access_memory machinery was added for non-stop mode.
- Only Linux supports non-stop.
- Linux no longer needs the prepare_to_access_memory machinery. In
fact, after the previous patch,
linux_process_target::prepare_to_access_memory became a nop.
Thus, prepare_to_access_memory can go away, simplifying core GDBserver
code.
Change-Id: I93ac8bfe66bd61c3d1c4a0e7d419335163120ecf
Pedro Alves [Mon, 28 Mar 2022 17:35:34 +0000 (18:35 +0100)]
gdbserver/linux: Access memory even if threads are running
Similarly to how the native Linux target was changed
and subsequently reworked in these commits:
05c06f318fd9 Linux: Access memory even if threads are running
8a89ddbda2ec Avoid /proc/pid/mem races (PR 28065)
... teach GDBserver to access memory even when the current thread is
running, by always accessing memory via /proc/PID/mem.
The existing comment:
/* Neither ptrace nor /proc/PID/mem allow accessing memory through a
running LWP. */
... is incorrect for /proc/PID/mem does allow that.
Actually, from GDB's perspective, GDBserver could already access
memory while threads were running, but at the expense of pausing all
threads for the duration of the memory access, via
prepare_to_access_memory. This new implementation does not require
pausing any thread, thus
linux_process_target::prepare_to_access_memory /
linux_process_target::done_accessing_memory become nops. A subsequent
patch will remove the whole prepare_to_access_memory infrastructure
completely.
The GDBserver linux-low.cc implementation is simpler than GDB's
linux-nat.c's, because GDBserver always adds the unfollowed vfork/fork
children to the process list immediately when the fork/vfork event is
seen out of ptrace. I.e., there's no need to keep the file descriptor
stored on a side map, we can store it directly in the process
structure.
Change-Id: I0abfd782ceaa4ddce8d3e5f3e2dfc5928862ef61
Pedro Alves [Thu, 31 Mar 2022 21:04:42 +0000 (22:04 +0100)]
gdbserver: special case target_write_memory len==0
The next patch in this series adds a common helper routine for both
memory reads and writes, like this:
static int
proc_xfer_memory (CORE_ADDR memaddr, unsigned char *readbuf,
const gdb_byte *writebuf, int len)
{
gdb_assert ((readbuf == nullptr) != (writebuf == nullptr));
...
}
int
linux_process_target::read_memory (CORE_ADDR memaddr,
unsigned char *myaddr, int len)
{
return proc_xfer_memory (memaddr, myaddr, nullptr, len);
}
linux_process_target::write_memory (CORE_ADDR memaddr,
const unsigned char *myaddr, int len)
{
return proc_xfer_memory (memaddr, nullptr, myaddr, len);
}
Surprisingly, the assertion fails. That happens because it can happen
that target_write_memory is called with LEN==0, due to this in
gdb/remote.c:
/* Determine whether the remote target supports binary downloading.
This is accomplished by sending a no-op memory write of zero length
to the target at the specified address. (...) */
void
remote_target::check_binary_download (CORE_ADDR addr)
{
...
p = rs->buf.data ();
*p++ = 'X';
p += hexnumstr (p, (ULONGEST) addr);
*p++ = ',';
p += hexnumstr (p, (ULONGEST) 0);
*p++ = ':';
*p = '\0';
In this scenario, in gdbserver's target_write_memory, the "myaddr"
argument of the_target->write_memory is passed the data() of a local
gdb::byte_vector (which is a specialized std::vector). It's valid for
std::vector::data() to return NULL when the vector is empty.
This commit adds an early return to target_write_memory to avoid
target backends having to care about this. For good measure, do the
same on the read side, in read_inferior_memory.
Change-Id: Iac8f04fcf99014c624ef4036bd318ca1771ad491
Pedro Alves [Tue, 29 Mar 2022 11:57:17 +0000 (12:57 +0100)]
gdbserver/qXfer::threads, prepare_to_access_memory=>target_pause_all
handle_qxfer_threads_proper needs to pause all threads even if the
target can read memory when threads are running, so use
target_pause_all instead, which is what the Linux implementation of
prepare_to_access_memory uses. (Only Linux implements this hook.)
A following patch will make the Linux backend be able to access memory
when threads are running, and thus will also make
prepare_to_access_memory do nothing, which would cause testsuite
regressions without this change.
Change-Id: I127fec7246b7c45b60dfa7341e781606bf54b5da
Tom Tromey [Thu, 14 Apr 2022 15:36:09 +0000 (09:36 -0600)]
Ignore 0,0 entries in .debug_aranges
When running the internal AdaCore test suite against the new DWARF
indexer, I found one regression on RISC-V. The test in question uses
--gc-sections, and winds up with an entry in the middle of a
.debug_aranges that has both address and length of 0. In this
scenario, gdb assumes the entries are terminated and then proceeds to
reject the section because it reads a subsequent entry as if it were a
header.
It seems to me that, because each header describes the size of each
.debug_aranges CU, it's better to simply ignore 0,0 entries and simply
read to the end. That is what this patch does.
I've patched an existing test to provide a regression test for this.
Tom Tromey [Wed, 13 Apr 2022 14:45:34 +0000 (08:45 -0600)]
Use GetThreadDescription on Windows
Windows 10 introduced SetThreadDescription and GetThreadDescription, a
simpler way to set a thread's name. This changes gdb and gdbserver to
use this convention when it is available.
This is part of PR win32/29050.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29050
Tom Tromey [Wed, 13 Apr 2022 14:12:52 +0000 (08:12 -0600)]
Set the worker thread name on Windows
This patch is a bit different from the rest of the series, in that it
is a change to gdb's behavior on the host. It changes gdb's thread
pool to try to set the thread name on Windows, if SetThreadDescription
is available.
This is part of PR win32/29050.
This patch isn't likely to be useful to many people in the short term,
because the Windows port of the libstdc++ thread code is not upstream.
(AdaCore uses it, and sent it upstream, but it did not land, I don't
know why.) However, if that patch does ever go in, or presumably if
you build using some other C++ runtime library, then this will be
useful.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29050
Tom Tromey [Tue, 12 Apr 2022 20:27:13 +0000 (14:27 -0600)]
Implement thread_name for gdbserver
This changes gdbserver to implement thread_name method.
Tom Tromey [Tue, 12 Apr 2022 20:25:44 +0000 (14:25 -0600)]
Share handle_ms_vc_exception with gdbserver
Currently, gdb's native Windows target implements the exception-based
approach for setting thread names, but gdbserver does not. This patch
moves handle_ms_vc_exception to the shared nat/windows-nat.c code, as
preparation for adding this support to gdbserver.
Tom Tromey [Wed, 13 Apr 2022 12:42:19 +0000 (06:42 -0600)]
Move target_read_string to target/target.c
This moves the two overloads of target_read_string to a new file,
target/target.c, and updates both gdb and gdbserver to build this.
Tom Tromey [Wed, 13 Apr 2022 12:32:28 +0000 (06:32 -0600)]
Remove the byte order parameter to target_read_string
target_read_string takes a byte order parameter, but only uses this to
check whether a given character is zero. This is readily done without
requiring the parameter, so remove it.
Tom Tromey [Wed, 13 Apr 2022 12:25:07 +0000 (06:25 -0600)]
Rename read_string
This renames read_string to be an overload of target_read_string.
This makes it more consistent for the eventual merger with gdbserver.
Tom Tromey [Tue, 12 Apr 2022 20:40:16 +0000 (14:40 -0600)]
Don't call QUIT in read_string
read_string does not need to call QUIT, because target_read_memory
already does. This change is needed to make string-reading usable by
gdbserver.
Tom Tromey [Wed, 13 Apr 2022 12:55:30 +0000 (06:55 -0600)]
Fix possible Cygwin build problem
I noticed that nat/windows-nat.c checks __USEWIDE, but nothing sets it
there -- I forgot to copy over the definition when making this file.
This patch tries to fix the problem. I don't have a Cygwin setup, so
I don't know whether this is sufficient, but it's probably necessary.
Lancelot SIX [Thu, 14 Apr 2022 17:21:04 +0000 (18:21 +0100)]
gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp
Pedro Alves warned me that there is a race in
gdb.dwarf2/calling-convention.exp making the test sometimes fail on his
setup. This can be reliably reproduced using :
make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"
The relevant part of the gdb.log file is:
return 35
Function 'foo' does not follow the target calling convention.
If you continue, setting the return value will probably lead to unpredictable behaviors.
Make foo return now? (y or n) PASS: gdb.dwarf2/calling-convention.exp: return 35
n
Not confirmed
(gdb) FAIL: gdb.dwarf2/calling-convention.exp: finish
The issue is that when doing the test for "return 35", the DejaGnu test
sends "n" (to tell GDB not to perform the return action) but never
consumes the "Not confirmed" acknowledgment sent by GDB. Later, when
trying to do the next test, DejaGnu tries to match the leftover output
from the "return" test. As this output is not expected, the test fails.
Fix by using gdb_test to send the "n" answer and match the confirmation
and consume all output to the prompt.
Also do minor adjustments to the main regex:
- Remove the leading ".*" which is not required.
- Ensure that the "?" from the question is properly escaped.
Tested on x86_64-gnu-linux, using
- make check TESTS="gdb.dwarf2/calling-convention.exp"
- make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"
- make check-readmore TESTS="gdb.dwarf2/calling-convention.exp"
Co-authored-by: Pedro Alves <pedro@palves.net>
Change-Id: I42858b13db2cbd623c5c1739de65ad423e0c0938
Tom Tromey [Thu, 7 Apr 2022 16:17:02 +0000 (10:17 -0600)]
Silence -Wmaybe-uninitialized warning from target_waitstatus
Currently, one use of target_waitstatus yields a warning:
target/waitstatus.h: In function 'void stop_all_threads()':
target/waitstatus.h:175:13: warning: 'ws.target_waitstatus::m_value' may be used uninitialized in this function [-Wmaybe-uninitialized]
175 | m_value = other.m_value;
| ~~~~~~~~^~~~~~~~~~~~~~~
This patch silences the warning. I tried the "volatile member"
approach that was used for gdb::optional, but that didn't work, so
this patch simply initializes the member.
Tom Tromey [Thu, 31 Mar 2022 13:55:09 +0000 (07:55 -0600)]
Fix regression on Windows with WOW64
Internally at AdaCore, we recently started testing a 64-bit gdb
debugging 32-bit processes. This failed with gdb head, but not with
gdb 11.
The tests fail like this:
Starting program: [...].exe
warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for NOT_AN_IMAGE.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for NOT_AN_IMAGE.
Do you need "set solib-search-path" or "set sysroot"?
After some debugging and bisecting, to my surprise the bug was
introduced by commit
183be222 ("gdb, gdbserver: make target_waitstatus
safe").
The problem occurs in handle_exception. Previously the code did:
- ourstatus->kind = TARGET_WAITKIND_STOPPED;
[...]
case EXCEPTION_BREAKPOINT:
[...]
- ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
[...]
/* FALLTHROUGH */
case STATUS_WX86_BREAKPOINT:
DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT");
- ourstatus->value.sig = GDB_SIGNAL_TRAP;
[...]
- last_sig = ourstatus->value.sig;
However, in the new code, the fallthrough case does:
+ ourstatus->set_stopped (GDB_SIGNAL_TRAP);
... which changes the 'kind' in 'ourstatus' after falling through.
This patch rearranges the 'last_sig' setting to more closely match
what was done before (this is probably not strictly needed but also
seemed harmless), and removes the fall-through in the
'ignore_first_breakpoint' case when __x86_64__ is defined.