binutils-gdb.git
9 years agoAdd test for thread names
Simon Marchi [Thu, 26 Nov 2015 14:49:04 +0000 (09:49 -0500)]
Add test for thread names

I couldn't find a test that verified the thread name functionality, so I
created a new one.

A target board can define gdb,no_thread_names if it doesn't support thread
names and wants to skip the tests that uses them.

This test has been made with Linux in mind.  Not all platforms use
pthread_setname_np to set the thread name, but some #ifdefs can be added
later in order to support other platforms.

Tested on x86-64 Ubuntu 14.04, native and remote.

gdb/testsuite/ChangeLog:

* gdb.threads/names.exp: New file.
* gdb.threads/names.c: New file.
* README: Mention gdb,no_thread_names.

9 years agoDisplay names of remote threads
Simon Marchi [Thu, 26 Nov 2015 14:49:04 +0000 (09:49 -0500)]
Display names of remote threads

This patch adds support for thread names in the remote protocol, and
updates gdb/gdbserver to use it.  The information is added to the XML
description sent in response to the qXfer:threads:read packet.

gdb/ChangeLog:

* linux-nat.c (linux_nat_thread_name): Replace implementation by call
to linux_proc_tid_get_name.
* nat/linux-procfs.c (linux_proc_tid_get_name): New function,
implementation inspired by linux_nat_thread_name.
* nat/linux-procfs.h (linux_proc_tid_get_name): New declaration.
* remote.c (struct private_thread_info) <name>: New field.
(free_private_thread_info): Free name field.
(remote_thread_name): New function.
(thread_item_t) <name>: New field.
(clear_threads_listing_context): Free name field.
(start_thread): Get name xml attribute.
(thread_attributes): Add "name" attribute.
(remote_update_thread_list): Copy name field.
(init_remote_ops): Assign remote_thread_name callback.
* target.h (target_thread_name): Update comment.
* NEWS: Mention remote thread name support.

gdb/gdbserver/ChangeLog:

* linux-low.c (linux_target_ops): Use linux_proc_tid_get_name.
* server.c (handle_qxfer_threads_worker): Refactor to include thread
name in reply.
* target.h (struct target_ops) <thread_name>: New field.
(target_thread_name): New macro.

gdb/doc/ChangeLog:

* gdb.texinfo (Thread List Format): Mention thread names.

9 years agoConstify thread name return path
Simon Marchi [Thu, 26 Nov 2015 14:49:03 +0000 (09:49 -0500)]
Constify thread name return path

