external/binutils.git
8 years agoAdd support for the --trace-decode option to the AArch64 simulator.
Nick Clifton [Wed, 27 Apr 2016 10:39:14 +0000 (11:39 +0100)]
Add support for the --trace-decode option to the AArch64 simulator.

* simulator.c: Add TRACE_DECODE statements to all emulation
functions.

8 years agoFix powerpc64 ld testsuite fail
Alan Modra [Wed, 27 Apr 2016 07:21:15 +0000 (16:51 +0930)]
Fix powerpc64 ld testsuite fail

PR target/19985
* configure.tgt: Don't use var+=.

8 years agoProvide xmemdup0
Alan Modra [Wed, 27 Apr 2016 06:12:50 +0000 (15:42 +0930)]
Provide xmemdup0

and some tidies in as.h

* as.h (inline, __PTR_TO_INT, __INT_TO_PTR): Don't define.
(xmemdup0): New inline function.

8 years agoCache result of scan for __start_* and __stop_* sections
Alan Modra [Wed, 27 Apr 2016 03:23:05 +0000 (12:53 +0930)]
Cache result of scan for __start_* and __stop_* sections

include/
* bfdlink.h (struct bfd_link_hash_entry): Add "section" field to
undef.  Formatting.
bfd/
* elflink.c (_bfd_elf_is_start_stop): New function.
(_bfd_elf_gc_mark_rsec): Use it.
* elf-bfd.h (_bfd_elf_is_start_stop): Declare.

8 years agoadd casts to avoid arithmetic on void *
Trevor Saunders [Wed, 13 Apr 2016 09:17:31 +0000 (05:17 -0400)]
add casts to avoid arithmetic on void *

arithmetic on void * is undefined in ISO C, so we should avoid it.  In
GNU C sizeof void * is defined as 1, and that is pretty clearly what
this code wants, so change it to do arithmetic on bfd_byte *.
Unfortunately most of the argument types come from virtual function
interfaces so changing the types to bfd_byte * isn't trivial though it
might make the code clearer.  So for the moment its easiest to leave the
variable types as void * and cast before doing arithmetic.

bfd/ChangeLog:

2016-04-26  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* elf32-rx.c (rx_set_section_contents): Avoid arithmetic on void *.
* mmo.c (mmo_get_section_contents): Likewise.
(mmo_set_section_contents): Likewise.

