binutils-gdb.git
7 years agocorelow: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Fri, 17 Mar 2017 17:55:52 +0000 (13:55 -0400)]
corelow: Use ptid from regcache instead of inferior_ptid

gdb/ChangeLog:

* corelow.c (get_core_register_section): Use ptid from regcache,
update doc.

7 years agobsd-uthread: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Fri, 17 Mar 2017 17:55:51 +0000 (13:55 -0400)]
bsd-uthread: Use ptid from regcache instead of inferior_ptid

This is one of the rare to_fetch/store_registers implementations that will
still rely (for now) on inferior_ptid (because of the memory read/write
operations).  We therefore have to add a save/restore of inferior_ptid.  We'll
be able to remove it when we make the memory operations accept the ptid as a
parameter.

gdb/ChangeLog:

* bsd-uthread.c (bsd_uthread_fetch_registers,
bsd_uthread_store_registers): Use ptid from regcache, set and
restore inferior_ptid.

7 years agoarm-nbsd-nat: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Fri, 17 Mar 2017 17:55:50 +0000 (13:55 -0400)]
arm-nbsd-nat: Use ptid from regcache instead of inferior_ptid

gdb/ChangeLog:

* arm-nbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register,
fetch_fp_regs, store_register, store_regs, store_fp_register,
store_fp_regs): Use ptid from regcache.

7 years agoarm-linux-nat.c: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Fri, 17 Mar 2017 17:55:49 +0000 (13:55 -0400)]
arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid

gdb/ChangeLog:

* arm-linux-nat.c (fetch_fpregs, store_fpregs, fetch_regs,
store_regs, fetch_wmmx_regs, store_wmmx_regs, fetch_vfp_regs,
store_vfp_regs): Use ptid from regcache.

7 years agoFix displaying the value associated a GNU BUILD note that uses an ascii name.
Nick Clifton [Fri, 17 Mar 2017 17:36:51 +0000 (17:36 +0000)]
Fix displaying the value associated a GNU BUILD note that uses an ascii name.

* readelf.c (print_gnu_build_attribute_name): Fix off by one error
printing the value for a build note with an ascii name.

7 years agoPR remote/21188: Fix remote serial timeout
Pedro Alves [Fri, 17 Mar 2017 16:08:12 +0000 (16:08 +0000)]
PR remote/21188: Fix remote serial timeout

As Gareth McMullin <gareth@blacksphere.co.nz> reports at
<https://sourceware.org/ml/gdb-patches/2017-02/msg00560.html>, the
timeout mechanism in ser-unix.c was broken by commit 048094acc
("target remote: Don't rely on immediate_quit (introduce quit
handlers)").

Instead of applying a local fix, and since we now finally always use
interrupt_select [1], let's get rid of hardwire_readchar entirely, and
use ser_base_readchar instead, which has similar timeout handling,
except for the bug.

Smoke tested with:

 $ socat -d -d pty,raw,echo=0 pty,raw,echo=0
 2017/03/14 14:08:13 socat[4994] N PTY is /dev/pts/14
 2017/03/14 14:08:13 socat[4994] N PTY is /dev/pts/15
 2017/03/14 14:08:13 socat[4994] N starting data transfer loop with FDs [3,3] and [5,5]
 $ gdbserver /dev/pts/14 PROG
 $ gdb PROG -ex "tar rem /dev/pts/15"

and then a few continues/ctrl-c's, plus killing gdbserver and socat.

[1] - See FIXME comments being removed.

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

PR remote/21188
* ser-base.c (ser_base_wait_for): Add comment.
(do_ser_base_readchar): Improve comment based on the ser-unix.c's
version.
* ser-unix.c (hardwire_raw): Remove reference to
scb->current_timeout.
(wait_for, do_hardwire_readchar, hardwire_readchar): Delete.
(hardwire_ops): Install ser_base_readchar instead of
hardwire_readchar.
* serial.h (struct serial) <current_timeout, timeout_remaining>:
Remove fields.