Since this code path returns a string owned by the target (we don't know how
it's allocated, could be a static read-only string), it's safer if we return
a constant string.  If, for some reasons, the caller wishes to modify the
string, it should make itself a copy.

gdb/ChangeLog:

* linux-nat.c (linux_nat_thread_name): Constify return value.
* target.h (struct target_ops) <to_thread_name>: Likewise.
(target_thread_name): Likewise.
* target.c (target_thread_name): Likewise.
* target-delegates.c (debug_thread_name): Regenerate.
* python/py-infthread.c (thpy_get_name): Constify local variables.
* thread.c (print_thread_info): Likewise.
(thread_find_command): Likewise.

9 years agobtrace: diagnose "record btrace pt" without libipt
Markus Metzger [Thu, 19 Nov 2015 13:33:41 +0000 (14:33 +0100)]
btrace: diagnose "record btrace pt" without libipt

If GDB has been configured without libipt support, i.e. HAVE_LIBIPT is
undefined, and is running on a system that supports Intel(R) Processor Trace,
GDB will run into an internal error when trying to decode the trace.

    (gdb) record btrace
    (gdb) s
    usage (name=0x7fffffffe954 "fib-64")
        at src/fib.c:12
    12          fprintf(stderr, "usage: %s <num>\n", name);
    (gdb) info record
    Active record target: record-btrace
    Recording format: Intel(R) Processor Trace.
    Buffer size: 16kB.
    gdb/btrace.c:971: internal-error: Unexpected branch trace format.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

This requires a system with Linux kernel 4.1 or later running on a 5th
Generation Intel Core processor or later.

The issue is documented as PR 19297.

When trying to enable branch tracing, in addition to checking the target
support for the requested branch tracing format, also check whether GDB
supports. it.

gdb/
* btrace.c (btrace_enable): Check whether HAVE_LIBIPT is defined.

testsuite/
* lib/gdb.exp (skip_btrace_pt_tests): Check for a "GDB does not
support" error.

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 26 Nov 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoImport zlib 1.2.8 with local change merged in.
Joel Brobecker [Wed, 25 Nov 2015 23:09:09 +0000 (15:09 -0800)]
Import zlib 1.2.8 with local change merged in.

ChangeLog:

        * zlib: Update to zlib 1.2.8 with local changes merged in.

9 years agoAdjust local symbol value in relocatable link to be relative to section.
Cary Coutant [Wed, 25 Nov 2015 16:50:41 +0000 (08:50 -0800)]
Adjust local symbol value in relocatable link to be relative to section.

gold/
PR gold/19291
* object.cc (Sized_relobj_file::write_local_symbols): If relocatable,
subtract section address from symbol value.

9 years ago[GOLD] Align PowerPC64 GOT
Alan Modra [Wed, 25 Nov 2015 03:08:43 +0000 (13:38 +1030)]
[GOLD] Align PowerPC64 GOT

As done in a27e685f for bfd ld.

* powerpc.cc (Output_data_got_powerpc::Output_data_got_powerpc): Align
to 256 byte boundary.

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 25 Nov 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years ago[GAS, ARM] Invalid LDR immediate transformation
Christophe Monat [Tue, 24 Nov 2015 21:17:54 +0000 (22:17 +0100)]
[GAS, ARM] Invalid LDR immediate transformation

2015-11-24  Christophe Monat <christophe.monat@st.com>

* config/tc-arm.c (move_or_literal_pool): Do not transform ldr
ri,=imm into movs when ri is a high register in T1.

2015-11-24  Christophe Monat <christophe.monat@st.com>

* gas/arm/thumb2_ldr_immediate_armv6t2.s: Added high register
tests.
* gas/arm/thumb2_ldr_immediate_armv6t2.d: Accounted for new test
cases.
* gas/arm/thumb2_ldr_immediate_highregs_armv6t2.s: New.
* gas/arm/thumb2_ldr_immediate_highregs_armv6t2.d: New.

9 years agoNEWS: "info" commands now list in ascending order
Pedro Alves [Tue, 24 Nov 2015 18:11:23 +0000 (18:11 +0000)]
NEWS: "info" commands now list in ascending order

gdb/ChangeLog:
2015-11-24  Pedro Alves  <palves@redhat.com>

* NEWS: Mention that a few "info" commands now list the
corresponding items in ascending ID order.

9 years agoList displays in ascending order
Pedro Alves [Tue, 24 Nov 2015 18:11:22 +0000 (18:11 +0000)]
List displays in ascending order

Before:
      (gdb) info display
      Auto-display expressions now in effect:
      Num Enb Expression
      3:   y  1
      2:   y  1
      1:   y  1

After:
      (gdb) info display
      Auto-display expressions now in effect:
      Num Enb Expression
      1:   y  1
      2:   y  1
      3:   y  1

gdb/ChangeLog:
2015-11-24  Pedro Alves  <palves@redhat.com>

PR 17539
* printcmd.c (display_command): Append new display at the end of
the list.

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

PR 17539
* gdb.base/display.exp: Expect displays to be sorted in ascending
order.  Use multi_line.
* gdb.base/solib-display.exp: Likewise.

9 years agoList checkpoints in ascending order
Pedro Alves [Tue, 24 Nov 2015 18:11:22 +0000 (18:11 +0000)]
List checkpoints in ascending order

Before:
     (gdb) info checkpoints
       3 process 29132 at 0x4008ad, file foo.c, line 81
       2 process 29131 at 0x4008ad, file foo.c, line 81
       1 process 29130 at 0x4008ad, file foo.c, line 81
     * 0 Thread 0x7ffff7fc5740 (LWP 29128) (main process) at 0x4008ad, file foo.c, line 81

After:
     (gdb) info checkpoints
     * 0 Thread 0x7ffff7fc5740 (LWP 29128) (main process) at 0x4008ad, file foo.c, line 81
       1 process 29130 at 0x4008ad, file foo.c, line 81
       2 process 29131 at 0x4008ad, file foo.c, line 81
       3 process 29132 at 0x4008ad, file foo.c, line 81

gdb/ChangeLog:
2015-11-24  Pedro Alves  <palves@redhat.com>

PR 17539
        * printcmd.c (display_command): Append new display at the end of
        the list.

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

PR 17539
        * gdb.base/display.exp: Expect displays to be sorted in ascending
        order.  Use multi_line.
        * gdb.base/solib-display.exp: Likewise.

9 years agoList inferiors/threads/pspaces in ascending order
Pedro Alves [Tue, 24 Nov 2015 18:11:21 +0000 (18:11 +0000)]
List inferiors/threads/pspaces in ascending order

Before:
  (gdb) info threads
    Id   Target Id         Frame
    3    Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30
    2    Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60
  * 1    Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92

After:
  (gdb) info threads
    Id   Target Id         Frame
  * 1    Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92
    2    Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60
    3    Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30

gdb/doc/ChangeLog:
2015-11-24  Pedro Alves  <palves@redhat.com>

PR 17539
* gdb.texinfo (Inferiors and Programs): Adjust "maint info
program-spaces" example to ascending order listing.
(Threads): Adjust "info threads" example to ascending order
listing.
(Forks): Adjust "info inferiors" example to ascending order
listing.

gdb/ChangeLog:
2015-11-24  Pedro Alves  <palves@redhat.com>

PR 17539
* inferior.c (add_inferior_silent): Append the new inferior to the
end of the list.
* progspace.c (add_program_space): Append the new pspace to the
end of the list.
* thread.c (new_thread): Append the new thread to the end of the
list.

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

PR 17539
* gdb.base/foll-exec-mode.exp: Adjust to GDB listing inferiors and
threads in ascending order.
* gdb.base/foll-fork.exp: Likewise.
* gdb.base/foll-vfork.exp: Likewise.
* gdb.base/multi-forks.exp: Likewise.
* gdb.mi/mi-nonstop.exp: Likewise.
* gdb.mi/mi-nsintrall.exp: Likewise.
* gdb.multi/base.exp: Likewise.
* gdb.multi/multi-arch.exp: Likewise.
* gdb.python/py-inferior.exp: Likewise.
* gdb.threads/break-while-running.exp: Likewise.
* gdb.threads/execl.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
* gdb.threads/info-threads-cur-sal.exp: Likewise.
* gdb.threads/kill.exp: Likewise.
* gdb.threads/linux-dp.exp: Likewise.
* gdb.threads/multiple-step-overs.exp: Likewise.
* gdb.threads/next-bp-other-thread.exp: Likewise.
* gdb.threads/step-bg-decr-pc-switch-thread.exp: Likewise.
* gdb.threads/step-over-lands-on-breakpoint.exp: Likewise.
* gdb.threads/step-over-trips-on-watchpoint.exp: Likewise.
* gdb.threads/thread-find.exp: Likewise.
* gdb.threads/tls.exp: Likewise.
* lib/mi-support.exp (mi_reverse_list): Delete.
(mi_check_thread_states): No longer reverse list.

9 years agoLinux: dump the signalled thread first
Pedro Alves [Tue, 24 Nov 2015 18:11:20 +0000 (18:11 +0000)]
Linux: dump the signalled thread first

... like the kernel does.

gcore-thread.exp has a check to make sure the signalled thread is the
current thread after loading the core back, but that just works by
accident, because the signalled thread happened to be the last thread
on the thread list, and gdb currently iterates over threads in reverse
order.

So this fixes gcore-thread.exp once we start walking threads in
ascending number.

gdb/ChangeLog:
2015-11-24  Pedro Alves  <palves@redhat.com>

* linux-tdep.c (find_stop_signal): Delete.
(struct linux_corefile_thread_data) <pid>: Remove field.
(linux_corefile_thread_callback): Rename to ...
(linux_corefile_thread): ... this.  Now takes a struct
linux_corefile_thread_data pointer rather than a void pointer.
Remove thread state and thread pid checks.
(linux_make_corefile_notes): Prefer dumping the signalled thread
first.  Use ALL_NON_EXITED_THREADS instead of
iterate_over_threads.

9 years agoMake gdb.python/py-inferior.exp test names unique
Pedro Alves [Tue, 24 Nov 2015 18:11:19 +0000 (18:11 +0000)]
Make gdb.python/py-inferior.exp test names unique

Before we had:

      $ cat testsuite/gdb.sum | grep "PASS" | sort | uniq -c | sort -n
      ...
      1 PASS: gdb.python/py-inferior.exp: write str
      2 PASS: gdb.python/py-inferior.exp: Get inferior list length
      2 PASS: gdb.python/py-inferior.exp: py start_addr = gdb.selected_frame ().read_var ('search_buf')
      2 PASS: gdb.python/py-inferior.exp: Switch to first inferior
      3 PASS: gdb.python/py-inferior.exp: find mixed-sized pattern
      4 PASS: gdb.python/py-inferior.exp: py length = search_buf.type.sizeof
      4 PASS: gdb.python/py-inferior.exp: py start_addr = search_buf.address
      5 PASS: gdb.python/py-inferior.exp: Check inferior validity
      $

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

* gdb.python/py-inferior.exp: Use with_test_prefix.  Consistently
use lowercase.

9 years ago[ARM][GAS] Fix invalid arm-wince-pe tests.
Matthew Wahab [Tue, 24 Nov 2015 10:21:52 +0000 (10:21 +0000)]
[ARM][GAS] Fix invalid arm-wince-pe tests.

There are a number of failures for the arm-wince-pe targets, most are due
to the test being invalid for the target.

This patch adjusts the invalid tests to either make them valid or to set
them as skipped for arm-wince-pe targets.

gas/testsuite
2015-11-24  Matthew Wahab  <matthew.wahab@arm.com>

* gas/arm/armv7e-m+fpv5-d16.d: Skip test for *-*-pe, *-wince-* and
for *-*-coff targets.
* gas/arm/armv7e-m+fpv5-sp-d16.d: Likewise.
* gas/arm/blx-bl-convert.d: Likewise.
* gas/arm/ldst-offset0.d: Likewise.
* gas/arm/thumb2_ldr_immediate_armv6t2.d: Likewise.
* gas/arm/armv8-a+pan.s: Adjust test to make it
valid for non-ELF targets.
* gas/arm/wince.d: Add assembler option "-mccs".
* gas/arm/wince_inst.d: Update expected output.

Change-Id: I33a356e97eace3f8e1d581a46ec6413898105bef

9 years agoAdd an AArch64 simulator to GDB.
Nick Clifton [Tue, 24 Nov 2015 08:47:59 +0000 (08:47 +0000)]
Add an AArch64 simulator to GDB.

sim * configure.tgt: Add aarch64 entry.
* configure: Regenerate.
* sim/aarch64/configure.ac: New configure template.
* sim/aarch64/aclocal.m4: Generate.
* sim/aarch64/config.in: Generate.
* sim/aarch64/configure: Generate.
* sim/aarch64/cpustate.c: New file - functions for accessing
AArch64 registers.
* sim/aarch64/cpustate.h: New header.
* sim/aarch64/decode.h: New header.
* sim/aarch64/interp.c: New file - interface between GDB and
simulator.
* sim/aarch64/Makefile.in: New makefile template.
* sim/aarch64/memory.c: New file - functions for simulating
aarch64 memory accesses.
* sim/aarch64/memory.h: New header.
* sim/aarch64/sim-main.h: New header.
* sim/aarch64/simulator.c: New file - aarch64 simulator
functions.
* sim/aarch64/simulator.h: New header.

include/gdb * sim-aarch64.h: New file.

sim/test * configure: Regenerate.
* sim/aarch64: New directory.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 24 Nov 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix internal error when saving fast tracepoint definitions
Simon Marchi [Mon, 23 Nov 2015 23:47:09 +0000 (18:47 -0500)]
Fix internal error when saving fast tracepoint definitions

When trying to save fast tracepoints to file, gdb returns internal failure:

  gdb/breakpoint.c:13446: internal-error: unhandled tracepoint type 27
  A problem internal to GDB has been detected, further debugging may prove unreliable.

And no file including the fast tracepoints definition is created.

The patch also extends save-trace.exp to test saving tracepoint with a
fast tracepoint in there.  Note that because this test doesn't actually
inserts the tracepoints in the program, we can run it with targets that
don't actually support fast tracepoints (or tracepoints at all).

gdb/ChangeLog:

* breakpoint.c (tracepoint_print_recreate): Fix logic error
if -> else if.

gdb/testsuite/ChangeLog:

* gdb.trace/actions.c: Include trace-common.h.
(main): Add a location for a fast tracepoint.
* gdb.trace/save-trace.exp: Set a fast tracepoint in addition to
the normal tracepoints.
(gdb_verify_tracepoints): Adjust number of expected tracepoints.

9 years agoRefactor gdb.trace/save-trace.exp
Simon Marchi [Mon, 23 Nov 2015 23:47:08 +0000 (18:47 -0500)]
Refactor gdb.trace/save-trace.exp

Some code is duplicated, to run the test twice with absolute and
relative paths, so I factored it out in a few procs.  It uses
with_test_prefix to differentiate between test runs.

I replaced usages of "save-tracepoints" with "save tracepoint", since
the former is deprecated.

I also removed the "10.x", as it doesn't make much sense anymore.  It
isn't used in general in the testsuite, and I don't think it's really
useful.

gdb/testsuite/ChangeLog:

* save-trace.exp: Factor out code to these...
(gdb_save_tracepoints): New.
(gdb_load_tracepoints): New.
(do_save_load_test): New.

9 years agominsyms.c: Scan backwards over all zero sized symbols.
Kevin Buettner [Sat, 14 Nov 2015 20:15:45 +0000 (13:15 -0700)]
minsyms.c: Scan backwards over all zero sized symbols.

The comment for the code in question says:

  /* If the minimal symbol has a zero size, save it
     but keep scanning backwards looking for one with
     a non-zero size.  A zero size may mean that the
     symbol isn't an object or function (e.g. a
     label), or it may just mean that the size was not
     specified.  */

As written, the code in question will only scan past the first symbol
of zero size.  My change fixes the implementation to match the
comment.

Having this correct is important when the compiler generates several
local labels that are left in place by the linker.  (I've been told
that the linker should eliminate these symbols, but I know of one
architecture for which this is not happening.)

I've created a test case called asmlabel.c.  It's pretty simple:

main (int argc, char **argv)
{
  asm ("L0:");
  v = 0;
  asm ("L1:");
  v = 1; /* set L1 breakpoint here */
  asm ("L2:");
  v = 2; /* set L2 breakpoint here */
  return 0;
}

If breakpoints are placed on the lines indicated by the comments,
this is the behavior of GDB built without my patch:

    (gdb) continue
    Continuing.

    Breakpoint 2, L1 () at asmlabel.c:26
    26   v = 1; /* set L1 breakpoint here */

Note that L1 appears as the function instead of main.  This is not
what we want to happen.  With my patch in place, we see the desired
behavior instead:

    (gdb) continue
    Continuing.

    Breakpoint 2, main (argc=1, argv=0x7fffffffdb88) at asmlabel.c:26
    26   v = 1; /* set L1 breakpoint here */

gdb/ChangeLog:

* minsyms.c (lookup_minimal_symbol_by_pc_section_1): Scan backwards
over all zero-sized symbols.

gdb/testsuite/ChangeLog:

* gdb.base/asmlabel.exp: New test.
* gdb.base/asmlabel.c: New test case.

9 years agoerror/internal-error printing local variable during "bt full".
Joel Brobecker [Mon, 23 Nov 2015 18:02:50 +0000 (10:02 -0800)]
error/internal-error printing local variable during "bt full".

One of our users reported an internal error using the "bt full"
command. In their situation, reproducing involved the following
scenario:

    (gdb) frame 1
    (gdb) bt full
    #0  0xf7783430 in __kernel_vsyscall ()
    No symbol table info available.
    #1  0xf5550aeb in waitpid () at ../sysdeps/unix/syscall-template.S:81
    No locals.
    [...]
    #6  0x0fe83139 in xxxx (arg=...)
    [...some locals printed, and then...]
    <S17b> =
    [...]/dwarf2loc.c:364: internal-error: dwarf_expr_frame_base: Assertion
    `framefunc != NULL' failed.

As shown above, the error happens while GDB is trying to print the value
of <S17b>, which is a local string internally generated by the compiler.
For that, it finds that the array lives in memory, and therefore tries
to create a struct value for it via:

        case DWARF_VALUE_MEMORY:
          {
            CORE_ADDR address = dwarf_expr_fetch_address (ctx, 0);
            [...]
            retval = value_at_lazy (type, address + byte_offset);

Unfortunately for us, TYPE happens to be an array whose bounds
are dynamic. More precisely, the bounds of our arrays are described
in the debugging info as being...

 <4><2c1985e>: Abbrev Number: 33 (DW_TAG_subrange_type)
    <2c1985f>   DW_AT_type        : <0x2c1989c>
    <2c19863>   DW_AT_lower_bound : <0x2c19835>
    <2c19867>   DW_AT_upper_bound : <0x2c19841>

... which are references to a pair of local variables. For instance,
the lower bound is a reference to the following DIE

 <3><2c19835>: Abbrev Number: 32 (DW_TAG_variable)
    <2c19836>   DW_AT_name        : [...]
    <2c1983a>   DW_AT_type        : <0x2c198b4>
    <2c1983e>   DW_AT_artificial  : 1
    <2c1983e>   DW_AT_location    : 2 byte block: 91 58         (DW_OP_fbreg: -40)

As a result of the above, value_at_lazy indirectly triggers
a resolution of TYPE (via value_from_contents_and_address),
which means a resolution of TYPE's bounds, and as seen in
the DW_AT_location attribute above for our bounds, computing
the bound's location requires the frame (its location expression
uses DW_OP_fbreg).

Unfortunately for us, value_at_lazy does not get passed a frame,
we've lost the relevant frame when we try to resolve the array's
bounds. Instead, resolve_dynamic_range gets calls dwarf2_evaluate_property
with NULL as the frame:

    static struct type *
    resolve_dynamic_range (struct type *dyn_range_type,
                           struct property_addr_info *addr_stack)
    {
      [...]
      if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
                                          ^^^^

... which then handles this by using the selected frame instead:

    if (frame == NULL && has_stack_frames ())
      frame = get_selected_frame (NULL);

In our case, the selected frame happens to be frame #1, which is
a frame where we have a minimal amount of debugging info, and in
particular, no debug info for the function itself. And because of that,
when we try to determine the frame's base...

    static void
    dwarf_expr_frame_base (void *baton, const gdb_byte **start,
                           size_t * length)
    {
      struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
      const struct block *bl = get_frame_block (debaton->frame, NULL);
      [...]
      framefunc = block_linkage_function (bl);

... framefunc ends up being NULL, which triggers the assert
in that same function:

      gdb_assert (framefunc != NULL);

This patches avoids the issue by temporarily setting the selected_frame
before printing the locals of each frames.

This patch also adds a small testcase, which reproduces the same
issue, but with a slightly different outcome:

    (gdb) bt full
    #0  0x000000000040049a in opaque_routine ()
    No symbol table info available.
    #1  0x0000000000400532 in main () at wrong_frame_bt_full-main.c:20
            my_table_size = 3
            my_table = <error reading variable my_table (frame address is not available.)>

With this patch, the output becomes:

    (gdb) bt full
    [...]
            my_table = {0, 1, 2}

gdb/ChangeLog:

        * stack.c (print_frame_local_vars): Temporarily set the selected
        frame to FRAME while printing the frame's local variables.

gdb/testsuite/ChangeLog:

        * gdb.base/wrong_frame_bt_full-main.c: New file.
        * gdb.base/wrong_frame_bt_full-opaque.c: New file.
        * gdb.base/wrong_frame_bt_full.exp: New file.

9 years ago[LynxOS] GDBserver crash debugging threaded program
Joel Brobecker [Mon, 23 Nov 2015 17:56:23 +0000 (09:56 -0800)]
[LynxOS] GDBserver crash debugging threaded program

This crash is observable by debugging a threaded program on LynxOS.
On the GDB side, this is what we would see:

    % gdb q
    (gdb) target remote machine:4444
    (gdb) break q.adb:6
    (gdb) cont
    [gdb hits breakpoint]
    (gdb) cont
    Remote connection closed    <<<--- expected: [Inferior 1 (Remote target) exited normally]

On the gdbserver side, which was launched as usual:

    % gdbserver --once :4444 q
    Segmentation fault (core dumped)

Ooops!

The problem happens while GDB is trying to handle the thread termination
event of the thread that hit the breakpoint. It started happening after
the following change was made:

    commit 96e7a1eb6d09fda9e22e112e35e7d0085a8f4fd0
    Date:   Fri Oct 16 11:08:38 2015 -0400
    Subject: gdbserver: Reset current_thread when the thread is removed.

    Reset current_thread and make sure 'remove_process' is used
    after all associated threads have been removed first.

More precisely:

  . GDBserver receives the execution-resume order;

  . lynx-low resumes it succesfully, and then relies on lynx_wait_1
    to wait for the next event;

  . We quickly receive one, which lynx_wait_1 analyzes to be
    a "thread exit" event, and therefore does...

          case SIGTHREADEXIT:
            remove_thread (find_thread_ptid (new_ptid));
            lynx_continue (new_ptid);
            goto retry;

    => remove_thread causes current_thread to be set to NULL...
       (that's the recent change mentioned above)

    => ... which causes problems during lynx_continue, because
       it calls lynx_resume, which calls regcache_invalidate,
       which unfortunately assumes that CURRENT_THREAD is not NULL:

        void
        regcache_invalidate (void)
        {
          /* Only update the threads of the current process.  */
SEGV!-->  int pid = ptid_get_pid (current_thread->entry.id);

          find_inferior (&all_threads, regcache_invalidate_one, &pid);
        }

Since the problem at hand is caused by trying to figure out which
inferior to reset the regcache for, and since lynx_resume actually
had that info, this patch fixes the problem by introducing a new
routine called regcache_invalidate_pid, which invalidates the cache
of the given pid; and then modifies lynx_resume use that new routine
rather than relying on regcache_invalidate to invalidate the regcache
of the expected inferior.

gdb/gdbserver/ChangeLog:

        * regcache.h (regcache_invalidate_pid): Add declaration.
        * regcache.c (regcache_invalidate_pid): New function, extracted
        from regcache_invalidate.
        (regcache_invalidate): Reimplement using regcache_invalidate_pid.
        Add trivial documentation comment.
        * lynx-low.c: Use regcache_invalidate_pid instead of
        regcache_invalidate.

9 years agoinfinite loop stopping at "pop" insn on x64-windows
Joel Brobecker [Mon, 23 Nov 2015 17:53:31 +0000 (09:53 -0800)]
infinite loop stopping at "pop" insn on x64-windows

We noticed the following hang trying to run a program where one
of the subroutines we built without debugging info (opaque_routine):

    $ gdb my_program
    (gdb) break opaque_routine
    (gdb) run
    [...hangs...]

The problem comes from the fact that, at the breakpoint's address,
we have the following code:

    => 0x0000000000401994 <+4>:     pop    %rbp

At some point after hitting the breakpoint and stopping, GDB calls
amd64_windows_frame_decode_epilogue, which then gets stuck in the
following infinite loop:

| /* We don't care about the instruction deallocating the frame:
|    if it hasn't been executed, the pc is still in the body,
|    if it has been executed, the following epilog decoding will work.  */
|
| /* First decode:
|    -  pop reg                 [41 58-5f] or [58-5f].  */
|
| while (1)
|   {
|     /* Read opcode. */
|     if (target_read_memory (pc, &op, 1) != 0)
|       return -1;
|
|     if (op >= 0x40 && op <= 0x4f)
|       {
|         /* REX prefix.  */
|         rex = op;
|
|         /* Read opcode. */
|         if (target_read_memory (pc + 1, &op, 1) != 0)
|           return -1;
|       }
|     else
|       rex = 0;
|
|     if (op >= 0x58 && op <= 0x5f)
|       {
|         /* pop reg  */
|         gdb_byte reg = (op & 0x0f) | ((rex & 1) << 3);
|
|         cache->prev_reg_addr[amd64_windows_w2gdb_regnum[reg]] = cur_sp;
|         cur_sp += 8;
|       }
|     else
|       break;
|
|     /* Allow the user to break this loop.  This shouldn't happen as the
|        number of consecutive pop should be small.  */
|     QUIT;
|   }

Nothing in that loop updates PC, and therefore, because the instruction
we stopped at is a "pop", we keep looping forever doing the same thing
over and over!

This patch fixes the issue by advancing PC to the beginning of
the next instruction if the current one is a "pop reg" instruction.

gdb/ChangeLog:

        * amd64-windows-tdep.c (amd64_windows_frame_decode_epilogue):
        Increment PC in while loop skipping "pop reg" instructions.

9 years ago[ARM] "svc" insn check at irrelevant address in ARM unwind info sniffer
Joel Brobecker [Mon, 23 Nov 2015 17:50:55 +0000 (09:50 -0800)]
[ARM] "svc" insn check at irrelevant address in ARM unwind info sniffer

The following issue has been observed on arm-android, trying to step
over the following line of code:

        Put_Line (">>> " & Integer'Image (Message (I)));

Below is a copy of the GDB transcript:

    (gdb) cont
    Breakpoint 1, q.dump (message=...) at q.adb:11
    11               Put_Line (">>> " & Integer'Image (Message (I)));
    (gdb) next
    0x00016000 in system.concat_2.str_concat_2 ()

The expected behavior for the "next" command is to step over
the call to Put_Line and stop at line 12:

    (gdb) next
    12               I := I + 1;

What happens during the next step is that the code for line 11
above make a call to system.concat_2.str_concat_2 (to implement
the '&' string concatenation operator) before making the call
to Put_Line. While stepping, GDB stops eventually stops at the
first instruction of that function, and fails to detect that
it's a function call from where we were before, and so decides
to stop stepping.

And the reason why it fails to detect that we landed inside a function
call is because it fails to unwind from that function:

    (gdb) bt
    #0  0x00016000 in system.concat_2.str_concat_2 ()
    #1  0x0001bc74 in ?? ()

Debugging GDB, I found that GDB decides to use the ARM unwind info
for that function, which contains the following data:

    0x16000 <system__concat_2__str_concat_2>: 0x80acb0b0
      Compact model index: 0
      0xac      pop {r4, r5, r6, r7, r8, r14}
      0xb0      finish
      0xb0      finish

But, in fact, using that data is wrong, in this case, because
it mentions a pop of 6 registers, and therefore hints at a frame
size of 24 bytes. The problem is that, because we're at the first
instruction of the function, the 6 registers haven't been pushed
to the stack yet. In other words, using the ARM unwind entry above,
GDB is tricked into thinking that the frame size is 24 bytes, and
that the return address (r14) is available on the stack.

One visible manifestation of this issue can been seen by looking
at the value of the stack pointer, and the frame's base address:

    (gdb) p /x $sp
    $2 = 0xbee427b0
    (gdb) info frame
    Stack level 0, frame at 0xbee427c8:
                            ^^^^^^^^^^
                            ||||||||||

The frame's base address should be equal to the value of the stack
pointer at entry. And you eventually get the correct frame address,
as well as the correct backtrace if you just single-step one additional
instruction, past the push:

    (gdb) x /i $pc
    => 0x16000 <system__concat_2__str_concat_2>:
        push        {r4, r5, r6, r7, r8, lr}
    (gdb) stepi
    (gdb) bt
    #0  0x00016004 in system.concat_2.str_concat_2 ()
    #1  0x00012b6c in q.dump (message=...) at q.adb:11
    #2  0x00012c3c in q () at q.adb:19

Digging further, I found that GDB tries to use the ARM unwind info
only when sure that it is relevant, as explained in the following
comment:

  /* The ARM exception table does not describe unwind information
     for arbitrary PC values, but is guaranteed to be correct only
     at call sites.  We have to decide here whether we want to use
     ARM exception table information for this frame, or fall back [...]

There is one case where it decides that the info is relevant,
described in the following comment:

      /* We also assume exception information is valid if we're currently
         blocked in a system call.  The system library is supposed to
         ensure this, so that e.g. pthread cancellation works.

For that, it just parses the instruction at the address it believes
to be the point of call, and matches it against an "svc" instruction.
For instance, for a non-thumb instruction, it is at...

    get_frame_pc (this_frame) - 4

... and the code checking looks like the following.

              if (safe_read_memory_integer (get_frame_pc (this_frame) - 4, 4,
                                            byte_order_for_code, &insn)
                  && (insn & 0x0f000000) == 0x0f000000 /* svc */)
                exc_valid = 1;

However, the reason why this doesn't work in our case is that
because we are at the first instruction of a function in the innermost
frame. That frame can't possibly be making a call, and therefore
be stuck on a system call.

What the code above ends up doing is checking the instruction
just before the start of our function, which in our case is not
even an actual instruction, but unlucky for us, happens to match
the pattern it is looking for, thus leading GDB to improperly
trust the ARM unwinding data.

gdb/ChangeLog:

        * arm-tdep.c (arm_exidx_unwind_sniffer): Do not check for a frame
        stuck on a system call if the given frame is the innermost frame.

9 years ago[gdbserver] disable Elf32_auxv_t/Elf64_auxv_t AC_CHECK_TYPES check on Android
Joel Brobecker [Mon, 23 Nov 2015 17:48:16 +0000 (09:48 -0800)]
[gdbserver] disable Elf32_auxv_t/Elf64_auxv_t AC_CHECK_TYPES check on Android

See the comment added in configure.ac for more details behind
this change.

gdb/gdbserver/ChangeLog:

        * configure.ac: Do not call AC_CHECK_TYPES for Elf32_auxv_t
        and Elf64_auxv_t if the target is Android.

9 years agoFix space-vs-tab issues in gdb/testsuite/ChangeLog.
Joel Brobecker [Mon, 23 Nov 2015 17:45:52 +0000 (09:45 -0800)]
Fix space-vs-tab issues in gdb/testsuite/ChangeLog.

9 years agogdb/dwarf2read: Minimal handling of non-constant struct sizes.
Joel Brobecker [Mon, 23 Nov 2015 17:44:16 +0000 (09:44 -0800)]
gdb/dwarf2read: Minimal handling of non-constant struct sizes.

Using the gdb.ada/var_rec_arr.exp test, where the program declares
an array of variant records...

   type Record_Type (I : Small_Type := 0) is record
      S : String (1 .. I);
   end record;
   type Array_Type is array (Integer range <>) of Record_Type;

... and then a variable A1 of type Array_Type, the following command
ocassionally trigger an internal error trying to allocate more memory
than we have left:

    (gdb) ptype a1(1)
    [...]/utils.c:1089: internal-error: virtual memory exhausted.
    A problem internal to GDB has been detected,
    [...]

What happens is that recent versions of GNAT are able to generate
DWARF expressions for type Record_Type, and therefore the record's
DW_AT_byte_size is not a constant, which unfortunately breaks
an assumption made by dwarf2read.c:read_structure_type when it does:

   attr = dwarf2_attr (die, DW_AT_byte_size, cu);
   if (attr)
     {
       TYPE_LENGTH (type) = DW_UNSND (attr);
     }

As a result of this, when ada_evaluate_subexp tries to create
a value_zero for a1(1) while processing the OP_FUNCALL operator
as part of evaluating the subscripting operation in no-side-effect
mode, we try to allocate a value with a bogus size, potentially
triggering the out-of-memory internal error.

This patch avoids this issue by setting the length to zero in
this case.  Until we decide to start supporting dynamic type
lengths in GDB's type struct, and it's not clear yet that
this is worth the effort (see added comment), that's probably
the best we can do.

gdb/ChangeLog:

        * dwarf2read.c (read_structure_type): Set the type's length
        to zero if it has a DW_AT_byte_size attribute which is not
        a constant.

gdb/testsuite/ChangeLog:

        * testsuite/gdb.ada/var_rec_arr.exp: Add "ptype a1(1)" test.

9 years agoopcodes: handle mach-o for thumb/arm disambiguation.
Tristan Gingold [Fri, 20 Nov 2015 16:24:52 +0000 (17:24 +0100)]
opcodes: handle mach-o for thumb/arm disambiguation.

opcodes/
* arm-dis.c (print_insn): Also set is_thumb for Mach-O.

9 years agodarwin-nat: disable sstep cache.
Tristan Gingold [Wed, 8 Jul 2015 10:18:32 +0000 (12:18 +0200)]
darwin-nat: disable sstep cache.

Was not reliable after inferior call.

9 years agosolib-darwin: support PIE for spawned processes.
Tristan Gingold [Mon, 23 Nov 2015 10:45:05 +0000 (11:45 +0100)]
solib-darwin: support PIE for spawned processes.

solib-darwin is now able to read the load address of the executable
before any inferior execution.

9 years agodarwin-nat: rewrite darwin_read_write_inferior
Tristan Gingold [Thu, 9 Oct 2014 12:08:07 +0000 (14:08 +0200)]
darwin-nat: rewrite darwin_read_write_inferior

This is a little bit more efficient.

9 years agotarget.h: #include <sys/types.h>.
Doug Evans [Mon, 23 Nov 2015 01:24:03 +0000 (17:24 -0800)]
target.h: #include <sys/types.h>.

For musl.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 23 Nov 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agosim: common: set up CPPFLAGS/CXXFLAGS/LDFLAGS from configure [PR sim/18762]
Mike Frysinger [Sun, 22 Nov 2015 07:22:39 +0000 (23:22 -0800)]
sim: common: set up CPPFLAGS/CXXFLAGS/LDFLAGS from configure [PR sim/18762]

Make sure we pass down the CPP/CXX/LD flags that configure set up for us
like we already do for C flags.

9 years agosim: sim_do_commandf: fix call to va_end [PR sim/19273]
Mike Frysinger [Sun, 22 Nov 2015 07:10:04 +0000 (23:10 -0800)]
sim: sim_do_commandf: fix call to va_end [PR sim/19273]

Make sure we call va_end even in the error case.

9 years agosim: ppc: avoid use of $< in ordinary rules [PR sim/13834]
Mike Frysinger [Sun, 22 Nov 2015 06:56:04 +0000 (22:56 -0800)]
sim: ppc: avoid use of $< in ordinary rules [PR sim/13834]

POSIX does not define $< behavior in ordinary rules, so avoid its use
to fix building on non-GNU make setups.

Reported-by: Christopher January <chris.january@allinea.com>
9 years agosim: common: add PRI printf defines
Mike Frysinger [Sat, 20 Jun 2015 09:36:26 +0000 (15:21 +0545)]
sim: common: add PRI printf defines

Keeping track of the right printf formats for the various types can be
a pretty big hassle, especially in common code which has to support a
variety of bitsizes.  Take a page from the existing standards and add
a set of PRI macros which hide the details in a common header.

9 years agosim: avr: move global state to sim/cpu state
Mike Frysinger [Sun, 22 Nov 2015 06:00:57 +0000 (22:00 -0800)]
sim: avr: move global state to sim/cpu state

We don't want global variables in the sim as all state should be in the
sim state or in the cpu state.  This pushes down all that logic for avr.

9 years agosim: avr: switch to common sim-reg
Mike Frysinger [Sun, 22 Nov 2015 05:12:59 +0000 (21:12 -0800)]
sim: avr: switch to common sim-reg

This is not entirely useful as avr doesn't (yet) store its register
state in the cpu state, but it does allow for switching to the common
code for these functions.

9 years agosim: sh: delete global callback/argv
Mike Frysinger [Sun, 22 Nov 2015 04:47:33 +0000 (20:47 -0800)]
sim: sh: delete global callback/argv

We can use the sim state everywhere now to get these values on the fly.

9 years agosim: h8300: delete global callback/kind/name
Mike Frysinger [Sat, 21 Nov 2015 04:49:35 +0000 (20:49 -0800)]
sim: h8300: delete global callback/kind/name

We can use the sim state everywhere now to get these values on the fly.

9 years agosim: mn10300: drop global callback handle
Mike Frysinger [Sat, 21 Nov 2015 04:41:51 +0000 (20:41 -0800)]
sim: mn10300: drop global callback handle

It's used in one place and can easily be replaced by using the sim state.

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 22 Nov 2015 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 21 Nov 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix '-data-read-memory-bytes' typo/assertion
Don Breazeal [Fri, 20 Nov 2015 17:45:44 +0000 (09:45 -0800)]
Fix '-data-read-memory-bytes' typo/assertion

This patch fixes a typo in target.c:read_memory_robust, where
it calls read_whatever_is_readable with the function arguments
in the wrong order.  Depending on the address being read, it
can cause an xmalloc with a huge size, resulting in an assertion
failure, or just read something other than what was requested.

The problem only arises when GDB is handling an MI
"-data-read-memory-bytes" request and the initial target_read returns
an error status.  Note that read_memory_robust is only called from
the MI code.

gdb/ChangeLog:

* gdb/target.c (read_memory_robust): Call
read_whatever_is_readable with arguments in the correct order.

9 years agoMIPS/GAS/testsuite: Tighten negative-match NaN tests
Maciej W. Rozycki [Fri, 20 Nov 2015 16:14:33 +0000 (16:14 +0000)]
MIPS/GAS/testsuite: Tighten negative-match NaN tests

Fix a test quality regression introduced with commit 351cdf24 [[MIPS]
Implement O32 FPXX, FP64 and FP64A ABI extensions] where MIPS ABI flags
match patterns have been added to negative-match tests covering ELF file
header flags.  Negative-match tests succeed whenever there is a failure
in matching output produced and consequently the likelihood of a false
success increases when patterns to match irrelevant output are added.

Therefore remove the irrelevant paterns so that the tests complete as
soon as the line concerned has been seen.

gas/testsuite/
* gas/mips/nan-legacy-1.d: Remove MIPS ABI flags match patterns.
* gas/mips/nan-legacy-2.d: Likewise.
* gas/mips/nan-legacy-3.d: Likewise.
* gas/mips/nan-legacy-4.d: Likewise.
* gas/mips/nan-legacy-5.d: Likewise.

9 years agoMIPS/LD: Fix little-endian `mti' and `img' ELF emulations
Maciej W. Rozycki [Fri, 20 Nov 2015 16:11:22 +0000 (16:11 +0000)]
MIPS/LD: Fix little-endian `mti' and `img' ELF emulations

Make the little-endian emulation the default for the `mips*el-mti-elf*'
and `mips*el-img-elf*' targets, fixing the issue of LD rejecting, in its
default configuration, object files produced by GAS also in its default
configuration.

ld/
* configure.tgt <mips*el-mti-elf*, mips*el-img-elf*>: Add
targets.

9 years ago[AArch64] Add support for ARMv8.1 Virtulization Host Extensions.
Matthew Wahab [Fri, 20 Nov 2015 16:09:34 +0000 (16:09 +0000)]
[AArch64] Add support for ARMv8.1 Virtulization Host Extensions.

The ARMv8.1 architecture includes the Virtualization Host Extensions
which add a number of system registers. This patch adds support for
these system registers, making them available when -march=armv8.1-a is
selected.

include/opcode/
2015-11-20  Matthew Wahab  <matthew.wahab@arm.com>

* aarch64.h (AARCH64_FEATURE_V8_1): New.
(AARCH64_ARCH_v8_1): Add AARCH64_FEATURE_V8_1.

opcodes/
2015-11-20  Matthew Wahab  <matthew.wahab@arm.com>

* aarch64-opc.c (aarch64_sys_regs): Add spsr_el12, elr_el12,
sctlr_el12, cpacr_el12, ttbr1_el2, ttbr0_el12, ttbr1_el12,
tcr_el12, afsr0_el12, afsr1_el12, esr_el12, far_el12, mair_el12,
amair_el12, vbar_el12, contextidr_el2, contextidr_el12,
cntkctl_el12, cntp_tval_el02, cntp_ctl_el02, cntp_cval_el02,
cntv_tval_el02, cntv_ctl_el02, cntv_cval_el02, cnthv_tval_el2,
cnthv_ctl_el2, cnthv_cval_el2.
(aarch64_sys_reg_supported_p): Update for the new system
registers.

gas/testsuite/
2015-11-20  Matthew Wahab  <matthew.wahab@arm.com>

* gas/aarch64/virthostext-directive.d: New.
* gas/aarch64/virthostext.d: New.
* gas/aarch64/virthostext.s: New.

Change-Id: Iecb370591b1b6e9e00d81c8ccd9ae3b0f71794a2

9 years agoStop the ARM short mapping symbol test being run for the symbianelf target.
Matthew Wahab [Fri, 20 Nov 2015 15:53:41 +0000 (15:53 +0000)]
Stop the ARM short mapping symbol test being run for the symbianelf target.

* gas/arm/mapshort-elf.d: Fix typo in exclusion list.

9 years agoFix a problem with the maximum number of open files held in the cache when running...
Stefan Teleman [Fri, 20 Nov 2015 15:28:40 +0000 (15:28 +0000)]
Fix a problem with the maximum number of open files held in the cache when running on a 32-bit Solaris host.

PR ld/19260
* cache.c (bfd_cache_max_open): Avoid using getrlimit on 32-bit
Solaris as the result is unreliable.

9 years agoRemove a if-clause that is redundant because the same test has been performed earlier on.
Nick Clifton [Fri, 20 Nov 2015 14:15:20 +0000 (14:15 +0000)]
Remove a if-clause that is redundant because the same test has been performed earlier on.

PR binutils/19224
* h8300-dis.c (bfd_h8_disassemble): Remove redundant if clause.

9 years agoFix missing update in previous patch.
Tristan Gingold [Fri, 20 Nov 2015 14:14:38 +0000 (15:14 +0100)]
Fix missing update in previous patch.

bfd/
* mach-o-x86-64.c (x86_64_howto_table): Change name here too.

9 years agoFix building objcopy under mingw64 by replacing uses of strndup with xstrndup.
Ronald Hoogenboom [Fri, 20 Nov 2015 14:08:29 +0000 (14:08 +0000)]
Fix building objcopy under mingw64 by replacing uses of strndup with xstrndup.

* objcopy.c (parse_symflags): Use xstrndup in place of strndup.
(copy_main): Likewise.

9 years agobinutils: add support for arm-*-darwin and aarch64-*-darwin.
Tristan Gingold [Fri, 20 Nov 2015 10:33:33 +0000 (11:33 +0100)]
binutils: add support for arm-*-darwin and aarch64-*-darwin.

Currently only in bfd and binutils.

ChangeLog/
* configure.ac: Add aarch64-*-darwin* and arm-*-darwin*.
* configure: Regenerate.

bfd/ChangeLog/
* targets.c (aarch64_mach_o_vec, arm_mach_o_vec): Declare.
(_bfd_target_vector): Add new vectors.
* reloc.c (BFD_RELOC_MACH_O_SUBTRACTOR32)
(BFD_RELOC_MACH_O_SUBTRACTOR64, BFD_RELOC_MACH_O_ARM64_ADDEND)
(BFD_RELOC_MACH_O_ARM64_GOT_LOAD_PAGE21)
(BFD_RELOC_MACH_O_ARM64_GOT_LOAD_PAGEOFF12)
(BFD_RELOC_MACH_O_ARM64_POINTER_TO_GOT): New relocations.
(BFD_RELOC_MACH_O_X86_64_SUBTRACTOR32)
(BFD_RELOC_MACH_O_X86_64_SUBTRACTOR64): Remove.
* mach-o-x86-64.c (bfd_mach_o_x86_64_swap_reloc_out): Change
name of subtractor relocations.
* config.bfd: Handle aarch64-*-darwin*, arm-*-darwin*.
* Makefile.am (BFD32_BACKENDS): Add mach-o-arm.lo.
(BFD32_BACKENDS_CFILES): Add mach-o-arm.c.
(BFD64_BACKENDS): Add mach-o-aarch64.lo.
(BFD64_BACKENDS_CFILES): Add mach-o-aarch64.c.
* configure.ac: Handle aarch64_mach_o_vec and arm_mach_o_vec.
* mach-o-aarch64.c: New file.
* mach-o-arm.c: New file.
* Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* configure: Regenerate.
* libbfd.h: Regenerate.

9 years agoSynchronize PDP11 page size between BFD and LD.
David Bridgham [Fri, 20 Nov 2015 12:58:16 +0000 (12:58 +0000)]
Synchronize PDP11 page size between BFD and LD.

* pdp11.c (TARGET_PAGE_SIZE): Set to 256 to match definition in
ld/emulparams/pdp11.sh.

9 years agoUpdate translations.
Nick Clifton [Fri, 20 Nov 2015 12:35:43 +0000 (12:35 +0000)]
Update translations.

binutils * po/ca.po: New Catalan translation.
* configure.ac (ALL_LINGUAS): Add ca.
* configure: Regenerate.

gas * po/fr.po: Updated French translation.
* po/uk.po: Updated Ukraninan translation.
* po/zh_CN.po: New simplified Chinese translation.
* configure.ac (ALL_LINGUAS): Add zh_CN.
* configure: Regenerate.

opcodes * po/zh_CN.po: Updated simplified Chinese translation.

9 years agocallfuncs.exp: avoid spurious register differences in sparc64 targets.
Jose E. Marchesi [Fri, 20 Nov 2015 10:36:07 +0000 (11:36 +0100)]
callfuncs.exp: avoid spurious register differences in sparc64 targets.

The Linux kernel disables the FPU upon returning to userland.  This
introduces spurious failures in the register preservation tests in
callfuncs.exp, since the pstate.PEF bit gets cleared after system
calls.

This patch filters out the pstate register in sparc64-*-linux-gnu
targets, so the relevant tests are no longer fooled and pass.

gdb/testsuite/ChangeLog:

2015-11-20  Jose E. Marchesi  <jose.marchesi@oracle.com>

        * gdb.base/callfuncs.exp (fetch_all_registers): Filter out the
          pstate register when comparing registers values in
          sparc64-*-linux-gnu targets to avoid spurious differences.

9 years agosparc: fix build of gdb/testsuite/gdb.arch/sparc-sysstep.c
Jose E. Marchesi [Fri, 20 Nov 2015 09:48:56 +0000 (10:48 +0100)]
sparc: fix build of gdb/testsuite/gdb.arch/sparc-sysstep.c

This patch adds a missing include that makes the test program to not
be built (--Wimplicit-function-declaration).

gdb/testsuite/ChangeLog:

2015-11-20  Jose E. Marchesi  <jose.marchesi@oracle.com>

     * gdb.arch/sparc-sysstep.c: Include unistd.h for getpid.

9 years agoFix think-o in calls to gdb_compile.
Sandra Loosemore [Fri, 20 Nov 2015 00:22:04 +0000 (16:22 -0800)]
Fix think-o in calls to gdb_compile.

2015-11-19  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.base/nested-subp1.exp: Pass executable, not executable name,
as type argument to gdb_compile.
* gdb.base/nested-subp2.exp: Likewise.
* gdb.base/nested-subp3.exp: Likewise.

9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 20 Nov 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agogdbserver: Fix qSupported:xmlRegisters=i386;UnknownFeature+ handling
Pedro Alves [Thu, 19 Nov 2015 18:31:50 +0000 (18:31 +0000)]
gdbserver: Fix qSupported:xmlRegisters=i386;UnknownFeature+ handling

The target_process_qsupported method is called for each qSupported
feature that the common code does not recognize.  The only current
implementation, for x86 Linux (x86_linux_process_qsupported), assumes
that it either is called with the "xmlRegisters=i386" feature, or that
it is isn't called at all, indicating the connected GDB predates x86
XML descriptions.

That's a bad assumption however.  If GDB sends in a new/unknown (to
core gdbserver) feature after "xmlRegisters=i386", say, something like
qSupported:xmlRegisters=i386;UnknownFeature+, then when
target_process_qsupported is called for "UnknownFeature+",
x86_linux_process_qsupported clears the 'use_xml' global and calls
x86_linux_update_xmltarget, and gdbserver ends up _not_ reporting a
XML description...

