binutils-gdb.git
7 years agoRemove AARCH64_RECORD_FAILURE
Yao Qi [Thu, 23 Mar 2017 14:11:04 +0000 (14:11 +0000)]
Remove AARCH64_RECORD_FAILURE

It is not used at all.

gdb:

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

* aarch64-tdep.c: Remove AARCH64_RECORD_FAILURE.

7 years agoRemove constness of libdir in do_start_initialization
Andreas Arnez [Thu, 23 Mar 2017 11:51:14 +0000 (12:51 +0100)]
Remove constness of libdir in do_start_initialization

The patch "Fix memory leak in python.c:do_start_initialization"
(https://sourceware.org/ml/gdb-patches/2017-03/msg00407.html) introduced a
compilation error on some platforms:

  ../../binutils-gdb/gdb/python/python.c: In function bool do_start_initialization():
  ../../binutils-gdb/gdb/python/python.c:1556:16: error: invalid conversion from const void* to void* [-fpermissive]
   xfree (libdir);
                ^

This is fixed by removing the constness of libdir's data type.

gdb/ChangeLog:

* python/python.c (do_start_initialization): Remove 'const' from
data type of libdir.

7 years agoFix memory leak in python.c:do_start_initialization
Philipp Rudo [Thu, 23 Mar 2017 11:22:11 +0000 (12:22 +0100)]
Fix memory leak in python.c:do_start_initialization

When intializing Python the path to the python binary is build the
following way

progname = concat (ldirname (python_libdir), SLASH_STRING, "bin",
   SLASH_STRING, "python", (char *) NULL);

This is problematic as both concat and ldirname allocate memory for the
string they return.  Thus the memory allocated by ldirname cannot be
accessed afterwards causing a memory leak.  Fix it by temporarily storing
libdir in a variable and xfree it after concat.

gdb/ChangeLog:
python/python.c (do_start_initialization): Fix memory leak.

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

7 years agoSanitize RISC-V GAS help text, documentation
Palmer Dabbelt [Tue, 21 Mar 2017 15:36:44 +0000 (08:36 -0700)]
Sanitize RISC-V GAS help text, documentation

It looks like I missed the GAS help text when going through all the
documentation last time, so it printed some of the old-format (never
upstream) arguments.  I fixed this, and when I went to check doc/ I
noticed it was missing the '-fpic'/'-fno-pic' options.

7 years agogas: xtensa: make trampolines relaxation work with jumps in slots other than 0
Max Filippov [Wed, 22 Mar 2017 17:19:14 +0000 (10:19 -0700)]
gas: xtensa: make trampolines relaxation work with jumps in slots other than 0

add_jump_to_trampoline assumes that jump instruction is in slot 0,
when it's in other slot that results in fixup that references NULL symbol,
which results in segfault later in xtensa_make_cached_fixup.
Search for the non-NULL symbol in the tc_frag_data.slot_symbols and check
that there's exactly one such slot.

xtensa_relax_frag for RELAX_TRAMPOLINE reassigns fixup from the original
instruction with jump to generated jump in the trampoline frag, but does not
fix its fx_r_type or fx_size. That results in "undecodable fix" or
"fixup not contained within frag" error messages during relaxation.
Fix both these fields.

gas/
2017-03-22  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (xtensa_relax_frag): Change fx_size of the
reassigned fixup to size of jump instruction (3) and fx_r_type
to BFD_RELOC_XTENSA_SLOT0_OP, as there's only one slot.
(add_jump_to_trampoline): Search
origfrag->tc_frag_data.slot_symbols for the slot with non-NULL
symbol and use that slot instead of slot 0.

7 years agoRemove lwp -> pid conversion in linux_nat_xfer_partial
Simon Marchi [Wed, 22 Mar 2017 14:35:07 +0000 (10:35 -0400)]
Remove lwp -> pid conversion in linux_nat_xfer_partial

The linux_nat_xfer_partial does a conversion of inferior_ptid: if it's
an LWP (ptid::lwp != 0), it builds a new ptid with the lwp as
the pid and assigns that temporarily to inferior_ptid.  For example, if
inferior_ptid is:

  { .pid = 1234, .lwp = 1235 }

it will assign this to inferior_ptid for the duration of the call:

  { .pid = 1235, .lwp = 0 }

Instead of doing this, this patch teaches the inf-ptrace implementation
of xfer_partial to deal with ptids representing lwps by using
get_ptrace_pid.

Also, in linux_proc_xfer_spu and linux_proc_xfer_partial, we use ptid_get_lwp
instead of ptid_get_pid.  While not strictly necessary, since the content of
/proc/<pid> and /proc/<lwp> should be the same, it's a bit safer, because:

- some files under /proc/<pid>/ may not work if the <pid> thread is
  running, just like ptrace requires a stopped thread.  The current
  thread's lwp id is more likely to be in the necessary state (stopped).

- if the leader (<pid>) had exited and is thus now zombie, then several
  files under "/proc/<pid>" won't work, while they will if you use
  "/proc/<lwp>".

The testsuite found no regression on native amd64 linux.

gdb/ChangeLog:

* inf-ptrace.c (inf_ptrace_xfer_partial): Get pid from ptid
using get_ptrace_pid.
* linux-nat.c (linux_nat_xfer_partial): Don't set/restore
inferior_ptid.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use lwp of
inferior_ptid instead of pid.

7 years agoSync top level config files with master versions in the FSF config project.
Nick Clifton [Wed, 22 Mar 2017 14:01:03 +0000 (14:01 +0000)]
Sync top level config files with master versions in the FSF config project.

* config.sub: Sync with master version in config project.
* config.guess: Likewise.

7 years agoRemove @code for python
Yao Qi [Wed, 22 Mar 2017 12:40:24 +0000 (12:40 +0000)]
Remove @code for python

There's no reason to use @code for Python the name of a programming
language.

gdb/doc:

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

* python.texi (Inferiors In Python): Remove @code from Python.

7 years agoWrap locally used classes in anonymous namespace
Yao Qi [Wed, 22 Mar 2017 12:35:31 +0000 (12:35 +0000)]
Wrap locally used classes in anonymous namespace

Both aarch64-tdep.c and arm-tdep.c defines a class instruction_reader, which
violates ODR, but linker doesn't an emit error.  I fix this issue by wrapping
them by anonymous namespace, but I think it is better to apply this for all
locally used classes.

If it is a good idea to put locally used class into anonymous namespace, we
should document this rule into GDB coding convention, or even GCC coding
convention.  Note that anonymous namespace has been used in GCC but GCC
coding convention doesn't mention the it.

gdb:

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

* aarch64-tdep.c: Wrap locally used classes in anonymous
namespace.
* arm-tdep.c: Likewise.
* linespec.c: Likewise.
* ui-out.c: Likewise.

7 years agoImport sys in gdb/python/lib/gdb/printer/bound_registers.py
Jonah Graham [Wed, 22 Mar 2017 11:19:44 +0000 (11:19 +0000)]
Import sys in gdb/python/lib/gdb/printer/bound_registers.py

Pick up missing bits from the patch merged in.

2017-03-22  Jonah Graham  <jonah@kichwacoders.com>

PR gdb/19637
* python/lib/gdb/printer/bound_registers.py: Import sys.

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

7 years agoDisable shared library tests for nios2-*-elf.
Sandra Loosemore [Tue, 21 Mar 2017 20:25:09 +0000 (13:25 -0700)]
Disable shared library tests for nios2-*-elf.

The Nios II processor documentation defines relocations for PIC and
shared libraries as part of the GNU/Linux ABI only; GCC rejects -fpic
on bare-metal.

2017-03-21  Sandra Loosemore  <sandra@codesourcery.com>

ld/
* testsuite/lib/ld-lib.exp (check_shared_lib_support): Return
false for nios2-*-elf.

7 years agowindows: Use ptid from regcache in register fetch/store
Simon Marchi [Tue, 21 Mar 2017 15:35:54 +0000 (11:35 -0400)]
windows: Use ptid from regcache in register fetch/store

Use the ptid from the regcache so we don't depend on the current value
of the inferior_ptid global.

Also, change how the current thread is passed to sub-functions.  The
windows_fetch_inferior_registers function sets current_thread then calls
do_windows_fetch_inferior_registers, which reads current_thread.  This
very much looks like passing a parameter through a global variable.  I
think it would be more straightforward to pass the thread as a
parameter.

gdb/ChangeLog:

* windows-nat.c (do_windows_fetch_inferior_registers): Add
windows_thread_info parameter and use it instead of
current_thread.
(windows_fetch_inferior_registers): Don't set current_thread,
pass the thread to do_windows_fetch_inferior_registers.  Use
ptid from regcache instead of inferior_ptid.
(do_windows_store_inferior_registers): Add windows_thread_info
parameter and use it instead of current_thread.
(windows_store_inferior_registers): Don't set current_thread,
pass the thread to do_windows_store_inferior_registers.  Use
ptid from regcache instead of inferior_ptid.

7 years agoRemove remaining reference to struct serial::current_timeout
Simon Marchi [Tue, 21 Mar 2017 15:35:42 +0000 (11:35 -0400)]
Remove remaining reference to struct serial::current_timeout

I get this when trying to build for --host=x68_64-w64-mingw32:

/home/emaisin/src/binutils-gdb/gdb/ser-mingw.c: In function 'void ser_windows_raw(serial*)':
/home/emaisin/src/binutils-gdb/gdb/ser-mingw.c:166:8: error: 'struct serial' has no member named 'current_timeout'
   scb->current_timeout = 0;
        ^~~~~~~~~~~~~~~

It is just a leftover from

  9bcbdca808b5f9fec6217d20bd4b48a56008c460
  PR remote/21188: Fix remote serial timeout

gdb/ChangeLog:

* ser-mingw.c (ser_windows_raw): Remove reference to
struct serial::current_timeout.

7 years agoS/390: Remove vx2 facility flag
Andreas Krebbel [Tue, 21 Mar 2017 13:21:02 +0000 (14:21 +0100)]
S/390: Remove vx2 facility flag

This patch removes the vx2 facility flag.  It will not be used by GCC
and was a misnomer anyway.

Committed to mainline and 2.28 branch.

include/ChangeLog:

2017-03-21  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* opcode/s390.h (S390_INSTR_FLAG_VX2): Remove.
(S390_INSTR_FLAG_FACILITY_MASK): Adjust value.

gas/ChangeLog:

2017-03-21  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* config/tc-s390.c (s390_parse_cpu): Remove S390_INSTR_FLAG_VX2
from cpu_table.  Remove vx2, and novx2 from cpu_flags.

opcodes/ChangeLog:

2017-03-21  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-mkopc.c (main): Remove vx2 check.
* s390-opc.txt: Remove vx2 instruction flags.

7 years agoAdd --inlines option to objdump to include scope backtrace of inlined functions when...
Andi Kleen [Tue, 21 Mar 2017 13:05:19 +0000 (13:05 +0000)]
Add --inlines option to objdump to include scope backtrace of inlined functions when generating source line number information.

* objdump.c (unwind_inlines): Add.
(option_values): Add OPTION_INLINES.
(show_line): Unwind inlines if requested.
(main): Parse OPTION_INLINES.
(usage): Document --inlines.
* doc/binutils.texi: Document --inlines.
* NEWS: Likewise.

7 years agoarc/nps400: Add cp16/cp32 instructions to opcodes library
Rinat Zelig [Tue, 21 Mar 2017 11:37:33 +0000 (11:37 +0000)]
arc/nps400: Add cp16/cp32 instructions to opcodes library

Instructions for loading or storing 16/32B data from one address type to
another.

gas/ChangeLog

* testsuite/gas/arc/nps400-11.s: New file.
* testsuite/gas/arc/nps400-11.d: New file.

include/ChangeLog

* opcode/arc.h (insn_class_t): Add DMA class.

opcodes/ChangeLog

* arc-nps400-tbl.h: Add cp32/cp16 instructions format.
* arc-opc.c: Add F_NPS_NA, NPS_DMA_IMM_ENTRY, NPS_DMA_IMM_OFFSET.
(insert_nps_imm_offset): New function.
(extract_nps_imm_offset): New function.
(insert_nps_imm_entry): New function.
(extract_nps_imm_entry): New function.

7 years agoUpdate support for GNU BUILD notes so that version notes can contain extra informatio...
Nick Clifton [Tue, 21 Mar 2017 11:48:57 +0000 (11:48 +0000)]
Update support for GNU BUILD notes so that version notes can contain extra information, and stack protection notes can contain numeric values.

* readelf.c (print_gnu_build_attribute_name): Allow stack
protection notes to contain numeric values.  Use a colon rather
than a space to separate a string name from its values.  Decode
the numeric value of a stack protection note.
* objcopy.c (merge_gnu_build_notes): Allow version notes to
contain extra text after the protocol version number.

7 years agoDecode properly flags of %ccr register on sparc64.
Ivo Raisr [Tue, 21 Mar 2017 11:39:33 +0000 (04:39 -0700)]
Decode properly flags of %ccr register on sparc64.

While at it, decode also properly one-bit flags for %fsr (accrued and
current exception flags were mixed up).

ChangeLog entry:
2017-03-21  Ivo Raisr  <ivo.raisr@oracle.com>

     PR tdep/20928
     * gdb/sparc-tdep.h (gdbarch_tdep) <sparc64_ccr_type>: New field.
     * gdb/sparc64-tdep.c (sparc64_ccr_type): New function.
     (sparc64_fsr_type): Fix %fsr decoding.

ChangeLog entry for testsuite:
2017-03-21  Ivo Raisr  <ivo.raisr@oracle.com>

     PR tdep/20928
     * gdb.arch/sparc64-regs.exp: New file.
     * gdb.arch/sparc64-regs.S: Likewise.

7 years agold: check overflow only for allocated sections.
Tristan Gingold [Fri, 17 Mar 2017 10:12:05 +0000 (11:12 +0100)]
ld: check overflow only for allocated sections.

* ldlang.c (lang_check_section_addresses): Check only for
allocated sections.

7 years agoFix break on Python 2
Tim Wiederhake [Tue, 21 Mar 2017 07:19:59 +0000 (08:19 +0100)]
Fix break on Python 2

This changes the return type of "gdb.BtraceInstruction.data ()" from
"memoryview" to "buffer" on Python 2.7 and below, similar to what
"gdb.Inferior.read_memory ()" does.

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

7 years agospu: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Mon, 20 Mar 2017 22:23:47 +0000 (18:23 -0400)]
spu: Use ptid from regcache instead of inferior_ptid