7 years agoFix PR gdb/19637: bound_registers.py: Add support for Python 3
Jonah Graham [Fri, 17 Mar 2017 14:57:44 +0000 (14:57 +0000)]
Fix PR gdb/19637: bound_registers.py: Add support for Python 3

Fix this the same way gdb/python/lib/gdb/printing.py handles it.

gdb/Changelog:
2017-03-17  Jonah Graham  <jonah@kichwacoders.com>

PR gdb/19637
* python/lib/gdb/printer/bound_registers.py: Add support for
Python 3.

7 years agoE6500 spr mnemonics
Alan Modra [Fri, 17 Mar 2017 08:36:12 +0000 (19:06 +1030)]
E6500 spr mnemonics

PR 21248
* ppc-opc.c (powerpc_opcodes): Enable mfivor32, mfivor33,
mtivor32, and mtivor33 for e6500.  Move mfibatl and mfibatu after
those spr mnemonics they alias.  Similarly for mtibatl, mtibatu.

7 years agold sec64k test fix
Alan Modra [Tue, 14 Mar 2017 11:31:34 +0000 (22:01 +1030)]
ld sec64k test fix

* testsuite/ld-elf/sec64k.exp: Don't run on h8300 and ip2k.

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

7 years agoBig-endian targets: Don't ignore offset into DW_OP_stack_value
Andreas Arnez [Thu, 16 Mar 2017 18:50:24 +0000 (19:50 +0100)]
Big-endian targets: Don't ignore offset into DW_OP_stack_value

Recently I fixed a bug that caused a DW_OP_implicit_pointer with non-zero
offset into a DW_OP_implicit_value to be handled incorrectly on big-endian
targets.  GDB ignored the offset and copied the wrong bytes:

  https://sourceware.org/ml/gdb-patches/2017-01/msg00251.html

But there is still a similar issue when a DW_OP_implicit_pointer points
into a DW_OP_stack_value instead; and again, the offset is ignored.  There
is an important difference, though: While implicit values are treated like
blocks of data and anchored at the lowest-addressed byte, stack values
traditionally contain integer numbers and are anchored at the *least
significant* byte.  Also, stack values do not come in varying sizes, but
are cut down appropriately when used.  Thus, on big-endian targets the
scenario looks like this (higher addresses shown right):

  |<- - - - - Stack value - - - - - - ->|
                  |                     |
                  |<- original object ->|
                  |
                  | offset ->|####|
      ^^^^
                              de-referenced
      implicit pointer

(Note how the original object's size influences the position of the
de-referenced implicit pointer within the stack value.  This is not the
case for little-endian targets, where the original object starts at offset
zero within the stack value.)

This patch implements the logic indicated in the above diagram and adds an
appropriate test case.  A new function dwarf2_fetch_die_type_sect_off is
added; it is used for retrieving the original object's type, so its size
can be determined.  That type is passed to dwarf2_evaluate_loc_desc_full
via a new parameter.

gdb/ChangeLog:

* dwarf2loc.c (indirect_synthetic_pointer): Get data type of
pointed-to DIE and pass it to dwarf2_evaluate_loc_desc_full.
(dwarf2_evaluate_loc_desc_full): New parameter subobj_type; rename
byte_offset to subobj_byte_offset.  Fix the handling of
DWARF_VALUE_STACK on big-endian targets when coming via an
implicit pointer.
(dwarf2_evaluate_loc_desc): Adjust call to
dwarf2_evaluate_loc_desc_full.
* dwarf2loc.h (dwarf2_fetch_die_type_sect_off): New declaration.
* dwarf2read.c (dwarf2_fetch_die_type_sect_off): New function.

gdb/testsuite/ChangeLog:

* lib/dwarf.exp: Add support for DW_OP_implicit_pointer.
* gdb.dwarf2/nonvar-access.exp: Add test for stack value location
and implicit pointer into such a location.