This commit changes the target_process_qsupported API to instead pass
down a vector of unprocessed qSupported features in one go.

(There's an early call to target_process_qsupported(NULL) that
indicates "starting qSupported processing".  There's no matching call
to mark the end of processing, though.  I first fixed this by passing
(char *)-1 to indicate that, and adjusted the x86 backend to only
clear 'use_xml' when qSupported processing starts, and then only call
x86_linux_update_xmltarget() when (char *)-1 was passed.  However, I
wasn't that happy with the hack and came up this alternative version.)

gdb/gdbserver/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

* linux-low.c (linux_process_qsupported): Change prototype.
Adjust.
* linux-low.h (struct linux_target_ops) <process_qsupported>:
Change prototype.
* linux-x86-low.c (x86_linux_process_qsupported): Change prototype
and adjust to loop over all features.
* server.c (handle_query) <qSupported>: Adjust to call
target_process_qsupported once, passing it a vector of unprocessed
features.
* target.h (struct target_ops) <process_qsupported>: Change
prototype.
(target_process_qsupported): Adjust.

9 years agogdb: Workaround bad gdbserver qSupported:xmlRegisters=i386;UnknwnFeat+ handling
Pedro Alves [Thu, 19 Nov 2015 18:31:49 +0000 (18:31 +0000)]
gdb: Workaround bad gdbserver qSupported:xmlRegisters=i386;UnknwnFeat+ handling

gdbserver's target_process_qsupported is called for each feature that
the gdbserver common code does not recognize.  The only current
implementation, for x86 Linux, does this:

  static void
  x86_linux_process_qsupported (const char *query)
  {
    /* Return if gdb doesn't support XML.  If gdb sends "xmlRegisters="
       with "i386" in qSupported query, it supports x86 XML target
       descriptions.  */
    use_xml = 0;
    if (query != NULL && startswith (query, "xmlRegisters="))
      {
char *copy = xstrdup (query + 13);
char *p;

for (p = strtok (copy, ","); p != NULL; p = strtok (NULL, ","))
  {
    if (strcmp (p, "i386") == 0)
      {
use_xml = 1;
break;
      }
  }

free (copy);
      }

    x86_linux_update_xmltarget ();
  }

Notice that this clears use_xml and calls x86_linux_update_xmltarget
each time target_process_qsupported is called.  So if gdb sends in any
unknown feature after "xmlRegisters=i386", like e.g.,
"xmlRegisters=i386;UnknownFeature+" gdbserver ends up not reporting a
XML description...

Work around this by having GDB send the "xmlRegisters=" feature last.

gdb/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

* remote.c (remote_query_supported): Send the "xmlRegisters="
feature last.

9 years agoFix iov_len calculation in aarch64_linux_set_debug_regs
Simon Marchi [Thu, 19 Nov 2015 15:17:36 +0000 (10:17 -0500)]
Fix iov_len calculation in aarch64_linux_set_debug_regs

There is this build failure when building in C++:

/home/simark/src/binutils-gdb/gdb/nat/aarch64-linux-hw-point.c: In function Ã¢â‚¬Ëœvoid aarch64_linux_set_debug_regs(const aarch64_debug_reg_state*, int, int)’:
/home/simark/src/binutils-gdb/gdb/nat/aarch64-linux-hw-point.c:564:64: error: Ã¢â‚¬Ëœcount’ cannot appear in a constant-expression
   iov.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs[count - 1])
                                                                ^
