external/binutils.git
6 years agoFix syscall group completion
Simon Marchi [Wed, 6 Dec 2017 21:27:33 +0000 (16:27 -0500)]
Fix syscall group completion

The test gdb.base/catch-syscall.exp has been failing since commit

  3d415c26bad3a15eed00d2ddf85c4268df77a4cc
  Remove cleanups from break-catch-syscall.c

The reason is that we are putting into the group_ptr array a pointer to
the buffer of the local string object.  If the string is small enough to
fit in the internal string buffer (used for small string optimizations),
the pointer will point to the local object directly.  So even if we
std::move the string to the vector, the pointer in group_ptr will still
point to the local object.  When we reuse that object (technically a new
instance, but most likely the same memory) for the next syscall, we'll
overwrite the previous string.  The result is that we'll get less
results than expected, since there will be duplicates.

We'll also run into problems if we push the string to the vector, and
then record the c_str () pointer using the string object in the vector.
The vector might get reallocated, the string may move in memory, and our
pointer in group_ptr will point to stale memory.

Instead, we have to push all the strings first, then, when we know the
vector won't change anymore, build the group_ptr array.  This is what
this patch does.

gdb/ChangeLog:

* break-catch-syscall.c (catch_syscall_completer): Get pointers
to syscall group strings after building the string vector.

6 years agoObjcopy interleave fails if section address not multiple of interleave.
Jim Wilson [Wed, 6 Dec 2017 18:34:36 +0000 (10:34 -0800)]
Objcopy interleave fails if section address not multiple of interleave.

PR 22465
binutils/
* objcopy.c (copy_section): New local extra.  If isection->lma not
exactly divisible by interleave, then bias from.  Also adjust
osection->lma if necessary.

ld/
* testsuite/ld-elf/interleave-0.d, testsuite/ld-elf/interleave-4.d,
* testsuite/ld-elf/interleave.ld, testsuite/ld-elf/interleave.s: New.

6 years agoremote: Make qXfer packets respect corresponding "set remote foo-packet"
Pedro Alves [Wed, 6 Dec 2017 11:28:47 +0000 (11:28 +0000)]
remote: Make qXfer packets respect corresponding "set remote foo-packet"

I've noticed that "set remote target-features-packet off" before
connecting has no effect -- GDB still fetches a target description
anyway.

The problem is that while most "set remote foo-packet" commands were
fixed by:

  From 4082afcc3d1af9d8063d1c8e02deb34a8b97a489 Mon Sep 17 00:00:00 2001
  From: Pedro Alves <palves@redhat.com>
  Date: Fri, 25 Apr 2014 18:07:02 +0100
  Subject: [PATCH] Fix several "set remote foo-packet on/off" commands.
  <https://sourceware.org/ml/gdb-patches/2014-04/msg00006.html>

the "qXfer" packets where missed.  This commit fixes that.

I've changed remote_search_memory too for consistency (seems like
those are the last direct references to packet->support), though the
difference is not observable because the qSearch:memory packet is auto
probed.  Note gdb.base/find-unmapped.exp already exercises explicit
"set remote search-memory-packet off".

gdb/ChangeLog:
2017-12-06  Pedro Alves  <palves@redhat.com>

* remote.c (remote_query_supported): Don't send "xmlRegisters=" if
"qXfer:features:read"" is disabled.
(remote_write_qxfer, remote_read_qxfer, remote_search_memory):
Check packet_config_support instead of packet->support directly.

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

* gdb.arch/i386-avx.exp: If testing with a RSP target, check
force-disabling XML descriptions.
--

 gdb/remote.c                        |   16 +++++++++-------
 gdb/testsuite/gdb.arch/i386-avx.exp |   25 +++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 7 deletions(-)

6 years agoTell the linker testsuite that lm32-rtems toolchains do not support the generation...
Nick Clifton [Wed, 6 Dec 2017 10:04:51 +0000 (10:04 +0000)]
Tell the linker testsuite that lm32-rtems toolchains do not support the generation of shared libraries.

* testsuite/lib/ld-lib.exp (check_shared_lib_support): Return
false for lm32-rtems targets.

6 years agoPR22552, readelf heap buffer overflow in load_debug_section
Alan Modra [Wed, 6 Dec 2017 07:02:48 +0000 (17:32 +1030)]
PR22552, readelf heap buffer overflow in load_debug_section

PR 22552
* readelf.c (process_file_header): Don't assume XINDEX case
value for e_shstrndx is within bounds.
(load_debug_section): Sanity test e_shstrndx before attempting
to read .shstrtab.  Wrap long lines.

6 years agoBFD whitespace fixes
Alan Modra [Tue, 5 Dec 2017 22:56:00 +0000 (09:26 +1030)]
BFD whitespace fixes

Binutils is supposed to use tabs.  In my git config I have
whitespace = indent-with-non-tab,space-before-tab,trailing-space
and I got annoyed enough seeing red in "git diff" output to fix
the problems.

* doc/header.sed: Trim trailing space when splitting lines.
* aix386-core.c, * aout-adobe.c, * aout-arm.c, * aout-cris.c,
* aout-ns32k.c, * aout-target.h, * aout-tic30.c, * aoutf1.h, * aoutx.h,
* arc-got.h, * arc-plt.def, * arc-plt.h, * archive.c, * archive64.c,
* archures.c, * armnetbsd.c, * bfd-in.h, * bfd.c, * bfdio.c, * binary.c,
* bout.c, * cache.c, * cisco-core.c, * coff-alpha.c, * coff-apollo.c,
* coff-arm.c, * coff-h8300.c, * coff-i386.c, * coff-i860.c,
* coff-i960.c, * coff-m68k.c, * coff-m88k.c, * coff-mcore.c,
* coff-mips.c, * coff-ppc.c, * coff-rs6000.c, * coff-sh.c,
* coff-stgo32.c, * coff-tic4x.c, * coff-tic54x.c, * coff-tic80.c,
* coff-we32k.c, * coff-x86_64.c, * coff-z80.c, * coff-z8k.c,
* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
* coffswap.h, * compress.c, * corefile.c, * cpu-alpha.c, * cpu-arm.c,
* cpu-avr.c, * cpu-bfin.c, * cpu-cr16.c, * cpu-cr16c.c, * cpu-crx.c,
* cpu-d10v.c, * cpu-frv.c, * cpu-ft32.c, * cpu-i370.c, * cpu-i960.c,
* cpu-ia64-opc.c, * cpu-ip2k.c, * cpu-lm32.c, * cpu-m32r.c,
* cpu-mcore.c, * cpu-microblaze.c, * cpu-mips.c, * cpu-moxie.c,
* cpu-mt.c, * cpu-nios2.c, * cpu-ns32k.c, * cpu-or1k.c, * cpu-powerpc.c,
* cpu-pru.c, * cpu-sh.c, * cpu-spu.c, * cpu-v850.c, * cpu-v850_rh850.c,
* cpu-xgate.c, * cpu-z80.c, * dwarf1.c, * dwarf2.c, * ecoff.c,
* ecofflink.c, * ecoffswap.h, * elf-bfd.h, * elf-eh-frame.c,
* elf-hppa.h, * elf-m10200.c, * elf-m10300.c, * elf-s390-common.c,
* elf-strtab.c, * elf-vxworks.c, * elf.c, * elf32-am33lin.c,
* elf32-arc.c, * elf32-arm.c, * elf32-avr.c, * elf32-avr.h,
* elf32-bfin.c, * elf32-cr16.c, * elf32-cr16c.c, * elf32-cris.c,
* elf32-crx.c, * elf32-d10v.c, * elf32-d30v.c, * elf32-dlx.c,
* elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c, * elf32-ft32.c,
* elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c, * elf32-i860.c,
* elf32-i960.c, * elf32-ip2k.c, * elf32-lm32.c, * elf32-m32c.c,
* elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c, * elf32-m68hc1x.c,
* elf32-m68hc1x.h, * elf32-m68k.c, * elf32-m88k.c, * elf32-mcore.c,
* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c, * elf32-mips.c,
* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
* elf32-nds32.h, * elf32-nios2.c, * elf32-or1k.c, * elf32-pj.c,
* elf32-ppc.c, * elf32-ppc.h, * elf32-pru.c, * elf32-rl78.c,
* elf32-rx.c, * elf32-s390.c, * elf32-score.c, * elf32-score.h,
* elf32-score7.c, * elf32-sh-symbian.c, * elf32-sh.c, * elf32-sh64.c,
* elf32-sparc.c, * elf32-spu.c, * elf32-tic6x.c, * elf32-tilegx.c,
* elf32-tilegx.h, * elf32-tilepro.c, * elf32-tilepro.h, * elf32-v850.c,
* elf32-vax.c, * elf32-wasm32.c, * elf32-xc16x.c, * elf32-xgate.c,
* elf32-xgate.h, * elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
* elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mips.c, * elf64-mmix.c,
* elf64-ppc.c, * elf64-s390.c, * elf64-sh64.c, * elf64-sparc.c,
* elf64-tilegx.c, * elf64-tilegx.h, * elf64-x86-64.c, * elfcore.h,
* elflink.c, * elfn32-mips.c, * elfnn-aarch64.c, * elfnn-ia64.c,
* elfnn-riscv.c, * elfxx-aarch64.c, * elfxx-aarch64.h, * elfxx-ia64.c,
* elfxx-ia64.h, * elfxx-mips.c, * elfxx-riscv.c, * elfxx-sparc.c,
* elfxx-tilegx.c, * elfxx-x86.c, * elfxx-x86.h, * freebsd.h, * hash.c,
* host-aout.c, * hp300hpux.c, * hppabsd-core.c, * hpux-core.c,
* i386aout.c, * i386linux.c, * i386lynx.c, * i386mach3.c, * i386msdos.c,
* i386netbsd.c, * ieee.c, * ihex.c, * irix-core.c, * libaout.h,
* libbfd-in.h, * libbfd.c, * libcoff-in.h, * libnlm.h, * libpei.h,
* libxcoff.h, * linker.c, * lynx-core.c, * m68k4knetbsd.c,
* m68klinux.c, * m68knetbsd.c, * m88kmach3.c, * mach-o-aarch64.c,
* mach-o-arm.c, * mach-o-i386.c, * mach-o-target.c, * mach-o-x86-64.c,
* mach-o.c, * mach-o.h, * merge.c, * mipsbsd.c, * mmo.c, * netbsd.h,
* netbsd-core.c, * newsos3.c, * nlm-target.h, * nlm32-ppc.c,
* nlm32-sparc.c, * nlmcode.h, * ns32k.h, * ns32knetbsd.c, * oasys.c,
* opncls.c, * pc532-mach.c, * pdp11.c, * pe-arm.c, * pe-i386.c,
* pe-mcore.c, * pe-mips.c, * pe-x86_64.c, * peXXigen.c, * pef.c,
* pef.h, * pei-arm.c, * pei-i386.c, * pei-mcore.c, * pei-x86_64.c,
* peicode.h, * plugin.c, * ppcboot.c, * ptrace-core.c, * reloc.c,
* riscix.c, * rs6000-core.c, * section.c, * som.c, * som.h,
* sparclinux.c, * sparcnetbsd.c, * srec.c, * stabs.c, * sunos.c,
* syms.c, * targets.c, * tekhex.c, * trad-core.c, * vax1knetbsd.c,
* vaxnetbsd.c, * verilog.c, * versados.c, * vms-alpha.c, * vms-lib.c,
* vms-misc.c, * wasm-module.c, * wasm-module.h, * xcofflink.c,
* xsym.c, * xsym.h: Whitespace fixes.
* bfd-in2.h, * libbfd.h, * libcoff.h: Regenerate.

6 years agoFix Common symbol override test fails
Alan Modra [Wed, 6 Dec 2017 07:01:15 +0000 (17:31 +1030)]
Fix Common symbol override test fails

Fixes fails on SH and NDS32 introduced by dyn_reloc tidy.

* elf32-lm32.c (lm32_elf_check_relocs): Skip non-ALLOC sections.
* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
* elf32-nds32.c (nds32_elf_check_relocs): Likewise.
* elf32-or1k.c (or1k_elf_check_relocs): Likewise.
* elf32-sh.c (sh_elf_check_relocs): Likewise.

6 years agoEnable shared lib tests for frv, lm32, m32r, microblaze, nds32 and or1k
Alan Modra [Tue, 5 Dec 2017 22:34:48 +0000 (09:04 +1030)]
Enable shared lib tests for frv, lm32, m32r, microblaze, nds32 and or1k