7 years agogdb.python/py-lazy-string (pointer): Really add new typedef.
Doug Evans [Thu, 16 Mar 2017 17:43:21 +0000 (10:43 -0700)]
gdb.python/py-lazy-string (pointer): Really add new typedef.

Somehow got dropped in earlier commit.

gdb/testsuite/ChangeLog:

* gdb.python/py-lazy-string (pointer): Really add new typedef.

7 years agoRemove collision markers from earlier commit
Doug Evans [Thu, 16 Mar 2017 17:39:26 +0000 (10:39 -0700)]
Remove collision markers from earlier commit

7 years agoAdd support for a GNU BUILD note type to record the enum size.
Nick Clifton [Thu, 16 Mar 2017 16:44:55 +0000 (16:44 +0000)]
Add support for a GNU BUILD note type to record the enum size.

include * elf/common.h (GNU_BUILD_ATTRIBUTE_SHORT_ENUM): New GNU BUILD
note type.

binutils * readelf.c (print_gnu_build_attribute_name): Add support for
GNU_BUILD_ATTRIBUTE_SHORT_ENUM.

7 years agoSupport CBNZ, CBZ, REV, REV16 and REVSH in arm process record
Yao Qi [Thu, 16 Mar 2017 16:35:18 +0000 (16:35 +0000)]
Support CBNZ, CBZ, REV, REV16 and REVSH in arm process record

This patch adds the support for these instructions in arm process
record.

gdb:

2017-03-16  Yao Qi  <yao.qi@linaro.org>

* arm-tdep.c (thumb_record_misc): Decode CBNZ, CBZ, REV16,
and REVSH instructions.

7 years agoFix arm process record for some instructions
Yao Qi [Thu, 16 Mar 2017 16:35:18 +0000 (16:35 +0000)]
Fix arm process record for some instructions

I look at some fails in gdb.reverse/solib-precsave.exp in -mthumb,
they are caused by some bugs on decoding these three instructions,
uxtb, ldr and mrc.  This patch adds unit tests against these three
instructions, and fix these bugs by re-organizing the code to match
the table in ARM ARM.

gdb:

2017-03-16  Yao Qi  <yao.qi@linaro.org>

* arm-tdep.c [GDB_SELF_TEST]: include "selftests.h".
(arm_record_test): Declare.
(_initialize_arm_tdep) [GDB_SELF_TEST]: call register_self_test.
(thumb_record_ld_st_reg_offset): Rewrite the opcode matching to
align with the manual.
(thumb_record_misc): Adjust the code order to align with the
manual.
(thumb2_record_decode_insn_handler): Fix instruction matching.
(instruction_reader_thumb): New class.
(arm_record_test): New function.

7 years agoAdd instruction_reader to arm process record
Yao Qi [Thu, 16 Mar 2017 16:35:18 +0000 (16:35 +0000)]
Add instruction_reader to arm process record

This patch adds an abstract class abstract_memory_reader a
and pass it to the code reading instructions in arm process record,
rather than using target_read_memory to read from real target.  This
paves the way for adding more unit tests to arm process record.

gdb:

2017-03-16  Yao Qi  <yao.qi@linaro.org>

* arm-tdep.c (abstract_memory_reader): New class.
(instruction_reader): New class.
(extract_arm_insn): Add argument 'reader'.  Callers updated.
(decode_insn): Likewise.

7 years agoCopy lazy string handling fixes from Python.
Doug Evans [Wed, 15 Mar 2017 22:44:45 +0000 (15:44 -0700)]
Copy lazy string handling fixes from Python.

This patch keeps the Scheme side of lazy string handling in sync
with the python size, bringing over fixes for
PRs python/17728, python/18439, python/18779.

gdb/ChangeLog:

* guile/scm-lazy-string.c (lazy_string_smob): Clarify use of LENGTH
member.  Change type of TYPE member to SCM.  All uses updated.
(lsscm_make_lazy_string_smob): Add assert.
(lsscm_make_lazy_string): Flag bad length values.
(lsscm_elt_type): New function.
(gdbscm_lazy_string_to_value): Rewrite to use
lsscm_safe_lazy_string_to_value.
(lsscm_safe_lazy_string_to_value): Fix handling of TYPE_CODE_PTR.
* guile/scm-value.c (gdbscm_value_to_lazy_string): Flag bad length
values.  Fix TYPE_CODE_PTR.  Handle TYPE_CODE_ARRAY.  Handle typedefs
in incoming type.
* guile/guile-internal.h (tyscm_scm_to_type): Declare.
* guile/scm-type.c (tyscm_scm_to_type): New function.

gdb/testsuite/ChangeLog:

* gdb.guile/scm-value.c (main) Delete locals sptr, sn.
* gdb.guile/scm-lazy-string.c: New file.
* gdb.guile/scm-value.exp: Move lazy string tests to ...
* gdb.guile/scm-lazy-string.exp: ... here, new file.  Add more tests
for pointer, array, typedef lazy strings.

7 years agoFix various python lazy string bugs.
Doug Evans [Wed, 15 Mar 2017 22:35:13 +0000 (15:35 -0700)]
Fix various python lazy string bugs.

gdb/ChangeLog:

PR python/17728, python/18439, python/18779
* python/py-lazy-string.c (lazy_string_object): Clarify use of LENGTH
member.  Change type of TYPE member to PyObject *.  All uses updated.
(stpy_convert_to_value): Fix handling of TYPE_CODE_PTR.
(gdbpy_create_lazy_string_object): Flag bad length values.
Handle TYPE_CODE_ARRAY with possibly different user-provided length.
Handle typedefs in incoming type.
(stpy_lazy_string_elt_type): New function.
(gdbpy_extract_lazy_string): Call it.
* python/py-value.c (valpy_lazy_string): Flag bad length values.
Fix handling of TYPE_CODE_PTR.  Handle TYPE_CODE_ARRAY.  Handle
typedefs in incoming type.

gdb/testsuite/ChangeLog:

PR python/17728, python/18439, python/18779
* gdb.python/py-value.c (main) Delete locals sptr, sn.
* gdb.python/py-lazy-string.c (pointer): New typedef.
(main): New locals ptr, array, typedef_ptr.
* gdb.python/py-value.exp: Move lazy string tests to ...
* gdb.python/py-lazy-string.exp: ... here.  Add more tests for pointer,
array, typedef lazy strings.

7 years agoNew function tyscm_scm_to_type.
Doug Evans [Mon, 7 Nov 2016 00:10:00 +0000 (16:10 -0800)]
New function tyscm_scm_to_type.

gdb/ChangeLog:

* guile/guile-internal.h (tyscm_scm_to_type): Declare.
* guile/scm-type.c (tyscm_scm_to_type): New function.

7 years agoLazy strings can be made from arrays too.
Doug Evans [Mon, 7 Nov 2016 00:03:56 +0000 (16:03 -0800)]
Lazy strings can be made from arrays too.

gdb/doc/ChangeLog:

* guile.texi (Lazy Strings In Guile): Mention arrays.
* python.texi (Lazy Strings In Python): Ditto.

7 years ago[Patch] Fix variable type glitch in inf-ptrace.c
Jiong Wang [Thu, 16 Mar 2017 09:55:18 +0000 (09:55 +0000)]
[Patch] Fix variable type glitch in inf-ptrace.c

gdb/
* inf-ptrace.c (inf_ptrace_peek_poke): Change the type to "ULONGEST"
for "skip".

7 years agoFix expect for gdb.cp/m-static.exp
Thomas Preud'homme [Thu, 16 Mar 2017 14:02:31 +0000 (14:02 +0000)]
Fix expect for gdb.cp/m-static.exp

The expectation in gdb.cp/m-static.exp for the ptype of
single_constructor is to get in the result of destructor with the
following prototype: ~single_constructor(int).

Yet, m-static.cc declares the destructor as ~single_constructor(). This
commit fixes the expectation.

