binutils-gdb.git
7 years agoFix building riscv targets with gcc v6.3.1
Nick Clifton [Wed, 15 Mar 2017 09:19:42 +0000 (09:19 +0000)]
Fix building riscv targets with gcc v6.3.1

* config/tc-riscv.c (riscv_pre_output_hook): Fix compile time
warning about discarding a const qualifier.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 15 Mar 2017 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAdd DW_OP_GNU_variable_value
H.J. Lu [Tue, 14 Mar 2017 19:56:49 +0000 (12:56 -0700)]
Add DW_OP_GNU_variable_value

Sync GCC dwarf.def change

2017-03-14  Jakub Jelinek  <jakub@redhat.com>

PR debug/77589
* dwarf2.def (DW_OP_GNU_variable_value): New opcode.

7 years agoinf-ptrace: Do not stop memory transfers after a single word
Andreas Arnez [Tue, 14 Mar 2017 18:20:46 +0000 (19:20 +0100)]
inf-ptrace: Do not stop memory transfers after a single word

When inf_ptrace_xfer_partial performs a memory transfer via ptrace with
PT_READ_I, PT_WRITE_I (aka PTRACE_PEEKTEXT, PTRACE_POKETEXT), etc., then
it currently transfers at most one word.  This behavior yields degraded
performance, particularly if the caller has significant preparation work
for each invocation.  And indeed it has for writing, in
memory_xfer_partial in target.c, where all of the remaining data to be
transferred is copied to a temporary buffer each time, for breakpoint
shadow handling.  Thus large writes have quadratic runtime and can take
hours.

Note: On GNU/Linux targets GDB usually does not use
inf_ptrace_xfer_partial for large memory transfers, but attempts a single
read/write from/to /proc/<pid>/mem instead.  However, the kernel may
reject writes to /proc/<pid>/mem (such as kernels prior to 2.6.39), or
/proc may not be mounted.  In both cases GDB falls back to the ptrace
mechanism.

This patch fixes the performance issue by attempting to fulfill the whole
transfer request in inf_ptrace_xfer_partial, using a loop around the
ptrace call.

gdb/ChangeLog:

PR gdb/21220
* inf-ptrace.c (inf_ptrace_xfer_partial): In "case
TARGET_OBJECT_MEMORY", extract the logic for ptrace peek/poke...
(inf_ptrace_peek_poke): ...here.  New function.  Now also loop
over ptrace peek/poke until end of buffer or error.

7 years agoRISC-V: Define DWARF2_USE_FIXED_ADVANCE_PC.
Kuan-Lin Chen [Thu, 2 Mar 2017 06:54:32 +0000 (14:54 +0800)]
RISC-V: Define DWARF2_USE_FIXED_ADVANCE_PC.

gas/ChangeLog

2017-03-02  Kuan-Lin Chen  <rufus@andestech.com>

        * config/tc-riscv.h (HWARD2_USE_FIXED_ADVANCE_PC): New define.

7 years agoRISC-V: Fix DW_CFA_advance_loc relocation.
Kuan-Lin Chen [Fri, 10 Feb 2017 06:58:52 +0000 (14:58 +0800)]
RISC-V: Fix DW_CFA_advance_loc relocation.

gas/ChangeLog:

2017-03-02  Kuan-Lin Chen  <rufus@andestech.com>

        * config/tc-riscv.c (md_apply_fix): Set fx_frag and
        fx_next->fx_frag for CFA_advance_loc relocations.

7 years agoRISC-V: Fix the offset of CFA relocation.
Kuan-Lin Chen [Thu, 2 Feb 2017 07:27:18 +0000 (15:27 +0800)]
RISC-V: Fix the offset of CFA relocation.

gas/ChangeLog:

2017-03-02  Kuan-Lin Chen  <rufus@andestech.com>

        * config/tc-riscv.c (md_apply_fix): Compute the correct offsets
        for CFA relocations.

7 years agoRISC-V: Fix [dis]assembly of srai/srli
Andrew Waterman [Mon, 13 Mar 2017 19:46:33 +0000 (12:46 -0700)]
RISC-V: Fix [dis]assembly of srai/srli

These were simple copy/paste errors from the compressed left shift
pattern, which can't have a 0-register.

7 years agoUse addr_mask to check VMA and LMA
H.J. Lu [Tue, 14 Mar 2017 16:09:54 +0000 (09:09 -0700)]
Use addr_mask to check VMA and LMA

Since BFD64 may be used on 32-bit address, we need to apply addr_mask
to check VMA and LMA.

* ldlang.c (lang_check_section_addresses): Use addr_mask to
check VMA and LMA.

7 years agoMake length_of_subexp static
Simon Marchi [Tue, 14 Mar 2017 14:25:39 +0000 (10:25 -0400)]
Make length_of_subexp static

It isn't used anywhere else than the file it's defined in.

gdb/ChangeLog:

* parse.c (length_of_subexp): Make static.
* parser-defs.h (length_of_subexp): Remove.

7 years agoTry harder to find the correct symbol to associate with OPEN GNU BUILD notes.
Nick Clifton [Tue, 14 Mar 2017 12:57:09 +0000 (12:57 +0000)]
Try harder to find the correct symbol to associate with OPEN GNU BUILD notes.

* readelf.c (print_gnu_build_attribute_description): Move symbol
printing code to...
(print_symbol_for_build_attribute): New function.  ...here.
Add to find the best symbol to associate with an OPEN note.
Add code to cache the symbol table and string table, so that they
are not loaded every time a note is displayed.
* testsuite/binutils-all/note-2-32.s: Add a function symbol.
* testsuite/binutils-all/note-2-64.s: Likewise.
* testsuite/binutils-all/note-2-32.d: Update expected note output.
* testsuite/binutils-all/note-2-64.d: Likewise.

7 years agoAdd test name argument to get_valueof, get_integer_valueof and get_sizeof
Anton Kolesov [Mon, 6 Mar 2017 18:24:38 +0000 (21:24 +0300)]
Add test name argument to get_valueof, get_integer_valueof and get_sizeof

An optional parameter TEST has been added to get_hexadecimal_valueof in commit:

  https://sourceware.org/ml/gdb-patches/2016-06/msg00469.html

This patch adds a similar optional parameter to other related methods that
retrieve expression values: get_valueof, get_integer_valueof and get_sizeof.
Thus tests that evaluate same expression multiple times can provide custom
test names, ensuring that test names will be unique.

gdb/testsuite/ChangeLog:
2017-03-14  Anton Kolesov  <anton.kolesov@synopsys.com>

* lib/gdb.exp (get_valueof, get_integer_valueof, get_sizeof):
  Add optional 'test' parameter.

7 years agolinux-nat: Exploit /proc/<pid>/mem for writing
Andreas Arnez [Tue, 14 Mar 2017 10:14:49 +0000 (11:14 +0100)]
linux-nat: Exploit /proc/<pid>/mem for writing

So far linux_proc_xfer_partial refused to handle write requests.  This is
still based on the assumption that the Linux kernel does not support
writes to /proc/<pid>/mem.  That used to be true, but has changed with
Linux 2.6.39 released in May 2011.

This patch lifts this restriction and now exploits /proc/<pid>/mem for
writing to inferior memory as well, if possible.

gdb/ChangeLog:

* linux-nat.c (linux_proc_xfer_partial): Handle write operations
as well.

7 years agoRestore test-cp-name-parser build
Pedro Alves [Tue, 14 Mar 2017 00:11:09 +0000 (00:11 +0000)]
Restore test-cp-name-parser build

Commit c8b23b3f89fbb0 ("Add constructor and destructor to
demangle_parse_info") a while ago broke the "test-cp-name-parser"
build:

 $ make test-cp-name-parser
 [...]
 src/gdb/cp-name-parser.y: In function ‘int main(int, char**)’:
 src/gdb/cp-name-parser.y:2190:9: error: cannot convert ‘std::unique_ptr<demangle_parse_info>’ to ‘demangle_parse_info*’ in assignment
   result = cp_demangled_name_to_comp (str2, &errmsg);
  ^
 src/gdb/cp-name-parser.y:2199:38: error: ‘cp_demangled_name_parse_free’ was not declared in this scope
   cp_demangled_name_parse_free (result);
       ^
 src/gdb/cp-name-parser.y:2211:14: error: cannot convert ‘std::unique_ptr<demangle_parse_info>’ to ‘demangle_parse_info*’ in assignment
result = cp_demangled_name_to_comp (argv[arg], &errmsg);
       ^
 src/gdb/cp-name-parser.y:2219:43: error: ‘cp_demangled_name_parse_free’ was not declared in this scope
cp_demangled_name_parse_free (result);
    ^
 Makefile:2107: recipe for target 'test-cp-name-parser.o' failed
 make: *** [test-cp-name-parser.o] Error 1

This commit restores it.

gdb/ChangeLog:
2017-03-14  Pedro Alves  <palves@redhat.com>

* cp-name-parser.y (cp_demangled_name_to_comp): Update comment.
(main): Use std::unique_ptr.  Remove calls to
cp_demangled_name_parse_free.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 14 Mar 2017 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoalpha-bsd-nat: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Mon, 13 Mar 2017 22:51:40 +0000 (18:51 -0400)]
alpha-bsd-nat: Use ptid from regcache instead of inferior_ptid

gdb/ChangeLog:

* alpha-bsd-nat.c (alphabsd_fetch_inferior_registers,
alphabsd_store_inferior_registers): Use regcache->ptid instead
of inferior_ptid.

7 years agoaix-thread: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Mon, 13 Mar 2017 22:51:40 +0000 (18:51 -0400)]
aix-thread: Use ptid from regcache instead of inferior_ptid

gdb/ChangeLog:

* aix-thread.c (aix_thread_fetch_registers,
aix_thread_store_registers): Use regcache->ptid instead of
inferior_ptid.

7 years agoaarc64-linux-nat: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Mon, 13 Mar 2017 22:51:39 +0000 (18:51 -0400)]
aarc64-linux-nat: Use ptid from regcache instead of inferior_ptid

gdb/ChangeLog:

* aarch64-linux-nat.c (fetch_gregs_from_thread,
store_gregs_to_thread, fetch_fpregs_from_thread,
store_fpregs_to_thread): Use regcache->ptid instead of
inferior_ptid.

7 years agoamd64-linux-nat: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Mon, 13 Mar 2017 22:51:39 +0000 (18:51 -0400)]
amd64-linux-nat: Use ptid from regcache instead of inferior_ptid

gdb/ChangeLog:

* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers,
amd64_linux_fetch_inferior_registers): Use regcache->ptid
instead of inferior_ptid.