The implementations of to_fetch_registers/to_store_registers in the spu
code use some functions that rely on inferior_ptid.  It's simpler for
now to set/restore inferior_ptid.

gdb/ChangeLog:

* spu-linux-nat.c (spu_fetch_inferior_registers,
spu_store_inferior_registers): Use ptid from regcache, set and
restore inferior_ptid.
* spu-multiarch.c (spu_fetch_registers, spu_store_registers):
Likewise.

7 years agoUse ptid from regcache in almost all remaining nat files
Simon Marchi [Mon, 20 Mar 2017 21:37:36 +0000 (17:37 -0400)]
Use ptid from regcache in almost all remaining nat files

This patch contains almost all of the remaining changes needed to make
to_fetch_registers/to_store_registers/to_prepare_to_store independent of
inferior_ptid.  It contains only some "trivial" changes, the more
complicated ones are in separate patches.

gdb/ChangeLog:

* i386-linux-nat.c (fetch_register, store_register,
i386_linux_fetch_inferior_registers,
i386_linux_store_inferior_registers): Use ptid from regcache.
* ia64-linux-nat.c (ia64_linux_fetch_register,
ia64_linux_store_register): Likewise.
* inf-ptrace.c (inf_ptrace_fetch_register,
inf_ptrace_store_register): Likewise.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers,
m32r_linux_store_inferior_registers): Likewise.
* m68k-bsd-nat.c (m68kbsd_fetch_inferior_registers,
m68kbsd_store_inferior_registers): Likewise.
* m68k-linux-nat.c (fetch_register, store_register,
m68k_linux_fetch_inferior_registers,
m68k_linux_store_inferior_registers): Likewise.
* m88k-bsd-nat.c (m88kbsd_fetch_inferior_registers,
m88kbsd_store_inferior_registers): Likewise.
* mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers,
mips_fbsd_store_inferior_registers): Likewise.
* mips-linux-nat.c (mips64_linux_regsets_fetch_registers,
mips64_linux_regsets_store_registers): Likewise.
* mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers,
mipsnbsd_store_inferior_registers): Likewise.
* mips-obsd-nat.c (mips64obsd_fetch_inferior_registers,
mips64obsd_store_inferior_registers): Likewise.
* nto-procfs.c (procfs_fetch_registers, procfs_store_registers):
Likewise.
* ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers,
ppcfbsd_store_inferior_registers): Likewise.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers,
ppc_linux_store_inferior_registers): Likewise.
* ppc-nbsd-nat.c (ppcnbsd_fetch_inferior_registers,
ppcnbsd_store_inferior_registers): Likewise.
* ppc-obsd-nat.c (ppcobsd_fetch_registers,
ppcobsd_store_registers): Likewise.
* procfs.c (procfs_fetch_registers, procfs_store_registers):
Likewise.
* ravenscar-thread.c (ravenscar_fetch_registers,
ravenscar_store_registers, ravenscar_prepare_to_store):
Likewise.
* record-btrace.c (record_btrace_fetch_registers,
record_btrace_store_registers, record_btrace_prepare_to_store):
Likewise.
* remote-sim.c (gdbsim_fetch_register, gdbsim_store_register):
Lookup inferior using ptid from regcache, instead of
current_inferior.
* remote.c (remote_fetch_registers, remote_store_registers): Use
ptid from regcache.
* rs6000-nat.c (fetch_register, store_register): Likewise.
* s390-linux-nat.c (s390_linux_fetch_inferior_registers,
s390_linux_store_inferior_registers): Likewise.
* sh-nbsd-nat.c (shnbsd_fetch_inferior_registers,
shnbsd_store_inferior_registers): Likewise.
* sol-thread.c (sol_thread_fetch_registers,
sol_thread_store_registers): Likewise.
* sparc-nat.c (sparc_fetch_inferior_registers,
sparc_store_inferior_registers): Likewise.
* tilegx-linux-nat.c (fetch_inferior_registers,
store_inferior_registers): Likewise.
* vax-bsd-nat.c (vaxbsd_fetch_inferior_registers,
vaxbsd_store_inferior_registers): Likewise.
* xtensa-linux-nat.c (fetch_gregs, store_gregs, fetch_xtregs,
store_xtregs): Likewise.

