Carl Love [Wed, 16 Jun 2021 17:07:39 +0000 (12:07 -0500)]
Add ISA 3.1 check to powerpc-plxv-norel.exp
This patch adds a file with the ISA 3.1 check. The ISA 3.1 check is
added to the test to ensure the test is only run on ISA 3.1 or newer.
gdb/testsuite/ChangeLog
2021-06-25 Carl Love <cel@us.ibm.com>
* gdb.arch/powerpc-plxv-norel.exp: Add call to skip_power_isa_3_1_tests.
* lib/gdb.exp(skip_power_isa_3_1_tests): New gdb_caching_proc test.
Tom Tromey [Fri, 25 Jun 2021 14:40:37 +0000 (08:40 -0600)]
Use gdb::function_view in addrmap_foreach
While working on the DWARF psymtab replacement, I needed
addrmap_foreach to accept a gdb::function_view. This seemed like a
worthwhile change on its own, so I've written it separately for
submission.
Regression tested on x86-64 Fedora 32.
gdb/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* dwarf2/index-write.c (struct addrmap_index_data): Add
initializers.
<operator()>: Declare.
(addrmap_index_data::operator()): Rename from
add_address_entry_worker. Remove 'datap' parameter.
(write_address_map): Update.
* psymtab.c (struct dump_psymtab_addrmap_data): Remove
(dump_psymtab_addrmap_1): Remove 'data' parameter, add other
parameters.
(dump_psymtab_addrmap): Update.
* addrmap.c (struct addrmap_funcs) <foreach>: Remove 'data'
parameter.
(addrmap_foreach, addrmap_fixed_foreach): Likewise.
(struct mutable_foreach_data): Remove.
(addrmap_mutable_foreach_worker): Update.
(addrmap_mutable_foreach): Remove 'data' parameter.
* addrmap.h (addrmap_foreach_fn): Use gdb::function_view.
(addrmap_foreach): Remove 'data' parameter.
Tom Tromey [Fri, 25 Jun 2021 14:01:15 +0000 (08:01 -0600)]
Decode Ada types in Python layer
GNAT emits encoded type names, but these aren't usually of interest to
users. The Ada language code in gdb hides this oddity -- but the
Python layer does not. This patch changes the Python code to use the
decoded Ada type name, when appropriate.
I looked at decoding Ada type names during construction, as that would
be cleaner. However, the Ada support in gdb relies on the encodings
at various points, so this isn't really doable right now.
2021-06-25 Tom Tromey <tromey@adacore.com>
* python/py-type.c (typy_get_name): Decode an Ada type name.
gdb/testsuite/ChangeLog
2021-06-25 Tom Tromey <tromey@adacore.com>
* gdb.ada/py_range.exp: Add type name test cases.
Tom Tromey [Fri, 25 Jun 2021 14:01:15 +0000 (08:01 -0600)]
Add non-wrapping mode to ada_decode
When ada_decode encounters a name that it cannot decode, it simply
wraps it in <...>, which is used elsewhere in the Ada code to indicate
that a verbatim match should be done.
A subequent patch needed the ability to suppress this wrapping, so
this patch adds a new mode to ada_decode.
2021-06-25 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_decode): Add wrap parameter.
* ada-lang.h (ada_decode): Add wrap parameter.
Luis Machado [Mon, 17 May 2021 14:41:09 +0000 (11:41 -0300)]
Update the core file architecture if a target description is present
At the moment, the core target has its own gdbarch (m_core_gdbarch), and that
gets set from the core_bfd on the core target's constructor.
That gdbarch doesn't contain a target description because it is constructed
before we get a chance to fetch the target description.
As a result, some hooks that depend on the target description being set are
not set, and that leads to problems. One of the examples is
gdbarch_report_signal_info, which is used to show AArch64 tag violation
information.
Fix this by reading the target description before fetching the core file's
gdbarch.
gdb/ChangeLog:
2021-06-25 Luis Machado <luis.machado@linaro.org>
* corelow.c (core_target::core_target) Update to read target
description.
Mike Frysinger [Thu, 24 Jun 2021 00:19:53 +0000 (20:19 -0400)]
sim: cris: fix a few missing prototype warnings
Add a stub prototype for the dump function meant to be called by devs
from gdb, and trim unused functions that aren't supposed to be used.
Mike Frysinger [Thu, 24 Jun 2021 04:14:15 +0000 (00:14 -0400)]
sim: callback: extend syscall interface to handle 7 args
The Linux syscall interface, depending on architecture, handles up to
7 arguments. Extend the callback API to handle those.
GDB Administrator [Fri, 25 Jun 2021 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Thu, 24 Jun 2021 10:55:08 +0000 (12:55 +0200)]
[gdb/testsuite] Fix duplicate in gdb.base/info-macros.exp
When running test-case gdb.base/info-macros.exp, I run into:
...
PASS: gdb.base/info-macros.exp: info macro --
PASS: gdb.base/info-macros.exp: info macro --
DUPLICATE: gdb.base/info-macros.exp: info macro --
PASS: gdb.base/info-macros.exp: info macro --
...
These messages come from gdb_test calls using the following commands:
- "info macro --"
- "info macro -- "
- "info macro -- ".
Apparantly the test names get stripped of trailing whitespace, and the first
two end up identical.
Fix this by explicitly specifying an <EOL> after the trailing whitespace in
the test name, such that we have:
...
PASS: gdb.base/info-macros.exp: info macro --
PASS: gdb.base/info-macros.exp: info macro -- <EOL>
PASS: gdb.base/info-macros.exp: info macro -- <EOL>
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-24 Tom de Vries <tdevries@suse.de>
* gdb.base/info-macros.exp: Add <EOL> after trailing whitespace in
test names.
Tom de Vries [Thu, 24 Jun 2021 10:08:54 +0000 (12:08 +0200)]
[gdb/testsuite] Fix duplicate in gdb.base/argv0-symlink.exp
I found the following duplicates in gdb.base/argv0-symlink.exp:
...
DUPLICATE: gdb.base/argv0-symlink.exp: set print repeats 10000
DUPLICATE: gdb.base/argv0-symlink.exp: set print elements 10000
...
Fix these by using with_test_prefix "file symlink" / "dir symlink".
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-24 Tom de Vries <tdevries@suse.de>
* gdb.base/argv0-symlink.exp: Use with_test_prefix.
Clément Chigot [Tue, 22 Jun 2021 08:15:06 +0000 (10:15 +0200)]
gas: update csect alignment for PPC prefixed instructions on XCOFF
Power10 prefixed instructions must not cross 64-byte boundaries.
This is already handled.
However, on XCOFF, the csect must be updated to match the new
alignment.
* config/tc-ppc.c (md_assemble): Update ppc_current_csect
alignment when finding prefixed instructions.
Mike Frysinger [Mon, 21 Jun 2021 03:50:35 +0000 (23:50 -0400)]
sim: syscall: handle killing the sim itself
If code tries to send a signal to itself, the callback layer ignores
it and forces the caller to handle it. This allows the sim to turn
that into an engine halt rather than actually killing the sim.
Mike Frysinger [Mon, 21 Jun 2021 03:42:20 +0000 (23:42 -0400)]
sim: cris: override getpid callback
The cris linux syscall layers assume getpid returns a constant,
so add a custom function to provide that.
Mike Frysinger [Mon, 21 Jun 2021 03:06:10 +0000 (23:06 -0400)]
sim: callback: add a kill interface
This will make it easier to emulate the syscall. If the kill target
is the sim itself, don't do anything. This forces the higher layers
to make a decision as to how to handle this event: like halting the
overall engine process.
GDB Administrator [Thu, 24 Jun 2021 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Wed, 23 Jun 2021 02:31:12 +0000 (22:31 -0400)]
sim: switch common srcdir to abs_srcdir
We rewrite srcdir in subdir Makefiles that we generate from the common
parent dir since it points to the parent dir. Since @srcdir@ can be a
variety of formats (relative & absolute), switch to @abs_srcdir@ which
is a lot easier to adjust. Our use of srcdir in here should handle it.
Tom de Vries [Wed, 23 Jun 2021 21:46:04 +0000 (23:46 +0200)]
[gdb/testsuite] Rewrite gdb_test_lines
On Ubuntu 20.04, when the debug info package for libc is not installed,
I get:
FAIL: gdb.base/info-types-c++.exp: info types
FAIL: gdb.base/info-types-c.exp: info types
The reason is that the output of info types is exactly:
(gdb) info types
All defined types:
File /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/info-types.c:
52: typedef enum {...} anon_enum_t;
45: typedef struct {...} anon_struct_t;
68: typedef union {...} anon_union_t;
28: typedef struct baz_t baz;
31: typedef struct baz_t * baz_ptr;
21: struct baz_t;
double
33: enum enum_t;
float
int
38: typedef enum enum_t my_enum_t;
17: typedef float my_float_t;
16: typedef int my_int_t;
54: typedef enum {...} nested_anon_enum_t;
47: typedef struct {...} nested_anon_struct_t;
70: typedef union {...} nested_anon_union_t;
30: typedef struct baz_t nested_baz;
29: typedef struct baz_t nested_baz_t;
39: typedef enum enum_t nested_enum_t;
19: typedef float nested_float_t;
18: typedef int nested_int_t;
62: typedef union union_t nested_union_t;
56: union union_t;
unsigned int
(gdb)
The lines we expect in the test contain an empty line at the end:
...
"62:\[\t \]+typedef union union_t nested_union_t;" \
"56:\[\t \]+union union_t;" \
"--optional" "\[\t \]+unsigned int" \
""]
This is written with the supposition that other files will be listed, so
an empty line will be included to separate the symbols from this file
from the next one. This empty line is not included when info-types.c is
the only file listed.
Fix this by rewriting gdb_test_lines to accept a single, plain tcl multiline
regexp, such that we can write:
...
"62:\[\t \]+typedef union union_t nested_union_t;" \
"56:\[\t \]+union union_t;(" \
"\[\t \]+unsigned int)?" \
"($|\r\n.*)"]
...
Tested affected test-cases:
- gdb.base/info-types-c.exp
- gdb.base/info-types-c++.exp
- gdb.base/info-macros.exp
- gdb.cp/cplusfuncs.exp
on x86_64-linux (openSUSE Leap 15.2), both with check and check-read1.
Also tested the first two with gcc-4.8.
Also tested on ubuntu 18.04.
gdb/testsuite/ChangeLog:
2021-06-23 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_test_lines): Rewrite to accept single
multiline tcl regexp.
* gdb.base/info-types.exp.tcl: Update. Make empty line at end of
regexp optional.
* gdb.base/info-macros.exp: Update.
* gdb.cp/cplusfuncs.exp: Update.
GDB Administrator [Wed, 23 Jun 2021 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Mon, 21 Jun 2021 04:10:22 +0000 (00:10 -0400)]
sim: cris: fix a few warnings
Include header for hw funcs called, adjust prototype to match the
args given to it, and adjust cast to match the function.
Mike Frysinger [Sun, 20 Jun 2021 16:53:38 +0000 (12:53 -0400)]
sim: callback: add missing cb_target_to_host_signal
There's been a prototype for this forever, but the implementation was
missing. Probably because there weren't any callers, but we'll start
using it to implement the kill function.
Mike Frysinger [Mon, 21 Jun 2021 02:55:44 +0000 (22:55 -0400)]
sim: callback: generate signal map
We've been generating the syscall/errno/open maps, but not the signal
map, even though we've been including them in the source constants.
Mike Frysinger [Sun, 20 Jun 2021 16:38:27 +0000 (12:38 -0400)]
sim: callback: add a getpid interface
Rather than hit the OS interface directly, use the existing callback
layer so the instantiator can decide behavior.
Mike Frysinger [Sun, 20 Jun 2021 05:04:34 +0000 (01:04 -0400)]
sim: rx: merge with common configure script
Move the unique configure flag to acinclude.m4 so the common code
can include it, then delete the rx configure logic entirely.
Mike Frysinger [Sun, 20 Jun 2021 01:33:30 +0000 (21:33 -0400)]
sim: drop configure scripts for simple ports
These ports only use the pieces that have been unified, so we can
merge them into the common configure script and get rid of their
unique one entirely.
We still compile & link separate run programs, and have dedicated
subdir Makefiles, but the configure script portion is merged.
Simon Marchi [Tue, 22 Jun 2021 19:07:50 +0000 (15:07 -0400)]
gdb: fix python/lib/gdb/__init__.py formatting
Run black to fix this formatting.
gdb/ChangeLog:
* python/lib/gdb/__init__.py: Format.
Change-Id: I68ea306d1991bf7243b2c8aeeb11719d668851e5
Simon Marchi [Tue, 22 Jun 2021 18:57:29 +0000 (14:57 -0400)]
gdb: remove unnecessary parameter wait_ptid from do_target_wait
do_target_wait has a wait_ptid parameter, to filter what ptid we wait
on. The sole caller of do_target_wait passes minus_one_ptid, meaning
"all ptids". So in practice, this parameter is not needed, remove it.
gdb/ChangeLog:
* infrun.c (do_target_wait): Remove wait_ptid parameter.
(fetch_inferior_event): Adjust.
Change-Id: I54119beb43db678e4b2081dc490f89e7ff878e74
Simon Marchi [Tue, 22 Jun 2021 18:16:01 +0000 (14:16 -0400)]
gdb/python: print name of unwinder that claimed frame in debug message
If we have multiple registered unwinders, this will helps identify which
unwinder was chosen and make it easier to track down potential problems.
Unwinders have a mandatory name argument, which we can use in the
message.
First, make gdb._execute_unwinders return a tuple containing the name,
in addition to the UnwindInfo. Then, make pyuw_sniffer include the name
in the debug message.
I moved the debug message earlier. I think it's good to print it as
early as possible, so that we see it in case an assert is hit in the
loop below, for example.
gdb/ChangeLog:
* python/lib/gdb/__init__.py (_execute_unwinders): Return tuple
with name of chosen unwinder.
* python/py-unwind.c (pyuw_sniffer): Print name of chosen
unwinder in debug message.
Change-Id: Id603545b44a97df2a39dd1872fe1f38ad5059f03
Andreas Schwab [Mon, 21 Jun 2021 09:38:23 +0000 (11:38 +0200)]
gdb: Support DW_LLE_start_end
Without that it is impossible to debug on riscv64.
gdb/
PR symtab/27999
* dwarf2/loc.c (decode_debug_loclists_addresses): Support
DW_LLE_start_end.
gdb/testsuite/
PR symtab/27999
* lib/dwarf.exp (start_end): New proc inside loclists.
* gdb.dwarf2/loclists-start-end.exp: New file.
* gdb.dwarf2/loclists-start-end.c: New file.
Tom de Vries [Tue, 22 Jun 2021 13:58:09 +0000 (15:58 +0200)]
[gdb/testsuite] Add gdb.dwarf2/imported-unit-c.exp
This test-case is intended to excercise this code in process_imported_unit_die:
...
/* We're importing a C++ compilation unit with tag DW_TAG_compile_unit
into another compilation unit, at root level. Regard this as a hint,
and ignore it. */
if (die->parent && die->parent->parent == NULL
&& per_cu->unit_type == DW_UT_compile
&& per_cu->lang == language_cplus)
return;
...
in the sense that the test-case should fail if the
"per_cu->lang == language_cplus" clause is removed.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-22 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/imported-unit-c.exp: New file.
Nelson Chu [Tue, 22 Jun 2021 04:02:52 +0000 (12:02 +0800)]
RISC-V: Clarify the addends of pc-relative access.
The original discussion was here,
https://github.com/riscv/riscv-elf-psabi-doc/issues/184
After discussing with Kito Cheng, I think the addends of %pcrel_hi
and %pcrel_lo are both allowed in GNU toolchain. However, both of
the them mean the offset of symbols, rather than the pc address.
But the addends of %got_pcrel_hi and it's %pcrel_lo do not look
reasonable. I believe gcc won't generate the got patterns with
addends, so linker should report dangerous relocation errors,
in case the assembly code use them.
Another issue was here,
https://sourceware.org/pipermail/binutils/2021-June/116983.html
At the beginnig, I suppose %pcrel_hi and %pcrel_lo are valid only
when they are in the same input section. But Jim Wilson points out
that gcc may generate %hi and %lo in the different input sections,
when -freorder-blocks-and-partition option is used. So that a memory
references for a loop may have the %hi outside the loop, but the %lo
remain in the loop. However, it is hard to create the testcases,
to see if %pcrel_hi and %pcrel_lo have the same behavior.
Unfortunately, I notice that the current pcrel resolver cannot
work for the above case. For now we build a hash table for pcrel
at the start of riscv_elf_relocate_section, and then free the hash
at the end. But riscv_elf_relocate_section only handles an input
section at a time, so that means we can only resolve the %pcrel_hi
and %pcrel_lo which are in the same input section. Otherwise, like
the above case, we will report "%pcrel_lo missing matching %pcrel_hi"
for them. I have no plan to improve this in the short-term, so maybe
we can wait until someone meets the problem before we deal with it.
bfd/
* elfnn-riscv.c (riscv_pcrel_hi_reloc): Added field to store
the original relocation type, in case the type is converted to
R_RISCV_HI20.
(riscv_pcrel_lo_reloc): Removed unused name field.
(riscv_pcrel_relocs): Added comments.
(riscv_zero_pcrel_hi_reloc): Removed unused input_bfd.
(riscv_record_pcrel_hi_reloc): Updated.
(riscv_record_pcrel_lo_reloc): Likewise.
(riscv_resolve_pcrel_lo_relocs): Likewise. Check the original
type of auipc, to make sure the %pcrel_lo without any addends.
Otherwise, report dangerous relocation error.
(riscv_elf_relocate_section): Updated above functions are changed.
For R_RISCV_GOT_HI20, report dangerous relocation error when addend
isn't zero.
ld/
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3a.d: New testcase.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3a.s: Likewise.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3b.d: New testcase.
Should report error since the %pcrel_lo with addend refers to
%got_pcrel_hi.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3b.s: Likewise.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3c.d: New testcase.
Should report error since the %got_pcrel_hi with addend.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3c.s: Likewise.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3.ld: Likewise.
Andrew Burgess [Fri, 11 Jun 2021 10:30:47 +0000 (11:30 +0100)]
gdb/remote: handle target dying just before a stepi
I randomly hit a situation where gdbserver crashed immediately before
I issued a 'stepi' to GDB, it turns out that this causes GDB itself to
crash.
What happens is that as part of the stepi we try to insert some
breakpoints into the inferior, so from insert_breakpoints we figure
out what we want to insert, then, eventually, try to send some packets
to the remote to get the breakpoints inserted.
It is only at this point that GDB realises that the target has gone
away. This causes GDB to then enter this call stack:
unpush_and_perror
remote_unpush_target
generic_mourn_inferior
breakpoint_init_inferior
delete_breakpoint
update_global_location_list
So, we realise the target is gone and so delete the breakpoints
associated with that target.
GDB then throws a TARGET_CLOSE_ERROR from unpush_and_error.
This error is caught in insert_breakpoints where we then try to print
a nice error saying something like:
Cannot insert breakpoint %d: some error text here...
To fill in the '%d' we try to read properties of the breakpoint
object.
Which was deleted due to the delete_breakpoint call above.
And so GDB dies...
My proposal in this commit is that, should we catch a
TARGET_CLOSE_ERROR in insert_breakpoints, then we just rethrow the
error.
This will cause the main event loop to print something like:
Remote connection closed
Which I think is fine, I don't think the user will care much which
particular breakpoint GDB was operating on when the connection closed,
just knowing that the connection closed should be enough I think.
I initially added a test to 'gdb.server/server-kill.exp' for this
issue, however, my first attempt was not good enough, the test was
passing even without my fix.
Turns out that the server-kill.exp test actually kills the PID of the
inferior, not the PID of the server. This means that gdbserver is
actually able to send a packet to GDB saying that the inferior has
exited prior to gdbserver itself shutting down. This extra
information was enough to prevent the bug I was seeing manifest.
So, I have extended server-kill.exp to run all of the tests twice, the
first time we still kill the inferior. On the second run we hard kill
the gdbserver itself, this prevents the server from sending anything
to GDB before it exits.
My new test is only expected to fail in this second mode of
operation (killing gdbserver itself), and without my fix, that is what
I see.
gdb/ChangeLog:
* breakpoint.c (insert_bp_location): If we catch a
TARGET_CLOSE_ERROR just rethrow it, the breakpoints might have
been deleted.
gdb/testsuite/ChangeLog:
* gdb.server/server-kill.exp: Introduce global kill_pid_of, and
make use of this in prepare to select which pid we should kill.
Run all the tests twice with a different kill_pid_of value.
(prepare): Make use of kill_pid_of.
(test_stepi): New proc.
Andrew Burgess [Mon, 21 Jun 2021 14:10:14 +0000 (15:10 +0100)]
opcodes: make use of __builtin_popcount when available
This commit provides a small performance improvement when starting up
CGEN based disassemblers by making use of __builtin_popcount.
The #if check used in this commit was copied from bfd/elf32-arm.c
where __builtin_popcount is also used.
I ran into this code while investigating some GDB tests that would
occasionally timeout. One of the reason these tests were having
problems is that the m16c and m32c disassemblers take so long to
initialise themselves. Speeding up count_decodable_bits helps, but is
not a total solution. Still, this felt like an easy win which added
minimal extra complexity, so I figure its worth doing.
opcodes/ChangeLog:
* cgen-dis.c (count_decodable_bits): Use __builtin_popcount when
available.
Alan Modra [Mon, 21 Jun 2021 07:37:05 +0000 (17:07 +0930)]
picojava assembler and disassembler fixes
Commit
54758c3e398d made changes to the picojava support based on
https://sourceware.org/pipermail/binutils/2005-November/045136.html
An update from picojava to picojava II, I think. Unfortunately the
patch neglected any changes to the gas testsuite, resulting in
"FAIL: pj" since that date. This patch makes a few relatively simple
changes to cure the regression.
gas/
* config/tc-pj.c (md_apply_fix): Apply PJ_CODE_REL32 relocs.
* testsuite/gas/pj/ops.s: Update jsr, ret, getstatic,
putstatic, getfield, putfield, invokevirtual, invokespecial,
invokestatic, invokeinterface, goto_w, jsr_w assembly. Delete
version 1 picojava opcodes.
* testsuite/gas/pj/ops.d: Match expected output.
opcodes/
* pj-dis.c (print_insn_pj): Don't print trailing tab. Do
print separator for pcrel insns.
Mike Frysinger [Sun, 20 Jun 2021 00:06:12 +0000 (20:06 -0400)]
sim: unify hardware settings
Move these options up to the common dir so we only test & export
them once across all ports.
Mike Frysinger [Sat, 19 Jun 2021 23:36:39 +0000 (19:36 -0400)]
sim: hw: rework configure option & device selection
The sim-hardware configure option allows builders to select a set of
device models to enable. But this seems like unnecessary overkill:
the existence of individual device models doesn't affect performance
at all as they are only enabled at runtime if the config uses them,
and individually these are all <5KB a piece. Stripping off a total
of ~50KB from a ~1MB binary doesn't seem useful, and it's extremely
unlikely anyone will ever bother.
So let's simplify the configure/make logic by turning sim-hardware
into a boolean option like many of the other sim options. Any ports
that have unique device models will declare them in their Makefile
instead of at configure time. This will allow us to (eventually)
unify the setting into the common dir.
GDB Administrator [Tue, 22 Jun 2021 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Tue, 4 May 2021 10:41:09 +0000 (11:41 +0100)]
gdb/riscv: add support for vector registers in target descriptions
This commit adds support to RISC-V GDB for vector registers in the
incoming target description.
The vector registers should be described in a feature called
"org.gnu.gdb.riscv.vector", and should contain the register v0 to
v31. There's no restriction on the size or type of these registers,
so the target description can set these up as it requires.
However, if the target feature is present then all of the registers
must be present, and they must all be the same size, these
requirements are, I believe, inline with the RISC-V vector extension.
The DWARF register numbers for the vector registers have been added,
and the code to map between GDB's internal numbering and the DWARF
numbering has been updated.
I have not yet added a feature/riscv/*.xml file for the vector
extension, the consequence of this is that we can't, right now, detect
vector registers on a native target, this patch is all about
supporting vectors on a remote target.
It is worth noting that I don't actually have access to a RISC-V
target with vectors, so the only testing that this patch has had has
been done using 'set tdesc filename ....' to load a target description
to which I have manually added the vector feature. This has shown
that the vector register feature can be successfully parsed, and that
the registers show up in the expected register groups.
Additionally, the RISC-V vector extension is currently at v0.10, which
is also the v1.0 draft release. However, this extension is not yet
finalised. It is possible (but unlikely I think) that the register
set could change between now and the final release of the vector
extension. If this were to happen then we would potentially end up
changing the requirements for the new org.gnu.gdb.riscv.vector
feature. I really don't think it is likely that the register set will
change this late in the process, and even if it did, changing the
feature requirements will not be a problem as far as I am
concerned (when the alternative is GDB just continues without this
feature for now).
gdb/ChangeLog:
* NEWS: Mention new target feature name.
* arch/riscv.c (riscv_create_target_description): GDB doesn't
currently create target descriptions containing vector registers.
* arch/riscv.h (struct riscv_gdbarch_features) <vlen>: New member
variable.
<operator==>: Also compare vlen.
<hash>: Also include vlen.
* riscv-tdep.c (riscv_feature_name_vector): New static global.
(struct riscv_vector_feature): New struct.
(riscv_vector_feature): New static global.
(riscv_register_reggroup_p): Ensure vector registers are part of
the 'all' group, and part of the 'vector' group.
(riscv_dwarf_reg_to_regnum): Handle vector registers.
(riscv_gdbarch_init): Check vector register feature.
* riscv-tdep.h: Add vector registers to GDB's internal register
numbers, and to the DWARF register numbers.
gdb/doc/ChangeLog:
* gdb.texinfo (RISC-V Features): Mention vector register feature.
Andrew Burgess [Wed, 26 May 2021 21:01:59 +0000 (22:01 +0100)]
gdb/python: add PendingFrame.level and Frame.level methods
Add new methods to the PendingFrame and Frame classes to obtain the
stack frame level for each object.
The use of 'level' as the method name is consistent with the existing
attribute RecordFunctionSegment.level (though this is an attribute
rather than a method).
For Frame/PendingFrame I went with methods as these classes currently
only use methods, including for simple data like architecture, so I
want to be consistent with this interface.
gdb/ChangeLog:
* NEWS: Mention the two new methods.
* python/py-frame.c (frapy_level): New function.
(frame_object_methods): Register 'level' method.
* python/py-unwind.c (pending_framepy_level): New function.
(pending_frame_object_methods): Register 'level' method.
gdb/doc/ChangeLog:
* python.texi (Unwinding Frames in Python): Mention
PendingFrame.level.
(Frames In Python): Mention Frame.level.
gdb/testsuite/ChangeLog:
* gdb.python/py-frame.exp: Add Frame.level tests.
* gdb.python/py-pending-frame-level.c: New file.
* gdb.python/py-pending-frame-level.exp: New file.
* gdb.python/py-pending-frame-level.py: New file.
Andrew Burgess [Wed, 26 May 2021 20:28:11 +0000 (21:28 +0100)]
gdb/python: move PyLong_From* calls into py-utils.c
We already have two helper functions in py-utils.c:
gdb_py_object_from_longest (LONGEST l)
gdb_py_object_from_ulongest (ULONGEST l)
these wrap around calls to either PyLong_FromLongLong,
PyLong_FromLong, or PyInt_From_Long (if Python 2 is being used).
There is one place in gdb/python/* where a call to PyLong_FromLong was
added outside of the above utility functions, this was done in the
recent commit:
commit
55789354fcbaf879f3ca8475b647b2747dec486e
Date: Fri May 14 11:56:31 2021 +0200
gdb/python: add a 'connection_num' attribute to Inferior objects
In this commit I replace the direct use of PyLong_FromLong with a call
to gdb_py_object_from_longest. The only real change with this commit,
is that, for Python 2, we will now end up calling PyInt_FromLong
instead of PyLong_FromLong, but this should be invisible to the user.
For Python 3 there should be absolutely no change.
gdb/ChangeLog:
* python/py-inferior.c (infpy_get_connection_num): Call
gdb_py_object_from_longest instead of PyLong_FromLong directly.
Andrew Burgess [Wed, 26 May 2021 14:24:04 +0000 (15:24 +0100)]
gdb/python: handle saving user registers in a frame unwinder
This patch came about because I wanted to write a frame unwinder that
would corrupt the backtrace in a particular way. In order to achieve
what I wanted I ended up trying to write an unwinder like this:
class FrameId(object):
.... snip class definition ....
class TestUnwinder(Unwinder):
def __init__(self):
Unwinder.__init__(self, "some name")
def __call__(self, pending_frame):
pc_desc = pending_frame.architecture().registers().find("pc")
pc = pending_frame.read_register(pc_desc)
sp_desc = pending_frame.architecture().registers().find("sp")
sp = pending_frame.read_register(sp_desc)
# ... snip code to decide if this unwinder applies or not.
fid = FrameId(pc, sp)
unwinder = pending_frame.create_unwind_info(fid)
unwinder.add_saved_register(pc_desc, pc)
unwinder.add_saved_register(sp_desc, sp)
return unwinder
The important things here are the two calls:
unwinder.add_saved_register(pc_desc, pc)
unwinder.add_saved_register(sp_desc, sp)
On x86-64 these would fail with an assertion error:
gdb/regcache.c:168: internal-error: int register_size(gdbarch*, int): Assertion `regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch)' failed.
What happens is that in unwind_infopy_add_saved_register (py-unwind.c)
we call register_size, as register_size should only be called on
cooked (real or pseudo) registers, and 'pc' and 'sp' are implemented
as user registers (at least on x86-64), we trigger the assertion.
A simple fix would be to check in unwind_infopy_add_saved_register if
the register number we are handling is a cooked register or not, if
not we can throw a 'Bad register' error back to the Python code.
However, I think we can do better.
Consider that at the CLI we can do this:
(gdb) set $pc=0x1234
This works because GDB first evaluates '$pc' to get a register value,
then evaluates '0x1234' to create a value encapsulating the
immediate. The contents of the immediate value are then copied back
to the location of the register value representing '$pc'.
The value location for a user-register will (usually) be the location
of the real register that was accessed, so on x86-64 we'd expect this
to be $rip.
So, in this patch I propose that in the unwinder code, when
add_saved_register is called, if it is passed a
user-register (i.e. non-cooked) then we first fetch the register,
extract the real register number from the value's location, and use
that new register number when handling the add_saved_register call.
If either the value location that we get for the user-register is not
a cooked register then we can throw a 'Bad register' error back to the
Python code, but in most cases this will not happen.
gdb/ChangeLog:
* python/py-unwind.c (unwind_infopy_add_saved_register): Handle
saving user registers.
gdb/testsuite/ChangeLog:
* gdb.python/py-unwind-user-regs.c: New file.
* gdb.python/py-unwind-user-regs.exp: New file.
* gdb.python/py-unwind-user-regs.py: New file.
Mike Frysinger [Sun, 20 Jun 2021 16:32:27 +0000 (12:32 -0400)]
sim: cris: clean up printf & abort usage a bit
Inline the stats printf calls to avoid compiler warnings about
non-literal format strings. This in turn highlights bad type
sizes being passed in, so fix the strings to use the right size
type. This in turn highlights the rest of the func using casts
rather than the right type directly, so adjust all of those.
Finally, replace a few abort+sim_engine_halt calls with the
common sim_engine_abort. This provides good output while still
aborting as we want.
GDB Administrator [Mon, 21 Jun 2021 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Sun, 20 Jun 2021 04:50:30 +0000 (00:50 -0400)]
sim: rx: scope the unique configure flag
This will make it possible to merge into the common configure by
making sure we never collide with other arches.
Mike Frysinger [Sat, 19 Jun 2021 05:36:30 +0000 (01:36 -0400)]
sim: delete SIM_AC_COMMON macro
Now that we've moved all content out to the common file, this is
empty and can be deleted it entirely.
Mike Frysinger [Sat, 19 Jun 2021 14:46:14 +0000 (10:46 -0400)]
sim: unify general maintainer settings
Move these options up to the common dir so we only test & export
them once across all ports. This takes a page from the cgen maint
logic to make $(MAINT) work for non-automake Makefiles which will
allow us to merge it together.
Mike Frysinger [Sat, 19 Jun 2021 14:42:37 +0000 (10:42 -0400)]
sim: unify cgen maintainer settings
Move these options up to the common dir so we only test & export
them once across all ports. It makes it available to targets that
aren't cgen-based, but those will just ignore the settings, so it
shouldn't be an issue.
Mike Frysinger [Sun, 20 Jun 2021 02:24:57 +0000 (22:24 -0400)]
sim: m68hc11: fix unused function warnings with -O0
Mark these functions as unused in case they don't get inlined when
building with -O0.
Mike Frysinger [Wed, 16 Jun 2021 02:45:07 +0000 (22:45 -0400)]
sim: move sim-inline to the common code
This will allow us to build the common code with the same inline
settings as the arch subdirs, and only do the test once.
H.J. Lu [Sun, 20 Jun 2021 03:20:52 +0000 (20:20 -0700)]
x86: Count PLT for GOTOFF relocation against IFUNC symbol
Since GOTOFF relocations against IFUNC symbols must go through PLT,
set PLT reference count to 1 for GOTOFF relocation.
bfd/
PR ld/27998
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Count PLT for GOTOFF
relocation against IFUNC symbols.
(_bfd_x86_elf_adjust_dynamic_symbol): Likewise.
ld/
PR ld/27998
* testsuite/ld-i386/i386.exp: Run PR ld/27998 tests.
* testsuite/ld-i386/pr27998a.d: New file.
* testsuite/ld-i386/pr27998a.s: Likewise.
* testsuite/ld-i386/pr27998b.d: Likewise.
* testsuite/ld-i386/pr27998b.s: Likewise.
Mike Frysinger [Tue, 15 Jun 2021 05:40:33 +0000 (01:40 -0400)]
gdb/gdbserver: switch to AC_CONFIG_MACRO_DIRS
These dirs don't use automake, so use AC_CONFIG_MACRO_DIRS to specify
../config as a search dir for m4 macros. This allows removal of a lot
of hand-written m4_include's from acinclude.m4 files, and simplifies
use of `aclocal` or `autoreconf` as manual -I is not needed.
Simon Marchi [Sun, 20 Jun 2021 02:49:21 +0000 (22:49 -0400)]
sim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's definition
I get this when building with gcc 11:
CC common/common_libcommon_a-sim-load.o
In file included from /home/simark/src/binutils-gdb/sim/common/sim-n-bits.h:27,
from /home/simark/src/binutils-gdb/sim/common/sim-bits.c:259,
from /home/simark/src/binutils-gdb/sim/common/sim-bits.h:599,
from /home/simark/src/binutils-gdb/sim/common/sim-basics.h:122,
from /home/simark/src/binutils-gdb/sim/common/sim-load.c:30:
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:27: error: 'offset_16' defined but not used [-Werror=unused-function]
39 | #define offset_N XCONCAT2(offset_,N)
| ^~~~~~~
/home/simark/src/binutils-gdb/sim/../include/symcat.h:23:26: note: in definition of macro 'CONCAT2'
23 | #define CONCAT2(a,b) a##b
| ^
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:18: note: in expansion of macro 'XCONCAT2'
39 | #define offset_N XCONCAT2(offset_,N)
| ^~~~~~~~
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:138:1: note: in expansion of macro 'offset_N'
138 | offset_N (unsigned_N *x,
| ^~~~~~~~
offset_N uses INLINE_SIM_ENDIAN, which uses UNUSED to put the "unused"
attribute. However, it appears after the function's return type, which
seems to make it not apply to the function. Moving it to before the
return type fixes the error.
Change all instances found in that file.
sim/common/ChangeLog:
* sim-inline.h: Move UNUSED before TYPE.
Change-Id: Ide20106683ed7a9ebf35d484dabf70b309cb1ba6
Mike Frysinger [Sun, 20 Jun 2021 02:13:00 +0000 (22:13 -0400)]
sim: unify dtc tool checks
Only one arch uses this currently, but others could too. By moving
it up to the common checks, it'll also let us simplify the moxie code
significantly.
Mike Frysinger [Wed, 16 Jun 2021 02:37:38 +0000 (22:37 -0400)]
sim: ppc: rename inline defines to match common code
Use the same basic names as the common sim inline logic so we can
merge the two. We don't do that here, just prepare for it.
The common code seems to be based on the ppc version but with slightly
different names as it was cleaned up & generalized. I *think* these
concepts are the same, so binding them together is OK, but maybe I'm
misreading them. If so, can always tweak them later.
REVEAL_MODULE -> H_REVEALS_MODULE
INLINE_MODULE -> C_REVEALS_MODULE
Mike Frysinger [Sun, 20 Jun 2021 02:23:14 +0000 (22:23 -0400)]
sim: drop old BUILT_SRC_FROM_COMMON ref
The code that set & used this variable was deleted long ago,
but the clean target was missed. Clean that up now.
GDB Administrator [Sun, 20 Jun 2021 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sat, 19 Jun 2021 23:33:24 +0000 (16:33 -0700)]
elf: Correct DT_TEXTREL warning in PDE
Change
ld: warning: creating DT_TEXTREL in a PIE
to
ld: warning: creating DT_TEXTREL in a PDE
on PDE.
bfd/
* elflink.c (bfd_elf_final_link): Correct DT_TEXTREL warning in
PDE.
ld/
* testsuite/ld-x86-64/textrel-1.err: New file.
* testsuite/ld-x86-64/textrel-1a.s: Likewise.
* testsuite/ld-x86-64/textrel-1b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run textrel-1 tests.
Mike Frysinger [Sat, 19 Jun 2021 04:52:10 +0000 (00:52 -0400)]
sim: unify gettext/intl probing logic
Move these options up to the common dir so we only test & export
them once across all ports.
Mike Frysinger [Fri, 18 Jun 2021 15:12:28 +0000 (11:12 -0400)]
sim: unify toolchain dependency logic
The common dir is already probing this info since it's using automake,
so pass it down to the subdirs so they don't have to probe it at all.
Mike Frysinger [Fri, 18 Jun 2021 14:45:03 +0000 (10:45 -0400)]
sim: unify toolchain probing logic
Move these options up to the common dir so we only test & export
them once across all ports.
H.J. Lu [Sat, 19 Jun 2021 02:56:47 +0000 (19:56 -0700)]
elf: Update GNU_PROPERTY_UINT32_[AND|OR]_XXX tests
1. Skip am33_2.0-*-* hppa*-*-hpux* mn10300-*-* since assembly source file
for the HPPA assembler is renamed and modifed by sed. mn10300 has RELA
relocations in .note.gnu.property section which elf_parse_notes doesn't
support.
2. Pass --generate-missing-build-notes=no to assembler.
3. Allow other note sections for xtensa.
* testsuite/ld-elf/property-and-1.d: Skip am33_2.0, hppa-hpux
and mn10300.
Pass --generate-missing-build-notes=no to assembler. Allow
other note sections for xtensa.
* testsuite/ld-elf/property-and-2.d: Likewise.
* testsuite/ld-elf/property-and-3.d: Likewise.
* testsuite/ld-elf/property-and-4.d: Likewise.
* testsuite/ld-elf/property-or-1.d: Likewise.
* testsuite/ld-elf/property-or-2.d: Likewise.
* testsuite/ld-elf/property-or-3.d: Likewise.
* testsuite/ld-elf/property-or-4.d: Likewise.
Mike Frysinger [Fri, 18 Jun 2021 06:03:44 +0000 (02:03 -0400)]
sim: unify bfd library dependency testing logic
Move these options up to the common dir so we only test & export
them once across all ports.
Mike Frysinger [Fri, 18 Jun 2021 05:59:25 +0000 (01:59 -0400)]
sim: mips: drop unused AC_PATH_X call
We don't use anything from X, so no sense in probing the env.
Mike Frysinger [Fri, 18 Jun 2021 05:58:00 +0000 (01:58 -0400)]
sim: unify various library testing logic
Move these options up to the common dir so we only test & export
them once across all ports.
Alan Modra [Sat, 19 Jun 2021 00:55:35 +0000 (10:25 +0930)]
ubsan: vax: pointer overflow
"VAX export class call relocation test" fails with ubsan on a 32-bit
host.
* vax-dis.c (print_insn_vax): Avoid pointer overflow.
Alan Modra [Fri, 18 Jun 2021 12:57:01 +0000 (22:27 +0930)]
ubsan errors when 32-bit bfd
A shift count exceeding the size of the value is undefined behaviour,
and so is negating a signed LONG_MIN.
* config/tc-z80.c (signed_overflow, unsigned_overflow): Avoid UB.
Alan Modra [Fri, 18 Jun 2021 12:56:11 +0000 (22:26 +0930)]
ppc raw test failure when 32-bit bfd
The test contained an expression that can't be evaluated unless
expressions are 64-bit.
* testsuite/gas/ppc/raw.s: Use 0 as pli constant.
* testsuite/gas/ppc/raw.d: Update to suit.
Alan Modra [Fri, 18 Jun 2021 12:55:10 +0000 (22:25 +0930)]
Fix another strncpy warning
* tic30-dis.c (get_register_operand): Don't ask strncpy to fill
entire buffer.
Alan Modra [Fri, 18 Jun 2021 08:54:43 +0000 (18:24 +0930)]
dwarf.c: string_fortify.h strncpy error
In function 'strncpy',
inlined from 'display_debug_lines_decoded' at /home/alan/src/binutils-gdb/binutils/dwarf.c:5434:5,
inlined from 'display_debug_lines' at /home/alan/src/binutils-gdb/binutils/dwarf.c:5567:21:
/usr/include/bits/string_fortified.h:95:10: error: '__builtin_strncpy' specified bound 36 equals destination size [-Werror=stringop-truncation]
No need for strncpy here, the string being copied always fits the
destination buffer.
* dwarf.c (display_debug_lines_decoded): Use memcpy rather than
strncpy when trimming file name length to MAX_FILENAME_LENGTH.
Don't make an unnecessary copy when length is good.
GDB Administrator [Sat, 19 Jun 2021 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
Carl Love [Wed, 16 Jun 2021 19:51:46 +0000 (14:51 -0500)]
Fix powerpc-power8.exp test with new mnemonics
This patch updates the gdb test to use the new bgetar and bnstarl mnemonics
introduced in commit
5a4037661bccd156d65093f1f0cf2cd43f31e9d9. The test
previously used the bctar and bctarl mnemonics.
gdb/testsuite/ChangeLog
2021-06-17 Carl Love <cel@us.ibm.com>
* gdb.arch/powerpc-power8.exp(bctar, bctarl): Update mnemonics
to bgetar and bgetarl.
* gdb.arch/powerpc-power8.s((bctar, bctarl): Update comments
for mnemonics to bgetar and bnstarl.
H.J. Lu [Fri, 18 Jun 2021 14:32:25 +0000 (07:32 -0700)]
ld.texi: Move -z unique-symbol after -z undefs.
* ld.texi: Move -z unique-symbol after -z undefs.
Mike Frysinger [Fri, 18 Jun 2021 05:14:39 +0000 (01:14 -0400)]
sim: unify -Werror build settings
Move these options up to the common dir so we only test & export
them once across all ports. It also enables -Werror usage on the
common files we've been pulling out of arch subdirs.
H.J. Lu [Fri, 18 Jun 2021 14:18:02 +0000 (07:18 -0700)]
elf: Add GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXX
Implement GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXX:
https://sourceware.org/pipermail/gnu-gabi/2021q1/000467.html
1. GNU_PROPERTY_UINT32_AND_LO..GNU_PROPERTY_UINT32_AND_HI
#define GNU_PROPERTY_UINT32_AND_LO 0xb0000000
#define GNU_PROPERTY_UINT32_AND_HI 0xb0007fff
A bit in the output pr_data field is set only if it is set in all
relocatable input pr_data fields. If all bits in the the output
pr_data field are zero, this property should be removed from output.
If the bit is 1, all input relocatables have the feature. If the
bit is 0 or the property is missing, the info is unknown.
2. GNU_PROPERTY_UINT32_OR_LO..GNU_PROPERTY_UINT32_OR_HI
#define GNU_PROPERTY_UINT32_OR_LO 0xb0008000
#define GNU_PROPERTY_UINT32_OR_HI 0xb000ffff
A bit in the output pr_data field is set if it is set in any
relocatable input pr_data fields. If all bits in the the output
pr_data field are zero, this property should be removed from output.
If the bit is 1, some input relocatables have the feature. If the
bit is 0 or the property is missing, the info is unknown.
bfd/
* elf-properties.c (_bfd_elf_parse_gnu_properties): Handle
GNU_PROPERTY_UINT32_AND_LO, GNU_PROPERTY_UINT32_AND_HI,
GNU_PROPERTY_UINT32_OR_LO and GNU_PROPERTY_UINT32_OR_HI.
(elf_merge_gnu_properties): Likewise.
binutils/
* readelf.c (print_gnu_property_note): Handle
GNU_PROPERTY_UINT32_AND_LO, GNU_PROPERTY_UINT32_AND_HI,
GNU_PROPERTY_UINT32_OR_LO and GNU_PROPERTY_UINT32_OR_HI.
include/
* elf/common.h (GNU_PROPERTY_UINT32_AND_LO): New.
(GNU_PROPERTY_UINT32_AND_HI): Likewise.
(GNU_PROPERTY_UINT32_OR_LO): Likewise.
(GNU_PROPERTY_UINT32_OR_HI): Likewise.
ld/
* testsuite/ld-elf/property-and-1.d: New file.
* testsuite/ld-elf/property-and-1.s: Likewise.
* testsuite/ld-elf/property-and-2.d: Likewise.
* testsuite/ld-elf/property-and-2.s: Likewise.
* testsuite/ld-elf/property-and-3.d: Likewise.
* testsuite/ld-elf/property-and-3.s: Likewise.
* testsuite/ld-elf/property-and-4.d: Likewise.
* testsuite/ld-elf/property-and-empty.s: Likewise.
* testsuite/ld-elf/property-or-1.d: Likewise.
* testsuite/ld-elf/property-or-1.s: Likewise.
* testsuite/ld-elf/property-or-2.d: Likewise.
* testsuite/ld-elf/property-or-2.s: Likewise.
* testsuite/ld-elf/property-or-3.d: Likewise.
* testsuite/ld-elf/property-or-3.s: Likewise.
* testsuite/ld-elf/property-or-4.d: Likewise.
* testsuite/ld-elf/property-or-empty.s: Likewise.
Mike Frysinger [Fri, 18 Jun 2021 06:14:52 +0000 (02:14 -0400)]
sim: move -Werror disabling to Makefile
For the ports that still don't build with -Werror, rather than disable
the flag at configure time, do it at make time. This will allow us to
unify these tests in the common sim configure script.
Mike Frysinger [Wed, 16 Jun 2021 03:01:45 +0000 (23:01 -0400)]
sim: create a makefile fragment to pass common settings down
As we merge settings from subdirs into the common configure, we
sometimes need to keep the settings working in both dirs. Create
a makefile fragment to pass them down so we don't have to run the
checks twice. For now, the file is empty, but we'll start moving
logic in shortly.
Jan Beulich [Fri, 18 Jun 2021 11:51:52 +0000 (13:51 +0200)]
gas: fold symbol table entries generated for .startof.() / .sizeof.()
When the same such construct is used multiple times in a source file,
there's still no need to emit a separate symbol each time. Under the
assumption that there won't be many of these, use a simple array
lookup method to record previously used symbols.
Mike Frysinger [Mon, 14 Jun 2021 03:16:32 +0000 (23:16 -0400)]
sim: split sim-signal.h include out
The sim-basics.h is too big and includes too many things. This leads
to some arch's sim-main.h having circular loop issues with defs, and
makes it hard to separate out common objects from arch-specific defs.
By splitting up sim-basics.h and killing off sim-main.h, it'll make
it easier to separate out the two.
Mike Frysinger [Mon, 14 Jun 2021 02:27:08 +0000 (22:27 -0400)]
sim: drop core libiberty.h include
This doesn't need to be included for every sim file, so drop it.
Every C file that needs it seems to already include it.
Mike Frysinger [Tue, 15 Jun 2021 23:51:52 +0000 (19:51 -0400)]
sim: overhaul & unify endian settings management
The m4 macro has 2 args: the "wire" settings (which represents the
hardwired port behavior), and the default settings (which are used
if nothing else is specified). If none are specified, the arch is
expected to support both, and the value will be probed based on the
user runtime options or the input program.
Only two arches today set the default value (bpf & mips). We can
probably let this go as it only shows up in one scenario: the sim
is invoked, but with no inputs, and no user endian selection. This
means bpf will not behave like the other arches: an error is shown
and forces the user to make a choice. If an input program is used
though, we'll still switch the default to that. This allows us to
remove the WITH_DEFAULT_TARGET_BYTE_ORDER setting.
For the ports that set a "wire" endian, move it to the runtime init
of the respective sim_open calls. This allows us to change the
WITH_TARGET_BYTE_ORDER to purely a user-selected configure setting
if they want to force a specific endianness.
With all the endian logic moved to runtime selection, we can move
the configure call up to the common dir so we only process it once
across all ports.
The ppc arch was picking the wire endian based on the target used,
but since we weren't doing that for other biendian arches, we can
let this go too. We'll rely on the input selecting the endian, or
make the user decide.
GDB Administrator [Fri, 18 Jun 2021 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Thu, 17 Jun 2021 23:03:32 +0000 (19:03 -0400)]
sim: ppc: avoid "PAGE_SIZE" name
This define is used for a particular target and depends on the
simulated CPU hardware. It has no relation to the host CPU that
the sim is running on. So rename the common "PAGE_SIZE" here to
better reflect its usage and avoid conflicts with system headers.
Pedro Alves [Thu, 17 Jun 2021 15:23:03 +0000 (16:23 +0100)]
Don't call sigtimedwait for scoped_ignore_sigttou
Because SIGTTOU is sent to the whole process instead of to a specific
thread, consuming a pending SIGTTOU in the destructor of
scoped_ignore_sigttou could consume a SIGTTOU signal raised due to
actions done by some other thread. Simply avoid sigtimedwait in
scoped_ignore_sigttou, thus plugging the race. This works because we
know that when the thread writes to the terminal and the signal is
blocked, the kernel does not raise the signal at all.
Tested on GNU/Linux, Solaris 11 and FreeBSD.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <pedro@palves.net>
* scoped_ignore_signal.h (scoped_ignore_signal): Add
ConsumePending template parameter.
(scoped_ignore_signal::~scoped_ignore_signal): Skip calling
sigtimedwait if ConsumePending is false.
(scoped_ignore_sigpipe): Initialize with ConsumePending=true.
* scoped_ignore_sigttou.h (scoped_ignore_sigttou)
<m_ignore_signal>: Initialize with ConsumePending=false.
Change-Id: I92f754dbc45c45819dce2ce68b8c067d8d5c61b1
H.J. Lu [Thu, 17 Jun 2021 17:32:27 +0000 (10:32 -0700)]
x86-64: Use $NOPIE_LDFLAGS/$NOPIE_CFLAGS on protected-func-1
PR ld/27973
* testsuite/ld-x86-64/x86-64.exp: Pass $NOPIE_LDFLAGS and
$NOPIE_CFLAGS to protected-func-1 without PIE.
H.J. Lu [Thu, 17 Jun 2021 17:19:29 +0000 (10:19 -0700)]
x86-64: Test protected function pointers
On x86-64, function pointers in executable for external funtions may be
resolved to their PLT entries in executable. If it happens, function
pointers of protected funtions in shared libraries must be resolved to
the PLT entries in executable, not addresses of protected funtions in
shared libraries.
PR ld/27973
* testsuite/ld-x86-64/x86-64.exp: Run protected function tests.
* testsuite/ld-x86-64/protected-func-1.h: New file.
* testsuite/ld-x86-64/protected-func-1a.s: Likewise.
* testsuite/ld-x86-64/protected-func-1b.c: Likewise.
Fangrui Song [Thu, 17 Jun 2021 17:18:28 +0000 (10:18 -0700)]
ld: Add ChangeLog entry for -no-pie
Fangrui Song [Thu, 17 Jun 2021 16:57:40 +0000 (09:57 -0700)]
ld: Add -no-pie
gold has had this option for many years. Not having this option caused
some confusion to users. The help message clarifies the default state.
ld/
* ldlex.h (enum option_values): Add OPTION_NO_PIE.
* lexsup.c (struct ld_options): Add -no-pie.
(parse_args): Handle -no-pie.
* ld.texi: Document -no-pie.
Pedro Alves [Thu, 17 Jun 2021 15:16:55 +0000 (16:16 +0100)]
Add a unit test for scoped_ignore_sigpipe
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <pedro@palves.net>
* Makefile.in (SELFTESTS_SRCS): Add
unittests/scoped_ignore_signal-selftests.c.
* unittests/scoped_ignore_signal-selftests.c: New.
Change-Id: Idce24aa9432a3f1eb7065bc9aa030b1d0d7dcad5
Pedro Alves [Thu, 17 Jun 2021 15:16:55 +0000 (16:16 +0100)]
scoped_ignore_signal: Use sigprocmask+sigtimedwait instead of signal
The problem with using signal(...) to temporarily ignore a signal, is
that that changes the the signal disposition for the whole process.
If multiple threads do it at the same time, you have a race.
Fix this by using sigprocmask + sigtimedwait to implement the ignoring
instead, if available, which I think probably means everywhere except
Windows nowadays. This way, we only change the signal mask for the
current thread, so there's no race.
Change-Id: Idfe3fb08327ef8cae926f3de9ee81c56a83b1738
gdbsupport/ChangeLog:
yyyy-mm-dd Pedro Alves <pedro@palves.net>
* scoped_ignore_signal.h
(scoped_ignore_signal::scoped_ignore_signal)
[HAVE_SIGPROCMASK]: Use sigprocmask to block the signal instead of
changing the signal disposition for the whole process.
(scoped_ignore_signal::~scoped_ignore_signal) [HAVE_SIGPROCMASK]:
Use sigtimedwait and sigprocmask to flush and unblock the signal.
Pedro Alves [Thu, 17 Jun 2021 15:16:54 +0000 (16:16 +0100)]
Introduce scoped_restore_signal
We currently have scoped_restore_sigttou and scoped_restore_sigpipe
doing basically the same thing -- temporarily ignoring a specific
signal.
This patch introduce a scoped_restore_signal type that can be used for
both. This will become more important for the next patch which
changes how the signal-ignoring is implemented.
scoped_restore_sigpipe is a straight alias to
scoped_restore_signal<SIGPIPE> on systems that define SIGPIPE, and an
alias to scoped_restore_signal_nop (a no-op version of
scoped_restore_signal) otherwise.
scoped_restore_sigttou is not a straight alias because it wants to
check the job_control global.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <pedro@palves.net>
* gdbsupport/scoped_ignore_signal.h: New.
* compile/compile.c: Include gdbsupport/scoped_ignore_signal.h
instead of <signal.h>. Don't include <unistd.h>.
(scoped_ignore_sigpipe): Remove.
* gdbsupport/scoped_ignore_sigttou.h: Include gdbsupport/scoped_ignore_signal.h
instead of <signal.h>. Don't include <unistd.h>.
(lazy_init): New.
(scoped_ignore_sigttou): Reimplement using scoped_ignore_signal
and lazy_init.
Change-Id: Ibb44d0bd705e96df03ef0787c77358a4a7b7086c
Pedro Alves [Thu, 17 Jun 2021 15:16:54 +0000 (16:16 +0100)]
Move scoped_ignore_sigttou to gdbsupport/
A following patch will want to use scoped_ignore_sigttou in code
shared between GDB and GDBserver. Move it under gdbsupport/.
Note that despite what inflow.h/inflow.c's first line says, inflow.c
is no longer about ptrace, it is about terminal management. Some
other files were unnecessarily including inflow.h, I guess a leftover
from the days when inflow.c really was about ptrace. Those inclusions
are simply dropped.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <pedro@palves.net>
* Makefile.in (HFILES_NO_SRCDIR): Remove inflow.h.
* inf-ptrace.c, inflow.c, procfs.c: Don't include "inflow.h".
* inflow.h: Delete, moved to gdbsupport/ under a different name.
* ser-unix.c: Don't include "inflow.h". Include
"gdbsupport/scoped_ignore_sigttou.h".
gdbsupport/ChangeLog:
yyyy-mm-dd Pedro Alves <pedro@palves.net>
* scoped_ignore_sigttou.h: New file, moved from gdb/ and renamed.
Change-Id: Ie390abf42c3a78bec6d282ad2a63edd3e623559a
Nick Clifton [Thu, 17 Jun 2021 15:19:20 +0000 (16:19 +0100)]
Fix an assertion failure in the AArch64 assembler triggered by incorrect instruction syntax.
PR 27904
* config/tc-aarch64.c (ldst_lo12_determine_real_reloc_type):
Generate a syntax error message if the reloc qualifier does not
match the instruction's size.
Clément Chigot [Tue, 15 Jun 2021 09:06:52 +0000 (11:06 +0200)]
gas: handle csect in bss section for XCOFF
Latest gcc versions are now generating csects instead of .lcomm
for bss symbols.
Some adjustements are needed in order to handle them.
* config/tc-ppc.c (md_begin): Create bss section with dummy
symbol.
(ppc_frob_symbol): Output XTY_CM for bss csects.
(ppc_fix_adjustable): Adjust condition to avoid bss csects.
Simon Marchi [Thu, 17 Jun 2021 13:41:59 +0000 (09:41 -0400)]
gdb/testsuite: gdb.base/args.exp: add KFAIL for native-extended-gdbserver
This test tests passing arguments made of exactly two single-quotes
('') or a single newline character through the --args argument of GDB.
For some reason, GDB adds some extra single quotes when transmitting the
arguments to GDBserver. This produces some FAILs when testing with the
native-extended-gdbserver board:
FAIL: gdb.base/args.exp: argv[2] for one empty (with single quotes)
FAIL: gdb.base/args.exp: argv[2] for two empty (with single quotes)
FAIL: gdb.base/args.exp: argv[3] for two empty (with single quotes)
FAIL: gdb.base/args.exp: argv[2] for one newline
FAIL: gdb.base/args.exp: argv[2] for two newlines
FAIL: gdb.base/args.exp: argv[3] for two newlines
This is documented as PR 27989. Add some appropriate KFAILs.
gdb/testsuite/ChangeLog:
* gdb.base/args.exp: Check target, KFAIL if remote.
(args_test): Add parameter and use it.
Change-Id: I49225d1c7df7ebaba480ebdd596df80f8fbf62f0
Simon Marchi [Thu, 17 Jun 2021 13:41:58 +0000 (09:41 -0400)]
gdb/testsuite: gdb.base/args.exp: remove trailing parenthesis in test names
Some test names end with a parenthesis, we don't want that:
https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Do_not_use_.22tail_parentheses.22_on_test_messages
Fix that.
gdb/testsuite/ChangeLog:
* gdb.base/args.exp: Remove trailing parenthesis in test names.
Change-Id: I0306ea202bae3a4ed5bf0bd65e0ab5ed5de52fe1
Simon Marchi [Thu, 17 Jun 2021 13:41:58 +0000 (09:41 -0400)]
gdb/testsuite: gdb.base/args.exp: use $old_gdbflags last two tests
All tests in this file append to GDBFLAGS instead of overwriting it,
except the last two. I noticed because when testing with the
native-extended-remote board, it removes the "set sysroot" argument, and
it causes the test to be very long to run, due to big glibc debug info
being read through the remote target.
I think this oddity is due to a race condition between these two
commits:
[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=
c22261528c50f7760dd6a2e29314662b377eebb4
[2] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=
6b8ce727297b1e40738e50f83a75881b290fe6a6
The first one added the two tests. The second one changes the test to
append to GDBFLAGS instead of overwriting it. But the second one was
probably written before the first one was it, so missed the new tests.
Change those two tests to be like the others.
gdb/testsuite/ChangeLog:
* gdb.base/args.exp: Use $old_gdbflags in all tests.
Change-Id: I531276125ecb70e80f52adbd320ebb85b0c8eba0
Simon Marchi [Thu, 17 Jun 2021 13:41:58 +0000 (09:41 -0400)]
gdb/testsuite: gdb.base/args.exp: use save_vars
Use save_vars instead of manually saving/restoring. This ensures that
if anything throws an error, GDBFLAGS will be correctly restored.
Remove the global GDBFLAGS declaration at the top, it's not necessary.
gdb/testsuite/ChangeLog:
* gdb.base/args.exp: Use save_vars.
Change-Id: I3a45e4fc1635ec0212de2415040f91eecaf4a057
Pedro Alves [Thu, 17 Jun 2021 10:57:56 +0000 (11:57 +0100)]
Make the TUI command window support the mouse
Currently, when the focus is on the command window, we disable the
keypad. This means that when the command window has the focus, keys
such as up/down/home/end etc. are not processed by curses, and their
escape sequences go straight to readline.
A side effect of disabling keypad mode is that wgetch no longer
processes mouse escape sequences, with the end result being the mouse
doesn't work, and worse, the raw mouse escape sequences are printed on
the terminal.
This commit makes the TUI command window support the mouse as well, by
always enabling the keypad, and then to avoid losing support for
up/down browsing the command history, home/end/left/right moving the
cursor position, etc., we forward those keys as raw escape sequences
to readline. Note we don't make an effort to pass down to readline
all keys returned by curses, only the common ones that readline
understands by default. Given users can specify their own readline
bindings (inputrc file, bind utility), this approach is good in
practice, though not 100% transparent or perfect.
Note that the patch makes it so that CTLC-L is always passed to
readline even if the command window does not have the focus. It was
simpler to implement that way, and it just seems correct to me. I
don't know of a reason we shouldn't do that.
The patch improves the TUI behavior in a related way. Now we can pass
special keys to readline irrespective of which window has the focus.
First, we try to dispatch the key to a window, via
tui_displatch_ctrl_char. If the key is dispatched, then we don't pass
it to readline. E.g., pressing "up" when you have the source window
in focus results in scrolling the source window, and nothing else. If
however, you press ctrl-del instead, that results in killing the next
word in the command window, no matter which window has has focus.
Before, it would only work if you had the command window in focus.
Similarly, ctrl-left/ctrl-right to move between words, etc.
Similarly, the previous spot where we handled mouse events was
incorrect. It was never reached if the window with focus can't
scroll, which is the case for the command window. Mouse scrolling
affects the window under the mouse cursor, not the window in focus.
We now always try to dispatch mouse events.
One last bit in the patch -- now if we don't recognize the non-8-bit
curses key, then we don't pass it down to readline at all. Before
that would result in bogus characters in the input line.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <pedro@palves.net>
* tui/tui-io.c (tui_dispatch_mouse_event): New, factored out from
...
(tui_dispatch_ctrl_char): ... this. Move CTRL-L handling to
tui_getc_1.
(cur_seq, start_sequence): New.
(tui_getc_1): Pass key escape sequences for curses control keys to
readline. Handle mouse and ctrl-l here.
(tui_resize_all): Disable/reenable the keypad if the command
window has the focus too.
* tui/tui-win.c (tui_set_focus_command): Don't change keypad
setting.
* tui/tui.c (tui_rl_other_window): Don't change keypad setting.
Change-Id: Ie0a7d849943cfb47f4a6589e1c73341563740fa9
Clément Chigot [Mon, 14 Jun 2021 11:25:42 +0000 (13:25 +0200)]
gas: ensure sections contents is zero for BFD_RELOC_PPC*_TLSM on XCOFF.
AIX ld expects the section contents for relocations BFD_RELOC_PPC_TLSM
or BFD_RELOC_PPC64_TLSM to be zero.
Actually, it seems to be the case for all the TLS relocations
generated by AIX assembly but only these two are mandatory.
* config/tc-ppc.c (md_apply_fix): Adjust addend to nullify
section contents for BFD_RELOC_PPC_TLSM or
BFD_RELOC_PPC64_TLSM.
* testsuite/gas/ppc/xcoff-tlsm-32.d: New test.
* testsuite/gas/ppc/xcoff-tlsm-64.d: New test.
* testsuite/gas/ppc/xcoff-tlsm.s: New test.
* testsuite/gas/ppc/aix.exp: Run new tests.
Alan Modra [Wed, 16 Jun 2021 07:05:53 +0000 (16:35 +0930)]
powerpc: move cell "or rx,rx,rx" hints
* ppc-opc.c (powerpc_opcodes): Move cell db*cyc to proper location
in table.
Mike Frysinger [Thu, 17 Jun 2021 04:12:15 +0000 (00:12 -0400)]
sim: mn10300: tweak static inlines
Use INLINE2 instead of INLINE to fix builds when -O0 are used -- the
latter define is omitted at -O0 levels while the former is always
set to inline. These helper funcs are used by defines in here but
the defines aren't always called.