7 years agoAdd asserts in target_fetch/store_registers
Simon Marchi [Mon, 13 Mar 2017 22:51:38 +0000 (18:51 -0400)]
Add asserts in target_fetch/store_registers

We are currently assuming that regcache->ptid is equal to inferior_ptid
when we call target_fetch/store_registers.  These asserts just validate
that assumption.  Also, since the following patches will change target
code to use regcache->ptid instead of inferior_ptid, asserting that they
are the same should ensure that our changes don't have any unintended
consequences.

gdb/ChangeLog:

* target.c (target_fetch_registers, target_store_registers): Add
assert.

7 years agoIntroduce regcache_get_ptid
Simon Marchi [Mon, 13 Mar 2017 22:51:38 +0000 (18:51 -0400)]
Introduce regcache_get_ptid

This patch introduces the regcache_get_ptid function, which can be used
to retrieve the ptid a regcache is connected to.  It is used in
subsequent patches.

gdb/ChangeLog:

* regcache.h (regcache_get_ptid): New function.
* regcache.c (regcache_get_ptid): New function.

7 years agogdbserver: Use pattern rule for the remaining %-ipa.o objects
Simon Marchi [Mon, 13 Mar 2017 22:44:05 +0000 (18:44 -0400)]
gdbserver: Use pattern rule for the remaining %-ipa.o objects

gdb/gdbserver/ChangeLog:

* Makefile.in (%-ipa.o: %-ipa.c): New rule.
(ax-ipa.o: ax.c): Remove.
(linux-i386-ipa.o: linux-i386-ipa.c): Remove.
(linux-amd64-ipa.o: linux-amd64-ipa.c): Remove.
(linux-aarch64-ipa.o: linux-aarch64-ipa.c): Remove.
(linux-s390-ipa.o: linux-s390-ipa.c): Remove.
(linux-ppc-ipa.o: linux-ppc-ipa.c): Remove.

7 years agogdbserver: Use pattern rule for IPA objects from common/
Simon Marchi [Mon, 13 Mar 2017 22:44:04 +0000 (18:44 -0400)]
gdbserver: Use pattern rule for IPA objects from common/

gdb/gdbserver/ChangeLog:

* Makefile.in (%-ipa.o: ../common/%.c): New rule.
(print-utils-ipa.o: ../common/print-utils.c): Remove.
(rsp-low-ipa.o: ../common/rsp-low.c): Remove.
(errors-ipa.o: ../common/errors.c): Remove.
(format-ipa.o: ../common/format.c): Remove.
(common-utils-ipa.o: ../common/common-utils.c): Remove.

7 years agogdbserver: Use pattern rule for IPA objects from gdbserver/
Simon Marchi [Mon, 13 Mar 2017 22:44:04 +0000 (18:44 -0400)]
gdbserver: Use pattern rule for IPA objects from gdbserver/

gdb/gdbserver/ChangeLog:

* Makefile.in (%-ipa.o: %.c): New rule.
(tracepoint-ipa.o: tracepoint.c): Remove.
(utils-ipa.o: utils.c): Remove.
(remote-utils-ipa.o: remote-utils.c): Remove.
(regcache-ipa.o: regcache.c): Remove.
(i386-linux-ipa.o: i386-linux.c): Remove.
(i386-mmx-linux-ipa.o: i386-mmx-linux.c): Remove.
(i386-avx-linux-ipa.o: i386-avx-linux.c): Remove.
(i386-mpx-linux-ipa.o: i386-mpx-linux.c): Remove.
(i386-avx-mpx-linux-ipa.o: i386-avx-mpx-linux.c): Remove.
(i386-avx-avx512-linux-ipa.o: i386-avx-avx512-linux.c): Remove.
(i386-avx-mpx-avx512-pku-linux-ipa.o: i386-avx-mpx-avx512-pku-linux.c): Remove.
(amd64-linux-ipa.o: amd64-linux.c): Remove.
(amd64-avx-linux-ipa.o: amd64-avx-linux.c): Remove.
(amd64-mpx-linux-ipa.o: amd64-mpx-linux.c): Remove.
(amd64-avx-mpx-linux-ipa.o: amd64-avx-mpx-linux.c): Remove.
(amd64-avx-avx512-linux-ipa.o: amd64-avx-avx512-linux.c): Remove.
(amd64-avx-mpx-avx512-pku-linux-ipa.o: amd64-avx-mpx-avx512-pku-linux.c): Remove.
(aarch64-ipa.o: aarch64.c): Remove.
(s390-linux32-ipa.o: s390-linux32.c): Remove.
(s390-linux32v1-ipa.o: s390-linux32v1.c): Remove.
(s390-linux32v2-ipa.o: s390-linux32v2.c): Remove.
(s390-linux64-ipa.o: s390-linux64.c): Remove.
(s390-linux64v1-ipa.o: s390-linux64v1.c): Remove.
(s390-linux64v2-ipa.o: s390-linux64v2.c): Remove.
(s390-te-linux64-ipa.o: s390-te-linux64.c): Remove.
(s390-vx-linux64-ipa.o: s390-vx-linux64.c): Remove.
(s390-tevx-linux64-ipa.o: s390-tevx-linux64.c): Remove.
(s390x-linux64-ipa.o: s390x-linux64.c): Remove.
(s390x-linux64v1-ipa.o: s390x-linux64v1.c): Remove.
(s390x-linux64v2-ipa.o: s390x-linux64v2.c): Remove.
(s390x-te-linux64-ipa.o: s390x-te-linux64.c): Remove.
(s390x-vx-linux64-ipa.o: s390x-vx-linux64.c): Remove.
(s390x-tevx-linux64-ipa.o: s390x-tevx-linux64.c): Remove.
(powerpc-32l-ipa.o: powerpc-32l.c): Remove.
(powerpc-altivec32l-ipa.o: powerpc-altivec32l.c): Remove.
(powerpc-cell32l-ipa.o: powerpc-cell32l.c): Remove.
(powerpc-vsx32l-ipa.o: powerpc-vsx32l.c): Remove.
(powerpc-isa205-32l-ipa.o: powerpc-isa205-32l.c): Remove.
(powerpc-isa205-altivec32l-ipa.o: powerpc-isa205-altivec32l.c): Remove.
(powerpc-isa205-vsx32l-ipa.o: powerpc-isa205-vsx32l.c): Remove.
(powerpc-e500l-ipa.o: powerpc-e500l.c): Remove.
(powerpc-64l-ipa.o: powerpc-64l.c): Remove.
(powerpc-altivec64l-ipa.o: powerpc-altivec64l.c): Remove.
(powerpc-cell64l-ipa.o: powerpc-cell64l.c): Remove.
(powerpc-vsx64l-ipa.o: powerpc-vsx64l.c): Remove.
(powerpc-isa205-64l-ipa.o: powerpc-isa205-64l.c): Remove.
(powerpc-isa205-altivec64l-ipa.o: powerpc-isa205-altivec64l.c): Remove.
(powerpc-isa205-vsx64l-ipa.o: powerpc-isa205-vsx64l.c): Remove.
(tdesc-ipa.o: tdesc.c): Remove.
(x32-linux-ipa.o: x32-linux.c): Remove.
(x32-avx-linux-ipa.o: x32-avx-linux.c): Remove.
(x32-avx512-linux-ipa.o: x32-avx512-linux.c): Remove.

7 years agogdbserver: Use pattern rule for objects from arch/
Simon Marchi [Mon, 13 Mar 2017 22:44:03 +0000 (18:44 -0400)]
gdbserver: Use pattern rule for objects from arch/

gdb/gdbserver/ChangeLog:

* Makefile.in (%.o: ../arch/%.c): New rule.
(arm.o: ../arch/arm.c): Remove.
(arm-linux.o: ../arch/arm-linux.c): Remove.
(arm-get-next-pcs.o: ../arch/arm-get-next-pcs.c): Remove.
(aarch64-insn.o: ../arch/aarch64-insn.c): Remove.

7 years agogdbserver: Use pattern rule for objects from nat/
Simon Marchi [Mon, 13 Mar 2017 22:44:03 +0000 (18:44 -0400)]
gdbserver: Use pattern rule for objects from nat/

gdb/gdbserver/ChangeLog:

* Makefile.in (%.o: ../nat/%.c): New rule.
(x86-dregs.o: ../nat/x86-dregs.c): Remove.
(amd64-linux-siginfo.o: ../nat/amd64-linux-siginfo.c): Remove.
(linux-btrace.o: ../nat/linux-btrace.c): Remove.
(linux-osdata.o: ../nat/linux-osdata.c): Remove.
(linux-procfs.o: ../nat/linux-procfs.c): Remove.
(linux-ptrace.o: ../nat/linux-ptrace.c): Remove.
(linux-waitpid.o: ../nat/linux-waitpid.c): Remove.
(mips-linux-watch.o: ../nat/mips-linux-watch.c): Remove.
(ppc-linux.o: ../nat/ppc-linux.c): Remove.
(linux-personality.o: ../nat/linux-personality.c): Remove.
(aarch64-linux-hw-point.o: ../nat/aarch64-linux-hw-point.c): Remove.
(aarch64-linux.o: ../nat/aarch64-linux.c): Remove.
(x86-linux.o: ../nat/x86-linux.c): Remove.
(x86-linux-dregs.o: ../nat/x86-linux-dregs.c): Remove.
(linux-namespaces.o: ../nat/linux-namespaces.c): Remove.

7 years agogdbserver: Use pattern rule for objects from common/
Simon Marchi [Mon, 13 Mar 2017 22:44:02 +0000 (18:44 -0400)]
gdbserver: Use pattern rule for objects from common/

gdb/gdbserver/ChangeLog:

* Makefile.in (%.o: ../common/%.c): New rule.
(signals.o: ../common/signals.c): Remove.
(print-utils.o: ../common/print-utils.c): Remove.
(rsp-low.o: ../common/rsp-low.c): Remove.
(common-utils.o: ../common/common-utils.c): Remove.
(posix-strerror.o: ../common/posix-strerror.c): Remove.
(mingw-strerror.o: ../common/mingw-strerror.c): Remove.
(vec.o: ../common/vec.c): Remove.
(gdb_vecs.o: ../common/gdb_vecs.c): Remove.
(xml-utils.o: ../common/xml-utils.c): Remove.
(ptid.o: ../common/ptid.c): Remove.
(buffer.o: ../common/buffer.c): Remove.
(format.o: ../common/format.c): Remove.
(filestuff.o: ../common/filestuff.c): Remove.
(agent.o: ../common/agent.c): Remove.
(errors.o: ../common/errors.c): Remove.
(environ.o: ../common/environ.c): Remove.
(common-debug.o: ../common/common-debug.c): Remove.
(cleanups.o: ../common/cleanups.c): Remove.
(common-exceptions.o: ../common/common-exceptions.c): Remove.
(fileio.o: ../common/fileio.c): Remove.
(common-regcache.o: ../common/common-regcache.c): Remove.
(signals-state-save-restore.o: ../common/signals-state-save-restore.c): Remove.
(new-op.o: ../common/new-op.c): Remove.
(btrace-common.o: ../common/btrace-common.c): Remove.