7 years agoAdd rvalue reference tests and docs
Artemiy Volkov [Mon, 20 Mar 2017 20:47:59 +0000 (13:47 -0700)]
Add rvalue reference tests and docs

This patch adds tests for the initial rvalue reference support patchset.  All
of the new tests are practically mirrored regular references tests and, except
for the demangler ones, are introduced in new files, which are set to be
compiled with -std=gnu++11.  Tested are printing of rvalue reference types and
values, rvalue reference parameters in function overloading, demangling of
function names containing rvalue reference parameters, casts to rvalue
reference types, application of the sizeof operator to rvalue reference types
and values, and support for rvalue references within the gdb python module.

gdb/ChnageLog

PR gdb/14441
* NEWS: Mention support for rvalue references in GDB and python.
* doc/gdb.texinfo (C Plus Plus Expressions): Mention that GDB
supports both lvalue and rvalue references.

gdb/testsuite/ChangeLog

PR gdb/14441
* gdb.cp/demangle.exp: Add rvalue reference tests.
* gdb.cp/rvalue-ref-casts.cc: New file.
* gdb.cp/rvalue-ref-casts.exp: New file.
* gdb.cp/rvalue-ref-overload.cc: New file.
* gdb.cp/rvalue-ref-overload.exp: New file.
* gdb.cp/rvalue-ref-params.cc: New file.
* gdb.cp/rvalue-ref-params.exp: New file.
* gdb.cp/rvalue-ref-sizeof.cc: New file.
* gdb.cp/rvalue-ref-sizeof.exp: New file.
* gdb.cp/rvalue-ref-types.cc: New file.
* gdb.cp/rvalue-ref-types.exp: New file.
* gdb.python/py-rvalue-ref-value-cc.cc: New file.
* gdb.python/py-rvalue-ref-value-cc.exp: New file.

