binutils-gdb.git
9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 21 Sep 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agodwarf2_compute_name: add fixme, don't use same name as parameter for local
Doug Evans [Sun, 20 Sep 2015 21:13:54 +0000 (14:13 -0700)]
dwarf2_compute_name: add fixme, don't use same name as parameter for local

gdb/ChangeLog:

* dwarf2read.c (dwarf2_compute_name): Add FIXME.  Don't use a local
variable name that collides with a parameter.

9 years agocrash printing non-local variable from nested subprogram
Joel Brobecker [Tue, 1 Sep 2015 20:20:32 +0000 (22:20 +0200)]
crash printing non-local variable from nested subprogram

We have noticed that GDB would sometimes crash trying to print
from a nested function the value of a variable declared in an
enclosing scope. This appears to be target dependent, although
that correlation might only be fortuitious.  We noticed the issue
on x86_64-darwin, x86-vxworks6 and x86-solaris.  The investigation
was done on Darwin.

This is a new feature that was introduced by:

    commit 63e43d3aedb8b1112899c2d0ad74cbbee687e5d6
    Date:   Thu Feb 5 17:00:06 2015 +0100
    DWARF: handle non-local references in nested functions

We can reproduce the problem with one of the testcases that was
added with the patch (gdb.base/nested-subp1.exp), where we have...

    18 int
    19 foo (int i1)
    20 {
    21   int
    22   nested (int i2)
    23   {
    [...]
    27     return i1 * i2; /* STOP */
    28   }

...  After building the example program, and running until line 27,
try printing the value of "i1":

    % gdb gdb.base/nested-subp1
    (gdb) break foo.c:27
    (gdb) run
    Breakpoint 1, nested (i2=2) at /[...]/nested-subp1.c:27
    27          return i1 * i2; /* STOP */
    (gdb) p i1
    [1]    73090 segmentation fault  ../gdb -q gdb.base/nested-subp1

Ooops!

What happens is that, because the reference is non-local, we are trying
to follow the function's static link, which does...

    /* If we don't know how to compute FRAME's base address, don't give up:
       maybe the frame we are looking for is upper in the stace frame.  */
    if (framefunc != NULL
        && SYMBOL_BLOCK_OPS (framefunc)->get_frame_base != NULL
        && (SYMBOL_BLOCK_OPS (framefunc)->get_frame_base (framefunc, frame)
            == upper_frame_base))

... or, in other words, calls the get_frame_base "method" of
framefunc's struct symbol_block_ops data. This resolves to
the block_op_get_frame_base function.

Looking at the function's implementation, we see:

  struct dwarf2_locexpr_baton *dlbaton;
  [...]
  dlbaton = SYMBOL_LOCATION_BATON (framefunc);
  [...]
  result = dwarf2_evaluate_loc_desc (type, frame, start, length,
                                     dlbaton->per_cu);
                                     ^^^^^^^^^^^^^^^

Printing dlbaton->per_cu gives a value that seems fairly bogus for
a memory address (0x60). Because of it, dwarf2_evaluate_loc_desc
then crashes trying to dereference it.

What's different on Darwin compared to Linux is that the function's
frame base is encoded using the following form:

        .byte   0x40    # uleb128 0x40; (DW_AT_frame_base)
        .byte   0x6     # uleb128 0x6; (DW_FORM_data4)

... and so dwarf2_symbol_mark_computed ends up creating
a SYMBOL_LOCATION_BATON as a struct dwarf2_loclist_baton:

  if (attr_form_is_section_offset (attr)
      /* .debug_loc{,.dwo} may not exist at all, or the offset may be outside
         the section.  If so, fall through to the complaint in the
         other branch.  */
      && DW_UNSND (attr) < dwarf2_section_size (objfile, section))
    {
      struct dwarf2_loclist_baton *baton;
      [...]
      SYMBOL_LOCATION_BATON (sym) = baton;

However, if you look more closely at block_op_get_frame_base's
implementation, you'll notice that the function extracts the
symbol's SYMBOL_LOCATION_BATON as a dwarf2_locexpr_baton
(a DWARF _expression_ rather than a _location list_).
That's why we end up decoding the DLBATON improperly, and thus
pass a random dlbaton->per_cu when calling dwarf2_evaluate_loc_desc.

This works on x86_64-linux, because we indeed have the frame base
described using a different form:

        .uleb128 0x40   # (DW_AT_frame_base)
        .uleb128 0x18   # (DW_FORM_exprloc)

This patch fixes the issue by doing what we do for most (if not all)
other such methods: providing one implementation each for loc-list,
and loc-expr. Both implementations are nearly identical, so perhaps
we might later want to improve this. But this patch first tries to
fix the crash first, leaving the design issue for later.

gdb/ChangeLog:

        * dwarf2loc.c (locexpr_get_frame_base): Renames
        block_op_get_frame_base.
        (dwarf2_block_frame_base_locexpr_funcs): Replace reference to
        block_op_get_frame_base by reference to locexpr_get_frame_base.
        (loclist_get_frame_base): New function, near identical copy of
        locexpr_get_frame_base.
        (dwarf2_block_frame_base_loclist_funcs): Replace reference to
        block_op_get_frame_base by reference to loclist_get_frame_base.

Tested on x86_64-darwin (AdaCore testsuite), and x86_64-linux
(official testsuite).

9 years agoAdd --no-dynamic-linker option to ld, for static PIE use
Rich Felker [Sun, 20 Sep 2015 02:50:19 +0000 (12:20 +0930)]
Add --no-dynamic-linker option to ld, for static PIE use

Inhibits output of .interp section in ELF executables.

include/
* bfdlink.h (struct bfd_link_info): Add "nointerp" field.
bfd/
* elflink.c (_bfd_elf_link_create_dynamic_sections): Don't create
.interp when info->nointerp.
(bfd_elf_size_dynamic_sections): Adjust assert.
* elf32-arm.c (elf32_arm_size_dynamic_sections): Don't size .interp
when info->nointerp.
* elf32-bfin.c (elf32_bfinfdpic_size_dynamic_sections): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise.
* elf32-cris.c (elf_cris_size_dynamic_sections): Likewise.
* elf32-frv.c (elf32_frvfdpic_size_dynamic_sections): Likewise.
* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise.
* elf32-i370.c (i370_elf_size_dynamic_sections): Likewise.
* elf32-i386.c (elf_i386_size_dynamic_sections): Likewise.
* elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise.
* elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise.
* elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
* elf32-metag.c (elf_metag_size_dynamic_sections): Likewise.
* elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise.
* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise.
* elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise.
* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise.
* elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise.
* elf32-sh.c (sh_elf_size_dynamic_sections): Likewise.
* elf32-tic6x.c (elf32_tic6x_size_dynamic_sections): Likewise.
* elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise.
* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
* elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Likewise.
* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
* elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise.
* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise.
* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf64-sh64.c (sh64_elf64_size_dynamic_sections): Likewise.
* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Likewise.
* elfnn-ia64.c (elfNN_ia64_size_dynamic_sections): Likewise.
* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise.
* elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise.
ld/
* ld.texinfo (--no-dynamic-linker): Document.
* ldlex.h (enum option_values): Add OPTION_NO_DYNAMIC_LINKER.
* lexsup.c (ld_options, parse_args): Handle --no-dynamic-linker.

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 20 Sep 2015 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoReplace current_inferior ()->gdbarch with its wrapper target_gdbarch.
Doug Evans [Sat, 19 Sep 2015 15:29:58 +0000 (08:29 -0700)]
Replace current_inferior ()->gdbarch with its wrapper target_gdbarch.

gdb/ChangeLog:

* ravenscar-thread.c (ravenscar_inferior_created): Replace
current_inferior ()->gdbarch with its wrapper target_gdbarch.

9 years agolinux-thread-db.c (record_thread): Return the created thread.
Doug Evans [Sat, 19 Sep 2015 06:21:04 +0000 (23:21 -0700)]
linux-thread-db.c (record_thread): Return the created thread.

gdb/ChangeLog:

* linux-thread-db.c (record_thread): Return the created thread.
(thread_from_lwp): Likewise.
(thread_db_get_thread_local_address): Update.

9 years agosymtab.h (general_symbol_info) <mangled_lang>: delete and move up only member.
Doug Evans [Sat, 19 Sep 2015 05:30:22 +0000 (22:30 -0700)]
symtab.h (general_symbol_info) <mangled_lang>: delete and move up only member.

gdb/ChangeLog:

* symtab.h (general_symbol_info) <mangled_lang>: Delete struct,
move only member demangled_name up.  All uses updated.

9 years agodefault_read_var_value <LOC_UNRESOLVED>: Include minsym kind in error message.
Doug Evans [Sat, 19 Sep 2015 04:43:38 +0000 (21:43 -0700)]
default_read_var_value <LOC_UNRESOLVED>: Include minsym kind in error message.

bfd/ChangeLog:

* targets.c (enum bfd_flavour): Add comment.
(bfd_flavour_name): New function.
* bfd-in2.h: Regenerate.

gdb/ChangeLog:

* findvar.c (default_read_var_value) <LOC_UNRESOLVED>: Include the
kind of minimal symbol in the error message.
* objfiles.c (objfile_flavour_name): New function.
* objfiles.h (objfile_flavour_name): Declare.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-bad-unresolved.c: New file.
* gdb.dwarf2/dw2-bad-unresolved.exp: New file.

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

9 years agoFix directory prefix in gdb.base/dso2dso.exp.
Sandra Loosemore [Fri, 18 Sep 2015 19:21:06 +0000 (12:21 -0700)]
Fix directory prefix in gdb.base/dso2dso.exp.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.base/dso2dso.exp: Don't use directory prefix when setting
the breakpoint.

9 years agoFix pathname prefix and timeout issues in gdb.mi/mi-pending.exp.
Sandra Loosemore [Fri, 18 Sep 2015 18:52:26 +0000 (11:52 -0700)]
Fix pathname prefix and timeout issues in gdb.mi/mi-pending.exp.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.mi/mi-pending.exp: Don't use directory prefix when setting
the pending breakpoint.  Remove timeout override for "Run till
MI pending breakpoint on pendfunc3 on thread 2" test.

9 years agoGeneralize breakpoint pattern in gdb.mi/mi-cli.exp.
Sandra Loosemore [Fri, 18 Sep 2015 16:39:31 +0000 (09:39 -0700)]
Generalize breakpoint pattern in gdb.mi/mi-cli.exp.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.mi/mi-cli.exp: Don't require directory prefix in breakpoint
filename pattern.

9 years agoGeneralize filename pattern in gdb.mi/mi-dprintf-pending.exp.
Sandra Loosemore [Fri, 18 Sep 2015 16:22:02 +0000 (09:22 -0700)]
Generalize filename pattern in gdb.mi/mi-dprintf-pending.exp.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.mi/mi-dprintf-pending.exp: Don't require directory prefix
in breakpoint filename pattern.

9 years agoFix shared library load in gdb.base/global-var-nested-by-dso.exp.
Sandra Loosemore [Fri, 18 Sep 2015 16:05:37 +0000 (09:05 -0700)]
Fix shared library load in gdb.base/global-var-nested-by-dso.exp.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.base/global-var-nested-by-dso.exp: Call gdb_load_shlibs.

9 years agoRequire readline for gdb.linespec/explicit.exp tab-completion tests.
Sandra Loosemore [Fri, 18 Sep 2015 15:54:20 +0000 (08:54 -0700)]
Require readline for gdb.linespec/explicit.exp tab-completion tests.

2015-09-18  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.linespec/explicit.exp: Check for readline support for
tab-completion tests.  Fix obvious typo.

9 years agoaarch64 multi-arch (part 3): get thread area
Yao Qi [Fri, 18 Sep 2015 12:59:42 +0000 (13:59 +0100)]
aarch64 multi-arch (part 3): get thread area

With the kernle fix <http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/356511.html>,
aarch64 GDB is able to read the base of thread area of 32-bit arm
program through NT_ARM_TLS.

This patch is to teach both GDB and GDBserver to read the base of
thread area correctly in the multi-arch case.  A new function
aarch64_ps_get_thread_area is added, and is shared between GDB and
GDBserver.

With this patch applied, the following fails in multi-arch testing
(GDB is aarch64 but the test cases are arm) are fixed,

 -FAIL: gdb.threads/tls-nodebug.exp: thread local storage
 -FAIL: gdb.threads/tls-shared.exp: print thread local storage variable
 -FAIL: gdb.threads/tls-so_extern.exp: print thread local storage variable
 -FAIL: gdb.threads/tls-var.exp: print tls_var
 -FAIL: gdb.threads/tls.exp: first thread local storage
 -FAIL: gdb.threads/tls.exp: first another thread local storage
 -FAIL: gdb.threads/tls.exp: p a_thread_local
 -FAIL: gdb.threads/tls.exp: p file2_thread_local
 -FAIL: gdb.threads/tls.exp: p a_thread_local second time

gdb:

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

* nat/aarch64-linux.c: Include elf/common.h,
nat/gdb_ptrace.h, asm/ptrace.h and sys/uio.h.
(aarch64_ps_get_thread_area): New function.
* nat/aarch64-linux.h: Include gdb_proc_service.h.
(aarch64_ps_get_thread_area): Declare.
* aarch64-linux-nat.c (ps_get_thread_area): Call
aarch64_ps_get_thread_area.

gdb/gdbserver:

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

* linux-aarch64-low.c: Don't include sys/uio.h.
(ps_get_thread_area): Call aarch64_ps_get_thread_area.

9 years agobtrace: honour scheduler-locking for all-stop targets
Markus Metzger [Wed, 16 Sep 2015 07:05:22 +0000 (09:05 +0200)]
btrace: honour scheduler-locking for all-stop targets

In all-stop mode, record btrace maintains the old behaviour of an implicit
scheduler-locking on.

Now that we added a scheduler-locking mode to model this old behaviour, we
don't need the respective code in record btrace anymore.  Remove it.

For all-stop targets, step inferior_ptid and continue other threads matching
the argument ptid.  Assert that inferior_ptid matches the argument ptid.

This should make record btrace honour scheduler-locking.

gdb/
* record-btrace.c (record_btrace_resume): Honour scheduler-locking.

testsuite/
* gdb.btrace/multi-thread-step.exp: Test scheduler-locking on, step,
and replay.

9 years agoinfrun: scheduler-locking replay
Markus Metzger [Mon, 7 Sep 2015 13:41:00 +0000 (15:41 +0200)]
infrun: scheduler-locking replay

Record targets behave as if scheduler-locking were on in replay mode.  Add a
new scheduler-locking option "replay" to make this implicit behaviour explicit.
It behaves like "on" in replay mode and like "off" in record mode.

By making the current behaviour a scheduler-locking option, we allow the user
to change it.  Since it is the current behaviour, this new option is also
the new default.

One caveat is that when resuming a thread that is at the end of its execution
history, record btrace implicitly stops replaying other threads and resumes
the entire process.  This is a convenience feature to not require the user
to explicitly move all other threads to the end of their execution histories
before being able to resume the process.

We mimick this behaviour with scheduler-locking replay and move it from
record-btrace into infrun.  With all-stop on top of non-stop, we can't do
this in record-btrace anymore.

Record full does not really support multi-threading and is therefore not
impacted.  If it were extended to support multi-threading, it would 'benefit'
from this change.  The good thing is that all record targets will behave the
same with respect to scheduler-locking.

I put the code for this into clear_proceed_status.  It also sends the
about_to_proceed notification.

gdb/
* NEWS: Announce new scheduler-locking mode.
* infrun.c (schedlock_replay): New.
(scheduler_enums): Add schedlock_replay.
(scheduler_mode): Change default to schedlock_replay.
(user_visible_resume_ptid): Handle schedlock_replay.
(clear_proceed_status_thread): Stop replaying if resumed thread is
not replaying.
(schedlock_applies): Handle schedlock_replay.
(_initialize_infrun): Document new scheduler-locking mode.
* record-btrace.c (record_btrace_resume): Remove code to stop other
threads when not replaying the resumed thread.

doc/
* gdb.texinfo (All-Stop Mode): Describe new scheduler-locking mode.

9 years agotarget: add to_record_will_replay target method
Markus Metzger [Thu, 17 Sep 2015 09:14:55 +0000 (11:14 +0200)]
target: add to_record_will_replay target method

Add a new target method to_record_will_replay to query if there is a record
target that will replay at least one thread matching the argument PTID if it
were executed in the argument execution direction.

gdb/
* record-btrace.c ((record_btrace_will_replay): New.
(init_record_btrace_ops): Initialize to_record_will_replay.
* record-full.c ((record_full_will_replay): New.
(init_record_full_ops): Initialize to_record_will_replay.
* target-delegates.c: Regenerated.
* target.c (target_record_will_replay): New.
* target.h (struct target_ops) <to_record_will_replay>: New.
(target_record_will_replay): New.

Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
9 years agotarget: add to_record_stop_replaying target method
Markus Metzger [Tue, 8 Sep 2015 07:42:20 +0000 (09:42 +0200)]
target: add to_record_stop_replaying target method

Add a new target method to_record_stop_replaying to stop replaying.

gdb/
* record-btrace.c (record_btrace_resume): Call
target_record_stop_replaying.
(record_btrace_stop_replaying_all): New.
(init_record_btrace_ops): Initialize to_record_stop_replaying.
* record-full.c (record_full_stop_replaying): New.
(init_record_full_ops ): Initialize to_record_stop_replaying.
* target-delegates.c: Regenerated.
* target.c (target_record_stop_replaying): New.
* target.h (struct target_ops) <to_record_stop_replaying>: New.
(target_record_stop_replaying): New.

9 years agobtrace: allow full memory and register access for non-replaying threads
Markus Metzger [Tue, 8 Sep 2015 07:05:38 +0000 (09:05 +0200)]
btrace: allow full memory and register access for non-replaying threads

The record btrace target does not allow accessing memory and storing registers
while replaying.  For multi-threaded applications, this prevents those
accesses also for threads that are at the end of their execution history as
long as at least one thread is replaying.

Change this to only check if the selected thread is replaying.  This allows
threads that are at the end of their execution history to read and write
memory and to store registers.

Also change the error message to reflect this change.

gdb/
* record-btrace.c (record_btrace_xfer_partial)
(record_btrace_store_registers, record_btrace_prepare_to_store):
Call record_btrace_is_replaying with inferior_ptid instead of
minus_one_ptid.
(record_btrace_store_registers): Change error message.

9 years agotarget, record: add PTID argument to to_record_is_replaying
Markus Metzger [Tue, 8 Sep 2015 06:26:16 +0000 (08:26 +0200)]
target, record: add PTID argument to to_record_is_replaying

The to_record_is_replaying target method is used to query record targets if
they are replaying.  This is currently interpreted as "is any thread being
replayed".

Add a PTID argument and change the interpretation to "is any thread matching
PTID being replayed".

Change all users to pass minus_one_ptid to preserve the old meaning.

The record full target does not really support multi-threading and ignores
the PTID argument.

gdb/
* record-btrace.c (record_btrace_is_replaying): Add ptid argument.
Update users to pass minus_one_ptid.
* record-full.c (record_full_is_replaying): Add ptid argument (ignored).
* record.c (cmd_record_delete): Pass inferior_ptid to
target_record_is_replaying.
* target-delegates.c: Regenerated.
* target.c (target_record_is_replaying): Add ptid argument.
* target.h (struct target_ops) <to_record_is_replaying>: Add ptid
argument.
(target_record_is_replaying): Add ptid argument.

9 years agobtrace: non-stop
Markus Metzger [Wed, 26 Aug 2015 09:33:07 +0000 (11:33 +0200)]
btrace: non-stop

Support non-stop mode in record btrace.

gdb/
* record-btrace.c (record_btrace_open): Remove non_stop check.
* NEWS: Announce that record btrace supports non-stop mode.

testsuite/
* gdb.btrace/non-stop.c: New.
* gdb.btrace/non-stop.exp: New.

9 years agoinfrun: switch to NO_HISTORY thread
Markus Metzger [Mon, 7 Sep 2015 08:00:46 +0000 (10:00 +0200)]
infrun: switch to NO_HISTORY thread

A thread that runs out of its execution history is stopped.  We already set
stop_pc and call stop_waiting.  But we do not switch to the stopped thread.

In normal_stop, we call finish_thread_state_cleanup to set a thread's running
state.  In all-stop mode, we call it with minus_one_ptid; in non-stop mode, we
only call it for inferior_ptid.

If in non-stop mode normal_stop is called on behalf of a thread that is not
inferior_ptid, that other thread will still be reported as running.  If it is
actually stopped it can't be resumed again.

Record targets traditionally don't support non-stop and only resume
inferior_ptid.  So this has not been a problem, so far.

Switch to the eventing thread for NO_HISTORY events as preparation to support
non-stop for the record btrace target.

gdb/
* infrun.c (handle_inferior_event_1): Switch to the eventing thread
in the TARKET_WAITKIND_NO_HISTORY case.

9 years agobtrace: async
Markus Metzger [Thu, 27 Aug 2015 14:24:38 +0000 (16:24 +0200)]
btrace: async

The record btrace target runs synchronous with GDB.  That is, GDB steps
resumed threads in record btrace's to_wait method.  Without GDB calling
to_wait, nothing happens 'on the target'.

Check for further expected events in to_wait before reporting the current
event and mark record btrace's async event handler in async mode.

gdb/
* record-btrace.c (record_btrace_maybe_mark_async_event): New.
(record_btrace_wait): Call record_btrace_maybe_mark_async_event.

9 years agobtrace: temporarily set inferior_ptid in record_btrace_start_replaying
Markus Metzger [Wed, 26 Aug 2015 13:37:55 +0000 (15:37 +0200)]
btrace: temporarily set inferior_ptid in record_btrace_start_replaying

Get_current_frame uses inferior_ptid.  In record_btrace_start_replaying,
we need to get the current frame of the argument thread.  So far, this
has always been inferior_ptid.  With non-stop, this is not guaranteed.

Temporarily set inferior_ptid to the ptid of the argument thread.

We already temporarily set the argument thread's executing flag to false.

Move both into a new function get_thread_current_frame that does the temporary
adjustments, calls get_current_frame, and restores the previous values.

gdb/
* record-btrace.c (get_thread_current_frame): New.
(record_btrace_start_replaying): Call get_thread_current_frame.

9 years agobtrace: resume all requested threads
Markus Metzger [Tue, 25 Aug 2015 11:42:39 +0000 (13:42 +0200)]
btrace: resume all requested threads

The record targets are implicitly schedlocked.  They only step the current
thread and keep other threads where they are.

Change record btrace to step all requested threads in to_resume.

For maintenance and debugging, we keep the old behaviour when the target below
is not non-stop.  Enable with "maint set target-non-stop on".

gdb/
* record-btrace.c (record_btrace_resume_thread): A move request
overwrites a previous move request.
(record_btrace_find_resume_thread): Removed.
(record_btrace_resume): Resume all requested threads.

9 years agobtrace: lock-step
Markus Metzger [Mon, 24 Aug 2015 14:28:06 +0000 (16:28 +0200)]
btrace: lock-step

Record btrace's to_wait method picks a single thread to step.  When passed
minus_one_ptid, it picks the current thread.  All other threads remain where
they are.

Change this to step all resumed threads together, one step at a time, until
the first thread reports an event.

We do delay reporting NO_HISTORY events until there are no other events to
report to prevent threads at the end of their execution history from starving
other threads.

We keep threads at the end of their execution history moving and replaying
until we announce their stop in to_wait.  This shouldn't really be user-visible
but its a detail worth mentioning.

Since record btrace's to_resume method also picks only a single thread to
resume, there shouldn't be a difference with the current all-stop.

With non-stop or all-stop on top of non-stop, we will see differences.  The
behaviour should be more natural as we're moving all threads.

gdb/
* record-btrace.c: Include vec.h.
(record_btrace_find_thread_to_move): Removed.
(btrace_step_no_resumed, btrace_step_again)
(record_btrace_stop_replaying_at_end): New.
(record_btrace_cancel_resume): Call record_btrace_stop_replaying_at_end.
(record_btrace_single_step_forward): Remove calls to
record_btrace_stop_replaying.
(record_btrace_step_thread): Do only one step for BTHR_CONT and
BTHR_RCONT.  Keep threads at the end of their history moving.
(record_btrace_wait): Call record_btrace_step_thread for all threads
until one reports an event.  Call record_btrace_stop_replaying_at_end
for the eventing thread.

9 years agobtrace: add missing NO_HISTORY
Markus Metzger [Fri, 4 Sep 2015 08:33:05 +0000 (10:33 +0200)]
btrace: add missing NO_HISTORY

If a single-step ended right at the end of the execution history, we forgot
to announce that.  Fix it.

gdb/
* record-btrace.c (record_btrace_single_step_forward): Return
NO_HISTORY if a step brings us to the end of the execution history.

9 years agobtrace: move breakpoint checking into stepping functions
Markus Metzger [Mon, 24 Aug 2015 13:55:02 +0000 (15:55 +0200)]
btrace: move breakpoint checking into stepping functions

Breakpoints are only checked for BTHR_CONT and BTHR_RCONT stepping requests.
A BTHR_STEP and BTHR_RSTEP request will always report stopped without reason.
Since breakpoints are reported correctly, I assume infrun is handling this.

Move the breakpoint check into the btrace single stepping functions.  This
will cause us to report breakpoint hits now also for single-step requests.

One thing to notice is that

  - when executing forwards, the breakpoint is checked before 'executing'
    the instruction, i.e. before moving the PC to the next instruction.

  - when executing backwards,  the breakpoint is checked after 'executing'
    the instruction, i.e. after moving the PC to the preceding instruction
    in the recorded execution.

There is code in infrun (see, for example proceed and adjust_pc_after_break)
that handles this and also depends on this behaviour.

gdb/
* record-btrace.c (record_btrace_step_thread): Move breakpoint check
to ...
(record_btrace_single_step_forward): ... here and
(record_btrace_single_step_backward): ... here.

9 years agobtrace: split record_btrace_step_thread
Markus Metzger [Mon, 24 Aug 2015 12:49:43 +0000 (14:49 +0200)]
btrace: split record_btrace_step_thread

The code for BTHR_STEP and BTHR_CONT is fairly similar.  Extract the common
parts into a new function record_btrace_single_step_forward.  The function
returns TARGET_WAITKIND_SPURIOUS to indicate that the single-step completed
without triggering a trap.

Same for BTHR_RSTEP and BTHR_RCONT.

gdb/
* record-btrace.c (btrace_step_spurious)
(record_btrace_single_step_forward)
(record_btrace_single_step_backward): New.
(record_btrace_step_thread): Call record_btrace_single_step_forward
and record_btrace_single_step_backward.

9 years agobtrace: extract the breakpoint check from record_btrace_step_thread
Markus Metzger [Tue, 25 Aug 2015 08:49:11 +0000 (10:49 +0200)]
btrace: extract the breakpoint check from record_btrace_step_thread

There are two places where record_btrace_step_thread checks for a breakpoint
at the current replay position.  Move this code into its own function.

gdb/
* record-btrace.c (record_btrace_replay_at_breakpoint): New.
(record_btrace_step_thread): Call record_btrace_replay_at_breakpoint.

9 years agobtrace: improve stepping debugging
Markus Metzger [Mon, 24 Aug 2015 11:34:57 +0000 (13:34 +0200)]
btrace: improve stepping debugging

gdb/
* record-btrace.c (btrace_thread_flag_to_str)
(record_btrace_cancel_resume): New.
(record_btrace_step_thread): Call btrace_thread_flag_to_str.
(record_btrace_resume): Print execution direction.
(record_btrace_resume_thread): Call btrace_thread_flag_to_str.
(record_btrace_wait): Call record_btrace_cancel_resume.

9 years agobtrace: support to_stop
Markus Metzger [Wed, 19 Aug 2015 11:35:52 +0000 (13:35 +0200)]
btrace: support to_stop

Add support for the to_stop target method to the btrace record target.

gdb/
* btrace.h (enum btrace_thread_flag) <BTHR_STOP>: New.
* record-btrace (record_btrace_resume_thread): Clear BTHR_STOP.
(record_btrace_find_thread_to_move): Also accept threads that have
BTHR_STOP set.
(btrace_step_stopped_on_request, record_btrace_stop): New.
(record_btrace_step_thread): Support BTHR_STOP.
(record_btrace_wait): Also clear BTHR_STOP when stopping other threads.
(init_record_btrace_ops): Initialize to_stop.

9 years agobtrace: fix non-stop check in to_wait
Markus Metzger [Tue, 8 Sep 2015 14:13:47 +0000 (16:13 +0200)]
btrace: fix non-stop check in to_wait

The record btrace target stops other threads in non-stop mode after stepping
the to-be-resumed thread.

The check is done on the non_stop variable.  It should rather be done on
target_is_non_stop_p ().  With all-stop on top of non-stop, infrun will
take care of stopping other threads.

gdb/
* record-btrace.c (record_btrace_wait): Replace non_stop check with
target_is_non_stop_p ().

9 years agoAdd missing PowerPC64 ld --save-restore-funcs doc
Alan Modra [Fri, 18 Sep 2015 05:21:50 +0000 (14:51 +0930)]
Add missing PowerPC64 ld --save-restore-funcs doc

* ld.texinfo: Document --{no-,}save-restore-funcs.

9 years agoAdd PowerPC64 ld --tls-get-addr-optimize.
Alan Modra [Fri, 18 Sep 2015 06:47:49 +0000 (16:17 +0930)]
Add PowerPC64 ld --tls-get-addr-optimize.

Sometimes it may be of benefit to force use of the __tls_get_addr_opt
call stub even when the glibc being used during linking does not
advertise __tls_get_addr_opt.

bfd/
* elf64-ppc.h (struct ppc64_elf_params <tls_get_addr_opt>): Rename
from no_tls_get_addr_opt.
* elf64-ppc.c: Update for rename and inversion of tls_get_addr_opt.
(ppc64_elf_tls_setup): Set tls_get_addr_opt to 0 only when at
default of -1.
ld/
* emultempl/ppc64elf.em (params): Init tls_get_addr_opt field to -1.
(OPTION_TLS_GET_ADDR_OPT): Define.
(PARSE_AND_LIST_LONGOPTS): Handle --tls-get-addr-opt.
(PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Likewise.
* ld.texinfo: Document --tls-get-addr-optimize and
--no-tls-get-addr-optimize.

9 years agoDelay converting linker script defined symbols from absolute
Alan Modra [Thu, 17 Sep 2015 23:44:25 +0000 (09:14 +0930)]
Delay converting linker script defined symbols from absolute

Giving linker script symbols defined outside of output sections a
section-relative value early, leads to them being used in expressions
as if they were defined inside an output section.  This can mean loss
of the section VMA, and wrong results.

ld/
PR ld/18963
* ldexp.h (struct ldexp_control): Add rel_from_abs.
(ldexp_finalize_syms): Declare.
* ldexp.c (new_rel_from_abs): Keep absolute for expressions
outside of output section statements.  Set rel_from_abs.
(make_abs, exp_fold_tree, exp_fold_tree_no_dot): Clear rel_from_abs.
(struct definedness_hash_entry): Add final_sec, and comment.
(update_definedness): Set final_sec.
(set_sym_sections, ldexp_finalize_syms): New functions.
* ldlang.c (lang_process): Call ldexp_finalize_syms.
ld/testsuite
PR ld/18963
* ld-scripts/pr18963.d,
* ld-scripts/pr18963.t: New test.
* ld-scripts/expr.exp: Run it.
* ld-elf/provide-hidden-2.ld: Explicitly make "dot" absolute.
* ld-mips-elf/gp-hidden.sd: Don't care about _gp section.
* ld-mips-elf/no-shared-1-n32.d: Don't care about symbol shown at
start of .data section.
* ld-mips-elf/no-shared-1-n64.d: Likewise.
* ld-mips-elf/no-shared-1-o32.d: Likewise.

9 years agoRemove one unnecessary iteration in insertion sort
Alan Modra [Thu, 17 Sep 2015 03:23:29 +0000 (12:53 +0930)]
Remove one unnecessary iteration in insertion sort

PR 18867
* elflink.c (elf_link_adjust_relocs): Correct start of insertion
sort main loop.

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

9 years agoAdd test case for tracepoints with conditions
Pierre Langlois [Thu, 17 Sep 2015 10:39:10 +0000 (11:39 +0100)]
Add test case for tracepoints with conditions

This patch adds a test case for tracepoints with a condition expression.
Each case will test a condition against the number of frames that should
have been traced.  Some of these tests fail on x86_64 and others on
i386, which have been marked as known failures for now, see PR/18955.

gdb/testsuite/ChangeLog:

2015-09-17  Pierre Langlois  <pierre.langlois@arm.com>
    Yao Qi  <yao.qi@linaro.org>

* gdb.trace/trace-condition.c: New file.
* gdb.trace/trace-condition.exp: New file.

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

9 years agoFix argument to compiled_cond, and add cases for compiled-condition.
Wei-cheng Wang [Wed, 16 Sep 2015 15:20:51 +0000 (16:20 +0100)]
Fix argument to compiled_cond, and add cases for compiled-condition.

This patch fixes the argument passed to compiled_cond.  It should be
regs buffer instead of tracepoint_hit_ctx.  Test case is added as
well for testing compiled-cond.

gdb/gdbserver/ChangeLog

2015-09-16  Wei-cheng Wang  <cole945@gmail.com>

* tracepoint.c (eval_result_type): Change prototype.
(condition_true_at_tracepoint): Fix argument to compiled_cond.

gdb/testsuite/ChangeLog

2015-09-16  Wei-cheng Wang  <cole945@gmail.com>

* gdb.trace/ftrace.exp: (test_ftrace_condition) New function
for testing bytecode compilation.

9 years agonon-stop-fair-events.exp slower on software single-step && !displ-step targets
Pedro Alves [Wed, 16 Sep 2015 14:51:36 +0000 (15:51 +0100)]
non-stop-fair-events.exp slower on software single-step && !displ-step targets

On software single-step targets that don't support displaced stepping,
threads keep hitting each other's single-step breakpoints, and then
GDB needs to pause all threads to step past those.  The end result is
that progress in the main thread will be slower and it may take a bit
longer for the signal to be queued.  This patch bumps the timeout on
such targets.

gdb/testsuite/ChangeLog:
2015-09-16  Pedro Alves  <palves@redhat.com>
    Sandra Loosemore <sandra@codesourcery.com>

* gdb.threads/non-stop-fair-events.c (timeout): New global.
(SECONDS): Redefine.
(main): Call pthread_kill and alarm early.
* gdb.threads/non-stop-fair-events.exp: Probe displaced stepping
support.
(test): If the target can't hardware step and doesn't support
displaced stepping, increase the timeout.

9 years agoMake it easier to debug non-stop-fair-events.exp
Pedro Alves [Wed, 16 Sep 2015 14:51:36 +0000 (15:51 +0100)]
Make it easier to debug non-stop-fair-events.exp

If we enable infrun debug running this test, it quickly fails with a
full expect buffer.  That can be simply handled with a couple
exp_continues.  As it's annoying to hack this every time we need to
debug the test, this patch adds bits to enable debugging support
easily, with a one-line change.

And then, if any iteration of the test fails, we end up with a long
cascade of time outs.  Just bail out when we see the first fail.

gdb/testsuite/
2015-09-16  Pedro Alves  <palves@redhat.com>

* gdb.threads/non-stop-fair-events.exp (gdb_test_no_anchor)
(enable_debug): New procedures.
(test): Use them.  Bail out if waiting for threads fails.
(top level): Bail out if a test fails.

9 years agoDon't skip gdb.asm/asm-source.exp on aarch64
Yao Qi [Wed, 16 Sep 2015 14:13:29 +0000 (15:13 +0100)]
Don't skip gdb.asm/asm-source.exp on aarch64

This patch adds gdb.asm/aarch64.inc, so asm-source.exp isn't skipped
on aarch64 any more.

gdb/testsuite:

2015-09-16  Yao Qi  <yao.qi@linaro.org>

* gdb.asm/asm-source.exp: Set asm-arch for
aarch64*-*-* target.
* gdb.asm/aarch64.inc: New file.

9 years agoFix slowdown in ld -r for most common case of out-of-order relocs
Alan Modra [Wed, 16 Sep 2015 08:37:03 +0000 (18:07 +0930)]
Fix slowdown in ld -r for most common case of out-of-order relocs

I chose insertion sort since relocs are mostly sorted, but there is a
common case we can handle better;  A run of relocs put out of order
due to not linking input files in order.

PR 18867
* elflink.c (elf_link_adjust_relocs): Modify insertion sort to
insert a run.  Return status in case of malloc failure.
Adjust callers.

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 16 Sep 2015 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years ago[Ada] Enhance type printing for arrays with variable-sized elements
Pierre-Marie de Rodat [Tue, 15 Sep 2015 09:56:03 +0000 (11:56 +0200)]
[Ada] Enhance type printing for arrays with variable-sized elements

This change is relevant only for standard DWARF (as opposed to the GNAT
encodings extensions): at the time of writing it only makes a difference
with GCC patches that are to be integrated: see the patch series
submission at
<https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01353.html>.

Given the following Ada declarations:

   subtype Small_Int is Natural range 0 .. 100;
   type R_Type (L : Small_Int := 0) is record
      S : String (1 .. L);
   end record;
   type A_Type is array (Natural range <>) of R_Type;

   A : A_Type := (1 => (L => 0, S => ""),
                  2 => (L => 2, S => "ab"));

Before this change, we would get the following GDB session:

    (gdb) ptype a
    type = array (1 .. 2) of foo.r_type <packed: 838-bit elements>

This is wrong: "a" is not a packed array.  This output comes from the
fact that, because R_Type has a dynamic size (with a maximum), the
compiler has to describe in the debugging information the size allocated
for each array element (i.e. the stride, in DWARF parlance: see
DW_AT_byte_stride).  Ada type printing currently assumes that arrays
with a stride are packed, hence the above output.

In practice, GNAT never performs bit-packing for arrays that contain
variable-sized elements.  Leveraging this fact, this patch enhances type
printing so that ptype does not pretend that arrays are packed when they
have a stride and they contain dynamic elements.  After this change, we
get the following expected output:

    (gdb) ptype a
    type = array (1 .. 2) of foo.r_type

gdb/ChangeLog:

* ada-typeprint.c (print_array_type): Do not describe arrays as
packed when they embed dynamic elements.

gdb/testsuite/ChangeLog:

* gdb.ada/array_of_variable_length.exp: New testcase.
* gdb.ada/array_of_variable_length/foo.adb: New file.
* gdb.ada/array_of_variable_length/pck.adb: New file.
* gdb.ada/array_of_variable_length/pck.ads: New file.

Tested on x86_64-linux, no regression.

9 years agoHandle clang naming of function static local variable.
Doug Evans [Tue, 15 Sep 2015 20:21:28 +0000 (13:21 -0700)]
Handle clang naming of function static local variable.

clang names the local variable t_structs_a.buf.

gdb/testsuite/ChangeLog:

* gdb.base/callfuncs.exp (do_function_calls): Handle clang naming
of function static local variable.

9 years agoxtensa: generate PLT entries for call0 ABI
Max Filippov [Tue, 15 Sep 2015 03:37:14 +0000 (06:37 +0300)]
xtensa: generate PLT entries for call0 ABI

2015-09-15  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (elf_xtensa_be_plt_entry)
(elf_xtensa_le_plt_entry): Emit 'entry' instruction only for
windowed ABI.
(elf_xtensa_create_plt_entry): Generate 'l32r' offsets and fix
up instructions according to ABI.

9 years agoFix PR/18564 - regression in showing __thread so extern variable
Philippe Waroquiers [Tue, 15 Sep 2015 19:02:15 +0000 (21:02 +0200)]
Fix PR/18564 - regression in showing __thread so extern variable

Ensure tls variable address is not relocated, as the msym addr
is an offset in the thread local storage of the shared library/object.

9 years agogdb/doc: revert previous vforkdone change
Pedro Alves [Tue, 15 Sep 2015 18:29:37 +0000 (19:29 +0100)]
gdb/doc: revert previous vforkdone change

The previous manual change was wrong.  The vfork parent thread ID
should be reported with the usual "thread" magic register:

   Sending packet: $vCont;c:p7260.7260#1e...Packet received: OK
 -   Notification received: Stop:T05vforkdone:;
 +   Notification received: Stop:T05vforkdone:;thread:p7260.7260
                                               ^^^^^^^^^^^^^^^^^

This is already how the parent is reported in the vfork/fork events,
and is actually what the fix made gdbserver do.  Following the
documentation change, the event would have been reported like this
instead:

    Notification received: Stop:T05vforkdone:p7260.7260

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

PR remote/18965
* gdb.texinfo (Stop Reply Packets): Revert previous change to
the vforkdone description.

9 years ago[AArch64] Use debug_printf instead of fprintf_unfiltered
Pierre Langlois [Tue, 15 Sep 2015 17:38:57 +0000 (18:38 +0100)]
[AArch64] Use debug_printf instead of fprintf_unfiltered

GDBserver uses debug_printf to print debugging output.  This patch makes
GDB use this too so we can share some of this code with GDBserver later.

gdb/ChangeLog:

* aarch64-tdep.c (decode_add_sub_imm): Use debug_printf.
(decode_adrp): Likewise.
(decode_b): Likewise.
(decode_bcond): Likewise.
(decode_br): Likewise.
(decode_cb): Likewise.
(decode_eret): Likewise.
(decode_movz): Likewise.
(decode_orr_shifted_register_x): Likewise.
(decode_ret): Likewise.
(decode_stp_offset): Likewise.
(decode_stp_offset_wb): Likewise.
(decode_stur): Likewise.
(decode_tb): Likewise.
(aarch64_analyze_prologue): Likewise.
(pass_in_x): Likewise.
(pass_in_v): Likewise.
(pass_on_stack): Likewise.
(aarch64_push_dummy_call): Likewise.
(aarch64_extract_return_value): Likewise.
(aarch64_store_return_value): Likewise.
(aarch64_return_value): Likewise.
(aarch64_record_asimd_load_store): Likewise.
(aarch64_record_load_store): Likewise.
(aarch64_record_data_proc_simd_fp): Likewise.

9 years ago[ppc64le] Use skip_entrypoint for skip_trampoline_code
Jan Kratochvil [Tue, 15 Sep 2015 17:08:04 +0000 (19:08 +0200)]
[ppc64le] Use skip_entrypoint for skip_trampoline_code

ppc64le loses control when stepping between two PLT-called functions inside
a shared library:

29        shlib_second (); /* first-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: first-hit
step^M
^M
Program received signal SIGABRT, Aborted.^M
0x00003fffb7cbe578 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56^M
56        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);^M
(gdb) FAIL: gdb.base/solib-intra-step.exp: second-hit
->
29        shlib_second (); /* first-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: first-hit
step^M
shlib_second () at ./gdb.base/solib-intra-step-lib.c:23^M
23        abort (); /* second-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: second-hit

This is because gdbarch_skip_trampoline_code() will resolve the final function
as shlib_second+0 and place there the breakpoint, but ld.so will jump after
the breakpoint - at shlib_second+8 - as it is ELFv2 local symbol optimization:

Dump of assembler code for function shlib_second:
   0x0000000000000804 <+0>:     addis   r2,r12,2
   0x0000000000000808 <+4>:     addi    r2,r2,30668
   0x000000000000080c <+8>:     mflr    r0

Currently gdbarch_skip_entrypoint() has been called in skip_prologue_sal() and
fill_in_stop_func() but that is not enough.  I believe
gdbarch_skip_entrypoint() should be called after every
gdbarch_skip_trampoline_code().

gdb/ChangeLog
2015-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

* linespec.c (minsym_found): Call gdbarch_skip_entrypoint.
* ppc64-tdep.c (ppc64_skip_trampoline_code): Rename to ...
(ppc64_skip_trampoline_code_1): ... here.
(ppc64_skip_trampoline_code): New wrapper function.
* symtab.c (find_function_start_sal): Call gdbarch_skip_entrypoint.

gdb/testsuite/ChangeLog
2015-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.opt/solib-intra-step-lib.c: New file.
* gdb.opt/solib-intra-step-main.c: New file.
* gdb.opt/solib-intra-step.exp: New file.

9 years agogdbserver: Fix exec stop reply reporting conditions
Pedro Alves [Tue, 15 Sep 2015 16:38:05 +0000 (17:38 +0100)]
gdbserver: Fix exec stop reply reporting conditions

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

* remote-utils.c (prepare_resume_reply) <TARGET_WAITKIND_EXECD>:
Check whether to report exec events instead of checking whether
multiprocess is enabled.

9 years agoMove ChangeLog entry to proper place
Pedro Alves [Tue, 15 Sep 2015 16:35:21 +0000 (17:35 +0100)]
Move ChangeLog entry to proper place

gdb/ChangeLog -> gdb/gdbserver/ChangeLog

2015-09-15  Pedro Alves  <palves@redhat.com>

PR remote/18965
* remote-utils.c (prepare_resume_reply): Merge
TARGET_WAITKIND_VFORK_DONE switch case with the
TARGET_WAITKIND_FORKED case.

9 years agoPR remote/18965: vforkdone stop reply should indicate parent PID
Pedro Alves [Tue, 15 Sep 2015 16:32:45 +0000 (17:32 +0100)]
PR remote/18965: vforkdone stop reply should indicate parent PID

The vforkdone stop reply misses indicating the thread ID of the vfork
parent which the event relates to:

 @cindex vfork events, remote reply
 @item vfork
 The packet indicates that @code{vfork} was called, and @var{r}
 is the thread ID of the new child process. Refer to
 @ref{thread-id syntax} for the format of the @var{thread-id}
 field.  This packet is only applicable to targets that support
 vfork events.

 @cindex vforkdone events, remote reply
 @item vforkdone
 The packet indicates that a child process created by a vfork
 has either called @code{exec} or terminated, so that the
 address spaces of the parent and child process are no longer
 shared. The @var{r} part is ignored.  This packet is only
 applicable to targets that support vforkdone events.

Unfortunately, this is not just a documentation issue.  GDBserver
is really not specifying the thread ID.  I noticed because
in non-stop mode, gdb complains:

 [Thread 6089.6089] #1 stopped.
 #0  0x0000003615a011f0 in ?? ()
 0x0000003615a011f0 in ?? ()
 (gdb) set debug remote 1
 (gdb) c
 Continuing.
 Sending packet: $QPassSignals:e;10;14;17;1a;1b;1c;21;24;25;2c;4c;#5f...Packet received: OK
 Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK
   Notification received: Stop:T05vfork:p17ce.17ce;06:40d7ffffff7f0000;07:30d7ffffff7f0000;10:e4c9eb1536000000;thread:p17c9.17c9;core:2;
 Sending packet: $vStopped#55...Packet received: OK
 Sending packet: $D;17ce#af...Packet received: OK
 Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK
   Notification received: Stop:T05vforkdone:;
 No process or thread specified in stop reply: T05vforkdone:;
 (gdb)

This is not non-stop-mode-specific, however.  Consider e.g., that in
all-stop, you may be debugging more than one process at the same time.
You continue, and both processes vfork.  So when you next get a
T05vforkdone, there's no way to tell which of the parent processes is
done with the vfork.

Tests will be added later.

Tested on x86_64 Fedora 20.

gdb/ChangeLog:
2015-09-15  Pedro Alves  <palves@redhat.com>

PR remote/18965
* remote-utils.c (prepare_resume_reply): Merge
TARGET_WAITKIND_VFORK_DONE switch case with the
TARGET_WAITKIND_FORKED case.

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

PR remote/18965
* gdb.texinfo (Stop Reply Packets): Explain that vforkdone's 'r'
part indicates the thread ID of the parent process.

9 years agoFix typo
Yao Qi [Tue, 15 Sep 2015 16:29:22 +0000 (17:29 +0100)]
Fix typo

gdb/gdbserver:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* server.c (handle_query): Check string comparison using
"else if" instead of "if".

9 years agoFix gdb.threads/non-ldr-exc-3.exp race
Pedro Alves [Tue, 15 Sep 2015 16:01:59 +0000 (17:01 +0100)]
Fix gdb.threads/non-ldr-exc-3.exp race

gdb.threads/non-ldr-exc-3.exp is sometimes failing like this:

 [Switching to Thread 6831.6832]

 Breakpoint 2, thread_execler (arg=0x0) at /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/non-ldr-exc-3.c:41
 41        if (execl (image, image, argv1, NULL) == -1) /* break-here */
 PASS: gdb.threads/non-ldr-exc-3.exp: lock-sched=on,non-stop=off: continue to breakpoint
 (gdb) set scheduler-locking on
 (gdb) FAIL: gdb.threads/non-ldr-exc-3.exp: lock-sched=on,non-stop=off: set scheduler-locking on

The problem is that the gdb_test_multiple is missing the prompt
anchor.  The problem was introduced by 2fd33e9448.  This reverts the
hunk that introduced the problem, reverting back to
gdb_continue_to_breakpoint.

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

* gdb.threads/non-ldr-exc-3.exp (do_test): Use
gdb_continue_to_breakpoint instead of gdb_test_multiple.

9 years agoSupport single step by arch or target
Yao Qi [Tue, 15 Sep 2015 13:09:18 +0000 (14:09 +0100)]
Support single step by arch or target

Nowadays, GDB only knows whether architecture supports hardware single
step or software single step (through gdbarch hook software_single_step),
and for a given instruction or instruction sequence, GDB knows how to
do single step (hardware or software).  However, GDB doesn't know whether
the target supports hardware single step.  It is possible that the
architecture doesn't support hardware single step, such as arm, but
the target supports, such as simulator.  This was discussed in this
thread https://www.sourceware.org/ml/gdb/2009-12/msg00033.html before.

I encounter this problem for aarch64 multi-arch support.  When aarch64
debugs arm program, gdbarch is arm, so software single step is still
used.  However, the underneath linux kernel does support hardware
single step, so IWBN to use it.

This patch is to add a new target_ops hook to_can_do_single_step, and
only use it in arm_linux_software_single_step to decide whether or not
to use hardware single step.  On the native aarch64 linux target, 1 is
returned.  On other targets, -1 is returned.  On the remote target, if
the target supports s and S actions in the vCont? reply, then target
can do single step.  However,  old GDBserver will send s and S in the
reply to vCont?, which will confuse new GDB.  For example, old GDBserver
on arm-linux will send s and S in the reply to vCont?, but it doesn't
support hardware single step.  On the other hand, new GDBserver, on
arm-linux for example, will not send s and S in the reply to vCont?,
but old GDB thinks it doesn't support vCont packet at all.  In order
to address this problem, I add a new qSupported feature vContSupported,
which indicates GDB wants to know the supported actions in the reply
to vCont?, and qSupported response contains vContSupported if the
stub is able tell supported vCont actions in the reply of vCont?.

If the patched GDB talks with patched GDBserver on x86, the RSP traffic
is like this:

 -> $qSupported:...+;vContSupported+
 <- ...+;vContSupported+
 ...
 -> $vCont?
 <- vCont;c;C;t;s;S;r

then, GDB knows the stub can do single step, and may stop using software
single step even the architecture doesn't support hardware single step.

If the patched GDB talks with patched GDBserver on arm, the last vCont?
reply will become:

 <- vCont;c;C;t

GDB thinks the target doesn't support single step, so it will use software
single step.

If the patched GDB talks with unpatched GDBserver, the RSP traffic is like
this:

 -> $qSupported:...+;vContSupported+
 <- ...+
 ...
 -> $vCont?
 <- vCont;c;C;t;s;S;r

although GDBserver returns s and S, GDB still thinks GDBserver may not
support single step because it doesn't support vContSupported.

If the unpatched GDB talks with patched GDBserver on x86, the RSP traffic
is like:

 -> $qSupported:...+;
 <- ...+;vContSupported+
 ...
 -> $vCont?
 <- vCont;c;C;t;s;S;r

Since GDB doesn't sent vContSupported in the qSupported feature, GDBserver
sends s and S regardless of the support of hardware single step.

gdb:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (aarch64_linux_can_do_single_step): New
function.
(_initialize_aarch64_linux_nat): Install it to to_can_do_single_step.
* arm-linux-tdep.c (arm_linux_software_single_step): Return 0
if target_can_do_single_step returns 1.
* remote.c (struct vCont_action_support) <s, S>: New fields.
(PACKET_vContSupported): New enum.
(remote_protocol_features): New element for vContSupported.
(remote_query_supported): Append "vContSupported+".
(remote_vcont_probe): Remove support_s and support_S, use
rs->supports_vCont.s and rs->supports_vCont.S instead.  Disable
vCont packet if c and C actions are not supported.
(remote_can_do_single_step): New function.
(init_remote_ops): Install it to to_can_do_single_step.
(_initialize_remote): Call add_packet_config_cmd.
* target.h (struct target_ops) <to_can_do_single_step>: New field.
(target_can_do_single_step): New macro.
* target-delegates.c: Re-generated.

gdb/gdbserver:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* server.c (vCont_supported): New global variable.
(handle_query): Set vCont_supported to 1 if "vContSupported+"
matches.  Append ";vContSupported+" to own_buf.
(handle_v_requests): Append ";s;S" to own_buf if target supports
hardware single step or vCont_supported is false.
(capture_main): Set vCont_supported to zero.

gdb/doc:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* gdb.texinfo (General Query Packets): Add vContSupported to
tables of 'gdbfeatures' and 'stub features' supported in the
qSupported packet, as well as to the list containing stub
feature details.

9 years ago[gdbserver] Rename supports_conditional_breakpoints to supports_hardware_single_step
Yao Qi [Tue, 15 Sep 2015 13:09:18 +0000 (14:09 +0100)]
[gdbserver] Rename supports_conditional_breakpoints to supports_hardware_single_step

In my patch https://sourceware.org/ml/gdb-patches/2015-04/msg01110.html
a new target_ops hook supports_conditional_breakpoints was added to
disable conditional breakpoints if target doesn't have hardware single
step.  This patch is to generalize this hook from
supports_conditional_breakpoints to supports_hardware_single_step,
so that the following patch can use it.

gdb/gdbserver:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (linux_supports_conditional_breakpoints): Rename
it to ...
(linux_supports_hardware_single_step): ... New function.
(linux_target_ops): Update.
* lynx-low.c (lynx_target_ops): Set field
supports_hardware_single_step to target_can_do_hardware_single_step.
* nto-low.c (nto_target_ops): Likewise.
* spu-low.c (spu_target_ops): Likewise.
* win32-low.c (win32_target_ops): Likewise.
* target.c (target_can_do_hardware_single_step): New function.
* target.h (struct target_ops) <supports_conditional_breakpoints>:
Remove.  <supports_hardware_single_step>: New field.
(target_supports_conditional_breakpoints): Remove.
(target_supports_hardware_single_step): New macro.
(target_can_do_hardware_single_step): Declare.
* server.c (handle_query): Use target_supports_hardware_single_step
instead of target_supports_conditional_breakpoints.

9 years agoaarch64 multi-arch support (part 2): siginfo fixup
Yao Qi [Tue, 15 Sep 2015 09:25:51 +0000 (10:25 +0100)]
aarch64 multi-arch support (part 2): siginfo fixup

This patch is to fixup the siginfo_t when aarch64 gdb or gdbserver
read from or write to the arm inferior.  It is to convert the
"struct siginfo_t" between aarch64 and arm, which is quite mechanical.

gdb/gdbserver:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_linux_siginfo_fixup): New
function.
(struct linux_target_ops the_low_target): Install
aarch64_linux_siginfo_fixup.

gdb:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (aarch64_linux_siginfo_fixup): New function.
(_initialize_aarch64_linux_nat): Call linux_nat_set_siginfo_fixup.
* nat/aarch64-linux.c (aarch64_compat_siginfo_from_siginfo):
New function.
(aarch64_siginfo_from_compat_siginfo): New function.
* nat/aarch64-linux.h: Include signal.h.
(compat_int_t, compat_uptr_t, compat_time_t): Typedef.
(compat_timer_t, compat_clock_t): Likewise.
(struct compat_timeval): New.
(union compat_sigval): New.
(struct compat_siginfo): New.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid): New macros.
(cpt_si_overrun, cpt_si_status, cpt_si_utime): Likewise.
(cpt_si_stime, cpt_si_ptr, cpt_si_addr): Likewise.
(cpt_si_band, cpt_si_fd): Likewise.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 15 Sep 2015 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix the SH behavior for EF_SH_PIC flag in FDPIC ABI
Rich Felker [Mon, 14 Sep 2015 23:16:27 +0000 (08:16 +0900)]
Fix the SH behavior for EF_SH_PIC flag in FDPIC ABI

Fix it so that it's compatible with the kernel and other FDPIC targets.

* elf32-sh.c (sh_elf_relocate_section): Set EF_SH_PIC flag
instead of clearing it on cross-section relocations.
(sh_elf_merge_private_data): Clear EF_SH_PIC flag by default.

9 years agoBail out of processing stop if hook-stop resumes target / changes context
Pedro Alves [Mon, 14 Sep 2015 14:45:14 +0000 (15:45 +0100)]
Bail out of processing stop if hook-stop resumes target / changes context

This patch, relative to a tree with
https://sourceware.org/ml/gdb-patches/2015-08/msg00295.html, fixes
issues/crashes that trigger if something unexpected happens during a
hook-stop.

E.g., if the inferior disappears while running the hook-stop, we hit
failed assertions:

 (gdb) define hook-stop
 Type commands for definition of "hook-stop".
 End with a line saying just "end".
 >kill
 >end
 (gdb) si
 Kill the program being debugged? (y or n) [answered Y; input not from terminal]
 /home/pedro/gdb/mygit/build/../src/gdb/thread.c:88: internal-error: inferior_thread: Assertion `tp' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n)

I noticed that if a hook-stop issues a synchronous execution command,
we print the same stop event twice:

 (gdb) define hook-stop
 Type commands for definition of "hook-stop".
 End with a line saying just "end".
 >si
 >end
 (gdb) si
 0x000000000040074a      42          args[i] = 1; /* Init value.  */  <<<<<<< once
 0x000000000040074a      42          args[i] = 1; /* Init value.  */  <<<<<<< twice
 (gdb)

In MI:

 *stopped,reason="end-stepping-range",frame={addr="0x000000000040074a",func="main",args=[],file="threads.c",fullname="/home/pedro/gdb/tests/threads.c",line="42"},thread-id="1",stopped-threads="all",core="0"
 *stopped,reason="end-stepping-range",frame={addr="0x000000000040074a",func="main",args=[],file="threads.c",fullname="/home/pedro/gdb/tests/threads.c",line="42"},thread-id="1",stopped-threads="all",core="0"
 (gdb)

The fix has GDB stop processing the event if the context changed.  I
don't expect people to be doing crazy things from the hook-stop.
E.g., it gives me headaches to try to come up a proper behavior for
handling a thread change from a hook-stop... (E.g., imagine the
hook-stop does thread N; step, with scheduler-locing on).  I think the
most important bit here is preventing crashes.

The patch adds a new hook-stop.exp test that covers the above and also
merges in the old hook-stop-continue.exp and hook-stop-frame.exp into
the same framework.

gdb/ChangeLog:
2015-09-14  Pedro Alves  <palves@redhat.com>

* infrun.c (current_stop_id): New global.
(get_stop_id, new_stop_id): New functions.
(fetch_inferior_event): Handle normal_stop proceeding the target.
(struct stop_context): New.
(save_stop_context, release_stop_context_cleanup)
(stop_context_changed): New functions.
(normal_stop): Return true if the hook-stop changes the stop
context.
* infrun.h (get_stop_id): Declare.
(normal_stop): Now returns int.  Add documentation.

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

* gdb.base/hook-stop-continue.c: Delete.
* gdb.base/hook-stop-continue.exp: Delete.
* gdb.base/hook-stop-frame.c: Delete.
* gdb.base/hook-stop-frame.exp: Delete.
* gdb.base/hook-stop.c: New file.
* gdb.base/hook-stop.exp: New file.

9 years ago[Ada] Fix the evaluation of access to packed array subscript
Pierre-Marie de Rodat [Fri, 4 Sep 2015 11:09:00 +0000 (13:09 +0200)]
[Ada] Fix the evaluation of access to packed array subscript

This change is relevant only for standard DWARF (as opposed to the GNAT
encodings extensions): at the time of writing it only makes a difference
with GCC patches that are to be integrated: see in particular
<https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01364.html>.

Given the following Ada declarations:

    type Small is mod 2 ** 6;
    type Array_Type is array (0 .. 9) of Small
       with Pack;
    type Array_Access is access all Array_Type;

    A  : aliased Array_Type := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    AA : constant Array_Type := A'Access;

Before this change, we would get the following GDB session:

    (gdb) print aa.all(2)
    $1 = 3
    (gdb) print aa(2)
    $2 = 16

This is wrong: both expression should yield the same value: 3.  The
problem is simply that the routine which handles accesses to arrays lack
general handling for packed arrays.  After this patch, we have the
expected output:

    (gdb) print aa.all(2)
    $1 = 3
    (gdb) print aa(2)
    $2 = 3

gdb/ChangeLog:

* ada-lang.c (ada_value_ptr_subscript): Update the heading
comment.  Handle packed arrays.

gdb/testsuite/ChangeLog:

* gdb.ada/access_to_packed_array.exp: New testcase.
* gdb.ada/access_to_packed_array/foo.adb: New file.
* gdb.ada/access_to_packed_array/pack.adb: New file.
* gdb.ada/access_to_packed_array/pack.ads: New file.

Tested on x86_64-linux, no regression.

9 years agoRemove duplicate gdb/NEWS entry
Pedro Alves [Mon, 14 Sep 2015 13:43:53 +0000 (14:43 +0100)]
Remove duplicate gdb/NEWS entry

Commit fbea99ea8a06 added this to both the "Changes in GDB 7.10" and
"Changes since GDB 7.10" sections by mistake.

gdb/ChangeLog:
2015-09-14  Pedro Alves  <palves@redhat.com>

* NEWS (Changes in GDB 7.10, New commands>: Remove duplicate
mention of maint set/show target-non-stop.

9 years agobtrace, test: remove buffer-size test with unlimited buffer size
Markus Metzger [Fri, 11 Sep 2015 07:26:21 +0000 (09:26 +0200)]
btrace, test: remove buffer-size test with unlimited buffer size

The gdb.btrace/buffer-size.exp test starts recording with an unlimited
buffer size.  This will, for a short time, use up most if not all BTS
resources.

I don' think this test is necessary.  Remove it.

testsuite/
* gdb.btrace/buffer-size.exp: Remove recording with unlimited BTS
buffer size test.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 14 Sep 2015 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 13 Sep 2015 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoSet .plt entry size to 0 in elf32-hppa.c
John David Anglin [Sat, 12 Sep 2015 16:50:55 +0000 (12:50 -0400)]
Set .plt entry size to 0 in elf32-hppa.c

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

9 years agoExtended-remote exec documentation
Don Breazeal [Fri, 11 Sep 2015 18:06:03 +0000 (11:06 -0700)]
Extended-remote exec documentation

This patch adds documentation of support for exec events on
extended-remote Linux targets.

gdb/ChangeLog:

* NEWS: Announce new remote packets for the exec-events
feature and the exec-events feature and associated commands.

gdb/doc/ChangeLog:

* gdb.texinfo (Remote Configuration): Add exec event
feature to table of packet settings.
(Stop Reply Packets): Add exec events to the list of stop
reasons.
(General Query Packets): Add exec events to tables of
'gdbfeatures' and 'stub features' supported in the qSupported
packet, as well as to the list containing stub feature
details.

9 years agoExtended-remote exec test
Don Breazeal [Fri, 11 Sep 2015 18:06:02 +0000 (11:06 -0700)]
Extended-remote exec test

This patch updates several exec-related tests and some of the library
functions in order to get them running with extended-remote.  There were
three changes that were required, as follows:

In gdb.base/foll-exec.exp, use 'clean_start' in place of proc 'zap_session'
to reset the state of the debugger between tests.  This sets 'remote
exec-file' to execute the correct binary file in each subsequent test.

In gdb.base/pie-execl.exp, there is an expect statement with an expression
that is used to match output from both gdb and the program under debug.
For the remote target, this had to be split into two expressions, using
$inferior_spawn_id to match the output from the program.

Because I had encountered problems with extended-remote exec events in
non-stop mode in my manual testing, I added non-stop testing to the
non-ldr-exc-[1234].exp tests.  In order to set non-stop mode for remote
targets, it is necessary to 'set non-stop on' after gdb has started, but
before it connects to gdbserver.  This is done using 'save_vars' to set
non-stop mode in GDBFLAGS, so GDB sets non-stop mode on startup.

gdb/testsuite/ChangeLog:

* gdb.base/foll-exec.c: Add copyright header.  Fix
formatting issues.
* gdb.base/foll-exec.exp (zap_session): Delete proc.
(do_exec_tests): Use clean_restart in place of zap_session,
and for test initialization.  Fix formatting issues.  Use
fail in place of perror.
* gdb.base/pie-execl.exp (main): Use 'inferior_spawn_id' in
an expect statement to match an expression with output from
the program under debug.
* gdb.threads/non-ldr-exc-1.exp (do_test, main): Add
non-stop tests and pass stop mode argument to clean_restart.
Use save_vars to enable non-stop in GDBFLAGS.
* gdb.threads/non-ldr-exc-2.exp: Likewise.
* gdb.threads/non-ldr-exc-3.exp: Likewise.
* gdb.threads/non-ldr-exc-4.exp: Likewise.

9 years agoExtended-remote catch exec
Don Breazeal [Fri, 11 Sep 2015 18:06:02 +0000 (11:06 -0700)]
Extended-remote catch exec

This patch implements exec catchpoints for extended-remote Linux
targets.  The implementation follows the same approach used for
fork catchpoints, implementing extended-remote target routines for
inserting and removing the catchpoints by just checking if exec events
are supported.  Existing host-side code and previous support for
extended-remote exec events takes care of the rest.

gdb/ChangeLog:

* remote.c (remote_exec_event_p): New function.
(remote_insert_exec_catchpoint): New function.
(remote_remove_exec_catchpoint): New function.
(init_extended_remote_ops): Initialize extended_remote_ops
members to_insert_exec_catchpoint and
to_remove_exec_catchpoint.

9 years agoExtended-remote follow-exec
Don Breazeal [Fri, 11 Sep 2015 18:06:02 +0000 (11:06 -0700)]
Extended-remote follow-exec

This patch implements support for exec events on extended-remote Linux
targets.  Follow-exec-mode and rerun behave as expected.  Catchpoints and
test updates are implemented in subsequent patches.

This patch was derived from a patch posted last October:
https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html.
It was originally based on some work done by Luis Machado in 2013.

IMPLEMENTATION
----------------
Exec events are enabled via ptrace options.

When an exec event is detected by gdbserver, the existing process
data, along with all its associated lwp and thread data, is deleted
and replaced by data for a new single-threaded process.  The new
process data is initialized with the appropriate parts of the state
of the execing process.  This approach takes care of several potential
pitfalls, including:

 * deleting the data for an execing non-leader thread before any
   wait/sigsuspend occurs
 * correctly initializing the architecture of the execed process

We then report the exec event using a new RSP stop reason, "exec".

When GDB receives an "exec" event, it saves the status in the event
structure's target_waitstatus field, like what is done for remote fork
events.  Because the original and execed programs may have different
architectures, we skip parsing the section of the stop reply packet
that contains register data.  The register data will be retrieved
later after the inferior's architecture has been set up by
infrun.c:follow_exec.

At that point the exec event is handled by the existing event handling
in GDB.  However, a few changes were necessary so that
infrun.c:follow_exec could accommodate the remote target.

 * Where follow-exec-mode "new" is handled, we now call
   add_inferior_with_spaces instead of add_inferior with separate calls
   to set up the program and address spaces.  The motivation for this
   is that add_inferior_with_spaces also sets up the initial architecture
   for the inferior, which is needed later by target_find_description
   when it calls target_gdbarch.

 * We call a new target function, target_follow_exec.  This function
   allows us to store the execd_pathname in the inferior, instead of
   using the static string remote_exec_file from remote.c.  The static
   string didn't work for follow-exec-mode "new", since once you switched
   to the execed program, the original remote exec-file was lost.  The
   execd_pathname is now stored in the inferior's program space as a
   REGISTRY field.  All of the requisite mechanisms for this are
   defined in remote.c.

gdb/gdbserver/ChangeLog:

* linux-low.c (linux_mourn): Static declaration.
(linux_arch_setup): Move in front of
handle_extended_wait.
(linux_arch_setup_thread): New function.
(handle_extended_wait): Handle exec events.  Call
linux_arch_setup_thread.  Make event_lwp argument a
pointer-to-a-pointer.
(check_zombie_leaders): Do not check stopped threads.
(linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC.
(linux_low_filter_event): Add lwp and thread for exec'ing
non-leader thread if leader thread has been deleted.
Refactor code into linux_arch_setup_thread and call it.
Pass child lwp pointer by reference to handle_extended_wait.
(linux_wait_for_event_filtered): Update comment.
(linux_wait_1): Prevent clobbering exec event status.
(linux_supports_exec_events): New function.
(linux_target_ops) <supports_exec_events>: Initialize new member.
* lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize
new member.
* remote-utils.c (prepare_resume_reply): New stop reason 'exec'.
* server.c (report_exec_events): New global variable.
(handle_query): Handle qSupported query for exec-events feature.
(captured_main): Initialize report_exec_events.
* server.h (report_exec_events): Declare new global variable.
* target.h (struct target_ops) <supports_exec_events>: New
member.
(target_supports_exec_events): New macro.
* win32-low.c (win32_target_ops) <supports_exec_events>:
Initialize new member.

gdb/ChangeLog:

* infrun.c (follow_exec): Use process-style ptid for
exec message.  Call add_inferior_with_spaces and
target_follow_exec.
* nat/linux-ptrace.c (linux_supports_traceexec): New function.
* nat/linux-ptrace.h (linux_supports_traceexec): Declare.
* remote.c (remote_pspace_data): New static variable.
(remote_pspace_data_cleanup): New function.
(get_remote_exec_file): New function.
(set_remote_exec_file_1): New function.
(set_remote_exec_file): New function.
(show_remote_exec_file): New function.
(remote_exec_file): Delete static variable.
(anonymous enum) <PACKET_exec_event_feature> New
enumeration constant.
(remote_protocol_features): Add entry for exec-events feature.
(remote_query_supported): Add client side of qSupported query
for exec-events feature.
(remote_follow_exec): New function.
(remote_parse_stop_reply): Handle 'exec' stop reason.
(extended_remote_run, extended_remote_create_inferior): Call
get_remote_exec_file and set_remote_exec_file_1.
(init_extended_remote_ops) <to_follow_exec>: Initialize new
member.
(_initialize_remote): Call
register_program_space_data_with_cleanup.  Call
add_packet_config_cmd for remote exec-events feature.
Modify call to add_setshow_string_noescape_cmd for exec-file
to use new functions set_remote_exec_file and
show_remote_exec_file.
* target-debug.h, target-delegates.c: Regenerated.
* target.c (target_follow_exec): New function.
* target.h (struct target_ops) <to_follow_exec>: New member.
(target_follow_exec): Declare new function.

9 years agoAdd "ld -r" tests for PR ld/15323
H.J. Lu [Fri, 11 Sep 2015 17:02:57 +0000 (10:02 -0700)]
Add "ld -r" tests for PR ld/15323

Weak defined function is turned into non-weak defined function by
"ld -r -flto" with GCC 5 due to a GCC 5 regression:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67548

Add "ld -r" tests for PR ld/15323 to make sure that any linker change
won't introduce linker regression for PR ld/15323.

* ld-plugin/lto.exp (lto_link_tests): Add a "ld -r" test for
PR ld/15323.
(lto_run_tests): Add a "ld -r" test for PR ld/15323.

9 years ago[AArch64] Cleanup comments in instruction decoding functions
Pierre Langlois [Fri, 11 Sep 2015 16:00:55 +0000 (17:00 +0100)]
[AArch64] Cleanup comments in instruction decoding functions

gdb/ChangeLog:

* aarch64-tdep.c (decode_cb): Move up comment describing the
encoding.
(decode_tb): Fix a typo in comment above the function.  Move up
comment describing the encoding.

9 years ago[AArch64] Fix incorrect mask when decoding b.cond instruction
Pierre Langlois [Fri, 11 Sep 2015 15:47:20 +0000 (16:47 +0100)]
[AArch64] Fix incorrect mask when decoding b.cond instruction

The encoding of the b.cond instruction is described in the architecture
reference manual as:

b.cond  0101 0100 iiii iiii iiii iiii iii0 cccc

So the mask should be 0xff000010.

gdb/ChangeLog:

* aarch64-tdep.c (decode_bcond): Fix incorrect mask.

9 years agogdb/18947: [aarch64]Step into shared library is very slow.
Mihail-Marian Nistor [Fri, 11 Sep 2015 14:22:11 +0000 (15:22 +0100)]
gdb/18947: [aarch64]Step into shared library is very slow.

Install gdbarch_skip_solib_resolver on aarch64 GNU/Linux

gdb/ChangeLog:

2015-09-11  Mihail-Marian Nistor  <mihail.nistor@freescale.com>

PR gdb/18947
* aarch64-linux-tdep.c: (aarch64_linux_init_abi): Install
glibc_skip_solib_resolver as gdbarch_skip_solib_resolver callback.

Signed-off-by: Mihail-Marian Nistor <mihail.nistor@freescale.com>
9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 11 Sep 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoSmall refactor in ada-lang.c:scan_discrim_bound
Simon Marchi [Thu, 10 Sep 2015 15:48:47 +0000 (11:48 -0400)]
Small refactor in ada-lang.c:scan_discrim_bound

Factor out common arithmetic operations for clarity.

gdb/ChangeLog:

* ada-lang.c (scan_discrim_bound): Factor out arithmetic
operations.

9 years agoConstify variables in ada-lang.c
Simon Marchi [Thu, 10 Sep 2015 15:12:51 +0000 (11:12 -0400)]
Constify variables in ada-lang.c

I found this const/not const mixup found by building in C++ mode.

gdb/ChangeLog:

* ada-lang.c (ada_search_struct_field): Constify parameters
and/or variables..
(xget_renaming_scope): Likewise.
(ada_is_redundant_range_encoding): Likewise.
(scan_discrim_bound): Likewise.
(to_fixed_range_type): Likewise.

9 years agoS/390: Fix instruction format of crj*, clrj*, and clgrj*.
Andreas Krebbel [Thu, 10 Sep 2015 13:18:00 +0000 (15:18 +0200)]
S/390: Fix instruction format of crj*, clrj*, and clgrj*.

This fixes the instruction format for 3 of the compare and branch
extended mnemonics.  That way the extended mnemonics are actually
being found by objdump.

gas/testsuite/ChangeLog:

2015-09-10  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* gas/s390/zarch-z10.d: Fix testcase for some of the compare and
branch extended mnemonics.

opcodes/ChangeLog:

2015-09-10  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.txt: Fix instruction format of crj*, clrj*, and clgrj*.

9 years agoS/390: Remove F_20 and FE_20. Adjust comments.
Andreas Krebbel [Thu, 10 Sep 2015 12:27:02 +0000 (14:27 +0200)]
S/390: Remove F_20 and FE_20. Adjust comments.

This is cleanup only.

opcodes/ChangeLog:

2015-09-10  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.c: Remove unused (and broken) F_20 and FE_20 operand
types and adjust numbering accordingly.  Fix some comments.

9 years agoS/390: Fix MASK_RIE_R0PI and MASK_RIE_R0PU.
Andreas Krebbel [Thu, 10 Sep 2015 12:18:14 +0000 (14:18 +0200)]
S/390: Fix MASK_RIE_R0PI and MASK_RIE_R0PU.

This makes objdump to be able to recognize some of the extended
mnemonics more often.  It does not lead to wrong being generated.

opcodes/ChangeLog:

2015-09-10  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.c: Fix MASK_RIE_R0PI and MASK_RIE_R0PU.

gas/testsuite/ChangeLog:

2015-09-10  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* gas/s390/zarch-z10.d: Fix testcase for compare and branch
extended mnemonics.

9 years agoAnother updated version of the simplified Chinese translation.
Nick Clifton [Thu, 10 Sep 2015 11:50:34 +0000 (12:50 +0100)]
Another updated version of the simplified Chinese translation.

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

9 years agoCall target_can_download_tracepoint if there are tracepoints to download
Yao Qi [Thu, 10 Sep 2015 11:31:36 +0000 (12:31 +0100)]
Call target_can_download_tracepoint if there are tracepoints to download

Nowadays, GDB calls target_can_download_tracepoint at the entry of
download_tracepoint_locations, which is called by.
update_global_location_list.  Sometimes, it is not needed to call
target_can_download_tracepoint at all because there is no tracepoint
created.  In remote target, target_can_download_tracepoint send
qTStatus to the remote in order to know whether tracepoint can be
downloaded or not.  This means some redundant qTStatus packets are
sent.

This patch is to teach GDB to call target_can_download_tracepoint
lazily, only on the moment there are tracepoint to download.
gdb.perf/single-step.exp (with a local patch to measure RSP packets)
shows the number of RSP packets is reduced because there is no
tracepoint at all, so GDB doesn't send qTStatus any more.

                       # of RSP packets
                       original  patched
single-step rsp 1000   7000      6000
single-step rsp 2000   14000     12000
single-step rsp 3000   21000     18000
single-step rsp 4000   28000     24000

gdb:

2015-09-10  Yao Qi  <yao.qi@linaro.org>

* breakpoint.c (download_tracepoint_locations): New local
can_download_tracepoint.  Check the result of
target_can_download_tracepoint and save it in
can_download_tracepoint if there are tracepoints to download.
* linux-nat.h (enum tribool): Move it to ...
* common/common-types.h: ... here.

9 years agoAdds an option to the strings program to specify a separator between the emitted...
Erik Ackermann [Thu, 10 Sep 2015 08:29:13 +0000 (09:29 +0100)]
Adds an option to the strings program to specify a separator between the emitted pieces of text.

* strings.c: Add -s/--output-separator option to specify custom
separator string.
* NEWS: Mention the new feature.
* doc/binutils.text (strings): Document the new command line
option.

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

9 years ago* gdb.python/py-prettyprint.exp: Check result of run_lang_tests.
Doug Evans [Wed, 9 Sep 2015 18:42:52 +0000 (11:42 -0700)]
* gdb.python/py-prettyprint.exp: Check result of run_lang_tests.

gdb/testsuite/ChangeLog:

* gdb.python/py-prettyprint.exp: Check result of run_lang_tests.

9 years ago* gdb.base/pie-execl.exp: Fix result test of build_executable.
Doug Evans [Wed, 9 Sep 2015 18:17:36 +0000 (11:17 -0700)]
* gdb.base/pie-execl.exp: Fix result test of build_executable.

gdb/testsuite/ChangeLog:

* gdb.base/pie-execl.exp: Fix result test of build_executable.

9 years ago* gdb.base/savedregs.exp: Fix typo.
Doug Evans [Wed, 9 Sep 2015 18:00:55 +0000 (11:00 -0700)]
* gdb.base/savedregs.exp: Fix typo.

gdb/testsuite/ChangeLog:

* gdb.base/savedregs.exp: Fix typo.

9 years agoDelete enum inferior_event_handler::INF_TIMER
Pedro Alves [Wed, 9 Sep 2015 17:23:25 +0000 (18:23 +0100)]
Delete enum inferior_event_handler::INF_TIMER

Nothing ever uses this.

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

* inf-loop.c (inferior_event_handler): Delete INF_TIMER case.
* target.h (enum inferior_event_type) <INF_TIMER>: Delete.

9 years agoGarbage collect thread continuations
Pedro Alves [Wed, 9 Sep 2015 17:23:25 +0000 (18:23 +0100)]
Garbage collect thread continuations

Nothing uses thread continuations anymore.

(inferior continuations are still used by the attach command.)

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

* continuations.c (add_continuation, restore_thread_cleanup)
(do_all_continuations_ptid, do_all_continuations_thread_callback)
(do_all_continuations_thread, do_all_continuations)
(discard_all_continuations_thread_callback)
(discard_all_continuations_thread, discard_all_continuations)
(add_intermediate_continuation)
(do_all_intermediate_continuations_thread_callback)
(do_all_intermediate_continuations_thread)
(do_all_intermediate_continuations)
(discard_all_intermediate_continuations_thread_callback)
(discard_all_intermediate_continuations_thread)
(discard_all_intermediate_continuations): Delete.
* continuations.h (add_continuation, do_all_continuations)
(do_all_continuations_thread, discard_all_continuations)
(discard_all_continuations_thread, add_intermediate_continuation)
(do_all_intermediate_continuations)
(do_all_intermediate_continuations_thread)
(discard_all_intermediate_continuations)
(discard_all_intermediate_continuations_thread): Delete
declarations.
* event-top.c (stdin_event_handler): Delete references to
continuations.
* gdbthread.h (struct thread_info): Delete continuations and
intermediate_continuations fields.
* inf-loop.c (inferior_event_handler): Remove references to
continuations.
* infrun.c (infrun_thread_stop_requested_callback): Remove
references to continuations.
* target.h (enum inferior_event_type) <INF_EXEC_CONTINUE>: Delete.
* thread.c: Don't include "continuations.h".
(clear_thread_inferior_resources): Remove references to
continuations.

9 years agoGarbage collect dummy_frame_ctx_saver
Pedro Alves [Wed, 9 Sep 2015 17:23:25 +0000 (18:23 +0100)]
Garbage collect dummy_frame_ctx_saver

Since the "finish" command and infcall's FSMs are now responsible for
saving the return value, the dummy_frame_ctx_saver is no longer needed
anywhere.

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

* infcall.c (struct dummy_frame_context_saver): Delete.
(dummy_frame_context_saver_free, dummy_frame_context_saver_dtor)
(dummy_frame_context_saver_drop)
(dummy_frame_context_saver_cleanup)
(dummy_frame_context_saver_get_regs)
(dummy_frame_context_saver_setup): Delete.
* infcall.h (dummy_frame_context_saver_drop)
(dummy_frame_context_saver_cleanup)
(dummy_frame_context_saver_get_regs, dummy_frame_context_saver):
Delete.
(get_return_value): Remove 'ctx_saver' paremeter.  Adjust.
* inferior.h (get_return_value): Remove 'ctx_saver' paremeter.
* python/py-finishbreakpoint.c (bpfinishpy_pre_stop_hook): Adjust.

9 years agoConvert the until/advance commands to thread_fsm mechanism
Pedro Alves [Wed, 9 Sep 2015 17:23:24 +0000 (18:23 +0100)]
Convert the until/advance commands to thread_fsm mechanism

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

* breakpoint.c: Include "thread-fsm.h".
(struct until_break_command_continuation_args): Delete.
(struct until_break_fsm): New.
(until_break_fsm_ops): New global.
(new_until_break_fsm, until_break_fsm_should_stop): New functions.
(until_break_command_continuation): Delete.
(until_break_fsm_clean_up): New function.
(until_break_fsm_async_reply_reason): New function.
(until_break_command): Adjust to create an until_break_fsm instead
of a continuation.
(momentary_bkpt_print_it): No longer print MI's async-stop-reason
here.
* infcmd.c (struct until_next_fsm): New.
(until_next_fsm_ops): New global.
(new_until_next_fsm, until_next_fsm_should_stop): New function.
(until_next_continuation): Delete.
(until_next_fsm_clean_up, until_next_fsm_async_reply_reason): New
functions.
(until_next_command): Adjust to create a new until_next_fsm
instead of a continuation.

9 years agoConvert infcalls to thread_fsm mechanism
Pedro Alves [Wed, 9 Sep 2015 17:23:24 +0000 (18:23 +0100)]
Convert infcalls to thread_fsm mechanism

This removes infcall-specific special casing from normal_stop,
simplifying it.

Like the "finish" command's, the FSM is responsible for storing the
function's return value.

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

* infcall.c: Include thread_fsm.h.
(struct call_return_meta_info): New.
(get_call_return_value): New function, factored out from
call_function_by_hand_dummy.
(struct call_thread_fsm): New.
(call_thread_fsm_ops): New global.
(new_call_thread_fsm, call_thread_fsm_should_stop)
(call_thread_fsm_should_notify_stop): New functions.
(run_inferior_call): Add 'sm' parameter.  Associate the FSM with
the thread.
(call_function_by_hand_dummy): Create a new call_thread_fsm
instance, associate it with the thread, and wait for the FSM to
finish.  If finished successfully, fetch the function's result
value out of the FSM.
* infrun.c (fetch_inferior_event): If the FSM says the stop
shouldn't be notified, don't call normal_stop.
(maybe_remove_breakpoints): New function, factored out from ...
(normal_stop): ... here.  Simplify.
* infrun.h (maybe_remove_breakpoints): Declare.
* thread-fsm.c (thread_fsm_should_notify_stop): New function.
(thread-fsm.h) <struct thread_fsm_ops>: New field.
(thread_fsm_should_notify_stop): Declare.