We can simplify the computation and make g++ happy at the same time by
formulating as:

  size of fixed part + size of variable part

thus...

  size of fixed part + count * size of one variable part element

thus...

  offsetof (struct user_hwdebug_state, dbg_regs) + count * sizeof (regs.dbg_reg[0]);

gdb/ChangeLog:

* nat/aarch64-linux-hw-point.c (aarch64_linux_set_debug_regs): Change
form of iov_len computation.

9 years ago[C++] Default to -Werror in C++ mode too
Pedro Alves [Thu, 19 Nov 2015 14:32:54 +0000 (14:32 +0000)]
[C++] Default to -Werror in C++ mode too

Both x86_64 GNU/Linux and x86_64 mingw-w64 build cleanly with
--enable-targets=all.  This enables -Werror by default in C++ mode
too, in order to let the buildbot catch C++ build regressions for us.

gdb/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

* configure.ac (ERROR_ON_WARNING): Don't check whether in C++
mode.
* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

* configure.ac (ERROR_ON_WARNING): Don't check whether in C++
mode.
* configure: Regenerate.

9 years ago[C++] Drop -fpermissive hack
Pedro Alves [Thu, 19 Nov 2015 14:32:54 +0000 (14:32 +0000)]
[C++] Drop -fpermissive hack