7 years agoAdd rvalue references to overloading resolution
Artemiy Volkov [Mon, 20 Mar 2017 20:47:57 +0000 (13:47 -0700)]
Add rvalue references to overloading resolution

This patch introduces changes to rank_one_type() dealing with ranking an rvalue
reference type when selecting a best viable function from a set of candidate
functions. The 4 new added rules for rvalue references are:

1) An rvalue argument cannot be bound to a non-const lvalue reference parameter
and an lvalue argument cannot be bound to an rvalue reference parameter.
[C++11 13.3.3.1.4p3]

2) If a conversion to one type of reference is an identity conversion, and a
conversion to the second type of reference is a non-identity conversion, choose
the first type. [C++11 13.3.3.2p3]

3) An rvalue should be first tried to bind to an rvalue reference, and then to
an lvalue reference. [C++11 13.3.3.2p3]

4) An lvalue reference to a function gets higher priority than an rvalue
reference to a function. [C++11 13.3.3.2p3]

This patch is not exactly correct.  See c++/15372 for tracking overload
resolution bugs.

gdb/ChangeLog

PR gdb/14441
* gdbtypes.c (rank_one_type): Implement overloading
resolution rules regarding rvalue references.

7 years agoConvert lvalue reference type check to general reference type check
Artemiy Volkov [Mon, 20 Mar 2017 20:47:54 +0000 (13:47 -0700)]
Convert lvalue reference type check to general reference type check