These claim to support shared libs when configuring for <target>-linux
(in contrast to <target>-elf which doesn't support shared libs).

* testsuite/lib/ld-lib.exp (check_shared_lib_support): Return true
for frv, lm32, m32r, microblaze, nds32 and or1k linux targets.

6 years agodyn_relocs tidy
Alan Modra [Mon, 4 Dec 2017 23:33:03 +0000 (10:03 +1030)]
dyn_relocs tidy

Many targets define their own dyn_relocs struct when they could use
struct elf_dyn_relocs.  This patch tidies that, and uses
readonly_dynrelocs in a few more places.

The SH adjust_dynamic_symbol had some really weird code dating back to
2002 that looked over dynamic relocations for any in SEC_HAS_CONTENTS
or SEC_READONLY sections, rather than just the usual SEC_READONLY
sections.  So basically any dynamic relocation.  What's more, the SH
relocate_section has no support for emitting dynamic relocations in
non-PIC.  In other words, SH has no support for avoiding copy relocs
in non-PIC.  I've made that more obvious by using "if (0 && ..)" in
asjust_dynamic_symbol.

Unfortunately, LM32, M32R, NDS32, and OR1K copied the bogus SH
adjust_dynamic_symbol code.  So none of those targets would have
avoided copy relocs.  LM32, M32R, NDS32 get the "if (0)" treatment
too.  (LM32 is even more broken in that non_got_ref is never set.)

OR1K relocate_section looks like it might support dynamic relocs in
non-PIC, so I've enabled the copy reloc avoidance code for that
target.

* elf32-hppa.c (struct elf32_hppa_dyn_reloc_entry): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(elf32_hppa_adjust_dynamic_symbol): Comment tidy.
* elf32-lm32.c (struct elf_lm32_dyn_relocs): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(lm32_elf_adjust_dynamic_symbol): Use readonly_dynrelocs, but disable.
Disable -z no-copyreloc too.
* elf32-m32r.c (struct elf_m32r_dyn_relocs): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(m32r_elf_adjust_dynamic_symbol): Use readonly_dynrelocs, but disable.
Disable -z no-copyreloc too.
* elf32-metag.c (struct elf_metag_dyn_reloc_entry): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(elf_metag_adjust_dynamic_symbol): Use readonly_dynrelocs.
* elf32-microblaze.c (struct elf32_mb_dyn_relocs): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(readonly_dynrelocs): New function.
(microblaze_elf_adjust_dynamic_symbol): Use it.
* elf32-nds32.c (struct elf_nds32_dyn_relocs): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(nds32_elf_adjust_dynamic_symbol): Use readonly_dynrelocs, but disable.
Disable -z no-copyreloc too.
* elf32-nios2.c (struct elf32_nios2_dyn_relocs): Delete.  Use
struct elf_dyn_relocs throughout file instead.
* elf32-or1k.c (struct elf_or1k_dyn_relocs): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(or1k_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
* elf32-sh.c (struct elf_sh_dyn_relocs): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(sh_elf_adjust_dynamic_symbol): Use readonly_dynrelocs, but disable.
Disable -z no-copyreloc too.
* elf32-tilepro.c (struct tilepro_elf_dyn_relocs): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(tilepro_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
* elfnn-riscv.c (struct riscv_elf_dyn_relocs): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(riscv_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
* elfxx-sparc.c (struct _bfd_sparc_elf_dyn_relocs): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(_bfd_sparc_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
* elfxx-tilegx.c (struct tilegx_elf_dyn_relocs): Delete.  Use
struct elf_dyn_relocs throughout file instead.
(tilegx_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Use readonly_dynrelocs.
* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Use readonly_dynrelocs.

6 years agoComment tidy
Alan Modra [Mon, 4 Dec 2017 23:35:19 +0000 (10:05 +1030)]
Comment tidy

Past tense is wrong for a comment before some action.

* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Comment tidy.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol): Likewise.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 6 Dec 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoReally fix riscv shared library __global_pointer$ problem.
Jim Wilson [Tue, 5 Dec 2017 22:42:12 +0000 (14:42 -0800)]
Really fix riscv shared library __global_pointer$ problem.

ld/
* emulparams/elf32lriscv-defs.sh (SDATA_START_SYMBOLS): Remove HIDDEN.
Don't define __global_pointer$ when CREATE_SHLIB.
* testsuite/ld-riscv-elf/gp-hidden-64.rd,
* testsuite/ld-riscv-elf/gp-hidden-lib.rd,
* testsuite/ld-riscv-elf/gp-hidden-lib.s,
* testsuite/ld-riscv-elf/gp-hidden-ver-64.rd,
* testsuite/ld-riscv-elf/gp-hidden-ver.rd,
* testsuite/ld-riscv-elf/gp-hidden-ver.s,
* testsuite/ld-riscv-elf/gp-hidden-ver.ver,
* testsuite/ld-riscv-elf/gp-hidden.rd,
* testsuite/ld-riscv-elf/gp-hidden.s,
* testsuite/ld-riscv-elf/gp-hidden.sd: Delete.
* testsuite/ld-riscv-elf/gp-test-lib.sd,
* testsuite/ld-riscv-elf/gp-test.s,
* testsuite/ld-riscv-elf/gp-test.sd: New.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Rewrite gp tests.

6 years agoAddress review comments for the previous series
Simon Marchi [Tue, 5 Dec 2017 21:39:35 +0000 (16:39 -0500)]
Address review comments for the previous series

I failed at git and missed adding/lost changes on the wrong branch, the
result being that I didn't incorporate fixes resulting from Yao's review
comments.  This patch fixes that.

There are two places where we should use the unique pointer typedef, and
ChangeLog entries missing.

gdb/ChangeLog:

* target-descriptions.c (struct tdesc_feature) <registers>: Use
tdesc_reg_up typedef.
(struct target_desc) <features>: Use tdesc_feature_up typedef.

6 years agoSplit tdesc_type into multiple classes
Simon Marchi [Tue, 5 Dec 2017 21:30:28 +0000 (16:30 -0500)]
Split tdesc_type into multiple classes

This patch makes tdesc_type an abstract base class and creates three
subclasses:

- tdesc_type_builtin, for builtin types
- tdesc_type_vector, for vector types
- tdesc_type_with_fields, for struct, union, flag and enum types

This allows getting rid of the union in tdesc_type and to not allow the
std::vector separately.  I tried to go further and create separate
classes for struct, union, flag and enum, but it proved too difficult.
One problem is that from the point of the of the target description
code, the types tdesc_type_* are opaque (only forward-declared).
Therefore, it doesn't know about inheritance relationship between those
classes.  This makes it impossible to make functions that accept a
pointer to a base class and pass a pointer to a derived class, for
example.  I think this patch here is a good compromise, and if somebody
wants to improve things further, the door is open.

A make_gdb_type virtual pure method is added to tdesc_type, which
replaces the current tdesc_gdb_type function.  Calling this method on a
tdesc_type returns the corresponding built gdb type.

gdb/ChangeLog:

* target-descriptions.c (struct tdesc_type): Use default
destructor.
<u>: Remove.
<accept>: Remove.
(struct tdesc_type_builtin): New.
(struct tdesc_type_vector): New.
(struct tdesc_type_with_fields): New.
(tdesc_predefined_types): Change type to tdesc_type_builtin[].
(tdesc_gdb_type): Remove.
(tdesc_register_type): Adjust.
(tdesc_create_vector): Create tdesc_type_vector.
(tdesc_create_struct): Create tdesc_type_with_fields.
(tdesc_set_struct_size): Change parameter type.
(tdesc_create_union): Create tdesc_type_with_fields.
(tdesc_create_flags): Likewise.
(tdesc_create_enum): Likewise.
(tdesc_add_field): Change parameter type.
(tdesc_add_typed_bitfield): Likewise.
(tdesc_add_bitfield): Likewise.
(tdesc_add_flag): Likewise.
(tdesc_add_enum_value): Likewise.
(print_c_tdesc) <visit>: Remove overload with tdesc_type
parameter, add overloads for tdesc_type_builtin,
tdesc_type_with_fields and tdesc_type_vector.
<m_printed_type>: Remove.
<m_printed_element_type, m_printed_type_with_fields>: Add.
* target-descriptions.h (tdesc_create_enum): Change return type.
(tdesc_add_typed_bitfield): Change parameter type.
(tdesc_add_enum_value): Change parameter type.
* xml-tdesc.c (struct tdesc_parsing_data) <current_type>: Change
type to tdesc_type_with_fields.
(tdesc_start_struct): Adjust.
(tdesc_start_flags): Adjust.
(tdesc_start_enum): Adjust.
(tdesc_start_field): Adjust.
* arch/tdesc.h (struct tdesc_type_builtin): Forward-declare.
(struct tdesc_type_vector): Forward-declare.
(struct tdesc_type_with_fields): Forward-declare.
(tdesc_create_struct): Change return type.
(tdesc_create_union): Likewise.
(tdesc_create_flags): Likewise.
(tdesc_add_field): Change parameter type.
(tdesc_set_struct_size): Likewise.
(tdesc_add_bitfield): Likewise.
(tdesc_add_flag): Likewise.
* features: Re-generate C files.

gdb/gdbserver/ChangeLog:

* tdesc.c (struct tdesc_type): Change return type.
(tdesc_add_flag): Change parameter type.
(tdesc_add_bitfield): Likewise.
(tdesc_add_field): Likewise.
(tdesc_set_struct_size): Likewise.

6 years agoMake tdesc_arch_data::arch_regs an std::vector
Simon Marchi [Tue, 5 Dec 2017 21:30:27 +0000 (16:30 -0500)]
Make tdesc_arch_data::arch_regs an std::vector

Make tdesc_arch_data::arch_regs be an std::vector of tdesc_arch_reg
objects.

On particularity is that the tdesc_arch_data linked to a gdbarch is
allocated on the gdbarch's obstack.  To be safe, I did not change it and
called placement-new on the area returned by OBSTACK_ZALLOC.

gdb/ChangeLog:

* target-descriptions.c (tdesc_arch_reg): Remove typedef.
(struct tdesc_arch_reg): Add constructor.
(DEF_VEC_O (tdesc_arch_reg)): Remove.
(struct tdesc_arch_data): Initialize fields.
<arch_regs>: Change type to std::vector.
(target_find_description): Adjust.
(tdesc_find_type): Adjust.
(tdesc_data_init): Call tdesc_arch_data constructor.
(tdesc_data_alloc): Allocate tdesc_arch_data with new.
(tdesc_data_cleanup): Free data with delete.
(tdesc_numbered_register): Adjust.
(tdesc_find_arch_register): Adjust.
(tdesc_use_registers): Adjust.

6 years agoMake tdesc_type::u::u::fields an std::vector
Simon Marchi [Tue, 5 Dec 2017 21:30:26 +0000 (16:30 -0500)]
Make tdesc_type::u::u::fields an std::vector

This patch makes the tdesc_type::u::u::fields an std::vector of
tdesc_type_field.   The difficulty here is that the vector is part of a
union.  Because of this, I made fields a pointer to a vector, and
instantiate/destroy the vector if the type is one that uses this member
of the union

The field tdesc_type_field::name is changed to an std::string at the
same time.

gdb/ChangeLog:

* target-descriptions.c (tdesc_type_field): Remove typedef.
(DEF_VEC_O (tdesc_type_field)): Remove.
(struct tdesc_type_field): Add constructor.
<name>: Change type to std::string.
(struct tdesc_type) <tdesc_type>: Instantiate vector if the type
kind uses it.
<~tdesc_type>: Destroy vector if the type kind uses it.
<u::u::fields>: Change type to std::vector.
(tdesc_gdb_type): Adjust.
(tdesc_add_field): Adjust.
(tdesc_add_typed_bitfield): Adjust.
(tdesc_add_field): Adjust.
(tdesc_add_enum_value): Adjust.
(class print_c_tdesc) <visit>: Adjust.

6 years agoMake tdesc_type::name an std::string
Simon Marchi [Tue, 5 Dec 2017 21:30:26 +0000 (16:30 -0500)]
Make tdesc_type::name an std::string

This patch makes tdesc_type::name an std::string.  This way, we don't
need to free it manually in ~tdesc_type.  I think the comment on top of
name is not correct, the string is always malloc'ed.

gdb/ChangeLog:

* target-descriptions.c (struct tdesc_type) <name>: Change type
to std::string.
<~tdesc_type>: Don't manually free name.
<operator==>: Adjust.
(tdesc_named_type): Adjust.
(tdesc_find_type): Adjust.
(tdesc_gdb_type): Adjust.
(class print_c_tdesc) <visit>: Adjust.

6 years agoMake tdesc_feature::types an std::vector
Simon Marchi [Tue, 5 Dec 2017 21:30:25 +0000 (16:30 -0500)]
Make tdesc_feature::types an std::vector

This patch makes tdesc_feature::types an std::vector of unique_ptr of
tdesc_type.  This way, we don't need to manually free the objects and
the vector in ~tdesc_feature.

gdb/ChangeLog:

* target-descriptions.c (tdesc_type_p): Remove typedef.
(DEF_VEC_P (tdesc_type_p)): Remove.
(struct tdesc_feature) <types>: Change type to std::vector.
<~tdesc_feature>: Replace with default implementation.
<accept>: Adjust.
(tdesc_named_type): Adjust.
(tdesc_create_vector): Adjust.
(tdesc_create_struct): Adjust.
(tdesc_create_union): Adjust.
(tdesc_create_flags): Adjust.
(tdesc_create_enum): Adjust.

6 years agoMake tdesc_reg string fields std::string
Simon Marchi [Tue, 5 Dec 2017 21:30:25 +0000 (16:30 -0500)]
Make tdesc_reg string fields std::string

Make the name, group and type fields of tdesc_reg std::strings.  This
way, we don't have to manually free them in ~tdesc_reg.

Doing so results in a small change in the generated tdesc.  Instead of
passing an empty string for the group parameter of tdesc_create_reg, the
two modified tdesc now pass NULL.  The end result should be the same.

gdb/ChangeLog:

* target-descriptions.c (struct tdesc_reg) <tdesc_reg>: Change
type of name_ parameter, adjust to std::string change.
<name, group, type>: Change type to std::string.
<~tdesc_reg>: Replace with default implementation.
<operator==>: Adjust.
(tdesc_find_register_early): Adjust.
(tdesc_register_name): Adjust.
(tdesc_register_type): Adjust.
(tdesc_register_in_reggroup_p): Adjust.
(class print_c_tdesc) <visit>: Adjust.
(class print_c_feature) <visit>: Adjust.

6 years agoMake tdesc_feature::registers an std::vector
Simon Marchi [Tue, 5 Dec 2017 21:30:24 +0000 (16:30 -0500)]
Make tdesc_feature::registers an std::vector

This patch makes tdesc_feature::registers an std::vector of unique_ptr
to tdesc_reg.  This way, we don't have to manually free the tdesc_reg
objects and the vector in the tdesc_feature destructor.

gdb/ChangeLog:

* target-descriptions.c (tdesc_reg_p): Remove typedef.
(DEF_VEC_P (tdesc_reg_p)): Remove.
(struct tdesc_feature) <registers>: Change type to std::vector.
<~tdesc_feature>: Don't manually free registers.
<accept>: Adjust.
<operator==>: Adjust.
(tdesc_has_registers): Adjust.
(tdesc_find_register_early): Adjust.
(tdesc_use_registers): Adjust.
(tdesc_create_reg): Adjust.

6 years agoMake tdesc_feature::name an std::string
Simon Marchi [Tue, 5 Dec 2017 21:30:24 +0000 (16:30 -0500)]
Make tdesc_feature::name an std::string

... so we don't have to manually free it in ~tdesc_feature.

gdb/ChangeLog:

* target-descriptions.c (tdesc_feature) <name>: Change type to
std::string.
<~tdesc_feature>: Don't manually free name.
<operator==>: Adjust.
(tdesc_find_feature): Adjust.
(tdesc_feature_name): Adjust.
(class print_c_tdesc) <visit_pre>: Adjust.
(class print_c_feature) <visit_pre>: Adjust.

6 years agoMake target_desc::features an std::vector
Simon Marchi [Tue, 5 Dec 2017 21:30:23 +0000 (16:30 -0500)]
Make target_desc::features an std::vector

This patch makes target_desc to be a vector of unique_ptr to
tdesc_feature objects.  This way, we don't have to manually free the
features and the vector in the target_desc destructor.

gdb/ChangeLog:

* target-descriptions.c (tdesc_feature_p): Remove typedef.
(DEF_VEC_P (tdesc_feature_p)): Remove.
(struct target_desc) <features>: Change type to std::vector.
<~target_desc>: Replace with default implementation.
<accept>: Adjust.
<operator==>: Adjust.
(tdesc_has_registers): Adjust.
(tdesc_find_feature): Adjust.
(tdesc_use_registers): Adjust.
(tdesc_create_feature): Adjust.

6 years agoMake target_desc::compatible an std::vector
Simon Marchi [Tue, 5 Dec 2017 21:30:22 +0000 (16:30 -0500)]
Make target_desc::compatible an std::vector

This patch changes target_desc::compatible to be a vector of
bfd_arch_info *.  This way, we don't need to manually free the vector in
the target_desc destructor.

gdb/ChangeLog:

* target-descriptions.c (arch_p): Remove typedef.
(DEF_VEC_P (arch_p)): Remove.
(struct target_desc) <compatible>: Change type to std::vector.
<~target_desc>: Don't manually free compatible.
(tdesc_compatible_p): Adjust.
(tdesc_add_compatible): Adjust.
(class print_c_tdesc) <visit_pre>: Adjust.

6 years agoMake target_desc::properties an std::vector
Simon Marchi [Tue, 5 Dec 2017 21:30:22 +0000 (16:30 -0500)]
Make target_desc::properties an std::vector

This patch changes target_desc::properties to be a vector of property
objects.  This way, we don't need to manually free the property members
as well as the property objects themselves.

gdb/ChangeLog:

* target-descriptions.c (property_s): Remove typedef.
(DEF_VEC_O (property_s)): Remove.
(struct target_desc) <properties>: Make an std::vector.
<~target_desc>: Don't manually free properties.
(tdesc_property): Adjust.
(set_tdesc_property): Adjust.
(class print_c_tdesc) <visit_pre>: Adjust.

6 years agoRedefine gdb_static_assert as static_assert
Simon Marchi [Tue, 5 Dec 2017 21:15:08 +0000 (16:15 -0500)]
Redefine gdb_static_assert as static_assert

Since we use C++11, we can use static_assert instead doing the trick
that makes a negative-sized array if the expression is false.
static_assert is built in the language and gives clearer error messages.

To avoid modifying the usages of gdb_static_assert, redefine
gdb_static_assert in terms of static_assert, passing an empty message.
If we want to add an assert with a message, it's always possible to use
static_assert directly.

gdb/ChangeLog:

* common/gdb_assert.h (gdb_static_assert): Redefine using
static_assert.

6 years agoRemove some unused variables
Simon Marchi [Tue, 5 Dec 2017 21:05:34 +0000 (16:05 -0500)]
Remove some unused variables

This patch removes some unused variables, found with -Wunused.  I have
not removed everything reported by -Wunused, because some expressions
such as

  struct type *arg_type = check_typedef (value_type);

in bfin-tdep.c could have an unexpected but important side-effect.  I
removed others that I considered more low-risk, such as:

  struct gdbarch *gdbarch = get_objfile_arch (objfile);

I tested building with Python 2/Python 3/no Python, with/without expat,
with/without libipt and with/without babeltrace.

gdb/ChangeLog:

* ada-lang.c (ada_collect_symbol_completion_matches): Remove
unused variables.
(ada_is_redundant_range_encoding): Likewise.
* ada-varobj.c (ada_varobj_get_value_of_array_variable):
Likewise.
* alpha-tdep.c (alpha_software_single_step): Likewise.
* arm-tdep.c (_initialize_arm_tdep): Likewise.
* auto-load.c (info_auto_load_cmd): Likewise.
* break-catch-syscall.c (insert_catch_syscall): Likewise.
(remove_catch_syscall): Likewise.
* breakpoint.c (condition_completer): Likewise.
(clear_command): Likewise.
(update_breakpoint_locations): Likewise.
* btrace.c (btrace_disable): Likewise.
(btrace_teardown): Likewise.
(btrace_maint_update_pt_packets): Likewise.
(maint_btrace_clear_cmd): Likewise.
* cli/cli-decode.c (lookup_cmd_1): Likewise.
(lookup_cmd_composition): Likewise.
* cli/cli-dump.c (scan_filename): Likewise.
(restore_command): Likewise.
* compile/compile-loc2c.c (compute_stack_depth): Likewise.
* compile/compile-object-load.c (compile_object_load): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (compile_to_object): Likewise.
* completer.c (filename_completer): Likewise.
(complete_files_symbols): Likewise.
(complete_expression): Likewise.
* corelow.c (core_open): Likewise.
* ctf.c (ctf_start): Likewise.
(ctf_write_status): Likewise.
(ctf_write_uploaded_tsv): Likewise.
(ctf_write_definition_end): Likewise.
(ctf_open_dir): Likewise.
(ctf_xfer_partial): Likewise.
(ctf_trace_find): Likewise.
* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn):
Likewise.
* dwarf2loc.c (allocate_piece_closure): Likewise.
(indirect_pieced_value): Likewise.
(dwarf2_evaluate_loc_desc_full): Likewise.
* dwarf2read.c (dw2_expand_marked_cus): Likewise.
(dw2_expand_symtabs_matching): Likewise.
(dw2_map_symbol_filenames): Likewise.
(read_and_check_comp_unit_head): Likewise.
(read_cutu_die_from_dwo): Likewise.
(lookup_dwo_unit): Likewise.
(read_comp_units_from_section): Likewise.
(dwarf2_compute_name): Likewise.
(handle_DW_AT_stmt_list): Likewise.
(create_cus_hash_table): Likewise.
(create_dwp_v2_section): Likewise.
(dwarf2_rnglists_process): Likewise.
(dwarf2_ranges_process): Likewise.
(dwarf2_record_block_ranges): Likewise.
(is_vtable_name): Likewise.
(read_formatted_entries): Likewise.
(skip_form_bytes): Likewise.
* elfread.c (elf_symtab_read): Likewise.
* exec.c (exec_file_command): Likewise.
* f-valprint.c (f_val_print): Likewise.
(info_common_command_for_block): Likewise.
* guile/guile.c (initialize_scheme_side): Likewise.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Likewise.
* guile/scm-cmd.c (cmdscm_completer): Likewise.
(gdbscm_register_command_x): Likewise.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-param.c (gdbscm_parameter_value): Likewise.
* guile/scm-ports.c (file_port_magic): Likewise.
* guile/scm-pretty-print.c (ppscm_search_pp_list): Likewise.
(ppscm_pretty_print_one_value): Likewise.
(ppscm_print_children): Likewise.
* guile/scm-string.c (gdbscm_string_to_argv): Likewise.
* guile/scm-symtab.c (gdbscm_sal_symtab): Likewise.
* guile/scm-type.c (gdbscm_type_next_field_x): Likewise.
* guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
* i386-tdep.c (i386_register_reggroup_p): Likewise.
* infcmd.c (run_command_1): Likewise.
(until_next_fsm_clean_up): Likewise.
* linespec.c (linespec_complete): Likewise.
(find_label_symbols): Likewise.
* m2-valprint.c (m2_val_print): Likewise.
* memattr.c (require_user_regions): Likewise.
(lookup_mem_region): Likewise.
(disable_mem_command): Likewise.
(mem_delete): Likewise.
* mep-tdep.c (mep_register_name): Likewise.
(mep_analyze_prologue): Likewise.
* mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Likewise.
* mi/mi-interp.c (mi_on_sync_execution_done): Likewise.
* mi/mi-main.c (mi_cmd_trace_frame_collected): Likewise.
* microblaze-linux-tdep.c (microblaze_linux_init_abi): Likewise.
* minidebug.c (lzma_open): Likewise.
* minsyms.c (lookup_minimal_symbol): Likewise.
* mips-linux-tdep.c (mips64_fill_fpregset): Likewise.
* mips-tdep.c (mips_stub_frame_sniffer): Likewise.
(mips_o64_return_value): Likewise.
(mips_single_step_through_delay): Likewise.
(_initialize_mips_tdep): Likewise.
* nios2-tdep.c (nios2_push_dummy_call): Likewise.
(nios2_software_single_step): Likewise.
* parse.c (find_minsym_type_and_address): Likewise.
* psymtab.c (psym_relocate): Likewise.
* python/py-breakpoint.c (bppy_get_commands): Likewise.
(gdbpy_breakpoint_modified): Likewise.
* python/py-infevents.c (create_inferior_call_event_object):
Likewise.
* python/py-record-btrace.c (btpy_list_item): Likewise.
* python/py-type.c (typy_str): Likewise.
* python/py-value.c (valpy_call): Likewise.
* python/python.c (do_start_initialization): Likewise.
* record-btrace.c (record_btrace_insn_history_range): Likewise.
(record_btrace_call_history_range): Likewise.
(record_btrace_record_method): Likewise.
(record_btrace_xfer_partial): Likewise.
(btrace_get_frame_function): Likewise.
* record-full.c (record_full_open): Likewise.
* record.c (get_context_size): Likewise.
* registry.h (DEFINE_REGISTRY): Likewise.
* remote-fileio.c (remote_fileio_request): Likewise.
* remote.c (remote_update_thread_list): Likewise.
(remote_check_symbols): Likewise.
(remote_commit_resume): Likewise.
(remote_interrupt): Likewise.
(remote_insert_breakpoint): Likewise.
(compare_sections_command): Likewise.
* rust-exp.y (super_name): Likewise.
(lex_string): Likewise.
(convert_ast_to_type): Likewise.
(convert_ast_to_expression): Likewise.
* rust-lang.c (rust_print_struct_def): Likewise.
(rust_print_type): Likewise.
(rust_evaluate_subexp): Likewise.
* rx-tdep.c (rx_register_type): Likewise.
* ser-event.c (serial_event_clear): Likewise.
* serial.c (serial_open): Likewise.
* spu-tdep.c (spu_overlay_new_objfile): Likewise.
* symfile.c (section_is_overlay): Likewise.
(overlay_unmapped_address): Likewise.
(overlay_mapped_address): Likewise.
(simple_overlay_update_1): Likewise.
(simple_overlay_update): Likewise.
* symtab.c (symbol_find_demangled_name): Likewise.
(search_symbols): Likewise.
* target-descriptions.c (tdesc_predefined_type): Likewise.
* target.c (target_commit_resume): Likewise.
* thread.c (print_selected_thread_frame): Likewise.
* top.c (new_ui_command): Likewise.
(gdb_readline_no_editing): Likewise.
* tracefile-tfile.c (tfile_open): Likewise.
* tracepoint.c (create_tsv_from_upload): Likewise.
* utils.c (quit): Likewise.
(defaulted_query): Likewise.
* valarith.c (value_concat): Likewise.
* xml-syscall.c (xml_list_syscalls_by_group): Likewise.
* xml-tdesc.c (target_fetch_description_xml): Likewise.
* xtensa-tdep.c (xtensa_pseudo_register_read): Likewise.
(xtensa_pseudo_register_write): Likewise.

gdb/gdbserver/ChangeLog:

* regcache.c (registers_to_string): Remove unused variable.

6 years agoRiscv shared libraries should not export __global_pointer$.
Jim Wilson [Tue, 5 Dec 2017 01:37:55 +0000 (17:37 -0800)]
Riscv shared libraries should not export __global_pointer$.

ld/
* emulparams/elf32lriscv-defs.sh (SDATA_START_SYMBOLS): Mark
__global_pointer$ as HIDDEN.
* testsuite/ld-riscv-elf/gp-hidden-64.rd: New.
* testsuite/ld-riscv-elf/gp-hidden-lib.rd: New.
* testsuite/ld-riscv-elf/gp-hidden-lib.s: New.
* testsuite/ld-riscv-elf/gp-hidden-ver-64.rd: New.
* testsuite/ld-riscv-elf/gp-hidden-ver.rd: New.
* testsuite/ld-riscv-elf/gp-hidden-ver.s: New.
* testsuite/ld-riscv-elf/gp-hidder-ver.ver: New.
* testsuite/ld-riscv-elf/gp-hidden.rd: New.
* testsuite/ld-riscv-elf/gp-hidden.s: New.
* testsuite/ld-riscv-elf/gp-hidden.sd: New.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Change riscv to riscv*.
Run the new tests with run_ld_link_tests.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 5 Dec 2017 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoExtend gdb.core/coredump-filter.exp to test dump-excluded-mappings.
Sergio Lopez [Mon, 4 Dec 2017 08:17:16 +0000 (09:17 +0100)]
Extend gdb.core/coredump-filter.exp to test dump-excluded-mappings.

gdb/testsuite/ChangeLog:
2017-11-30  Sergio Lopez  <slp@redhat.com>

* gdb.core/coredump-filter.exp: Extend test to verify
the functionality of the dump-excluded-mappings command.

6 years agoDocument the new "-a" command line option for gcore
Sergio Lopez [Mon, 4 Dec 2017 08:17:15 +0000 (09:17 +0100)]
Document the new "-a" command line option for gcore

gdb/ChangeLog:
2017-11-29  Sergio Lopez  <slp@redhat.com>

* NEWS (Changes since GDB 8.0): Announce new "-a"
command line option for gcore.

gdb/doc/ChangeLog:
2017-11-29  Sergio Lopez  <slp@redhat.com>

* gdb.texinfo (gcore man): Document new "-a" command line option.

6 years agoImplement "-a" command line option for gcore
Sergio Lopez [Mon, 4 Dec 2017 08:17:14 +0000 (09:17 +0100)]
Implement "-a" command line option for gcore

With the new "-a" command line option, the user may request gcore to
actually dump all present memory mappings. The actual effect of this
argument is OS dependent.

On GNU/Linux, it will disable use-coredump-filter and enable
dump-excluded-mappings.

gdb/ChangeLog:
2017-11-29  Sergio Lopez  <slp@redhat.com>

* gcore.in: Add "-a" command line option for instructing gdb to
dump all memory mappings (OS dependent).

6 years agoDocument new {set,show} dump-excluded-mappings commands.
Sergio Lopez [Mon, 4 Dec 2017 08:17:13 +0000 (09:17 +0100)]
Document new {set,show} dump-excluded-mappings commands.

gdb/ChangeLog:
2017-11-29  Sergio Lopez  <slp@redhat.com>

* NEWS (Changes since GDB 8.0): Announce {set,show}
dump_excluded_mappings commands.

gdb/doc/ChangeLog:
2017-11-29  Sergio Lopez  <slp@redhat.com>

* gdb.texinfo (gcore): Mention new {set,show}
dump-excluded-mappings commands.
(set dump-excluded-mappings): Document new command.

6 years agoImplement 'set dump-excluded-mappings' command
Sergio Lopez [Mon, 4 Dec 2017 08:17:12 +0000 (09:17 +0100)]
Implement 'set dump-excluded-mappings' command

Commit df8411da087dc05481926f4c4a82deabc5bc3859 implemented support for
checking /proc/PID/coredump_filter, and also changed gcore behavior to
unconditionally honor the VM_DONTDUMP flag, preventing sections marked
as such for being dumped into the core file.

This patch implements the 'set dump-excluded-mappings' command for
instructing gdb to ignore the VM_DONTDUMP flag. Combined with 'set
use-coredump-filter', this allows the user to restore the old behavior,
dumping all sections (except the ones marked as IO) unconditionally.

gdb/Changelog:
2017-11-29  Sergio Lopez  <slp@redhat.com>

* linux-tdep.c (dump_excluded_mappings): New variable.
(dump_mapping_p): Use dump_excluded_mappings variable.
(_initialize_linux_tdep): New command 'set dump_excluded_mappings'.

6 years agoUpdate manual for Rust change
Tom Tromey [Fri, 1 Dec 2017 21:16:33 +0000 (14:16 -0700)]
Update manual for Rust change

I realized today that a recent change to the Rust support required an
update to the manual; and so I updated NEWS as well.

2017-12-04  Tom Tromey  <tom@tromey.com>

* NEWS: Mention Rust trait object inspection.

2017-12-04  Tom Tromey  <tom@tromey.com>

* gdb.texinfo (Rust): Update trait object status

6 years agoFix displaced-stepping RIP-relative VEX-encoded instructions (AVX) (PR gdb/22499)
Pedro Alves [Mon, 4 Dec 2017 15:59:20 +0000 (15:59 +0000)]
Fix displaced-stepping RIP-relative VEX-encoded instructions (AVX) (PR gdb/22499)

PR gdb/22499 is about a latent bug exposed by the switch to "maint set
target-non-stop on" by default on x86-64 GNU/Linux, a while ago.  With
that on, GDB is also preferring to use displaced-stepping by default.

The testcase in the bug is failing because GDB ends up incorrectly
displaced-stepping over a RIP-relative VEX-encoded instruction, like
this:

 0x00000000004007f5 <+15>:    c5 fb 10 05 8b 01 00 00 vmovsd 0x18b(%rip),%xmm0        # 0x400988

While RIP-relative instructions need adjustment when relocated to the
scratch pad, GDB ends up just copying VEX-encoded instructions to the
scratch pad unmodified, with the end result that the inferior ends up
executing an instruction that fetches/writes memory from the wrong
address...

This patch teaches GDB about the VEX-encoding prefixes, fixing the
problem, and adds a testcase that fails without the GDB fix.

I think we may need a similar treatment for EVEX-encoded instructions,
but I didn't address that simply because I couldn't find any
EVEX-encoded RIP-relative instruction in the gas testsuite.  In any
case, this commit is forward progress as-is already.

gdb/ChangeLog:
2017-12-04  Pedro Alves  <palves@redhat.com>

PR gdb/22499
* amd64-tdep.c (amd64_insn::rex_offset): Rename to...
(amd64_insn::enc_prefix_offset): ... this, and tweak comment.
(vex2_prefix_p, vex3_prefix_p): New functions.
(amd64_get_insn_details): Adjust to rename.  Also skip VEX2 and
VEX3 prefixes.
(fixup_riprel): Set VEX3.!B.

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

PR gdb/22499
* gdb.arch/amd64-disp-step-avx.S: New file.
* gdb.arch/amd64-disp-step-avx.exp: New file.

6 years agox86 map file textrel
Alan Modra [Sat, 2 Dec 2017 04:18:50 +0000 (14:48 +1030)]
x86 map file textrel

bfd/
* elfxx-x86.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function.  Always prints via minfo and
correct "readonly" to "read-only" in warning message., replacing..
(_bfd_x86_elf_readonly_dynrelocs): ..this.
(_bfd_x86_elf_size_dynamic_sections): Correct "readonly" to
"read-only" in warning message.  Formatting.
(_bfd_x86_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
* linker.c (bfd_link_hash_traverse): Comment typo fix.
ld/
* testsuite/ld-i386/pr17935-1.d: Adjust expected error.
* testsuite/ld-i386/pr17935-2.d: Likewise.
* testsuite/ld-x86-64/pr17935-1.d: Likewise.
* testsuite/ld-x86-64/pr17935-2.d: Likewise.

6 years agoDocumentation fix
Alan Modra [Mon, 4 Dec 2017 11:55:45 +0000 (22:25 +1030)]
Documentation fix

PR 22544
* doc/as.texinfo (8byte): Correct.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 4 Dec 2017 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoRun powerpc vle gas tests for all powerpc ELF targets
Alan Modra [Sun, 3 Dec 2017 23:42:46 +0000 (10:12 +1030)]
Run powerpc vle gas tests for all powerpc ELF targets

* testsuite/gas/ppc/ppc.exp: Don't exclude VLE tests when little-endian.
* testsuite/gas/ppc/efs.d: Add -mbig to assembler options.
* testsuite/gas/ppc/efs2.d: Likewise.
* testsuite/gas/ppc/lsp-checks.d: Likewise.
* testsuite/gas/ppc/lsp.d: Likewise.
* testsuite/gas/ppc/spe.d: Likewise.
* testsuite/gas/ppc/spe2-checks.d: Likewise.
* testsuite/gas/ppc/spe2.d: Likewise.
* testsuite/gas/ppc/spe_ambiguous.d: Likewise.
* testsuite/gas/ppc/vle-mult-ld-st-insns.d: Likewise.
* testsuite/gas/ppc/vle-reloc.d: Likewise.
* testsuite/gas/ppc/vle-simple-1.d: Likewise.
* testsuite/gas/ppc/vle-simple-2.d: Likewise.
* testsuite/gas/ppc/vle-simple-3.d: Likewise.
* testsuite/gas/ppc/vle-simple-4.d: Likewise.
* testsuite/gas/ppc/vle-simple-5.d: Likewise.
* testsuite/gas/ppc/vle-simple-6.d: Likewise.
* testsuite/gas/ppc/vle.d: Likewise.

6 years agoModify ppceabi ld tests to run on all powerpc ELF targets
Alan Modra [Sun, 3 Dec 2017 22:08:35 +0000 (08:38 +1030)]
Modify ppceabi ld tests to run on all powerpc ELF targets

* testsuite/ld-powerpc/powerpc.exp (ppceabitests): Add -a32 -mbig
to assembler options, and -melf32ppc to linker options.  Always
run these tests.

6 years agoFix for texinfo 4.8.
Jim Wilson [Sun, 3 Dec 2017 23:11:07 +0000 (15:11 -0800)]
Fix for texinfo 4.8.

gas/
* doc/c-riscv.texi (RISC-V-Directives): Move @section immediately after
@node.

6 years agoRemove mem_region_vector typedef
Simon Marchi [Sun, 3 Dec 2017 18:01:03 +0000 (13:01 -0500)]
Remove mem_region_vector typedef

Now that make-target-delegates understands namespaces and templates,
this typedef is no longer useful.

gdb/ChangeLog:

* target.h (mem_region_vector): Remove.
(struct target_ops) <to_memory_map>: Change return type to
std::vector<mem_region>.
* target-debug.h (target_debug_print_mem_region_vector): Rename
to ...
(target_debug_print_std_vector_mem_region): ... this.
* target-delegates.c: Re-generate.

6 years agoMake make-target-delegates grok namespace scope op and template params
Pedro Alves [Sun, 3 Dec 2017 17:50:43 +0000 (12:50 -0500)]
Make make-target-delegates grok namespace scope op and template params

The next patch will want to use gdb::array_view<int> as parameter type
of a target_ops method.  However, that runs into a
make-target-delegates limitation: target_debug_foo calls in
target-delegates.c for parameters/return types with namespace scope
operators ("::") or template parameters, end up looking like:

 @@ -1313,9 +1313,7 @@ debug_set_syscall_catchpoint (struct target_ops *self, int arg1, int arg2, int a
    fputs_unfiltered (", ", gdb_stdlog);
    target_debug_print_int (arg3);
    fputs_unfiltered (", ", gdb_stdlog);
 -  target_debug_print_int (arg4);
 -  fputs_unfiltered (", ", gdb_stdlog);
 -  target_debug_print_int_p (arg5);
 +  target_debug_print_gdb::array_view<const_int> (arg4);

which obviously isn't something that compiles.  The problem is that
make-target-delegates wasn't ever taught that '::', '<', and '>' can
appear in parameter/return types.  You could work around it by hidding
the unsupported characters behind a typedef in the target method
declaration, or by using an explicit TARGET_DEBUG_PRINTER, but it's
better to just remove the limitation.

While at it, also fix an "abuse" of reserved identifiers.

gdb/ChangeLog:

* make-target-delegates (munge_type): Also munge '<', '>', and
':'.  Avoid double underscores in identifiers, and trailing
underscores.
* target-debug.h
(target_debug_print_VEC_static_tracepoint_marker_p__p): Rename to
...
(target_debug_print_VEC_static_tracepoint_marker_p_p): ... this.
* target-delegates.c: Regenerate.

6 years agoFix gdb.threads/process-dies-while-detaching.exp
Pedro Alves [Sun, 3 Dec 2017 15:32:08 +0000 (15:32 +0000)]
Fix gdb.threads/process-dies-while-detaching.exp

I noticed [1] a test bug in gdb.threads/process-dies-while-detaching.exp.
Simplified, the test code in question looks somewhat like this:

~~~
  # Detach from a process, and ensure that it exits after detaching.
  # This relies on inferior I/O.

  proc detach_and_expect_exit {test} {

      gdb_test_multiple "detach" $test ....

      set saw_prompt 0
      set saw_inf_exit 0
      while { !$saw_prompt && !$saw_inf_exit } {
          gdb_test_multiple "" $test {
              -re "exited, status=0" {
                  set saw_inf_exit 1
              }
              -re "$gdb_prompt " {
                  set saw_prompt 1
              }
          }
      }

      pass $test
  }
~~~

The bug is in the while loop's condition.  We want to make sure we see
both the inferior output and the prompt, so the loop's test should be:

   -    while { !$saw_prompt && !$saw_inf_exit } {
   +    while { !$saw_prompt || !$saw_inf_exit } {

If we just fix that, the test starts failing though, because it
exposes a couple latent problems:

- When called from test_detach_killed_outside, the parent doesn't
  print "exited, status=0", because in that case the child dies with a
  signal, and so detach_and_expect_exit times out.

  Fix it by making the parent print "signaled, sig=9" in that case,
  and have the .exp expect it.

- When testing against --target_board=native-gdbserver, sometimes we'd
  get this:

    ERROR: Process no longer exists
    ERROR: : spawn id exp9 not open
while executing
    "expect {
    -i exp8 -timeout 220
    -i $server_spawn_id
    eof {
pass $test
wait -i $server_spawn_id
unset server_spawn_id
    }
    timeout {
       ..."
("uplevel" body line 1)
invoked from within
    "uplevel $body" NONE : spawn id exp9 not open

  The problem is that:

   - inferior_spawn_id and server_spawn_id are the same when testing
     with gdbserver.
   - gdbserver exits after "detach", so we get an eof for
     $inferior_spawn_id in the loop in detach_and_expect_exit.
     That's the first "ERROR: Process no longer exists".
   - and then when we reach test_server_exit, server_spawn_id
     is already closed (because server_spawn_id==inferior_spawn_id).

  To handle this, make the loop in detach_and_expect_exit use an
  indirect spawn id list and remove $inferior_spawn_id from the list
  as soon as we got the inferior output we're expecting, so that the
  "eof" is left unprocessed until we reach test_server_exit.

[1] I changed GDB in a way that should have made the test fail, but it
    didn't.

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

* gdb.threads/process-dies-while-detaching.c: Include <errno.h>
and <string.h>.
(parent_function): Print distinct messages when waitpid fails, or
the child exits with a signal, or the child exits for an unhandled
reason.
* gdb.threads/process-dies-while-detaching.exp
(detach_and_expect_exit): New 'inf_output_re' parameter and use
it.  Wait for both inferior output and GDB's prompt.  Use an
indirect spawn id list.
(do_detach): New parameter 'child_exit'.  Use it to compute
expected inferior output.
(test_detach, test_detach_watch, test_detach_killed_outside):
Adjust to pass down the expected child exit kind.

6 years agoFix "FAIL: VLE relocations 3"
Alan Modra [Sun, 3 Dec 2017 11:21:45 +0000 (21:51 +1030)]
Fix "FAIL: VLE relocations 3"

Correct sign extension.

* ppc-opc.c (extract_li20): Rewrite.

6 years agoRemove for_each_inferior_with_data
Simon Marchi [Sun, 3 Dec 2017 01:36:46 +0000 (20:36 -0500)]
Remove for_each_inferior_with_data

Remove for_each_inferior_with_data, replacing its sole usage with
for_each_thread.

gdb/gdbserver/ChangeLog:

* inferiors.c (for_each_inferior_with_data): Remove.
* inferiors.h (for_each_inferior_with_data): Remove.
* server.c (handle_qxfer_threads_worker): Change parameter type.
(handle_qxfer_threads_proper): Use for_each_thread.

6 years agoRemove for_each_inferior
Simon Marchi [Sun, 3 Dec 2017 01:37:53 +0000 (20:37 -0500)]
Remove for_each_inferior

This patch removes for_each_inferior, replacing all its usages with
for_each_thread.

gdb/gdbserver/ChangeLog:

* inferiors.c (for_each_inferior): Remove.
(clear_inferiors): Use for_each_thread.
* inferiors.h (for_each_inferior): Remove.
* linux-low.c (linux_wait_for_event_filtered): Use
for_each_thread.
(linux_stabilize_threads): Likewise.
* regcache.c (regcache_release): Likewise.
* server.c (gdb_wants_all_threads_stopped): Likewise.
(clear_pending_status_callback): Remove.
(handle_status): Use for_each_thread.
(captured_main): Likewise.
* win32-low.c (child_init_thread_list): Likewise.
(win32_clear_inferiors): Likewise.
(fake_breakpoint_event): Likewise.

6 years agoRemove find_inferior
Simon Marchi [Sun, 3 Dec 2017 01:36:45 +0000 (20:36 -0500)]
Remove find_inferior

All the usages of find_inferior were removed, so the function itself can
be removed.

gdb/gdbserver/ChangeLog:

* inferiors.h (find_inferior): Remove.
* inferiors.c (find_inferior): Remove.

6 years agoUpdate comments
Simon Marchi [Sun, 3 Dec 2017 01:36:44 +0000 (20:36 -0500)]
Update comments

These functions were modified in the previous patch series, but I forgot
to update some comments.

gdb/gdbserver/ChangeLog:

* linux-low.c (resume_status_pending_p): Update comment.
(need_step_over_p): Update comment.

6 years agoRemove usages of find_inferior that call proceed_one_lwp
Simon Marchi [Sun, 3 Dec 2017 01:36:43 +0000 (20:36 -0500)]
Remove usages of find_inferior that call proceed_one_lwp

Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

* linux-low.c (proceed_one_lwp): Return void, change parameter
type.
(unsuspend_and_proceed_one_lwp): Likewise.
(proceed_all_lwps): Use for_each_thread.
(unstop_all_lwps): Likewise.

6 years agoRemove usage of find_inferior in linux_resume
Simon Marchi [Sun, 3 Dec 2017 01:36:42 +0000 (20:36 -0500)]
Remove usage of find_inferior in linux_resume

Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

* linux-low.c (linux_resume_one_thread): Return void, take
parameter directly.
(linux_resume): Use for_each_thread.

6 years agoRemove usages of find_inferior in stop_all_lwps
Simon Marchi [Sun, 3 Dec 2017 01:36:41 +0000 (20:36 -0500)]
Remove usages of find_inferior in stop_all_lwps

Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

* linux-low.c (send_sigstop_callback): Return void, change
parameter type.  Rename to...
(send_sigstop): ... this.
(suspend_and_send_sigstop_callback): Return void, change parameter
type.  Rename to...
(suspend_and_send_sigstop): ... this.
(stop_all_lwps): Use for_each_thread.

6 years agoRemove usage of find_inferior in linux_stabilize_threads
Simon Marchi [Sun, 3 Dec 2017 01:36:41 +0000 (20:36 -0500)]
Remove usage of find_inferior in linux_stabilize_threads

Replace with find_thread.

gdb/gdbserver/ChangeLog:

* linux-low.c (lwp_running): Return bool, remove unused
argument.
(linux_stabilize_threads): Use find_thread.

6 years agoRemove usages of find_inferior in select_event_lwp
Simon Marchi [Sun, 3 Dec 2017 01:36:40 +0000 (20:36 -0500)]
Remove usages of find_inferior in select_event_lwp

Replace with find_thread/for_each_thread.  I inlined the callbacks,
because they are relatively simple.

gdb/gdbserver/ChangeLog:

* linux-low.c (select_singlestep_lwp_callback): Remove.
(count_events_callback): Remove.
(select_event_lwp_callback): Remove.
(select_event_lwp): Use find_thread/for_each_thread.

6 years agoRemove usages of find_inferior calling not_stopped_callback
Simon Marchi [Sun, 3 Dec 2017 01:36:39 +0000 (20:36 -0500)]
Remove usages of find_inferior calling not_stopped_callback

Replace with find_thread.  Writing a lambda inline in directly in the if
conditions would be a bit messy, so I chose to assign them to variables
instead.

gdb/gdbserver/ChangeLog:

* linux-low.c (not_stopped_callback): Return bool, take filter
argument directly.
(linux_wait_for_event_filtered): Use find_thread.
(linux_wait_1): Likewise.

6 years agoRemove usage of find_inferior in find_lwp_pid
Simon Marchi [Sun, 3 Dec 2017 01:36:38 +0000 (20:36 -0500)]
Remove usage of find_inferior in find_lwp_pid

Replace with find_thread.  We could almost use find_thread_ptid, except
that find_lwp_pid uses the pid of the input ptid of the lwp is 0, so the
behavior is not quite the same.

gdb/gdbserver/ChangeLog:

* linux-low.c (same_lwp): Remove.
(find_lwp_pid): Use find_thread.

6 years agoRemove usage of find_inferior in linux_mourn
Simon Marchi [Sun, 3 Dec 2017 01:36:37 +0000 (20:36 -0500)]
Remove usage of find_inferior in linux_mourn

Replace with for_each_thread with pid filtering.  The callback becomes
trivial enough that it's better to inline it.

gdb/gdbserver/ChangeLog:

* linux-low.c (delete_lwp_callback): Remove.
(linux_mourn): Use for_each_thread.

6 years agoRemove usage of find_inferior in linux_detach
Simon Marchi [Sun, 3 Dec 2017 01:36:36 +0000 (20:36 -0500)]
Remove usage of find_inferior in linux_detach

Replace with for_each_thread with pid filtering.

gdb/gdbserver/ChangeLog:

* linux-low.c (linux_detach_lwp_callback): Return void, remove
args parameter, don't check for pid.
(linux_detach): Use for_each_thread.

6 years agoRemove usage of find_inferior in last_thread_of_process_p
Simon Marchi [Sun, 3 Dec 2017 01:36:36 +0000 (20:36 -0500)]
Remove usage of find_inferior in last_thread_of_process_p

Replace it with find_thread.  I also modified the code a bit to use a
lambda and a boolean.

gdb/gdbserver/ChangeLog:

* linux-low.c (struct counter): Remove.
(second_thread_of_pid_p): Remove.
(last_thread_of_process_p): Use find_thread.

6 years agoRemove find_inferior_in_random
Simon Marchi [Sun, 3 Dec 2017 01:36:35 +0000 (20:36 -0500)]
Remove find_inferior_in_random

Replace with find_thread_in_random.

gdb/gdbserver/ChangeLog:

* inferiors.c (find_inferior_in_random): Remove.
* inferiors.h (find_inferior_in_random): Remove.
* linux-low.c (status_pending_p_callback): Return bool, accept
parameter ptid directly.
(linux_wait_for_event_filtered): Use find_thread_in_random.
(linux_wait_1): Likewise.

6 years agoRemove find_inferior_id
Simon Marchi [Sun, 3 Dec 2017 01:36:34 +0000 (20:36 -0500)]
Remove find_inferior_id

Remove find_inferior_id, replacing its usages with find_thread_ptid.
find_thread_ptid was implemented using find_inferior_id, so move the
implementation there instead.

gdb/gdbserver/ChangeLog:

* inferiors.c (find_inferior_id): Remove.
(find_thread_ptid): Move implemention from find_inferior_id to
here.
* inferiors.h (find_inferior_id): Remove.
* server.c (handle_status): Use find_thread_ptid.
(process_serial_event): Likewise.
* thread-db.c (find_one_thread): Likewise.
(thread_db_thread_handle): Likewise.
* win32-low.c (thread_rec): Likewise.
(child_delete_thread): Likewise.
(win32_thread_alive): Likewise.
(get_child_debug_event): Likewise.

6 years agoRemove usages of find_inferior in linux-mips-low.c
Simon Marchi [Sun, 3 Dec 2017 01:36:33 +0000 (20:36 -0500)]
Remove usages of find_inferior in linux-mips-low.c

Replace with for_each_thread with pid filtering.  This allows
simplifying the callback a little bit.

gdb/gdbserver/ChangeLog:

* linux-mips-low.c (update_watch_registers_callback): Return
void, remove pid_p parameter, don't check for pid.
(mips_insert_point, mips_remove_point): Use for_each_thread.

6 years agoRemove usage of find_inferior in lynx_mourn
Simon Marchi [Sun, 3 Dec 2017 01:36:32 +0000 (20:36 -0500)]
Remove usage of find_inferior in lynx_mourn

Replace it with for_each_thread with pid filtering.  We can remove
lynx_delete_thread_callback and pass remove_thread directly.

I can't build/test this change, but it should be obvious enough.

gdb/gdbserver/ChangeLog:

* lynx.low (lynx_delete_thread_callback): Remove.
(lynx_mourn): Use for_each_thread.

6 years agoRemove usage of find_inferior in regcache_invalidate_pid
Simon Marchi [Sun, 3 Dec 2017 01:36:32 +0000 (20:36 -0500)]
Remove usage of find_inferior in regcache_invalidate_pid

Replace with for_each_thread with pid filtering.
regcache_invalidate_one is not longer needed, as it was only used to
filter the pid.  We can call regcache_invalidate_thread directly.

gdb/gdbserver/ChangeLog:

* regcache.c (regcache_invalidate_one): Remove.
(regcache_invalidate_pid): use for_each_thread.

6 years agoFix typo in poison.h
Simon Marchi [Sun, 3 Dec 2017 01:28:22 +0000 (20:28 -0500)]
Fix typo in poison.h

gdb/ChangeLog:

* common/poison.h (XDELETE): Fix typo.

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 3 Dec 2017 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoHandle case where posix_fallocate is not supported for a filesystem.
Cary Coutant [Sat, 2 Dec 2017 17:56:40 +0000 (09:56 -0800)]
Handle case where posix_fallocate is not supported for a filesystem.

2017-12-02  Vladimir Kondratyev  <vladimir@kondratyev.su>
    Cary Coutant  <ccoutant@gmail.com>

gold/
PR gold/22540
* output.cc (gold_fallocate): Trivial return for len == 0.
Add fallback options when posix_fallocate and fallocate return
not-supported errors.

6 years agoDisallow --incremental with -pie and force -no-pie for incremental tests.
Cary Coutant [Wed, 15 Feb 2017 08:25:29 +0000 (00:25 -0800)]
Disallow --incremental with -pie and force -no-pie for incremental tests.

This is a partial fix for the gold testsuite failures documented in
PR 21090. The use of -fpie triggers some mov-to-lea optimizations that
are not compatible with incremental linking, so those optimizations need
to be disabled. We also diagnose the attempt to use -pie with incremental
linking, and force -no-pie for the incremental tests in case the build has
been configured to have GCC pass -pie all the time.

We still have a problem where compiling with -fpie results in some GOT
entries even when linking with -no-pie. This combination still causes test
failures because we are not updating the GOT entries in an incremental update
link.

gold/
PR gold/21090
* incremental.cc (Sized_relobj_incr::do_relocate): Fix comment.
* options.cc (General_options::finalize): Disallow -pie with
incremental linking.
* x86_64.cc (Target_x86_64::Scan::local): Don't do mov-to-lea
or callq-to-direct optimizations for incremental links.
(Target_x86_64::Scan::global): Likewise.
(Target_x86_64::Relocate::relocate): Likewise.
* testsuite/Makefile.am (incremental_test): Force -no-pie.
(incremental_test_2): Likewise.
(incremental_test_3): Likewise.
(incremental_test_4): Likewise.
(incremental_test_5): Likewise.
(incremental_test_6): Likewise.
(incremental_copy_test): Likewise.
(incremental_common_test_1): Likewise.
(incremental_comdat_test_1):  Likewise.
* testsuite/Makefile.in: Regenerate.

6 years agoWorkaround GCC 7 bug with debug line numbers causing debug_msg.sh failure.
Cary Coutant [Sat, 2 Dec 2017 06:53:08 +0000 (22:53 -0800)]
Workaround GCC 7 bug with debug line numbers causing debug_msg.sh failure.

gold/
PR gold/21841
* testsuite/debug_msg.sh: Adjust expected line numbers.
* testsuite/odr_violation2.cc (DummyFunction): New function.

6 years agoFix incremental linking failure with GCC 7+.
Cary Coutant [Sat, 2 Dec 2017 06:03:09 +0000 (22:03 -0800)]
Fix incremental linking failure with GCC 7+.

With the new compiler, we're running out of patch space for the .eh_frame
section. To workaround that issue, we compile the before and after versions
both with no unwind tables.

gold/
PR gold/22309
* testsuite/Makefile.am (two_file_test_1_v1_ndebug.o): Compile with
no EH information.
(two_file_test_1_ndebug.o): Likewise.
* testsuite/Makefile.in: Regenerate.
* testsuite/two_file_test_1.cc: Touch to force recompilation with new
flags.
* testsuite/two_file_test_1_v1.cc: Likewise.

6 years agoAdd support for the readnever concept
Sergio Durigan Junior [Fri, 24 Nov 2017 21:56:08 +0000 (16:56 -0500)]
Add support for the readnever concept

The purpose of this concept is to turn the load of debugging
information off, either globally (via the '--readnever' option), or
objfile-specific.  The implementation proposed here is an extension of
the patch distributed with Fedora GDB; looking at the Fedora patch
itself and the history, one can see some reasons why it was never
resubmitted:

  - The patch appears to have been introduced as a workaround, at
    least initially;
  - The patch is far from perfect, as it simply shunts the load of
    DWARF debugging information, without really worrying about the
    other debug format.
  - Who really does non-symbolic debugging anyways?

One use of this feature is when a user simply wants to do the
following sequence: attach, dump core, detach.  Loading the debugging
information in this case is an unnecessary cause of delay.

This patch expands the version shipped with Fedora GDB in order to
make the feature available for all the debuginfo backends, not only
for DWARF.  It also implements a per-objfile flag which can be
activated by using the "-readnever" command when using the
'add-symbol-file' or 'symbol-file' commands.

It's also worth mentioning that this patch tests whether GDB correctly
fails to initialize if both '--readnow' and '--readnever' options are
passed.

Tested on the BuildBot.

gdb/ChangeLog:

2017-12-01  Andrew Cagney  <cagney@redhat.com>
    Joel Brobecker  <brobecker@adacore.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>

* NEWS (Changes since GDB 8.0: Mention new '--readnever'
feature.
* coffread.c (coff_symfile_read): Do not map over sections with
'coff_locate_sections' if readnever is on.
* dwarf2read.c (dwarf2_has_info): Return 0 if
readnever is on.
* elfread.c (elf_symfile_read): Do not map over sections with
'elf_locate_sections' if readnever is on.
* main.c (validate_readnow_readnever): New function.
(captured_main_1): Add support for --readnever.
(print_gdb_help): Document --readnever.
* objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New
flag.
* symfile.c (readnever_symbol_files): New global.
(symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when
'READNEVER_SYMBOL_FILES' is set.
(validate_readnow_readnever): New function.
(symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(add_symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(_initialize_symfile): Document new '-readnever' option for
both 'symbol-file' and 'add-symbol-file' commands.
* top.h (readnever_symbol_files): New extern global.
* xcoffread.c (xcoff_initial_scan): Do not read debug
information if readnever is on.

gdb/doc/ChangeLog:

2017-12-01  Andrew Cagney  <cagney@redhat.com>
    Joel Brobecker  <brobecker@adacore.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>

* gdb.texinfo (File Options): Document --readnever.
(Commands to Specify Files): Likewise, for 'symbol-file' and
'add-symbol-file'.

gdb/testsuite/ChangeLog:

2017-12-01  Joel Brobecker  <brobecker@adacore.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>
    Pedro Alves  <palves@redhat.com>

* gdb.base/readnever.c, gdb.base/readnever.exp: New files.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 2 Dec 2017 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoUpdate and clean up RISC-V gas documentation.
Jim Wilson [Fri, 1 Dec 2017 23:34:42 +0000 (15:34 -0800)]
Update and clean up RISC-V gas documentation.

gas/
* doc/as.texinfo (RISC-V): Alphabetize RISC-V entries.  Change
RISC-V-Opts to RISC-V-Options.  Delete redundant space.  Add -fpic
and related options to option list.
* doc/c-riscv.texi: (RISC-V-Options): Renamed from RISC-V-Opts.
(RISC-V Options): Renamed from Options.  Add missing period.
(-fpic): Also mention -fPIC.
(RISC-V Directives): New node.

6 years agoMake '{add-,}symbol-file' not care about the position of command line arguments
Sergio Durigan Junior [Wed, 29 Nov 2017 21:36:13 +0000 (16:36 -0500)]
Make '{add-,}symbol-file' not care about the position of command line arguments

This is a bug that's been detected while doing the readnever work.

If you use 'symbol-file' or 'add-symbol-file', the position of each
argument passed to the command matters.  This means that if you do:

  (gdb) symbol-file -readnow /foo/bar

The symbol file specified will (correctly) have all of its symbols
read by GDB (because of the -readnow flag).  However, if you do:

  (gdb) symbol-file /foo/bar -readnow

GDB will silently ignore the -readnow flag, because it was specified
after the filename.  This is not a good thing to do and may confuse
the user.

To address that, I've modified the argument parsing mechanisms of
symbol_file_command and add_symbol_file_command to be
"position-independent".  I have also added one error call at the end
of add_symbol_file_command's argument parsing logic, which now clearly
complains if no filename has been specified.  Both commands now
support the "--" option to stop argument processing.

This patch provides a testcase for both commands, in order to make
sure that the argument order does not matter.  It has been
regression-tested on BuildBot.

gdb/ChangeLog:

2017-12-01  Sergio Durigan Junior  <sergiodj@redhat.com>

* symfile.c (symbol_file_command): Call
'symbol_file_add_main_1' only after processing all command
line options.
(add_symbol_file_command): Modify logic to make arguments
position-independent.

gdb/testsuite/ChangeLog:

2017-12-01  Sergio Durigan Junior  <sergiodj@redhat.com>

* gdb.base/relocate.exp: Add tests to guarantee that arguments
to 'symbol-file' and 'add-symbol-file' can be
position-independent.

6 years agoRevert "Add support for the readnever concept"
Sergio Durigan Junior [Fri, 1 Dec 2017 21:58:47 +0000 (16:58 -0500)]
Revert "Add support for the readnever concept"

This reverts commit e2e321740ce2e36a97be2a410cd56eebaa2304aa.

It was mistakenly pushed.

6 years agoFix localized help string output for -fuse-ld.
Cary Coutant [Fri, 1 Dec 2017 21:44:54 +0000 (13:44 -0800)]
Fix localized help string output for -fuse-ld.

gold/
PR gold/22042
* options.h (-fuse-ld): Use NULL instead of empty string.

6 years ago(Ada) GDB crash printing expression with type casting
Joel Brobecker [Fri, 1 Dec 2017 20:45:30 +0000 (15:45 -0500)]
(Ada) GDB crash printing expression with type casting

One of our users reported that trying to print the following expression,
caused GDB to SEGV:

    (gdb) print some_package.some_type (val)

In this particular instance, the crash occurred inside ada_args_match
because it is given a NULL "func", leading to the SEGV because of:

    struct type *func_type = SYMBOL_TYPE (func);

This NULL symbol comes from a list of symbols which was given to
ada_resolve_function (parameter called "syms") which then iterates
over each of them to discard the ones that don't match the actuals:

     for (k = 0; k < nsyms; k += 1)
       {
         struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].symbol));

         if (ada_args_match (syms[k].symbol, args, nargs)
             && (fallback || return_match (type, context_type)))
         [...]
       }

What's really interesting is that, when entering the block above for
the first time, all entries in SYMS have a valid (non-NULL) symbol.
However, once we return from the call to ada_check_typedef, the first
entry of our SYMS table gets set to all zeros:

    (gdb) p syms[0]
    $2 = {symbol = 0x0, block = 0x0}

Hence the call to ada_args_match with a NULL symbol, and the ensuing
SEGV.

To find out why this happen, we need to step back a little and look
at how syms was allocated. This list of symbols comes from a symbol
lookup, which means ada_lookup_symbol_list_worker. We have our first
hint when we look at the function's documentation and see:

    This vector is transient---good only to the next call of
    ada_lookup_symbol_list.

Implementation-wise, this is done by using a static global obstack,
which we just re-initialize each time ada_lookup_symbol_list_worker
gets called:

    obstack_free (&symbol_list_obstack, NULL);
    obstack_init (&symbol_list_obstack);

This property was probably established in order to facilitate the use
of the returned vector, since the users of that function would not have
to worry about releasing that memory when no longer needed. However,
I found during this investigation that it is all to easy to indirectly
trigger another symbol lookup while still using the results of a previous
lookup.

In our particular case, there is the call to ada_check_typedef, which
leads to check_typedef. As it happens, my first symbol had a type which
was a typedef to a stub type, so check_typedef calls lookup_symbol to
find the non-stub version. This in turn eventually leads us back to
ada_lookup_symbol_list_worker, where the first thing it does is free
the memory area when our list of symbols have been residing and then
recreates a new one. in other words, SYMS then becomes a dangling
pointer!

This patch fixes the issue by having ada_lookup_symbol_list_worker
return a copy of the list of symbols, with the responsibility of
deallocating that list now transfered to the users of that list.

More generally speaking, it is absolutely amazing that we haven't seen
consequences of this issue before. This can happen fairly frequently.
For instance, I found that ada-exp.y::write_var_or_type calls
ada_lookup_symbol_list, and then, while processing that list, calls
select_possible_type_sym, which leads to ada_prefer_type, eventually
leading to ada_check_typedef again (via eg. ada_is_array_descriptor_type).

Even more amazing is the fact that, while I was able to produce multiple
scenarios where the corruption occurs, none of them leads to incorrect
behavior at the user level. In other words, it requires a very precise
set of conditions for the corruption to become user-visible, and
despite having a megalarge program where the crash occured, using that
as a template for creating a reproducer did not work (pb goes away).
This is why this patch does not come with a reproducer. On the other hand,
this should not be a problem in terms of testing coverage, as the changes
are made in common areas which, at least for the most part, are routinely
exercised during testing.

gdb/ChangeLog:

        * ada-lang.c (symbol_list_obstack): Delete.
        (resolve_subexp): Make sure "candidates" gets xfree'ed.
        (ada_lookup_symbol_list_worker): Remove the limitation that
        the result is only good until the next call, now making it
        the responsibility of the caller to free the result when no
        longer needed.  Adjust the function's intro comment accordingly.
        (ada_lookup_symbol_list): Adjust the function's intro comment.
        (ada_iterate_over_symbols): Make sure "results" gets xfree'ed.
        (ada_lookup_encoded_symbol, get_var_value): Likewise.
        (_initialize_ada_language): Remove symbol_list_obstack
        initialization.
        * ada-exp.y (block_lookup): Make sure "syms" gets xfree'ed.
        (write_var_or_type, write_name_assoc): Likewise.

Tested on x86_64-linux.

6 years agoFix internal error from command line with unbalanced --start-lib/--end-lib.
Benjamin Peterson [Fri, 1 Dec 2017 20:59:36 +0000 (12:59 -0800)]
Fix internal error from command line with unbalanced --start-lib/--end-lib.

The problem is that while the command line isn't trivially empty,
it contains no input files. As gold tries to configure the number
of threads to use based on the number of input files, this causes
the assertion failure above. Fix this problem by making the logic
in gold.cc more robust and also adding a better error message
about --start-lib to options.cc.

gold/
PR gold/22406
* gold.cc (queue_initial_tasks) Check for number of real input files.
* options.cc (Command_line::process) Check for unterminated --start-lib
options.
* testsuite/Makefile.am: Add new test script.
* testsuite/Makefile.in: Regenerate.
* testsuite/check_empty_command_lines.sh: New test script.

6 years agoFix problem where undef can fail to trigger archive rescan.
Stephen Crane [Fri, 1 Dec 2017 20:10:02 +0000 (12:10 -0800)]
Fix problem where undef can fail to trigger archive rescan.

If a shared library contains an undefined symbol and LTO adds
a new reference to that same undefined symbol, the reference in the new
object added by the plugin would not trigger a rescan of the archive
containing the symbol.

2017-11-17  Stephen Crane  <sjc@immunant.com>

gold/
PR gold/22448
* symtab.cc (Symbol_table::add_from_object): Only rescan for
undefined symbols in regular, not dynamic, objects.

6 years agoAdd support for the readnever concept
Sergio Durigan Junior [Fri, 24 Nov 2017 21:56:08 +0000 (16:56 -0500)]
Add support for the readnever concept

The purpose of this concept is to turn the load of debugging
information off, either globally (via the '--readnever' option), or
objfile-specific.  The implementation proposed here is an extension of
the patch distributed with Fedora GDB; looking at the Fedora patch
itself and the history, one can see some reasons why it was never
resubmitted:

  - The patch appears to have been introduced as a workaround, at
    least initially;
  - The patch is far from perfect, as it simply shunts the load of
    DWARF debugging information, without really worrying about the
    other debug format.
  - Who really does non-symbolic debugging anyways?

One use of this feature is when a user simply wants to do the
following sequence: attach, dump core, detach.  Loading the debugging
information in this case is an unnecessary cause of delay.

This patch expands the version shipped with Fedora GDB in order to
make the feature available for all the debuginfo backends, not only
for DWARF.  It also implements a per-objfile flag which can be
activated by using the "-readnever" command when using the
'add-symbol-file' or 'symbol-file' commands.

It's also worth mentioning that this patch tests whether GDB correctly
fails to initialize if both '--readnow' and '--readnever' options are
passed.

Tested on the BuildBot.

gdb/ChangeLog:

2017-12-01  Andrew Cagney  <cagney@redhat.com>
    Joel Brobecker  <brobecker@adacore.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>

* NEWS (Changes since GDB 8.0: Mention new '--readnever'
feature.
* coffread.c (coff_symfile_read): Do not map over sections with
'coff_locate_sections' if readnever is on.
* dwarf2read.c (dwarf2_has_info): Return 0 if
readnever is on.
* elfread.c (elf_symfile_read): Do not map over sections with
'elf_locate_sections' if readnever is on.
* main.c (validate_readnow_readnever): New function.
(captured_main_1): Add support for --readnever.
(print_gdb_help): Document --readnever.
* objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New
flag.
* symfile.c (readnever_symbol_files): New global.
(symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when
'READNEVER_SYMBOL_FILES' is set.
(validate_readnow_readnever): New function.
(symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(add_symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(_initialize_symfile): Document new '-readnever' option for
both 'symbol-file' and 'add-symbol-file' commands.
* top.h (readnever_symbol_files): New extern global.
* xcoffread.c (xcoff_initial_scan): Do not read debug
information if readnever is on.

gdb/doc/ChangeLog:

2017-12-01  Andrew Cagney  <cagney@redhat.com>
    Joel Brobecker  <brobecker@adacore.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>

* gdb.texinfo (File Options): Document --readnever.
(Commands to Specify Files): Likewise, for 'symbol-file' and
'add-symbol-file'.

gdb/testsuite/ChangeLog:

2017-12-01  Joel Brobecker  <brobecker@adacore.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>
    Pedro Alves  <palves@redhat.com>

* gdb.base/readnever.c, gdb.base/readnever.exp: New files.

6 years agoUse consistent types for holding instructions, instruction masks, etc.
Peter Bergner [Fri, 1 Dec 2017 17:20:15 +0000 (11:20 -0600)]
Use consistent types for holding instructions, instruction masks, etc.

include/
* opcode/ppc.h (PPC_INT_FMT): Define.
(struct powerpc_opcode) <opcode>: Update type.
(struct powerpc_opcode) <mask>: Likewise.
(struct powerpc_opcode) <bitm>: Likewise.
(struct powerpc_opcode) <insert>: Likewise.
(struct powerpc_opcode) <extract>: Likewise.
(ppc_optional_operand_value): Likewise.

gas/
* config/tc-ppc.c (last_insn): Update type.
(insn_validate) <omask, mask>: Likewise.
(ppc_setup_opcodes) <mask, right_bit>: Likewise.
<PRINT_OPCODE_TABLE>: Update types and printf format specifiers.
(ppc_insert_operand): Update return and argument types and remove
unneeded type casts.
<min, max, right, tmp>: Update type.
(md_assemble): Remove unneeded type casts.
<insn, val, tmp_insn>: Update type.

opcodes/
* opcodes/ppc-dis.c (disassemble_init_powerpc): Fix white space.
(operand_value_powerpc): Update return and argument type.
<value, top>: Update type.
(skip_optional_operands): Update argument type.
(lookup_powerpc): Likewise.
(lookup_vle): Likewise.
<table_opcd, table_mask, insn2>: Update type.
(lookup_spe2): Update argument type.
<table_opcd, table_mask, insn2>: Update type.
(print_insn_powerpc) <insn, value>: Update type.
Use PPC_INT_FMT for printing instructions and operands.
* opcodes/ppc-opc.c (insert_arx, extract_arx, insert_ary, extract_ary,
insert_rx, extract_rx, insert_ry, extract_ry, insert_bat, extract_bat,
insert_bba, extract_bba, insert_bdm, extract_bdm, insert_bdp,
extract_bdp, valid_bo_pre_v2, valid_bo_post_v2, valid_bo, insert_bo,
extract_bo, insert_boe, extract_boe, insert_dcmxs, extract_dcmxs,
insert_dxd, extract_dxd, insert_dxdn, extract_dxdn, insert_fxm,
extract_fxm, insert_li20, extract_li20, insert_ls, extract_ls,
insert_esync, extract_esync, insert_mbe, extract_mbe, insert_mb6,
extract_mb6, extract_nb, insert_nbi, insert_nsi, extract_nsi,
insert_ral, extract_ral, insert_ram, extract_ram, insert_raq,
extract_raq, insert_ras, extract_ras, insert_rbs, extract_rbs,
insert_rbx, extract_rbx, insert_sci8, extract_sci8, insert_sci8n,
extract_sci8n, insert_sd4h, extract_sd4h, insert_sd4w, extract_sd4w,
insert_oimm, extract_oimm, insert_sh6, extract_sh6, insert_spr,
extract_spr, insert_sprg, extract_sprg, insert_tbr, extract_tbr,
insert_xt6, extract_xt6, insert_xtq6, extract_xtq6, insert_xa6,
extract_xa6, insert_xb6, extract_xb6, insert_xb6s, extract_xb6s,
insert_xc6, extract_xc6, insert_dm, extract_dm, insert_vlesi,
extract_vlesi, insert_vlensi, extract_vlensi, insert_vleui,
extract_vleui, insert_vleil, extract_vleil, insert_evuimm1_ex0,
extract_evuimm1_ex0, insert_evuimm2_ex0, extract_evuimm2_ex0,
insert_evuimm4_ex0, extract_evuimm4_ex0, insert_evuimm8_ex0,
extract_evuimm8_ex0, insert_evuimm_lt8, extract_evuimm_lt8,
insert_evuimm_lt16, extract_evuimm_lt16, insert_rD_rS_even,
extract_rD_rS_even, insert_off_lsp, extract_off_lsp, insert_off_spe2,
extract_off_spe2, insert_Ddd, extract_Ddd): Update types.
(OP, OPTO, OPL, OPVUP, OPVUPRT, A, AFRALFRC_MASK, B, BD8, BD8IO, BD15,
BD24, BBO, Y_MASK  , AT1_MASK, AT2_MASK, BBOCB, C_LK, C, CTX, UCTX,
DX, EVSEL, IA16, I16A, I16L, IM7, LI20, MME, MD, MDS, SC, SC_MASK,
SCI8, SCI8BF, SD4, SE_IM5, SE_R, SE_RR, VX, VX_LSP, VX_RA_CONST,
VX_RB_CONST, VX_SPE_CRFD, VX_SPE2_CLR, VX_SPE2_SPLATB, VX_SPE2_OCTET,
VX_SPE2_DDHH, VX_SPE2_HH, VX_SPE2_EVMAR, VX_SPE2_EVMAR_MASK, VXA,
VXR, VXASH, X, EX, XX2, XX3, XX3RC, XX4, Z, XWRA_MASK, XLRT_MASK,
XRLARB_MASK, XLRAND_MASK, XRTLRA_MASK, XRTLRARB_MASK, XRTARARB_MASK,
XRTBFRARB_MASK, XOPL, XOPL2, XRCL, XRT, XRTRA, XCMP_MASK, XCMPL_MASK,
XTO, XTLB, XSYNC, XEH_MASK, XDSS, XFL, XISEL, XL, XLO, XLYLK, XLOCB,
XMBAR, XO, XOPS, XS, XFXM, XSPR, XUC, XW, APU): Update types in casts.

6 years agoFix dependency tracking for objects in subdirectories
Tom Tromey [Thu, 30 Nov 2017 18:49:27 +0000 (11:49 -0700)]
Fix dependency tracking for objects in subdirectories

On irc, Pedro pointed out that dependencies for objects in
subdirectories didn't seem to be working.

The bug was that the "-include" for .deps files was using the wrong file
name for subdirectory objects; e.g., for cli/cli-decode.o it was trying
to open .deps/cli/cli-decode.o, whereas the correct file is
cli/.deps/cli-decode.o.

This patch changes how the dep files are found.  Tested by touching a
source file and rebuilding cli/cli-decode.o.

2017-12-01  Tom Tromey  <tom@tromey.com>

* Makefile.in (all_deps_files): New variable.
Include .Po files using all_deps_files.

6 years agoUpdate GDB's list of maintainers to reflect today's reality
Joel Brobecker [Fri, 1 Dec 2017 13:35:56 +0000 (08:35 -0500)]
Update GDB's list of maintainers to reflect today's reality

gdb/ChangeLog:

       * MAINTAINERS: Update list of maintainers, moving those who
       stepped down or became inactive to the "Past Maintainers"
       section.

6 years agox86: Print dynreloc in readonly section for map file output
H.J. Lu [Fri, 1 Dec 2017 12:01:11 +0000 (04:01 -0800)]
x86: Print dynreloc in readonly section for map file output

This fixed:

FAIL: DT_TEXTREL map file warning

on Linux/x86.

* elfxx-x86.c (_bfd_x86_elf_readonly_dynrelocs): Print dynamic
relocation in readonly section for map file output.

6 years agoReplace mail address with the URL in copyright header
Yao Qi [Fri, 1 Dec 2017 11:34:14 +0000 (11:34 +0000)]
Replace mail address with the URL in copyright header

The copyright header in most of GDB files were changed from mail address
to the URL in the conversion to GPLv3 in Aug 2007.  However, some files
still use mail address instead of the URL.  This patch fixes them.

gdb/testsuite:

2017-12-01  Yao Qi  <yao.qi@linaro.org>

* gdb.arch/aarch64-atomic-inst.exp: Replace mail address with
the URL in copyright header.
* gdb.arch/aarch64-fp.exp: Likewise.
* gdb.arch/ppc64-atomic-inst.exp: Likewise.
* gdb.arch/ppc64-isa207-atomic-inst.exp: Likewise.
* gdb.base/expand-psymtabs.exp: Likewise.
* gdb.cp/expand-psymtabs-cxx.exp: Likewise.
* gdb.fortran/common-block.exp: Likewise.
* gdb.fortran/common-block.f90: Likewise.
* gdb.fortran/logical.exp: Likewise.
* gdb.fortran/vla-datatypes.f90: Likewise.
* gdb.fortran/vla-sub.f90: Likewise.

6 years agoCheck return value of bfd_new_link_order
Tobias Ulmer [Fri, 1 Dec 2017 08:55:19 +0000 (19:25 +1030)]
Check return value of bfd_new_link_order

* ldwrite.c (build_link_order): Check return value of all
bfd_new_link_order calls.

6 years agoAdd --strip-unneeded to objcopy synopsis
Oleksandr Pikozh [Fri, 1 Dec 2017 07:10:55 +0000 (17:40 +1030)]
Add --strip-unneeded to objcopy synopsis

* doc/binutils.texi: Add --strip-unneeded to objcopy synopsis.

6 years agoweak alias test
Alan Modra [Fri, 1 Dec 2017 03:08:01 +0000 (13:38 +1030)]
weak alias test

This adds the test I was using when testing 60d67dc8.

* testsuite/ld-elfweak/alias.c,
* testsuite/ld-elfweak/alias.dat,
* testsuite/ld-elfweak/aliasmain.c,
* testsuite/ld-elfweak/weakref1.c,
* testsuite/ld-elfweak/weakref2.c: New test.
* testsuite/ld-elfweak/elfweak.exp: Run it.  Don't return on fails,
attempt other tests.

6 years agoreadonly_dynrelocs
Alan Modra [Thu, 30 Nov 2017 09:16:17 +0000 (19:46 +1030)]
readonly_dynrelocs

In early October, HJ Lu added support for a number of targets to "Dump
dynamic relocation in read-only section with minfo".  This extends
that support to more targets, displays the symbol involved, and splits
the existing function that sets TEXTREL into a "readonly_dynrelocs"
and "maybe_set_textrel" function.  I'll need "readonly_dynrelocs" if I
ever get around to fixing "pr22374 function pointer initialization"
fails.

am33_2.0, arc, bfin, hppa64, mn10300, and nios2 fail to mark a binary
needing text relocations with DT_TEXTREL.  That's not good.  xtensa also
fails to do so but complains about "dangerous relocation: dynamic
relocation in read-only section" so I reckon that is fine and have
marked the test as an xfail.  The other targets need maintainer
attention.

Curiously, the map file dump wasn't added for x86, so the map test
currently fail on x86.  It also fails on alpha, am33_2.0, arc, bfin,
hppa64, ia64, m68k, mips, mn10300, nios2, score and vax.  cris
complains with "tmpdir/textrel.o, section .rodata: relocation
R_CRIS_32 should not be used in a shared object; recompile with -fPIC"
so I've marked it as an xfail.

bfd/
* elf32-hppa.c (maybe_set_textrel): Print symbol for map file output.
* elf32-ppc.c (maybe_set_textrel): Likewise.
* elf64-ppc.c (maybe_set_textrel): Likewise.
* elf32-arm.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing..
(elf32_arm_readonly_dynrelocs): ..this.
* elf32-lm32.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-m32r.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-metag.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-nds32.c: Delete unnecessary forward declarations.
(readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-or1k.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-s390.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-sh.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-tic6x.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing..
(elf32_tic6x_readonly_dynrelocs): ..this.
* elf32-tilepro.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf64-s390.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elfnn-aarch64.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing..
(aarch64_readonly_readonly_dynrelocs): ..this.
* elfnn-riscv.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elfxx-sparc.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elfxx-tilegx.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
ld/
* testsuite/ld-elf/shared.exp: Run new textrel tests.
* testsuite/ld-elf/textrel.map: New file.
* testsuite/ld-elf/textrel.rd: New file.
* testsuite/ld-elf/textrel.s: New file.
* testsuite/ld-elf/textrel.warn: New file.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 1 Dec 2017 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoNew gdb.ada/repeat_dyn testcase.
Joel Brobecker [Thu, 30 Nov 2017 23:41:55 +0000 (18:41 -0500)]
New gdb.ada/repeat_dyn testcase.

This patch introduces a testcase that exercises a scenario
which used to trigger an internal-error, but no longer does:

Consider the following array:

   type Small is new Integer range Ident (1) .. Ident (10);
   type Table is array (1 .. 3) of Small;
   A1 : Table := (3, 5, 8);

The particularity of this array is that the type of each element
is a range type whose bounds are dynamic, since they depend on
the value returned by Ident (1) and Ident (10). Trying to apply
the repeat operator ('@') on one of its elements used to yield
an internal error:

    (gdb) p a1(1)@3
    $1 =
    /[...]/gdbtypes.c:4512: internal-error:
    copy_type: Assertion `TYPE_OBJFILE_OWNED (type)' failed.

Although the issue no longer appears, the testcase is still
interesting to have.

gdb/testsuite/ChangeLog:

        * gdb.ada/repeat_dyn: New testcase.

Tested on x86_64-linux with clean results.

6 years agoFix internal error in fix_errata on aarch64.
Peter Smith [Thu, 30 Nov 2017 23:07:26 +0000 (15:07 -0800)]
Fix internal error in fix_errata on aarch64.

The addresses of erratum stubs can be changed by relaxation passes, and
need to be updated.

gold/
PR gold/20765
* aarch64.cc (Aarch64_relobj::update_erratum_address): New method.
(AArch64_relobj::scan_errata): Update addresses in stub table after
relaxation pass.

6 years agoFix problem where erratum stubs are not always applied.
Cary Coutant [Thu, 30 Nov 2017 21:44:28 +0000 (13:44 -0800)]
Fix problem where erratum stubs are not always applied.

I checked over the results of applying --fix-cortex-a53-843419 to
a very large program (gitit) with two stub tables and thousands
of erratum fixes. I noticed that all the erratum_stubs were being
created but about 1/3 of them were being skipped over by
fix_errata_and_relocate_erratum_stubs(). By skipped over I mean
no branch relocation or adrp -> adr transformation was applied to
the erratum address, leaving the erratum_stub unreachable, and
with a branch with a 0 immediate.

The root cause of the skipped over erratum_stubs is
Erratum_stub::invalidate_erratum_stub() that is used to set
relobj_ to NULL when an erratum_stub has been processed.
Unfortunately relobj_ is used in operator<() so altering relobj
makes the results from erratum_stubs_.lower_bound() as used in
find_erratum_stubs_for_input_section() unreliable.

2017-11-30  Peter Smith  <peter.smith@linaro.org>
    Cary Coutant  <ccoutant@gmail.com>

gold/
PR gold/20765
* aarch64.cc (Erratum_stub::invalidate_erratum_stub): Use erratum_insn_
instead of relobj_ to invalidate the stub.
(Erratum_stub::is_invalidated_erratum_stub): Likewise.

6 years agoFix segfault in relocate_erratum_stub on aarch64.
Peter Smith [Thu, 30 Nov 2017 21:30:58 +0000 (13:30 -0800)]
Fix segfault in relocate_erratum_stub on aarch64.

The fix for PR21868 (an internal error when --fix-cortex-a53-843419
is applied) has a small mistake in it. When the stub_owner section
needs an erratum fix an incorrect address for the stubs for the section
is given to relocate_erratum_stub. If we are lucky we will get a segfault;
if we aren't, an incorrect patch or data corruption is possible.
The error is visible in PR21868, but the side-effects aren't fatal.

gold/
PR gold/22233
* aarch64.cc (AArch64_relobj::fix_errata_and_relocate_erratum_stubs):
Fix calculation of stub address.

6 years agoPR22533, dynamic relocs generated for weak aliases
Alan Modra [Thu, 30 Nov 2017 21:23:16 +0000 (07:53 +1030)]
PR22533, dynamic relocs generated for weak aliases

This cleans up yet more craziness with non_got_ref.

PR 22533
* elf32-hppa.c (elf32_hppa_copy_indirect_symbol): Don't do anything
special with non_got_ref for weak aliases.
(elf32_hppa_check_relocs): Tweak setting of non_got_ref.
(elf32_hppa_adjust_dynamic_symbol): When initialising weak aliases,
don't uselessly copy non_got_ref.  Clear dyn_relocs instead if
strong symbol is allocated in dynbss.  Tidy comments.
(elf32_hppa_relocate_section): Comment fix.
* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Don't do anything
special with non_got_ref for weak aliases.
(ppc_elf_adjust_dynamic_symbol): When initialising weak aliases,
don't uselessly copy non_got_ref.  Clear dyn_relocs instead if
strong symbol is allocated in dynbss.  Tidy comments.
* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Don't do anything
special with non_got_ref for weak aliases.
(ppc64_elf_adjust_dynamic_symbol): When initialising weak aliases,
don't uselessly copy non_got_ref.  Clear dyn_relocs instead if
strong symbol is allocated in dynbss.  Tidy comments.

6 years ago[spu] Some additional test fixes
Ulrich Weigand [Thu, 30 Nov 2017 17:35:54 +0000 (18:35 +0100)]
[spu] Some additional test fixes

Now that the ppc64 breakpoint regression is fixed, running the
gdb.cell test suite showed a few more test case problems, caused
by tests that haven't been updated to adapt to GDB changes.

gdb/testsuite/ChangeLog:
2017-11-30  Ulrich Weigand  <uweigand@de.ibm.com>

* gdb.cell/gcore.exp: Fix typo when setting spu_bin.
Update for changed thread numbering.
* gdb.cell/bt.exp: Update for changed GDB output.

6 years agoUse boards/local-board.exp more
Simon Marchi [Thu, 30 Nov 2017 16:39:31 +0000 (11:39 -0500)]
Use boards/local-board.exp more

local-board.exp was introduced recently, containing the code required to
force the gdbserver boards to be non-remote (from the DejaGNU point of
view).  Other board files use the same trick of forcing isremote to 0.
Instead of doing it by hand in each file, include local-board.exp.

gdb/testsuite/ChangeLog:

* boards/cc-with-tweaks.exp: Include local-board.exp instead of
setting isremote by hand.
* boards/dwarf4-gdb-index.exp: Likewise.
* boards/fission.exp: Likewise.
* boards/stabs.exp: Likewise.

6 years agoFix gdb.linespec/cpls-ops.exp on 32-bit
Pedro Alves [Thu, 30 Nov 2017 16:32:10 +0000 (16:32 +0000)]
Fix gdb.linespec/cpls-ops.exp on 32-bit

gdb.linespec/cpls-ops.exp is currently failing on x86-64 -m32 and other
32-bit ports:

 b test_op_new::operator new(unsigned int) FAIL: gdb.linespec/cpls-ops.exp: operator-new: tab complete "b test_op_new::operator" (timeout)
 ^CQuit
 (gdb) complete b test_op_new::operator
 b test_op_new::operator new(unsigned int)
 (gdb) FAIL: gdb.linespec/cpls-ops.exp: operator-new: cmd complete "b test_op_new::operator"

The problem is simply that the testcase incorrectly assumes that
size_t is "unsigned long".

Fix this by extracting the right type with the "ptype" command.

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

* gdb.linespec/cpls-ops.exp
(check_explicit_skips_function_argument): Extract the underlying
type of size_t instead of hardcoding it.

6 years agoRemove ioctl-based procfs support on Solaris
Rainer Orth [Thu, 30 Nov 2017 15:05:30 +0000 (16:05 +0100)]
Remove ioctl-based procfs support on Solaris

This is the previously mentioned patch to get rid of
unstructured/ioctl-based procfs support in procfs.c.  Given that support
for structured procfs was introduced in Solaris 2.6 back in 1997 and
we're just removing support for Solaris < 10, there's no point in
carrying that baggage (and tons of support for IRIX and OSF/1 as well)
around any longer.

Most of the patch should be straightforward (removing support for
!NEW_PROC_API, non-Solaris OSes and pre-Solaris 10 quirks).

Only a few points need explanations:

* <sys/syscall.h> was already included unconditionally in most places,
  so there's no need to have guards in a few remaining ones.

* configure.host already obsoletes i?86-*-sysv4.2, i?86-*-sysv5, so
  NEW_PROC_API detection for those in configure.ac can go.

* I'm still including <sys/procfs.h> with #define _STRUCTURED_PROC 1.
  Theoretically, it would be better to include <procfs.h> on Solaris
  (which includes that define), but that breaks the build over
  <procfs.h> vs. gdb's "procfs.h", and doesn't exist on Linux.

* I've regenerated syscall_table[] in proc-events.c with a small script
  from Solaris 10, 11.3, 11.4 <sys/syscall.h>, so there should be no
  traces of older Solaris versions and other OSes left.

* prsysent_t and DYNAMIC_SYSCALLS was only used for AIX 5, but AIX
  doesn't use procfs.c any longer, so all related code can go.

The patch was generated with diff -w so one can easier see changes
without being distracted by simple reindentations.

So far, it has only been compiled and smoke-tested on
amd64-pc-solaris2.1[01], sparcv9-sun-solaris2.1[01], and
x86_64-pc-linux-gnu.  Certainly needs more testing (Solaris 11.3
vs. 11.4, 32-bit gdb, testsuite once I've figured out what's wrong on
Solaris 10 etc.), but it's enough to get a first impression how much
cleanup is possible here.

* configure.ac Don't check for sys/fault.h, sys/syscall.h,
sys/proc.h.
(NEW_PROC_API): Remove.
(prsysent_t, pr_sigset_t, pr_sigaction64_t, pr_siginfo64_t):
Likewise.
* common/common.m4 (GDB_AC_COMMON): Don't check for sys/syscall.h.
* configure: Regenerate.
* config.in: Regenerate.
* gdbserver/configure: Regenerate.
* gdbserver/config.in: Regenerate.

* i386-sol2-nat.c (_initialize_amd64_sol2_nat): Remove
NEW_PROC_API test.
* sparc-sol2-nat.c (_initialize_sparc_sol2_nat): Likewise.

* linux-btrace.c: Remove HAVE_SYS_SYSCALL_H test.

* proc-api.c: Remove !NEW_PROC_API support.
Remove HAVE_SYS_PROC_H and HAVE_SYS_USER_H tests.
Remove tests for macros always defined on Solaris.
* proc-events.c: Remove !NEW_PROC_API support.
Remove Remove HAVE_SYS_SYSCALL_H, HAVE_SYS_PROC_H and
HAVE_SYS_USER_H tests.
(init_syscall_table): Remove non-Solaris syscalls.
Remove tests for syscalls present on all Solaris versions.
Add missing Solaris 10+ syscalls.
(signal_table): Remove non-Solaris signals.
Remove tests for signals present on all Solaris versions.
(fault_table): Remove non-Solaris faults.
Remove tests for faults present on all Solaris versions.
* proc-flags.c: Remove !NEW_PROC_API support.
(pr_flag_table): Remove non-Solaris and pre-Solaris 7 comments.
Remove non-Solaris flags.
* proc-why.c: Remove !NEW_PROC_API support.
(pr_why_table): Remove meaningless comments.
Remove tests for reasons present on all Solaris versions.
Remove OSF/1 cases.
(proc_prettyfprint_why): Likewise.

* procfs.c: Remove !NEW_PROC_API and DYNAMIC_SYSCALLS support.
Remove HAVE_SYS_FAULT_H and HAVE_SYS_SYSCALL_H tests.
Remove WA_READ test, IRIX watchpoint support.
(gdb_sigset_t, gdb_sigaction_t, gdb_siginfo_t): Replace by base
types.  Change users.
(gdb_praddset, gdb_prdelset, gdb_premptysysset, gdb_praddsysset)
(gdb_prdelset, gdb_pr_issyssetmember): Replace by base macros.
Change callers.
Remove CTL_PROC_NAME_FMT tests.
(gdb_prstatus_t, gdb_lwpstatus_t): Replace by base types.  Change
users.
(sysset_t_size): Remove.  Use sizeof (sysset_t) in callers.
Remove PROCFS_DONT_PIOCSSIG_CURSIG support.
(proc_modify_flag): Replace GDBRESET by PCUNSET.
Remove PR_ASYNC, PR_KLC tests.
(proc_unset_inherit_on_fork): Remove PR_ASYNC test.
(proc_parent_pid): Remove PCWATCH etc. tests.
(proc_set_watchpoint): Remove !PCWATCH && !PIOCSWATCH support.
Remove PCAGENT test.
(proc_get_nthreads) [PIOCNTHR && PIOCTLIST]: Remove.
Remove SYS_lwpcreate || SYS_lwp_create test.
(proc_get_current_thread): Likewise.
[PIOCNTHR && PIOCTLIST]: Remove.
[PIOCLSTATUS]: Remove.
(procfs_debug_inferior): Remove non-Solaris cases, conditionals.
[PRFS_STOPEXEC]: Remove.
(syscall_is_lwp_exit): Remove non-Solaris cases, conditionals.
(syscall_is_exit): Likewise.
(syscall_is_exec): Likewise.
(syscall_is_lwp_create): Likewise.
Remove SYS_syssgi support.
(procfs_wait): Remove PR_ASYNC, !PIOCSSPCACT tests.
[SYS_syssgi]: Remove.
Remove non-Solaris cases, conditionals.
(unconditionally_kill_inferior) [PROCFS_NEED_PIOCSSIG_FOR_KILL]:
Remove.
(procfs_init_inferior) [SYS_syssgi]: Remove.
(procfs_set_exec_trap) [PRFS_STOPEXEC]: Remove.
(procfs_inferior_created) [SYS_syssgi]: Remove.
(procfs_set_watchpoint): Remove !AIX5 test.
(procfs_stopped_by_watchpoint): Remove FLTWATCH test, FLTKWATCH
case.
(mappingflags) [MA_PHYS]: Remove.
(info_mappings_callback): Remove PCAGENT test.
Remove PIOCOPENLWP || PCAGENT test.

6 years agox86: derive DispN from BaseIndex
Jan Beulich [Thu, 30 Nov 2017 10:48:13 +0000 (11:48 +0100)]
x86: derive DispN from BaseIndex

BaseIndex implies - with the exception of string instructions the
optional presence of a displacement. This is almost completely uniform
for all instructions (the sole exception being MPX ones, which don't
allow 16-bit addressing and hence Disp16), so there's no point in
explicitly stating this in the main opcode table. Drop those explict
specifications in favor of adding logic to i386-gen, shrinking the
table size quite a bit and hence making it more readable.

The opcodes/i386-tbl.h changes are due to a few cases where pointless
Disp* still hadn't been removed from their insns.