Both x86_64 GNU/Linux and x86_64 mingw-w64 build cleanly with
--enable-targets=all.  Let's drop the -fpermissive hack, in order to
let the buildbot catch C++ build regressions for us.

gdb/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

* build-with-cxx.m4 (GDB_AC_BUILD_WITH_CXX): Remove -fpermissive.
* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

* configure: Regenerate.

9 years ago[C++] breakpoint.c: "no memory" software watchpoints and enum casts
Pedro Alves [Thu, 19 Nov 2015 14:32:53 +0000 (14:32 +0000)]
[C++] breakpoint.c: "no memory" software watchpoints and enum casts

Fixes:

 src/gdb/breakpoint.c: In function â€˜void update_watchpoint(watchpoint*, int)’:
 src/gdb/breakpoint.c:2147:31: error: invalid conversion from â€˜int’ to â€˜target_hw_bp_type’ [-fpermissive]
     base->loc->watchpoint_type = -1;
^

Seems better to rely on "address == -1 && length == -1" than on a enum
value that's not really part of the set of supposedly valid enum
values.  Also, factor that out to separate functions for better
localization of the concept.

gdb/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

* breakpoint.c (software_watchpoint_add_no_memory_location)
(is_no_memory_software_watchpoint): New functions.
(update_watchpoint): Use
software_watchpoint_add_memoryless_location.
(breakpoint_address_bits): Use is_no_memory_software_watchpoint.