In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.

gdb/ChangeLog

PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.

7 years agoSupport rvalue references in the gdb python module (includes doc/)
Artemiy Volkov [Mon, 20 Mar 2017 20:47:52 +0000 (13:47 -0700)]
Support rvalue references in the gdb python module (includes doc/)

This patch adds the ability to inspect rvalue reference types and values using
the gdb python module. This is achieved by creating two wrappers for
valpy_reference_value(), using the ReferenceExplorer class to handle the
objects of rvalue reference types and placing necessary checks for a
TYPE_CODE_RVALUE_REF type code next to the checks for a TYPE_CODE_REF type
code.

gdb/ChangeLog

PR gdb/14441
* doc/python.texi (Types in Python): Add TYPE_CODE_RVALUE_REF to
table of constants.
* python/lib/gdb/command/explore.py: Support exploring values
of rvalue reference types.
* python/lib/gdb/types.py: Implement get_basic_type() for
rvalue reference types.
* python/py-type.c (pyty_codes) <TYPE_CODE_RVALUE_REF>: New
constant.
* python/py-value.c (valpy_getitem): Add an rvalue reference
check.
(valpy_reference_value): Add new parameter "refcode".
(valpy_lvalue_reference_value, valpy_rvalue_reference_value):
New wrappers for valpy_reference_value().
* python/py-xmethods.c (gdbpy_get_xmethod_result_type)
(gdbpy_invoke_xmethod): Likewise.

7 years agoSupport DW_TAG_rvalue_reference type
Artemiy Volkov [Mon, 20 Mar 2017 20:47:50 +0000 (13:47 -0700)]
Support DW_TAG_rvalue_reference type

Make gdb DWARF reader understand the DW_TAG_rvalue_reference type tag. Handling
of this tag is done in the existing read_tag_reference_type() function, to
which we add a new parameter representing the kind of reference type
(lvalue vs rvalue).

gdb/ChangeLog

PR gdb/14441
* dwarf2read.c (process_die, read_type_die_1): Handle the
DW_TAG_rvalue_reference_type DIE.
(read_tag_reference_type): Add new parameter "refcode".

7 years agoImplement printing of rvalue reference types and values
Artemiy Volkov [Mon, 20 Mar 2017 20:47:48 +0000 (13:47 -0700)]
Implement printing of rvalue reference types and values

This patch provides the ability to print out names of rvalue reference types
and values of those types. This is done in full similarity to regular
references, and as with them, we don't print out "const" suffix because all
rvalue references are const.

gdb/ChangeLog

PR gdb/14441
* c-typeprint.c (c_print_type, c_type_print_varspec_prefix)
(c_type_print_modifier, c_type_print_varspec_suffix)
(c_type_print_base): Support printing rvalue reference types.
* c-valprint.c (c_val_print, c_value_print): Support printing
rvalue reference values.

7 years agoImplement demangling for rvalue reference type names
Artemiy Volkov [Mon, 20 Mar 2017 20:47:46 +0000 (13:47 -0700)]
Implement demangling for rvalue reference type names

This patch fixes demangling of names containing rvalue reference typenames by
handling DEMANGLE_COMPONENT_RVALUE_REFERENCE demangle component.

gdb/ChangeLog

PR gdb/14441
* cp-name-parser.y (ptr_operator): Handle the '&&' token in
typename.
* cp-support.c (replace_typedefs): Handle
DEMANGLE_COMPONENT_RVALUE_REFERENCE.
* python/py-type.c (typy_lookup_type): Likewise.

7 years agoSupport rvalue reference type in parser
Artemiy Volkov [Mon, 20 Mar 2017 20:47:43 +0000 (13:47 -0700)]
Support rvalue reference type in parser

This patch implements correct parsing of C++11 rvalue reference typenames.
This is done in full similarity to the handling of regular references by adding
a '&&' token handling in c-exp.y, defining an rvalue reference type piece, and
implementing a follow type derivation in follow_types().

