Commit Graph

85714 Commits

Author SHA1 Message Date
Pedro Alves 050c224b67 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.
2015-11-24 18:36:09 +00:00
Pedro Alves 2cc57ad8d1 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.
2015-11-24 18:11:19 +00:00
Matthew Wahab 3ff0b31dc6 [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
2015-11-24 10:21:52 +00:00
Nick Clifton 2e8cf49e13 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.
2015-11-24 08:47:59 +00:00
GDB Administrator 351e610191 Automatic date update in version.in 2015-11-24 00:00:08 +00:00
Simon Marchi c93e8391bf 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.
2015-11-23 18:47:09 -05:00
Simon Marchi 045ccf910b 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.
2015-11-23 18:47:08 -05:00
Kevin Buettner 5506f9f67e 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.
2015-11-23 15:42:44 -07:00
Joel Brobecker 16c3b12f19 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.
2015-11-23 10:02:50 -08:00
Joel Brobecker 80d82c1964 [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 96e7a1eb6d
    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.
2015-11-23 09:56:23 -08:00
Joel Brobecker a6a20ad7a1 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.
2015-11-23 09:53:31 -08:00
Joel Brobecker 416dc9c6e9 [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.
2015-11-23 09:50:55 -08:00
Joel Brobecker 64da5dd5ea [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.
2015-11-23 09:48:16 -08:00
Joel Brobecker 206853a02e Fix space-vs-tab issues in gdb/testsuite/ChangeLog. 2015-11-23 09:45:52 -08:00
Joel Brobecker 155bfbd30a 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.
2015-11-23 09:44:16 -08:00
Tristan Gingold e49d43ff73 opcodes: handle mach-o for thumb/arm disambiguation.
opcodes/
	* arm-dis.c (print_insn): Also set is_thumb for Mach-O.
2015-11-23 15:50:29 +01:00
Tristan Gingold aa14fb5078 darwin-nat: disable sstep cache.
Was not reliable after inferior call.
2015-11-23 15:29:57 +01:00
Tristan Gingold ad2073b0b4 solib-darwin: support PIE for spawned processes.
solib-darwin is now able to read the load address of the executable
before any inferior execution.
2015-11-23 14:52:12 +01:00
Tristan Gingold 3eb831e0ca darwin-nat: rewrite darwin_read_write_inferior
This is a little bit more efficient.
2015-11-23 11:26:34 +01:00
Doug Evans 37ce4055fe target.h: #include <sys/types.h>.
For musl.
2015-11-22 17:24:03 -08:00
GDB Administrator d41fc1249b Automatic date update in version.in 2015-11-23 00:00:08 +00:00
Mike Frysinger dc11500a11 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.
2015-11-22 02:23:25 -05:00
Mike Frysinger 2561d5808a sim: sim_do_commandf: fix call to va_end [PR sim/19273]
Make sure we call va_end even in the error case.
2015-11-22 02:15:28 -05:00
Mike Frysinger 7c125e3b10 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>
2015-11-22 01:59:20 -05:00
Mike Frysinger 37258e9950 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.
2015-11-22 01:37:24 -05:00
Mike Frysinger 82d442c6c6 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.
2015-11-22 01:12:21 -05:00
Mike Frysinger 807eaf04cb 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.
2015-11-22 00:53:23 -05:00
Mike Frysinger 6cc9885631 sim: sh: delete global callback/argv
We can use the sim state everywhere now to get these values on the fly.
2015-11-22 00:53:23 -05:00
Mike Frysinger c1fc4b4d17 sim: h8300: delete global callback/kind/name
We can use the sim state everywhere now to get these values on the fly.
2015-11-22 00:53:23 -05:00
Mike Frysinger d320201dbe sim: mn10300: drop global callback handle
It's used in one place and can easily be replaced by using the sim state.
2015-11-22 00:53:23 -05:00
GDB Administrator 3559ed3fa4 Automatic date update in version.in 2015-11-22 00:00:07 +00:00
GDB Administrator 38d42a53a7 Automatic date update in version.in 2015-11-21 00:00:08 +00:00
Don Breazeal e084c964d6 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.
2015-11-20 09:45:44 -08:00
Maciej W. Rozycki 314cf376c5 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.
2015-11-20 16:17:53 +00:00
Maciej W. Rozycki f21cd97985 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.
2015-11-20 16:16:40 +00:00
Matthew Wahab 250aafa477 [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
2015-11-20 16:09:34 +00:00
Matthew Wahab 8c00185a1e Stop the ARM short mapping symbol test being run for the symbianelf target.
* gas/arm/mapshort-elf.d: Fix typo in exclusion list.
2015-11-20 15:53:41 +00:00
Stefan Teleman 0b1fa2880c 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.
2015-11-20 15:28:40 +00:00
Nick Clifton a915c10f7f 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.
2015-11-20 14:16:30 +00:00
Tristan Gingold 9b334a2ccd Fix missing update in previous patch.
bfd/
	* mach-o-x86-64.c (x86_64_howto_table): Change name here too.
2015-11-20 15:15:24 +01:00
Ronald Hoogenboom a4f8732b2a 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.
2015-11-20 14:08:29 +00:00
Tristan Gingold f075eb5e6b 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.
2015-11-20 14:53:06 +01:00
David Bridgham 11b8aeb881 Synchronize PDP11 page size between BFD and LD.
* pdp11.c (TARGET_PAGE_SIZE): Set to 256 to match definition in
	ld/emulparams/pdp11.sh.
2015-11-20 12:58:16 +00:00
Nick Clifton f8c2a96547 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.
2015-11-20 12:35:43 +00:00
Jose E. Marchesi bb0974456e 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.
2015-11-20 11:36:07 +01:00
Jose E. Marchesi 9c88ed8f11 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.
2015-11-20 10:48:56 +01:00
Sandra Loosemore 96161e2527 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.
2015-11-19 16:22:04 -08:00
GDB Administrator 7fcdc24df1 Automatic date update in version.in 2015-11-20 00:00:08 +00:00
Pedro Alves 06e03fff31 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.
2015-11-19 18:32:55 +00:00
Pedro Alves b35d5edb03 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.
2015-11-19 18:31:49 +00:00