2017-03-16  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gdb/testsuite/
* gdb.cp/m-static.exp: Fix expectation for prototype of
test5.single_constructor and single_constructor::single_constructor.

7 years agogas/arc: Limit special handling of t/nt flag to ARCv2
Rinat Zelig [Thu, 16 Mar 2017 10:05:22 +0000 (10:05 +0000)]
gas/arc: Limit special handling of t/nt flag to ARCv2

In a later commit I'll be adding a new version of the ".nt" flag for an
ARC700 extension (NPS400) which does not require this same special
handling.

In this commit I have restricted the special flag handling to only apply
if we are assembling for ARCv2.  This is a restructuring commit, and
there should be no user visible changes after this commit.

gas/ChangeLog:

* config/tc-arc.c (assemble_insn): Only handle ".t" and ".nt"
specially for ARCv2.

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

7 years agoMips: Fix TLS LDM GOT entry.
Vladimir Radosavljevic [Wed, 15 Mar 2017 23:49:16 +0000 (16:49 -0700)]
Mips: Fix TLS LDM GOT entry.

gold/
* mips.cc (Mips_got_entry::hash()): Shift addend to reduce
possibility of collisions.
(Mips_got_entry::equals): Fix case for GOT_TLS_LDM
entries.

7 years agoMips: Omit empty objects for merging processor-specific data.
Vladimir Radosavljevic [Wed, 15 Mar 2017 23:46:26 +0000 (16:46 -0700)]
Mips: Omit empty objects for merging processor-specific data.

gold/
* mips.cc (Mips_relobj::merge_processor_specific_data_): New data
member.
(Mips_relobj::merge_processor_specific_data): New method.
(Mips_relobj::do_read_symbols): Set merge_processor_specific_data_
to false, only if the input file is a binary or if object has no
contents except the section name string table and an empty symbol
table with the undefined symbol.
(Target_mips::do_finalize_sections): Refactor.  Skip empty object files
for merging processor-specific data.

7 years agoMips: Add support for resolving multiple consecutive relocations.
Vladimir Radosavljevic [Wed, 15 Mar 2017 23:41:48 +0000 (16:41 -0700)]
Mips: Add support for resolving multiple consecutive relocations.

gold/
* mips.cc (Target_mips::Relocate::calculated_value_): New data
member.
(Target_mips::Relocate::calculate_only_): Likewise.
(Target_mips::Relocate::relocate): Handle multiple consecutive
relocations with the same offset.

7 years agoRemove redundant checks for relocatable link (MIPS).
Vladimir Radosavljevic [Wed, 15 Mar 2017 22:52:12 +0000 (15:52 -0700)]
Remove redundant checks for relocatable link (MIPS).

gold/
* mips.cc (Target_mips::Relocate::relocate): Remove redundant
checks for relocatable link.
(Mips_relocate_functions::reljalr): Likewise.

7 years agoAdd support for .MIPS.options section.
Vladimir Radosavljevic [Wed, 15 Mar 2017 22:47:58 +0000 (15:47 -0700)]
Add support for .MIPS.options section.

gold/
        * mips.cc (class Mips_output_section_options): New class.
        (Target_mips::do_make_output_section): New method.

7 years agoImprove relocation overflow errors on MIPS.
Vladimir Radosavljevic [Wed, 15 Mar 2017 22:43:25 +0000 (15:43 -0700)]
Improve relocation overflow errors on MIPS.

gold/
        * mips.cc (Mips_relocate_functions::rel26): Don't print relocation
        overflow error message.
        (Target_mips::relocate_special_relocatable): Improve relocation
        overflow error message.
        (Target_mips::Relocate::relocate): Likewise.

7 years agoCorrect the definition of _gp and _GLOBAL_OFFSET_TABLE_ symbols for MIPS.
Vladimir Radosavljevic [Wed, 15 Mar 2017 22:35:15 +0000 (15:35 -0700)]
Correct the definition of _gp and _GLOBAL_OFFSET_TABLE_ symbols for MIPS.