gdb/ChangeLog

PR gdb/14441
* c-exp.y (ptr_operator): Handle the '&&' token in the typename.
* parse.c (insert_type): Change assert statement.
(follow_types): Handle rvalue reference types.
* parser-defs.h (enum type_pieces) <tp_rvalue_reference>: New
constant.

7 years agoAdd ability to return rvalue reference values from value_ref
Artemiy Volkov [Mon, 20 Mar 2017 20:47:41 +0000 (13:47 -0700)]
Add ability to return rvalue reference values from value_ref

Parameterize value_ref() by the kind of reference type the value of which
is requested. Change all callers to use the new API.

gdb/ChangeLog

PR gdb/14441
* ada-lang.c (ada_evaluate_subexp): Adhere to the new
value_ref() interface.
* c-valprint.c (c_value_print): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* python/py-value.c (valpy_reference_value): Likewise.
* valops.c (value_cast, value_reinterpret_cast)
(value_dynamic_cast, typecmp): Likewise.
(value_ref): Parameterize by kind of return value reference type.
* value.h (value_ref): Add new parameter "refcode".

7 years agoChange {lookup,make}_reference_type API
Artemiy Volkov [Mon, 20 Mar 2017 20:47:39 +0000 (13:47 -0700)]
Change {lookup,make}_reference_type API

Parameterize lookup_reference_type() and make_reference_type() by the kind of
reference type we want to look up. Create two wrapper functions
lookup_{lvalue,rvalue}_reference_type() for lookup_reference_type() to simplify
the API. Change all callers to use the new API.

gdb/Changelog

PR gdb/14441
* dwarf2read.c (read_tag_reference_type): Use
lookup_lvalue_reference_type() instead of lookup_reference_type().
* eval.c (evaluate_subexp_standard): Likewise.
* f-exp.y: Likewise.
* gdbtypes.c (make_reference_type, lookup_reference_type):
Generalize with rvalue reference types.
(lookup_lvalue_reference_type, lookup_rvalue_reference_type): New
convenience wrappers for lookup_reference_type().
* gdbtypes.h (make_reference_type, lookup_reference_type): Add a
reference kind parameter.
(lookup_lvalue_reference_type, lookup_rvalue_reference_type): Add
wrappers for lookup_reference_type().
* guile/scm-type.c (gdbscm_type_reference): Use
lookup_lvalue_reference_type() instead of lookup_reference_type().
* guile/scm-value.c (gdbscm_value_dynamic_type): Likewise.
* parse.c (follow_types): Likewise.
* python/py-type.c (typy_reference, typy_lookup_type): Likewise.
* python/py-value.c (valpy_get_dynamic_type, valpy_getitem):
Likewise.
* python/py-xmethods.c (gdbpy_get_xmethod_result_type)
(gdbpy_invoke_xmethod): Likewise.
* stabsread.c: Provide extra argument to make_reference_type()
call.
* valops.c (value_ref, value_rtti_indirect_type): Use
lookup_lvalue_reference_type() instead of lookup_reference_type().

7 years agoAdd definitions for rvalue reference types
Artemiy Volkov [Mon, 20 Mar 2017 20:47:30 +0000 (13:47 -0700)]
Add definitions for rvalue reference types

This patch introduces preliminal definitions regarding C++11 rvalue references
to the gdb type system. In addition to an enum type_code entry, a field in
struct type and an accessor macro for that which are created similarly to the
lvalue references counterparts, we also introduce a TYPE_REFERENCE convenience
macro used to check for both kinds of references simultaneously as they are
equivalent in many contexts.

gdb/Changelog

    PR gdb/14441
    * gdbtypes.h (enum type_code) <TYPE_CODE_RVALUE_REF>: New constant.
    (TYPE_IS_REFERENCE): New macro.
    (struct type): Add rvalue_reference_type field.
    (TYPE_RVALUE_REFERENCE_TYPE): New macro.

7 years agoAdd -file-list-shared-libraries MI command
Marc-Andre Laperle [Mon, 20 Mar 2017 18:57:51 +0000 (14:57 -0400)]
Add -file-list-shared-libraries MI command

This change adds the MI equivalent for the "info sharedlibrary"
command. The command was already partially documented but ignored as
it was not implemented. The new MI command works similarly to the CLI
command, taking an optional regular expression as an argument and
outputting the library information.

I included a test for the new command in mi-solib.exp.

gdb/doc/ChangeLog:

* gdb.texinfo (gdb/mi Symbol Query Commands): Document new MI
command file-list-shared-libraries
(GDB/MI Async Records): Update documentation of library-loaded with new
field.

gdb/ChangeLog:

* NEWS: Add an entry about new '-file-list-shared-libraries' command.
* mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries):
New function definition.
* mi/mi-cmds.c (mi_cmds): Add -file-list-shared-libraries command.
* mi/mi-cmds.h (mi_cmd_file_list_shared_libraries):
New function declaration.
* mi/mi-interp.c (mi_output_solib_attribs): New Function.
* mi/mi-interp.h: New file.
* solib.c (info_sharedlibrary_command): Replace for loop with
ALL_SO_LIBS macro
* solib.h (update_solib_list): New function declaration.
(so_list_head): Move macro.
* solist.h (ALL_SO_LIBS): New macro.

