Alan Modra [Fri, 9 Oct 2020 06:26:33 +0000 (16:56 +1030)]
[GOLD] Power10 segv due to wild r2
Calling non-pcrel functions from pcrel code requires a stub to set up
r2. Gold created the stub, but an "optimisation" made the stub jump
to the function local entry, ie. r2 was not initialised.
This patch fixes that long branch stub problem, and another that might
occur for plt call stubs to local functions.
bfd/
* elf64-ppc.c (write_plt_relocs_for_local_syms): Don't do local
entry offset optimisation.
gold/
* powerpc.cc (Powerpc_relobj::do_relocate_sections): Don't do
local entry offset optimisation for lplt_section.
(Target_powerpc::Branch_info::make_stub): Don't add local
entry offset to long branch dest passed to
add_long_branch_entry. Do pass st_other bits.
(Stub_table::Branch_stub_ent): Add "other_" field.
(Stub_table::add_long_branch_entry): Add "other" param, and
save.
(Stub_table::branch_stub_size): Adjust long branch offset.
(Stub_table::do_write): Likewise.
(Target_powerpc::Relocate::relocate): Likewise.
Alan Modra [Fri, 9 Oct 2020 00:29:33 +0000 (10:59 +1030)]
[GOLD] internal error in relocate, at powerpc.cc:10473
GOT relocations can refer directly to a function in a fixed position
executable, unlike ADDR64 which needs a global entry stub, or branch
relocs, which need PLT stubs.
* powerpc.cc (is_got_reloc): New function.
(Target_powerpc::Relocate::relocate): Use it here, exclude GOT
relocs when looking for stubs.
The previous GNU_PROPERTY_X86_ISA_1_XXX macros are deprecated and renamed
to GNU_PROPERTY_X86_COMPAT_2_ISA_1_XXX.
In addition to EM_X86_64, GNU_PROPERTY_X86_ISA_1_V[234] marker can be used
by ld.so to detect the x86-64-v4 shared library placed in an x86-64-v2
directory by mistake on an x86-64-v2 machine to avoid crashes on x86-64-v4
instructions.
Add -z x86-64-v[234] linker command line option to mark x86-64-v[234]
ISA level as needed.
gdb: Have allocate_target_description return a unique_ptr
There were a few places where we could (should?) have delayed
releasing the target_desc_up until a little later. This commit
catches these cases.
In the case of ARC, the target_desc_up is now exposed right out to
gdbserver, which means making a small change there too.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* arch/aarch32.c (aarch32_create_target_description): Release the
target_desc_up as late as possible.
* arch/aarch64.c (aarch64_create_target_description): Likewise.
* arch/amd64.c (amd64_create_target_description): Likewise.
* arch/arc.c (arc_create_target_description): Return a
target_desc_up, don't release it.
* arch/arc.h (arc_create_target_description): Update declaration.
(arc_lookup_target_description): Move target_desc_up into the
cache, and return a borrowed pointer.
* arch/arm.c (arm_create_target_description): Release the
target_desc_up as late as possible.
* arch/i386.c (i386_create_target_description): Likewise.
* arch/riscv.h (riscv_create_target_description): Update
declaration to match definition.
* arch/tic6x.c (tic6x_create_target_description): Release the
target_desc_up as late as possible.
gdbserver/ChangeLog:
* linux-arc-low.cc (arc_linux_read_description): Release the
unique_ptr returned from arc_create_target_description.
that the solution might be to make use of $(LIB_GETRANDOM), a variable
defined in the gnulib makefile, when linking GDB.
In fact I think the issue is bigger than just LIB_GETRANDOM. When
using the script binutils-gdb/gnulib/update-gnulib.sh to reimport
gnulib there is a lot of output from gnulib's gnulib-tool. Part of
that output is this:
You may need to use the following makefile variables when linking.
Use them in <program>_LDADD when linking a program, or
in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library.
$(FREXPL_LIBM)
$(FREXP_LIBM)
$(INET_NTOP_LIB)
$(LIBTHREAD)
$(LIB_GETLOGIN)
$(LIB_GETRANDOM)
$(LIB_HARD_LOCALE)
$(LIB_MBRTOWC)
$(LIB_SETLOCALE_NULL)
$(LTLIBINTL) when linking with libtool, $(LIBINTL) otherwise
What I think this is telling us is that we should be including the
value of all these variables on the link line for gdb and gdbserver.
The problem though is that these variables are define in gnulib's
makefile, but are not (necessarily) defined in GDB's makefile.
One solution would be to recreate the checks that gnulib performs in
order to recreate these variables in both gdb's and gdbserver's
makefile. Though this shouldn't be too hard, most (if not all) of
these checks are in the form macros defined in m4 files in the gnulib
tree, so we could just reference these as needed. However, in this
commit I propose a different solution.
Currently, in the top level makefile, we give gdb and gdbserver a
dependency on gnulib. Once gnulib has finished building gdb and
gdbserver can start, these projects then have a hard coded (relative)
path to the compiled gnulib library in their makefiles.
In this commit I extend the gnulib configure script to install a new
makefile fragment in the gnulib build directory. This new file will
have the usual variable substitutions applied to it, and so can
include the complete list (see above) of all the extra libraries that
are needed when linking against gnulib.
In fact the new makefile fragment defines three variables, these are:
LIBGNU: The path to the archive containing gnulib. Can be used as a
dependency as when this file changes gdb/gdbserver should be
relinked.
LIBGNU_EXTRA_LIBS: A list of linker -l.... flags that should be
included in the link line of gdb/gdbserver. These are
libraries that $(LIBGNU) depends on. This list is taken from
the output of gnulib-tool, which is run by our
gnulib/update-gnulib.sh script.
INCGNU: A list of -I.... include paths that should be passed to the
compiler, these are where the gnulib headers can be found.
Now both gdb and gdbserver can include the makefile fragment and make
use of these variables.
The makefile fragment relies on the variable GNULIB_BUILDDIR being
defined. This is checked for in the fragment, and was already defined
in the makefiles of gdb and gdbserver.
gdb/ChangeLog:
* Makefile.in: Include Makefile.gnulib.inc. Don't define LIBGNU
or INCGNU. Make use of LIBGNU_EXTRA_LIBS when linking.
gdbserver/ChangeLog:
* Makefile.in: Include Makefile.gnulib.inc. Don't define LIBGNU
or INCGNU. Make use of LIBGNU_EXTRA_LIBS when linking.
gnulib/ChangeLog:
* Makefile.gnulib.inc.in: New file.
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Install the new file.
Tom Tromey [Fri, 9 Oct 2020 01:41:45 +0000 (19:41 -0600)]
Style more output of "disassemble" command
I noticed a couple of spots where the "disassemble" could style its
output, but currently does not. This patch adds styling to the
function name at the start of the disassembly, and any addresses
printed there.
gdb/ChangeLog
2020-10-08 Tom Tromey <tom@tromey.com>
* cli/cli-cmds.c (print_disassembly): Style function name and
addresses. Add _() wrappers.
gdb/testsuite/ChangeLog
2020-10-08 Tom Tromey <tom@tromey.com>
* gdb.base/style.exp: Check that "main"'s name is styled.
Andrew Burgess [Mon, 20 Jul 2020 13:18:04 +0000 (14:18 +0100)]
gdb: Have allocate_target_description return a unique_ptr
Update allocate_target_description to return a target_desc_up, a
specialisation of unique_ptr.
This commit does not attempt to make use of the unique_ptr in the
best possible way, in almost all cases we immediately release the
pointer from within the unique_ptr and then continue as before.
There are a few places where it was easy to handle the unique_ptr, and
in these cases I've done that.
Everything under gdb/features/* is auto-regenerated.
There should be no user visible changes after this commit.
Alan Modra [Wed, 7 Oct 2020 23:57:43 +0000 (10:27 +1030)]
[GOLD] Increase --split-stack-adjust-size
For functions with small (< 256 bytes) stack frames, the current x86
do_calls_non_split ignores --split-stack-adjust-size and, in
combination with __morestack_non_split, supplies a non-split-stack
function with at least 0x100000 (1M) available stack. On powerpc64, a
default of 0x4000 is not large enough to reliably work with the golang
testsuite. This increase the default size to the defacto x86 value.
* options.h (split_stack_adjust_size): Default to 0x100000.
Tom Tromey [Wed, 7 Oct 2020 18:07:55 +0000 (12:07 -0600)]
Move simple_search_memory to gdbsupport/search.cc
This moves the simple_search_memory function to a new file,
gdbsupport/search.cc. The API is slightly changed to make it more
general. This generality is useful for wiring it to gdbserver, and
also for unit testing.
gdb/ChangeLog
2020-10-07 Tom Tromey <tromey@adacore.com>
Simon Marchi [Wed, 7 Oct 2020 17:58:57 +0000 (13:58 -0400)]
gdb: put user-supplied CFLAGS at the end
GDB currently doesn't build cleanly with clang (a -Wdeprecated-copy-dtor
error). I configured my clang-based GDB build with
CXXFLAGS="-Wno-error=deprecated-copy-dtor", so I can use it despite that
problem. However, I found that it had no effect. This is because my
-Wno-error=Wdeprecated-copy-dtor switch is followed by -Werror in the
command line, which switches back all warnings to be errors.
If we want the user-supplied C(XX)FLAGS to be able to override flags
added by our configure script, the user-supplied C(XX)FLAGS should
appear after the configure-supplied flags.
This patch moves the user-supplied CXXFLAGS at the very end of the
compilation command line, which fixes the problem described above. This
means moving it out of INTERNAL_CFLAGS and inlining it in the users of
INTERNAL_CFLAGS.
I observed the problem when building GDB, but the same problem could
happen with GDBserver, so the change is done there too.
In GDBserver, INTERNAL_CFLAGS is passed when linking
Add Makefile.in entry for "Add NetBSD/aarch64 gdbserver support"
The support is on par with NetBSD/amd64, thus GPR works,
single step and software breakpoint are operational, and the
SVR4 r_debug integration is functional.
Anton Kolesov [Mon, 30 Jan 2017 15:32:10 +0000 (18:32 +0300)]
arc: Add support for Linux coredump files
With the implemenations in this patch, ARC gdb can handle
coredump related matters. The binutils counter part of
this patch has already been pushed [1].
v2 [2]:
- arc_linux_collect_gregset: Use "reg <= ARC_LAST_REGNUM" instead of
"reg < ARC_LAST_REGNUM" for the condition check of the for-loop.
- arc-linux-tdep.c: Use "ARC_LAST_REGNUM < ARRAY_SIZE (...)" instead of
"ARC_LAST_REGNUM <= ARRAY_SIZE (...)" for the "asserts".
- Use "buf + arc_linux_core_reg_offsets[ARC_ERET_REGNUM]" instead of
"buf + REG_OFF (6)".
- Fix a few typos/indentation.
v3 [3]:
- Use gdb_assert_not_reached(text) instead of gdb_assert (!text).
- Remove unnecessary braces in the for loop.
[1] arc: Add support for ARC HS extra registers in core files
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=2745674244d6aecddcf636475034bdb9c0a6b4a0
[2] First remarks
https://sourceware.org/pipermail/gdb-patches/2020-September/171912.html
[3] Second remarks
https://sourceware.org/pipermail/gdb-patches/2020-October/172302.html
Anton Kolesov [Wed, 6 Jul 2016 17:30:29 +0000 (20:30 +0300)]
gdbserver: Add GNU/Linux support for ARC
This gdbserver implementation supports ARC ABI v3 and v4 (older ARC ABI
versions are not supported by other modern GNU tools or Linux itself).
Gdbserver supports inspection of ARC HS registers R30, R58 and R59 - feature
that has been added to Linux 4.12. Whether gdbserver build will actually
support this feature depends on the version of Linux headers used to build
the server.
v2 [1]:
- Use "this->read_memory ()" instead of "the_target->read_memory ()".
- Remove the unnecessary "arch-arc.o:" target from the "Makefile.in".
- Got rid of "ntohs()" function and added lots of comments about
endianness.
- Clarify why "pc" value is read from and saved to different fields
in user regs struct.
- In function "is_reg_name_available_p()", use a range-based iterator
to loop over the registers.
- Removed mentioning of issue number that was not related to sourceware.
- A few typo's fixed.
Shahab Vahedi [Mon, 5 Oct 2020 15:10:47 +0000 (17:10 +0200)]
arc: Rename "arc_gdbarch_features" struct
"arc_gdbarch_features" is a data structure containing information
about the ARC architecture: ISA version, register size, etc.
This name is misleading, because although it carries the phrase
"gdbarch", it has nothing to do with the type/interface in GDB.
Traditionaly, "gdbarch" structures are only used for that purpose.
To rectify this, this patch changes the name to "arc_arch_features".
In `attach_command`, there is a call to `init_wait_for_inferior`
followed by a call to `clear_proceed_status`. However,
`init_wait_for_inferior` already calls `clear_proceed_status`. Remove
the redundant call.
Regression-tested on X86_64 Linux.
gdb/ChangeLog:
2020-10-07 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infcmd.c (attach_command): Remove the redundant call to
`clear_proceed_status`.
Add common write_memory and read_memory NetBSD routines
Instead of sharing the native-only code with all BSDs with slightly
different semantics of the kernels, share the NetBSD-only behavior beteen
the NetBSD native and gdbserver setup.
NetBSD does not differentiate the address space I and D in the
operations (contrary to OpenBSD). NetBSD handles EACCES that integrates
with NetBSD specific PaX MPROTECT error handling.
Add a verbose message in the native client that an operation could be
cancelled due to PaX MPROTECT setup.
Add ChangeLog for "Add NetBSD/aarch64 gdbserver support"
The support is on par with NetBSD/amd64, thus GPR works,
single step and software breakpoint are operational, and the
SVR4 r_debug integration is functional.
The support is on par with NetBSD/amd64, thus GPR works,
single step and software breakpoint are operational, and the
SVR4 r_debug integration is functional.
Simon Marchi [Wed, 7 Oct 2020 12:13:44 +0000 (08:13 -0400)]
gdb: make signal_catch_counts a static array
I noticed that signal_catch_counts is a dynamically-allocated array of
constant size, allocated at startup an never freed. This might as well
be a statically-allocated array.
gdb/ChangeLog:
* break-catch-sig.c (signal_catch_counts): Make a static arrray.
(_initialize_break_catch_sig): Don't allocate array.
Michael Forney [Tue, 6 Oct 2020 21:12:57 +0000 (17:12 -0400)]
gdb: Fix installation of gcore.1 on some platforms
gcore is installed on NetBSD, FreeBSD, Solaris (HAVE_NATIVE_GCORE_HOST=1)
and Linux (HAVE_NATIVE_GCORE_TARGET=1). However, even though gcore.1
is installed conditional on those variables, HAVE_NATIVE_GCORE_HOST
was missing from gdb/doc/Makefile.in, so manual installation was
skipped on NetBSD, FreeBSD, and Solaris.
gdb/doc/ChangeLog:
2020-10-06 Michael Forney <mforney@mforney.org>
* Makefile.in (HAVE_NATIVE_GCORE_HOST): Add for gcore.1
install condition.
Shahab Vahedi [Tue, 6 Oct 2020 11:15:32 +0000 (13:15 +0200)]
gdbserver: Remove unused argument in register_data()
The register_data() function in gdbserver/regcache.cc has an
input argument called "fetch". This argument is not used by this
static function at all. Therefore, it is time to get rid of it.
Alex Coplan [Tue, 6 Oct 2020 14:56:44 +0000 (15:56 +0100)]
aarch64: Fix bogus type punning in parse_barrier() [PR26699]
This patch fixes a bogus use of type punning in parse_barrier() which
was causing an assembly failure on big endian LP64 hosts when attempting
to assemble "isb sy" for AArch64.
The type of the entries in aarch64_barrier_opt_hsh is
aarch64_name_value_pair. We were incorrectly casting this to the
locally-defined asm_barrier_opt which has a wider type (on LP64) for the
second member. This happened to work on little-endian hosts but fails on
LP64 big endian.
The fix is to use the correct type in parse_barrier(). This makes the
locally-defined asm_barrier_opt redundant, so remove it.
gas/ChangeLog:
* config/tc-aarch64.c (asm_barrier_opt): Delete.
(parse_barrier): Fix bogus type punning.
* testsuite/gas/aarch64/system.d: Update disassembly.
* testsuite/gas/aarch64/system.s: Add isb sy test.
Gary Benson [Tue, 6 Oct 2020 14:08:37 +0000 (15:08 +0100)]
Fix gdb.base/list.exp with Clang
Two subtests of gdb.base/list.exp failed when built with Clang
because the unused function "unused" was optimized out. This
commit adds __attribute__ ((used)) to both definitions.
Gary Benson [Tue, 6 Oct 2020 14:08:37 +0000 (15:08 +0100)]
Fix gdb.base/list-ambiguous.exp with Clang
The ambiguous variable parts of gdb.base/list-ambiguous.exp failed
when built with Clang because the variable in question was unused
and was optimized out. This commit adds __attribute__ ((used)) to
both definitions.
A small set of code improvements for the Z80 assembler.
PR 26692
* config/tc-z80.c (md_begin): Ensure that xpressions are empty
before using them.
(unify_indexed): Likewise.
(z80_start_line_hook): Improve hash sign handling when SDCC
compatibility mode enabled.
(md_parse_exp_not_indexed): Improve indirect addressing
detection.
(md_pseudo_table): Accept hd64 as an alias of z810.
Andrew Burgess [Mon, 5 Oct 2020 08:53:50 +0000 (09:53 +0100)]
sim: Fix autoreconf errors in sim/ directory
Run autoreconf in sim/ directory and you'll see some errors. The
problem is that autoreconf (a perl script) does not evaluate the value
passed as an argument to AC_CONFIG_AUX_DIR, so something like:
AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
does not do the right thing inside autoreconf, my understanding is
that changing to something like this is fine:
AC_CONFIG_AUX_DIR(../..)
the generated configure seems to check the value passed, and the value
passed relative to the source directory, so I think we get basically
the same behaviour as before.
Andrew Burgess [Sun, 13 Sep 2020 20:53:26 +0000 (21:53 +0100)]
gdb: handle unmapped overlays in find_pc_line
I configured and built an m32r-elf toolchain, and ran the
gdb.base/overlays.exp test. I saw a couple of errors where GDB would
place a breakpoint in the wrong place when placing a breakpoint using
a function name, for example in this function:
GDB would place the breakpoint on line 2 instead of line 3. The issue
is that GDB was failing to skip the prologue correctly.
The reason for this is that in m32r-tdep.c:m32r_skip_prologue, we
first use find_pc_partial_function to find the functions start and end
addresses, then we use find_pc_line to find the start and end of the
first line of the function.
Currently, if the pc value passed to find_pc_partial_function is in an
unmapped overlay then the function start and end addresses that are
returned are also the unmapped addresses.
However, this is not the case for find_pc_line, here, if the address
passed in is in an unmapped overlay then we still get back a
symtab_and_line describing the mapped location.
What this means is that if a function's mapped location is 0x100 ->
0x120, and its unmapped locations is 0x400 -> 0x420 then we think that
the start/end is 0x400 and 0x420 respectively, but the first line
might run from 0x100 to 0x108.
GDB will then try to scan the prologue starting from 0x400 and ending
at 0x108, this immediately gives up as it thinks we have gone past the
end of the prologue and the breakpoint is placed at 0x400.
In this commit I propose that we change find_pc_line to return
addresses in the unmapped range if the address passed in is already in
the unmapped range. Now the first line will appear to run from 0x400
to 0x408 and the prologue scanner will correctly find the end of the
prologue.
With this commit gdb.base/overlays.exp now completely passes with an
m32r-elf toolchain.
gdb/ChangeLog:
* symtab.c (find_pc_line): Return unmapped addresses when the
requested address is also unmapped.
Andrew Burgess [Sun, 13 Sep 2020 20:53:08 +0000 (21:53 +0100)]
gdb/testsuite: allow gdb.base/overlays.exp to compile for m32r
The gdb.base/overlays.exp test is only currently supported on m32r
baremetal targets, however, when I configure a toolchain for m32r-elf
the test does not compile.
This commit updates the linker script, fixes some TCL errors in the
exp file, and adds some missing includes to the source file so that
the test does compile.
With this test, when run against an m32r-elf toolchain the test mostly
passes, but there are a couple of failures, these are GDB issues and
will be addressed in a later commit.
gdb/testsuite/ChangeLog:
* gdb.base/m32r.ld: Remove SEARCH_DIR line. Add MEMORY regions,
make use of regions throughout.
* gdb.base/overlays.exp: Enclose string with variableds in "..",
not {...}.
* gdb.base/ovlymgr.c: Add 'string.h' and 'stdlib.h' includes.
Simon Marchi [Mon, 5 Oct 2020 16:21:14 +0000 (12:21 -0400)]
gdb: TYPE_VECTOR -> type::is_vector in amd64-windows-tdep.c
I get this build failure:
CXX amd64-windows-tdep.o
cc1plus: warning: command-line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
/home/smarchi/src/binutils-gdb/gdb/amd64-windows-tdep.c: In function 'return_value_convention amd64_windows_return_value(gdbarch*, value*, type*, regcache*, gdb_byte*, const gdb_byte*)':
/home/smarchi/src/binutils-gdb/gdb/amd64-windows-tdep.c:374:6: error: 'TYPE_VECTOR' was not declared in this scope
374 | if (TYPE_VECTOR (type) && len == 16)
| ^~~~~~~~~~~
TYPE_VECTOR was removed in favor of the type::is_vector method.
gdb/ChangeLog:
* amd64-windows-tdep.c (amd64_windows_return_value): Use
type::is_vector instead of TYPE_VECTOR.
Simon Marchi [Mon, 5 Oct 2020 13:02:42 +0000 (09:02 -0400)]
gdb: avoid unnecessary string copy in auto_load_objfile_script_1
Assigning the result of STRIP_DRIVE_SPEC to an std::string creates an
unnecessary copy of the string. STRIP_DRIVE_SPEC is defined as:
#define STRIP_DRIVE_SPEC(f) ((f) + 2)
So if it is passed a "const char *", it returns a "const char *". We
could use a "const char *" intermediary variable instead of an
std::string, or (as implemented in this patch) just use it directly in
the concatenation right after.
gdb/ChangeLog:
* auto-load.c (auto_load_objfile_script_1): Don't use
debugfile_holder as temporary variable when stripping drive
letter.
Hannes Domani [Tue, 5 May 2020 12:31:26 +0000 (14:31 +0200)]
Fix function argument and return value locations
Fixes these testsuite fails on Windows:
FAIL: gdb.base/callfuncs.exp: p t_float_complex_values(fc1, fc2)
FAIL: gdb.base/callfuncs.exp: p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)
FAIL: gdb.base/callfuncs.exp: noproto: p t_float_complex_values(fc1, fc2)
FAIL: gdb.base/callfuncs.exp: noproto: p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)
FAIL: gdb.base/call-sc.exp: p/c fun(); call call-sc-tld
FAIL: gdb.base/call-sc.exp: advance to fun for return; return call-sc-tld
FAIL: gdb.base/call-sc.exp: zed L for return; return call-sc-tld
FAIL: gdb.base/call-sc.exp: return foo; return call-sc-tld
FAIL: gdb.base/call-sc.exp: return foo; synchronize pc to main() for 'call-sc-tld'
FAIL: gdb.base/call-sc.exp: return foo; synchronize pc to main() for 'call-sc-tld'
FAIL: gdb.base/call-sc.exp: advance to fun for finish; return call-sc-tld
FAIL: gdb.base/call-sc.exp: zed L for finish; return call-sc-tld
FAIL: gdb.base/call-sc.exp: finish foo; return call-sc-tld (the program is no longer running)
FAIL: gdb.base/call-sc.exp: value foo finished; return call-sc-tld
For function arguments (callfuncs.exp), only TYPE_CODE_COMPLEX was
missing in the types passed via integer registers.
For return values, there were a lot more issues:
- TYPE_CODE_DECFLOAT is NOT returned via XMM0.
- long double is NOT returned via XMM0.
- but __int128 IS returned via XMM0.
- the comments for TYPE_CODE_FLT state that __m128, __m128i and __m128d are
returned by XMM0, and this is correct, but it doesn't actually check for
them, because they are TYPE_CODE_ARRAY with TYPE_VECTOR
So I had to add TYPE_CODE_DECFLOAT to the arguments passed via XMM register,
but I had to remove it from the values returned via XMM0 register.
gdb/ChangeLog:
2020-10-05 Hannes Domani <ssbssa@yahoo.de>
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Add TYPE_CODE_COMPLEX.
(amd64_windows_return_value): Fix types returned via XMM0.
gdb/testsuite/ChangeLog:
2020-10-05 Hannes Domani <ssbssa@yahoo.de>
* gdb.base/call-sc.c: Fix return struct on stack test case.
* gdb.base/call-sc.exp: Likewise.
H.J. Lu [Mon, 5 Oct 2020 12:27:58 +0000 (05:27 -0700)]
x86-64: Always display suffix for %LQ in 64bit
In 64bit, assembler generates a warning for "sysret":
$ echo sysret | as --64 -o x.o -
{standard input}: Assembler messages:
{standard input}:1: Warning: no instruction mnemonic suffix given and no register operands; using default for `sysret'
Always display suffix for %LQ in 64bit to display "sysretl".
H.J. Lu [Mon, 5 Oct 2020 12:23:29 +0000 (05:23 -0700)]
x86: Clear modrm if not needed
The MODRM byte can be checked to display the instruction name only if the
MODRM byte needed. Clear modrm if the MODRM byte isn't needed so that
modrm field checks in putop like, modrm.mod == N with N != 0, can be done
without checking need_modrm.
Nick Clifton [Mon, 5 Oct 2020 09:40:07 +0000 (10:40 +0100)]
GAS: Update the .section directive so that a numeric section index can be provided when the "o" flag is used.
PR 26253
gas * config/obj-elf.c (obj_elf_section): Accept a numeric value for
the "o" section flag. Interpret it as a section index. Allow an
index of zero.
* doc/as.texi: Document the new behaviour.
* NEWS: Mention the new feature. Tidy entries.
* testsuite/gas/elf/sh-link-zero.s: New test.
* testsuite/gas/elf/sh-link-zero.d: New test driver.
* testsuite/gas/elf/elf.exp: Run the new test.
* testsuite/gas/elf/section21.l: Updated expected assembler
output.
bfd * elf.c (_bfd_elf_setup_sections): Do not complain about an
sh_link value of zero when the SLF_LINK_ORDER flag is set.
(assign_section_numbers): Likewise.
Simon Marchi [Sun, 4 Oct 2020 16:36:02 +0000 (12:36 -0400)]
gdb/doc: space out list entries, fix one type
I want to add an item to this list, but it's so packed I have trouble
finding where one item ends and the next starts. Add a few empty lines
to make it a bit more readable.
Doing this, I also noticed that an "aix-thread" should in fact be
"aix-solib".
H.J. Lu [Sat, 3 Oct 2020 11:23:55 +0000 (04:23 -0700)]
x86: Update register operand check for AddrPrefixOpReg
When the address size prefix applies to both the memory and the register
operand, we need to extract the address size prefix from the register
operand if the memory operand has no real registers, like symbol, DISP
or symbol(%rip).
NB: GCC always generates symbol(%rip) for RIP-relative addressing for
both x32 and x86-64.
Move the .code16 tests in movdir.s to movdir-16bit to show the correct
output from objdump.
PR gas/26685
* config/tc-i386.c (process_suffix): Also check the register
operand for the address size prefix if the memory operand has
no real registers.
* testsuite/gas/i386/enqcmd-16bit.d: New file.
* testsuite/gas/i386/enqcmd-16bit.s: Likewise.
* testsuite/gas/i386/movdir-16bit.d: Likewise.
* testsuite/gas/i386/movdir-16bit.s: Likewise.
* testsuite/gas/i386/enqcmd.s: Add tests with symbol and DISP.
* testsuite/gas/i386/x86-64-enqcmd.s: Likewise.
* testsuite/gas/i386/x86-64-movdir.s: Likewise.
* testsuite/gas/i386/movdir.s: Add tests with symbol and DISP.
Remove the .code16 test.
* testsuite/gas/i386/i386.exp: Run movdir-16bit and enqcmd-16bit.
* testsuite/gas/i386/x86-64-enqcmd-intel.d: Updated.
* testsuite/gas/i386/x86-64-enqcmd.d: Likewise.
* testsuite/gas/i386/x86-64-movdir-intel.d: Likewise.
* testsuite/gas/i386/x86-64-movdir.d: Likewise.
* testsuite/gas/i386/enqcmd-intel.d: Likewise.
* testsuite/gas/i386/enqcmd.d: Likewise.
* testsuite/gas/i386/movdir-intel.d: Likewise.
* testsuite/gas/i386/movdir.d: Likewise.
* testsuite/gas/i386/x86-64-enqcmd-intel.d: Likewise.
* testsuite/gas/i386/x86-64-enqcmd.d: Likewise.
* testsuite/gas/i386/x86-64-movdir-intel.d: Likewise.
* testsuite/gas/i386/x86-64-movdir.d: Likewise.
Tom Tromey [Fri, 2 Oct 2020 16:23:25 +0000 (10:23 -0600)]
Unconditionally use REG_EXTENDED
skip.c checks whether REG_EXTENDED is defined -- but this should
always be available, and is used unconditionally in other parts of
gdb. This patch removes this check, then further simplifies this
code, removing a declaration and a repeated assertion.
2020-10-02 Tom Tromey <tromey@adacore.com>
* skip.c (skiplist_entry::skiplist_entry): Unconditionally use
REG_EXTENDED.
Simon Marchi [Fri, 2 Oct 2020 19:22:21 +0000 (15:22 -0400)]
gdb: fix some inferior_created observer signatures
I just noticed that in a7aba2668a7b ("gdb: remove arguments from
inferior_created observable"), I forgot to update
aix_thread_inferior_created and procfs_inferior_created, which are in
files I can't compile.
Remove the parameters from aix_thread_inferior_created. And simply
remove procfs_inferior_created, since it's empty anyway.
* server.cc (handle_monitor_command): Handle "set
debug-event-loop".
(captured_main): Handle "--debug-event-loop".
(monitor_show_help): Mention new setting.
(gdbserver_usage): Mention new flag.
gdbsupport/ChangeLog:
* event-loop.h (debug_event_loop): New variable declaration.
(event_loop_debug_printf_1): New function declaration.
(event_loop_debug_printf): New macro.
* event-loop.cc (debug_event_loop): New variable.
(handle_file_event): Add debug print.
(event_loop_debug_printf_1): New function.
Simon Marchi [Fri, 2 Oct 2020 18:45:52 +0000 (14:45 -0400)]
gdb: give names to event loop file handlers
Assign names to event loop file handlers. They will be used in debug
messages when file handlers are invoked.
In GDB, each UI used to get its own unique number, until commit cbe256847e19 ("Remove ui::num"). Re-introduce this field, and use it to
make a unique name for the handler.
I'm not too sure what goes on in ser-base.c, all I know is that it's
what is used when debugging remotely. I've just named the main handler
"serial". It would be good to have unique names there too. For instance
when debugging with two different remote connections, we'd ideally want
the handlers to have unique names. I didn't do it in this patch though.
Simon Marchi [Fri, 2 Oct 2020 14:46:38 +0000 (10:46 -0400)]
gdb: remove arguments from inferior_created observable
I noticed that non of the listeners of the inferior_created observable
used either of the arguments. Remove them. This in turn allows
removing the target parameter of post_create_inferior.
Tested only by rebuilding.
gdb/ChangeLog:
* observable.h <inferior_created>: Remove parameters. Update all
listeners.
* inferior.h (post_create_inferior): Remove target parameter.
Update all callers.
DWARFv5: Handle DW_MACRO_define_strx and DW_MACRO_undef_strx macro entries.
GDB complaints "During symbol reading: unrecognized DW_MACFINO
opcode 0xb" with the testcase given below. Clang is emitting
DW_MACRO_define_strx and DW_MACRO_undef_strx entries in .debug_macro
section which are not supported in GDB. This patch handles them.
DW_MACRO_define_strx and DW_MACRO_undef_strx are added in DWARFv5.
They have two operands. The first operand encodes the line number of
the #define or #undef macro directive. The second operand identifies
a string; it is represented using an unsigned LEB128 encoded value,
which is interpreted as a zero-based index into an array of offsets
in the .debug_str_offsets section. This is as per the section 6.3.2.1
of Dwarf Debugging Information Format Version 5.
Test case used:
#define MAX_SIZE 10
int main(void)
{
int size = 0;
size = size + MAX_SIZE;
gdb/new_gdb/binutils-gdb/build/bin/gdb -q macro.out -ex "set complaints 1" -ex "start"
Reading symbols from macro.out...
During symbol reading: unrecognized DW_MACFINO opcode 0xb
Temporary breakpoint 1 at 0x4004df: file macro.c, line 7.
Starting program: /home/nitika/workspace/macro.out
Temporary breakpoint 1, main () at macro.c:7
7 int size = 0;
(gdb)
Tested by running the testsuite before and after the patch with
-gdwarf-5 and there is no increase in the number of test cases
that fails. Used clang 11.0.0.
gdb/ChangeLog:
* dwarf2/macro.c (dwarf_decode_macro_bytes): Handle DW_MACRO_define_strx
and DW_MACRO_undef_strx.
(dwarf_decode_macros): Likewise
* dwarf2/read.c (dwarf_decode_macros): Pass str_offsets_base in the parameters
which is the value of DW_AT_str_offsets_base.
* dwarf2/macro.h (dwarf_decode_macros): Modify the definition to include
str_offsets_base.
Remove old, no longer needed and no longer valid extern.
../../gdb/i386-nbsd-tdep.c:58:12: error: 'i386nbsd_sc_reg_offset' was declared 'extern' and later 'static' [-fpermissive]
58 | static int i386nbsd_sc_reg_offset[] =
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../gdb/i386-nbsd-tdep.c:31:
../../gdb/i386-tdep.h:480:12: note: previous declaration of 'i386nbsd_sc_reg_offset'
480 | extern int i386nbsd_sc_reg_offset[];
| ^~~~~~~~~~~~~~~~~~~~~~
Remove the old sanity check of sigcontext offsets for NetBSD/i386
NetBSD switched to ucontext, back in 2003 and the sigcontext code
is no longer available for users, except for legacy compat layers.
This code was not available anyway as the pre-processor check
was probably never operational and buildable on NetBSD. The code
inside it does not compile.
Meanwhile, move the offset variable into the ifdef goards and avoid
the error about unused variable.
../../gdb/i386-bsd-nat.c: In function 'void _initialize_i386bsd_nat()':
../../gdb/i386-bsd-nat.c:347:7: error: unused variable 'offset' [-Werror=unused-variable]
347 | int offset;
| ^~~~~~
cc1plus: all warnings being treated as errors
gdb/ChangeLog:
* i386-bsd-nat.c (_initialize_i386bsd_nat): Update.
* i386-nbsd-tdep.c (i386nbsd_sc_reg_offset): Now static.
The support is on part with NetBSD/amd64, thus GPR works,
single step and software breakpoint are operational, and the
SVR4 r_debug integration is functional.
Replace the pre-C++ construct of netbsd_target_ops, netbsd_regset_info
and netbsd_tdesc with C++ inheritance approach found in the Linux
gdbserver code. Add netbsd_amd64_target, that inherits from the
netbsd_process_target class and add proper singleton object for
the_netbsd_target, initialized from netbsd_amd64_target.
Call low_arch_setup () on post process creation, which sets machine
specific properties of the traced process.
Remove global singleton the_netbsd_target object from the generic
gdbserver code.
This refactoring introduces no functional change from the end-user
point of view.
Include the x86-bsd-nat.h header and fix the NetBSD/i386 build
In file included from ../../gdb/i386-nbsd-nat.c:26:
../../gdb/i386-bsd-nat.h:34:53: error: expected template-name before '<' token
34 | class i386_bsd_nat_target : public x86bsd_nat_target<BaseTarget>
| ^
../../gdb/i386-bsd-nat.h:34:53: error: expected '{' before '<' token
../../gdb/i386-nbsd-nat.c:74:45: error: aggregate 'i386_bsd_nat_target<nbsd_nat_target> the_i386_nbsd_nat_target' has incomplete type and cannot be defined
74 | static i386_bsd_nat_target<nbsd_nat_target> the_i386_nbsd_nat_target;
| ^~~~~~~~~~~~~~~~~~~~~~~~
Nick Clifton [Thu, 1 Oct 2020 15:34:05 +0000 (16:34 +0100)]
Add new directive to GAS: .attach_to_group.
* config/obj-elf (elf_pseudo_table): Add attach_to_group.
(obj_elf_attach_to_group): New function.
* doc/as.texi: Document the new directive.
* NEWS: Mention the new feature.
* testsuite/gas/elf/attach-1.s: New test.
* testsuite/gas/elf/attach-1.d: New test driver.
* testsuite/gas/elf/attach-2.s: New test.
* testsuite/gas/elf/attach-2.d: New test driver.
* testsuite/gas/elf/attach-err.s: New test.
* testsuite/gas/elf/attach-err.d: New test driver.
* testsuite/gas/elf/attach-err.err: New test error output.
* testsuite/gas/elf/elf.exp: Run the new tests.
Tom de Vries [Wed, 30 Sep 2020 19:49:01 +0000 (21:49 +0200)]
[gdb] Fix regression in dwarf2_name
Since commit 2c830f5475 "Change some uses of DW_STRING to string method" we
have these regressions:
...
FAIL: gdb.base/info-types-c++.exp: info types
FAIL: gdb.cp/anon-struct.exp: print type of t::t
FAIL: gdb.cp/anon-struct.exp: print type of X::t2
FAIL: gdb.cp/anon-struct.exp: print type of X::t2::t2
FAIL: gdb.cp/anon-struct.exp: print type of t3::~t3
...
Fix these in dwarf2_name by updating attr_name each time attr is updated.
Tested on x86_64-linux.
gdb/ChangeLog:
2020-09-30 Tom de Vries <tdevries@suse.de>
PR symtab/26683
* dwarf2/read.c (dwarf2_name): Update attr_name after attr is updated.
Tom Tromey [Wed, 30 Sep 2020 15:46:36 +0000 (09:46 -0600)]
Fix regression in variant part handling
My series to change DWARF attribute handling to be type-safe
introduced a regression in gdb.ada/variant.exp. handle_variant was
using as_unsigned on an attribute with DW_FORM_sdata. This patch
changes it to use constant_value instead.
2020-09-30 Tom Tromey <tromey@adacore.com>
* dwarf2/read.c (handle_variant): Use constant_value.