9 years ago[C++] s390: Fix enum gdb_syscall conversion
Simon Marchi [Thu, 19 Nov 2015 14:32:53 +0000 (14:32 +0000)]
[C++] s390: Fix enum gdb_syscall conversion

Fixes:

 src/gdb/s390-linux-tdep.c: In function â€˜gdb_syscall s390_canonicalize_syscall(int, s390_abi_kind)’:
 src/gdb/s390-linux-tdep.c:2622:16: error: invalid conversion from â€˜int’ to â€˜gdb_syscall’ [-fpermissive]
  return syscall;
 ^
 src/gdb/s390-linux-tdep.c:2722:16: error: invalid conversion from â€˜int’ to â€˜gdb_syscall’ [-fpermissive]
  return syscall;
 ^
 src/gdb/s390-linux-tdep.c:2725:24: error: invalid conversion from â€˜int’ to â€˜gdb_syscall’ [-fpermissive]
  return syscall + 2;
 ^
 src/gdb/s390-linux-tdep.c:2728:24: error: invalid conversion from â€˜int’ to â€˜gdb_syscall’ [-fpermissive]
  return syscall + 5;
 ^
 src/gdb/s390-linux-tdep.c:2731:24: error: invalid conversion from â€˜int’ to â€˜gdb_syscall’ [-fpermissive]
  return syscall + 6;
 ^
 src/gdb/s390-linux-tdep.c:2734:24: error: invalid conversion from â€˜int’ to â€˜gdb_syscall’ [-fpermissive]
  return syscall + 7;
 ^

gdb/ChangeLog:
2015-11-19  Simon Marchi  <simon.marchi@ericsson.com>
    Pedro Alves  <palves@redhat.com>

* s390-linux-tdep.c (s390_canonicalize_syscall): Add casts and
intermediate 'int' variable.

9 years ago[C++] linux-thread-db.c: dladdr cast
Pedro Alves [Thu, 19 Nov 2015 14:32:53 +0000 (14:32 +0000)]
[C++] linux-thread-db.c: dladdr cast

Fixes:

 src/gdb/linux-thread-db.c: In function â€˜int try_thread_db_load_1(thread_db_info*)’:
 src/gdb/linux-thread-db.c:769:53: error: invalid conversion from â€˜td_err_e (*)(ps_prochandle*, td_thragent_t**) {aka td_err_e (*)(ps_prochandle*, td_thragent**)}’ to â€˜const void*’ [-fpermissive]
library = dladdr_to_soname (*info->td_ta_new_p);
      ^
 src/gdb/linux-thread-db.c:637:1: error:   initializing argument 1 of â€˜const char* dladdr_to_soname(const void*)’ [-fpermissive]
  dladdr_to_soname (const void *addr)
  ^

gdb/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

* linux-thread-db.c (try_thread_db_load_1): Add cast.

9 years ago[C++] remote.c: Avoid enum arithmetic
Pedro Alves [Thu, 19 Nov 2015 14:32:53 +0000 (14:32 +0000)]
[C++] remote.c: Avoid enum arithmetic

Fixes:

  src/gdb/remote.c: In function â€˜void remote_unpush_target()’:
  src/gdb/remote.c:4610:45: error: invalid conversion from â€˜int’ to â€˜strata’ [-fpermissive]
     pop_all_targets_above (process_stratum - 1);
       ^
  In file included from src/gdb/inferior.h:38:0,
   from src/gdb/remote.c:25:
  src/gdb/target.h:2299:13: error:   initializing argument 1 of â€˜void pop_all_targets_above(strata)’ [-fpermissive]
   extern void pop_all_targets_above (enum strata above_stratum);
       ^

I used to carry a patch in the C++ branch that just did:

 -  pop_all_targets_above (process_stratum - 1);
 +  pop_all_targets_above ((enum strata) (process_stratum - 1));

But then thought that maybe adding a routine that does exactly what we
need results in clearer code.  This is the result.

gdb/ChangeLog:
2015-11-19  Pedro Alves  <palves@redhat.com>

* remote.c (remote_unpush_target): Use
pop_all_targets_at_and_above instead of pop_all_targets_above.
* target.c (unpush_target_and_assert): New function, factored out
from ...
(pop_all_targets_above): ... here.
(pop_all_targets_at_and_above): New function.
* target.h (pop_all_targets_at_and_above): Declare.

9 years ago[AArch64] Reject invalid immediate operands to MSR PAN
Matthew Wahab [Thu, 19 Nov 2015 14:13:45 +0000 (14:13 +0000)]
[AArch64] Reject invalid immediate operands to MSR PAN

The support for accessing the ARMv8.1 PSTATE field PAN allows
instructions of the form MSR PAN, #<imm> with <imm> any unsigned 4-bit
integer. However, the architecture specification requires that the
immediate is either 0 or 1.

This patch implements the constraint on the immediate, generating an
error if the immediate operand is invalid, and adds tests for the
illegal forms.

opcodes/
2015-11-19  Matthew Wahab  <matthew.wahab@arm.com>

* aarch64-opc.c (operand_general_constraint_met_p): Check validity
of MSR PAN immediate operand.

gas/testsuite/
2015-11-19  Matthew Wahab  <matthew.wahab@arm.com>

* gas/aarch64/pan-illegal.d: New.
* gas/aarch64/pan-illegal.l: New.
* gas/aarch64/pan.s: Add tests for invalid immediates.

Change-Id: Ibb3056c975eb792104da138d94594224f56a993e

9 years agoChange argument opcode type from enum aarch64_opcodes to uint32_t
Yao Qi [Thu, 19 Nov 2015 13:58:29 +0000 (13:58 +0000)]
Change argument opcode type from enum aarch64_opcodes to uint32_t

The patch fixes the following errors in C++ build,

gdb/gdbserver/linux-aarch64-low.c: In function 'int emit_data_processing(uint32_t*, aarch64_opcodes, aarch64_register, aarch64_register, aarch64_operand)':
gdb/gdbserver/linux-aarch64-low.c:1071:52: error: invalid conversion from 'unsigned int' to 'aarch64_opcodes' [-fpermissive]
       return emit_data_processing_reg (buf, opcode | operand_opcode, rd,
                                                    ^
gdb/gdbserver:

2015-11-19  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (emit_data_processing_reg): Change opcode
type to uint32_t.

9 years agoDefine enum out of the scope of struct
Yao Qi [Thu, 19 Nov 2015 13:58:29 +0000 (13:58 +0000)]
Define enum out of the scope of struct

This patch moves the enum definition out of the scope of struct, and
fixes the following error.

gdb/gdbserver/linux-aarch64-low.c:681:18: error: 'OPERAND_REGISTER' was not declared in this scope
   operand.type = OPERAND_REGISTER;
                  ^
gdb/gdbserver:

2015-11-19  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (enum aarch64_operand_type): New.
(struct aarch64_operand): Move enum out.

9 years agoCast void * to user_fpsimd_state *.
Yao Qi [Thu, 19 Nov 2015 13:58:29 +0000 (13:58 +0000)]
Cast void * to user_fpsimd_state *.

This patch fixes the following build error in GDBserver,

gdb/gdbserver/linux-aarch64-low.c: In function 'void aarch64_fill_fpregset(regcache*, void*)':
gdb/gdbserver/linux-aarch64-low.c:134:38: error: invalid conversion from 'void*' to 'user_fpsimd_state*' [-fpermissive]
   struct user_fpsimd_state *regset = buf;
                                      ^
gdb/gdbserver/linux-aarch64-low.c: In function 'void aarch64_store_fpregset(regcache*, const void*)':
gdb/gdbserver/linux-aarch64-low.c:146:44: error: invalid conversion from 'const void*' to 'const user_fpsimd_state*' [-fpermissive]
   const struct user_fpsimd_state *regset = buf;
                                            ^
gdb/gdbserver:

2015-11-19  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_fill_fpregset): Cast buf to
struct user_fpsimd_state *.
(aarch64_store_fpregset): Likewise.

9 years agoCast void * to struct user_pt_regs *
Yao Qi [Thu, 19 Nov 2015 13:58:29 +0000 (13:58 +0000)]
Cast void * to struct user_pt_regs *

This patch fixes the following GDBserver build errors in C++.

gdb/gdbserver/linux-aarch64-low.c:108:33: error: invalid conversion from 'void*' to 'user_pt_regs*' [-fpermissive]
   struct user_pt_regs *regset = buf;
                                 ^
gdb/gdbserver/linux-aarch64-low.c: In function 'void aarch64_store_gregset(regcache*, const void*)':
gdb/gdbserver/linux-aarch64-low.c:121:39: error: invalid conversion from 'const void*' to 'const user_pt_regs*' [-fpermissive]
   const struct user_pt_regs *regset = buf;

gdb/gdbserver:

2015-11-19  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_fill_gregset): Cast buf to
struct user_pt_regs *.
(aarch64_store_gregset): Likewise.

9 years ago[S/390] Add null ptr check + port GOTOFF handling from 32 bit over to 64 bit
Andreas Krebbel [Thu, 19 Nov 2015 10:10:06 +0000 (11:10 +0100)]
[S/390] Add null ptr check + port GOTOFF handling from 32 bit over to 64 bit