gdb/testsuite/ChangeLog:

* gdb.mi/mi-solib.exp (test_file_list_shared_libraries):
New procedure.

Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
7 years agoAdd a better diagnostic message in mi_gdb_test
Marc-Andre Laperle [Mon, 20 Mar 2017 18:57:45 +0000 (14:57 -0400)]
Add a better diagnostic message in mi_gdb_test

When using mi_gdb_test, if it fails because of the presence of
unexpected output, the error message is only the message passed as
the argument with no indication that there was an unexpected output.
This change adds an additional text to the failure message to
indicate that there was an unexpected output.

gdb/testsuite/ChangeLog:

* lib/mi-support.exp (mi_gdb_test): Add additional message
for unexpected output.

Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
7 years agoRemove unused parameter in solib_add and update_solib_list
Marc-Andre Laperle [Mon, 20 Mar 2017 18:57:32 +0000 (14:57 -0400)]
Remove unused parameter in solib_add and update_solib_list

The target parameter in both solib_add and update_solib_list
functions is not used anymore and as not been used for a while. This
change removes the parameter to clean up the code a little bit.

gdb/ChangeLog:

* infcmd.c (post_create_inferior): Remove unused argument in
call to solib_add.
* remote.c (remote_start_remote): Likewise.
* solib-frv.c (frv_fetch_objfile_link_map): Likewise.
* solib-svr4.c: (svr4_fetch_objfile_link_map): Likewise.
(enable_break): Likewise.
* solib.c (update_solib_list): Remove unused target argument
and its documentation.
(solib_add): Remove unused target argument.  Remove unused
argument in call to update_solib_list.
(info_sharedlibrary_command): Remove unused argument in call
to update_solib_list.
(sharedlibrary_command): Remove unused argument in call to
solib_add.
(handle_solib_event): Likewise.
(reload_shared_libraries): Likewise.
* solib.h (solib_add): Remove unused target argument.

Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
7 years agoFix spurious FAILs with examine-backward.exp
Andreas Arnez [Mon, 20 Mar 2017 17:55:39 +0000 (18:55 +0100)]
Fix spurious FAILs with examine-backward.exp

The test case examine-backward.exp issues the command "x/-s" after the end
of the first string in TestStrings, but without making sure that this
string is preceded by a string terminator.  Thus GDB may spuriously print
some random characters from before that string, and then the test fails.

This patch assures that TestStrings is preceded by a string terminator.

gdb/testsuite/ChangeLog:

* gdb.base/examine-backward.c (Barrier): New character array
constant, to ensure that TestStrings is preceded by a string
terminator.

7 years agoreadelf: Don't error on .debug files with NOBITS .dynamic section.
Mark Wielaard [Mon, 20 Mar 2017 14:32:34 +0000 (15:32 +0100)]
readelf: Don't error on .debug files with NOBITS .dynamic section.

The fix for PR binutils/17512 added a check for the dynamic segment being
inside the actual ELF file. If not an error message would be produced:

readelf: Error: the dynamic segment offset + size exceeds the size of the file

Unfortunately for separate debuginfo files it is common for the dynamic
segment not being inside the file because the .dynamic section is NOBITS.

Since the check is done unconditionally in process_program_headers and
process_program_headers is always called (to setup dynamic_addr in case
it is needed). The error is produced on any operations done on any .debug
file (even if no program headers or the dynamic segment is used).

If there are section headers then a cross check is done to see if the
.dynamic section is NOBITS in which case dynamic_addr is set to zero
without a warning or error (which is then checked first before any
operation on the dynamic segement is done).

Move the check for the dynamic segment being inside the actual ELF file
after the cross check with the section headers to suppress the error for
.debug files.

binutils/ChangeLog:

* readelf.c (process_program_headers): Move dynamic_addr check
after .dynamic section cross check.

7 years agoUpdate descriptions of the .2byte, .4byte and .8byte directives.
Nick Clifton [Mon, 20 Mar 2017 16:57:07 +0000 (16:57 +0000)]
Update descriptions of the .2byte, .4byte and .8byte directives.

* doc/as.texinfo (2byte): Note that if no expressions are present
the directive does nothing.  Emphasize that the output is
unaligned, and that this can have an effect on the relocations
generated.
(4byte): Simplify description.  Refer back to the 2byte
description.
(8byte): Likewise.

7 years agos390: Fix displaced-stepping certain relative branch insns
Andreas Arnez [Mon, 20 Mar 2017 16:30:01 +0000 (17:30 +0100)]
s390: Fix displaced-stepping certain relative branch insns

On s390x targets GDB can not handle displaced stepping correctly for some
relative branch instructions, such as cij (compare immediate and branch
relative).  When setting a breakpoint on such an instruction and
single-stepping over it, the branch is never taken.  This is because the
check in s390_displaced_step_fixup for relative branch instructions is
incomplete.

Instead of completing the list of relative branch instructions to check
against, this patch just treats relative branches and non-branching
instructions in the same way and adjusts the PC with the negated
displacement in both cases.

gdb/ChangeLog:

* s390-linux-tdep.c (is_rsi, is_rie): Remove functions.
(s390_displaced_step_fixup): Cover relative branches with the
default fixup handling.  This fixes lack of support for some
relative branch instructions.