8 years agoAutomatic date update in version.in
GDB Administrator [Wed, 27 Apr 2016 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agofort_dyn_array: Use value constructor instead of raw-buffer manipulation.
Keven Boell [Tue, 26 Apr 2016 14:46:48 +0000 (16:46 +0200)]
fort_dyn_array: Use value constructor instead of raw-buffer manipulation.

Instead of pre-computing indices into a fortran array re-use
the value_* interfaces to subscript a fortran array.
The benefit of using the new interface is that it takes care of
dynamic types and resolve them when needed.
This fixes issues when printing structures with dynamic arrays from toplevel.

Before:
(gdb) p twov
$1 = ( (( ( 6352320, 0, -66, -1, 267) ( 343476, 1, -15, 1, 0) ( 5, 0, 5, 0, 1) ...

After:
(gdb) p twov
$1 = ( (( ( 1, 1, 1, 1, 1) ( 1, 1, 321, 1, 1) ( 1, 1, 1, 1, 1) ...

2016-04-26  Sanimir Agovic  <sanimir.agovic@intel.com>
            Keven Boell  <keven.boell@intel.com>
            Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
* f-valprint.c (f77_create_arrayprint_offset_tbl): Remove
function.
(F77_DIM_SIZE, F77_DIM_OFFSET): Remove macro.
(f77_print_array_1): Use value_subscript to subscript a
value array.
(f77_print_array): Remove call to f77_create_arrayprint_offset_tbl.
(f_val_print): Use value_field to construct a field value.

gdb/testsuite/Changelog:
* vla-type.exp: Print structure from toplevel.

8 years agofort_dyn_array: Support evaluation of dynamic elements inside arrays.
Bernhard Heckel [Tue, 26 Apr 2016 14:38:19 +0000 (16:38 +0200)]
fort_dyn_array: Support evaluation of dynamic elements inside arrays.

Resolve type of an array's element to be printed in case it is dynamic.
Otherwise we don't use the correct boundaries nor the right location.

Before:
  ptype fivearr(1)
  type = Type five
      Type one
          integer(kind=4) :: ivla(34196784:34196832,34197072:34197120,34197360:34197408)
      End Type one :: tone
  End Type five

After:
  ptype fivearr(1)
  type = Type five
      Type one
          integer(kind=4) :: ivla(2,4,6)
      End Type one :: tone
  End Type five

2016-04-26  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
* valarith.c (value_address): Resolve dynamic types.

gdb/testsuite/Changelog:
* gdb.fortran/vla-type.f90: Add test for static and dynamic arrays
of dynamic types.
* gdb.fortran/vla-type.exp: Add test for static and dynamic arrays
of dynamic types.

8 years agofort_dyn_array: Enable dynamic member types inside a structure.
Bernhard Heckel [Tue, 26 Apr 2016 14:28:43 +0000 (16:28 +0200)]
fort_dyn_array: Enable dynamic member types inside a structure.

Fortran supports dynamic types for which bounds, size and location
can vary during their lifetime. As a result of the dynamic
behaviour, they have to be resolved at every query.
This patch will resolve the type of a structure field when it
is dynamic.

2016-04-26  Bernhard Heckel  <bernhard.heckel@intel.com>
2016-04-26  Keven Boell  <keven.boell@intel.com>

Before:
(gdb) print threev%ivla(1)
Cannot access memory at address 0x3
(gdb) print threev%ivla(5)
no such vector element

After:
(gdb) print threev%ivla(1)
$9 = 1
(gdb) print threev%ivla(5)
$10 = 42

gdb/Changelog:

* NEWS: Add new supported features for fortran.
* gdbtypes.c (remove_dyn_prop): New.
(resolve_dynamic_struct): Keep type length for fortran structs.
* gdbtypes.h: Forward declaration of new function.
* value.c (value_address): Return dynamic resolved location of a value.
(set_value_component_location): Adjust the value address
for single value prints.
(value_primitive_field): Support value types with a dynamic location.
(set_internalvar): Remove dynamic location property of
internal variables.

gdb/testsuite/Changelog:

* gdb.fortran/vla-type.f90: New file.
* gdb.fortran/vla-type.exp: New file.

8 years agoAlways count the NULL entry in dynamic symbol table
H.J. Lu [Tue, 26 Apr 2016 10:53:07 +0000 (03:53 -0700)]
Always count the NULL entry in dynamic symbol table

There is an unused NULL entry at the head of dynamic symbol table which
we must account for in our count even if the table is empty or unused
since it is intended for the mandatory DT_SYMTAB tag (.dynsym section)
in .dynamic section.

* elf-bfd.h (elf_link_hash_table): Update comments for
dynsymcount.
* elflink.c (_bfd_elf_link_renumber_dynsyms): Always count for
the unused NULL entry at the head of dynamic symbol table.
(bfd_elf_size_dynsym_hash_dynstr): Remove dynsymcount != 0
checks.

8 years agoAutomatic date update in version.in
GDB Administrator [Tue, 26 Apr 2016 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoAllow powerpc64le-linux-gnu toolchain to support big endian targets as well.
Nick Clifton [Mon, 25 Apr 2016 16:25:27 +0000 (17:25 +0100)]
Allow powerpc64le-linux-gnu toolchain to support big endian targets as well.

PR target/19985
* configure.tgt: Include big endian PPC64 emulations with little
endian PPC64 targets.

8 years agoAVR: Allow the start address of the .text section to be set by --section-start.
Senthil Kumar Selvaraj [Mon, 25 Apr 2016 12:14:10 +0000 (13:14 +0100)]
AVR: Allow the start address of the .text section to be set by --section-start.

* scripttempl/avrtiny.sc (.text): Do not set LMA to zero.

8 years agoNew test case gdb.base/branch-to-self.exp
Yao Qi [Mon, 25 Apr 2016 08:53:51 +0000 (09:53 +0100)]
New test case gdb.base/branch-to-self.exp

gdb/testsuite:

2016-04-25  Yao Qi  <yao.qi@linaro.org>

* gdb.base/branch-to-self.c: New file.
* gdb.base/branch-to-self.exp: New file.

8 years agoResume the inferior with signal rather than stepping over
Yao Qi [Mon, 25 Apr 2016 08:46:36 +0000 (09:46 +0100)]
Resume the inferior with signal rather than stepping over

When GDBserver steps over a breakpoint using software single step, it
enqueues the signal, single step and deliver the signal in the next
resume if step over is not needed.  In this way, the program won't
receive the signal if the conditional breakpoint is set a branch to
self instruction, because the step over is always needed.

This patch removes the restriction that don't deliver the signal to
the inferior if we are trying to reinsert a breakpoint for software
single step and change the decision on resume vs. step-over when the
LWP has pending signals to deliver.

gdb/gdbserver:

2016-04-25  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (lwp_signal_can_be_delivered): Adjust.
(need_step_over_p): Return zero if the LWP has pending signals
can be delivered on software single step target.

8 years ago[GDBserver] Don't error in reinsert_raw_breakpoint if bp->inserted
Yao Qi [Mon, 25 Apr 2016 08:46:36 +0000 (09:46 +0100)]
[GDBserver] Don't error in reinsert_raw_breakpoint if bp->inserted

GDBserver steps over a breakpoint while the single step breakpoint
is inserted at the same address, there are two breakpoint objects
using single raw breakpoint, which is inserted (for single step).
When step over is finished, GDBserver reinsert the breakpoint, but
it finds the raw breakpoint is already inserted, and error out
"Breakpoint already inserted at reinsert time."  Even if I change the
order to delete reinsert breakpoints first (which only decreases the
refcount, but leave inserted flag unchanged), the error is still
there.

The fix is to remove the error and return instead.

gdb/gdbserver:

2016-04-25  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (reinsert_raw_breakpoint): If bp->inserted is true
return instead of error.

8 years agoInsert breakpoint even when the raw breakpoint is found
Yao Qi [Mon, 25 Apr 2016 08:43:36 +0000 (09:43 +0100)]
Insert breakpoint even when the raw breakpoint is found

When GDBserver inserts a breakpoint, it looks for raw breakpoint, if
the raw breakpoint is found, increase its refcount, and return.  This
doesn't work when it steps over a breakpoint using software single
step and the underneath instruction of breakpoint is branch to self.

When stepping over a breakpoint on ADDR using software single step,
GDBserver uninsert the breakpoint, so the corresponding raw breakpoint
RAW's 'inserted' flag is zero.  Then, GDBserver insert single step
breakpoint at the same address ADDR because the instruction is branch
to self, the same raw brekapoint RAW is found, and increase the
refcount.  However, the raw breakpoint is not inserted, and the
program won't stop.

gdb/gdbserver:

2016-04-25  Pedro Alves  <palves@redhat.com>
    Yao Qi  <yao.qi@linaro.org>

* mem-break.c (set_raw_breakpoint_at): Create a raw breakpoint
object.  Insert it if it is not inserted yet.  Increase the
refcount and link it into the proc's raw breakpoint list.

8 years agoForce to insert software single step breakpoint
Yao Qi [Mon, 25 Apr 2016 08:16:21 +0000 (09:16 +0100)]
Force to insert software single step breakpoint

GDB doesn't insert software single step breakpoint if the instruction
branches to itself, so that the program can't stop after command "si".

(gdb) b 32
Breakpoint 2 at 0x8680: file git/gdb/testsuite/gdb.base/branch-to-self.c, line 32.
(gdb) c
Continuing.

Breakpoint 2, main () at gdb/git/gdb/testsuite/gdb.base/branch-to-self.c:32
32   asm (".Lhere: " BRANCH_INSN " .Lhere"); /* loop-line */
(gdb) si
infrun: clear_proceed_status_thread (Thread 3991.3991)
infrun: proceed (addr=0xffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: step-over queue now empty
infrun: resuming [Thread 3991.3991] for step-over
infrun: skipping breakpoint: stepping past insn at: 0x8680
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sending packet: $Z0,8678,4#f3...Packet received: OK
infrun: skipping breakpoint: stepping past insn at: 0x8680
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sending packet: $Z0,b6fe86c8,4#82...Packet received: OK
infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=1, current thread [Thread 3991.3991] at 0x868

breakpoint.c:should_be_inserted thinks the breakpoint shouldn't be
inserted, which is wrong.  This patch restrict the condition that
only skip the non-single-step breakpoints if they are inserted at
the place we are stepping over, however we don't want to skip
single-step breakpoint if its thread is the thread we are stepping
over, so in this patch, I add a thread num in 'struct step_over_info'
to record the thread we're stepping over.

gdb:

2016-04-25  Yao Qi  <yao.qi@linaro.org>

* breakpoint.c (should_be_inserted): Return 0 if the location's
owner is not single step breakpoint or single step breakpoint's
thread isn't the thread which is stepping past a breakpoint.
* gdbarch.sh (software_single_step): Update comments.
* gdbarch.h: Regenerated.
* infrun.c (struct step_over_info) <thread>: New field.
(set_step_over_info): New argument 'thread'.  Callers updated.
(clear_step_over_info): Set field thread to -1.
(thread_is_stepping_over_breakpoint): New function.
* infrun.h (thread_is_stepping_over_breakpoint): Declaration.

8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 25 Apr 2016 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoAutomatic date update in version.in
GDB Administrator [Sun, 24 Apr 2016 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoSkip if size of bfd_vma is smaller than address size
H.J. Lu [Sat, 23 Apr 2016 16:32:59 +0000 (09:32 -0700)]
Skip if size of bfd_vma is smaller than address size

Disassembler won't work properly when size of bfd_vma is smaller than
address size.

PR binutils/19983
PR binutils/19984
* i386-dis.c (print_insn): Return -1 if size of bfd_vma is
smaller than address size.

8 years agoAutomatic date update in version.in
GDB Administrator [Sat, 23 Apr 2016 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoFix checks for VSX and Altivec availability on Power
Edjunior Barbosa Machado [Fri, 22 Apr 2016 22:39:12 +0000 (19:39 -0300)]
Fix checks for VSX and Altivec availability on Power

gdb/ChangeLog

* ppc-linux-nat.c (ppc_linux_read_description): Use PPC_FEATURE_HAS_VSX
and PPC_FEATURE_HAS_ALTIVEC to check if such features are available.

8 years agoFix fails in gdb.trace/unavailable.exp
Yao Qi [Fri, 22 Apr 2016 16:23:23 +0000 (17:23 +0100)]
Fix fails in gdb.trace/unavailable.exp

I am seeing some test fails in gdb.trace/unavailable.exp on aarch64-linux,
like this,

print derived_whole^M
$43 = (Derived) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = 0x401860 <VTT for Derived>, y = 3}, _vptr.Derived = 0x401848 <vtable for Derived+32>, z = 4}^M
(gdb) FAIL: gdb.trace/unavailable.exp: collect globals: print object on: print derived_whole

print derived_whole^M
$47 = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = 0x401860 <VTT for Derived>, y = 3}, _vptr.Derived = 0x401848 <vtable for Derived+32>, z = 4}^M
(gdb) FAIL: gdb.trace/unavailable.exp: collect globals: print object off: print derived_whole

these fails are also found by recent x86_64-linux buildbot,
https://sourceware.org/ml/gdb-testers/2016-q2/msg00622.html

The fix is exactly the same as this one
http://www.sourceware.org/ml/gdb-patches/2015-10/msg00252.html (the
extra "VTT" after hex), in which we match extra things after $hex.

gdb/testsuite:

2016-04-22  Yao Qi  <yao.qi@linaro.org>

* gdb.trace/unavailable.exp (gdb_collect_globals_test_1): Match
more after $hex.

8 years agoChoose TARGET_OBJECT_STACK_MEMORY and TARGET_OBJECT_MEMORY in read_value_memory
Yao Qi [Fri, 22 Apr 2016 16:18:31 +0000 (17:18 +0100)]
Choose TARGET_OBJECT_STACK_MEMORY and TARGET_OBJECT_MEMORY in read_value_memory

Before this patch
https://sourceware.org/ml/gdb-patches/2014-02/msg00709.html
read_value_memory checks parameter 'stack', and call read_stack or
read_memory respectively.  However, 'stack' is not checked and
TARGET_OBJECT_MEMORY is always used in target_xfer_partial, which is
a mistake in the patch above.

This patch checks parameter 'stack', and choose TARGET_OBJECT_MEMORY
or TARGET_OBJECT_STACK_MEMORY accordingly.

gdb:

2016-04-22  Yao Qi  <yao.qi@linaro.org>

* valops.c (read_value_memory): New local variable 'stack'.
Set it to either TARGET_OBJECT_STACK_MEMORY or
TARGET_OBJECT_MEMORY.

8 years agoCentralize yacc interface names remapping (yyparse, yylex, yyerror, etc)
Pedro Alves [Fri, 22 Apr 2016 15:40:33 +0000 (16:40 +0100)]
Centralize yacc interface names remapping (yyparse, yylex, yyerror, etc)

This factors out all the yy-variables remapping to a single file,
instead of each parser having to do the same, with different prefixes.

With this, a parser just needs to define the prefix they want and
include yy-remap.h, which does the dirty job.

Note this renames the c_error, ada_error, etc. functions.  Writing the
remapping pattern as:

 #define yyerror GDB_YY_REMAP (error)

instead of:

 #define yyerror GDB_YY_REMAP (yyerror)

would have avoided the renaming.  However, that would be problematic
if we have a macro 'foo' in scope, when we write:

 #define yyfoo GDB_YY_REMAP (foo)

as that would expand 'foo'.

The c_yyerror etc. naming end ups indicating that this is a yacc
related function more clearly, so feels like a good change, anyway.

gdb/ChangeLog:
2016-04-22  Pedro Alves  <palves@redhat.com>

* ada-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* ada-lang.c (ada_language_defn): Adjust.
* ada-lang.h (ada_error): Rename to ...
(ada_yyerror): ... this.
* c-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Adjust.
* c-lang.h (c_error): Rename to ...
(c_yyerror): ... this.
* d-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* d-lang.c (d_language_defn): Adjust.
* d-lang.h (d_error): Rename to ...
(d_yyerror): ... this.
* f-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* f-lang.c (f_language_defn): Adjust.
* f-lang.h (f_error): Rename to ...
(f_yyerror): ... this.
* go-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* go-lang.c (go_language_defn): Adjust.
* go-lang.h (go_error): Rename to ...
(go_yyerror): ... this.
* jv-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* jv-lang.c (java_language_defn): Adjust.
* jv-lang.h (java_error): Rename to ...
(java_yyerror): ... this.
* m2-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* m2-lang.c (m2_language_defn): Adjust.
* m2-lang.h (m2_error): Rename to ...
(m2_yyerror): ... this.
* objc-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* objc-lang.c (objc_language_defn): Adjust.
* opencl-lang.c (opencl_language_defn): Adjust.
* p-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* p-lang.c (pascal_language_defn): Adjust.
* p-lang.h (pascal_error): Rename to ...
(pascal_yyerror): ... this.
* yy-remap.h: New file.

8 years agoSwitch gdb's TRY/CATCH to C++ try/catch
Pedro Alves [Fri, 22 Apr 2016 15:18:33 +0000 (16:18 +0100)]
Switch gdb's TRY/CATCH to C++ try/catch

The exceptions-across-readline issue was fixed by the previous commit.
Let's try this again.

gdb/ChangeLog:
2016-04-22  Pedro Alves  <palves@redhat.com>

* common/common-exceptions.h (GDB_XCPT_TRY): Remove mention of
the foreign frames issue.
[__cplusplus] (GDB_XCPT): Define as GDB_XCPT_TRY.

8 years agoPropagate GDB/C++ exceptions across readline using sj/lj-based TRY/CATCH
Pedro Alves [Fri, 22 Apr 2016 15:18:33 +0000 (16:18 +0100)]
Propagate GDB/C++ exceptions across readline using sj/lj-based TRY/CATCH

If we map GDB'S TRY/CATCH macros to C++ try/catch, GDB breaks on
systems where readline isn't built with exceptions support.  The
problem is that readline calls into GDB through the callback
interface, and if GDB's callback throws a C++ exception/error, the
system unwinder won't manage to unwind past the readline frame, and
ends up calling std::terminate(), which aborts the process:

 (gdb) whatever-command-that-causes-an-error
 terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
 Aborted
 $

This went unnoticed for so long because:

- the x86-64 ABI requires -fasynchronous-unwind-tables, making it
  possible for exceptions to cross readline with no special handling.
  But e.g., on ARM or AIX, unless you build readline with
  -fexceptions, you trip on the problem.

- TRY/CATCH was mapped to setjmp/longjmp, even in C++ mode, until
  quite recently.

The fix is to catch and save any GDB exception that is thrown inside
the GDB readline callback, and then once the callback returns back to
the GDB code that called into readline in the first place, rethrow the
saved GDB exception.

This is similar in spirit to how we catch/map GDB exceptions at the
GDB/Python and GDB/Guile API boundaries.

The next question is then: if we intercept all exceptions within GDB's
readline callback, should we simply return normally to readline?  The
callback prototype has no way to signal an error back to readline (*).
The answer is no -- if we return normally, we'll be returning to a
loop inside rl_callback_read_char that continues processing pending
input, calling into GDB again, redisplaying the prompt, etc.  Thus if
we want to error out of rl_callback_read_char, we need to long jump
across it, just like we always did before TRY/CATCH were ever mapped
to C++ exceptions.

My first approach built a specialized API to handle this, with a
couple macros to hide the setjmp/longjmp and the struct gdb_exception
saving/rethrowing.

However, I realized that we need to:

 - Handle multiple active rl_callback_read_char invocations.  If,
   while processing input something triggers a secondary prompt, we
   end up in a nested rl_callback_read_char call, through
   gdb_readline_wrapper.

 - Propagate a struct gdb_exception along with the longjmp.

... and that this is exactly what the setjmp/longjmp-based TRY/CATCH
does.

So the fix makes the setjmp/longjmp TRY/CATCH always available under
new TRY_SJLJ/CATCH_SJLJ aliases, even when TRY/CATCH is mapped to C++
try/catch, and then uses TRY_SJLJ/CATCH_SJLJ to propagate GDB
exceptions across the readline callback.

This turns out to be a much better looking fix than my bespoke API
attempt, even.  We'll probably be able to simplify TRY_SJLJ/CATCH_SJLJ
when we finally get rid of TRY/CATCH all over the tree, but until
then, this reuse seems quite nice for avoiding a second parallel
setjmp/longjmp mechanism.

(*) - maybe we could propose a readline API change, but we still need
      to handle current readline, anyway.

gdb/ChangeLog:
2016-04-22  Pedro Alves  <palves@redhat.com>

* common/common-exceptions.c (enum catcher_state, struct catcher)
(current_catcher): Define in C++ mode too.
(exceptions_state_mc_catch): Call throw_exception_sjlj instead of
throw_exception.
(throw_exception_sjlj, throw_exception_cxx): New functions,
factored out from throw_exception.
(throw_exception): Reimplement.
* common/common-exceptions.h (exceptions_state_mc_init)
(exceptions_state_mc_action_iter)
(exceptions_state_mc_action_iter_1, exceptions_state_mc_catch):
Declare in C++ mode too.
(TRY): Rename to ...
(TRY_SJLJ): ... this.
(CATCH): Rename to ...
(CATCH_SJLJ): ... this.
(END_CATCH): Rename to ...
(END_CATCH_SJLJ): ... this.
[GDB_XCPT == GDB_XCPT_SJMP] (TRY, CATCH, END_CATCH): Map to SJLJ
equivalents.
(throw_exception): Update comments.
(throw_exception_sjlj): Declare.
* event-top.c (gdb_rl_callback_read_char_wrapper): Extend intro
comment.  Wrap body in TRY_SJLJ/CATCH_SJLJ and rethrow any
intercepted exception.
(gdb_rl_callback_handler): New function.
(gdb_rl_callback_handler_install): Always install
gdb_rl_callback_handler as readline callback.

8 years agoRename rl_callback_read_char_wrapper -> gdb_rl_callback_read_char_wrapper
Pedro Alves [Fri, 22 Apr 2016 15:18:33 +0000 (16:18 +0100)]
Rename rl_callback_read_char_wrapper -> gdb_rl_callback_read_char_wrapper

Use the "gdb_rl_" prefix like other gdb readline function wrappers to
make it clear this is a gdb function, not a readline function.

gdb/ChangeLog:
2016-04-22  Pedro Alves  <palves@redhat.com>

* event-top.c (rl_callback_read_char_wrapper): Rename to ...
(gdb_rl_callback_read_char_wrapper): ... this.
(change_line_handler, gdb_setup_readline): Adjust.

8 years ago[ARM] Clear reserved bits in CPSR
Yao Qi [Fri, 22 Apr 2016 14:53:05 +0000 (15:53 +0100)]
[ARM] Clear reserved bits in CPSR

Bits 20 ~ 23 of CPSR are reserved (RAZ, read as zero), but they are not
zero if the arm program runs on aarch64-linux.  AArch64 tracer gets PSTATE
from arm 32-bit tracee as CPSR, but bits 20 ~ 23 are used in PSTATE.  I
think kernel should clear these bits when it is read through ptrace, but
the fix in user space is still needed.

This patch fixes these two fails,

-FAIL: gdb.reverse/insn-reverse.exp: ext_reg_push_pop: compare registers on insn 0:vldr d7, [r11, #-12]
-FAIL: gdb.reverse/insn-reverse.exp: ext_reg_push_pop: compare registers on insn 0:vldr d7, [r7]

gdb:

2016-04-22  Yao Qi  <yao.qi@linaro.org>

* aarch32-linux-nat.c (aarch32_gp_regcache_supply): Clear CPSR
bits 20 to 23.

gdb/gdbserver:

2016-04-22  Yao Qi  <yao.qi@linaro.org>

* linux-aarch32-low.c (arm_store_gregset): Clear CPSR bits 20
to 23.

8 years agoFix fail in gdb.base/annota1.exp and gdb.base/annota3.exp
Yao Qi [Fri, 22 Apr 2016 14:35:07 +0000 (15:35 +0100)]
Fix fail in gdb.base/annota1.exp and gdb.base/annota3.exp

Hi,

I am seeing the fail below on aarch64-linux with gcc 4.9.2,

break main
Breakpoint 1 at 0x4006e8: file binutils-gdb/gdb/testsuite/gdb.base/annota1.c, line 14.^M
(gdb) FAIL: gdb.base/annota1.exp: breakpoint main

the test expects the breakpoint is set on line 15.  Let us look at
the main function,

12 int
13 main (void)
14 {
15   int my_array[3] = { 1, 2, 3 };  /* break main */
16
17   value = 7;
18
19 #ifdef SIGUSR1
20   signal (SIGUSR1, handle_USR1);
21 #endif

(gdb) disassemble main
Dump of assembler code for function main:
   0x00000000004006e0 <+0>: stp x29, x30, [sp,#-48]!
   0x00000000004006e4 <+4>: mov x29, sp
   0x00000000004006e8 <+8>: adrp x0, 0x411000 <signal@got.plt>
   0x00000000004006ec <+12>: add x0, x0, #0x40

the breakpoint is set on the right address after skipping prologue, but
0x00000000004006e8 is mapped to the line 14, as shown below,

(gdb) maintenance info line-table
objfile: /home/yao.qi/source/build-aarch64/gdb/testsuite/outputs/gdb.base/annota1/annota1 ((struct objfile *) 0x2b0e1850)
compunit_symtab: ((struct compunit_symtab *) 0x2b0ded50)
symtab: /home/yao.qi/source/binutils-gdb/gdb/testsuite/gdb.base/annota1.c ((struct symtab *) 0x2b0dedd0)
linetable: ((struct linetable *) 0x2b12c8b0):
INDEX    LINE ADDRESS
0           7 0x00000000004006d0
1           8 0x00000000004006d8
2          14 0x00000000004006e0
3          14 0x00000000004006e8
4          15 0x00000000004006fc

so GDB does nothing wrong.  Program hits breakpoint on either line 14
or line 15 is right to me.  With anther gcc (4.9.3), the line-table looks
correct, and no test fail.  Instead of setting breakpoint on main and
assuming the line is what we get from the source, we can set breakpoint
on that line.  On the other hand, the test prints the values of the
array and check, so we need to set breakpoint on the line setting the
values of array and "next", rather than setting the breakpoint on main.

gdb/testsuite:

2016-04-22  Yao Qi  <yao.qi@linaro.org>

* gdb.base/annota1.exp: Set breakpoint on line $main_line.
* gdb.base/annota3.exp: Likewise.

8 years agoJoel Brobecker stepping down as AIX Maintainer
Joel Brobecker [Fri, 22 Apr 2016 14:16:31 +0000 (10:16 -0400)]
Joel Brobecker stepping down as AIX Maintainer

gdb/ChangeLog:

        * MAINTAINERS: Remove myself as AIX Maintainer.

8 years ago[obv] [PR gdb/19980] Typo in gdbserver/configure.srv
Walfred Tedeschi [Fri, 22 Apr 2016 12:23:29 +0000 (14:23 +0200)]
[obv] [PR gdb/19980] Typo in gdbserver/configure.srv

Simple exchange of mpx-avx for avx-mpx.
Other occurrences were not found.

2016-04-22  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/gdbserver/ChangeLog:

* configure.srv (srv_amd64_xmlfiles): Exchange
i386/amd64-mpx-avx.xml for i386/amd64-avx-mpx.xml.

8 years agoTweak gdb.reverse/step-precsave.exp and gdb.reverse/step-reverse.exp
Yao Qi [Fri, 22 Apr 2016 11:14:40 +0000 (12:14 +0100)]
Tweak gdb.reverse/step-precsave.exp and gdb.reverse/step-reverse.exp

I see the following test fail in arm-linux with -marm and -fomit-frame-pointer,

 step
 callee () at /home/yao/SourceCode/gnu/gdb/git/gdb/testsuite/gdb.reverse/step-reverse.c:27
 27      }                       /* RETURN FROM CALLEE */
 (gdb) step
 main () at /home/yao/SourceCode/gnu/gdb/git/gdb/testsuite/gdb.reverse/step-reverse.c:58
 58         callee();    /* STEP INTO THIS CALL */
 (gdb) FAIL: gdb.reverse/step-precsave.exp: reverse step into fn call

As we can see, the "step" has already stepped into the function callee,
but in the last line.  The second "step" attempts to step to function
body, but it goes out of callee, which isn't expected.

The program is compiled with -marm and -fomit-frame-pointer, the
function callee is prologue-less, because nothing needs to be saved
on stack,

(gdb) disassemble callee
Dump of assembler code for function callee:
   0x00010680 <+0>: movw r3, #2364 ; 0x93c
   0x00010684 <+4>: movt r3, #2
   0x00010688 <+8>: ldr r3, [r3]
   0x0001068c <+12>: add r2, r3, #1
   0x00010690 <+16>: movw r3, #2364 ; 0x93c
   0x00010694 <+20>: movt r3, #2
   0x00010698 <+24>: str r2, [r3]
   0x0001069c <+28>: mov r3, #0
   0x000106a0 <+32>: mov r0, r3
   0x000106a4 <+36>: bx lr

program stops at the 0x106a0 (passed the epilogue) after the first
"step".  When second "step" is executed, the stepping range is
[0x10680-0x106a0], which starts from the first instruction of function
callee (because it doesn't have prologue).

infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=0, current thread [LWP 2461] at 0x1069c^M
infrun: prepare_to_wait^M
infrun: target_wait (-1.0.0, status) =^M
infrun:   2461.2461.0 [LWP 2461],^M
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP^M
infrun: TARGET_WAITKIND_STOPPED^M
infrun: stop_pc = 0x10698^M
infrun: stepping inside range [0x10680-0x106a0]

When program goes out of the range, it stops at the caller of callee,
and test fails.  IOW, if function callee has prologue, the stepping
range won't start from the first instruction of the function, and
program stops at the prologue and test passes.

IMO, GDB does nothing wrong, but test shouldn't expect the program
stops in callee after the second "step".  I decide to fix test rather
than GDB.  In this patch, I change to test to do one "step", and check
the program is still in callee, then, do multiple "step" until program
goes out of the callee.

gdb/testsuite:

2016-04-22  Yao Qi  <yao.qi@linaro.org>

* gdb.reverse/step-precsave.exp: Do one step and test program
stops in "callee" and do multiple steps until program goes out
of "callee".
* gdb.reverse/step-reverse.exp: Likewise.

8 years agoDeliver signal in hardware single step
Yao Qi [Fri, 22 Apr 2016 10:59:18 +0000 (11:59 +0100)]
Deliver signal in hardware single step

GDBserver doesn't deliver signal when stepping over a breakpoint even
hardware single step is used.  When GDBserver started to step over
(thread creation) breakpoint for mutlit-threaded debugging in 2002 [1],
GDBserver behaves this way.

This behavior gets trouble on conditional breakpoints on branch to
self instruction like this,

   0x00000000004005b6 <+29>: jmp    0x4005b6 <main+29>

and I set breakpoint

$(gdb) break branch-to-self.c:43 if counter > 3

and the variable counter will be set to 5 in SIGALRM signal handler.
Since GDBserver keeps stepping over breakpoint, the SIGALRM can never
be dequeued and delivered to the inferior, so the program can't stop.
The test can be found in gdb.base/branch-to-self.exp.

GDBserver didn't deliver signal when stepping over a breakpoint because
a tracepoint is collected twice if GDBserver does so in the following
scenario, which can be reproduced by gdb.trace/signal.exp.

 - program stops at tracepoint, and tracepoint is collected,
 - gdbserver starts a step-over,
 - a signal arrives, step-over is canceled, and signal should be passed,
 - gdbserver starts a new step-over again, pass the signal as well,
 - program stops at the entry of signal handler, step-over finished,
 - gdbserver proceeds,
 - program returns from the signal handler, again to the tracepoint,
   and thus is collected again.

The spurious collection isn't that harmful, IMO, so it should be OK
to let GDBserver deliver signal when stepping over a breakpoint.

gdb/gdbserver:

2016-04-22  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (lwp_signal_can_be_delivered): Don't deliver
signal when stepping over breakpoint with software single
step.

gdb/testsuite:

2016-04-22  Yao Qi  <yao.qi@linaro.org>

* gdb.trace/signal.exp: Also pass if
$tracepoint_hits($i) > $iterations.

8 years agoNew test case gdb.trace/signal.exp
Yao Qi [Fri, 22 Apr 2016 10:59:18 +0000 (11:59 +0100)]
New test case gdb.trace/signal.exp

This is to test whether GDBserver deliver signal to the inferior while
doing the step over.  Nowadays, GDBserver doesn't deliver signal, so
there won't be spurious collection, however, if GDBserver does deliver
signal, there might be spurious collection.

gdb/testsuite:

2016-04-22  Yao Qi  <yao.qi@linaro.org>

* gdb.trace/signal.c: New file.
* gdb.trace/signal.exp: New file.

8 years agoExclude linker created file from dynobj
H.J. Lu [Fri, 22 Apr 2016 04:45:57 +0000 (21:45 -0700)]
Exclude linker created file from dynobj

Some ELF targets create a "linker stubs" fake bfd.  Don't use it to
set dynobj.

* elflink.c (_bfd_elf_link_create_dynstrtab): Exclude linker
created file from dynobj.

8 years agoSet dynobj to a normal input file if possible
H.J. Lu [Fri, 22 Apr 2016 02:14:10 +0000 (19:14 -0700)]
Set dynobj to a normal input file if possible

When check_relocs is called after gc-sections has run,
_bfd_elf_link_create_dynstrtab may be called with an dynamic object
and hash_table->dynobj may be NULL.  We may not set dynobj, an input
file holding linker created dynamic sections to the dynamic object,
which has its own dynamic sections.  We need to find a normal input
file to hold linker created sections if possible.  Otherwise ld will
crash during LTO input rescan when linker created dynamic section
overrides input dynamic section.

* elflink.c (_bfd_elf_link_create_dynstrtab): Set dynobj to a
normal input file if possible.

8 years agoMIPS/GAS: Fix an ISA override not lifting ABI restrictions
Maciej W. Rozycki [Fri, 22 Apr 2016 00:04:52 +0000 (01:04 +0100)]
MIPS/GAS: Fix an ISA override not lifting ABI restrictions

Correct a regression introduced with commit 919731affbef ("Add MIPS
.module directive") causing code like:

.set mips3
dli $2, 0x9000000080000000

to fail assembly with the following error message produced:

Error: number (0x9000000080000000) larger than 32 bits

if built with `mips3' selected as the global ISA (e.g. `-march=mips3').
This is because a `.set' directive doing an ISA override does not lift
the ABI restriction on register sizes if the ISA remains unchanged.
Previously the directive always set register sizes from the ISA chosen,
which is what some code expects.  Restore the old semantics then.

gas/
* config/tc-mips.c (code_option_type): New enum.
(parse_code_option): Return status indicating option type.
(s_mipsset): Update `parse_code_option' call site accordingly.
Always set register sizes from the ISA with ISA overrides.
(s_module): Update `parse_code_option' call site.
* testsuite/gas/mips/isa-override-1.d: New test.
* testsuite/gas/mips/micromips@isa-override-1.d: New test.
* testsuite/gas/mips/mips1@isa-override-1.d: New test.
* testsuite/gas/mips/mips2@isa-override-1.d: New test.
* testsuite/gas/mips/mips32@isa-override-1.d: New test.
* testsuite/gas/mips/mips32r2@isa-override-1.d: New test.
* testsuite/gas/mips/mips32r3@isa-override-1.d: New test.
* testsuite/gas/mips/mips32r5@isa-override-1.d: New test.
* testsuite/gas/mips/mips32r6@isa-override-1.d: New test.
* testsuite/gas/mips/mips64r2@isa-override-1.d: New test.
* testsuite/gas/mips/mips64r3@isa-override-1.d: New test.
* testsuite/gas/mips/mips64r5@isa-override-1.d: New test.
* testsuite/gas/mips/mips64r6@isa-override-1.d: New test.
* testsuite/gas/mips/r3000@isa-override-1.d: New test.
* testsuite/gas/mips/r3900@isa-override-1.d: New test.
* testsuite/gas/mips/r5900@isa-override-1.d: New test.
* testsuite/gas/mips/octeon@isa-override-1.d: New test.
* testsuite/gas/mips/octeon3@isa-override-1.d: New test.
* testsuite/gas/mips/isa-override-2.l: New list test.
* testsuite/gas/mips/mips1@isa-override-2.l: New list test.
* testsuite/gas/mips/mips2@isa-override-2.l: New list test.
* testsuite/gas/mips/mips32@isa-override-2.l: New list test.
* testsuite/gas/mips/mips32r2@isa-override-2.l: New list test.
* testsuite/gas/mips/mips32r3@isa-override-2.l: New list test.
* testsuite/gas/mips/mips32r5@isa-override-2.l: New list test.
* testsuite/gas/mips/mips32r6@isa-override-2.l: New list test.
* testsuite/gas/mips/r3000@isa-override-2.l: New list test.
* testsuite/gas/mips/r3900@isa-override-2.l: New list test.
* testsuite/gas/mips/octeon3@isa-override-2.l: New list test.
* testsuite/gas/mips/octeon3@isa-override-1.l: New stderr
output.
* testsuite/gas/mips/isa-override-1.s: New test source.
* testsuite/gas/mips/r5900@isa-override-1.s: New test source.
* testsuite/gas/mips/isa-override-2.s: New test source.
* testsuite/gas/mips/mips1@isa-override-2.s: New test source.
* testsuite/gas/mips/mips2@isa-override-2.s: New test source.
* testsuite/gas/mips/mips32@isa-override-2.s: New test source.
* testsuite/gas/mips/mips32r2@isa-override-2.s: New test source.
* testsuite/gas/mips/mips32r3@isa-override-2.s: New test source.
* testsuite/gas/mips/mips32r5@isa-override-2.s: New test source.
* testsuite/gas/mips/mips32r6@isa-override-2.s: New test source.
* testsuite/gas/mips/r3000@isa-override-2.s: New test source.
* testsuite/gas/mips/r3900@isa-override-2.s: New test source.
* testsuite/gas/mips/octeon3@isa-override-2.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

8 years agoMIPS: Go back with the default Linux # of registers to 90
Maciej W. Rozycki [Mon, 18 Apr 2016 13:17:18 +0000 (14:17 +0100)]
MIPS: Go back with the default Linux # of registers to 90

Set the number of registers for non-XML-described Linux targets to 90,
reverting a change made here with the addition of DSP register support:

commit 1faeff088bbbd037d7769d214378b4faf805fa2e
Author: Maciej W. Rozycki <macro@linux-mips.org>
Date:   Thu Mar 1 22:19:48 2012 +0000

and fixing a regression introduced for legacy `gdbserver' targets
causing a "Remote 'g' packet reply is too long" error message where the
amount of register data received with a `g' packet (90) exceeds the
maximum number of registers expected (79).

Update the setting for XML-described targets, reflecting the actual
number of registers which have been assigned numbers, matching the:

      gdb_assert (gdbarch_num_regs (gdbarch) <= MIPS_RESTART_REGNUM);

requirement in `mips_linux_init_abi'.

gdb/
* mips-tdep.c (mips_gdbarch_init): For GDB_OSABI_LINUX set
`num_regs' to 90 rather than 79.  Where a target description is
present adjust the setting appropriately.

8 years agoAutomatic date update in version.in
GDB Administrator [Fri, 22 Apr 2016 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoSwitch gdb's TRY/CATCH to sjlj again
Pedro Alves [Thu, 21 Apr 2016 16:28:58 +0000 (17:28 +0100)]
Switch gdb's TRY/CATCH to sjlj again

We don't currently handle the case of gdb's readline callback throwing
gdb C++ exceptions across a readline that wasn't built with
-fexceptions.  The end result is:

 (gdb) whatever-command-that-causes-an-error
 terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
 Aborted
 $

Until that is fixed, revert back to sjlj-based exceptions again.

gdb/ChangeLog:
2016-04-21  Pedro Alves  <palves@redhat.com>

* common/common-exceptions.h (GDB_XCPT_TRY): Add comment.
(GDB_XCPT): Always define as GDB_XCPT_SJMP.

8 years agoAlways run LTO tests on Linux with GCC 4.9 or newer
H.J. Lu [Thu, 21 Apr 2016 16:04:18 +0000 (09:04 -0700)]
Always run LTO tests on Linux with GCC 4.9 or newer

Check for LTO availability will hide LTO bugs in ld.  Since GCC 4.9 adds
-ffat-lto-objects, we always run LTO tests on Linux with GCC 4.9 or newer.

* testsuite/lib/ld-lib.exp (check_lto_available): Return 1 on
Linux with GCC 4.9 or newer.
(check_lto_fat_available): Likewise.
(check_lto_shared_available): Likewise.

8 years agoAdd support for non-ELF targets to check their relocs.
Nick Clifton [Thu, 21 Apr 2016 14:43:00 +0000 (15:43 +0100)]
Add support for non-ELF targets to check their relocs.

bfd * aout-adobe.c: Use _bfd_generic_link_check_relocs.
* aout-target.h: Likewise.
* aout-tic30.c: Likewise.
* binary.c: Likewise.
* bout.c: Likewise.
* coff-alpha.c: Likewise.
* coff-rs6000.c: Likewise.
* coff64-rs6000.c: Likewise.
* coffcode.h: Likewise.
* i386msdos.c: Likewise.
* i386os9k.c: Likewise.
* ieee.c: Likewise.
* ihex.c: Likewise.
* libbfd-in.h: Likewise.
* libecoff.h: Likewise.
* mach-o-target.c: Likewise.
* mmo.c: Likewise.
* nlm-target.h: Likewise.
* oasys.c: Likewise.
* pef.c: Likewise.
* plugin.c: Likewise.
* ppcboot.c: Likewise.
* som.c: Likewise.
* srec.c: Likewise.
* tekhex.c: Likewise.
* versados.c: Likewise.
* vms-alpha.c: Likewise.
* xsym.c: Likewise.
* elfxx-target.h: Use _bfd_elf_link_check_relocs.
* linker.c (bfd_link_check_relocs): New function.
(_bfd_generic_link_check_relocs): New function.
* targets.c (BFD_JUMP_TABLE_LINK): Add initialization of
_bfd_link_check_relocs field.
(struct bfd_target)L Add _bfd_link_check_relocs field.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.

ld * ldlang.c (lang_check_relocs): Use bfd_link_check_relocs in
prefernce to _bfd_elf_link_check_relocs.  Drop test for ELF
targets.  Do not stop the checks when problems are encountered.

include * bfdlink.h: Add prototype for bfd_link_check_relocs.

8 years agoFix AIX gdb build with C++ compiler
Pedro Alves [Thu, 21 Apr 2016 13:02:20 +0000 (14:02 +0100)]
Fix AIX gdb build with C++ compiler

We currently get:

 ../../src/gdb/aix-thread.c: In function 'int pdc_read_data(pthdb_user_t, void*, pthdb_addr_t, size_t)':
 ../../src/gdb/aix-thread.c:465:46: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
    status = target_read_memory (addr, buf, len);
       ^

 ../../src/gdb/aix-thread.c: In function 'void aix_thread_resume(target_ops*, ptid_t, int, gdb_signal)':
 ../../src/gdb/aix-thread.c:1010:46: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
 gdb_signal_to_host (sig), (void *) tid);
       ^
 ../../src/gdb/aix-thread.c:243:1: error:   initializing argument 5 of 'int ptrace64aix(int, int, long long int, int, int*)' [-fpermissive]
  ptrace64aix (int req, int id, long long addr, int data, int *buf)

 ../../src/gdb/rs6000-nat.c: In function 'gdb_byte* rs6000_ptrace_ldinfo(ptid_t)':
 ../../src/gdb/rs6000-nat.c:596:36: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
    gdb_byte *ldi = xmalloc (ldi_size);
     ^
 ../../src/gdb/rs6000-nat.c:615:36: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
ldi = xrealloc (ldi, ldi_size);
     ^

(and more instances of the same).

gdb/ChangeLog:
2016-04-21  Pedro Alves  <palves@redhat.com>

* aix-thread.c (pdc_read_data, pdc_write_data): Add cast.
(aix_thread_resume): Use PTRACE_TYPE_ARG5.
* rs6000-nat.c (rs6000_ptrace64): Use PTRACE_TYPE_ARG5.
(rs6000_ptrace_ldinfo): Change type of 'ldi' local to void
pointer, and cast return to gdb_byte pointer.

8 years agoFix s390 GNU/Linux gdb and gdbserver builds
Pedro Alves [Thu, 21 Apr 2016 10:42:13 +0000 (06:42 -0400)]
Fix s390 GNU/Linux gdb and gdbserver builds

Now that gdb/gdbserver compile as C++ programs by default, the s390
GNU/Linux build started failing with:

 In file included from ../../src/gdb/common/common-defs.h:64:0,
  from ../../src/gdb/defs.h:28,
  from ../../src/gdb/s390-linux-nat.c:22:
 ../../src/gdb/s390-linux-nat.c: In function â€˜void fetch_regset(regcache*, int, int, int, const regset*)’:
 ../../src/gdb/../include/libiberty.h:711:38: error: invalid conversion from â€˜void*’ to â€˜gdb_byte* {aka unsigned char*}’ [-fpermissive]
  # define alloca(x) __builtin_alloca(x)
       ^
 ../../src/gdb/s390-linux-nat.c:297:19: note: in expansion of macro â€˜alloca’
    gdb_byte *buf = alloca (regsize);
    ^

etc.

gdb/ChangeLog:
2016-04-21  Pedro Alves  <palves@redhat.com>

* s390-linux-nat.c (fetch_regset, store_regset, check_regset): Use
void * instead of gdb_byte *.

gdb/gdbserver/ChangeLog:
2016-04-21  Pedro Alves  <palves@redhat.com>

* linux-s390-low.c (s390_collect_ptrace_register)
(s390_supply_ptrace_register, s390_get_hwcap): Use gdb_byte * and
add casts.
(s390_check_regset): Use void * instead of gdb_byte *.

8 years agoAdd missing sentinel 'char *' casts in concat/reconcat calls
Pedro Alves [Thu, 21 Apr 2016 10:34:18 +0000 (11:34 +0100)]
Add missing sentinel 'char *' casts in concat/reconcat calls

The wildebeest-debian-wheezy-i686 buildslave's build is broken due to:

 ../../binutils-gdb/gdb/python/python.c: In function void _initialize_python():
 ../../binutils-gdb/gdb/python/python.c:1709:36: error: missing sentinel in function call [-Werror=format]

Reproduced on Fedora 23 by sticking a few:

 #undef NULL
 #define 0

in build/gdb/build-gnulib/{stddef|signal|stdio}.h.  Hopefully this
caught all instances.

gdb/ChangeLog:
2016-04-21  Pedro Alves  <palves@redhat.com>

* dwarf2read.c (try_open_dwop_file, open_dwo_file)
(file_file_name, file_full_name): Add char * cast to sentinel in
concat/reconcat calls.
* event-top.c (top_level_prompt): Likewise.
* guile/guile.c (initialize_scheme_side): Likewise.
* linux-tdep.c (linux_fill_prpsinfo): Likewise.
* macrotab.c (macro_source_fullname): Likewise.
* main.c (get_init_files, captured_main): Likewise.
* psymtab.c (psymtab_to_fullname): Likewise.
* python/python.c (_initialize_python)
(gdbpy_finish_initialization): Likewise.
* source.c (symtab_to_fullname): Likewise.

8 years agoNew NOCROSSREFS_TO tests
Alan Modra [Thu, 21 Apr 2016 01:35:41 +0000 (11:05 +0930)]
New NOCROSSREFS_TO tests

Fixes failures on hppa-linux and alpha-linux due to not merging
.data.* and .sdata into .data.  cross3.t modified too since it is the
template for the NOCROSSREFS_TO scripts.

* testsuite/ld-scripts/cross3.t: Add commonly used data
and text section names to output section statements.
* testsuite/ld-scripts/cross4.t: Likewise.
* testsuite/ld-scripts/cross5.t: Likewise.
* testsuite/ld-scripts/cross6.t: Likewise.
* testsuite/ld-scripts/cross7.t: Likewise.

8 years agoRemove x86 gc_sweep_hook
H.J. Lu [Thu, 21 Apr 2016 00:12:46 +0000 (17:12 -0700)]
Remove x86 gc_sweep_hook

Since x86 backends never see the removed sections, there is no need
for gc_sweep_hook.

* elf32-i386.c (elf_i386_gc_sweep_hook): Removed.
(elf_backend_gc_sweep_hook): Likewise.
* elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.

8 years agoDon't check relocations in excluded sections
H.J. Lu [Thu, 21 Apr 2016 00:10:55 +0000 (17:10 -0700)]
Don't check relocations in excluded sections

When checking relocations after gc-sections has run, the unused sections
have been removed.  Don't check relocations in excluded sections.

* elflink.c (_bfd_elf_link_check_relocs): Don't check relocations
in excluded sections

8 years agoMove ELF relocation check after lang_gc_sections
H.J. Lu [Thu, 21 Apr 2016 00:06:58 +0000 (17:06 -0700)]
Move ELF relocation check after lang_gc_sections

Move ELF relocation check after lang_gc_sections so that all the
reference counting code for plt and got relocs can be removed.  This
only affects ELF targets which check relocations after opening all
input file.

* ldlang.c (lang_check_relocs): New function.
(lang_process): Call lang_check_relocs after lang_gc_sections.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Don't
call _bfd_elf_link_check_relocs here.

8 years agoAutomatic date update in version.in
GDB Administrator [Thu, 21 Apr 2016 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoBuild GDB as a C++ program by default
Pedro Alves [Wed, 20 Apr 2016 22:20:15 +0000 (23:20 +0100)]
Build GDB as a C++ program by default

This makes --enable-build-with-cxx be "yes" by default.

One must now configure with --enable-build-with-cxx=no in order to
build with a C compiler.

gdb/ChangeLog:
2016-04-20  Pedro Alves  <palves@redhat.com>

* build-with-cxx.m4 (GDB_AC_BUILD_WITH_CXX): Default to yes.
* configure: Renegerate.

gdb/gdbserver/ChangeLog:
2016-04-20  Pedro Alves  <palves@redhat.com>

* configure: Renegerate.

8 years agoFix host signal vs gdb signal mixup in gdb/darwin-nat.c
Pedro Alves [Wed, 20 Apr 2016 19:13:23 +0000 (20:13 +0100)]
Fix host signal vs gdb signal mixup in gdb/darwin-nat.c

Building in C++ mode caught a bug here:

 .../src/gdb/darwin-nat.c: In function 'ptid_t darwin_decode_message(mach_msg_header_t*, darwin_thread_t**, inferior**, target_waitstatus*)':
 .../src/gdb/darwin-nat.c:1016:25: error: invalid conversion from 'int' to 'gdb_signal' [-fpermissive]
      status->value.sig = WTERMSIG (wstatus);
  ^

gdb/ChangeLog:
2016-04-20  Pedro Alves  <palves@redhat.com>

* darwin-nat.c (darwin_decode_message): Use gdb_signal_from_host.

8 years agoFix "incompatible pointer type" warning in gdb/aarch64-tdep.c
Pedro Alves [Wed, 20 Apr 2016 19:15:21 +0000 (20:15 +0100)]
Fix "incompatible pointer type" warning in gdb/aarch64-tdep.c

Fixes, with x86_64-apple-darwin15-gcc (gcc 5.3.0):

 .../src/gdb/aarch64-tdep.c: In function 'aarch64_record_load_store':
 .../src/gdb/aarch64-tdep.c:3479:67: error: passing argument 3 of 'regcache_raw_read_unsigned' from incompatible pointer type [-Werror=incompatible-pointer-types]
       bits (aarch64_insn_r->aarch64_insn, 16, 20), &reg_rm_val);
    ^
 In file included from .../src/gdb/regcache.h:23:0,
  from .../src/gdb/gdbarch.h:69,
  from .../src/gdb/defs.h:620,
  from .../src/gdb/aarch64-tdep.c:21:
 .../src/gdb/common/common-regcache.h:60:29: note: expected 'ULONGEST * {aka long unsigned int *}' but argument is of type 'uint64_t * {aka long long unsigned int *}'
  extern enum register_status regcache_raw_read_unsigned
      ^

gdb/ChangeLog:
2016-04-20  Pedro Alves  <palves@redhat.com>

* aarch64-tdep.c (aarch64_record_load_store): Change type of
'reg_rm_val' local to ULONGEST.

8 years agogdb/darwin-nat.c: Fix "cast to pointer from integer of different size" warning
Pedro Alves [Wed, 20 Apr 2016 20:42:57 +0000 (21:42 +0100)]
gdb/darwin-nat.c: Fix "cast to pointer from integer of different size" warning

Fixes, with gcc 5.3.0:

 .../src/gdb/darwin-nat.c: In function 'void darwin_resume_thread(inferior*, darwin_thread_t*, int, int)':
 .../src/gdb/darwin-nat.c:731:21: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     (caddr_t)thread->gdb_port, nsignal);
      ^
 .../src/gdb/darwin-nat.c:84:35: note: in definition of macro 'PTRACE'
   darwin_ptrace(#CMD, CMD, (PID), (ADDR), (SIG))
    ^

thread->gdb_port is an unsigned int, caddr_t is a void pointer.

gdb/ChangeLog:
2016-04-20  Pedro Alves  <palves@redhat.com>

* darwin-nat.c (darwin_resume_thread): Add uintptr_t cast.

8 years agoCheck R_386_NONE/R_X86_64_NONE in eh6.d
H.J. Lu [Wed, 20 Apr 2016 18:15:05 +0000 (11:15 -0700)]
Check R_386_NONE/R_X86_64_NONE in eh6.d

There is no need for run-time relocation when converting pointers
in .eh_frame section to DW_EH_PE_pcrel encoding.  R_386_NONE and
R_X86_64_NONE are expected since the space for run-time relocation
has been allocated.  This is an optimization.

PR ld/19972
* testsuite/ld-elf/eh6.d: Pass -rW to readelf and check for
R_386_NONE or R_X86_64_NONE.

8 years agoAdd ld-x86-64/pic1 test
H.J. Lu [Wed, 20 Apr 2016 18:13:38 +0000 (11:13 -0700)]
Add ld-x86-64/pic1 test

* testsuite/ld-x86-64/pic1.d: New file.
* testsuite/ld-x86-64/pic1.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pic1.

8 years agoAdd ld-x86-64/pie2 test
H.J. Lu [Wed, 20 Apr 2016 18:12:06 +0000 (11:12 -0700)]
Add ld-x86-64/pie2 test

* testsuite/ld-x86-64/pie2.d: New file.
* testsuite/ld-x86-64/pie2.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pie2.

8 years agoCheck run-time R_X86_64_32 relocation overflow
H.J. Lu [Wed, 20 Apr 2016 18:10:21 +0000 (11:10 -0700)]
Check run-time R_X86_64_32 relocation overflow

Since elf_x86_64_check_relocs is called after opening all input files,
we can detect dynamic R_X86_64_32 relocation overflow there.

bfd/

PR ld/19969
* elf64-x86-64.c (check_relocs_failed): New.
(elf_x86_64_need_pic): Moved before elf_x86_64_check_relocs.
Support relocation agaist local symbol.  Set check_relocs_failed.
(elf_x86_64_check_relocs): Use elf_x86_64_need_pic.  Check
R_X86_64_32 relocation overflow.
(elf_x86_64_relocate_section): Skip if check_relocs failed.
Update one elf_x86_64_need_pic and remove one elf_x86_64_need_pic.

ld/

PR ld/19969
* testsuite/ld-x86-64/pr19969.d: New file.
* testsuite/ld-x86-64/pr19969a.S: Likewise.
* testsuite/ld-x86-64/pr19969b.S: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr19969 tests.

8 years agosymmisc.c (dump_symtab_1): Print owning compunit for identical blockvectors.
Doug Evans [Wed, 20 Apr 2016 17:17:12 +0000 (10:17 -0700)]
symmisc.c (dump_symtab_1): Print owning compunit for identical blockvectors.

* symmisc.c (dump_symtab_1): Print owning compunit for identical
blockvectors.

8 years agoInclude arch/arm-linux.h in aarch32-linux-nat.c
Yao Qi [Wed, 20 Apr 2016 14:02:54 +0000 (15:02 +0100)]
Include arch/arm-linux.h in aarch32-linux-nat.c

Fix the compilation failure by including arch/arm-linux.h in
aarch32-linux-nat.c.

gdb:

2016-04-20  Yao Qi  <yao.qi@linaro.org>

* aarch32-linux-nat.c: Include "arch/arm-linux.h".

8 years agoCall _bfd_elf_create_ifunc_sections only for ifunc
H.J. Lu [Wed, 20 Apr 2016 12:34:02 +0000 (05:34 -0700)]
Call _bfd_elf_create_ifunc_sections only for ifunc

Since x86 check_relocs is called after opening all input files, we
need to call _bfd_elf_create_ifunc_sections only for STT_GNU_IFUNC
symbols.

* elf32-i386.c (elf_i386_check_relocs): Call
_bfd_elf_create_ifunc_sections only for STT_GNU_IFUNC symbol.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.

8 years agoCheck ELF relocs after opening all input files
H.J. Lu [Wed, 20 Apr 2016 12:26:37 +0000 (05:26 -0700)]
Check ELF relocs after opening all input files

Delaying checking ELF relocations until opening all input files so
that symbol information is final when relocations are checked.  This
is only enabled for x86 targets.

bfd/

* elf-bfd.h (_bfd_elf_link_check_relocs): New.
* elflink.c (_bfd_elf_link_check_relocs): New function.
(elf_link_add_object_symbols): Call _bfd_elf_link_check_relocs
if check_relocs_after_open_input is FALSE.

include/

* bfdlink.h (bfd_link_info): Add check_relocs_after_open_input.

ld/

* emulparams/elf32_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
New.
* emulparams/elf_i386.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_i386_be.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_i386_chaos.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_i386_ldso.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_i386_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/i386nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse):
Set check_relocs_after_open_input to TRUE if
CHECK_RELOCS_AFTER_OPEN_INPUT is yes.
(gld${EMULATION_NAME}_after_open): Call
_bfd_elf_link_check_relocs on all inputs if
check_relocs_after_open_input is TRUE.

8 years agoMove ARM_CPSR_GREGNUM to arch/arm-linux.h
Yao Qi [Wed, 20 Apr 2016 11:31:53 +0000 (12:31 +0100)]
Move ARM_CPSR_GREGNUM to arch/arm-linux.h

This patch moves macro ARM_CPSR_GREGNUM to arch/arm-linux.h so that it
can be used in GDBserver side.

gdb:

2016-04-20  Yao Qi  <yao.qi@linaro.org>

* arm-linux-tdep.h (ARM_CPSR_GREGNUM): Move it to ...
* arch/arm-linux.h: ... here.

gdb/gdbserver:

2016-04-20  Yao Qi  <yao.qi@linaro.org>

* linux-aarch32-low.c: Include "arch/arm-linux.h".
(arm_fill_gregset): Use ARM_CPSR_GREGNUM rather than magic
number 16.
(arm_store_gregset): Likewise.

8 years agoReplace .long with .dc.a on my_personality_v0
H.J. Lu [Wed, 20 Apr 2016 11:27:47 +0000 (04:27 -0700)]
Replace .long with .dc.a on my_personality_v0

We should use .dc.a instead of .long to take address of a symbol.

* testsuite/ld-elf/eh6.s: Replace .long with .dc.a on
my_personality_v0.

8 years agoupdate many old style function definitions
Trevor Saunders [Wed, 13 Apr 2016 22:30:46 +0000 (18:30 -0400)]
update many old style function definitions

This includes regenerating a bunch of files in opcodes/ with trunk cgen.

gprof/ChangeLog:

2016-04-20  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* basic_blocks.c: Update old style function definitions.
* cg_arcs.c: Likewise.
* cg_print.c: Likewise.
* gen-c-prog.awk: Likewise.
* gmon_io.c: Likewise.
* hertz.c: Likewise.
* hist.c: Likewise.
* sym_ids.c: Likewise.

bfd/ChangeLog:

2016-04-20  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* cache.c: Update old style function definitions.
* elf32-m68k.c: Likewise.
* elf64-mmix.c: Likewise.
* stab-syms.c: Likewise.

opcodes/ChangeLog:

2016-04-20  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* alpha-dis.c: Regenerate.
* crx-dis.c: Likewise.
* disassemble.c: Likewise.
* epiphany-opc.c: Likewise.
* fr30-opc.c: Likewise.
* frv-opc.c: Likewise.
* ip2k-opc.c: Likewise.
* iq2000-opc.c: Likewise.
* lm32-opc.c: Likewise.
* lm32-opinst.c: Likewise.
* m32c-opc.c: Likewise.
* m32r-opc.c: Likewise.
* m32r-opinst.c: Likewise.
* mep-opc.c: Likewise.
* mt-opc.c: Likewise.
* or1k-opc.c: Likewise.
* or1k-opinst.c: Likewise.
* tic80-opc.c: Likewise.
* xc16x-opc.c: Likewise.
* xstormy16-opc.c: Likewise.

ld/ChangeLog:

2016-04-20  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* emultempl/scoreelf.em: Likewise.

binutils/ChangeLog:

2016-04-20  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* resres.c: Likewise.

gas/ChangeLog:

2016-04-20  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* cgen.c: Likewise.
* config/tc-bfin.c: Likewise.
* config/tc-ia64.c: Likewise.
* config/tc-mep.c: Likewise.
* config/tc-metag.c: Likewise.
* config/tc-nios2.c: Likewise.
* config/tc-rl78.c: Likewise.

8 years agochange argument type to bfd_byte
Trevor Saunders [Wed, 13 Apr 2016 08:41:23 +0000 (04:41 -0400)]
change argument type to bfd_byte

We operate on the pointer's target as a set of bytes, and this avoids doing
arithmetic on void * which is undefined in ISO C.

bfd/ChangeLog:

2016-04-20  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* elf32-arm.c (put_thumb2_insn): Change argument type to bfd_byte *.

8 years agogas/doc/arc: Add nps400 references into the documentation
Andrew Burgess [Tue, 19 Apr 2016 18:02:27 +0000 (19:02 +0100)]
gas/doc/arc: Add nps400 references into the documentation

Add nps400 to the list of acceptable values for the -mcpu command line
switch, and to the .cpu directive.

I've added an extra cross reference from -mcpu to .cpu to improve
navigation of the documentation.

gas/ChangeLog:

* doc/c-arc.texi (ARC Options): Add nps400 to list of valus for
-mcpu.  Add cross reference to .cpu directive from -mcpu option.
(ARC Directives): Add NPS400 to .cpu directive list.

8 years agoarc: Fix relocation formula for ARC_NPS_CMEM16 relocation
Andrew Burgess [Tue, 19 Apr 2016 16:40:41 +0000 (17:40 +0100)]
arc: Fix relocation formula for ARC_NPS_CMEM16 relocation

The ME modifier was missing from the relocation formula for the
ARC_NPS_CMEM16 relocation, and as such the relocation would not patch
correctly on little endian targets.

include/ChangeLog:

* elf/arc-reloc.def (ARC_NPS_CMEM16): Add ME modifier to formula.

8 years ago[AArch64] Support RAS extension for ARMv8 onwards.
Matthew Wahab [Wed, 20 Apr 2016 08:31:49 +0000 (09:31 +0100)]
[AArch64] Support RAS extension for ARMv8 onwards.

The RAS extension was introduced as part of the ARMv8.2 architecture
where it is a required feature. It is also available as an optional
feature for ARMv8 and ARMv8.1. In binutils, the RAS extension is
currently enabled by default for -march=armv8.2-a but is not available
for -march=armv8 or -march=armv8.1-a.

This patch adds the feature extension '+ras' to enable the RAS extension
for ARMv8 and ARMv8.1, it is disabled by default.

gas/
2016-04-20  Matthew Wahab  <matthew.wahab@arm.com>

* config/tc-aarch64.c (aarch64_features): Add "ras".
* doc/c-aarch64.texi (AArch64 Extensions): Add "ras".
* testsuite/gas/aarch64/armv8-ras-1.d: New.
* testsuite/gas/aarch64/armv8-ras-1.s: New.
* testsuite/gas/aarch64/illegal-ras-1.d: New.
* testsuite/gas/aarch64/illegal-ras-1.s: New.

Change-Id: I824fb9bc8cf846bcc03aa17a726efb1350d78b9d

8 years agoAdd another testcase for PR ld/19719
H.J. Lu [Wed, 20 Apr 2016 03:11:55 +0000 (20:11 -0700)]
Add another testcase for PR ld/19719

This test checks run-time relocation overflow with GOT relocation and
32-bit relocation against the same symbol.

PR ld/19719
* testsuite/ld-x86-64/pr19719.d: New file.
* testsuite/ld-x86-64/pr19719.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr19719.

8 years agoAutomatic date update in version.in
GDB Administrator [Wed, 20 Apr 2016 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoHandle void * conversions in FreeBSD/x86 native code to fix C++ build.
John Baldwin [Tue, 19 Jan 2016 19:02:09 +0000 (11:02 -0800)]
Handle void * conversions in FreeBSD/x86 native code to fix C++ build.

gdb/ChangeLog:

* amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Change xstateregs
to void *.
(amd64bsd_store_inferior_registers): Likewise.
* fbsd-nat.c (resume_one_thread_cb): Explicitly cast data to ptid_t *.
(resume_all_threads_cb): Likewise.
* i386bsd-nat.c (i386bsd_supply_gregset): Cast gregs to char *.
(i386bsd_collect_gregset): Likewise.
(i386bsd_fetch_inferior_registers): Change xstateregs to void *.
(i386bsd_store_inferior_registers): Likewise.

8 years agoCast the pointer assigned to ss_sp to char *.
John Baldwin [Tue, 19 Apr 2016 20:51:05 +0000 (13:51 -0700)]
Cast the pointer assigned to ss_sp to char *.

FreeBSD versions older than 11.0 use char * as the type of ss_sp in
stack_t instead of the standards-defined void *.  C++ allows a char *
pointer to be converted to a void *, so it is safe to cast the return
value of xmalloc to char * if ss_sp is either a char * or void *.
Just always use the cast to char * since that is less ugly than having
to add a special case.

gdb/ChangeLog:

* main.c (setup_alternate_signal_stack): Cast to char *.

8 years agoopcodes/arc: Add yet more nps instructions
Andrew Burgess [Fri, 1 Apr 2016 18:51:50 +0000 (19:51 +0100)]
opcodes/arc: Add yet more nps instructions

Add some more arc/nps400 instructions and the associated operands.
There's also a test added into the assembler.

gas/ChangeLog:

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

include/ChangeLog:

* opcode/arc.h (MAX_INSN_ARGS): Increase 6 to 8.

opcodes/ChangeLog:

* arc-nps400-tbl.h: Add addb, subb, adcb, sbcb, andb, xorb, orb,
fxorb, wxorb, shlb, shrb, notb, cntbb, div, mod, divm, and qcmp
instructions.
* arc-opc.c (insert_nps_bitop_size): Delete.
(extract_nps_bitop_size): Delete.
(MAKE_SRC_POS_INSERT_EXTRACT_FUNCS): Define, and use.
(extract_nps_qcmp_m3): Define.
(extract_nps_qcmp_m2): Define.
(extract_nps_qcmp_m1): Define.
(arc_flag_operands): Add F_NPS_SX, F_NPS_AR, F_NPS_AL.
(arc_flag_classes): Add C_NPS_SX, C_NPS_AR_AL
(arc_operands): Add NPS_SRC2_POS, NPS_SRC1_POS, NPS_ADDB_SIZE,
NPS_ANDB_SIZE, NPS_FXORB_SIZ, NPS_WXORB_SIZ, NPS_R_XLDST,
NPS_DIV_UIMM4, NPS_QCMP_SIZE, NPS_QCMP_M1, NPS_QCMP_M2, and
NPS_QCMP_M3.

8 years agoopcodes/arc: Add more nps instructions
Andrew Burgess [Thu, 31 Mar 2016 18:51:14 +0000 (19:51 +0100)]
opcodes/arc: Add more nps instructions

Add dctcp, dcip, dcet, and dcacl instructions.

gas/ChangeLog:

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

include/ChangeLog:

* opcode/arc.h (insn_class_t): Add NET and ACL class.

opcodes/ChangeLog:

* arc-nps400-tbl.h: Add dctcp, dcip, dcet, and dcacl instructions.

8 years agoAdd pr number to earlier entry.
Doug Evans [Tue, 19 Apr 2016 16:57:04 +0000 (09:57 -0700)]
Add pr number to earlier entry.

8 years agosymmisc.c (dump_symtab_1, dump_symtab): Delete arg objfile.
Doug Evans [Tue, 19 Apr 2016 16:52:45 +0000 (09:52 -0700)]
symmisc.c (dump_symtab_1, dump_symtab): Delete arg objfile.

gdb/ChangeLog:

* symmisc.c (dump_symtab_1, dump_symtab): Delete arg objfile.
All callers updated.

8 years agoFix copyright year, remove linux only test.
Doug Evans [Tue, 19 Apr 2016 16:06:53 +0000 (09:06 -0700)]
Fix copyright year, remove linux only test.

8 years ago* source.c (is_regular_file): New arg errno_ptr.
Doug Evans [Tue, 19 Apr 2016 16:01:44 +0000 (09:01 -0700)]
* source.c (is_regular_file): New arg errno_ptr.

gdb/ChangeLog:

* source.c (is_regular_file): New arg errno_ptr.
All callers updated.

gdb/testsuite/ChangeLog:

* gdb.base/bad-file.exp: New file.

8 years agolinux-record: Squash cases with identical handling
Andreas Arnez [Tue, 19 Apr 2016 14:53:40 +0000 (16:53 +0200)]
linux-record: Squash cases with identical handling

In record_linux_system_call there are some cases with identical
handling.  These are merged together to reduce code duplication.

gdb/ChangeLog:

* linux-record.c (record_linux_system_call): Merge handling for
readlink/recv/read and pipe/pipe2.

8 years agoRe-factor (i386|amd64)mpx target descriptions.
Walfred Tedeschi [Tue, 19 Apr 2016 13:45:50 +0000 (15:45 +0200)]
Re-factor (i386|amd64)mpx target descriptions.

In the previous patch a new set of target descriptions
(i386|amd64)-avx-mpx were added  being same as the (i386|amd64)-mpx.
This patch removes AVX feature from  (i386|amd64)-mpx target
description set.

This way the (i386|amd64)avx_mpx(_linux|) set has AVX and MPX features
and (i386|amd64)mpx(_linux|) only MPX.

2016-04-14  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* features/i386/amd64-mpx-linux.xml: Remove AVX feature.
* features/i386/amd64-mpx.xml: Remove AVX feature.
* features/i386/i386-mpx-linux.xml: Remove AVX feature.
* features/i386/i386-mpx.xml: Remove AVX feature.
* features/i386/amd64-mpx-linux.c: Regenerate.
* features/i386/amd64-mpx.c: Regenerate.
* features/i386/i386-mpx-linux.c: Regenerate.
* features/i386/i386-mpx.c: Regenerate.
* regformats/i386/amd64-mpx-linux.dat: Regenerate.
* regformats/i386/amd64-mpx.dat: Regenerate.
* regformats/i386/i386-mpx-linux.dat: Regenerate.
* regformats/i386/i386-mpx.dat: Regenerate.

8 years agoAdd target descriptions for AVX + MPX
Walfred Tedeschi [Tue, 19 Apr 2016 13:44:32 +0000 (15:44 +0200)]
Add target descriptions for AVX + MPX

The current MPX target descriptions assume that MPX is always combined
with AVX, however that's not correct.  We can have machines with MPX
and without AVX; or machines with AVX and without MPX.

This patch adds new target descriptions for machines that support
both MPX and AVX, as duplicates of the existing MPX descriptions.

The following commit will remove AVX from the MPX-only descriptions.

2016-04-16  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/ChangeLog:

* amd64-linux-tdep.c (features/i386/amd64-avx-mpx-linux.c):
New include.
(amd64_linux_core_read_description): Add case for
 X86_XSTATE_AVX_MPX_MASK.
(_initialize_amd64_linux_tdep): Call initialize_tdesc_amd64_avx_mpx_linux.
* amd64-linux-tdep.h (tdesc_amd64_avx_mpx_linux): New definition.
* amd64-tdep.c (features/i386/amd64-avx-mpx.c): New include.
(amd64_target_description): Add case for  X86_XSTATE_AVX_MPX_MASK.
(_initialize_amd64_tdep): Call initialize_tdesc_amd64_avx_mpx.
* common/x86-xstate.h (X86_XSTATE_MPX_MASK): Remove AVX bits.
(X86_XSTATE_AVX_MPX_MASK): New case.
* features/Makefile (i386/i386-avx-mpx, i386/i386-avx-mpx-linux)
(i386/amd64-avx-mpx, i386/amd64-avx-mpx-linux): New rules.
(i386/i386-avx-mpx-expedite, i386/i386-avx-mpx-linux-expedite)
(i386/amd64-avx-mpx-expedite, i386/amd64-avx-mpx-linux-expedite):
New expedites.
* i386-linux-tdep.c (features/i386/i386-avx-mpx-linux.c): New
include.
(i386_linux_core_read_description): Add case
X86_XSTATE_AVX_MPX_MASK.
(_initialize_i386_linux_tdep): Call
initialize_tdesc_i386_avx_mpx_linux.
* i386-linux-tdep.h (tdesc_i386_avx_mpx_linux): New include.
* i386-tdep.c (features/i386/i386-avx-mpx.c): New include.
(i386_target_description): Add case for X86_XSTATE_AVX_MPX_MASK.
* x86-linux-nat.c (x86_linux_read_description): Add case for
X86_XSTATE_AVX_MPX_MASK.
* features/i386/amd64-avx-mpx-linux.xml: New file.
* features/i386/i386-avx-mpx-linux.xml: New file.
* features/i386/i386-avx-mpx.xml: New file.
* features/i386/amd64-avx-mpx.xml: New file.
* features/i386/amd64-avx-mpx-linux.c: Generated.
* features/i386/amd64-avx-mpx.c: Generated.
* features/i386/i386-avx-mpx-linux.c: Generated.
* features/i386/i386-avx-mpx.c: Generated.
* regformats/i386/amd64-avx-mpx-linux.dat: Generated.
* regformats/i386/amd64-avx-mpx.dat: Generated.
* regformats/i386/i386-avx-mpx-linux.dat: Generated.
* regformats/i386/i386-avx-mpx.dat: Generated.

gdb/gdbserver/ChangeLog:

* Makefile.in (clean): Add removal for i386-avx-mpx.c,
i386-avx-mpx-linux.c, amd64-avx-mpx.c and amd64-avx-mpx-linux.c.
(i386-avx-mpx.c, i386-avx-mpx-linux.c, amd64-avx-mpx.c)
(amd64-avx-mpx-linux.c): New rules.
(amd64-avx-mpx-linux-ipa.o, i386-avx-mpx-linux-ipa.o): New rule.
* configure.srv (srv_i386_regobj): Add i386-avx-mpx.o.
(srv_i386_linux_regobj): Add i386-avx-mpx-linux.o.
(srv_amd64_regobj): Add amd64-avx-mpx.o.
(srv_amd64_linux_regobj): Add amd64-avx-mpx-linux.o.
(srv_i386_xmlfiles): Add i386/i386-avx-mpx.xml.
(srv_amd64_xmlfiles): Add i386/amd64-avx-mpx.xml.
(srv_i386_linux_xmlfiles): Add i386/i386-avx-mpx-linux.xml.
(srv_amd64_linux_xmlfiles): Add i386/amd64-avx-mpx-linux.xml.
(ipa_i386_linux_regobj): Add i386-avx-mpx-linux-ipa.o.
(ipa_amd64_linux_regobj): Add amd64-avx-mpx-linux-ipa.o.
* linux-x86-low.c (x86_linux_read_description): Add case for
X86_XSTATE_AVX_MPX_MASK.
(x86_get_ipa_tdesc_idx): Add cases for avx_mpx.
(initialize_low_arch): Call init_registers_amd64_avx_mpx_linux and
init_registers_i386_avx_mpx_linux.
* linux-i386-ipa.c (get_ipa_tdesc): Add case for avx_mpx.
(initialize_low_tracepoint): Call
init_registers_i386_avx_mpx_linux.
* linux-amd64-ipa.c (get_ipa_tdesc):  Add case for avx_mpx.
(initialize_low_tracepoint): Call
init_registers_amd64_avx_mpx_linux.
* linux-x86-tdesc.h (X86_TDESC_AVX_MPX): New enum value.
(init_registers_amd64_avx_mpx_linux, tdesc_amd64_avx_mpx_linux)
(init_registers_i386_avx_mpx_linux, tdesc_i386_avx_mpx_linux): New
declarations.

8 years agoSync Makefile.tpl with gcc.
Nick Clifton [Tue, 19 Apr 2016 08:26:16 +0000 (09:26 +0100)]
Sync Makefile.tpl with gcc.

2016-04-13  Segher Boessenkool  <segher@kernel.crashing.org>

PR bootstrap/70173
* Makefile.tpl (local-distclean): Delete the libcc1, gnattools,
and gotools directories.  Delete the stage_final file.
* Makefile.in: Regenerate.

8 years ago.cfi_remember_state/.cfi_restore_state documentation
Martin Galvan [Mon, 18 Apr 2016 23:46:09 +0000 (09:16 +0930)]
.cfi_remember_state/.cfi_restore_state documentation

* doc/as.texinfo (.cfi_remember_state, .cfi_restore_state): Improve
documentation.

8 years agoAutomatic date update in version.in
GDB Administrator [Tue, 19 Apr 2016 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoFix PR gdb/19250: ptrace prototype is not detected properly in C++ mode
Pedro Alves [Mon, 18 Apr 2016 16:42:50 +0000 (17:42 +0100)]
Fix PR gdb/19250: ptrace prototype is not detected properly in C++ mode

The ptrace args/return types detection doesn't work properly in C++
mode, on non-GNU/Linux hosts.  For example, on gcc70 (NetBSD 5.1),
where the prototype is:

 int ptrace(int, __pid_t, void*, int);

configure misdetects it as:

 $ grep PTRACE_TYPE config.h
 #define PTRACE_TYPE_ARG1 int
 #define PTRACE_TYPE_ARG3 int *
 #define PTRACE_TYPE_ARG4 int
 /* #undef PTRACE_TYPE_ARG5 */
 #define PTRACE_TYPE_RET int

resulting in:

 ../../src/gdb/amd64bsd-nat.c: In function 'void amd64bsd_fetch_inferior_registers(target_ops*, regcache*, int)':
 ../../src/gdb/amd64bsd-nat.c:56: warning: dereferencing type-punned pointer will break strict-aliasing rules
 ../../src/gdb/amd64bsd-nat.c: In function 'void amd64bsd_store_inferior_registers(target_ops*, regcache*, int)':
 ../../src/gdb/amd64bsd-nat.c:104: warning: dereferencing type-punned pointer will break strict-aliasing rules
 ../../src/gdb/amd64bsd-nat.c:110: warning: dereferencing type-punned pointer will break strict-aliasing rules

We could address this [1], however despite ptrace.m4's claim:

 # Needs to be tested in C++ mode, to detect whether we need to cast
 # the first argument to enum __ptrace_request.

it appears that there's actually no need to test in C++ mode.  Always
running the ptrace tests in C mode works just the same on GNU/Linux.

I remember experimenting with several different ways to handle the
original issue back then, and maybe that was needed in some other
attempt and then I didn't realize it ended up not really necessary.

Confirmed that this fixes the NetBSD 5.1 C++ build, and confirmed that
C and C++ builds on Fedora 23 are unaffected.

[1] - https://sourceware.org/ml/gdb-patches/2016-04/msg00374.html

gdb/ChangeLog:
2016-04-18  Pedro Alves  <palves@redhat.com>

* ptrace.m4 (GDB_AC_PTRACE): Don't run tests in C++ mode.
* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2016-04-18  Pedro Alves  <palves@redhat.com>

* configure: Regenerate.

8 years agoFix gdb crash when trying to print the address of a synthetic C++ reference
Martin Galvan [Mon, 18 Apr 2016 13:58:14 +0000 (10:58 -0300)]
Fix gdb crash when trying to print the address of a synthetic C++ reference

After compiling a program which uses C++ references some optimizations may
convert the references into synthetic "pointers".  Trying to print the address
of one of such synthetic references causes gdb to crash with the following
error:

(gdb) print &ref
/build/buildd/gdb-7.7.1/gdb/dwarf2loc.c:1624: internal-error: Should not be able to create a lazy value with an enclosing type
A problem internal to GDB has been detected,
further debugging may prove unreliable.

Apparently, what was causing it was that value_addr returns a copy of the value
that represents the reference with its type set to T* instead of T&.  However,
its enclosing_type is left untouched, which fails a check made in
read_pieced_value.  We only see the crash happen for references that are
synthetic because they're treated as pieced values, thus the call to
read_pieced_value.

On a related note, it seems that in general there are all sorts of breakage
when working with synthetic references.  This is reported here:

https://sourceware.org/bugzilla/show_bug.cgi?id=19893

gdb/ChangeLog:
2016-04-18  Martin Galvan  <martin.galvan@tallertechnologies.com>

* valops.c (value_addr): For C++ references, set the copied value's
enclosing_type as well.

gdb/testsuite/ChangeLog:
2016-04-18  Martin Galvan  <martin.galvan@tallertechnologies.com>

* gdb.dwarf2/implref.exp: New file.

8 years agofortran: Testsuite, fix different type naming across compilers.
Bernhard Heckel [Thu, 7 Apr 2016 08:28:14 +0000 (10:28 +0200)]
fortran: Testsuite, fix different type naming across compilers.

Gfortran and ifort have different names for data types.  Encapsulate
type names in a library to increase number of supported compilers.
gfortran -4.2 : int4
gfortran>=4.3 : integer(kind=4)
ifort         : INTEGER(4)

2016-04-18  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/testsuite/Changelog:
* gdb.fortran/common-block.exp: Use type naming defined in lib fortran.
* gdb.fortran/derived-type.exp: Use type naming defined in lib fortran.
* gdb.fortran/multi-dim.exp: Use type naming defined in lib fortran.
* gdb.fortran/vla-datatypes.exp: Use type naming defined in lib fortran.
* gdb.fortran/vla-ptype-sub.exp: Use type naming defined in lib fortran.
* gdb.fortran/vla-ptype.exp: Use type naming defined in lib fortran.
* gdb.fortran/whatis_type.exp: Use type naming defined in lib fortran.
* lib/fortran.exp (fortran_int4): New procedure.
(fortran_real4, fortran_real8, fortran_complex4): Likewise.
(fortran_logical4): Likewise.

8 years agoTestsuite: Fix compiling of shared libraries with ICC.
Bernhard Heckel [Mon, 18 Apr 2016 09:49:07 +0000 (11:49 +0200)]
Testsuite: Fix compiling of shared libraries with ICC.

We are missing "-fpic" flag when compiling shared libraries with ICC.

2016-04-18  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Testsuite/Changelog:
* lib/gdb.exp (gdb_compile_shlib): Add flag for ICC compiler.

8 years agotestsuite: Support detection of Intel compilers via test_compiler_version.
Bernhard Heckel [Fri, 15 Apr 2016 09:03:42 +0000 (11:03 +0200)]
testsuite: Support detection of Intel compilers via test_compiler_version.

Add Intel specific preprocessor macros to query the version of the compiler.

2016-04-18  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Testsuite/Changelog:
* lib/compiler.c: Add Intel specific preprocessor macros.
* lib/compiler.cc: Likewise.

8 years agoAdd new NOCROSSREFS_TO linker script command
Matthew Fortune [Thu, 14 Apr 2016 10:49:53 +0000 (11:49 +0100)]
Add new NOCROSSREFS_TO linker script command

NOCROSSREFS_TO is similar to the existing NOCROSSREFS command but only
checks one direction of cross referencing.

ld/ChangeLog

* ld.texinfo: Document NOCROSSREFS_TO script command.
* ldlang.h (struct lang_nocrossrefs): Add onlyfirst field.
(lang_add_nocrossref_to): New prototype.
* ldcref.c (check_local_sym_xref): Use onlyfirst to only look for
symbols defined in the first section.
(check_nocrossref): Likewise.
* ldgram.y (NOCROSSREFS_TO): New script command.
* ldlang.c (lang_add_nocrossref): Set onlyfirst to FALSE.
(lang_add_nocrossref_to): New function.
* ldlex.l (NOCROSSREFS_TO): New token.
* NEWS: Mention NOCROSSREFS_TO.
* testsuite/ld-scripts/cross4.t: New file.
* testsuite/ld-scripts/cross5.t: Likewise.
* testsuite/ld-scripts/cross6.t: Likewise.
* testsuite/ld-scripts/cross7.t: Likewise.
* testsuite/ld-scripts/crossref.exp: Run 4 new NOCROSSREFS_TO
tests.

8 years agoRevert 415fa612
Yao Qi [Mon, 18 Apr 2016 07:50:09 +0000 (08:50 +0100)]
Revert 415fa612

2016-04-18  Yao Qi  <yao.qi@linaro.org>

Revert:
2016-04-15  Yao Qi  <yao.qi@linaro.org>

* arm-tdep.c (thumb_stack_frame_destroyed_p): Return zero if
PC is far from the end of function.

8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 18 Apr 2016 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoRevert "gas/arc: Make .cpu directive case-insensitive"
Andrew Burgess [Sun, 17 Apr 2016 22:17:44 +0000 (23:17 +0100)]
Revert "gas/arc: Make .cpu directive case-insensitive"

This reverts commit 9a452709fe126ea6da23a53426362e4435d2dc06.

This change was committed as obvious, but it has been rightly been
pointed out to me that this change is not obvious, and as such I am
reverting it.

gas/ChangeLog:

Revert prevous change.
* config/tc-arc.c (arc_option): Make .cpu directive
case-sensitive again.

8 years agoAutomatic date update in version.in
GDB Administrator [Sun, 17 Apr 2016 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agogas/arc: Make .cpu directive case-insensitive
Andrew Burgess [Sat, 16 Apr 2016 15:21:32 +0000 (16:21 +0100)]
gas/arc: Make .cpu directive case-insensitive

gas/ChangeLog:

* config/tc-arc.c (arc_option): Make .cpu directive
case-insensitive.

8 years agogas/arc: Support NPS400 in .cpu directive
Andrew Burgess [Sat, 16 Apr 2016 15:19:40 +0000 (16:19 +0100)]
gas/arc: Support NPS400 in .cpu directive

gas/ChangeLog:

* config/tc-arc.c (arc_option): Allow NPS400 in .cpu directive.

8 years agoremove pointless assignment
Trevor Saunders [Wed, 13 Apr 2016 09:03:22 +0000 (05:03 -0400)]
remove pointless assignment

Presumably this was supposed to be regname[sizeof (regname) - 1] but was typoed
to regname[sizeof (rename) - 1].  However that should be unnecessary because
sprintf should null terminate.  As is this assignment is invalid ISO C because
rename refers to the function rename (), and sizeof on functions is undefined.
In GNU C C the size of functions is 1 so the expression is the same as
regname[0].  The following call to sprintf () clearly will over right that, so
the statement either has no effect or is invalid.  Given that it seems safe to
just remove it.  While we are there correct the size of regname, and switch
from snprintf to sprintf since we know the exact length of the result.

gas/ChangeLog:

2016-04-15  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* config/tc-mips.c (md_begin): Remove useless assignment.