bfd/ChangeLog:

2015-11-19  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

PR ld/19263
* elf32-s390.c (elf_s390_gc_sweep_hook): Add null ptr check.
* elf64-s390.c (elf_s390_check_relocs): Port the GOTOFF handling
over from the 32 bit code.
(elf_s390_relocate_section): Likewise.

9 years ago[ARM] Add ARMv8.2 architecture feature and command line option.
Matthew Wahab [Thu, 19 Nov 2015 09:24:14 +0000 (09:24 +0000)]
[ARM] Add ARMv8.2 architecture feature and command line option.

ARMv8.2 is an architectural extension of ARMv8. This patch adds an
architecture feature macro for ARMv8.2 to the binutils ARM target
with GAS command line option -march=armv8.2-a.

gas/
2015-11-19  Matthew Wahab  <matthew.wahab@arm.com>

* config/tc-arm.c (arm_archs): Add "armv8.2-a".
* doc/c-arm.texi (-march): Add "armv8.2-a".

include/opcode/
2015-11-19  Matthew Wahab  <matthew.wahab@arm.com>

* arm.h (ARM_EXT2_V8_2A): New.
(ARM_ARCH_V8_2A): New.

Change-Id: I9e0f50e3c6cea24e6b87b8b862fd4e1cdcc1052e

9 years ago[AArch64] Add ARMv8.2 command line option and feature flag.
Matthew Wahab [Thu, 19 Nov 2015 09:12:49 +0000 (09:12 +0000)]
[AArch64] Add ARMv8.2 command line option and feature flag.

ARMv8.2 is an architectural extension of ARMv8. This patch adds an
architecture feature macro for ARMv8.2 to the binutils AArch64 target
with GAS command line option -march=armv8.2-a.

gas/
2015-11-19  Matthew Wahab  <matthew.wahab@arm.com>

* config/tc-aarch64.c (aarch64_archs): Add "armv8.2-a".
* doc/c-aarch64.texi (-march): Likewise.

include/opcode/
2015-11-19  Matthew Wahab  <matthew.wahab@arm.com>

* aarch64.h (AARCH64_FEATURE_V8_2): New.
(AARCH64_ARCH_V8_2): New.

Change-Id: I129232ab00234a07d18ce4b619607344acb3cbaf

9 years agooutput_big_leb128 comment
Alan Modra [Thu, 19 Nov 2015 06:31:59 +0000 (17:01 +1030)]
output_big_leb128 comment

* read.c (output_big_leb128): Describe "sign" parameter.

9 years ago[GOLD] PowerPC TOC16 and GOT16 relocs are relative
Alan Modra [Thu, 19 Nov 2015 06:29:36 +0000 (16:59 +1030)]
[GOLD] PowerPC TOC16 and GOT16 relocs are relative

* powerpc.cc (Target_powerpc::Scan::get_reference_flags): Correct
GOT16 and TOC16 relocs to RELATIVE_REF.

9 years agoRecent powerpc testcase fails
Alan Modra [Thu, 19 Nov 2015 06:27:49 +0000 (16:57 +1030)]
Recent powerpc testcase fails

On powerpcle-cygwin a couple of tests fail due to alignment.

* gas/ppc/altivec3.d: Allow for padding at end of section.
* gas/testsuite/gas/ppc/power9.d: Likewise.

9 years agoUse default sub-segment align for non-ELF powerpc
Alan Modra [Thu, 19 Nov 2015 06:23:43 +0000 (16:53 +1030)]
Use default sub-segment align for non-ELF powerpc

Defining this to zero for COFF and PE meant that code sections were
padded with zeros.  The fact that no one has complained since 2006
says these targets are dead, I guess.

* config/tc-ppc.h (SUB_SEGMENT_ALIGN): Define only for ELF.

9 years agoAccount for .tbss alignment when adjusting start of relro
Alan Modra [Thu, 19 Nov 2015 04:30:13 +0000 (15:00 +1030)]
Account for .tbss alignment when adjusting start of relro

Another option might be to not bump "dot" for .tbss alignment in the
main section sizing loop, but that could leak some of the following
section into the TLS segment.  Leakage shouldn't matter since it will
be to bytes past the end of .tdata, but for now this is a safer
option.

PR ld/19264
* ldlang.c (lang_size_sections): Don't ignore .tbss when
adjusting start of relro region.

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 19 Nov 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoConstify value_string
Simon Marchi [Wed, 18 Nov 2015 16:20:22 +0000 (11:20 -0500)]
Constify value_string

If we constify value_cstring, we might as well constify this one.

gdb/ChangeLog:

* valops.c (value_string): Constify 'ptr' parameter.
* value.h (value_string): Constify 'ptr' parameter.

9 years ago[C++] Add casts to obstack_base calls
Simon Marchi [Tue, 17 Nov 2015 13:07:24 +0000 (13:07 +0000)]
[C++] Add casts to obstack_base calls

The recent libiberty import of upstream obstack.h (314dee8ea9be) makes
obstack_base return a 'void *', with the consequence that a few places
in gdb need a (char *) cast.

gdb/ChangeLog:
2015-11-18  Simon Marchi  <simon.marchi@ericsson.com>
    Pedro Alves  <palves@redhat.com>

* break-catch-sig.c (signal_catchpoint_print_one): Add cast.
* c-exp.y (parse_string_or_char, yylex): Add casts.
* c-lang.c (evaluate_subexp_c): Add casts.
* d-exp.y (parse_string_or_char, yylex): Add casts.
* go-exp.y (parse_string_or_char, build_packaged_name): Add casts.
* p-valprint.c (pascal_object_print_value_fields): Add casts.
* valprint.c (generic_emit_char, generic_printstr): Add casts.

9 years agoConstify value_cstring
Simon Marchi [Wed, 18 Nov 2015 15:51:17 +0000 (15:51 +0000)]
Constify value_cstring

gdb/ChangeLog:
2015-11-18  Simon Marchi  <simon.marchi@ericsson.com>

* valops.c (value_cstring): Constify 'ptr' parameter.
* value.h (value_cstring): Constify 'ptr' parameter.

9 years agomach-o: decode and display arm64 compact unwind entries.
Tristan Gingold [Wed, 18 Nov 2015 15:45:03 +0000 (16:45 +0100)]
mach-o: decode and display arm64 compact unwind entries.

9 years agomach-o: use a per-target reloc canonicalize function.
Tristan Gingold [Wed, 18 Nov 2015 14:43:27 +0000 (15:43 +0100)]
mach-o: use a per-target reloc canonicalize function.

bfd/
* mach-o.h (bfd_mach_o_swap_in_non_scattered_reloc)
(bfd_mach_o_canonicalize_non_scattered_reloc)
(bfd_mach_o_pre_canonicalize_one_reloc): Declare.
(bfd_mach_o_backend_data): Rename field
_bfd_mach_o_swap_reloc_in to _bfd_mach_o_canonicalize_one_reloc.
* mach-o.c (bfd_mach_o_swap_in_non_scattered_reloc): Now public.
(bfd_mach_o_canonicalize_non_scattered_reloc): Renames from
bfd_mach_o_canonicalize_one_reloc.
(bfd_mach_o_pre_canonicalize_one_reloc): New function.
(bfd_mach_o_canonicalize_relocs): Adjust.
(bfd_mach_o_canonicalize_relocs): Rename define from
bfd_mach_o_swap_reloc_in.
* mach-o-target.c (TARGET_NAME_BACKEND): Use
bfd_mach_o_canonicalize_one_reloc instead of
bfd_mach_o_swap_reloc_in.
* mach-o-i386.c (bfd_mach_o_i386_canonicalize_one_reloc): Renames
from bfd_mach_o_i386_swap_reloc_in and adjust.
(bfd_mach_o_canonicalize_one_reloc): Renames from
bfd_mach_o_i386_canonicalize_one_reloc.
* mach-o-x86_64.c (bfd_mach_o_x86_64_canonicalize_one_reloc): Renames
from bfd_mach_o_x86_64_swap_reloc_in and adjust.
(bfd_mach_o_canonicalize_one_reloc): Renames from
bfd_mach_o_x86_64_canonicalize_one_reloc.

9 years ago[gdbserver/ipa] Fix build dependencies
Pedro Alves [Wed, 18 Nov 2015 13:02:21 +0000 (13:02 +0000)]
[gdbserver/ipa] Fix build dependencies

Commit 91ee7171d088 (MinGW and attribute format(printf/gnu_printf))
made common/common-defs.h depend on gnulib's substitute headers.
Turns out that that broke the gdbserver/ipa build (as the buildbots
discovered) because nothing is making sure that gnulib is built before
the ipa is.

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

* Makefile.in (all_object_files): Add $IPA_OBJS.

9 years agoFix out of boundary access in pass_in_v
Yao Qi [Wed, 18 Nov 2015 11:49:32 +0000 (11:49 +0000)]
Fix out of boundary access in pass_in_v

Hi,
I build GDB with -fsanitize=address, and run testsuite.  In
gdb.base/callfuncs.exp, I see the following error,

p t_float_values(0.0,0.0)
=================================================================
==8088==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000cb650 at pc 0x6e195c bp 0x7fff164f9770 sp 0x7fff164f9768
READ of size 16 at 0x6020000cb650 thread T0^
    #0 0x6e195b in regcache_raw_write /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:912
    #1 0x6e1e52 in regcache_cooked_write /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:945
    #2 0x466d69 in pass_in_v /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1101
    #3 0x467512 in pass_in_v_or_stack /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1196
    #4 0x467d7d in aarch64_push_dummy_call /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1335

The code in pass_in_v read contents from V registers (128 bit), but the
data passed through V registers can be less than 128 bit.  In this case,
float is passed.  So writing V registers contents into contents buff
will cause overflow.  In this patch, we add an array reg[V_REGISTER_SIZE],
which is to hold the contents from V registers, and then copy useful
bits to buf.

gdb:

2015-11-18  Yao Qi  <yao.qi@linaro.org>

* aarch64-tdep.c (pass_in_v): Add argument len.  Add local array
reg.  Callers updated.

9 years agoPrevent looping in archives
Alan Modra [Wed, 18 Nov 2015 11:42:23 +0000 (22:12 +1030)]
Prevent looping in archives

PR 19256
* archive.c (bfd_generic_openr_next_archived_file): Don't allow
backward file movement via "negative" sizes.
* coff-alpha.c (alpha_ecoff_openr_next_archived_file): Likewise.

9 years agomach-o cleanup: remove useless calls to bfd_seek.
Tristan Gingold [Wed, 18 Nov 2015 09:33:11 +0000 (10:33 +0100)]
mach-o cleanup: remove useless calls to bfd_seek.

Also support new commands.