7 years agoUpdate the openrisc previous program counter (ppc) when running code in the cgen...
Stafford Horne [Mon, 20 Mar 2017 15:33:51 +0000 (15:33 +0000)]
Update the openrisc previous program counter (ppc) when running code in the cgen based simulator.

* or1kcommon.cpu: Add pc set semantics to also update ppc.

7 years ago[arm] Document missing -mfpu entries.
Richard Earnshaw [Mon, 20 Mar 2017 14:56:22 +0000 (14:56 +0000)]
[arm] Document missing -mfpu entries.

Nick pointed out that I hadn't documented the new -mfpu option
neon-vfpv3 and mentioned that some others were missing.

Having looked through the list only one (neon-fp16) really should be
documented; the other two entries in the real table should not be
documented as they are aliases kept for legacy compatibility reasons.
This patch adds the missing entries and notes in the main table that
the other two entries should not be documented.

I've also fixed a small spelling error in the accompanying text.

* config/tc-arm.c (arm_fpus): Note entires that should not be
documented.
* doc/c-arm.texi (-mfpu): Add missing FPU entries for neon-vfpv3 and
neon-fp16.  Fix spelling error.

7 years ago[arm] Add neon-vfp3 as an alias for neon to -mfpu.
Richard Earnshaw [Mon, 20 Mar 2017 10:03:15 +0000 (10:03 +0000)]
[arm] Add neon-vfp3 as an alias for neon to -mfpu.

GCC recently added neon-vfpv3 as an alias for neon in -mfpu.  This patch adds a similar alias in GAS.

* config/tc-arm.c (arm_fpus): Add neon-vfpv3 as an alias for neon.

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

7 years agoPR 21266, unstable qsort in bfd/elf64-ppc.c
Alan Modra [Sun, 19 Mar 2017 21:55:50 +0000 (08:25 +1030)]
PR 21266, unstable qsort in bfd/elf64-ppc.c

PR 21266
* elf64-ppc.c (compare_symbols): Stabilize sort.

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

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

7 years agoDT_TEXTREL vs IFUNC
Alan Modra [Thu, 16 Mar 2017 22:07:15 +0000 (08:37 +1030)]
DT_TEXTREL vs IFUNC

If you should somehow link non-pic objects into a PIE or shared
library, resulting in an object with DT_TEXTREL (text relocations)
set, and your executable or shared library also contains GNU indirect
functions, then you're in trouble.  To apply dynamic relocations
ld.so will make the text segment writable.  On most systems this will
make the text segment non-executable, which will then result in a
segfault when ld.so tries to run ifunc resolvers when applying
relocations against ifuncs.

This patch teaches PowerPC ld to detect the situation, and warn.

* elf64-ppc.c (struct ppc_link_hash_table): Add
local_ifunc_resolver and maybe_local_ifunc_resolver.
(ppc_build_one_stub): Set flags on emitting dynamic
relocation to ifunc.
(ppc64_elf_relocate_section): Likewise.
(ppc64_elf_finish_dynamic_symbol): Likewise.
(ppc64_elf_finish_dynamic_sections): Error on DT_TEXTREL with
local dynamic relocs to ifuncs.
* elf32-ppc.c (struct ppc_elf_link_hash_table): Add
local_ifunc_resolver and maybe_local_ifunc_resolver.
(ppc_elf_relocate_section): Set flag on emitting dynamic
relocation to ifuncs.
(ppc_elf_finish_dynamic_symbol): Likewise.
(ppc_elf_finish_dynamic_sections): Error on DT_TEXTREL with local
dynamic relocs to ifuncs.

7 years agoi386-gnu-nat: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Fri, 17 Mar 2017 17:55:57 +0000 (13:55 -0400)]
i386-gnu-nat: Use ptid from regcache instead of inferior_ptid

gdb/ChangeLog:

* i386-gnu-nat.c (gnu_fetch_registers, gnu_store_registers): Use
ptid from regcache.

7 years agoi386-darwin-nat: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Fri, 17 Mar 2017 17:55:56 +0000 (13:55 -0400)]
i386-darwin-nat: Use ptid from regcache instead of inferior_ptid

gdb/ChangeLog:

* i386-darwin-nat.c (i386_darwin_fetch_inferior_registers,
i386_darwin_store_inferior_registers): Use ptid from regcache.

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

gdb/ChangeLog:

* i386-bsd-nat.c (i386bsd_fetch_inferior_registers,
i386bsd_store_inferior_registers): Use ptid from regcache.

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

gdb/ChangeLog:

* hppa-obsd-nat.c (hppaobsd_fetch_registers,
hppaobsd_store_registers): Use ptid from regcache.

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

gdb/ChangeLog:

* hppa-nbsd-nat.c (hppanbsd_fetch_registers,
hppanbsd_store_registers): Use ptid from regcache.

7 years agohppa-linux-nat: Use ptid from regcache instead of inferior_ptid
Simon Marchi [Fri, 17 Mar 2017 17:55:53 +0000 (13:55 -0400)]
hppa-linux-nat: Use ptid from regcache instead of inferior_ptid

gdb/ChangeLog:

* hppa-linux-nat.c (fetch_register, store_register): Use ptid
from regcache.  Use get_ptrace_pid.

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.