gold/
        * mips.cc (symbol_refs_local): Return false if a symbol
        is from a dynamic object.
        (Target_mips::got_section): Make _GLOBAL_OFFSET_TABLE_ STV_HIDDEN.
        (Target_mips::set_gp): Refactor.  Make _gp STT_NOTYPE and
        STB_LOCAL.
        (Target_mips::do_finalize_sections): Set _gp after all the checks
        for creating .got are done.
        (Target_mips::Scan::global): Remove unused code.

7 years agoRISC-V: Fix assembler for c.li, c.andi and c.addiw
Kito Cheng [Tue, 7 Mar 2017 10:15:02 +0000 (18:15 +0800)]
RISC-V: Fix assembler for c.li, c.andi and c.addiw

 - They can accept 0 in imm field

 2017-03-14  Kito Cheng  <kito.cheng@gmail.com>

       * riscv-opc.c (riscv_opcodes> <c.li>: Use the 'o' immediate encoding.
       <c.andi>: Likewise.
       <c.addiw> Likewise.

7 years agoRISC-V: Fix assembler for c.addi, rd can be x0
Kito Cheng [Tue, 7 Mar 2017 11:56:40 +0000 (19:56 +0800)]
RISC-V: Fix assembler for c.addi, rd can be x0

opcodes/ChangeLog:

2017-03-14  Kito Cheng  <kito.cheng@gmail.com>

* riscv-opc.c (riscv_opcodes) <c.addi>: Use match_opcode.

7 years agold-checks: tweak overflow checks.
Tristan Gingold [Tue, 14 Mar 2017 13:54:37 +0000 (14:54 +0100)]
ld-checks: tweak overflow checks.

* testsuite/ld-checks/checks.exp (overflow_check): Disable for
non-elf targets.

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

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

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

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

Sync GCC dwarf.def change

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

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

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

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

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

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

gdb/ChangeLog:

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

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

gas/ChangeLog

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

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

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

gas/ChangeLog:

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

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

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

gas/ChangeLog:

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

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

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

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

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

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

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

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

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

gdb/ChangeLog:

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

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

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

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

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

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

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

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

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

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

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

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

gdb/ChangeLog:

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

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

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

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

This commit restores it.

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

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

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

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

gdb/ChangeLog:

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

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

gdb/ChangeLog:

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

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

gdb/ChangeLog:

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

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

gdb/ChangeLog:

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

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

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

gdb/ChangeLog:

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

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

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

gdb/ChangeLog:

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

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

gdb/gdbserver/ChangeLog:

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

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

gdb/gdbserver/ChangeLog:

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

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

gdb/gdbserver/ChangeLog:

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

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

gdb/gdbserver/ChangeLog:

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

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

gdb/gdbserver/ChangeLog:

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

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

gdb/gdbserver/ChangeLog:

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

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

gdb/gdbserver/ChangeLog:

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

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

gdb/gdbserver/ChangeLog:

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

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

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

  "print \\\nargc\n"

gdb received:

  "print  argc\n"

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

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

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

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

gdb/testsuite/ChangeLog:

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

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

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

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

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

gdb/testsuite/ChangeLog:

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

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

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

libiberty/ChangeLog:

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

gdb/ChangeLog:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This patch fixes this:

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

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

gdb/ChangeLog

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

gdb/testsuite/ChangeLog

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

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

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

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

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

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

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

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

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

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

Given a linker script fragment like this:

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

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

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

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

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

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

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

ld/ChangeLog:

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

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

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

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

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

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

For example, consider this linker script:

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

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

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

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

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

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

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

ld/ChangeLog:

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

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

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

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

ld/ChangeLog:

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

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

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

gas/

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

opcodes/

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

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

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

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

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

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

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

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

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

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

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

Currently diffing testrun results shows:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Tested on x86_64 Fedora 23, native and gdbserver.

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

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

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

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

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

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

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

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

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

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

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

binutils/

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

include/

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

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

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

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

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

Currently I get:

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

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

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

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