7 years agogdbserver: Use pattern rule for objects from target/
Simon Marchi [Mon, 13 Mar 2017 22:44:02 +0000 (18:44 -0400)]
gdbserver: Use pattern rule for objects from target/

gdb/gdbserver/ChangeLog:

* Makefile.in (%.o: ../target/%.c): New rule.
(waitstatus.o: ../target/waitstatus.c): Remove.

7 years agogdbserver: Use pattern rule for regformats source file generation
Simon Marchi [Mon, 13 Mar 2017 22:44:01 +0000 (18:44 -0400)]
gdbserver: Use pattern rule for regformats source file generation

gdb/gdbserver/ChangeLog:

* Makefile.in
(%.c: ../regformats/%.dat,
(%.c: ../regformats/arm/%.dat,
(%.c: ../regformats/i386/%.dat,
(%.c: ../regformats/rs6000/%.dat): New rules.
(aarch64.c): Remove.
(reg-arm.c): Remove.
(arm-with-iwmmxt.c): Remove.
(arm-with-vfpv2.c): Remove.
(arm-with-vfpv3.c): Remove.
(arm-with-neon.c): Remove.
(reg-bfin.c): Remove.
(reg-cris.c): Remove.
(reg-crisv32.c): Remove.
(i386.c): Remove.
(i386-linux.c): Remove.
(i386-avx.c): Remove.
(i386-avx-linux.c): Remove.
(i386-avx-avx512.c): Remove.
(i386-avx-avx512-linux.c): Remove.
(i386-mpx.c): Remove.
(i386-mpx-linux.c): Remove.
(i386-avx-mpx-avx512-pku.c): Remove.
(i386-avx-mpx-avx512-pku-linux.c): Remove.
(i386-avx-mpx.c): Remove.
(i386-avx-mpx-linux.c): Remove.
(i386-mmx.c): Remove.
(i386-mmx-linux.c): Remove.
(reg-ia64.c): Remove.
(reg-m32r.c): Remove.
(reg-m68k.c): Remove.
(reg-cf.c): Remove.
(mips-linux.c): Remove.
(mips-dsp-linux.c): Remove.
(mips64-linux.c): Remove.
(mips64-dsp-linux.c): Remove.
(nios2-linux.c): Remove.
(powerpc-32.c): Remove.
(powerpc-32l.c): Remove.
(powerpc-altivec32l.c): Remove.
(powerpc-cell32l.c): Remove.
(powerpc-vsx32l.c): Remove.
(powerpc-isa205-32l.c): Remove.
(powerpc-isa205-altivec32l.c): Remove.
(powerpc-isa205-vsx32l.c): Remove.
(powerpc-e500l.c): Remove.
(powerpc-64l.c): Remove.
(powerpc-altivec64l.c): Remove.
(powerpc-cell64l.c): Remove.
(powerpc-vsx64l.c): Remove.
(powerpc-isa205-64l.c): Remove.
(powerpc-isa205-altivec64l.c): Remove.
(powerpc-isa205-vsx64l.c): Remove.
(s390-linux32.c): Remove.
(s390-linux32v1.c): Remove.
(s390-linux32v2.c): Remove.
(s390-linux64.c): Remove.
(s390-linux64v1.c): Remove.
(s390-linux64v2.c): Remove.
(s390-te-linux64.c): Remove.
(s390-vx-linux64.c): Remove.
(s390-tevx-linux64.c): Remove.
(s390x-linux64.c): Remove.
(s390x-linux64v1.c): Remove.
(s390x-linux64v2.c): Remove.
(s390x-te-linux64.c): Remove.
(s390x-vx-linux64.c): Remove.
(s390x-tevx-linux64.c): Remove.
(tic6x-c64xp-linux.c): Remove.
(tic6x-c64x-linux.c): Remove.
(tic6x-c62x-linux.c): Remove.
(reg-sh.c): Remove.
(reg-sparc64.c): Remove.
(reg-spu.c): Remove.
(amd64.c): Remove.
(amd64-linux.c): Remove.
(amd64-avx.c): Remove.
(amd64-avx-linux.c): Remove.
(amd64-avx-avx512.c): Remove.
(amd64-avx-avx512-linux.c): Remove.
(amd64-mpx.c): Remove.
(amd64-mpx-linux.c): Remove.
(amd64-avx-mpx-avx512-pku.c): Remove.
(amd64-avx-mpx-avx512-pku-linux.c): Remove.
(amd64-avx-mpx.c): Remove.
(amd64-avx-mpx-linux.c): Remove.
(x32.c): Remove.
(x32-linux.c): Remove.
(x32-avx.c): Remove.
(x32-avx-linux.c): Remove.
(x32-avx-avx512.c): Remove.
(x32-avx-avx512-linux.c): Remove.
(reg-xtensa.c): Remove.
(reg-tilegx.c): Remove.
(reg-tilegx32.c): Remove.

7 years agotestsuite: Disable backslash_in_multi_line_command_test for old DejaGnus
Simon Marchi [Mon, 13 Mar 2017 22:02:08 +0000 (18:02 -0400)]
testsuite: Disable backslash_in_multi_line_command_test for old DejaGnus

I noticed that backslash_in_multi_line_command_test in
gdb.base/commands.exp failed on our RHEL6 servers.  I traced it to the
old version of DejaGnu (1.4.4).  I have found that instead of receiving
the expected:

  "print \\\nargc\n"

gdb received:

  "print  argc\n"

thus breaking the test and its purpose.  Versionof DejaGnu < 1.5 mess
up sending "\\\n", it somehow gets replaced with a space.  I found that
the following commit in DejaGnu fixed the issue:

http://git.savannah.gnu.org/cgit/dejagnu.git/commit/lib/remote.exp?id=3f39294f5cd6802858838d3bcc0ccce847ae17f2

Even though the commit is almost 10 years old, the following release of
DejaGnu was only in 2013, which is why we still have systems with the
old code.

If the DejaGnu version is < 1.5, we just skip the test.

gdb/testsuite/ChangeLog:

* gdb.base/commands.exp (backslash_in_multi_line_command_test):
Skip for versions of DejaGnu < 1.5.

7 years agotestsuite: Introduce dejagnu_version
Simon Marchi [Mon, 13 Mar 2017 22:02:07 +0000 (18:02 -0400)]
testsuite: Introduce dejagnu_version

The next patch will require checking the DejaGnu version.  There is
already a test that does this,
gdb.threads/attach-many-short-lived-threads.exp.  This patch introduces
a new procedure, dejagnu_version, and makes that test use it.

The version number is "right-padded" with zeroes, to make sure that we
always return a triplet (major, minor, patch).

The procedure does not consider the DejaGnu versions from git.  For
example, if you used DejaGnu from its current master branch, the version
would be "1.6.1-git", meaning that 1.6.1 will be the next release.  I
figured we'll cross that bridge when (and if) we get there.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (dejagnu_version): New proc.
* gdb.threads/attach-many-short-lived-threads.exp (bad_dejagnu):
Use dejagnu_version.

7 years agoMerge libiberty: Initialize d_printing in all cplus_demangle_fill_* functions.
mark [Mon, 13 Mar 2017 18:26:47 +0000 (18:26 +0000)]
Merge libiberty: Initialize d_printing in all cplus_demangle_fill_* functions.

While integrating the d_printing recursion guard change into gdb I
noticed we forgot to initialize the demangle_component d_printing
field in cplus_demangle_fill_{name,extended_operator,ctor,dtor}.
As is done in cplus_demangle_fill_{component,builtin_type,operator}.
It happened to work because in gcc all demangle_components were
allocated through d_make_empty. But gdb has its own allocation
mechanism (as might other users).

libiberty/ChangeLog:

       * cp-demangle.c (cplus_demangle_fill_name): Initialize
       demangle_component d_printing.
       (cplus_demangle_fill_extended_operator): Likewise.
       (cplus_demangle_fill_ctor): Likewise.
       (cplus_demangle_fill_dtor): Likewise.

gdb/ChangeLog:

       * cp-name-parser.y (make_empty): Initialize d_printing to zero.

7 years agoSync libiberty sources with GCC.
Nick Clifton [Mon, 13 Mar 2017 17:49:32 +0000 (17:49 +0000)]
Sync libiberty sources with GCC.

PR demangler/70909
PR demangler/67264
* cp-demangle.c: Fix endless recursion. Pass
struct demangle_component as non const.
(d_make_empty): Initialize variable.
(d_print_comp_inner): Limit recursion.
(d_print_comp): Decrement variable.
* cp-demint.c (cplus_demangle_fill_component): Initialize
variable.
(cplus_demangle_fill_builtin_type): Likewise.
(cplus_demangle_fill_operator): Likewise.
* testsuite/demangle-expected: Add tests.

7 years agoobjdump -dS: warn if source is more recent than object
Alan Modra [Mon, 13 Mar 2017 10:26:25 +0000 (20:56 +1030)]
objdump -dS: warn if source is more recent than object

If the source file is more recent than the object file, line number
information in the object may no longer match the source.  So print a
warning message.

* objdump.c (update_source_path): Add abfd param.  Add struct
stat vars.  Pass to try_print_file_open.  Warn if source is more
recent than object.
(try_print_file_open, slurp_file): Add struct stat param to
return fstat.
(show_line): Call update_source_path with bfd.

7 years agoRename R_AARCH64_TLSDESC_LD64_LO12_NC to R_AARCH64_TLSDESC_LD64_LO12 and R_AARCH64_TL...
Nick Clifton [Mon, 13 Mar 2017 09:58:04 +0000 (09:58 +0000)]
Rename R_AARCH64_TLSDESC_LD64_LO12_NC to R_AARCH64_TLSDESC_LD64_LO12 and R_AARCH64_TLSDESC_ADD_LO12_NC to R_AARCH64_TLSDESC_ADD_LO12.

PR binutils/21202
include * elf/aarch64.h (R_AARCH64_TLSDESC_LD64_LO12_NC): Rename to
R_AARCH64_TLSDESC_LD64_LO12.
(R_AARCH64_TLSDESC_ADD_LO12_NC): Rename to
R_AARCH64_TLSDESC_ADD_LO12_NC.

bfd * reloc.c (BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC): Rename to
BFD_RELOC_AARCH64_TLSDESC_LD64_LO12.
(BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC): Rename to
BFD_RELOC_AARCH64_TLSDESC_ADD_LO12.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* elfnn-aarch64.c (IS_AARCH64_TLS_RELAX_RELOC): Update reloc
names.
(IS_AARCH64_TLSDESC_RELOC): Likewise.
(elfNN_aarch64_howto_table): Likewise.
(aarch64_tls_transition_without_check): Likewise.
(aarch64_reloc_got_type): Likewise.
(elfNN_aarch64_final_link_relocate): Likewise.
(elfNN_aarch64_tls_relax): Likewise.
(elfNN_aarch64_relocate_section): Likewise.
(elfNN_aarch64_gc_sweep_hook): Likewise.
(elfNN_aarch64_check_relocs): Likewise.
* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
(_bfd_aarch64_elf_resolve_relocation): Likewise.

gas * config/tc-aarch64.c (reloc_table): Rename
BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC to
BFD_RELOC_AARCH64_TLSDESC_LD64_LO12.  Rname
BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC to
BFD_RELOC_AARCH64_TLSDESC_ADD_LO12.
(md_apply_fix): Likewise.
(aarch64_force_relocation): Likewise.
* testsuite/gas/aarch64/tls.d: Update regexp.

ld * testsuite/ld-aarch64/ifunc-5r-local.d: Update regexp.

7 years agold: add an error in case of address space overflow.
Tristan Gingold [Fri, 10 Mar 2017 14:16:19 +0000 (15:16 +0100)]
ld: add an error in case of address space overflow.

ld/
* ldlang.c (lang_check_section_addresses): Check for address space
overflow.
* testsuite/ld-checks/checks.exp (overflow_check): New procedure
* testsuite/ld-checks/over.s: New test source.
* testsuite/ld-checks/over.d: New test.
* testsuite/ld-checks/over2.s: New test source.
* testsuite/ld-checks/over2.d: New test.

7 years agoPowerPC: incorrect library search order
Alexey Neyman [Mon, 13 Mar 2017 03:49:46 +0000 (20:49 -0700)]
PowerPC: incorrect library search order

First, need to match against just the CPU name, not the whole triplet.
Otherwise, the test picks up "*le-*" pattern from x86_64-apple-darwin
triplet.

Second, it should be testing for $target, not $host. Host may be
little endian by default, and the sysroot directory layout shouldn't
depend on whether it is built on LE or BE machine.

* emulparams/elf32ppccommon.sh (LIBPATH_SUFFIX): Set from target
cpu, not host.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 13 Mar 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 12 Mar 2017 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAdd sysroot for ld -rpath search
Alan Modra [Sat, 11 Mar 2017 13:07:02 +0000 (23:37 +1030)]
Add sysroot for ld -rpath search

* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Add
sysroot for -rpath search.

7 years agoRewrite add_sysroot
Alan Modra [Sat, 11 Mar 2017 12:27:29 +0000 (22:57 +1030)]
Rewrite add_sysroot

Relative paths shouldn't have the sysroot prefix added.  The patch
also makes some attempt at supporting DOS paths, and tidies code using
the new add_sysroot.

* emultempl/elf32.em (gld${EMULATION_NAME}_add_sysroot): Rewrite.
Only prefix absolute paths with sysroot.  Handle DOS paths.
(gld${EMULATION_NAME}_check_ld_elf_hints): Constify variable.
(gld${EMULATION_NAME}_check_ld_so_conf): Likewise.
(gld${EMULATION_NAME}_after_open): Short-circuit NULL path
searches.  Rename variable.  Simplify get_runpath search.

7 years agoRemove bogus ATTRIBUTE_UNUSED
Alan Modra [Sat, 11 Mar 2017 10:26:51 +0000 (20:56 +1030)]
Remove bogus ATTRIBUTE_UNUSED

* elf32-ppc.c: Remove ATTRIBUTE_UNUSED throughout when function
parameter is in fact used.  Whitespace fixes.
* elf64-ppc.c: Likewise.

7 years agoDon't use -rdynamic in ld test
Alan Modra [Sat, 11 Mar 2017 00:34:02 +0000 (11:04 +1030)]
Don't use -rdynamic in ld test

This gcc option isn't well supported, so use the actual linker option
we want to test.

* testsuite/ld-elf/shared.exp: Use -Wl,-export-dynamic rather
than -rdynamic.

7 years agoDon't run new orphan tests on i860 and i960
Alan Modra [Sat, 11 Mar 2017 00:21:56 +0000 (10:51 +1030)]
Don't run new orphan tests on i860 and i960

These targets use the generic ELF support, so don't handle orphans
well.  The patch also updates the orphan doco to reflect this fact,
and deletes some ELF details that don't really add anything.

* ld.texinfo (Orphan Sections): Mention that not all targets
handle orphans well.  Delete ELF details.
* testsuite/ld-elf/orphan-9.d: Don't run for i860 and i960.
* testsuite/ld-elf/orphan-10.d: Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 11 Mar 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoc++/8218: Destructors w/arguments.
Keith Seitz [Fri, 10 Mar 2017 18:32:09 +0000 (10:32 -0800)]
c++/8218: Destructors w/arguments.

For a long time now, c++/8218 has noted that GDB is printing argument types
for destructors:

(gdb) ptype A
type = class A {
  public:
    ~A(int);
}

This happens because cp_type_print_method_args doesn't ignore artificial
arguments.  [It ignores the first `this' pointer because it simply skips
the first argument for any non-static function.]

This patch fixes this:

(gdb) ptype  A
type = class A {
  public:
    ~A();
}

I've adjusted gdb.cp/templates.exp to account for this and added a new
passing regexp.

gdb/ChangeLog

PR c++/8218
* c-typeprint.c (cp_type_print_method_args): Skip artificial arguments.

gdb/testsuite/ChangeLog

PR c++/8128
* gdb.cp/templates.exp (test_ptype_of_templates): Remove argument
type from destructor regexps.
Add a branch which actually passes the test.
Adjust "ptype t5i" test names.

7 years agoMake objdump's --wide command line option affect its output of DWARF debug information.
Chia-Hao Lo [Fri, 10 Mar 2017 16:29:58 +0000 (16:29 +0000)]
Make objdump's --wide command line option affect its output of DWARF debug information.

PR binutils/21235
* objdump.c (main): Set do_wide with --wide.

7 years agoDocument that the .2byte and .4byte directives warn about overlarge values.
Nick Clifton [Fri, 10 Mar 2017 15:42:04 +0000 (15:42 +0000)]
Document that the .2byte and .4byte directives warn about overlarge values.

* doc/as.texinfo (2byte): Tidy up wording.  Add note that
overlarge values will produce a warning message and be trunacted.
(4byte): Likewise.

7 years agoAdd basic recognition of new EM_ ELF machine numbers.
Nick Clifton [Fri, 10 Mar 2017 10:50:34 +0000 (10:50 +0000)]
Add basic recognition of new EM_ ELF machine numbers.

include * elf/common.h (EM_LANAI): New machine number.
(EM_BPF): Likewise.
(EM_WEBASSEMBLY): Likewise.
Move low value, deprecated, numbers to their numerical
equivalents.

binutils * readelf.c (get_machine_name): Rearrange switch table in order of
increasing machine number.  Add missing entries.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 10 Mar 2017 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agold: Track changes to default region LMA even for empty sections
Andrew Burgess [Tue, 17 Jan 2017 19:13:29 +0000 (19:13 +0000)]
ld: Track changes to default region LMA even for empty sections

Given a linker script fragment like this:

   SECTIONS {
     . = 0x1000;
     .text   : AT(0x100) { *(.text)   }
     .data   : AT(0x200) { *(.data)   }
     .rodata : AT(0x300) { *(.rodata) }
   }

and an input file containing sections, '.text', '.data.1', and
'.rodata', then we'd expect the linker to place '.text' and '.rodata' in
the obvious way, and the '.data.1' orphan section would be located after
the '.data' section (assuming similar section properties).

Further, I believe that the expectation would be that the LMA for the
orphan '.data.1' section would start from 0x200 (as there is no '.data'
content).

However, right now, the LMA for '.data.1' would be 0x101, following on
from the '.text' section, this is because the change in LMA for the
'.data' section is not noticed by the linker, if there's no content in
the '.data' section.

What can be even more confusing to a user (though the cause is obvious
once you understand what's going on) is that adding some content to
'.data' will cause the orphan '.data.1' to switch to an LMA based off of
0x200.

This commit changes the behaviour so that an empty section that is in
the default lma region, and sets its lma, will adjust the lma of the
default region, this change will then be reflected in following sections
within the default lma memory region.

There's a new test to cover this issue that passes on a range of
targets, however, some targets generate additional sections, or have
stricter memory region size requirements that make it harder to come
up with a generic pass pattern, that still tests the required
features.  For now I've set the test to ignore these targets.

ld/ChangeLog:

* ldlang.c (lang_size_sections_1): Shortcut loop only after
tracking changes to the default regions LMA.
* testsuite/ld-elf/orphan-9.ld: Extend header comment.
* testsuite/ld-elf/orphan-10.d: New file.
* testsuite/ld-elf/orphan-10.s: New file.
* NEWS: Mention change in behaviour.

7 years agold: better handling of lma region for orphan sections
Andrew Burgess [Tue, 17 Jan 2017 19:12:54 +0000 (19:12 +0000)]
ld: better handling of lma region for orphan sections

When picking an lma_region for an orphan section we currently create a
new lang_output_section_statement_type and then populate this with the
orphan section.

The problem is that the lang_output_section_statement_type has a prev
pointer that links back to the previous output section.  For non-orphan
output sections, that are created in linker script order, the prev
pointer will point to the output section that appears previous in linker
script order, as you'd probably expect.

The problem is that orphan sections are placed after processing the
linker script, and so, in the case of an output section created for an
orphan input section, the prev pointer actually points to the last
output section created.

This causes some unexpected behaviour when the orphan section is not
placed after the last non-orphan section that was created.

For example, consider this linker script:

  MEMORY {
    TEXT   : ORIGIN = 0x200,  LENGTH = 0x10
    RODATA : ORIGIN = 0x400,  LENGTH = 0x10
  }

  SECTIONS {
    .text   :           {*(.text)    } AT>TEXT
    .data   : AT(0x300) { *(.data)   }
    .rodata :           { *(.rodata) } AT>RODATA
  }

If we are processing an orphan section '.data.1' and decide to place
this after '.data', then the output section created will have a prev
pointer that references the '.rodata' output section.  The result of
this is that '.data.1' will actually be assigned to the RODATA lma
region, which is probably not the expected behaviour.

The reason why '.data.1' is placed into the lma region of the '.rodata'
section is that lma region propagation is done at the time we create the
output section, based on the previous output section pointer, which is
really just a last-output-section-created pointer at that point in time,
though the prev point is fixed up later to reflect the true order of the
output sections.

The solution I propose in this commit is to move the propagation of lma
regions into a separate pass of the linker, rather than performing this
as part of the enter/exit of output sections during linker script
parsing.

During this later phase we have all of the output sections to hand, and
the prev/next points have been fixed up by this point to reflect the
actual placement ordering.

There's a new test to cover this issue that passes on a range of
targets, however, some targets generate additional sections, or have
stricter memory region size requirements that make it harder to come
up with a generic pass pattern, that still tests the required
features.  For now I've set the test to ignore these targets.

ld/ChangeLog:

* ldlang.c (lang_leave_output_section_statement): Move lma_region
logic to...
(lang_propagate_lma_regions): ...this new function.
(lang_process): Call new function.
* testsuite/ld-elf/orphan-9.d: New file.
* testsuite/ld-elf/orphan-9.ld: New file.
* testsuite/ld-elf/orphan-9.s: New file.
* NEWS: Mention change in behaviour.

7 years agold: Orphan section documentation
Andrew Burgess [Tue, 17 Jan 2017 18:08:17 +0000 (18:08 +0000)]
ld: Orphan section documentation

Make more explicit mention of the fact that orphan sections can cause a
new output section to be created.  Though this information is clearly
implied in the manual it might not be clear enough.

A user _might_ (incorrectly) think that orphan sections can only be
inserted into an existing output section.

ld/ChangeLog:

* ld.texinfo (Orphan Sections): Add more detail.

7 years agoX86: Add pseudo prefixes to control encoding
H.J. Lu [Thu, 9 Mar 2017 17:58:46 +0000 (09:58 -0800)]
X86: Add pseudo prefixes to control encoding

Many x86 instructions have more than one encodings.  Assembler picks
the default one, usually the shortest one.  Although the ".s", ".d8"
and ".d32" suffixes can be used to swap register operands or specify
displacement size, they aren't very flexible.  This patch adds pseudo
prefixes, {xxx}, to control instruction encoding.  The available
pseudo prefixes are {disp8}, {disp32}, {load}, {store}, {vex2}, {vex3}
and {evex}.  Pseudo prefixes are preferred over the ".s", ".d8" and
".d32" suffixes, which are deprecated.

gas/

* config/tc-i386.c (_i386_insn): Add dir_encoding and
vec_encoding.  Remove swap_operand and need_vrex.
(extra_symbol_chars): Add '}'.
(md_begin): Mark '}' with LEX_BEGIN_NAME.  Allow '}' in
mnemonic.
(build_vex_prefix): Don't use 2-byte VEX encoding with
{vex3}.  Check dir_encoding and load.
(parse_insn): Check pseudo prefixes.  Set dir_encoding.
(VEX_check_operands): Likewise.
(match_template): Check dir_encoding and load.
(parse_real_register): Set vec_encoding instead of need_vrex.
(parse_register): Likewise.
* doc/c-i386.texi: Document {disp8}, {disp32}, {load}, {store},
{vex2}, {vex3} and {evex}.  Remove ".s", ".d8" and ".d32"
* testsuite/gas/i386/i386.exp: Run pseudos and x86-64-pseudos.
* testsuite/gas/i386/pseudos.d: New file.
* testsuite/gas/i386/pseudos.s: Likewise.
* testsuite/gas/i386/x86-64-pseudos.d: Likewise.
* testsuite/gas/i386/x86-64-pseudos.s: Likewise.

opcodes/

* i386-gen.c (opcode_modifiers): Replace S with Load.
* i386-opc.h (S): Removed.
(Load): New.
(i386_opcode_modifier): Replace s with load.
* i386-opc.tbl: Add {disp8}, {disp32}, {swap}, {vex2}, {vex3}
and {evex}.  Replace S with Load.
* i386-tbl.h: Regenerated.

7 years agoFix compile time warnings about using possibly uninitialised variables in rs6000...
Sam Thursfield [Thu, 9 Mar 2017 15:58:39 +0000 (15:58 +0000)]
Fix compile time warnings about using possibly uninitialised variables in rs6000-core.c.

* rs6000-core.c (CORE_NEW): Simplify macro when
AIX_CORE_DUMPX_CORE and BFD64 are true to avoid compile warning.

7 years agoUse CpuCET on rdsspq
H.J. Lu [Thu, 9 Mar 2017 15:43:48 +0000 (07:43 -0800)]
Use CpuCET on rdsspq

* i386-opc.tbl: Use CpuCET on rdsspq.
* i386-tbl.h: Regenerated.

7 years agoUpdate -maltivec and -mvsx options to only enable their oldest instructions.
Peter Bergner [Thu, 9 Mar 2017 02:49:03 +0000 (20:49 -0600)]
Update -maltivec and -mvsx options to only enable their oldest instructions.

Currently, the -maltivec and -mvsx GAS options enable *all* of the altivec
and vsx instructions respecitively that have ever been added.  This is in
constract to GCC's -maltivec and -mvsx options, which only enable the oldest
(ie, first) set of altivec and vsx instructions.  This patch changes GAS to
mimic GCC's behaviour with respect to -maltivec and -mvsx and it solves a
problem with trying to assemble the lxvx instruction which is different
between POWER8 and POWER9.

opcodes/
* ppc-dis.c (ppc_opts) <altivec>: Do not use PPC_OPCODE_ALTIVEC2;
<vsx>: Do not use PPC_OPCODE_VSX3;

gas/
* testsuite/gas/ppc/altivec2.d (as): Use the -mpower8 option.
(objdump): Use the -Mpower8 option.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 9 Mar 2017 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAvoid unstable test message in gdb.base/step-over-exit.exp
Pedro Alves [Wed, 8 Mar 2017 22:05:36 +0000 (22:05 +0000)]
Avoid unstable test message in gdb.base/step-over-exit.exp

Currently diffing testrun results shows:

 -PASS: gdb.base/step-over-exit.exp: break *0x7ffff77e18c6 if main == 0
 +PASS: gdb.base/step-over-exit.exp: break *0x2aaaab0988c6 if main == 0

gdb/testsuite/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

* gdb.base/step-over-exit.exp: Add explicit test message.

7 years agoAdd support for the new 'lnia' extended mnemonic.
Peter Bergner [Wed, 8 Mar 2017 20:00:42 +0000 (14:00 -0600)]
Add support for the new 'lnia' extended mnemonic.

opcodes/
* ppc-opc.c (powerpc_opcodes) <lnia>: New extended mnemonic.

gas/
* testsuite/gas/ppc/power9.d <lnia> New test.
* testsuite/gas/ppc/power9.s: Likewise.

7 years agoFix PR18360 - internal error when using "interrupt -a"
Pedro Alves [Wed, 8 Mar 2017 18:54:34 +0000 (18:54 +0000)]
Fix PR18360 - internal error when using "interrupt -a"

If you do "interrupt -a" just while some thread is stepping over a
breakpoint, gdb trips on an internal error.

The test added by this patch manages to trigger this consistently by
spawning a few threads that are constantly tripping on a conditional
breakpoint whose condition always evaluates to false.  With current
gdb, you get:

~~~
 interrupt -a
 .../src/gdb/inline-frame.c:343: internal-error: void skip_inline_frames(ptid_t): Assertion `find_inline_frame_state (ptid) == NULL' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n) FAIL: gdb.threads/interrupt-while-step-over.exp: displaced-stepping=on: iter=0: interrupt -a (GDB internal error)
[...]
 .../src/gdb/inline-frame.c:343: internal-error: void skip_inline_frames(ptid_t): Assertion `find_inline_frame_state (ptid) == NULL' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n) FAIL: gdb.threads/interrupt-while-step-over.exp: displaced-stepping=off: iter=0: wait for stops (GDB internal error)
~~~

The assertion triggers because we're processing a stop for a thread
that had already stopped before and thus had already its inline-frame
state filled in.

Calling handle_inferior_event_1 directly within a
"thread_stop_requested" observer is something that I've wanted to get
rid of before, for being fragile.  Nowadays, infrun is aware of
threads with pending events, so we can use that instead, and let the
normal fetch_inferior_event -> handle_inferior_event code path handle
the forced stop.

The change to finish_step_over is necessary because sometimes a thread
that was told to PTRACE_SINGLESTEP reports back a SIGSTOP instead of a
SIGTRAP (i.e., we tell it to single-step, and then interrupt it quick
enough that on the kernel side the thread dequeues the SIGTOP before
ever having had a chance of executing the instruction to be stepped).
SIGSTOP gets translated to a GDB_SIGNAL_0.  And then finish_step_over
would miss calling clear_step_over_info, and thus miss restarting the
other threads (which in this case of threads with pending events,
means setting their "resumed" flag, so their pending events can be
consumed).

And now that we always restart threads in finish_step_over, we no
longer need to do that in handle_signal_stop.

Tested on x86_64 Fedora 23, native and gdbserver.

gdb/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

PR gdb/18360
* infrun.c (start_step_over, do_target_resume, resume)
(restart_threads): Assert we're not resuming a thread that is
meant to be stopped.
(infrun_thread_stop_requested_callback): Delete.
(infrun_thread_stop_requested): If the thread is internally
stopped, queue a pending stop event and clear the thread's
inline-frame state.
(handle_stop_requested): New function.
(handle_syscall_event, handle_inferior_event_1): Use
handle_stop_requested.
(handle_stop_requested): New function.
(handle_signal_stop): Set the thread's stop_signal here instead of
at caller.
(finish_step_over): Clear step over info unconditionally.
(handle_signal_stop): If the user had interrupted the event
thread, consider the stop a random signal.
(handle_signal_stop) <signal arrived while stepping over
breakpoint>: Don't restart threads here.
(stop_waiting): Don't clear step-over info here.

gdb/testsuite/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

PR gdb/18360
* gdb.threads/interrupt-while-step-over.c: New file.
* gdb.threads/interrupt-while-step-over.exp: New file.

7 years agogdb: Fix ATTRIBUTE_NONNULL usage
Pedro Alves [Wed, 8 Mar 2017 15:52:16 +0000 (15:52 +0000)]
gdb: Fix ATTRIBUTE_NONNULL usage

Should fix the build failure with Clang mentioned at
<https://sourceware.org/bugzilla/show_bug.cgi?id=21206#c2>:

 In file included from ../../binutils-gdb/gdb/dwarf2read.c:72:
 ../../binutils-gdb/gdb/common/gdb_unlinker.h:35:35: error: '__nonnull__' attribute is invalid for the implicit this argument
   unlinker (const char *filename) ATTRIBUTE_NONNULL (1)
   ^                  ~
 ../../binutils-gdb/gdb/../include/ansidecl.h:169:48: note: expanded from macro 'ATTRIBUTE_NONNULL'
 #  define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))

gdb/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

PR 21206
* common/gdb_unlinker.h (unlinker::unlinker): Attribute nonnull
goes to argument 2, not 1.

7 years agoProperly dump NT_GNU_PROPERTY_TYPE_0
H.J. Lu [Wed, 8 Mar 2017 15:44:04 +0000 (07:44 -0800)]
Properly dump NT_GNU_PROPERTY_TYPE_0

Property type and datasz are always 4 bytes for both 32-bit and 64-bit
objects.  Property values for GNU_PROPERTY_X86_ISA_1_USED and
GNU_PROPERTY_X86_ISA_1_NEEDED are 4 bytes for both i386 and x86-64
objects.  We should also check GNU_PROPERTY_LOPROC and
GNU_PROPERTY_LOUSER.

binutils/

PR binutils/21231
* readelf.c (decode_x86_isa): Change argument to unsigned int.
(print_gnu_property_note): Retrieve property type and datasz as
4-byte integer.  Consolidate property datasz check.  Check
GNU_PROPERTY_LOPROC and GNU_PROPERTY_LOUSER.
* testsuite/binutils-all/i386/pr21231a.d: New file.
* testsuite/binutils-all/i386/pr21231a.s: Likewise.
* testsuite/binutils-all/i386/pr21231b.d: Likewise.
* testsuite/binutils-all/i386/pr21231b.s: Likewise.
* testsuite/binutils-all/x86-64/pr21231a.d: Likewise.
* testsuite/binutils-all/x86-64/pr21231a.s: Likewise.
* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
* testsuite/binutils-all/x86-64/pr21231b.s: Likewise.

include/

PR binutils/21231
* elf/common.h (GNU_PROPERTY_LOPROC): New.
(GNU_PROPERTY_HIPROC): Likewise.
(GNU_PROPERTY_LOUSER): Likewise.
(GNU_PROPERTY_HIUSER): Likewise.

7 years agogdb.arch/amd64-entry-value-param*.exp: Make sure test messages are unique
Pedro Alves [Wed, 8 Mar 2017 14:05:41 +0000 (14:05 +0000)]
gdb.arch/amd64-entry-value-param*.exp: Make sure test messages are unique

gdb/testsuite/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

* gdb.arch/amd64-entry-value-param-dwarf5.exp: Use with_test_prefix.
* gdb.arch/amd64-entry-value-param.exp: Use with_test_prefix.

7 years ago"gdb.arch/i386-pkru.exp: probe PKRU support" shouldn't FAIL if not supported
Pedro Alves [Wed, 8 Mar 2017 13:09:45 +0000 (13:09 +0000)]
"gdb.arch/i386-pkru.exp: probe PKRU support" shouldn't FAIL if not supported

Currently I get:

 (gdb) print have_pkru()
 $1 = 0
 (gdb) FAIL: gdb.arch/i386-pkru.exp: probe PKRU support
 UNSUPPORTED: gdb.arch/i386-pkru.exp: processor does not support protection key feature.

Probing suceeded, so that should be a PASS -> UNSUPPORTED.

gdb/testsuite/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

* gdb.arch/i386-pkru.exp (probe PKRU support): Handle detecting
PKRU as not supported as a PASS.

7 years agogdb: Fix a few unstable test names
Pedro Alves [Wed, 8 Mar 2017 12:46:44 +0000 (12:46 +0000)]
gdb: Fix a few unstable test names

Avoid putting unstable path names in test messages, in order to avoid
spurious testrun result diffs like:

 [....]
 -PASS: gdb.base/break-fun-addr.exp: /home/pedro/gdb/test-build1/gdb/testsuite/outputs/gdb.base/break-fun-addr/break-fun-addr1: break *main
 +PASS: gdb.base/break-fun-addr.exp: /home/pedro/gdb/test-build2/gdb/testsuite/outputs/gdb.base/break-fun-addr/break-fun-addr1: break *main
 [....]

gdb/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

* gdb.base/break-fun-addr.exp: Use $testfile1/$testfile2 for test
prefix instead of $binfile1/$binfile2.
* gdb.btrace/gcore.exp: Use "core" instead of unstable path name
in test message.
* gdb.python/py-completion.exp: Use "load python file" as test
messages instead of unstable path names.

7 years agoFix PR 21218: GDB dumps core when escaping newline in multi-line command
Pedro Alves [Wed, 8 Mar 2017 11:41:35 +0000 (11:41 +0000)]
Fix PR 21218: GDB dumps core when escaping newline in multi-line command

With commit 3b12939dfc2399 ("Replace the sync_execution global with a
new enum prompt_state tristate"), GDB started aborting if you try
splitting an input line with a continuation char (backslash) while in
a multi-line command:

 (gdb) commands
 Type commands for breakpoint(s) 1, one per line.
 End with a line saying just "end".
 >print \

 (gdb) 1      # note "(gdb)" incorrectly printed here.
 >end

 readline: readline_callback_read_char() called with no handler!
 $

That abort is actually a symptom of an old problem introduced when
gdb_readline_wrapper was rewritten to use asynchronous readline, back
in 2007.  Note how the "(gdb)" prompt is printed above in the "(gdb)
1" line.  Clearly it shouldn't be there, but it already was before the
commit mentioned above.  Fixing that also fixes the readline abort
shown above.

The problem starts when command_line_input passes a NULL prompt to
gdb_readline_wrapper when it finds previous incomplete input due to a
backslash, trying to fetch more input without printing another ">"
secondary prompt.  That itself should not be a problem, because
passing NULL to gdb_readline_wrapper has the same meaning as passing a
pointer to empty string, since gdb_readline_wrapper exposes the same
interface as 'readline(char *)'.  However, gdb_readline_wrapper passes
the prompt argument directly to display_gdb_prompt, and for the
latter, a NULL prompt argument has a different meaning - it requests
printing the primary prompt.

Before commit 782a7b8ef9c096 (which rewrote gdb_readline_wrapper to
use asynchronous readline), GDB behaved like this:

 (gdb) commands
 [....]
 >print \
 1
 >end
 (gdb)

The above is what this commit restores GDB back to.

New test included.

gdb/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

PR cli/21218
* top.c (gdb_readline_wrapper): Avoid passing NULL to
display_gdb_prompt.
(command_line_input): Add comment.

gdb/testsuite/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>
    Jan Kratochvil  <jan.kratochvil@redhat.com>

PR cli/21218
* gdb.base/commands.exp (backslash_in_multi_line_command_test):
New proc.
(top level): Call it.

7 years ago[gdb, doc] Add missing escape character '@'
Jiong Wang [Wed, 8 Mar 2017 11:14:41 +0000 (11:14 +0000)]
[gdb, doc] Add missing escape character '@'

gdb/doc/
        * gdb.texinfo (Memory Protection Extensions): Add missing escape
character "@".

7 years agoFix PR tui/21216: TUI line breaks regression
Pedro Alves [Wed, 8 Mar 2017 00:14:59 +0000 (00:14 +0000)]
Fix PR tui/21216: TUI line breaks regression

Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") regressed the TUI's command window.
Newlines miss doing a "carriage return", resulting in output like:

~~~~~~~~~~~~~~~~~~
(gdb) helpList of classes of commands:

                                      aliases -- Aliases of other commands
                                                                          breakpoints -- Making program stop at certain points
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Before the commit mentioned above, the default ui_file->to_write
implementation had a hack that would defer into the ui_file->to_fputs
method.  The TUI's ui_file did not implement the to_write method, so
all writes would end up going to the ncurses window via tui_file_fputs
-> tui_puts.

After the commit above, the hack is gone, but the TUI's ui_file still
does not implement the ui_file::write method.  Since tui_file inherits
from stdio_file, writing to a tui_file ends up doing fwrite on the
FILE stream the TUI is "associated" with, via stdio_file::write,
instead of writing to the ncurses window.

The fix is to have tui_file override the "write" method.

New test included.

gdb/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

PR tui/21216
* tui/tui-file.c (tui_file::write): New.
* tui/tui-file.h (tui_file): Override "write".
* tui/tui-io.c (do_tui_putc, update_start_line): New functions,
factored out from ...
(tui_puts): ... here.
(tui_putc): Use them.
(tui_write): New function.
* tui/tui-io.h (tui_write): Declare.

gdb/testsuite/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

PR tui/21216
* gdb.tui/tui-nl-filtered-output.exp: New file.

7 years agoMove TUI completion tests to gdb.tui/completion.exp
Pedro Alves [Wed, 8 Mar 2017 00:14:58 +0000 (00:14 +0000)]
Move TUI completion tests to gdb.tui/completion.exp

gdb/testsuite/ChangeLog:
2017-03-08  Pedro Alves  <palves@redhat.com>

* gdb.base/completion.exp: Move TUI completion tests to ...
* gdb.tui/completion.exp: ... this new file.

7 years agoMove TUI testcases to new gdb/testsuite/gdb.tui/ directory
Pedro Alves [Wed, 8 Mar 2017 00:14:58 +0000 (00:14 +0000)]
Move TUI testcases to new gdb/testsuite/gdb.tui/ directory

Let's start putting TUI tests in their own dir.

gdb/testsuite/
2017-03-08  Pedro Alves  <palves@redhat.com>

* gdb.base/tui-disasm-long-lines.c,
gdb.base/tui-disasm-long-lines.exp, gdb.base/tui-layout.c,
gdb.base/tui-layout.exp: Move to ...
* gdb.tui/: ... this new directory.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 8 Mar 2017 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoShare gdb/environ.[ch] with gdbserver
Sergio Durigan Junior [Thu, 22 Dec 2016 14:20:00 +0000 (09:20 -0500)]
Share gdb/environ.[ch] with gdbserver

We will need access to the environment functions when we share
fork_inferior between GDB and gdbserver, therefore we simply make the
API on gdb/environ.[ch] available on common/.  No extra adjustments
are needed to make it compile on gdbserver.

gdb/ChangeLog:
2017-03-07  Sergio Durigan Junior  <sergiodj@redhat.com>

* Makefile.in (SFILES): Replace "environ.c" with
"common/environ.c".
(HFILES_NO_SRCDIR): Likewise, for "environ.h".
* environ.c: Include "common-defs.h" instead of "defs.h.  Moved
to...
* common/environ.c: ... here.
* environ.h: Moved to...
* common/environ.h: ... here.

gdb/gdbserver/ChangeLog:
2017-03-07  Sergio Durigan Junior  <sergiodj@redhat.com>

* Makefile.in (SFILES): Add "common/environ.c".
(OBJS): Add "common/environ.h".

7 years agoGDB: Fix some null pointer dereferences due to disassembler-options patch.
Peter Bergner [Tue, 7 Mar 2017 15:49:10 +0000 (09:49 -0600)]
GDB: Fix some null pointer dereferences due to disassembler-options patch.

gdb/
* gdbarch.sh (pstring_ptr): New static function.
(gdbarch_disassembler_options): Use it.
(gdbarch_verify_disassembler_options): Print valid_disassembler_options,
not valid_disassembler_option->name.
* gdbarch.c: Regenerate.

7 years agoRemove use of the no longer needed -mminimal-toc option.
Peter Bergner [Tue, 7 Mar 2017 15:39:13 +0000 (09:39 -0600)]
Remove use of the no longer needed -mminimal-toc option.

* config/powerpc/ppc64-linux.mh (MH_CFLAGS): Delete.

7 years agoFix "layout reg" crash
Pedro Alves [Tue, 7 Mar 2017 12:44:58 +0000 (12:44 +0000)]
Fix "layout reg" crash

Commit d7e747318f4d04 ("Eliminate make_cleanup_ui_file_delete / make
ui_file a class hierarchy") introduced a problem when using "layout
regs", that leads gdb to crash when issuing:

./gdb ./a.out -ex 'layout regs' -ex start

From the backtrace, it's caused by this 'delete' on tui_restore_gdbout():

 (gdb) bt
 #0  0x00007ffff6b962b2 in free () from /lib64/libc.so.6
 #1  0x000000000059fa47 in tui_restore_gdbout (ui=0x22997b0) at ../../gdb/tui/tui-regs.c:714
 #2  0x0000000000619996 in do_my_cleanups (pmy_chain=pmy_chain@entry=0x1e08320 <cleanup_chain>, old_chain=old_chain@entry=0x235b4b0) at ../../gdb/common/cleanups.c:154
 #3  0x0000000000619b1d in do_cleanups (old_chain=old_chain@entry=0x235b4b0) at ../../gdb/common/cleanups.c:176
 #4  0x000000000059fb0d in tui_register_format (frame=frame@entry=0x22564e0, regnum=regnum@entry=0) at ../../gdb/tui/tui-regs.c:747
 #5  0x000000000059ffeb in tui_get_register (data=0x2434d18, changedp=0x0, regnum=0, frame=0x22564e0) at ../../gdb/tui/tui-regs.c:768
 #6  tui_show_register_group (refresh_values_only=<optimized out>, frame=0x22564e0, group=0x1e09250 <general_group>) at ../../gdb/tui/tui-regs.c:287
 #7  tui_show_registers (group=0x1e09250 <general_group>) at ../../gdb/tui/tui-regs.c:156
 #8  0x00000000005a07cf in tui_check_register_values (frame=frame@entry=0x22564e0) at ../../gdb/tui/tui-regs.c:496
 #9  0x00000000005a3e65 in tui_check_data_values (frame=frame@entry=0x22564e0) at ../../gdb/tui/tui-windata.c:232
 #10 0x000000000059cf65 in tui_refresh_frame_and_register_information (registers_too_p=1) at ../../gdb/tui/tui-hooks.c:156
 #11 0x00000000006d5c05 in generic_observer_notify (args=0x7fffffffdbe0, subject=<optimized out>) at ../../gdb/observer.c:167
 #12 observer_notify_normal_stop (bs=<optimized out>, print_frame=print_frame@entry=1) at ./observer.inc:61
 #13 0x00000000006a6409 in normal_stop () at ../../gdb/infrun.c:8364
 #14 0x00000000006af8f5 in fetch_inferior_event (client_data=<optimized out>) at ../../gdb/infrun.c:3990
 #15 0x000000000066f0fd in gdb_wait_for_event (block=block@entry=0) at ../../gdb/event-loop.c:859
 #16 0x000000000066f237 in gdb_do_one_event () at ../../gdb/event-loop.c:322
 #17 0x000000000066f386 in gdb_do_one_event () at ../../gdb/event-loop.c:353
 #18 0x00000000007411bc in wait_sync_command_done () at ../../gdb/top.c:570
 #19 0x0000000000741426 in maybe_wait_sync_command_done (was_sync=0) at ../../gdb/top.c:587
 #20 execute_command (p=<optimized out>, p@entry=0x7fffffffe43a "start", from_tty=from_tty@entry=1) at ../../gdb/top.c:676
 #21 0x00000000006c2048 in catch_command_errors (command=0x741200 <execute_command(char*, int)>, arg=0x7fffffffe43a "start", from_tty=1) at ../../gdb/main.c:376
 #22 0x00000000006c2b60 in captured_main_1 (context=0x7fffffffde70) at ../../gdb/main.c:1119
 #23 captured_main (data=0x7fffffffde70) at ../../gdb/main.c:1140
 #24 gdb_main (args=args@entry=0x7fffffffdf90) at ../../gdb/main.c:1158
 #25 0x0000000000408cf5 in main (argc=<optimized out>, argv=<optimized out>) at ../../gdb/gdb.c:32
 (gdb) f 1
 #1  0x000000000059fa47 in tui_restore_gdbout (ui=0x22997b0) at ../../gdb/tui/tui-regs.c:714
 714   delete gdb_stdout;

The problem is simply that the commit mentioned above made the ui_file
that gdb_stdout is temporarily set to be a stack-allocated
string_file, while before it used to be a heap-allocated ui_file.  The
fix is simply to remove the now-incorrect delete.

New test included, which exercises enabling all TUI layouts, with and
without execution.  (This particular crash only triggers with
execution.)

gdb/ChangeLog:
2017-03-07  Pedro Alves  <palves@redhat.com>

* tui/tui-regs.c (tui_restore_gdbout): Don't delete gdb_stdout.

gdb/testsuite/ChangeLog:
2017-03-07  Pedro Alves  <palves@redhat.com>

* gdb.base/tui-layout.c: New file.
* gdb.base/tui-layout.exp: New file.

7 years agoRename gdb.base/tui-layout.exp -> gdb.base/tui-disasm-long-lines.exp
Pedro Alves [Tue, 7 Mar 2017 12:21:00 +0000 (12:21 +0000)]
Rename gdb.base/tui-layout.exp -> gdb.base/tui-disasm-long-lines.exp

To better reflect what the testcase is about, and to make room for a
different testcase.

gdb/testsuite/ChangeLog:
2017-03-07  Pedro Alves  <palves@redhat.com>

* gdb.base/tui-layout.c: Rename to ...
* gdb.base/tui-disasm-long-lines.c: ... this.
* gdb.base/tui-layout.exp: Rename to ...
* gdb.base/tui-disasm-long-lines.exp: ... this.

7 years agoAdd describing intro comment to gdb.base/tui-layout.exp
Pedro Alves [Tue, 7 Mar 2017 12:11:45 +0000 (12:11 +0000)]
Add describing intro comment to gdb.base/tui-layout.exp

gdb/testsuite/ChangeLog:
2017-03-07  Pedro Alves  <palves@redhat.com>

* gdb.base/tui-layout.exp: Add intro comment and fix typo.

7 years agoFix whitespace/typos in gdb/ChangeLog and gdb/testsuite/ChangeLog
Pedro Alves [Tue, 7 Mar 2017 13:51:33 +0000 (13:51 +0000)]
Fix whitespace/typos in gdb/ChangeLog and gdb/testsuite/ChangeLog

7 years agoamd64-mpx: initialize BND register before performing inferior calls.
Walfred Tedeschi [Tue, 7 Mar 2017 12:53:41 +0000 (13:53 +0100)]
amd64-mpx: initialize BND register before performing inferior calls.

This patch initializes the BND registers before executing the inferior
call.  BND registers can be in arbitrary values at the moment of the
inferior call.  In case the function being called uses as part of the
parameters BND register, e.g. when passing a pointer as parameter, the
current value of the register will be used.  This can cause boundary
violations that are not due to a real bug or even desired by the user.
In this sense the best to be done is set the BND registers to allow
access to the whole memory, i.e. initialized state, before pushing the
inferior call.

2017-03-07  Walfred Tedeschi <walfred.tedeschi@intel.com>

gdb/ChangeLog:

* i387-tdep.h (i387_reset_bnd_regs): Add function definition.
* i387-tdep.c (i387_reset_bnd_regs): Add function implementation.
* i386-tdep.c (i386_push_dummy_call): Call i387_reset_bnd_regs.
* amd64-tdep (amd64_push_dummy_call): Call i387_reset_bnd_regs.

gdb/testsuite/ChangeLog:

* i386-mpx-call.c: New file.
* i386-mpx-call.exp: New file.

gdb/doc/ChangeLog:

* Memory Protection Extensions: Add information about inferior
calls.

7 years agoCorrect @section placement for makeinfo 4.13
Alan Modra [Tue, 7 Mar 2017 09:09:32 +0000 (19:39 +1030)]
Correct @section placement for makeinfo 4.13

* doc/as.texinfo (2byte, 4byte, 8byte): Correct @section placement.

7 years agoDocument .Nbyte assembler directives
Alan Modra [Tue, 7 Mar 2017 06:16:36 +0000 (16:46 +1030)]
Document .Nbyte assembler directives

* doc/as.texinfo (2byte, 4byte, 8byte): Document.
* doc/c-arm.texi (2byte, 4byte, 8byte): Omit if ELF.

7 years agoFix ld uninitialized read of script ASSERT data structure
Alan Modra [Tue, 7 Mar 2017 01:50:00 +0000 (12:20 +1030)]
Fix ld uninitialized read of script ASSERT data structure

lang_assignment_statement serves both assignments and asserts.

* ldlang.c (open_input_bfds): Check that lang_assignment_statement
is not an assert before referencing defsym.

7 years agoPowerPC64 abort due to dynamic relocs on hidden undefweak
Alan Modra [Tue, 7 Mar 2017 00:34:19 +0000 (11:04 +1030)]
PowerPC64 abort due to dynamic relocs on hidden undefweak

ppc64_elf_relocate_section lacked a check which meant that it emitted
dynamic relocs against a hidden undefweak symbol for which no dynamic
relocs had been allocated.

PR 21224
PR 20519
* elf64-ppc.c (ppc64_elf_relocate_section): Add missing
dyn_relocs check.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 7 Mar 2017 00:00:39 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAdd support for Intel CET instructions
H.J. Lu [Mon, 6 Mar 2017 23:26:37 +0000 (15:26 -0800)]
Add support for Intel CET instructions

Support Intel Control-flow Enforcement Technology (CET) instructions:

https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf

gas/

* config/tc-i386.c (cpu_arch): Add .cet.
* doc/c-i386.texi: Document cet.
* testsuite/gas/i386/cet-intel.d: New file.
* testsuite/gas/i386/cet.d: Likewise.
* testsuite/gas/i386/cet.s: Likewise.
* testsuite/gas/i386/x86-64-cet-intel.d: Likewise.
* testsuite/gas/i386/x86-64-cet.d: Likewise.
* testsuite/gas/i386/x86-64-cet.s: Likewise.
* testsuite/gas/i386/i386.exp: Run Intel CET tests.

opcodes/

* i386-dis.c (REG_0F1E_MOD_3): New enum.
(MOD_0F1E_PREFIX_1): Likewise.
(MOD_0F38F5_PREFIX_2): Likewise.
(MOD_0F38F6_PREFIX_0): Likewise.
(RM_0F1E_MOD_3_REG_7): Likewise.
(PREFIX_MOD_0_0F01_REG_5): Likewise.
(PREFIX_MOD_3_0F01_REG_5_RM_1): Likewise.
(PREFIX_MOD_3_0F01_REG_5_RM_2): Likewise.
(PREFIX_0F1E): Likewise.
(PREFIX_MOD_0_0FAE_REG_5): Likewise.
(PREFIX_0F38F5): Likewise.
(dis386_twobyte): Use PREFIX_0F1E.
(reg_table): Add REG_0F1E_MOD_3.
(prefix_table): Add PREFIX_MOD_0_0F01_REG_5,
PREFIX_MOD_3_0F01_REG_5_RM_1, PREFIX_MOD_3_0F01_REG_5_RM_2,
PREFIX_0F1E, PREFIX_MOD_0_0FAE_REG_5 and PREFIX_0F38F5.  Update
PREFIX_0FAE_REG_6 and PREFIX_0F38F6.
(three_byte_table): Use PREFIX_0F38F5.
(mod_table): Use PREFIX_MOD_0_0F01_REG_5, PREFIX_MOD_0_0FAE_REG_5.
Add MOD_0F1E_PREFIX_1, MOD_0F38F5_PREFIX_2, MOD_0F38F6_PREFIX_0.
(rm_table): Add MOD_0F38F5_PREFIX_2, MOD_0F38F6_PREFIX_0,
RM_0F1E_MOD_3_REG_7.  Use PREFIX_MOD_3_0F01_REG_5_RM_1 and
PREFIX_MOD_3_0F01_REG_5_RM_2.
* i386-gen.c (cpu_flag_init): Add CPU_CET_FLAGS.
(cpu_flags): Add CpuCET.
* i386-opc.h (CpuCET): New enum.
(CpuUnused): Commented out.
(i386_cpu_flags): Add cpucet.
* i386-opc.tbl: Add Intel CET instructions.
* i386-init.h: Regenerated.
* i386-tbl.h: Likewise.

7 years agoUpdate x86-64-mpx-inval-2 test for COFF
H.J. Lu [Mon, 6 Mar 2017 23:00:52 +0000 (15:00 -0800)]
Update x86-64-mpx-inval-2 test for COFF

Assembler displays upper case hex numbers and we need to force a good
alignment to avoid matching NOPs at the end.

* testsuite/gas/i386/x86-64-mpx-inval-2.s: Force a good alignment.
* testsuite/gas/i386/x86-64-mpx-inval-2.l: Expect [0-9A-F]+.

7 years agoRemove const in xtensa-linux-nat.c:fetch_gregs
Simon Marchi [Mon, 6 Mar 2017 21:06:42 +0000 (16:06 -0500)]
Remove const in xtensa-linux-nat.c:fetch_gregs

Fixes:

/home/emaisin/src/binutils-gdb/gdb/xtensa-linux-nat.c: In function 'void fetch_gregs(regcache*, ptid_t, int)':
/home/emaisin/src/binutils-gdb/gdb/xtensa-linux-nat.c:178:23: error: uninitialized const 'regs' [-fpermissive]
   const gdb_gregset_t regs;
                       ^

gdb/ChangeLog:

* xtensa-linux-nat.c (fetch_gregs): Remove const.

7 years agoFix reading numeric values from GNU BUILD NOTEs.
Nick Clifton [Mon, 6 Mar 2017 17:21:04 +0000 (17:21 +0000)]
Fix reading numeric values from GNU BUILD NOTEs.

* readelf.c (print_gnu_build_attribute_name): Read byte values
from the name string as unsigned bytes.
(process_notes_at): Use memcpy to copy an unterminated name
string.

7 years agoDon't decode powerpc insns with invalid fields
Alan Modra [Mon, 6 Mar 2017 09:09:34 +0000 (19:39 +1030)]
Don't decode powerpc insns with invalid fields

Certain insns have restrictions on fields.  For example, the insn
mentioned in the PR, lqarx, must specify an even general purpose
register as its destination and that register cannot appear in
either of the base or index reg fields.  This holds even when the RA0
field is 0 (meaning a zero rather than r0).

PR 21124
* ppc-opc.c (extract_esync, extract_ls, extract_ral, extract_ram)
(extract_raq, extract_ras, extract_rbx): New functions.
(powerpc_operands): Use opposite corresponding insert function.
(Q_MASK): Define.
(powerpc_opcodes): Apply Q_MASK to all quad insns with even
register restriction.

7 years agodw2gencfi.c DWARF2_FDE_RELOC_SIZE
Alan Modra [Sun, 5 Mar 2017 12:55:16 +0000 (23:25 +1030)]
dw2gencfi.c DWARF2_FDE_RELOC_SIZE

Add asserts that reloc size matches encoding size, and tidy.

* dw2gencfi.c (encoding_size): Return unsigned int.
(emit_expr_encoded): Assert size matches reloc bitsize.
(output_fde): Use unsigned for offset_size and addr_size.  Set
addr_size earlier and use in place of constant 4 and uses of
DWARF2_FDE_RELOC_SIZE.  Assert it matches reloc bitsize.

7 years agogas/dw2gencfi.c formatting
Alan Modra [Sun, 5 Mar 2017 12:25:29 +0000 (22:55 +1030)]
gas/dw2gencfi.c formatting

* dw2gencfi.c: Wrap overlong lines.  Add parens for emacs
auto reformat.  Formatting and whitespace fixes.

7 years agobinutils: Fix warning on platforms that don't have asprintf
Sam Thursfield [Fri, 3 Mar 2017 14:14:35 +0000 (14:14 +0000)]
binutils: Fix warning on platforms that don't have asprintf

* configure.ac (AC_CHECK_DECLS): Add asprintf.
* config.in: Regenerate.
* configure: Regenerate.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 6 Mar 2017 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agogas: Emit name, comp_dir and producer strings in .debug_str.
Mark Wielaard [Sun, 5 Mar 2017 22:37:54 +0000 (23:37 +0100)]
gas: Emit name, comp_dir and producer strings in .debug_str.

Putting the name, comp_dir and producer strings in the .debug_str section
makes it possible to share them across CUs. This saves a small amount of
space (about ~20K on a glibc libc.so.6 build with debuginfo). And makes
it easier for tools like rpm debugedit to adjust the source paths when
generating separate debuginfo files.

gas/
       * dwarf2dbg.c (out_debug_abbrev): Use DW_FORM_strp instead of
       DW_FORM_string for DW_AT_name, DW_AT_comp_dir and DW_AT_producer.
       (out_debug_info): Accept symbols to name, comp_dir and producer
       in the .debug_str section and emit those offsets not full strings.
       (out_debug_str): New function that outputs the strings for name,
       comp_dir and producer in .debug_str and generates symbols to
       those strings.
       (out_debug_line): Create a .debug_str section if necessary and
       call out_debug_str before calling out_debug_info.
       * testsuite/gas/aarch64/dwarf.d: Add extra section symbol to
       expected output.

7 years agoAlign eh_frame FDEs according to their encoding
Alan Modra [Sun, 5 Mar 2017 04:19:54 +0000 (14:49 +1030)]
Align eh_frame FDEs according to their encoding

bfd/
* elf-bfd.h (struct eh_cie_fde): Add u.cie.per_encoding_aligned8.
* elf-eh-frame.c (size_of_output_cie_fde): Don't align here.
(next_cie_fde_offset): New function.
(_bfd_elf_parse_eh_frame): Set u.cie.per_encoding_aligned8.
(_bfd_elf_discard_section_eh_frame): Align zero terminator to
four bytes.  Align CIEs to four or eight bytes depending on
per_encoding_aligned8.  Align FDEs according to their encoding.
Pad last FDE to output section alignment.
(_bfd_elf_write_section_eh_frame): Adjust to suit.  Remove
assertion.
* elf64-ppc.c (glink_eh_frame_cie): Delete padding.
(ppc64_elf_size_stubs): Pad glink eh_frame as per elf-eh-frame.c.
(ppc64_elf_finish_dynamic_sections): Adjust to suit.
ld/
* testsuite/ld-elf/eh3.d: Adjust for eh_frame alignment change.
* testsuite/ld-elf/eh6.d: Likewise.
* testsuite/ld-alpha/tlsbin.dd: Likewise.
* testsuite/ld-alpha/tlsbin.td: Likewise.
* testsuite/ld-alpha/tlsbinr.dd: Likewise.
* testsuite/ld-alpha/tlspic.dd: Likewise.
* testsuite/ld-alpha/tlspic.rd: Likewise.
* testsuite/ld-alpha/tlspic.sd: Likewise.
* testsuite/ld-alpha/tlspic.td: Likewise.
* testsuite/ld-mips-elf/eh-frame1-n64.d: Likewise.
* testsuite/ld-mips-elf/eh-frame2-n64.d: Likewise.
* testsuite/ld-mips-elf/eh-frame3.d: Likewise.
* testsuite/ld-x86-64/pr20830a.d: Likewise.
* testsuite/ld-x86-64/pr21038a.d: Likewise.
* testsuite/ld-x86-64/pr21038b.d: Likewise.
* testsuite/ld-x86-64/pr21038c.d: Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 5 Mar 2017 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 4 Mar 2017 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFix umulh and smulh bugs. Fix bugs in last week's sumov.s testsuite.
Jim Wilson [Fri, 3 Mar 2017 21:10:45 +0000 (13:10 -0800)]
Fix umulh and smulh bugs.  Fix bugs in last week's sumov.s testsuite.

sim/aarch64/
* simulator.c (mul64hi): Shift carry left by 32.
(smulh): Change signum to negate.  If negate, invert result, and add
carry bit if low part of multiply result is zero.

sim/testsuite/sim/aarch64/
* sumov.s: Correct compare test values.
* sumulh.s: New.

7 years agoUse range-based for loop in remote_add_target_side_commands
Simon Marchi [Fri, 3 Mar 2017 17:58:24 +0000 (12:58 -0500)]
Use range-based for loop in remote_add_target_side_commands

gdb/ChangeLog:

* remote.c (remote_add_target_side_commands): Use range-based
for loop.