Philippe Waroquiers [Tue, 4 Dec 2018 22:28:14 +0000 (23:28 +0100)]
Fix a (one shot small) leak in language.c
Valgrind detects the following leak:
==28395== VALGRIND_GDB_ERROR_BEGIN
==28395== 5 bytes in 1 blocks are definitely lost in loss record 20 of 2,770
==28395== at 0x4C2BE2D: malloc (vg_replace_malloc.c:299)
==28395== by 0x41D9E7: xmalloc (common-utils.c:44)
==28395== by 0x78BF39: xstrdup (xstrdup.c:34)
==28395== by 0x51F1AC: _initialize_language() (language.c:1175)
==28395== by 0x6B3356: initialize_all_files() (init.c:308)
==28395== by 0x66D194: gdb_init(char*) (top.c:2159)
==28395== by 0x554C11: captured_main_1 (main.c:863)
==28395== by 0x554C11: captured_main (main.c:1167)
==28395== by 0x554C11: gdb_main(captured_main_args*) (main.c:1193)
==28395== by 0x29D837: main (gdb.c:32)
==28395==
==28395== VALGRIND_GDB_ERROR_END
This is a very small leak (1 block/5 bytes), happening only once
per GDB startup as far as I can see. But this fix make the nr of leaking
GDB in the testsuite decreasing from 628 to 566.
It is unclear why a xstrdup-ed value is assigned to 'language'
at initialization time, while a static "auto" string is assigned
as part of the set_language_command.
So, that shows that it is ok to initialize 'language' directly
with "auto".
Also, I cannot find any place where 'language' is xfree-d.
No leak was detected for 'range' and 'case_sensitive', but
similarly, no indication why a static string cannot be assigned.
Regression-tested on debian/x86_64.
Also, full testsuite run under valgrind, less tests leaking,
and no dangling pointer problem detected.
gdb/ChangeLog
2018-12-05 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* language.c (_initialize_language): Fix leak by assigning
a static string to language. Same for range and case_sensitive,
even if no leak is detected for these variables.
Alan Modra [Fri, 7 Dec 2018 13:09:42 +0000 (23:39 +1030)]
PR23952, memory leak in _bfd_generic_read_minisymbols
bfd/
PR 23952
* syms.c (_bfd_generic_read_minisymbols): Free syms before
returning with zero symcount.
binutils/
* nm.c (display_rel_file): Use xrealloc to increase minisyms
for synthetic symbols.
Nick Clifton [Fri, 7 Dec 2018 11:32:55 +0000 (11:32 +0000)]
Synchronize libiberty with gcc and add --no-recruse-limit option to tools that support name demangling.
This patch addresses the multitude of bug reports about resource exhaustion
in libiberty's name demangling code. It adds a limit to the amount of
recursion that is allowed, before an error is triggered. It also adds a
new demangling option to disable this limit. (The limit is enabled by
default).
PR 87681
PR 87675
PR 87636
PR 87335
libiberty * cp-demangle.h (struct d_info): Add recursion_limit field.
* cp-demangle.c (d_function_type): If the recursion limit is
enabled and reached, return with a failure result.
(d_demangle_callback): If the recursion limit is enabled, check
for a mangled string that is so long that there is not enough
stack space for the local arrays.
* cplus-dem.c (struct work): Add recursion_level field.
(demangle_nested_args): If the recursion limit is enabled and
reached, return with a failure result.
include * demangle.h (DMGL_RECURSE_LIMIT): Define.
(DEMANGLE_RECURSION_LIMIT): Prototype.
binutuils * addr2line.c (demangle_flags): New static variable.
(long_options): Add --recurse-limit and --no-recurse-limit.
(translate_address): Pass demangle_flags to bfd_demangle.
(main): Handle --recurse-limit and --no-recurse-limit options.
* cxxfilt.c (flags): Add DMGL_RECURSE_LIMIT.
(long_options): Add --recurse-limit and --no-recurse-limit.
(main): Handle new options.
* dlltool.c (gen_def_file): Include DMGL_RECURSE_LIMIT in flags
passed to cplus_demangle.
* nm.c (demangle_flags): New static variable.
(long_options): Add --recurse-limit and --no-recurse-limit.
(main): Handle new options.
* objdump.c (demangle_flags): New static variable.
(usage): Add --recurse-limit and --no-recurse-limit.
(long_options): Likewise.
(objdump_print_symname): Pass demangle_flags to bfd_demangle.
(disassemble_section): Likewise.
(dump_dymbols): Likewise.
(main): Handle new options.
* prdbg.c (demangle_flags): New static variable.
(tg_variable): Pass demangle_flags to demangler.
(tg_start_function): Likewise.
* stabs.c (demangle_flags): New static variable.
(stab_demangle_template): Pass demangle_flags to demangler.
(stab_demangle_v3_argtypes): Likewise.
(stab_demangle_v3_arg): Likewise.
* doc/binutuls.texi: Document new command line options.
* NEWS: Mention the new feature.
* testsuite/config/default.exp (CXXFILT): Define if not already
defined.
(CXXFILTFLAGS): Likewise.
* testsuite/binutils-all/cxxfilt.exp: New file. Runs a few
simple tests of the cxxfilt program.
GDB Administrator [Fri, 7 Dec 2018 00:00:46 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Thu, 6 Dec 2018 20:28:46 +0000 (12:28 -0800)]
gold: Provide more failed archive member info in error message
When gold fails to get an archive member, its error message doesn't
have information for
1. The failed archive member name.
2. The cause of failure: non-ELF object vs non-IR object.
This patch adds the failed archive member name and non-ELF/non-IR info
to gold error message.
* archive.cc (Archive::get_elf_object_for_member): Also print
archive member and non-ELF/non-IR info on error.
Alan Modra [Thu, 6 Dec 2018 10:21:27 +0000 (20:51 +1030)]
PowerPC @l, @h and @ha warnings, plus VLE e_li
This patch started off just adding the warnings in tc-ppc.c about
incorrect usage of @l, @h and @ha in instructions that don't have
16-bit D-form fields. That unfortunately showed up three warnings in
ld/testsuite/ld-powerpc/vle-multiseg.s on instructions like
e_li r3, IV_table@l+0x00
which was being assembled to
8: 70 60 00 00 e_li r3,0
a: R_PPC_ADDR16_LO IV_table
The ADDR16_LO reloc is of course completely bogus on e_li, which has
a split 20-bit signed integer field in bits 0x1f7fff, the low 11 bit
in 0x7ff, the next 5 bits in 0x1f0000, and the high 4 bits in 0x7800.
Applying an ADDR16_LO reloc to the instruction potentially changes
the e_li instruction to e_add2i., e_add2is, e_cmp16i, e_mull2i,
e_cmpl16i, e_cmph16i, e_cmphl16i, e_or2i, e_and2i., e_or2is, e_lis,
e_and2is, or some invalid encodings.
Now there is a relocation that suits e_li, R_PPC_VLE_ADDR20, which was
added 2017-09-05 but I can't see code in gas to generate the
relocation. In any case, VLE_ADDR20 probably doesn't have the correct
semantics for @l since ideally you'd want an @l to pair with @h or @ha
to generate a 32-bit constant. Thus @l should only produce a 16-bit
value, I think. So we need some more relocations to handle e_li it
seems, or as I do in this patch, modify the behaviour of existing
relocations when applied to e_li instructions.
include/
* opcode/ppc.h (E_OPCODE_MASK, E_LI_MASK, E_LI_INSN): Define.
bfd/
* elf32-ppc.c (ppc_elf_howto_raw <R_PPC_VLE_ADDR20>): Correct
mask and shift value.
(ppc_elf_vle_split16): Use E_OPCODE_MASK. Handle e_li
specially.
gas/
* config/tc-ppc.c (md_assemble): Adjust relocs for VLE before
TLS tweaks. Handle e_li. Warn on unexpected operand field
for lo16/hi16/ha16 relocs.
Andrew Burgess [Tue, 16 Oct 2018 09:49:15 +0000 (10:49 +0100)]
sim/cris: Fix references to cgen cpu directory
Don't assume that cgen is located within the binutils-gdb tree. We
already have CGEN_CPU_DIR and CPU_DIR defined, these are the cpu/
directory within cgen, and the cpu/ directory within binutils-cpu.
The cris target tries to find CPU_DIR relative to the cgen source
tree, which can be wrong when building with an out of tree cgen.
sim/cris/ChangeLog:
* Makefile.in: Replace uses of CGEN_CPU_DIR with CPU_DIR, and
remove the definition of CGEN_CPU_DIR.
Andrew Burgess [Wed, 10 Oct 2018 13:58:10 +0000 (14:58 +0100)]
sim/opcodes: Allow use of out of tree cgen source directory
When configuring with '--enbale-cgen-maint' the default for both the
opcodes/ and sim/ directories is to assume that the cgen source is
within the binutils-gdb source tree as binutils-gdb/cgen/.
In the old cvs days, this worked well, as cgen was just another
sub-module of the single cvs repository and could easily be checked
out within the binutils-gdb directory, and managed by cvs in the
normal way.
Now that binutils-gdb is in git, while cgen is still in cvs, placing
the cgen respository within the binutils-gdb tree is more troublesome,
and it would be nice if the two tools could be kept separate.
Luckily there is already some initial code in the configure.ac files
for both opcodes/ and sim/ to support having cgen be located outside
of the binutils-gdb tree, however, this was speculative code written
imagining a future where cgen would be built and installed to some
location.
Right now there is no install support for cgen, and so the configure
code in opcodes/ and sim/ doesn't really do anything useful. In this
commit I repurpose this code to allow binutils-gdb to be configured so
that it can make use of a cgen source directory that is outside of the
binutils-gdb tree.
With this commit applied it is now possible to configure and build
binutils-gdb like this:
/path/to/binutils-gdb/src/configure --enable-cgen-maint=/path/to/cgen/src/cgen/
make all-opcodes
make -C opcodes run-cgen-all
Just in case anyone is still using cgen inside the binutils-gdb tree,
I have left the default behaviour of '--enable-cgen-maint' (with no
parameter) unchanged, that is it looks for the cgen directory as
'binutils-gdb/cgen/'.
opcodes/ChangeLog:
* configure.ac (enable-cgen-maint): Support passing path to cgen
source tree.
* configure: Regenerate.
sim/ChangeLog:
* common/acinclude.m4 (enable-cgen-maint): Support passing path to
cgen source tree.
* cris/configure: Regenerate.
* frv/configure: Regenerate.
* iq2000/configure: Regenerate.
* lm32/configure: Regenerate.
* m32r/configure: Regenerate.
* or1k/configure: Regenerate.
* sh64/configure: Regenerate.
Andrew Burgess [Mon, 3 Dec 2018 14:46:18 +0000 (14:46 +0000)]
opcodes/riscv: Hide '.L0 ' fake symbols
The RISC-V assembler generates fake labels with the name '.L0 ' as
part of the debug information (see
gas/config/tc-riscv.h:FAKE_LABEL_NAME).
The problem is that currently, when disassembling an object file, the
output looks like this (this is an example from the GDB testsuite, but
is pretty representative of anything with debug information):
000000000000001e <main>:
1e: 7179 addi sp,sp,-48
20: f406 sd ra,40(sp)
22: f022 sd s0,32(sp)
24: 1800 addi s0,sp,48
0000000000000026 <.L0 >:
26: 87aa mv a5,a0
28:
feb43023 sd a1,-32(s0)
2c:
fcc43c23 sd a2,-40(s0)
30:
fef42623 sw a5,-20(s0)
0000000000000034 <.L0 >:
34:
fec42783 lw a5,-20(s0)
38:
0007871b sext.w a4,a5
3c: 678d lui a5,0x3
3e:
03978793 addi a5,a5,57 # 3039 <.LASF30+0x2a9d>
42:
02f71463 bne a4,a5,6a <.L0 >
0000000000000046 <.L0 >:
46:
000007b7 lui a5,0x0
4a:
0007b783 ld a5,0(a5) # 0 <need_malloc>
4e: 6f9c ld a5,24(a5)
0000000000000050 <.L0 >:
50: 86be mv a3,a5
52: 466d li a2,27
54: 4585 li a1,1
56:
000007b7 lui a5,0x0
5a:
00078513 mv a0,a5
5e:
00000097 auipc ra,0x0
62:
000080e7 jalr ra # 5e <.L0 +0xe>
0000000000000066 <.L0 >:
66: 4785 li a5,1
68: a869 j 102 <.L0 >
000000000000006a <.L0 >:
6a:
000007b7 lui a5,0x0
6e:
00078513 mv a0,a5
72:
00000097 auipc ra,0x0
76:
000080e7 jalr ra # 72 <.L0 +0x8>
The frequent repeated '.L0 ' labels are pointless, as they are
non-unique there's no way to match a use of '.L0 ' to its appearence
in the output, so we'd be better off just not printing it at all.
That's what this patch does by defining a 'symbol_is_valid' method for
RISC-V. With this commit, the same disassembly now looks like this:
000000000000001e <main>:
1e: 7179 addi sp,sp,-48
20: f406 sd ra,40(sp)
22: f022 sd s0,32(sp)
24: 1800 addi s0,sp,48
26: 87aa mv a5,a0
28:
feb43023 sd a1,-32(s0)
2c:
fcc43c23 sd a2,-40(s0)
30:
fef42623 sw a5,-20(s0)
34:
fec42783 lw a5,-20(s0)
38:
0007871b sext.w a4,a5
3c: 678d lui a5,0x3
3e:
03978793 addi a5,a5,57 # 3039 <.LASF30+0x2a9d>
42:
02f71463 bne a4,a5,6a <.L4>
46:
000007b7 lui a5,0x0
4a:
0007b783 ld a5,0(a5) # 0 <need_malloc>
4e: 6f9c ld a5,24(a5)
50: 86be mv a3,a5
52: 466d li a2,27
54: 4585 li a1,1
56:
000007b7 lui a5,0x0
5a:
00078513 mv a0,a5
5e:
00000097 auipc ra,0x0
62:
000080e7 jalr ra # 5e <main+0x40>
66: 4785 li a5,1
68: a869 j 102 <.L5>
000000000000006a <.L4>:
6a:
000007b7 lui a5,0x0
6e:
00078513 mv a0,a5
72:
00000097 auipc ra,0x0
76:
000080e7 jalr ra # 72 <.L4+0x8>
In order to share the fake label between the assembler and the
libopcodes library, I've added some new defines RISCV_FAKE_LABEL_NAME
and RISCV_FAKE_LABEL_CHAR in include/opcode/riscv.h. I could have
just moved FAKE_LABEL_NAME to the include file, however, I thnk this
would be confusing, someone working on the assembler would likely not
expect to find FAKE_LABEL_NAME defined outside of the assembler source
tree. By introducing the RISCV_FAKE_LABEL_* defines I can leave the
assembler standard FAKE_LABEL_ defines in the assembler source, but
still share the RISCV_FAKE_LABEL_* with libopcodes.
gas/ChangeLog:
* config/tc-riscv.h (FAKE_LABEL_NAME): Define as
RISCV_FAKE_LABEL_NAME.
(FAKE_LABEL_CHAR): Define as RISCV_FAKE_LABEL_CHAR.
include/ChangeLog:
* dis-asm.h (riscv_symbol_is_valid): Declare.
* opcode/riscv.h (RISCV_FAKE_LABEL_NAME): Define.
(RISCV_FAKE_LABEL_CHAR): Define.
opcodes/ChangeLog:
* disassembler.c (disassemble_init_for_target): Add RISC-V
initialisation.
* riscv-dis.c (riscv_symbol_is_valid): New function.
GDB Administrator [Thu, 6 Dec 2018 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
John Baldwin [Wed, 5 Dec 2018 18:51:16 +0000 (10:51 -0800)]
Use separate sed expressions to escape auto-load directories.
Not all sed implementations support alternation via \| in the default
regular expressions. Instead, resort to separate sed expressions via
-e for $debugdir and $datadir. This fixes the default setting of the
auto-load directories on FreeBSD. Previously on FreeBSD the sed
invocation was a no-op causing the debugdir and datadir values to be
expanded yielding an autoload path of ':${prefix}/share/gdb'.
gdb/ChangeLog:
* configure: Re-generate.
* configure.ac: Use separate sed expressions to escape variables
in auto-load directories.
Sam Tebbs [Wed, 5 Dec 2018 18:27:23 +0000 (18:27 +0000)]
[aarch64] Add support for pointer authentication B key
Armv8.3-A has another key used in pointer authentication called the
B-key (other than the A-key that is already supported). In order for
stack unwinders to work it is necessary to be able to identify frames
that have been signed with the B-key rather than the A-key and it was
felt that keeping this as an augmentation character in the CIE was the
best bet. The DWARF extensions for ARM therefore propose to add a new
augmentation character 'B' to the CIE augmentation string and the
corresponding cfi directive ".cfi_b_key_frame". I've made the relevant
changes to GAS and LD to add support for B-key unwinding, which required
modifying LD to check for 'B' in the augmentation string, adding the
".cfi_b_key_frame" directive to GAS and adding a "pauth_key" field to
GAS's fde_entry and cie_entry structs.
The pointer authentication instructions will behave as NOPs on
architectures that don't support them, and so a check for the
architecture being assembled for is not necessary since there will be no
behavioural difference between augmentation strings with and without the
'B' character on such architectures.
2018-12-05 Sam Tebbs <sam.tebbs@arm.com>
bfd/
* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Add check for 'B'.
gas/
* dw2gencfi.c (struct cie_entry): Add tc_cie_entry_extras invocation.
(alloc_fde_entry): Add tc_fde_entry_init_extra invocation.
(output_cie): Add tc_output_cie_extra invocation.
(select_cie_for_fde): Add tc_cie_fde_equivalent_extra and
tc_cie_entry_init_extra invocation.
(frch_cfi_data, cfa_save_data): Move to dwgencfi.h.
* config/tc-aarch64.c (s_aarch64_cfi_b_key_frame): Declare.
(md_pseudo_table): Add "cfi_b_key_frame".
* config/tc-aarch64.h (tc_fde_entry_extras, tc_cie_entry_extras,
tc_fde_entry_init_extra, tc_output_cie_extra,
tc_cie_fde_equivalent_extra, tc_cie_entry_init_extra): Define.
* dw2gencfi.h (struct fde_entry): Add tc_fde_entry_extras invocation.
(pointer_auth_key): Define.
(frch_cfi_data, cfa_save_data): Move from dwgencfi.c.
* doc/c-aarch64.texi (.cfi_b_key_frame): Add documentation.
* testsuite/gas/aarch64/(pac_ab_key.d, pac_ab_key.s): New file.
Andrew Burgess [Mon, 3 Dec 2018 17:48:49 +0000 (17:48 +0000)]
gdb/riscv: Improve logic for when h/w float abi should be used
Currently, if the target announces that it has floating point
registers in its target description then GDB assumes that the hardware
float ABI should be used. However, there's nothing stopping a user
compiling a program for the soft-float abi, and then trying to run
this on a target with hardware floating point registers.
This commit adjusts the logic that decides if GDB should use the
hardware float abi. The primary decision now is based on what the ELF
currently being executed says in its headers. If the file was
compiled for h/w float abi, then GDB uses h/w float abi, otherwise s/w
float is used.
If the current BFD is not an ELF then we don't currently have a
mechanism for figuring out if the file was compiled for float or not.
In this case we disable the h/w float abi. This shouldn't be a
problem as, right now, the RISC-V linker can only produce ELFs.
If there is NO current BFD (can this happen?) then we will enable h/w
float abi if the target has floating point hardware, otherwise, s/w
float abi is used.
This commit also adds some sanity checking that the features requested
in the BFD (xlen and flen) match the target description.
For testing I ran the testsuite on a target that returns a target
description containing both integer and floating point registers, but
used a compiler that didn't have floating point support. Before this
commit I would see failures on may tests that made inferior calls
using floating point arguments, after this commit, all of these issues
are resolved. One example from the testsuite is
gdb.base/infcall-nested-structs.exp.
gdb/ChangeLog:
* riscv-tdep.c (riscv_features_from_gdbarch_info): New function.
(riscv_find_default_target_description): Use new function to
extract feature from gdbarch_info.
(riscv_gdbarch_init): Add error checks for xlen and flen between
target description and bfd headers. Be smarter about when we
think the hardware floating point abi should be used.
Andrew Burgess [Tue, 4 Dec 2018 11:29:47 +0000 (11:29 +0000)]
gdb/testsuite/sim: Remove redundant setting of timeout
In the config/sim.exp file two functions are defined. Both of these
functions define local timeout variables and then call gdb_expect,
which (through a call to get_largest_timeout) will find the local
definition of timeout.
However, both of these functions set the local timeout to some
arbitrary value and print a log message for this "new" timeout just
before returning.
As in both cases, the timeout is a local variable, this final setting
of the timeout has no effect and can be removed.
As having log messages about the timeout being adjusted could cause
confusion I've removed all logging related to timeouts in this
function, timeouts are adjusted throughout the testsuite without any
logging, there doesn't seem to be any good reason why these functions
should get their own logging.
With the logging gone there seems to be little need to a local timeout
variable at all, and so I've folded the local timeout directly into
the call to gdb_expect.
gdb/testsuite/ChangeLog:
* config/sim.exp (gdb_target_sim): Remove redundant adjustment of
local timeout variable before return, and remove all local timeout
variable entirely.
(gdb_load): Likewise.
Alan Hayward [Wed, 5 Dec 2018 10:34:54 +0000 (10:34 +0000)]
AArch64: Racy: Don't set empty set of hardware BPs/WPs on new thread
On some heavily loaded AArch64 boxes, GDB will sometimes hang forever when
the inferior creates a thread. This hang happens inside the kernel during
the ptrace call to set hardware watchpoints or hardware breakpoints.
Currently, GDB will always set hw wp/bp at the start of each thread even if
there are none set in the process.
This patch works around the issue by avoiding setting hw wp/bp if there
are none set for the process.
On an effected machine, this fix drastically reduces the racy nature of the
gdb.threads test set. I ran the entire gdb test suite across all processors
for 100 iterations, then ran the results through the racy tests script.
Without the patch, 58 .exp files in gdb.threads were marked as racy. After
the patch this reduced to the same ~14 tests as the non effected boxes.
Clearly GDB will still be subject to hangs on an effect box if hw wp/bp's are
used prior to creating inferior threads on a heavily loaded system.
To enable this in gdbserver, the sequence in gdbserver add_lwp() is switched
to the same as gdb order as gdb, to ensure the thread is registered before
calling new_thread(). This allows aarch64_linux_new_thread() to read the
ptid.
gdb/ChangeLog:
* nat/aarch64-linux-hw-point.c
(aarch64_linux_any_set_debug_regs_state): New function.
* nat/aarch64-linux-hw-point.h
(aarch64_linux_any_set_debug_regs_state): New declaration.
* nat/aarch64-linux.c (aarch64_linux_new_thread): Check if any
BPs or WPs are set.
gdb/gdbserver/ChangeLog:
* linux-low.c (add_lwp): Switch ordering.
Alan Modra [Wed, 5 Dec 2018 01:49:34 +0000 (12:19 +1030)]
gold won't build with gcc-9
* symtab.h (Symbol::Symbol): Avoid -Wclass-memaccess warning.
GDB Administrator [Wed, 5 Dec 2018 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Tue, 4 Dec 2018 14:00:57 +0000 (06:00 -0800)]
x86: Don't remove empty GNU_PROPERTY_X86_UINT32_OR_AND properties
For GNU_PROPERTY_X86_COMPAT_ISA_1_USED and GNU_PROPERTY_X86_UINT32_OR_AND
properties, a bit in the output pr_data field is set if it is set in any
relocatable input pr_data fields and this property is present in all
relocatable input files. A missing property implies that its bits have
unknown values. When all bits in the the output pr_data field are zero,
this property should not be removed from output to indicate it has zero
in all bits.
bfd/
PR ld/23372
* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Don't remove
empty properties for GNU_PROPERTY_X86_COMPAT_ISA_1_USED and
GNU_PROPERTY_X86_UINT32_OR_AND.
(_bfd_x86_elf_link_fixup_gnu_properties): Likewise.
ld/
PR ld/23372
* testsuite/ld-i386/pr23372a.d: Updated.
* testsuite/ld-i386/pr23372c.d: Likewise.
* testsuite/ld-x86-64/pr23372a-x32.d: Likewise.
* testsuite/ld-x86-64/pr23372a.d: Likewise.
* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
* testsuite/ld-x86-64/pr23372c.d: Likewise.
Alexey Neyman [Tue, 4 Dec 2018 07:50:48 +0000 (23:50 -0800)]
Restore build on x86_64-w64-mingw32.
gold/
PR gold/23594
* configure.ac: Add checks for link, mkdtemp.
* configure: Regenerate.
* config.in: Regenerate.
* plugin.cc (Plugin_recorder::init): Fall back to mktemp
if mkdtemp is not available.
(link_or_copy_file): Fall back to copy if link() is not available.
wu.heng [Mon, 3 Dec 2018 02:02:13 +0000 (12:32 +1030)]
PR23939, Check frch_cfi_data before use
PR 23939
* dw2gencfi.c (dot_cfi_label): Check frch_cfi_data is non-NULL
before use.
GDB Administrator [Tue, 4 Dec 2018 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Mon, 3 Dec 2018 21:59:44 +0000 (13:59 -0800)]
RISC-V: Accept version, supervisor ext and more than one NSE for -march.
This patch moves all -march parsing logic into bfd, because we will use this
code in ELF attributes.
bfd/
* elfxx-riscv.h (RISCV_DONT_CARE_VERSION): New macro.
(struct riscv_subset_t): New structure.
(riscv_subset_t): New typedef.
(riscv_subset_list_t): New structure.
(riscv_release_subset_list): New prototype.
(riscv_add_subset): Likewise.
(riscv_lookup_subset): Likewise.
(riscv_lookup_subset_version): Likewise.
(riscv_release_subset_list): Likewise.
* elfxx-riscv.c: Include safe-ctype.h.
(riscv_parsing_subset_version): New function.
(riscv_supported_std_ext): Likewise.
(riscv_parse_std_ext): Likewise.
(riscv_parse_sv_or_non_std_ext): Likewise.
(riscv_parse_subset): Likewise.
(riscv_add_subset): Likewise.
(riscv_lookup_subset): Likewise.
(riscv_lookup_subset_version): Likewise.
(riscv_release_subset_list): Likewise.
gas/
* config/tc-riscv.c: Include elfxx-riscv.h.
(struct riscv_subset): Removed.
(riscv_subsets): Change type to riscv_subset_list_t.
(riscv_subset_supports): Removed argument: xlen_required and move
logic into libbfd.
(riscv_multi_subset_supports): Removed argument: xlen_required.
(riscv_clear_subsets): Removed.
(riscv_add_subset): Ditto.
(riscv_set_arch): Extract parsing logic into libbfd.
(riscv_ip): Update argument for riscv_multi_subset_supports and
riscv_subset_supports. Update riscv_subsets due to struct definition
changed.
(riscv_after_parse_args): Update riscv_subsets due to struct
definition changed, update and argument for riscv_subset_supports.
* testsuite/gas/riscv/empty.s: New.
* testsuite/gas/riscv/march-fail-rv32ef.d: Likewise.
* testsuite/gas/riscv/march-fail-rv32ef.l: Likewise.
* testsuite/gas/riscv/march-fail-rv32i.d: Likewise.
* testsuite/gas/riscv/march-fail-rv32i.l: Likewise.
* testsuite/gas/riscv/march-fail-rv32iam.d: Likewise.
* testsuite/gas/riscv/march-fail-rv32iam.l: Likewise.
* testsuite/gas/riscv/march-fail-rv32ic.d: Likewise.
* testsuite/gas/riscv/march-fail-rv32ic.l: Likewise.
* testsuite/gas/riscv/march-fail-rv32icx2p.d: Likewise.
* testsuite/gas/riscv/march-fail-rv32icx2p.l: Likewise.
* testsuite/gas/riscv/march-fail-rv32imc.d: Likewise.
* testsuite/gas/riscv/march-fail-rv32imc.l: Likewise.
* testsuite/gas/riscv/march-fail-rv64I.d: Likewise.
* testsuite/gas/riscv/march-fail-rv64I.l: Likewise.
* testsuite/gas/riscv/march-fail-rv64e.d: Likewise.
* testsuite/gas/riscv/march-fail-rv64e.l: Likewise.
* testsuite/gas/riscv/march-ok-g2.d: Likewise.
* testsuite/gas/riscv/march-ok-g2p0.d: Likewise.
* testsuite/gas/riscv/march-ok-i2p0.d: Likewise.
* testsuite/gas/riscv/march-ok-nse-with-version.: Likewise.d
* testsuite/gas/riscv/march-ok-s-with-version.d: Likewise.
* testsuite/gas/riscv/march-ok-s.d: Likewise.
* testsuite/gas/riscv/march-ok-sx.d: Likewise.
* testsuite/gas/riscv/march-ok-two-nse.d: Likewise.
* testsuite/gas/riscv/march-ok-g2_p1.d: Likewise.
* testsuite/gas/riscv/march-ok-i2p0m2_a2f2.d: Likewise.
include/
* opcode/riscv.h (riscv_opcode): Change type of xlen_requirement to
unsigned.
opcodes/
* riscv-opc.c: Change the type of xlen, because type of
xlen_requirement changed.
Egeyar Bagcioglu [Mon, 3 Dec 2018 17:31:44 +0000 (17:31 +0000)]
[aarch64] - Only use MOV for disassembly when shifter op is LSL #0
ARM Architecture Reference Manual for the profile ARMv8-A, Issue C.a,
states that MOV (register) is an alias of the ORR (shifted register)
iff shift == '00' && imm6 == '000000' && Rn == '11111'. However, mov
is currently preferred for a broader range of orr instructions, which
is incorrect.
2018-12-03 Egeyar Bagcioglu <egeyar.bagcioglu@oracle.com>
opcodes:
PR 23193
PR 19721
* aarch64-tbl.h (aarch64_opcode_table): Only disassemble an ORR
encoding as MOV if the shift operation is a left shift of zero.
gas:
PR 23193
PR 19721
* testsuite/gas/aarch64/pr19721.s: Add new test cases.
* testsuite/gas/aarch64/pr19721.d: Correct existing test
cases and add new ones.
Nick Clifton [Mon, 3 Dec 2018 17:26:41 +0000 (17:26 +0000)]
Update the assembler to use a version of 3 when generating the header of the .debug_line section.
PR 23941
gas * dwarf2dbg.c (DWARF2_LINE_VERSION): Change to 3.
* testsuite/gas/elf/dwarf2-3.d: Update expected output.
* testsuite/gas/elf/dwarf2-5.d: Likewise.
* testsuite/gas/i386/debug1.d: Likewise.
* testsuite/gas/i386/dw2-compress-1.d: Likewise.
* testsuite/gas/i386/dw2-compress-3a.d: Likewise.
* testsuite/gas/i386/dw2-compress-3b.d: Likewise.
* testsuite/gas/i386/dw2-compressed-1.d: Likewise.
* testsuite/gas/i386/dw2-compressed-3a.d: Likewise.
* testsuite/gas/i386/dw2-compressed-3b.d: Likewise.
* testsuite/gas/ia64/pr13167.d: Likewise.
* testsuite/gas/mips/loc-swap-2.d: Likewise.
* testsuite/gas/mips/loc-swap.d: Likewise.
* testsuite/gas/mips/micromips@loc-swap-2.d: Likewise.
* testsuite/gas/mips/micromips@loc-swap.d: Likewise.
* testsuite/gas/mips/mips16@loc-swap-2.d: Likewise.
* testsuite/gas/mips/mips16@loc-swap.d: Likewise.
* testsuite/gas/mips/mips16e@loc-swap.d: Likewise.
binutils* testsuite/binutils-all/i386/compressed-1a.d: Update expected output.
* testsuite/binutils-all/x86-64/compressed-1a.d: Likewise.
GDB Administrator [Mon, 3 Dec 2018 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sun, 2 Dec 2018 13:42:36 +0000 (05:42 -0800)]
gold: Get alignment of uncompressed section from ch_addralign
The ELF compression header has a field (ch_addralign) that is set to
the alignment of the uncompressed section. This way the section itself
can have a different alignment than the decompressed section. Update
decompress_input_section to get alignment of the decompressed section
and use it when merging decompressed strings.
PR binutils/23919
* merge.cc (Output_merge_string<Char_type>::do_add_input_section):
Get addralign from decompressed_section_contents.
* object.cc (build_compressed_section_map): Set info.addralign.
(Object::decompressed_section_contents): Add a palign
argument and store p->second.addralign in *palign if it isn't
NULL.
* object.h (Compressed_section_info): Add addralign.
(section_is_compressed): Add a palign argument, default it
to NULL, store p->second.addralign in *palign if it isn't NULL.
(Object::decompressed_section_contents): Likewise.
* output.cc (Output_section::add_input_section): Get addralign
from section_is_compressed.
GDB Administrator [Sun, 2 Dec 2018 00:01:21 +0000 (00:01 +0000)]
Automatic date update in version.in
H.J. Lu [Sat, 1 Dec 2018 13:42:33 +0000 (05:42 -0800)]
x86: Delay setting the iplt section alignment
Delay setting its alignment until we know it is non-empty. Otherwise an
empty iplt section may change vma and lma of the following sections, which
triggers moving dot of the following section backwards, resulting in a
warning and section lma not being set properly. It later leads to a
"File truncated" error.
bfd/
PR ld/23930
* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Update
the iplt section alignment if it is non-empty.
(_bfd_x86_elf_link_setup_gnu_properties): Set plt.iplt_alignment
and delay setting the iplt section alignment.
* elfxx-x86.h (elf_x86_plt_layout): Add iplt_alignment.
ld/
PR ld/23930
* testsuite/ld-i386/i386.exp: Run pr23930.
* testsuite/ld-i386/pr23930.d: New file.
* testsuite/ld-x86-64/pr23930-32.t: Likewise.
* testsuite/ld-x86-64/pr23930-x32.d: Likewise.
* testsuite/ld-x86-64/pr23930.d: Likewise.
* testsuite/ld-x86-64/pr23930.t: Likewise.
* testsuite/ld-x86-64/pr23930a.s: Likewise.
* testsuite/ld-x86-64/pr23930b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr23930 and pr23930-x32.
Alan Modra [Sat, 1 Dec 2018 11:22:37 +0000 (21:52 +1030)]
PR23946, illegal memory access in readelf.c:slurp_ia64_unwind_table
PR 23946
* readelf.c (slurp_ia64_unwind_table): Bounds check symbol index
on reloc.
(slurp_hppa_unwind_table): Likewise.
Alan Modra [Sat, 1 Dec 2018 10:45:03 +0000 (21:15 +1030)]
PR23945, NULL pointer dereference in readelf.c:slurp_hppa_unwind_table
PR 23945
* readelf.c (slurp_ia64_unwind_table): Don't call elf_ia64_reloc_type
needlessly.
(slurp_hppa_unwind_table): Use same range checks and error messages
as slurp_ia64_unwind_table.
Tom de Vries [Sat, 1 Dec 2018 07:56:56 +0000 (08:56 +0100)]
[gdb/testsuite] Add gdb-caching-proc.exp testcase
When caching a proc using gdb_caching_proc, it will become less likely to
be executed, and consequently it's going to be harder to detect that the
proc is racy. OTOH, in general the proc is easy to rerun. So, add a
test-case to run all uncached gdb_caching_procs a number of times and detect
inconsistent results.
The purpose of caching is to reduce runtime, so rerunning is somewhat
counter-productive in that aspect, but it's better than uncached, because the
number of reruns is constant-bounded, and the increase in runtime is bound to
this test-case, and can be disabled on slow targets.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2018-12-01 Tom de Vries <tdevries@suse.de>
* gdb.base/gdb-caching-proc.exp: New file.
Alan Modra [Fri, 30 Nov 2018 23:07:48 +0000 (09:37 +1030)]
PR23938, should not free memory alloced in obstack by free()
This removes ineffectual and wrong code caching section names in
gas/stabs.c. Code like
seg = subseg_new (name, 0);
...
if (seg->name == name)
seg->name = xstrdup (name);
with the idea of being able to unconditionally free "name" later no
longer works. "name" is referenced by the section hash table as well
as in the section->name field. It would be possible to use
"bfd_rename_section (stdoutput, seg, xstrdup (name))", but instead I
opted for a fairly straight-forward approach of adding extra
parameters to two functions to indicate section name strings should be
freed if possible.
PR 23938
* read.h (get_stab_string_offset): Update prototype.
* stabs.c (get_stab_string_offset): Add free_stabstr_secname
parameter. Free stabstr_secname if unused as section name.
Don't xstrdup name when used.
(s_stab_generic): Remove forward declaration. Add
stab_secname_obstack_end param. Reference notes obstack via
macros. Delete cached_secname. Adjust get_stab_string_offset
call. Free stab_secname if unused as section name.
(s_stab): Adjust s_stab_generic call.
(s_xstab): Likewise. Delete saved_secname and saved_strsecname.
* config/obj-elf.c (obj_elf_init_stab_section): Adjust
get_stab_string_offset call.
* config/obj-coff.c (obj_coff_init_stab_section): Likewise.
* config/obj-som.c (obj_som_init_stab_section): Likewise.
* testsuite/gas/all/pr23938.s: New test.
* testsuite/gas/all/gas.exp: Run it.
GDB Administrator [Sat, 1 Dec 2018 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in
John Baldwin [Fri, 30 Nov 2018 23:14:18 +0000 (15:14 -0800)]
Use kinfo_getfile to implement fdwalk on FreeBSD.
kinfo_getfile() requires a couple of system calls to fetch the list of
open file descriptors. This can be much cheaper than invoking fstat
on all of the values from 0 to the open file resource limit maximum.
gdb/ChangeLog:
* common/filestuff.c [HAVE_KINFO_GETFILE]: Include headers.
(fdwalk) [HAVE_KINFO_GETFILE]: Use kinfo_getfile.
Simon Marchi [Fri, 30 Nov 2018 21:49:35 +0000 (16:49 -0500)]
Fix leak in linespec parser
Valgrind reports this leak:
==798== VALGRIND_GDB_ERROR_BEGIN
==798== 32 (24 direct, 8 indirect) bytes in 1 blocks are definitely lost in loss record 447 of 3,143
==798== at 0x4C2C48C: operator new(unsigned long) (vg_replace_malloc.c:334)
==798== by 0x51D401: linespec_parser_new(ls_parser*, int, language_defn const*, program_space*, symtab*, int, linespec_result*) (linespec.c:2756)
==798== by 0x524BF7: decode_line_full(event_location const*, int, program_space*, symtab*, int, linespec_result*, char const*, char const*) (linespec.c:3271)
==798== by 0x3E8893: parse_breakpoint_sals(event_location const*, linespec_result*) (breakpoint.c:9067)
==798== by 0x3E4E7F: create_breakpoint(gdbarch*, event_location const*, char const*, int, char const*, int, int, bptype, int, auto_boolean, breakpoint_ops const*, int, int, int, unsigned int) (breakpoint.c:9248)
==798== by 0x3E55F5: break_command_1(char const*, int, int) (breakpoint.c:9434)
==798== by 0x40BA68: cmd_func(cmd_list_element*, char const*, int) (cli-decode.c:1888)
==798== by 0x665300: execute_command(char const*, int) (top.c:630)
...
linespec_parser_new allocates a std::vector<symtab *> at line 2756, and stores
the pointer to this vector in PARSER_RESULT (parser)->file_symtabs. At 3
different places in linespec.c, another std::vector is assigned to a
linespec->file_symtabs, without first deleting the current value.
The leak is fixed by assigning the vector itself instead of the pointer.
Everything should be moved, so there is no significant data copy
involved.
Tested on debian/amd64, + a bunch of tests re-run under valgrind
(including the test that throws an error).
gdb/ChangeLog:
* linespec.c (symtab_vector_up): Remove.
(symtabs_from_filename): Change return type to std::vector.
(collect_symtabs_from_filename): Likewise.
(create_sals_line_offset): Assign return value of
collect_symtabs_from_filename to *ls->file_symtabs.
(convert_explicit_location_to_linespec): Remove call to release.
(parse_linespec): Likewise.
(symtab_collector) <symtab_collector>: Remove initialization of
m_symtabs.
<release_symtabs>: Change return type to std::vector<symtab *>.
<operator ()>: Adjust.
John Baldwin [Fri, 30 Nov 2018 21:21:19 +0000 (13:21 -0800)]
Update the conditionals in fbsd-nat.h so they are always honored.
Not all of the architecture-specific FreeBSD target files were
including the right headers to enable conditionals in fbsd-nat.h after
the C++ target conversion. As a result, certain operations like 'info
auxv' and 'p $_siginfo' were not working for some native targets
(noticed on RISC-V). Fix this in a couple of ways:
1) Declare fbsd_nat_target::xfer_partial unconditionally and only use
conditionals in the function body for individual target objects.
Originally this function was only used to read the ELF auxiliary
vector, so the entire function was conditional on a macro required
for that object (KERN_AUXV_PROC). However, xfer_partial has since
grown support for additional objects. Making the function
unconditional avoids needing to add the right header to fbsd-nat.h
and allows each target object to use independent requirements.
This did require using a more explicit conditional test for the
$_siginfo support. Removing the "outer" KERN_PROC_AUXV test
enabled $_siginfo for all kernels with PT_LWPINFO, but some older
kernels (FreeBSD 6.0) exposed PT_LWPINFO with a different siginfo
format. Instead use an explicit test for when the current siginfo
format was adopted (shipped in FreeBSD 7.0). This actually enables
$_siginfo on a wider range of kernels as KERN_PROC_AUXV wasn't
introduced until FreeBSD 9.1/10.0.
2) Include <sys/proc.h> in fbsd-nat.h for the definition of
TDP_RFPPWAIT that governs support for fork following.
gdb/ChangeLog:
* fbsd-nat.c [__FreeBSD_version >= 700009] (USE_SIGINFO): Macro
defined.
(union sigval32, struct siginfo32, fbsd_siginfo_size)
(fbsd_convert_siginfo): Make conditional on USE_SIGINFO instead
of KERN_PROC_AUXV and PT_LWPINFO.
(fbsd_nat_target::xfer_partial): Define method unconditionally.
Make TARGET_OBJECT_SIGNAL_INFO conditional on USE_SIGINFO.
Make TARGET_OBJECT_AUXV conditional on KERN_PROC_AUXV.
Make TARGET_OBJECT_FREEBSD_VMMAP and
TARGET_OBJECT_FREEBSD_PS_STRINGS conditional on KERN_PROC_VMMAP
and KERN_PROC_PS_STRINGS.
* fbsd-nat.h: Include <sys/proc.h>.
(fbsd_nat_target::xfer_partial): Declare method unconditionally.
Fredrik Noring [Fri, 30 Nov 2018 18:32:36 +0000 (18:32 +0000)]
GAS/MIPS: Add `-mfix-r5900' option for the R5900 short loop erratum
`-march=r5900' already enables the R5900 short loop workaround.
However, the R5900 ISA and most other MIPS ISAs are mutually
exclusive since R5900-specific instructions are generated as well.
The `-mfix-r5900' option can be used in combination with e.g.
`-mips2' or `-mips3' to generate generic MIPS binaries that also
work with the R5900 target.
This change has been tested with `make RUNTESTFLAGS=mips.exp
check-gas' for the targets `mipsr5900el-unknown-linux-gnu',
`mipsr5900el-elf' and `mips3-unknown-linux-gnu'.
gas/
* config/tc-mips.c (mips_fix_r5900, mips_fix_r5900_explicit):
New variables.
(options): Add OPTION_FIX_R5900 and OPTION_NO_FIX_R5900
enumeration constants.
(md_longopts): Add "mfix-r5900" and "mno-fix-r5900" options.
(can_swap_branch_p, md_parse_option, mips_after_parse_args):
Handle the new options.
(md_show_usage): Document the `-mfix-r5900' option.
* doc/as.texi: Likewise.
* doc/c-mips.texi: Likewise.
* testsuite/gas/mips/mips.exp: Run R5900 dump tests.
* testsuite/gas/mips/r5900-fix.d: Test `-mfix-r5900' option.
* testsuite/gas/mips/r5900-fix.s: Likewise.
* testsuite/gas/mips/r5900-no-fix.d: Test `-mno-fix-r5900'.
* testsuite/gas/mips/r5900-no-fix.s: Likewise.
Andrew Burgess [Wed, 28 Nov 2018 22:42:27 +0000 (22:42 +0000)]
gdb/riscv: Add read_description method for riscv_linux_nat_target
Adds riscv_linux_nat_target::read_description method to find a
suitable target description for the native linux target we are running
on.
Currently this will supply a suitably sized set of x-registers, and
will probe the kernel to see if the f-registers are readable. If they
are readable then we currently assume that the f-registers are the
same size as the x-registers as I don't know of a good way to probe
the f-register length. This will obviously need fixing in future.
As of Linux 4.19 there is no ptrace support for reading the
f-registers, this should appear in 4.20, so right now we only return
target descriptions without f-registers.
gdb/ChangeLog:
* riscv-linux-nat.c: Add 'inferior.h' and 'target-descriptions.h'
header files.
(riscv_linux_nat_target::read_description): New method.
Andrew Burgess [Thu, 29 Nov 2018 15:51:58 +0000 (15:51 +0000)]
gdb/riscv: Create each unique target description only once
GDB relies on the fact that if two target descriptions have the same
contents, then they will be the same object instance (having the same
address). One place where this is a requirement is in
GDBARCH_LIST_LOOKUP_BY_INFO which is used to find previously created
gdbarch objects.
In GDBARCH_LIST_LOOKUP_BY_INFO a pointer comparison is made on the
gdbarch's target description, if the pointers are different then it is
assumed the gdbarches have different, non-compatible target
descriptions.
Previously we would create duplicate target descriptions in the belief
that RISCV_GDBARCH_INIT would spot this duplication and discard the
second instance. However, this was incorrect, and instead we ended up
creating duplicate gdbarch objects.
With this commit every unique feature set will create one and only one
target description, the feature set and resulting target description
is then cached so that the same target description object can be
returned later.
Many other target avoid this problem by creating a small number of
named target descriptions, and returning one of these. However, we
currently have 8 possible target descriptions (32 vs 64 bit for x-reg
and f-reg, and h/w or s/w float abi) and creating each of these just
to avoid a dynamic cache seems pointless.
gdb/ChangeLog:
* arch/riscv.h (riscv_gdbarch_features::hash): New method.
* arch/riscv.c (struct riscv_gdbarch_features_hasher): New.
(riscv_tdesc_cache): New global.
(riscv_create_target_description): Look in the cache before
creating a new target description.
Andrew Burgess [Thu, 29 Nov 2018 15:07:59 +0000 (15:07 +0000)]
gdb/riscv: Add equality operators to riscv_gdb_features
Add '==' and '!=' operators for the struct riscv_gdb_features,
allowing a small simplification.
gdb/ChangeLog:
* arch/riscv.h (riscv_gdb_features::operator==): New.
(riscv_gdb_features::operator!=): New.
* riscv-tdep.c (riscv_gdbarch_init): Make use of the inequality
operator.
Andrew Burgess [Thu, 29 Nov 2018 15:38:29 +0000 (15:38 +0000)]
gdb/riscv: Make some target description functions constant
Makes more of the interface related to fetching target descriptions
constant.
gdb/ChangeLog:
* arch/riscv.h (riscv_create_target_description): Make return type
const.
* arch/riscv.c (riscv_create_target_description): Likewise.
* riscv-tdep.c (riscv_find_default_target_description): Likewise.
Sergio Durigan Junior [Wed, 28 Nov 2018 22:22:08 +0000 (17:22 -0500)]
Fix dwarf2read.c:dwarf2_find_containing_comp_unit's binary search
First of all, I would like to express my gratitude to Keith Seitz, Jan
Kratochvil and Tom Tromey, who were really kind and helped a lot with
this bug. The patch itself was authored by Jan.
This all began with:
https://bugzilla.redhat.com/show_bug.cgi?id=1639242
py-bt is broken, results in exception
In summary, the error reported by the bug above is:
$ gdb -args python3
GNU gdb (GDB) Fedora 8.1.1-3.fc28
(...)
Reading symbols from python3...Reading symbols from /usr/lib/debug/usr/bin/python3.6-3.6.6-1.fc28.x86_64.debug...done.
done.
Dwarf Error: could not find partial DIE containing offset 0x316 [in module /usr/lib/debug/usr/bin/python3.6-3.6.6-1.fc28.x86_64.debug]
After a long investigation, and after thinking that the problem might
actually be on DWZ's side, we were able to determine that there's
something wrong going on when
dwarf2read.c:dwarf2_find_containing_comp_unit performs a binary search
over all of the CUs belonging to an objfile in order to find the CU
which contains a DIE at an specific offset. The current algorithm is:
static struct dwarf2_per_cu_data *
dwarf2_find_containing_comp_unit (sect_offset sect_off,
unsigned int offset_in_dwz,
struct dwarf2_per_objfile *dwarf2_per_objfile)
{
struct dwarf2_per_cu_data *this_cu;
int low, high;
const sect_offset *cu_off;
low = 0;
high = dwarf2_per_objfile->all_comp_units.size () - 1;
while (high > low)
{
struct dwarf2_per_cu_data *mid_cu;
int mid = low + (high - low) / 2;
mid_cu = dwarf2_per_objfile->all_comp_units[mid];
cu_off = &mid_cu->sect_off;
if (mid_cu->is_dwz > offset_in_dwz
|| (mid_cu->is_dwz == offset_in_dwz && *cu_off >= sect_off))
high = mid;
else
low = mid + 1;
}
For the sake of this example, let's consider that "sect_off =
0x7d".
There are a few important things going on here. First,
"dwarf2_per_objfile->all_comp_units ()" will be sorted first by
whether the CU is a DWZ CU, and then by cu->sect_off. In this
specific bug, "offset_in_dwz" is false, which means that, for the most
part of the loop, we're going to do "high = mid" (i.e, we'll work with
the lower part of the vector).
In our particular case, when we reach the part where "mid_cu->is_dwz
== offset_in_dwz" (i.e, both are false), we end up with "high = 2" and
"mid = 1". I.e., there are only 2 elements in the vector who are not
DWZ. The vector looks like this:
#0: cu->sect_off = 0; length = 114; is_dwz = false <-- low
#1: cu->sect_off = 114; length = 7796; is_dwz = false <-- mid
#2: cu->sect_off = 0; length = 28; is_dwz = true <-- high
...
The CU we want is #1, which is exactly where "mid" is. Also, #1 is
not DWZ, which is also exactly what we want. So we perform the second
comparison:
(mid_cu->is_dwz == offset_in_dwz && *cu_off >= sect_off)
^^^^^^^^^^^^^^^^^^^
Because "*cu_off = 114" and "sect_off = 0x7d", this evaluates to
false, so we end up with "low = mid + 1 = 2", which actually gives us
the wrong CU (i.e., a CU that is DWZ). Next in the code, GDB does:
gdb_assert (low == high);
this_cu = dwarf2_per_objfile->all_comp_units[low];
cu_off = &this_cu->sect_off;
if (this_cu->is_dwz != offset_in_dwz || *cu_off > sect_off)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
{
if (low == 0 || this_cu->is_dwz != offset_in_dwz)
error (_("Dwarf Error: could not find partial DIE containing "
"offset %s [in module %s]"),
sect_offset_str (sect_off),
bfd_get_filename (dwarf2_per_objfile->objfile->obfd));
...
Triggering the error we saw in the original bug report.
It's important to notice that we see the error message because the
selected CU is a DWZ one, but we're looking for a non-DWZ CU here.
However, even when the selected CU is *not* a DWZ (and we don't see
any error message), we still end up with the wrong CU. For example,
suppose that the vector had:
#0: cu->sect_off = 0; length = 114; is_dwz = false
#1: cu->sect_off = 114; length = 7796; is_dwz = false
#2: cu->sect_off = 7910; length = 28; is_dwz = false
...
I.e., #2's "is_dwz" is false instead of true. In this case, we still
want #1, because that's where the DIE is located. After the loop ends
up in #2, we have "is_dwz" as false, which is what we wanted, so we
compare offsets. In this case, "7910 >= 0x7d", so we set "mid = high
= 2". Next iteration, we have "mid = 0 + (2 - 0) / 2 = 1", and thus
we examining #1. "is_dwz" is still false, but "114 >= 0x7d" also
evaluates to false, so "low = mid + 1 = 2", which makes the loop stop.
Therefore, we end up choosing #2 as our CU, even though #1 is the
right one.
The problem here is happening because we're comparing "sect_off"
directly against "*cu_off", while we should actually be comparing
against "*cu_off + mid_cu->length" (i.e., the end offset):
...
|| (mid_cu->is_dwz == offset_in_dwz
&& *cu_off + mid_cu->length >= sect_off))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
And this is what the patch does. The idea is that if GDB is searching
for an offset that falls above the *end* of the CU being
analyzed (i.e., "mid"), then the next iteration should try a
higher-offset CU next. The previous algorithm was using
the *beginning* of the CU.
Unfortunately, I could not devise a testcase for this problem, so I am
proposing a fix with this huge explanation attached to it in the hope
that it is sufficient. After talking a bit to Keith (our testcase
guru), it seems that one would have to create an objfile with both DWZ
and non-DWZ sections, which may prove very hard to do, I think.
I ran this patch on our BuildBot, and no regressions were detected.
gdb/ChangeLog:
2018-11-30 Jan Kratochvil <jan.kratochvil@redhat.com>
Keith Seitz <keiths@redhat.com>
Tom Tromey <tom@tromey.com>
Sergio Durigan Junior <sergiodj@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1613614
* dwarf2read.c (dwarf2_find_containing_comp_unit): Add
'mid_cu->length' to '*cu_off' when checking if 'sect_off' is
inside the CU.
Pedro Alves [Fri, 30 Nov 2018 17:49:49 +0000 (17:49 +0000)]
target_ops::to_stratum -> target_ops::stratum() virtual method
Given that a target's stratum is a property of the type, and not of an
instance of the type, get rid of to_stratum data field and replace it
with a virtual method.
I.e., when we have e.g., 10 target remote instances active, there's no
need for each of the instances to have their own to_stratum copy.
gdb/ChangeLog:
2018-11-30 Pedro Alves <palves@redhat.com>
* aix-thread.c (aix_thread_target) <aix_thread_target>: Delete.
<stratum>: New override.
* bfd-target.c (aix_thread_target) <aix_thread_target>: Delete.
<stratum>: New override.
* bsd-uthread.c (bsd_uthread_target) <bsd_uthread_target>: Delete.
<stratum>: New override.
* exec.c (exec_target) <exec_target>: Delete.
<stratum>: New override.
* gdbarch-selftests.c (register_to_value_test): Adjust to use the
stratum method instead of the to_stratum field.
* linux-thread-db.c (thread_db_target) <thread_db_target>: Delete.
<stratum>: New override.
(thread_db_target::thread_db_target): Delete.
* make-target-delegates (print_class): Don't print a ctor
declaration. Print a stratum method override declaration.
* process-stratum-target.h (process_stratum_target)
<process_stratum_target>: Delete.
<stratum>: New override.
* ravenscar-thread.c (ravenscar_thread_target)
<ravenscar_thread_target>: Delete.
<stratum>: New override.
* record-btrace.c (record_btrace_target)
<record_btrace_target>: Delete.
<stratum>: New override.
* record-full.c (record_full_base_target)
<record_full_base_target>: Delete.
<stratum>: New override.
* record.c (record_disconnect, record_detach)
(record_mourn_inferior, record_kill): Adjust to use the stratum
method instead of the to_stratum field.
* regcache.c (cooked_read_test, cooked_write_test): Likewise.
* sol-thread.c (sol_thread_target)
<sol_thread_target>: Delete.
<stratum>: New override.
* spu-multiarch.c (spu_multiarch_target)
<spu_multiarch_target>: Delete.
<stratum>: New override.
* target-delegates.c: Regenerate.
* target.c (target_stack::push, target_stack::unpush)
(pop_all_targets_above, pop_all_targets_at_and_above)
(info_target_command, target_require_runnable)
(target_stack::find_beneath): Adjust to use the stratum method
instead of the to_stratum field.
(dummy_target::dummy_target): Delete.
(dummy_target::stratum): New.
(debug_target::debug_target): Delete.
(debug_target::stratum): New.
(maintenance_print_target_stack): Adjust to use the stratum method
instead of the to_stratum field.
* target.h (struct target_ops) <stratum>: New method.
<to_stratum>: Delete.
<is_pushed>: Adjust to use the stratum method
instead of the to_stratum field.
Nick Clifton [Fri, 30 Nov 2018 17:45:07 +0000 (17:45 +0000)]
Add PR number to previous delta to the bfd/ directory.
Pedro Alves [Fri, 30 Nov 2018 14:53:40 +0000 (14:53 +0000)]
Convert default_child_has_foo functions to process_stratum_target methods
This patch converts the default_child_has_foo functions to
process_stratum_target methods. This simplifies "regular"
non-inf_child process_stratum targets, since they no longer have to
override the target_ops::has_foo methods to call the default_child_foo
functions. A couple targets need to override the new defaults
(corelow and tracefiles), but it still seems like a good tradeoff,
since those are expected to be little different (target doesn't run).
gdb/ChangeLog:
2018-11-30 Pedro Alves <palves@redhat.com>
* corelow.c (core_target) <has_all_memory, has_execution>: New
overrides.
* inf-child.c (inf_child_target::has_all_memory)
(inf_child_target::has_memory, inf_child_target::has_stack)
(inf_child_target::has_registers)
(inf_child_target::has_execution): Delete.
* inf-child.h (inf_child_target) <has_all_memory, has_memory,
has_stack, has_registers, has_execution>: Delete.
* process-stratum-target.c
(process_stratum_target::has_all_memory)
(process_stratum_target::has_memory)
(process_stratum_target::has_stack)
(process_stratum_target::has_registers)
(process_stratum_target::has_execution): New.
* process-stratum-target.h (process_stratum_target)
<has_all_memory, has_memory, has_stack, has_registers,
has_execution>: New method overrides.
* ravenscar-thread.c (ravenscar_thread_target) <has_all_memory,
has_memory, has_stack, has_registers, has_execution>: Delete.
* remote-sim.c (gdbsim_target) <has_stack, has_registers,
has_execution>: Delete.
* remote.c (remote_target) <has_all_memory, has_memory, has_stack,
has_registers, has_execution>: Delete.
* target.c (default_child_has_all_memory)
(default_child_has_memory, default_child_has_stack)
(default_child_has_registers, default_child_has_execution):
Delete.
* target.h (default_child_has_all_memory)
(default_child_has_memory, default_child_has_stack)
(default_child_has_registers, default_child_has_execution):
Delete.
* tracefile.h (tracefile_target) <has_execution>: New override.
Pedro Alves [Fri, 30 Nov 2018 14:53:39 +0000 (14:53 +0000)]
Introduce process_stratum_target
This adds a base class that all process_stratum targets inherit from.
default_thread_address_space/default_thread_architecture only make
sense for process_stratum targets, so they are transformed to
process_stratum_target methods/overrides.
gdb/ChangeLog:
2018-11-30 Pedro Alves <palves@redhat.com>
* Makefile.in (COMMON_SFILES): Add process-stratum-target.c.
* bsd-kvm.c: Include "process-stratum-target.h".
(bsd_kvm_target): Now inherits from process_stratum_target.
(bsd_kvm_target::bsd_kvm_target): Default it.
* corelow.c: Include "process-stratum-target.h".
(core_target): Now inherits from process_stratum_target.
(core_target::core_target): Don't set to_stratum here.
* inf-child.c (inf_child_target::inf_child_target): Delete.
* inf-child.h: Include "process-stratum-target.h".
(inf_child_target): Inherit from process_stratum_target.
(inf_child_target) <inf_child_target>: Default it.
<can_async_p, supports_non_stop, supports_disable_randomization>:
Delete overrides.
* process-stratum-target.c: New file.
* process-stratum-target.h: New file.
* remote-sim.c: Include "process-stratum-target.h".
(gdbsim_target): Inherit from process_stratum_target.
<gdbsim_target>: Default it.
* remote.c: Include "process-stratum-target.h".
(remote_target): Inherit from process_stratum_target.
<remote_target>: Default it.
* target.c (default_thread_address_space)
(default_thread_architecture): Delete.
* target.h (target_ops) <thread_architecture>: Now returns NULL by
default.
<thread_address_space>: Ditto.
* test-target.h: Include "process-stratum-target.h" instead of
"target.h".
(test_target_ops): Inherit from process_stratum_target.
<test_target_ops>: Default it.
* tracefile.c (tracefile_target::tracefile_target): Delete.
* tracefile.h: Include "process-stratum-target.h".
(tracefile_target): Inherit from process_stratum_target.
<tracefile_target>: Default it.
* target-delegates.c: Regenerate.
Pedro Alves [Fri, 30 Nov 2018 14:53:38 +0000 (14:53 +0000)]
Move test_target_ops to a separate file
There's no need to have all target.h users seeing this type.
Also helps with a follow up patch.
gdb/ChangeLog:
2018-11-30 Pedro Alves <palves@redhat.com>
* Makefile.in (COMMON_SFILES): Add test-target.c.
* gdbarch-selftests.c: Include "test-target.h".
* regcache.c: Include "test-target.h".
* target.c (test_target_info, test_target_ops::info): Move to ...
* test-target.c: ... this new file.
* target.h (test_target_ops): Move to ...
* test-target.h: ... this new file.
Nick Clifton [Fri, 30 Nov 2018 11:45:33 +0000 (11:45 +0000)]
Fix a memory exhaustion bug when attempting to allocate room for an impossible number of program headers.
* elfcode.h (elf_object_p): Check for corrupt input files with
more program headers than can actually fit in the file.
Nick Clifton [Fri, 30 Nov 2018 11:43:12 +0000 (11:43 +0000)]
Remove an abort in the bfd library and add a check for an integer overflow when mapping sections to segments.
PR 23932
* elf.c (IS_CONTAINED_BY_LMA): Add a check for a negative section
size.
(rewrite_elf_program_header): If no sections are mapped into a
segment return an error.
Alan Modra [Fri, 30 Nov 2018 05:04:11 +0000 (15:34 +1030)]
PR23937, powerpc64le local ifunc IRELATIVE relocs are wrong
IFUNC resolvers must always be called via their global entry point.
They will be called from ld.so rather than from the local executable.
PR 23937
bfd/
* elf64-ppc.c (write_plt_relocs_for_local_syms): Don't add local
entry offset for ifuncs.
ld/
* testsuite/ld-powerpc/pr23937.d,
* testsuite/ld-powerpc/pr23937.s: New test.
* testsuite/ld-powerpc/powerpc.exp: Run it.
GDB Administrator [Fri, 30 Nov 2018 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in
Philippe Waroquiers [Tue, 27 Nov 2018 23:22:29 +0000 (00:22 +0100)]
Fix leak in forward-search
Valgrind reports the below leak.
Fix the leak by using xrealloc, even for the first allocation,
as buf is static.
==29158== 5,888 bytes in 23 blocks are definitely lost in loss record 3,028 of 3,149
==29158== at 0x4C2BE2D: malloc (vg_replace_malloc.c:299)
==29158== by 0x41B557: xmalloc (common-utils.c:44)
==29158== by 0x60B7D9: forward_search_command(char const*, int) (source.c:1563)
==29158== by 0x40BA68: cmd_func(cmd_list_element*, char const*, int) (cli-decode.c:1888)
==29158== by 0x665300: execute_command(char const*, int) (top.c:630)
...
gdb/ChangeLog
2018-11-29 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* source.c (forward_search_command): Fix leak by using
xrealloc even for the first allocation in the loop, as buf
is static.
Rajendra SY [Thu, 29 Nov 2018 21:26:31 +0000 (13:26 -0800)]
Implement the "gdb_signal_to/from_target" gdbarch methods for FreeBSD.
This fixes failures in the gdb.base/exitsignal.exp test.
gdb/ChangeLog:
PR gdb/23093
* gdb/fbsd-tdep.c (fbsd_gdb_signal_from_target)
(fbsd_gdb_signal_to_target): New.
(fbsd_init_abi): Install gdbarch "signal_from_target" and
"signal_to_target" methods.
Jim Wilson [Thu, 29 Nov 2018 21:05:25 +0000 (13:05 -0800)]
RISC-V: Add missing c.unimp instruction.
opcodes/
* riscv-opc.c (unimp): Mark compressed unimp as INSN_ALIAS.
(c.unimp): New.
Tom Tromey [Wed, 28 Nov 2018 17:34:15 +0000 (10:34 -0700)]
Avoid buffer overflow in value_x_unop
Commit
6b1747cd1 ("invoke_xmethod & array_view") contains this change:
- argvec = (struct value **) alloca (sizeof (struct value *) * 4);
+ value *argvec_storage[3];
+ gdb::array_view<value *> argvec = argvec_storage;
However, value_x_unop still does:
argvec[2] = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
argvec[3] = 0;
This triggers an error with -fsanitize=address from userdef.exp:
ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffdcf185068 at pc 0x000000e4f912 bp 0x7ffdcf184d80 sp 0x7ffdcf184d70
WRITE of size 8 at 0x7ffdcf185068 thread T0
#0 0xe4f911 in value_x_unop(value*, exp_opcode, noside) ../../binutils-gdb/gdb/valarith.c:557
[...]
I think the two assignments to argvec[3] should just be removed, and
that this was intended in the earlier patch but just missed.
This passes userdef.exp with -fsanitize=address.
gdb/ChangeLog
2018-11-29 Tom Tromey <tom@tromey.com>
* valarith.c (value_x_unop): Don't set argvec[3].
Tom Tromey [Mon, 30 Jul 2018 01:21:01 +0000 (19:21 -0600)]
Fix use-after-free in gdbserver
-fsanitize=address pointed out a use-after-free in gdbserver. In
particular, handle_detach could reference "process" after it was
deleted by detach_inferior. Avoiding this also necessitated changing
target_ops::join to take a pid rather than a process_info*.
Tested by the buildbot using a few of the gdbserver builders.
gdb/gdbserver/ChangeLog
2018-11-29 Tom Tromey <tom@tromey.com>
* win32-low.c (win32_join): Take pid, not process.
* target.h (struct target_ops) <join>: Change argument type.
(join_inferior): Change argument name.
* spu-low.c (spu_join): Take pid, not process.
* server.c (handle_detach): Preserve pid before destroying
process.
* lynx-low.c (lynx_join): Take pid, not process.
* linux-low.c (linux_join): Take pid, not process.
Thomas Preud'homme [Thu, 29 Nov 2018 13:42:49 +0000 (13:42 +0000)]
Document purpose of each ld statement lists
When discovering the statement lists via their header variable
statement_list, file_chain and input_file_chain it can be confusing to
figure out what they are for. They can point to the same initial
statement and the relation between the next field they use is not
obvious from the name.
This commit adds comment for each of those statement list header to
explain what they are for and what next field they use. It also rewrite
the comment for the next fields to simply redirect the reader to the
list header to avoid duplication of documentation.
2018-11-29 Thomas Preud'homme <thomas.preudhomme@linaro.org>
ld/
* ldlang.c (statement_list): Document purpose and what next field it
uses.
(file_chain): Likewise.
(input_file_chain): Likewise.
* ldlang.h (lang_statement_header_type): Document statement list header
the next pointer correspond to.
(lang_statement_header_type): Replace comment for next and
next_real_file field to refer the reader to their corresponding
statement list header.
H.J. Lu [Thu, 29 Nov 2018 12:44:20 +0000 (04:44 -0800)]
elf: Don't merge .note.gnu.property section in IR
.note.gnu.property section in IR inputs should be ignored. Don't
merge them.
PR ld/23929
* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Don't
merge .note.gnu.property section in IR inputs.
Nick Clifton [Thu, 29 Nov 2018 10:57:54 +0000 (10:57 +0000)]
objdump: Fix check for corrupt reloc information, to allow for the fact that PDP11 relocs are bigger when in internal format.
PR 23931
* objdump.c (dump_relocs_in_section): When checking for an
unreasonable amount of relocs in a bfd, allow for the fact that
the internal representation of a reloc may be bigger than the
external representation.
GDB Administrator [Thu, 29 Nov 2018 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Wed, 28 Nov 2018 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Tue, 27 Nov 2018 19:29:23 +0000 (11:29 -0800)]
RISC-V: Add .insn CA support.
gas/
* config/tc-riscv.c (validate_riscv_insn) <'F'>: Add support for CF6
and CF2 operands.
(riscv_ip) <'F'>: Likewise.
* doc/c-riscv.texi (RISC-V-Formats): Add func6 abbreviation. Use rs2
instead of rs1 in CR description. Add CA docs.
* gas/testsuite/riscv/insn.s: Add use of .insn ca.
* gas/testsuite/riscv/insn.d: Update to match.
include/
* opcode/riscv.h (OP_MASK_CFUNCT6, OP_SH_CFUNCT6): New.
(OP_MASK_CFUNCT2, OP_SH_CFUNCT2): New.
opcodes/
* riscv-opc.c (ciw): Fix whitespace to align columns.
(ca): New.
Thomas Preud'homme [Tue, 27 Nov 2018 18:27:35 +0000 (18:27 +0000)]
[ARM] Update knowledge of bfd architectures
Commit
c0c468d562649df0f695737262b6230b7a56a4bb updated bfd's knowledge
of Arm architectures to Armv5TEJ and later but missed the list of CPUs
recognized by objdump -d -m<cpu>.
.note.gnu.arm.ident related code is intentionally not updated as build
attributes are a better mechanism to express the ISA in a file. However
this patch adds tests for the existing code since no existing testcase
cover those codepaths. Since I've only ever managed for
bfd_arm_get_mach_from_notes () to have an effect by using objcopy on
a file with a note but no Arm build attribute, the tests make use of
both objcopy actions supported by run_dump_test which requires to have a
ld line as well.
Note that the CPU list in bfd/cpu-arm.c was simply copied over from
GAS' CPU list but sorted alphabetically as already done for existing
entries.
2018-11-27 Thomas Preud'homme <thomas.preudhomme@linaro.org>
bfd/
* cpu-arm.c (processors): Add processors known to GAS but missing here
and reindent.
(bfd_arm_update_notes): Add comment explaining why the list of
architectures in the switch should not be updated.
(architectures): Likewise.
gas/
* testsuite/gas/arm/cpu-arm1020.d: New testcase.
* testsuite/gas/arm/cpu-arm1020e.d: Likewise.
* testsuite/gas/arm/cpu-arm1020t.d: Likewise.
* testsuite/gas/arm/cpu-arm1022e.d: Likewise.
* testsuite/gas/arm/cpu-arm1026ej-s.d: Likewise.
* testsuite/gas/arm/cpu-arm1026ejs.d: Likewise.
* testsuite/gas/arm/cpu-arm10e.d: Likewise.
* testsuite/gas/arm/cpu-arm10t.d: Likewise.
* testsuite/gas/arm/cpu-arm10tdmi.d: Likewise.
* testsuite/gas/arm/cpu-arm1136j-s.d: Likewise.
* testsuite/gas/arm/cpu-arm1136jf-s.d: Likewise.
* testsuite/gas/arm/cpu-arm1136jfs.d: Likewise.
* testsuite/gas/arm/cpu-arm1136js.d: Likewise.
* testsuite/gas/arm/cpu-arm1156t2-s.d: Likewise.
* testsuite/gas/arm/cpu-arm1156t2f-s.d: Likewise.
* testsuite/gas/arm/cpu-arm1176jz-s.d: Likewise.
* testsuite/gas/arm/cpu-arm1176jzf-s.d: Likewise.
* testsuite/gas/arm/cpu-arm2.d: Likewise.
* testsuite/gas/arm/cpu-arm250.d: Likewise.
* testsuite/gas/arm/cpu-arm3.d: Likewise.
* testsuite/gas/arm/cpu-arm6.d: Likewise.
* testsuite/gas/arm/cpu-arm60.d: Likewise.
* testsuite/gas/arm/cpu-arm600.d: Likewise.
* testsuite/gas/arm/cpu-arm610.d: Likewise.
* testsuite/gas/arm/cpu-arm620.d: Likewise.
* testsuite/gas/arm/cpu-arm7.d: Likewise.
* testsuite/gas/arm/cpu-arm70.d: Likewise.
* testsuite/gas/arm/cpu-arm700.d: Likewise.
* testsuite/gas/arm/cpu-arm700i.d: Likewise.
* testsuite/gas/arm/cpu-arm710.d: Likewise.
* testsuite/gas/arm/cpu-arm7100.d: Likewise.
* testsuite/gas/arm/cpu-arm710c.d: Likewise.
* testsuite/gas/arm/cpu-arm710t.d: Likewise.
* testsuite/gas/arm/cpu-arm720.d: Likewise.
* testsuite/gas/arm/cpu-arm720t.d: Likewise.
* testsuite/gas/arm/cpu-arm740t.d: Likewise.
* testsuite/gas/arm/cpu-arm7500.d: Likewise.
* testsuite/gas/arm/cpu-arm7500fe.d: Likewise.
* testsuite/gas/arm/cpu-arm7d.d: Likewise.
* testsuite/gas/arm/cpu-arm7di.d: Likewise.
* testsuite/gas/arm/cpu-arm7dm.d: Likewise.
* testsuite/gas/arm/cpu-arm7dmi.d: Likewise.
* testsuite/gas/arm/cpu-arm7m.d: Likewise.
* testsuite/gas/arm/cpu-arm7t.d: Likewise.
* testsuite/gas/arm/cpu-arm7tdmi-s.d: Likewise.
* testsuite/gas/arm/cpu-arm7tdmi.d: Likewise.
* testsuite/gas/arm/cpu-arm8.d: Likewise.
* testsuite/gas/arm/cpu-arm810.d: Likewise.
* testsuite/gas/arm/cpu-arm9.d: Likewise.
* testsuite/gas/arm/cpu-arm920.d: Likewise.
* testsuite/gas/arm/cpu-arm920t.d: Likewise.
* testsuite/gas/arm/cpu-arm922t.d: Likewise.
* testsuite/gas/arm/cpu-arm926ej-s.d: Likewise.
* testsuite/gas/arm/cpu-arm926ej.d: Likewise.
* testsuite/gas/arm/cpu-arm926ejs.d: Likewise.
* testsuite/gas/arm/cpu-arm940t.d: Likewise.
* testsuite/gas/arm/cpu-arm946e-r0.d: Likewise.
* testsuite/gas/arm/cpu-arm946e-s.d: Likewise.
* testsuite/gas/arm/cpu-arm946e.d: Likewise.
* testsuite/gas/arm/cpu-arm966e-r0.d: Likewise.
* testsuite/gas/arm/cpu-arm966e-s.d: Likewise.
* testsuite/gas/arm/cpu-arm966e.d: Likewise.
* testsuite/gas/arm/cpu-arm968e-s.d: Likewise.
* testsuite/gas/arm/cpu-arm9e-r0.d: Likewise.
* testsuite/gas/arm/cpu-arm9e.d: Likewise.
* testsuite/gas/arm/cpu-arm9tdmi.d: Likewise.
* testsuite/gas/arm/cpu-arm_any.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a12.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a15.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a17.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a32.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a35.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a5.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a53.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a55.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a57.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a7.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a72.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a73.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a75.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a76.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a8.d: Likewise.
* testsuite/gas/arm/cpu-cortex-a9.d: Likewise.
* testsuite/gas/arm/cpu-cortex-m0.d: Likewise.
* testsuite/gas/arm/cpu-cortex-m0plus.d: Likewise.
* testsuite/gas/arm/cpu-cortex-m1.d: Likewise.
* testsuite/gas/arm/cpu-cortex-m23.d: Likewise.
* testsuite/gas/arm/cpu-cortex-m3.d: Likewise.
* testsuite/gas/arm/cpu-cortex-m33.d: Likewise.
* testsuite/gas/arm/cpu-cortex-m4.d: Likewise.
* testsuite/gas/arm/cpu-cortex-m7.d: Likewise.
* testsuite/gas/arm/cpu-cortex-r4.d: Likewise.
* testsuite/gas/arm/cpu-cortex-r4f.d: Likewise.
* testsuite/gas/arm/cpu-cortex-r5.d: Likewise.
* testsuite/gas/arm/cpu-cortex-r52.d: Likewise.
* testsuite/gas/arm/cpu-cortex-r7.d: Likewise.
* testsuite/gas/arm/cpu-cortex-r8.d: Likewise.
* testsuite/gas/arm/cpu-ep9312.d: Likewise.
* testsuite/gas/arm/cpu-exynos-m1.d: Likewise.
* testsuite/gas/arm/cpu-fa526.d: Likewise.
* testsuite/gas/arm/cpu-fa606te.d: Likewise.
* testsuite/gas/arm/cpu-fa616te.d: Likewise.
* testsuite/gas/arm/cpu-fa626.d: Likewise.
* testsuite/gas/arm/cpu-fa626te.d: Likewise.
* testsuite/gas/arm/cpu-fa726te.d: Likewise.
* testsuite/gas/arm/cpu-fmp626.d: Likewise.
* testsuite/gas/arm/cpu-i80200.d: Likewise.
* testsuite/gas/arm/cpu-iwmmxt.d: Likewise.
* testsuite/gas/arm/cpu-iwmmxt2.d: Likewise.
* testsuite/gas/arm/cpu-marvell-pj4.d: Likewise.
* testsuite/gas/arm/cpu-marvell-whitney.d: Likewise.
* testsuite/gas/arm/cpu-mpcore.d: Likewise.
* testsuite/gas/arm/cpu-mpcorenovfp.d: Likewise.
* testsuite/gas/arm/cpu-sa1.d: Likewise.
* testsuite/gas/arm/cpu-strongarm.d: Likewise.
* testsuite/gas/arm/cpu-strongarm1.d: Likewise.
* testsuite/gas/arm/cpu-strongarm110.d: Likewise.
* testsuite/gas/arm/cpu-strongarm1100.d: Likewise.
* testsuite/gas/arm/cpu-strongarm1110.d: Likewise.
* testsuite/gas/arm/cpu-xgene1.d: Likewise.
* testsuite/gas/arm/cpu-xgene2.d: Likewise.
* testsuite/gas/arm/cpu-xscale.d: Likewise.
* testsuite/gas/arm/nop-asm.s: Likewise.
* testsuite/gas/arm/note-march-armv2.d: Likewise.
* testsuite/gas/arm/note-march-armv2.s: Likewise.
* testsuite/gas/arm/note-march-armv2a.d: Likewise.
* testsuite/gas/arm/note-march-armv2a.s: Likewise.
* testsuite/gas/arm/note-march-armv3.d: Likewise.
* testsuite/gas/arm/note-march-armv3.s: Likewise.
* testsuite/gas/arm/note-march-armv3m.d: Likewise.
* testsuite/gas/arm/note-march-armv3m.s: Likewise.
* testsuite/gas/arm/note-march-armv4.d: Likewise.
* testsuite/gas/arm/note-march-armv4.s: Likewise.
* testsuite/gas/arm/note-march-armv4t.d: Likewise.
* testsuite/gas/arm/note-march-armv4t.s: Likewise.
* testsuite/gas/arm/note-march-armv5.d: Likewise.
* testsuite/gas/arm/note-march-armv5.s: Likewise.
* testsuite/gas/arm/note-march-armv5t.d: Likewise.
* testsuite/gas/arm/note-march-armv5t.s: Likewise.
* testsuite/gas/arm/note-march-armv5te.d: Likewise.
* testsuite/gas/arm/note-march-armv5te.d: Likewise.
* testsuite/gas/arm/note-march-ep9312.d: Likewise.
* testsuite/gas/arm/note-march-ep9312.s: Likewise.
* testsuite/gas/arm/note-march-iwmmxt.d: Likewise.
* testsuite/gas/arm/note-march-iwmmxt.s: Likewise.
* testsuite/gas/arm/note-march-iwmmxt2.d: Likewise.
* testsuite/gas/arm/note-march-iwmmxt2.s: Likewise.
* testsuite/gas/arm/note-march-xscale.d: Likewise.
* testsuite/gas/arm/note-march-xscale.s: Likewise.
Maciej W. Rozycki [Tue, 27 Nov 2018 16:34:03 +0000 (16:34 +0000)]
MIPS/LD: Accept high-part relocations in PIC code with absolute symbols
Accept R_MIPS_HI16, R_MIPS_HIGHER and R_MIPS_HIGHEST relocations and
their compressed counterparts in PIC code where the symbol referred is
absolute. Such an operation is meaningful, because an absolute symbol
effectively is a constant the calculation of the value of which has been
deferred to the static link time, and which is not going to change any
further at the dynamic load time. Therefore there is no need ever to
refuse the use of these relocations with such symbols, as the resulting
run-time value observed by the program will be correct even in PIC code.
This is not the case with R_MIPS_26 and its compressed counterparts,
because the run-time value calculated by the instructions these
relocations are used with depends on the address of the instruction
itself, and that can change according to the base address used by the
dynamic loader. Therefore these relocations have to continue being
rejected in PIC code even with absolute symbols.
This allows successful linking of code that relies on previous linker
behavior up to commit
861fb55ab50a ("Defer allocation of R_MIPS_REL32
GOT slots"), <https://sourceware.org/ml/binutils/2008-08/msg00096.html>,
which introduced the problematic check missing this special exception
for absolute symbols.
bfd/
* elfxx-mips.c (_bfd_mips_elf_check_relocs) <R_MIPS16_HI16>
<R_MIPS_HI16, R_MIPS_HIGHER, R_MIPS_HIGHEST, R_MICROMIPS_HI16>
<R_MICROMIPS_HIGHER, R_MICROMIPS_HIGHEST>: Also accept an
absolute symbol in PIC code.
ld/
* testsuite/ld-mips-elf/pic-reloc-0.d: New test.
* testsuite/ld-mips-elf/pic-reloc-1.d: New test.
* testsuite/ld-mips-elf/pic-reloc-2.d: New test.
* testsuite/ld-mips-elf/pic-reloc-3.d: New test.
* testsuite/ld-mips-elf/pic-reloc-4.d: New test.
* testsuite/ld-mips-elf/pic-reloc-absolute-hi.ld: New test
linker script.
* testsuite/ld-mips-elf/pic-reloc-absolute-lo.ld: New test
linker script.
* testsuite/ld-mips-elf/pic-reloc-ordinary.ld: New test linker
script.
* testsuite/ld-mips-elf/pic-reloc-j.s: New test source.
* testsuite/ld-mips-elf/pic-reloc-lui.s: New test source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Maciej W. Rozycki [Tue, 27 Nov 2018 16:34:03 +0000 (16:34 +0000)]
MIPS/LD: Continue processing with refused relocations in PIC code
Switch from `_bfd_error_handler' to `info->callbacks->einfo' with error
reporting concerning the use of position-dependent relocations such as
R_MIPS_HI16 or R_MIPS_26 in PIC code and continue processing so that any
subsequent link errors are also shown rather than the linker terminating
right away. This can reduce user frustration where correcting one error
only reveals another one; instead all are shown together making them all
possible to investigate at once. The use of the `%X' specifier causes
the linker to terminate unsuccessfully at the end of processing.
Also fix the message to say `cannot' rather than `can not'.
bfd/
* elfxx-mips.c (_bfd_mips_elf_check_relocs) <R_MIPS16_26>
<R_MIPS_26, R_MICROMIPS_26_S1>: Use `info->callbacks->einfo'
rather than `_bfd_error_handler' to report refused relocations
in PIC code and continue processing. Fix error message: `can
not' -> `cannot'.
Maciej W. Rozycki [Tue, 27 Nov 2018 16:34:03 +0000 (16:34 +0000)]
LD: Convert `%P: %H:' to `%H:' in error messages
Similarly to commit
174d0a74a2e6 ("PowerPC/BFD: Convert `%P: %H:' to
`%H:' in error messages") convert linker relocation error messages to
use `%H:' rather `%P: %H:', removing inconsistent message composition
like:
$ cat reloc-j.s
.text
.globl foo
.ent foo
foo:
j bar
j bar
.end foo
$ cat reloc-j.ld
SECTIONS
{
bar = 0x12345678;
.text : { *(.text) }
/DISCARD/ : { *(*) }
}
$ as -o reloc-j.o reloc-j.s
$ ld -T reloc-j.ld -o reloc-j reloc-j.o
ld: tmpdir/reloc-j.o: in function `foo':
(.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar'
ld: (.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar'
$
where subsequent lines referring to issues within a single function have
the name of the linker executable prepended, but the first one does not.
As noted with the commit referred this breaks a GNU Coding Standard's
requirement that error messages from compilers should look like this:
source-file-name:lineno: message
also quoted in `vfinfo' code handling these specifiers.
Remove the linker name prefix then, making the messages now look like:
$ ld -T reloc-j.ld -o reloc-j reloc-j.o
tmpdir/reloc-j.o: in function `foo':
(.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar'
(.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar'
$
instead.
ld/
* ldmain.c (reloc_overflow): Use `%H:' rather than `%P: %H:'
with `einfo'.
(reloc_dangerous): Likewise.
(unattached_reloc): Likewise.
H.J. Lu [Tue, 27 Nov 2018 14:02:36 +0000 (06:02 -0800)]
Initialize *uncompressed_align_pow_p to 0
Initialize *uncompressed_align_pow_p to 0 since *uncompressed_align_pow_p
is passed to bfd_is_section_compressed_with_header as uninitialized,
PR binutils/23919
* compress.c (bfd_is_section_compressed_with_header): Initialize
*uncompressed_align_pow_p to 0.
Tamar Christina [Tue, 27 Nov 2018 12:33:21 +0000 (12:33 +0000)]
AArch64: Fix regression in Cortex A53 erratum when PIE. (PR ld/23904)
The fix for PR ld/22263 causes TLS relocations using ADRP to be relaxed
into MOVZ, however this causes issues for the erratum code.
The erratum code scans the input sections looking for ADRP instructions
and notes their location in the stream.
It then later tries to find them again in order to generate the linker
stubs. Due to the relaxation it instead finds a MOVZ and hard aborts.
Since this relaxation is a valid one, and in which case the erratum no
longer applies, it shouldn't abort but instead just continue.
This changes the TLS relaxation code such that when it finds an ADRP and
it relaxes it, it removes the erratum entry from the work list by changing
the stub type into none so the stub is ignored.
The entry is not actually removed as removal is a more expensive operation
and we have already allocated the memory anyway.
The clearing is done for IE->LE and GD->LE relaxations, and a testcase is
added for the IE case. The GD case I believe to be impossible to get together
with the erratum sequence due to the required BL which would break the sequence.
However to cover all basis I have added the guard there as well.
build on native hardware and regtested on
aarch64-none-elf, aarch64-none-elf (32 bit host),
aarch64-none-linux-gnu, aarch64-none-linux-gnu (32 bit host)
Cross-compiled and regtested on
aarch64-none-linux-gnu, aarch64_be-none-linux-gnu
Testcase in PR23940 tested and works as expected now and benchmarks ran on A53
showing no regressions and no issues.
bfd/ChangeLog:
PR ld/23904
* elfnn-aarch64.c (_bfd_aarch64_adrp_p): Use existing constants.
(_bfd_aarch64_erratum_843419_branch_to_stub): Use _bfd_aarch64_adrp_p.
(struct erratum_835769_branch_to_stub_clear_data): New.
(_bfd_aarch64_erratum_843419_clear_stub): New.
(clear_erratum_843419_entry): New.
(elfNN_aarch64_tls_relax): Use it.
(elfNN_aarch64_relocate_section): Pass input_section.
(aarch64_map_one_stub): Handle branch type none as valid.
ld/ChangeLog:
PR ld/23904
* testsuite/ld-aarch64/aarch64-elf.exp: Add erratum843419_tls_ie.
* testsuite/ld-aarch64/erratum843419_tls_ie.d: New test.
* testsuite/ld-aarch64/erratum843419_tls_ie.s: New test.
Jozef Lawrynowicz [Tue, 27 Nov 2018 12:25:09 +0000 (12:25 +0000)]
Tighten the constraints for warning about NOPs for the MSP 430 ISA, so NOPs are only inserted/warned about when needed. Specifically: 430 and 430x ISA require a NOP after DINT. Only the 430x ISA requires NOP before EINT. Only the 430x ISA requires NOP after every EINT. CPU42 errata.
* config/tc-msp430.c (is_dint): New.
(is_eint): New.
(gen_nop): New.
(warn_eint_nop): New.
(warn_unsure_interrupt): New.
(msp430_operands): Determine the effect MOV #N,SR insns have on
interrupt state.
Only emit NOP warnings for 430 ISA in certain situations.
(msp430_md_end): Only warn about an EINT at the end of the file
if NOP warnings are enabled.
* testsuite/gas/msp430/bad.l: Adjust expected output for new warnings.
* testsuite/gas/msp430/msp430.exp: Run new tests.
* testsuite/gas/msp430/nop-dint-430.d: New.
* testsuite/gas/msp430/nop-dint-430.l: New.
* testsuite/gas/msp430/nop-dint-430x-ignore.d: New.
* testsuite/gas/msp430/nop-dint-430x-silent.d: New.
* testsuite/gas/msp430/nop-dint-430x.d: New.
* testsuite/gas/msp430/nop-dint-430x.l: New.
* testsuite/gas/msp430/nop-dint.s: New.
* testsuite/gas/msp430/nop-eint-430.d: New.
* testsuite/gas/msp430/nop-eint-430.l: New.
* testsuite/gas/msp430/nop-eint-430x-ignore.d: New.
* testsuite/gas/msp430/nop-eint-430x-silent.d: New.
* testsuite/gas/msp430/nop-eint-430x.d: New.
* testsuite/gas/msp430/nop-eint-430x.l: New.
* testsuite/gas/msp430/nop-eint.s: New.
* testsuite/gas/msp430/nop-int-430.d: New.
* testsuite/gas/msp430/nop-int-430.l: New.
* testsuite/gas/msp430/nop-int-430x-silent.d: New.
* testsuite/gas/msp430/nop-int-430x.d: New.
* testsuite/gas/msp430/nop-int-430x.l: New.
* testsuite/gas/msp430/nop-int.s: New.
Mark Wielaard [Tue, 27 Nov 2018 11:59:10 +0000 (11:59 +0000)]
Handle ELF compressed header alignment correctly by setting up the section alignment correctly for the Elf32_Chdr or Elf64_Chdr type and respect the ch_addralign field when decompressing the section data.
PR binutils/23919
binutils* readelf.c (dump_sections_as_strings): Remove bogus addralign check.
(dump_sections_as_bytes): Likewise.
(load_specific_debug_sections): Likewise.
* testsuite/binutils-all/dw2-3.rS: Adjust alignment.
* testsuite/binutils-all/dw2-3.rt: Likewise.
bfd * bfd.c (bfd_update_compression_header): Explicitly set alignment.
(bfd_check_compression_header): Add uncompressed_alignment_power
argument. Check ch_addralign is a power of 2.
* bfd-in2.h: Regenerated.
* compress.c (bfd_compress_section_contents): Get and set
orig_uncompressed_alignment_pow if section is decompressed.
(bfd_is_section_compressed_with_header): Add and get
uncompressed_align_pow_p argument.
(bfd_is_section_compressed): Add uncompressed_align_power argument
to bfd_is_section_compressed_with_header call.
(bfd_init_section_decompress_status): Get and set
uncompressed_alignment_power.
* elf.c (_bfd_elf_make_section_from_shdr): Add
uncompressed_align_power argument to
bfd_is_section_compressed_with_header call.
GDB Administrator [Tue, 27 Nov 2018 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Mon, 26 Nov 2018 19:35:03 +0000 (14:35 -0500)]
Fix spurious semicolon in sparc-linux-nat.c
Remove a semicolon that should not be there, as reported in PR 23917:
CXX sparc-linux-nat.o
/home/emaisin/src/binutils-gdb/gdb/sparc-linux-nat.c:39:3: error: expected unqualified-id before ‘{’ token
{ sparc_store_inferior_registers (regcache, regnum); }
^
Tested by rebuilding the file manually (make sparc-linux-nat.o) in a
sparc64-linux-gnu build.
gdb/ChangeLog:
PR gdb/23917
* sparc-linux-nat.c (sparc_linux_nat_target): Remove extraneous
semicolon.
Pedro Alves [Mon, 26 Nov 2018 13:13:35 +0000 (13:13 +0000)]
Fix Solaris build
The recent commit
080363310650 ("Per-inferior thread list, thread
ranges/iterators, down with ALL_THREADS, etc.") removed the
definitions of is_running/is_stopped/is_exited but missed updating a
couple uses of is_exited in Solaris-specific code.
Tested by Rainer Orth on amd64-pc-solaris2.11.
gdb/ChangeLog:
2018-11-26 Pedro Alves <palves@redhat.com>
* procfs.c (procfs_notice_thread): Replace uses of
in_thread_list/is_exited with find_thread_ptid/THREAD_EXITED.
* sol-thread.c (sol_thread_target::wait)
(sol_update_thread_list_callback): Likewise.
Alan Modra [Mon, 26 Nov 2018 11:37:17 +0000 (22:07 +1030)]
[GOLD] justsyms_exec test fail on powerpc64
This test fails on powerpc64le due to the justsyms_lib being built
with exported_data at 0x2010000, apparently due to the powerpc target
code generating an empty relro .branch_lt section. Since the test
relies on the library having exported_data at 0x2000000, avoid the
problem by linking with -z norelro. Also, the test doesn't need to
avoid checking the function symbol on powerpc elfv2.
* testsuite/Makefile.am (justsyms_lib): Link with -z norelro.
* testsuite/Makefile.in: Regenerate.
* testsuite/justsyms_exec.c (main): Do check exported_func
on PowerPC64 ELFv2.
Alan Modra [Mon, 26 Nov 2018 11:35:54 +0000 (22:05 +1030)]
[GOLD] support objdump -T display of st_other
PowerPC64 ELFv2 uses the top 3 bits of st_other to encode a function's
local entry point offset from its global entry point. Allow st_other
bits except for visibility==default.
* testsuite/ver_test_14.sh: Accept objdump -T display of st_other
bits on powerpc64le.
GDB Administrator [Mon, 26 Nov 2018 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in
Sergio Durigan Junior [Thu, 22 Nov 2018 21:45:33 +0000 (16:45 -0500)]
Implement timestamp'ed output on "make check"
It is unfortunately not uncommon to have tests hanging on some of the
BuildBot workers. For example, the ppc64be/ppc64le+gdbserver builders
are especially in a bad state when it comes to testing GDB/gdbserver,
and we can have builds that take an absurd amount of time to
finish (almost 1 week for one single build, for example).
It may be hard to diagnose these failures, because sometimes we don't
have access to the faulty systems, and other times we're just too busy
to wait and check which test is actually hanging. During one of our
conversations about the topic, someone proposed that it would be a
good idea to have a timestamp put together with stdout output, so that
we can come back later and examine which tests are taking too long to
complete.
Here's my proposal to do this. The very first thing I tried to do was
to use "ts(1)" to achieve this feature, and it obviously worked, but
the problem is that I'm afraid "ts(1)" may not be widely available on
every system we support. Therefore, I decided to implement a *very*
simple version of "ts(1)", in Python 3, which basically does the same
thing: iterate over the stdin lines, and prepend a timestamp onto
them.
As for testsuite/Makefile.in, the user can now specify two new
variables to enable timestamp'ed output: TS (which enables the
output), and TS_FORMAT (optional, used to specify another timestamp
format according to "strftime").
Here's an example of how the output looks like:
...
[Nov 22 17:07:19] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/call-strs.exp ...
[Nov 22 17:07:19] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/step-over-no-symbols.exp ...
[Nov 22 17:07:20] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/all-architectures-6.exp ...
[Nov 22 17:07:20] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/hashline3.exp ...
[Nov 22 17:07:20] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/max-value-size.exp ...
[Nov 22 17:07:20] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/quit-live.exp ...
[Nov 22 17:07:46] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/paginate-bg-execution.exp ...
[Nov 22 17:07:56] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp ...
[Nov 22 17:07:56] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/gcore-relro.exp ...
[Nov 22 17:07:56] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/watchpoint-delete.exp ...
[Nov 22 17:07:56] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp ...
[Nov 22 17:07:56] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/vla-sideeffect.exp ...
[Nov 22 17:07:57] [1234] Running binutils-gdb/gdb/testsuite/gdb.base/unload.exp ...
...
(What, gdb.base/quit-live.exp is taking 26 seconds to complete?!)
Output to stderr is not timestamp'ed, but I don't think that will be a
problem for us. If it is, we can revisit the solution and extend it.
gdb/testsuite/ChangeLog:
2018-11-25 Sergio Durigan Junior <sergiodj@redhat.com>
* Makefile.in (TIMESTAMP): New variable.
(check-single): Add $(TIMESTAMP) to the end of $(DO_RUNTEST)
command.
(check-single-racy): Likewise.
(check/%.exp): Likewise.
(check-racy/%.exp): Likewise.
(workers/%.worker): Likewise.
(build-perf): Likewise.
(check-perf): Likewise.
* README: Describe new "TS" and "TS_FORMAT" variables.
* print-ts.py: New file.
Tom Tromey [Sun, 25 Nov 2018 19:30:20 +0000 (12:30 -0700)]
Remove obsolete comments from field_fmt
This removes some comments that I believe were made obsolete by the
recent change to cli_ui_out::do_field_fmt. The comment in mi_ui_out
probably was just copy/paste, because I think aligning never made
sense in an MI context.
gdb/ChangeLog
2018-11-25 Tom Tromey <tom@tromey.com>
* ui-out.c (ui_out::field_fmt): Remove comment.
* tui/tui-out.c (tui_ui_out::do_field_fmt): Remove comment.
* mi/mi-out.c (mi_ui_out::do_field_fmt): Remove comment.
GDB Administrator [Sun, 25 Nov 2018 00:01:25 +0000 (00:01 +0000)]
Automatic date update in version.in
Philippe Waroquiers [Sat, 24 Nov 2018 11:42:24 +0000 (12:42 +0100)]
Re-fix leak in source.c (open_source_file).
Leak fixed in '
8e6a5953e1d Fix 4K leak in open_source_file' has been partially
undone by '
2179fbc36d23 Return scoped_fd from open_source_file'. Re-add the
transfer of current s->fullname to the unique_xmalloc_ptr fullname given to
find_and_open_source.
GDB Administrator [Sat, 24 Nov 2018 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
Andre Vieira [Fri, 23 Nov 2018 17:10:53 +0000 (17:10 +0000)]
[GAS][ARM] Fix testism for bl local v4t test
gas/ChangeLog
2018-11-23 Andre Vieira <andre.simoesdiasvieira@arm.com>
* testsuite/gas/arm/bl-local-v4t.d: Remove
warning check.
* testsuite/gas/arm/blx-local-thumb.s: New.
* testsuite/gas/arm/blx-local-thumb.d: New.
Alan Hayward [Fri, 23 Nov 2018 11:46:34 +0000 (11:46 +0000)]
gdbserver: AArch64: Remove cannot_fetch/store_register
The cannot store/fetch register functions are only used for checking
if a register can be accessed using PEEKUSER/POKEUSER.
The AArch64 port doesn't support this method of access, so remove the
unused functions.
gdb/gdbserver:
* linux-aarch64-low.c (aarch64_cannot_store_register): Remove.
(aarch64_cannot_fetch_register): Likewise.
(struct linux_target_ops): Update references.
Pedro Alves [Fri, 23 Nov 2018 13:36:59 +0000 (13:36 +0000)]
Remove declarations of is_running/is_stopped/is_exited
The recent commit
080363310650 ("Per-inferior thread list, thread
ranges/iterators, down with ALL_THREADS, etc.") removed the
definitions of is_running/is_stopped/is_exited but missed removing the
declarations.
gdb/ChangeLog:
2018-11-23 Pedro Alves <palves@redhat.com>
* gdbthread.h (enum thread_state): Move comments here.
(is_running, is_stopped, is_exited): Remove declarations.
GDB Administrator [Fri, 23 Nov 2018 00:00:49 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Thu, 22 Nov 2018 16:09:14 +0000 (16:09 +0000)]
Per-inferior thread list, thread ranges/iterators, down with ALL_THREADS, etc.
As preparation for multi-target, this patch makes each inferior have
its own thread list.
This isn't absolutely necessary for multi-target, but simplifies
things. It originally stemmed from the desire to eliminate the
init_thread_list calls sprinkled around, plus it makes it more
efficient to iterate over threads of a given inferior (no need to
always iterate over threads of all inferiors).
We still need to iterate over threads of all inferiors in a number of
places, which means we'd need adjust the ALL_THREADS /
ALL_NON_EXITED_THREADS macros. However, naively tweaking those macros
to have an extra for loop, like:
#define ALL_THREADS (thr, inf) \
for (inf = inferior_list; inf; inf = inf->next) \
for (thr = inf->thread_list; thr; thr = thr->next)
causes problems with code that does "break" or "continue" within the
ALL_THREADS loop body. Plus, we need to declare the extra "inf" local
variable in order to pass it as temporary variable to ALL_THREADS
(etc.)
It gets even trickier when we consider extending the macros to filter
out threads matching a ptid_t and a target. The macros become tricker
to read/write. Been there.
An alternative (which was my next attempt), is to replace the
ALL_THREADS etc. iteration style with for_each_all_threads,
for_each_non_exited_threads, etc. functions which would take a
callback as parameter, which would usually be passed a lambda.
However, I did not find that satisfactory at all, because the
resulting code ends up a little less natural / more noisy to read,
write and debug/step-through (due to use of lambdas), and in many
places where we use "continue;" to skip to the next thread now need to
use "return;". (I ran into hard to debug bugs caused by a
continue/return confusion.)
I.e., before:
ALL_NON_EXITED_THREADS (tp)
{
if (tp->not_what_I_want)
continue;
// do something
}
would turn into:
for_each_non_exited_thread ([&] (thread_info *tp)
{
if (tp->not_what_I_want)
return;
// do something
});
Lastly, the solution I settled with was to replace the ALL_THREADS /
ALL_NON_EXITED_THREADS / ALL_INFERIORS macros with (C++20-like) ranges
and iterators, such that you can instead naturaly iterate over
threads/inferiors using range-for, like e.g,.:
// all threads, including THREAD_EXITED threads.
for (thread_info *tp : all_threads ())
{ .... }
// all non-exited threads.
for (thread_info *tp : all_non_exited_threads ())
{ .... }
// all non-exited threads of INF inferior.
for (thread_info *tp : inf->non_exited_threads ())
{ .... }
The all_non_exited_threads() function takes an optional filter ptid_t as
parameter, which is quite convenient when we need to iterate over
threads matching that filter. See e.g., how the
set_executing/set_stop_requested/finish_thread_state etc. functions in
thread.c end up being simplified.
Most of the patch thus is about adding the infrustructure for allowing
the above. Later on when we get to actual multi-target, these
functions/ranges/iterators will gain a "target_ops *" parameter so
that e.g., we can iterate over all threads of a given target that
match a given filter ptid_t.
The only entry points users needs to be aware of are the
all_threads/all_non_exited_threads etc. functions seen above. Thus,
those functions are declared in gdbthread.h/inferior.h. The actual
iterators/ranges are mainly "internals" and thus are put out of view
in the new thread-iter.h/thread-iter.c/inferior-iter.h files. That
keeps the gdbthread.h/inferior.h headers quite a bit more readable.
A common/safe-iterator.h header is added which adds a template that
can be used to build "safe" iterators, which are forward iterators
that can be used to replace the ALL_THREADS_SAFE macro and other
instances of the same idiom in future.
There's a little bit of shuffling of code between
gdbthread.h/thread.c/inferior.h in the patch. That is necessary in
order to avoid circular dependencies between the
gdbthread.h/inferior.h headers.
As for the init_thread_list calls sprinkled around, they're all
eliminated by this patch, and a new, central call is added to
inferior_appeared. Note how also related to that, there's a call to
init_wait_for_inferior in remote.c that is eliminated.
init_wait_for_inferior is currently responsible for discarding skipped
inline frames, which had to be moved elsewhere. Given that nowadays
we always have a thread even for single-threaded processes, the
natural place is to delete a frame's inline frame info when we delete
the thread. I.e., from clear_thread_inferior_resources.
gdb/ChangeLog:
2018-11-22 Pedro Alves <palves@redhat.com>
* Makefile.in (COMMON_SFILES): Add thread-iter.c.
* breakpoint.c (breakpoints_should_be_inserted_now): Replace
ALL_NON_EXITED_THREADS with all_non_exited_threads.
(print_one_breakpoint_location): Replace ALL_INFERIORS with
all_inferiors.
* bsd-kvm.c: Include inferior.h.
* btrace.c (btrace_free_objfile): Replace ALL_NON_EXITED_THREADS
with all_non_exited_threads.
* common/filtered-iterator.h: New.
* common/safe-iterator.h: New.
* corelow.c (core_target_open): Don't call init_thread_list here.
* darwin-nat.c (thread_info_from_private_thread_info): Replace
ALL_THREADS with all_threads.
* fbsd-nat.c (fbsd_nat_target::resume): Replace
ALL_NON_EXITED_THREADS with inf->non_exited_threads.
* fbsd-tdep.c (fbsd_make_corefile_notes): Replace
ALL_NON_EXITED_THREADS with inf->non_exited_threads.
* fork-child.c (postfork_hook): Don't call init_thread_list here.
* gdbarch-selftests.c (register_to_value_test): Adjust.
* gdbthread.h: Don't include "inferior.h" here.
(struct inferior): Forward declare.
(enum step_over_calls_kind): Moved here from inferior.h.
(thread_info::deletable): Definition moved to thread.c.
(find_thread_ptid (inferior *, ptid_t)): Declare.
(ALL_THREADS, ALL_THREADS_BY_INFERIOR, ALL_THREADS_SAFE): Delete.
Include "thread-iter.h".
(all_threads, all_non_exited_threads, all_threads_safe): New.
(any_thread_p): Declare.
(thread_list): Delete.
* infcmd.c (signal_command): Replace ALL_NON_EXITED_THREADS with
all_non_exited_threads.
(proceed_after_attach_callback): Delete.
(proceed_after_attach): Take an inferior pointer instead of an
integer PID. Adjust to use range-for.
(attach_post_wait): Pass down inferior pointer instead of pid.
Use range-for instead of ALL_NON_EXITED_THREADS.
(detach_command): Remove init_thread_list call.
* inferior-iter.h: New.
* inferior.c (struct delete_thread_of_inferior_arg): Delete.
(delete_thread_of_inferior): Delete.
(delete_inferior, exit_inferior_1): Use range-for with
inf->threads_safe() instead of iterate_over_threads.
(inferior_appeared): Call init_thread_list here.
(discard_all_inferiors): Use all_non_exited_inferiors.
(find_inferior_id, find_inferior_pid): Use all_inferiors.
(iterate_over_inferiors): Use all_inferiors_safe.
(have_inferiors, number_of_live_inferiors): Use
all_non_exited_inferiors.
(number_of_inferiors): Use all_inferiors and std::distance.
(print_inferior): Use all_inferiors.
* inferior.h: Include gdbthread.h.
(enum step_over_calls_kind): Moved to gdbthread.h.
(struct inferior) <thread_list>: New field.
<threads, non_exited_threads, threads_safe>: New methods.
(ALL_INFERIORS): Delete.
Include "inferior-iter.h".
(ALL_NON_EXITED_INFERIORS): Delete.
(all_inferiors_safe, all_inferiors, all_non_exited_inferiors): New
functions.
* inflow.c (child_interrupt, child_pass_ctrlc): Replace
ALL_NON_EXITED_THREADS with all_non_exited_threads.
* infrun.c (follow_exec): Use all_threads_safe.
(clear_proceed_status, proceed): Use all_non_exited_threads.
(init_wait_for_inferior): Don't clear inline frame state here.
(infrun_thread_stop_requested, for_each_just_stopped_thread): Use
all_threads instead of ALL_NON_EXITED_THREADS.
(random_pending_event_thread): Use all_non_exited_threads instead
of ALL_NON_EXITED_THREADS. Use a lambda for repeated code.
(clean_up_just_stopped_threads_fsms): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
(handle_no_resumed): Use all_non_exited_threads instead of
ALL_NON_EXITED_THREADS. Use all_inferiors instead of
ALL_INFERIORS.
(restart_threads, switch_back_to_stepped_thread): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
* linux-nat.c (check_zombie_leaders): Replace ALL_INFERIORS with
all_inferiors.
(kill_unfollowed_fork_children): Use inf->non_exited_threads
instead of ALL_NON_EXITED_THREADS.
* linux-tdep.c (linux_make_corefile_notes): Use
inf->non_exited_threads instead of ALL_NON_EXITED_THREADS.
* linux-thread-db.c (thread_db_target::update_thread_list):
Replace ALL_INFERIORS with all_inferiors.
(thread_db_target::thread_handle_to_thread_info): Use
inf->non_exited_threads instead of ALL_NON_EXITED_THREADS.
* mi/mi-interp.c (multiple_inferiors_p): New.
(mi_on_resume_1): Simplify using all_non_exited_threads and
multiple_inferiors_p.
* mi/mi-main.c (mi_cmd_thread_list_ids): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
* nto-procfs.c (nto_procfs_target::open): Don't call
init_thread_list here.
* record-btrace.c (record_btrace_target_open)
(record_btrace_target::stop_recording)
(record_btrace_target::close)
(record_btrace_target::record_is_replaying)
(record_btrace_target::resume, record_btrace_target::wait)
(record_btrace_target::record_stop_replaying): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
* record-full.c (record_full_wait_1): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
* regcache.c (cooked_read_test): Remove reference to global
thread_list.
* remote-sim.c (gdbsim_target::create_inferior): Don't call
init_thread_list here.
* remote.c (remote_target::update_thread_list): Use
all_threads_safe instead of ALL_NON_EXITED_THREADS.
(remote_target::process_initial_stop_replies): Replace
ALL_INFERIORS with all_non_exited_inferiors and use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
(remote_target::open_1): Don't call init_thread_list here.
(remote_target::append_pending_thread_resumptions)
(remote_target::remote_resume_with_hc): Use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
(remote_target::commit_resume)
(remote_target::remove_new_fork_children): Replace ALL_INFERIORS
with all_non_exited_inferiors and use all_non_exited_threads
instead of ALL_NON_EXITED_THREADS.
(remote_target::kill_new_fork_children): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS. Remove
init_thread_list and init_wait_for_inferior calls.
(remote_target::remote_btrace_maybe_reopen)
(remote_target::thread_handle_to_thread_info): Use
all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
* target.c (target_terminal::restore_inferior)
(target_terminal_is_ours_kind): Replace ALL_INFERIORS with
all_non_exited_inferiors.
* thread-iter.c: New file.
* thread-iter.h: New file.
* thread.c: Include "inline-frame.h".
(thread_list): Delete.
(clear_thread_inferior_resources): Call clear_inline_frame_state.
(init_thread_list): Use all_threads_safe instead of
ALL_THREADS_SAFE. Adjust to per-inferior thread lists.
(new_thread): Adjust to per-inferior thread lists.
(add_thread_silent): Pass inferior to find_thread_ptid.
(thread_info::deletable): New, moved from the header.
(delete_thread_1): Adjust to per-inferior thread lists.
(find_thread_global_id): Use inf->threads().
(find_thread_ptid): Use find_inferior_ptid and pass inferior to
find_thread_ptid.
(find_thread_ptid(inferior*, ptid_t)): New overload.
(iterate_over_threads): Use all_threads_safe.
(any_thread_p): New.
(thread_count): Use all_threads and std::distance.
(live_threads_count): Use all_non_exited_threads and
std::distance.
(valid_global_thread_id): Use all_threads.
(in_thread_list): Use find_thread_ptid.
(first_thread_of_inferior): Adjust to per-inferior thread lists.
(any_thread_of_inferior, any_live_thread_of_inferior): Use
inf->non_exited_threads().
(prune_threads, delete_exited_threads): Use all_threads_safe.
(thread_change_ptid): Pass inferior pointer to find_thread_ptid.
(set_resumed, set_running): Use all_non_exited_threads.
(is_thread_state, is_stopped, is_exited, is_running)
(is_executing): Delete.
(set_executing, set_stop_requested, finish_thread_state): Use
all_non_exited_threads.
(print_thread_info_1): Use all_inferiors and all_threads.
(thread_apply_all_command): Use all_non_exited_threads.
(thread_find_command): Use all_threads.
(update_threads_executing): Use all_non_exited_threads.
* tid-parse.c (parse_thread_id): Use inf->threads.
* x86-bsd-nat.c (x86bsd_dr_set): Use inf->non_exited_threads ().
Pedro Alves [Thu, 22 Nov 2018 16:09:12 +0000 (16:09 +0000)]
Fix follow_exec latent problem
A following commit to make each inferior have its own thread list
exposes a problem with
bf93d7ba99 ("Add thread after updating gdbarch
when exec'ing"), which is that we can't defer adding the thread
because that breaks try_open_exec_file which deep inside ends up
calling inferior_thread():
#5 0x0000000000637c78 in internal_error(char const*, int, char const*, ...) (file=0xc151f8 "src/gdb/thread.c", line=165, fmt=0xc15180 "%s: Assertion `%s' failed.") at src/gdb/common/errors.c:55
#6 0x00000000008a3d80 in inferior_thread() () at src/gdb/thread.c:165
#7 0x0000000000456f91 in try_thread_db_load_1(thread_db_info*) (info=0x277eb00) at src/gdb/linux-thread-db.c:830
#8 0x0000000000457554 in try_thread_db_load(char const*, int) (library=0xb01a4f "libthread_db.so.1", check_auto_load_safe=0)
at src/gdb/linux-thread-db.c:1002
#9 0x0000000000457861 in try_thread_db_load_from_sdir() () at src/gdb/linux-thread-db.c:1079
#10 0x0000000000457b72 in thread_db_load_search() () at src/gdb/linux-thread-db.c:1134
#11 0x0000000000457d29 in thread_db_load() () at src/gdb/linux-thread-db.c:1192
#12 0x0000000000457e51 in check_for_thread_db() () at src/gdb/linux-thread-db.c:1244
#13 0x0000000000457ed2 in thread_db_new_objfile(objfile*) (objfile=0x270ff60) at src/gdb/linux-thread-db.c:1273
#14 0x000000000045a92e in std::_Function_handler<void (objfile*), void (*)(objfile*)>::_M_invoke(std::_Any_data const&, objfile*&&) (__functor=..., __args#0=@0x7ffef3efe140: 0x270ff60) at /usr/include/c++/7/bits/std_function.h:316
#15 0x00000000007bbebf in std::function<void (objfile*)>::operator()(objfile*) const (this=0x24e1d18, __args#0=0x270ff60)
at /usr/include/c++/7/bits/std_function.h:706
#16 0x00000000007bba86 in gdb::observers::observable<objfile*>::notify(objfile*) const (this=0x117ce80 <gdb::observers::new_objfile>, args#0=0x270ff60) at src/gdb/common/observable.h:106
#17 0x0000000000856000 in symbol_file_add_with_addrs(bfd*, char const*, symfile_add_flags, section_addr_info*, objfile_flags, objfile*) (abfd=0x1d7dae0, name=0x254bfc0 "/ho
The problem is latent currently because inferior_thread() at that
point manages to return a thread, even though it's the wrong one (of
the old inferior).
The problem originally fixed by
bf93d7ba99 was:
(...) we should avoid doing register reads
after a process does an exec and before we've updated that inferior's
gdbarch. Otherwise, we may interpret the registers using the wrong
architecture.
(...) The call to "add_thread" done just after adding the inferior is
problematic, because it ends up reading the registers (because the ptid
is re-used, we end up doing a switch_to_thread to it, which tries to
update stop_pc). (...)
The register-reading issue is no longer a problem nowadays, ever since
switch_to_thread stopped reading the stop_pc in git commit
f2ffa92bbce9 ("gdb: Eliminate the 'stop_pc' global").
So this commit basically reverts
bf93d7ba99.
gdb/ChangeLog:
2018-11-22 Pedro Alves <palves@redhat.com>
* infrun.c (follow_exec) <set follow-exec new>: Add thread and
switch to it before calling into try_open_exec_file.
Pedro Alves [Thu, 22 Nov 2018 16:09:12 +0000 (16:09 +0000)]
Avoid find_thread_ptid with null_ptid
With a following patch, find_thread_ptid will first find the inferior
for the passed-in ptid, using find_inferior_pid, and then look for the
thread in that inferior's thread list. If we pass down null_ptid to
find_thread_ptid then that means we'll end up passing 0 to
find_inferior_pid, which hits this assertion:
> struct inferior *
> find_inferior_pid (int pid)
> {
> struct inferior *inf;
>
> /* Looking for inferior pid == 0 is always wrong, and indicative of
> a bug somewhere else. There may be more than one with pid == 0,
> for instance. */
> gdb_assert (pid != 0);
This patch prepares for the change, by avoiding passing down null_ptid
to find_thread_ptid or to functions that naturally use it, such as the
target_pid_to_str call in inferior.c:add_inferior. In that latter
case, the patch changes GDB output,
from:
(gdb) add-inferior
[New inferior 2 (process 0)]
to:
(gdb) add-inferior
[New inferior 2]
which seems like a good change to me. It might not even make sense to
talk about "process" for the current target, for example.
The python_on_normal_stop change ends up avoiding looking up the
same thread twice (inferior_thread also does a look up).
gdb/ChangeLog:
2018-11-22 Pedro Alves <palves@redhat.com>
* cli/cli-interp.c (cli_on_user_selected_context_changed): Use
inferior_thread instead of find_thread_ptid, and only when
inferior_ptid is not null_ptid.
* inferior.c (add_inferior): Don't include target_pid_to_str
output when the inferior is not started.
* python/py-inferior.c (python_on_normal_stop): Don't use
find_thread_ptid.
(tui_on_user_selected_context_changed): Use inferior_thread
instead of find_thread_ptid, and only when inferior_ptid is not
null_ptid.
GDB Administrator [Thu, 22 Nov 2018 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in
John Darrington [Tue, 20 Nov 2018 17:50:30 +0000 (18:50 +0100)]
S12Z opcodes: Fix bug disassembling certain shift instructions.
Shift and rotate instructions when the number of bit positions
was an immediate value greater than 1 were incorrectly disassembled.
This change fixes that problem and extends the test to check for
it.
gas/ChangeLog:
testsuite/gas/s12z/shift.s: Add new test case.
testsuite/gas/s12z/shift.d: Add expected result.
opcodes/ChangeLog:
s12z-dis.c (print_insn_shift) [SB_REG_REG_N]: Enter special case
if the postbyte matches the appropriate pattern.
John Darrington [Tue, 20 Nov 2018 17:50:30 +0000 (18:50 +0100)]
S12Z: Add alias instructions BHS and BLO.
These are documented by NXP as alternative mnemonics for BCC and BCS
respectively.
gas/ChangeLog:
* config/tc-s12z.c (opcodes): bhs, blo: New members.
* testsuite/gas/s12z/bra.d: Add tests for aliases.
* testsuite/gas/s12z/bra.s: Add tests for aliases.
Benno Fünfstück [Wed, 21 Nov 2018 17:06:05 +0000 (17:06 +0000)]
Make command-repeat work after gdb.execute
Since commit
56bcdbea2bed ("Let gdb.execute handle multi-line commands")
command repetition after using the `gdb.execute` Python function
fails (the previous command is not repeated anymore). This happens
because read_command_lines_1 sets dont_repeat, but the call to
prevent_dont_repeat in execute_gdb_command is later.
The fix is to move the call to prevent_dont_repeat to the beginning of
the function.
Tested on my laptop (ArchLinux-x86_64).
gdb/ChangeLog:
PR python/23714
* gdb/python/python.c (execute_gdb_command): Call
prevent_dont_repeat earlier to avoid affecting dont_repeat.
gdb/testuite/ChangeLog:
PR python/23714
* gdb.python/python.exp: Test command repetition after
gdb.execute.
Jozef Lawrynowicz [Wed, 21 Nov 2018 16:21:25 +0000 (16:21 +0000)]
Fix linking MSP430 files created by gcc's LTO optimizer.
When invoking GCC with "-g -flto", the compiler will create LTO objects
with debug information. The objects created are "simple ELF" objects (see
libiberty/simple-object-elf.c) and do not have target-specific sections.
When the MSP430 linker sees one of these objects without a .MSP430.attributes
section it errors:
> error: /tmp/cc4LhbEI.ltrans0.ltrans.o uses MSP430X instructions but /tmp/ccynqIwudebugobj uses unknown
> error: /tmp/cc4LhbEI.ltrans0.ltrans.o uses the small code model whereas /tmp/ccynqIwudebugobj uses the unknown code model
> error: /tmp/cc4LhbEI.ltrans0.ltrans.o uses the small data model whereas /tmp/ccynqIwudebugobj uses the unknown data model
> error: /tmp/cc4LhbEI.ltrans0.ltrans.o uses the small code model but /tmp/ccynqIwudebugobj uses the unknown data model
> failed to merge target specific data of file /tmp/cc4LhbEI.ltrans0.ltrans.o
The following patch allows these debug LTO objects to be linked with other
MSP430 objects even if they do not have a .MSP430.attributes section.
bfd * elf32-msp430.c (elf32_msp430_merge_mspabi_attributes): Do not
error when .MSP430.attributes section is missing from objects
created by LTO.
Andrew Burgess [Mon, 29 Oct 2018 15:10:52 +0000 (15:10 +0000)]
gdb/riscv: Add target description support
This commit adds target description support for riscv.
I've used the split feature approach for specifying the architectural
features, and the CSR feature is auto-generated from the riscv-opc.h
header file.
If the target doesn't provide a suitable target description then GDB
will build one by looking at the bfd headers.
This commit does not implement target description creation for the
Linux or FreeBSD native targets, both of these will need to add
read_description methods into their respective target classes, which
probe the target features, and then call
riscv_create_target_description to build a suitable target
description. Until this is done Linux and FreeBSD will get the same
default target description based on the bfd that bare-metal targets
get.
I've only added feature descriptions for 32 and 64 bit registers, 128
bit registers (for RISC-V) are not supported in the reset of GDB yet.
This commit removes the special reading of the MISA register in order
to establish the target features, this was only used for figuring out
the f-register size, and even that wasn't done consistently. We now
rely on the target to tell us what size of registers it has (or look
in the BFD as a last resort). The result of this is that we should
now support RV64 targets with 32-bit float, though I have not
extensively tested this combination yet.
* Makefile.in (ALL_TARGET_OBS): Add arch/riscv.o.
(HFILES_NO_SRCDIR): Add arch/riscv.h.
* arch/riscv.c: New file.
* arch/riscv.h: New file.
* configure.tgt: Add cpu_obs list of riscv, move riscv-tdep.o into
this list, and add arch/riscv.o.
* features/Makefile: Add riscv features.
* features/riscv/32bit-cpu.c: New file.
* features/riscv/32bit-cpu.xml: New file.
* features/riscv/32bit-csr.c: New file.
* features/riscv/32bit-csr.xml: New file.
* features/riscv/32bit-fpu.c: New file.
* features/riscv/32bit-fpu.xml: New file.
* features/riscv/64bit-cpu.c: New file.
* features/riscv/64bit-cpu.xml: New file.
* features/riscv/64bit-csr.c: New file.
* features/riscv/64bit-csr.xml: New file.
* features/riscv/64bit-fpu.c: New file.
* features/riscv/64bit-fpu.xml: New file.
* features/riscv/rebuild-csr-xml.sh: New file.
* riscv-tdep.c: Add 'arch/riscv.h' include.
(riscv_gdb_reg_names): Delete.
(csr_reggroup): New global.
(struct riscv_register_alias): Delete.
(struct riscv_register_feature): New structure.
(riscv_register_aliases): Delete.
(riscv_xreg_feature): New global.
(riscv_freg_feature): New global.
(riscv_virtual_feature): New global.
(riscv_csr_feature): New global.
(riscv_create_csr_aliases): New function.
(riscv_read_misa_reg): Delete.
(riscv_has_feature): Delete.
(riscv_isa_xlen): Simplify, just return cached xlen.
(riscv_isa_flen): Simplify, just return cached flen.
(riscv_has_fp_abi): Update for changes in struct gdbarch_tdep.
(riscv_register_name): Update to make use of tdesc_register_name.
Look up xreg and freg names in the new globals riscv_xreg_feature
and riscv_freg_feature. Don't supply csr aliases here.
(riscv_fpreg_q_type): Delete.
(riscv_register_type): Use tdesc_register_type in almost all
cases, override the returned type in a few specific cases only.
(riscv_print_one_register_info): Handle errors reading registers.
(riscv_register_reggroup_p): Use tdesc_register_in_reggroup_p for
registers that are otherwise unknown to GDB. Also check the
csr_reggroup.
(riscv_print_registers_info): Remove assert about upper register
number, and use gdbarch_register_reggroup_p instead of
short-cutting.
(riscv_find_default_target_description): New function.
(riscv_check_tdesc_feature): New function.
(riscv_add_reggroups): New function.
(riscv_setup_register_aliases): New function.
(riscv_init_reggroups): New function.
(_initialize_riscv_tdep): Add calls to setup CSR aliases, and
setup register groups. Register new riscv debug variable.
* riscv-tdep.h: Add 'arch/riscv.h' include.
(struct gdbarch_tdep): Remove abi union, and add
riscv_gdbarch_features field. Remove cached quad floating point
type, and provide initialisation for double type field.
* target-descriptions.c (maint_print_c_tdesc_cmd): Add riscv to
the list of targets using the feature based target descriptions.
* NEWS: Mention target description support.
gdb/doc/ChangeLog:
* gdb.texinfo (Standard Target Features): Add RISC-V Features
sub-section.
Pedro Alves [Wed, 21 Nov 2018 11:55:15 +0000 (11:55 +0000)]
valops.c: Overload resolution code: Rename parameters/locals
While looking over this code, I thought the names of the parameters to
find_oload_champ and related functions and locals were a bit too
cryptic. For example, FN_LIST holds methods, not free functions.
Free-functions are in OLOAD_SYMS.
This patch renames parameters/variables to the more obvious
methods/xmethods/functions instead.
gdb/ChangeLog:
2018-11-21 Pedro Alves <palves@redhat.com>
* valops.c (find_method_list, value_find_oload_method_list)
(find_overload_match, find_oload_champ): Rename parameters and
locals.
Pedro Alves [Wed, 21 Nov 2018 11:55:14 +0000 (11:55 +0000)]
valops.c: Some more gdb::array_view
This commit replaces some more use of pointer+length pairs in the
overload resolution code with gdb::array_view.
find_oload_champ's interface is simplified/normalized: the xmethods
parameter is converted from std::vector to array pointer, and then the
num_fns parameter is always passed in, no matter the array which is
non-NULL. I tweaked the formatting of callers a little bit here and
there so that the 3 optional parameters are all in the same line. (I
tried making the 3 optional array parameters be array_views, but the
resulting code didn't look as nice.)
gdb/ChangeLog:
2018-11-21 Pedro Alves <palves@redhat.com>
* valops.c (find_method_list): Replace pointer and length
parameters with an gdb::array_view. Adjust.
(value_find_oload_method_list): Likewise.
(find_overload_match): Use gdb::array_view for methods list.
Adjust to find_oload_champ interface change.
(find_oload_champ): 'xm_worker_vec' parameter now a pointer/array.
'num_fns' parameter now a size_t. Eliminate 'fn_count' local.
Pedro Alves [Wed, 21 Nov 2018 11:55:14 +0000 (11:55 +0000)]
C++ify badness_vector, fix leaks
badness_vector is currently an open coded vector. This reimplements
it as a std::vector.
This fixes a few leaks as well:
- find_oload_champ is leaking every badness vector calculated bar the
one returned.
- bv->rank is always leaked, since callers of rank_function only
xfree the badness_vector pointer, not bv->rank.
gdb/ChangeLog:
2018-11-21 Pedro Alves <palves@redhat.com>
* gdbtypes.c (compare_badness): Change type of parameters to const
reference. Adjust to badness_vector being a std::vector now.
(rank_function): Adjust to badness_vector being a std::vector now.
* gdbtypes.h (badness_vector): Now a typedef to std::vector.
(LENGTH_MATCH): Delete.
(compare_badness): Change type of parameters to const reference.
(rank_function): Return a badness_vector by value now.
(find_overload_match): Adjust to badness_vector being a
std::vector now. Remove cleanups.
(find_oload_champ_namespace): 'oload_champ_bv' parameter now a
badness_vector pointer.
(find_oload_champ_namespace_loop): 'oload_champ_bv' parameter now
a badness_vector pointer. Adjust to badness_vector being a
std::vector now. Remove cleanups.
(find_oload_champ): 'oload_champ_bv' parameter now
a badness_vector pointer. Adjust to badness_vector being a
std::vector now. Remove cleanups.
Pedro Alves [Wed, 21 Nov 2018 11:55:13 +0000 (11:55 +0000)]
Eliminate make_symbol_overload_list-related globals & cleanup
This gets rid of a few globals and a cleanup.
make_symbol_overload_list & friends currently maintain a global
open-coded vector. Reimplement that with a std::vector, trickled down
through the functions. Rename a few functions from "make_" to "add_"
for clarity.
gdb/ChangeLog:
2018-11-21 Pedro Alves <palves@redhat.com>
* cp-support.c (sym_return_val_size, sym_return_val_index)
(sym_return_val): Delete.
(overload_list_add_symbol): Add std::vector parameter. Adjust to
add to the vector.
(make_symbol_overload_list): Adjust to return a std::vector
instead of maintaining a global open coded vector.
(make_symbol_overload_list_block): Add std::vector parameter.
(make_symbol_overload_list_block): Rename to ...
(add_symbol_overload_list_block): ... this and add std::vector
parameter.
(make_symbol_overload_list_namespace): Rename to ...
(add_symbol_overload_list_namespace): ... this and add std::vector
parameter.
(make_symbol_overload_list_adl_namespace): Rename to ...
(add_symbol_overload_list_adl_namespace): ... this and add
std::vector parameter.
(make_symbol_overload_list_adl): Delete.
(add_symbol_overload_list_adl): New.
(make_symbol_overload_list_using): Rename to ...
(add_symbol_overload_list_using): ... this and add std::vector
parameter.
(make_symbol_overload_list_qualified): Rename to ...
(add_symbol_overload_list_qualified): ... this and add std::vector
parameter.
* cp-support.h: Include "common/array-view.h" and <vector>.
(make_symbol_overload_list): Change return type to std::vector.
(make_symbol_overload_list_adl): Delete declaration.
(add_symbol_overload_list_adl): New declaration.
* valops.c (find_overload_match): Local 'oload_syms' now a
std::vector.
(find_oload_champ_namespace): 'oload_syms' parameter now a
std::vector pointer.
(find_oload_champ_namespace_loop): 'oload_syms' parameter now a
std::vector pointer. Adjust to new make_symbol_overload_list
interface.
Pedro Alves [Wed, 21 Nov 2018 11:55:12 +0000 (11:55 +0000)]
invoke_xmethod & array_view
This replaces more pointer+length with gdb::array_view. This time,
around invoke_xmethod, and then propagating the fallout around, which
inevitably leaks to the overload resolution code.
There are several places in the code that want to grab a slice of an
array, by advancing the array pointer, and decreasing the length
pointer. This patch introduces a pair of new
gdb::array_view::slice(...) methods to make that convenient and clear.
Unit test included.
gdb/ChangeLog:
2018-11-21 Pedro Alves <palves@redhat.com>
* common/array-view.h (array_view::splice(size_type, size_t)): New.
(array_view::splice(size_type)): New.
* eval.c (eval_call, evaluate_funcall): Adjust to use array_view.
* extension.c (xmethod_worker::get_arg_types): Adjust to return an
std::vector.
(xmethod_worker::get_result_type): Adjust to use gdb::array_view.
* extension.h: Include "common/array-view.h".
(xmethod_worker::invoke): Adjust to use gdb::array_view.
(xmethod_worker::get_arg_types): Adjust to return an std::vector.
(xmethod_worker::get_result_type): Adjust to use gdb::array_view.
(xmethod_worker::do_get_arg_types): Adjust to use std::vector.
(xmethod_worker::do_get_result_type): Adjust to use
gdb::array_view.
* gdbtypes.c (rank_function): Adjust to use gdb::array_view.
* gdbtypes.h: Include "common/array-view.h".
(rank_function): Adjust to use gdb::array_view.
* python/py-xmethods.c (python_xmethod_worker::invoke)
(python_xmethod_worker::do_get_arg_types)
(python_xmethod_worker::do_get_result_type)
(python_xmethod_worker::invoke): Adjust to new interfaces.
* valarith.c (value_user_defined_cpp_op, value_user_defined_op)
(value_x_binop, value_x_unop): Adjust to use gdb::array_view.
* valops.c (find_overload_match, find_oload_champ_namespace)
(find_oload_champ_namespace_loop, find_oload_champ): Adjust to use
gdb:array_view and the new xmethod_worker interfaces.
* value.c (result_type_of_xmethod, call_xmethod): Adjust to use
gdb::array_view.
* value.h (find_overload_match, result_type_of_xmethod)
(call_xmethod): Adjust to use gdb::array_view.
* unittests/array-view-selftests.c: Add slicing tests.
Pedro Alves [Wed, 21 Nov 2018 11:55:11 +0000 (11:55 +0000)]
Use gdb:array_view in call_function_by_hand & friends
This replaces a few uses of pointer+length with gdb::array_view, in
call_function_by_hand and related code.
Unfortunately, due to -Wnarrowing, there are places where we can't
brace-initialize an gdb::array_view without an ugly-ish cast. To
avoid the cast, this patch introduces a gdb::make_array_view function.
Unit tests included.
This patch in isolation may not look so interesting, due to
gdb::make_array_view uses, but I think it's still worth it. Some of
the gdb::make_array_view calls disappear down the series, and others
could be eliminated with more (non-trivial) gdb::array_view
detangling/conversion (e.g. code around eval_call). See this as a "we
have to start somewhere" patch.
gdb/ChangeLog:
2018-11-21 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_evaluate_subexp): Adjust to pass an array_view.
* common/array-view.h (make_array_view): New.
* compile/compile-object-run.c (compile_object_run): Adjust to
pass an array_view.
* elfread.c (elf_gnu_ifunc_resolve_addr): Adjust.
* eval.c (eval_call): Adjust to pass an array_view.
(evaluate_subexp_standard): Adjust to pass an array_view.
* gcore.c (call_target_sbrk): Adjust to pass an array_view.
* guile/scm-value.c (gdbscm_value_call): Likewise.
* infcall.c (push_dummy_code): Replace pointer + size parameters
with an array_view parameter.
(call_function_by_hand, call_function_by_hand_dummy): Likewise and
adjust.
* infcall.h: Include "common/array-view.h".
(call_function_by_hand, call_function_by_hand_dummy): Replace
pointer + size parameters with an array_view parameter.
* linux-fork.c (inferior_call_waitpid): Adjust to use array_view.
* linux-tdep.c (linux_infcall_mmap): Likewise.
* objc-lang.c (lookup_objc_class, lookup_child_selector)
(value_nsstring, print_object_command): Likewise.
* python/py-value.c (valpy_call): Likewise.
* rust-lang.c (rust_evaluate_funcall): Likewise.
* spu-tdep.c (flush_ea_cache): Likewise.
* valarith.c (value_x_binop, value_x_unop): Likewise.
* valops.c (value_allocate_space_in_inferior): Likewise.
* unittests/array-view-selftests.c (run_tests): Add
gdb::make_array_view test.