bfd/
* mach-o.h (struct mach_o_data_struct): Add hdr_offset field.
(bfd_mach_o_fat_archive_p): Renames prototype.
(bfd_mach_o_fat_openr_next_archived_file): Renames.
(bfd_mach_o_header_p): Add argument.
* mach-o.c (bfd_mach_o_read_header): Add hdr_off argument and
use it.
(bfd_mach_o_read_section_32, bfd_mach_o_read_section_64)
(bfd_mach_o_read_section): Remove offset argument.
(bfd_mach_o_read_dylinker): Remove bfd_seek call.
(bfd_mach_o_read_dylib, bfd_mach_o_read_prebound_dylib)
(bfd_mach_o_read_prebind_cksum, bfd_mach_o_read_twolevel_hints)
(bfd_mach_o_read_fvmlib, bfd_mach_o_read_dysymtab)
(bfd_mach_o_read_symtab, bfd_mach_o_read_uuid)
(bfd_mach_o_read_linkedit, bfd_mach_o_read_str)
(bfd_mach_o_read_dyld_info, bfd_mach_o_read_version_min)
(bfd_mach_o_read_encryption_info): Likewise.
(bfd_mach_o_read_encryption_info_64): New function.
(bfd_mach_o_read_main, bfd_mach_o_read_source_version)
(bfd_mach_o_read_segment): Remove call to bfd_seek.
(bfd_mach_o_read_command): Use hdr_offset in bfd_seek.
Handle BFD_MACH_O_LC_LINKER_OPTIMIZATION_HINT,
BFD_MACH_O_LC_ENCRYPTION_INFO_64, BFD_MACH_O_LC_VERSION_MIN_WATCHOS.
(bfd_mach_o_header_p): Add hdr_off argument.
(bfd_mach_o_gen_object_p, bfd_mach_o_gen_core_p): Adjust calls.
(bfd_mach_o_fat_archive_p): Renames.
(bfd_mach_o_fat_openr_next_archived_file): Renames.
(bfd_mach_o_close_and_cleanup): Remove useless code.
(bfd_mach_o_close_and_cleanup): Define.
* mach-o-x86-64.c (bfd_mach_o_x86_64_object_p)
(bfd_mach_o_x86_64_core_p): Adjust calls.
* mach-o-target.c: Move defines for archive from mach-o.c.
Remove check on TARGET_ARCHIVE.
* mach-o-i386.c (bfd_mach_o_i386_object_p)
(bfd_mach_o_i386_core_p): Adjust calls.

9 years agosim: mn10300/v850: drop unused WITH_CORE define
Mike Frysinger [Tue, 17 Nov 2015 08:24:35 +0000 (00:24 -0800)]
sim: mn10300/v850: drop unused WITH_CORE define

This was dropped from the sim core in 1997, so no point in having these
sim ports continue to define it.

9 years agosim: always enable modulo memory
Mike Frysinger [Tue, 17 Nov 2015 08:19:56 +0000 (00:19 -0800)]
sim: always enable modulo memory

Having this be a config option doesn't make sense: the code size is
pretty much the same (as all the logic is still active), and if it's
disabled, the sim throws an error if you try to use it.  That means
we can't break sims that weren't using it before by enabling it all
the time.

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 18 Nov 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years ago[sim/ppc] Fix printf_filtered reference
Pedro Alves [Tue, 17 Nov 2015 19:21:21 +0000 (19:21 +0000)]
[sim/ppc] Fix printf_filtered reference

Building a gdb that includes the PPC sim in C++ mode fails to link with:

(...)s.o compile-object-load.o compile-object-run.o compile-loc2c.o compile-c-support.o inflow.o    init.o \
          ../sim/ppc/libsim.a ../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a -lz  ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -ldl -ldl -lncurses -lm -ldl  -lguile-2.0 -lgc  -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic -lexpat -llzma -lbabeltrace -lbabeltrace-ctf  ../libiberty/libiberty.a  build-gnulib/import/libgnu.a
../sim/ppc/libsim.a(sim_calls.o): In function `sim_open':
/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:73: undefined reference to `printf_filtered'
/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:73: undefined reference to `printf_filtered'
../sim/ppc/libsim.a(sim_calls.o): In function `sim_close':
/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:93: undefined reference to `printf_filtered'
/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:93: undefined reference to `printf_filtered'
../sim/ppc/libsim.a(sim_calls.o): In function `sim_load':
/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:102: undefined reference to `printf_filtered'
../sim/ppc/libsim.a(sim_calls.o):/home/pedro/gdb/mygit/cxx-convertion/src/sim/ppc/sim_calls.c:102: more undefined references to `printf_filtered' follow
collect2: error: ld returned 1 exit status

The undefined references come from TRACE macro calls, which expand to
calls to printf_filtered.

But note that the sim's 'printf_filtered' is actually a #define to
'sim_io_printf_filtered', in sim_callbacks.h :

 #define printf_filtered sim_io_printf_filtered

AFAICS, this is not meant to call gdb's printf_filtered function.  The
ChangeLog entry that added the printf_filtered macro reads:

 Tue Jul 30 21:12:24 1996  Andrew Cagney  <cagney@kremvax.highland.com.au>

 * sim_callbacks.h (sim_io_printf_filtered): Replace
 printf_filtered with a local simulator specific version.  Add
 #define printf_filtered to simplify updating of existing code.

That is, just another incomplete/partial transition.  Maybe prior to
1996 this was really meant to call gdb's printf_filtered version.

The reference to printf_filtered appears because sim_calls.c, the
compilation unit that fails to link, has this at the top:

 #undef printf_filtered /* blow away the mapping */

presumably so that this further below:

 void
 sim_io_printf_filtered(const char *fmt,
...)
 {
   (...)
   callbacks->printf_filtered(callbacks, "%s", message);
 }

works.  So those TRACE macros instances in sim_calls.c just happen to
work because gdb is linked in, which satisfies the 'printf_filtered'
reference, when GDB is built in C mode.  When built in C++ mode, the
problem is exposed, as GDB's printf_filtered is mangled.

The fix here is to make the TRACE macro call sim_io_printf_filtered
directly.

(Standalone "run" doesn't fail to link simply because the offending
routines are not part of its link.)

sim/ppc/ChangeLog
2015-11-17  Pedro Alves  <palves@redhat.com>

* debug.h (TRACE, ITRACE, DTRACE, DITRACE, PTRACE): Call
sim_io_printf_filtered instead of printf_filtered.

9 years agoFix gdb.threads/multiple-step-overs.exp fails on arm
Yao Qi [Tue, 17 Nov 2015 15:40:29 +0000 (15:40 +0000)]
Fix gdb.threads/multiple-step-overs.exp fails on arm

Hi,
Some tests in gdb.threads/multiple-step-overs.exp fail on arm target
when the displaced stepping on, but they pass when displaced stepping
is off.

 FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: step: step
 FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: next: next
 FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: continue: continue
 FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: signal thr1: continue to sigusr1_handler

when displaced stepping is on,

Sending packet: $vCont;c#a8...infrun: infrun_async(1)^M <--- [1]
infrun: prepare_to_wait^M
infrun: target_wait (-1.0.0, status) =^M
infrun:   -1.0.0 [Thread 0],^M
infrun:   status->kind = ignore^M
infrun: TARGET_WAITKIND_IGNORE^M
infrun: prepare_to_wait^M
Packet received: T05swbreak:;0b:f8faffbe;0d:409ee7b6;0f:d0880000;thread:p635.636;core:0;^M
infrun: target_wait (-1.0.0, status) =^M
infrun:   1589.1590.0 [Thread 1590],^M
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP^M
infrun: TARGET_WAITKIND_STOPPED^M
infrun: stop_pc = 0x88d0^M
infrun: context switch^M
infrun: Switching context from Thread 1591 to Thread 1590^

GDB resumes the whole process (all threads) rather than the specific
thread for which GDB wants to step over the breakpoint (as shown in [1]).
That is wrong because we resume a single thread and leave others stopped
when doing a normal step over where we temporarily remove the breakpoint,
single-step, reinsert the breakpoint, is that if we let other threads run
in the period while the breakpoint is removed, then these other threads
could miss the breakpoint.  Since with displaced stepping, we don't ever
remove the breakpoint, it should be fine to let other threads run.  However,
there's another reason that we should not let other threads run: that is
the case where some of those threads are also stopped for a breakpoint that
itself needs to be stepped over.  If we just let those threads run, then
they immediately re-trap their breakpoint again.

when displaced stepping is off, GDB behaves correctly, only resumes
the specific thread (as shown in [2]).

Sending packet: $vCont;c:p611.613#b2...infrun: infrun_async(1)^M <-- [2]
infrun: prepare_to_wait^M
infrun: target_wait (-1.0.0, status) =^M
infrun:   -1.0.0 [Thread 0],^M
infrun:   status->kind = ignore^M
infrun: TARGET_WAITKIND_IGNORE^M
infrun: prepare_to_wait^M
Packet received: T05swbreak:;0b:f8faffbe;0d:409e67b6;0f:48880000;thread:p611.613;core:1;^M
infrun: target_wait (-1.0.0, status) =^M
infrun:   1553.1555.0 [Thread 1555],^M
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP^M
infrun: TARGET_WAITKIND_STOPPED^M
infrun: clear_step_over_info^M
infrun: stop_pc = 0x8848

The current logic in GDB on deciding the set of threads to resume is:

  /* Decide the set of threads to ask the target to resume.  */
  if ((step || thread_has_single_step_breakpoints_set (tp))
      && tp->control.trap_expected)
    {
      /* We're allowing a thread to run past a breakpoint it has
 hit, by single-stepping the thread with the breakpoint
 removed.  In which case, we need to single-step only this
 thread, and keep others stopped, as they can miss this
 breakpoint if allowed to run.  */
      resume_ptid = inferior_ptid;
    }
  else
    resume_ptid = internal_resume_ptid (user_step);

it doesn't handle the case correctly that GDB continue (instead of
single step) the thread for displaced stepping.

I also update the comment below to reflect the code.  I remove the
"with the breakpoint removed" comment, because GDB doesn't remove
breakpoints in displaced stepping, so we don't have to worry that
other threads may miss the breakpoint.

Patch is regression tested on both x86_64-linux and arm-linux.

gdb:

2015-11-17  Yao Qi  <yao.qi@linaro.org>

* infrun.c (resume): Check control.trap_expected only
when deciding the set of threads to resume.

9 years agoIntroduce null_block_symbol
Pedro Alves [Tue, 17 Nov 2015 13:12:23 +0000 (13:12 +0000)]
Introduce null_block_symbol

... in the spirit of null_ptid, null_frame_id, etc.

Fixes two instances of:

  /root/binutils-gdb/gdb/cp-namespace.c: In function 'block_symbol cp_lookup_nested_symbol(type*, const char*, const block*, domain_enum)':
  /root/binutils-gdb/gdb/cp-namespace.c:1010: warning: jump to case label
  /root/binutils-gdb/gdb/cp-namespace.c:1008: error:   crosses initialization of 'block_symbol <anonymous>'

Compiler info:

  Reading specs from /usr/lib/gcc-lib/amd64-unknown-openbsd5.8/4.2.1/specs
  Target: amd64-unknown-openbsd5.8
  Configured with: OpenBSD/amd64 system compiler
  Thread model: posix
  gcc version 4.2.1 20070719

gdb/ChangeLog:
2015-11-17  Pedro Alves  <palves@redhat.com>

* cp-namespace.c (cp_lookup_bare_symbol)
(cp_search_static_and_baseclasses, cp_lookup_symbol_via_imports)
(cp_lookup_symbol_via_all_imports, cp_lookup_nested_symbol_1)
(cp_lookup_nested_symbol): Use null_block_symbol.
* d-namespace.c (d_lookup_symbol, d_lookup_nested_symbol)
(d_lookup_symbol_imports, d_lookup_symbol_module): Use
null_block_symbol.
* symtab.c (null_block_symbol): New global.
* symtab.h (null_block_symbol): Declare.