binutils-gdb.git
9 years agoEvaluate __start_* and __stop_* symbol PROVIDE expressions early
Alan Modra [Tue, 27 Oct 2015 01:31:55 +0000 (12:01 +1030)]
Evaluate __start_* and __stop_* symbol PROVIDE expressions early

Makes these symbols defined before bfd_elf_size_dynamic_sections, to
avoid horrible hacks elsewhere.  The exp_fold_tree undefweak change
is necessary to define undefweak symbols early too.  The comment was
wrong.  PROVIDE in fact defines undefweak symbols, via
bfd_elf_record_link_assignment.

PR ld/19175
* ldlang.c (lang_insert_orphan): Evaluate __start_* and __stop_*
symbol PROVIDE expressions.
* ldexp.c (exp_fold_tree_1 <etree_provide>): Define undefweak
references.

9 years agotarget.c: Add a cast and change a type
Simon Marchi [Tue, 27 Oct 2015 02:07:27 +0000 (22:07 -0400)]
target.c: Add a cast and change a type

Fixes some errors in C++ build.

gdb/ChangeLog:

* target.c (memory_xfer_partial): Change type of buf to gdb_byte
pointer.
(simple_search_memory): Cast return of memmem.

9 years agostap-probe.c: Add casts
Simon Marchi [Tue, 27 Oct 2015 02:04:10 +0000 (22:04 -0400)]
stap-probe.c: Add casts

gdb/ChangeLog:

* stap-probe.c (handle_stap_probe): Add (const char *) casts.

9 years agoctf_xfer_partial: Return TARGET_XFER_E_IO instead of -1 on error
Simon Marchi [Tue, 27 Oct 2015 02:00:41 +0000 (22:00 -0400)]
ctf_xfer_partial: Return TARGET_XFER_E_IO instead of -1 on error

Use the enum value instead of the corresponding int value.

gdb/ChangeLog:

* ctf.c (ctf_xfer_partial): Return TARGET_XFER_E_IO instead of
-1 on error.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 27 Oct 2015 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoCheck symbol defined by assignment in linker script
H.J. Lu [Mon, 26 Oct 2015 23:32:34 +0000 (16:32 -0700)]
Check symbol defined by assignment in linker script

Symbol symbol defined by an assignment in a linker script has type
bfd_link_hash_new.  elf_i386_convert_load and elf_x86_64_convert_load
should check bfd_link_hash_new to see if a symbol is defined by a linker
script.

bfd/

PR ld/19175
* elf32-i386.c (elf_i386_convert_load): Check bfd_link_hash_new
instead of calling bfd_link_get_defined_symbol.
* elf64-x86-64.c (elf_x86_64_convert_load): Likewise.  Skip
relocation overflow for bfd_link_hash_new.
* linker.c (bfd_link_get_defined_symbol): Removed.
* bfd-in2.h: Regenerated.

ld/testsuite/

PR ld/19175
* ld-i386/i386.exp: Run pr19175.
* ld-x86-64/x86-64.exp: Likewise.
* ld-i386/pr19175.d: New file.
* ld-i386/pr19175.s: Likewise.
* ld-i386/pr19175.t: Likewise.
* ld-x86-64/pr19175.d: Likewise.
* ld-x86-64/pr19175.s: Likewise.
* ld-x86-64/pr19175.t: Likewise.

9 years agoPR symtab/17391 gdb internal error: assertion fails in regcache.c:178
Doug Evans [Mon, 26 Oct 2015 23:05:21 +0000 (16:05 -0700)]
PR symtab/17391 gdb internal error: assertion fails in regcache.c:178

gdb/ChangeLog:

* dwarf2-frame.c (dwarf2_restore_rule): Call dwarf_reg_to_regnum
instead of gdbarch_dwarf2_reg_to_regnum.
(dwarf2_frame_cache): Ditto.
(read_addr_from_reg): Call dwarf_reg_to_regnum_or_error instead of
gdbarch_dwarf2_reg_to_regnum.
(get_reg_value): Ditto.
(dwarf2_fetch_cfa_info): Ditto.
(dwarf2_frame_prev_register): Ditto.
* dwarf2loc.c: #include "complaints.h".
(dwarf_expr_read_addr_from_reg): Call dwarf_reg_to_regnum_or_error
instead of gdbarch_dwarf2_reg_to_regnum.
(dwarf_expr_get_reg_value): Ditto.
(read_pieced_value): Ditto.
(write_pieced_value): Ditto.
(dwarf2_evaluate_loc_desc_full): Ditto.
(dwarf_reg_to_regnum): New function.
(throw_bad_regnum_error): New function.
(dwarf_reg_to_regnum_or_error): Renamed from
dwarf2_reg_to_regnum_or_errorChange to take a ULONGEST regnum.
All callers updated.  Call throw_bad_regnum_error.
(locexpr_regname): Improve text of bad register number.
* dwarf2loc.h (dwarf_reg_to_regnum): Declare.
(dwarf_reg_to_regnum_or_error): Update prototype.
* dwarf2expr.c: #include "dwarf2loc.h".
(dwarf_block_to_sp_offset): Call dwarf_reg_to_regnum instead of
gdbarch_dwarf2_reg_to_regnum.
* gdbarch.sh (dwarf2_reg_to_regnum): Add comment.
* gdbarch.h: Regenerate.
* amd64-tdep.c (amd64_dwarf_reg_to_regnum): Remove warning for bad
register.
* avr-tdep.c (avr_dwarf_reg_to_regnum): Ditto.
* cris-tdep.c (cris_dwarf2_reg_to_regnum): Ditto.
* bfin-tdep.c (bfin_reg_to_regnum): Fix error checking.
* hppa-linux-tdep.c (hppa_dwarf_reg_to_regnum): Improve error checking.
Remove warning for bad register.
* hppa-tdep.c (hppa64_dwarf_reg_to_regnum): Ditto.
* i386-tdep.c (i386_svr4_dwarf_reg_to_regnum): Renamed from
i386_svr4_reg_to_regnum.  Return -1 for bad registers.
(i386_svr4_reg_to_regnum): New function.
(i386_gdbarch_init): Update call to set_gdbarch_dwarf2_reg_to_regnum.
* microblaze-tdep.c (microblaze_dwarf2_reg_to_regnum): Don't assert
on bad registers, return -1.
* msp430-tdep.c (msp430_dwarf2_reg_to_regnum): Improve error checking.
Remove warning for bad register.
* nios2-tdep.c: Add static assert for NIOS2_NUM_REGS.
(nios2_dwarf_reg_to_regnum): Fix off-by-one error.
Remove warning for bad register.  Return -1 for bad register.
* rl78-tdep.c (rl78_dwarf_reg_to_regnum): Don't flag an internal error
for bad register, return -1.
* rx-tdep.c (rx_dwarf_reg_to_regnum): Ditto.
* m68k-tdep.c (m68k_dwarf_reg_to_regnum): Fix error result.
* mep-tdep.c (mep_debug_reg_to_regnum): Ditto.
* mips-tdep.c (mips_stab_reg_to_regnum): Ditto.
(mips_dwarf_dwarf2_ecoff_reg_to_regnum): Ditto.
* mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): Remove warning
for bad regs.
* xtensa-tdep.c (xtensa_reg_to_regnum): Remove internal error for
bad regs.  Fix error result.
* stabsread.c (stab_reg_to_regnum): Watch for negative regno.
(reg_value_complaint): Update complaint text.
* mdebugread.c (reg_value_complaint): New function.
(mdebug_reg_to_regnum): Rewrite to watch for bad reg numbers.

gdb/testsuite/ChangeLog:

* lib/dwarf.exp (_location): Add support for DW_OP_regx.
* gdb.dwarf2/bad-regnum.c: New file.
* gdb.dwarf2/bad-regnum.exp: New file.

9 years agoPR python/18938: source -s foo.py with foo.py a symlink to foo.notpy fails
Doug Evans [Mon, 26 Oct 2015 21:33:19 +0000 (14:33 -0700)]
PR python/18938: source -s foo.py with foo.py a symlink to foo.notpy fails

gdb/ChangeLog:

PR python/18938
* cli/cli-cmds (source_script_fron_sctream): New arg file_to_open.
All callers updated.

gdb/testsuite/ChangeLog:

* gdb.python/python.exp: Add test for symlink from .py file to .notpy
file.

9 years agoPrint address map in output of "mt print psymbols"
Doug Evans [Mon, 26 Oct 2015 21:12:51 +0000 (14:12 -0700)]
Print address map in output of "mt print psymbols"

gdb/ChangeLog:

* psymtab.c (struct dump_psymtab_addrmap_data): Define.
(dump_psymtab_addrmap_1, dump_psymtab_addrmap): New functions.
(maintenance_print_psymbols): Print address map.

9 years agoMove __SIGRTMIN.
Doug Evans [Mon, 26 Oct 2015 20:30:57 +0000 (13:30 -0700)]
Move __SIGRTMIN.

gdb/ChangeLog:

* nat/linux-nat.h (__SIGRTMIN): Move here from gdbserver/linux-low.c.

gdb/gdbserver/ChangeLog:

* linux-low.c (__SIGRTMIN): Move to nat/linux-nat.h.

9 years agomusl: Move W_STOPCODE to common/gdb_wait.h.
Doug Evans [Mon, 26 Oct 2015 20:24:01 +0000 (13:24 -0700)]
musl: Move W_STOPCODE to common/gdb_wait.h.

gdb/ChangeLog:

* common/gdb_wait.h (W_STOPCODE): Define, moved here from
gdbserver/linux-low.c.
(WSETSTOP): Simplify.

gdb/gdbserver/ChangeLog:

* linux-low.c (W_STOPCODE): Moved to common/gdb_wait.h.

9 years agoAdd some casts for building on musl.
Doug Evans [Mon, 26 Oct 2015 20:20:12 +0000 (13:20 -0700)]
Add some casts for building on musl.

gdb/ChangeLog:

* linux-thread-db.c (find_new_threads_callback): Cast ti.ti_tid to
unsigned long for debug_printf.
(thread_db_pid_to_str): Ditto.

gdb/gdbserver/ChangeLog:

* thread-db.c (find_one_thread): Cast ti.ti_tid to unsigned long
for debug_printf.
(attach_thread, find_new_threads_callback): Ditto.

9 years agoguile: Simplify ioscm_make_gdb_stdio_port
Simon Marchi [Mon, 26 Oct 2015 19:05:50 +0000 (15:05 -0400)]
guile: Simplify ioscm_make_gdb_stdio_port

As pointed out by Pedro, it's clearer to do it this way.  We can trust
that scm_mode_bits won't try to modify our string, even though it takes
a non-const char *.

gdb/ChangeLog:

* guile/scm-ports.c (ioscm_make_gdb_stdio_port): Do not pass a
local char array to scm_mode_bits, use a cast instead.

9 years agotui: Simplify tui_alloc_content
Simon Marchi [Mon, 26 Oct 2015 16:58:32 +0000 (12:58 -0400)]
tui: Simplify tui_alloc_content

I stumbled upon this while doing some cxx-conversion work.  Since the
x-family alloc functions throw on failure, it is useless to test their
result for failure.  The else branch of != NULL is basically dead code.

I changed the type of element_block_ptr to struct tui_win_element, which
seems obvious (this is actually what raised the flag, casting the result
of xmalloc to struct tui_win_element* wouldn't work).

gdb/ChangeLog:

* tui/tui-data.c (tui_alloc_content): Don't check xmalloc
result.  Change type of element_block_ptr.  Change allocation to
use XNEWVEC.

9 years agoProperly convert address load of __start_XXX/__stop_XXX
H.J. Lu [Mon, 26 Oct 2015 13:10:23 +0000 (06:10 -0700)]
Properly convert address load of __start_XXX/__stop_XXX

Since __start_XXX and __stop_XXX symbols aren't defined when address
load is being converted, we need to check if there is an XXX output
section to get their section and value.  This patch adds a new function,
bfd_link_get_defined_symbol, to search for the XXX output section to
check if __start_XXX and __stop_XXX symbols are defined.

bfd/

PR ld/19171
* elf32-i386.c (elf_i386_convert_load): Call
bfd_link_get_defined_symbol to check if a symbol is defined.
* elf64-x86-64.c (elf_x86_64_convert_load): Call
bfd_link_get_defined_symbol to get defined symbol section and
value.
* linker.c (bfd_link_get_defined_symbol): New function.
* bfd-in2.h: Regenerated.

ld/testsuite/

PR ld/19171
* ld-i386/lea1.s: Add tests for address load of __start_XXX
and __stop_XXX.
* ld-i386/mov1.s: Likewise.
* ld-x86-64/lea1.s: Likewise.
* ld-x86-64/mov1.s: Likewise.
* ld-i386/lea1a.d: Updated.
* ld-i386/lea1b.d: Likewise.
* ld-i386/lea1c.d: Likewise.
* ld-i386/mov1a.d: Likewise.
* ld-i386/mov1b.d: Likewise.
* ld-x86-64/lea1a.d: Likewise.
* ld-x86-64/lea1b.d: Likewise.
* ld-x86-64/lea1c.d: Likewise.
* ld-x86-64/lea1d.d: Likewise.
* ld-x86-64/lea1e.d: Likewise.
* ld-x86-64/lea1f.d: Likewise.
* ld-x86-64/mov1a.d: Likewise.
* ld-x86-64/mov1b.d: Likewise.
* ld-x86-64/mov1c.d: Likewise.
* ld-x86-64/mov1d.d: Likewise.

9 years agoDo not pass NULL for the string in catch_errors
Luis Machado [Mon, 26 Oct 2015 13:17:29 +0000 (11:17 -0200)]
Do not pass NULL for the string in catch_errors

I caught a segmentation fault while running gdb.reverse/sigall-reverse.exp,
in a mingw32 GDB, in this code path. It boils down to the code trying to
strlen () a NULL pointer. I tracked things down and it looks like
record_full_message_wrapper_safe is the only offender.

gdb/ChangeLog:

2015-10-26  Luis Machado  <lgustavo@codesourcery.com>

* record-full.c (record_full_message_wrapper_safe): Pass empty string to
catch_errors call instead of NULL.

9 years agoFix constness problem in ioscm_make_gdb_stdio_port
Simon Marchi [Mon, 26 Oct 2015 12:41:38 +0000 (08:41 -0400)]
Fix constness problem in ioscm_make_gdb_stdio_port

ioscm_make_gdb_stdio_port passes const char pointers (literal strings) to
scm_mode_bits, which takes a non-const char pointer.  Ideally, we would
change scm_mode_bits to take a const char pointer, but it's not part of
an API we control.

Instead, it's easy enough to build the string to pass to scm_mode_bits in
a (non-const) char array and pass that.

gdb/ChangeLog:

* guile/scm-ports.c (ioscm_make_gdb_stdio_port): Pass non-const
char pointer to scm_mode_bits.

9 years agosymtab.c: Add cast
Simon Marchi [Mon, 26 Oct 2015 12:41:38 +0000 (08:41 -0400)]
symtab.c: Add cast

gdb/ChangeLog:

* symtab.c (default_make_symbol_completion_list_break_on_1): Add
cast.

9 years agogdbscm_memory_port_write: use local variable to avoid adding casts
Simon Marchi [Mon, 26 Oct 2015 12:41:37 +0000 (08:41 -0400)]
gdbscm_memory_port_write: use local variable to avoid adding casts

By having a local variable of type (const gdb_byte *), we can avoid adding
two casts.

gdb/ChangeLog:

* guile/scm-ports.c (gdbscm_memory_port_write): Declare new
"data" local variable and use it.

9 years agoscm-symbol.c: Add (domain_enum) casts
Simon Marchi [Mon, 26 Oct 2015 12:41:36 +0000 (08:41 -0400)]
scm-symbol.c: Add (domain_enum) casts

We currently pass integers as domain_enums to lookup_symbol.  The
most obvious fix is to add casts there.

I first thought of changing the type of the domain variables to
domain_enum.  However, because we pass a pointer to them to
gdbscm_parse_function_args, which expects them to be integers (because
of the format string), I don't think it would be correct.  If the enum
does not have the same size as an int, gdbscm_parse_function_args could
write past the memory of domain, overwriting something else on the
stack.

gdb/ChangeLog:

* guile/scm-symbol.c (gdbscm_lookup_global_symbol): Add
domain_enum cast.
(gdbscm_lookup_symbol): Likewise.

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

9 years agoFix compile.exp error message expectation
Jan Kratochvil [Sun, 25 Oct 2015 11:16:10 +0000 (12:16 +0100)]
Fix compile.exp error message expectation

commit cdaec3f3e7ea9118204f0e579bd3257234fbae63
Author: Luis Machado <lgustavo@codesourcery.com>
Date:   Thu Aug 27 02:00:16 2015 -0300
    Mention language in compile error message

regressed:

-PASS: gdb.compile/compile.exp: compile code globalvar
+FAIL: gdb.compile/compile.exp: compile code globalvar

Update the expected message.

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

* gdb.compile/compile.exp (compile code globalvar): Update expectation
for a change by "Mention language in compile error message".

9 years agoRe-apply change for handling non-local references in nested functions.
Iain Buclaw [Sun, 25 Oct 2015 08:17:24 +0000 (09:17 +0100)]
Re-apply change for handling non-local references in nested functions.

gdb/ChangeLog:

* d-exp.y: Remove an obsolete comment and propagate the block
information to the produced expression.

9 years agotui-data.c: Remove unnecessary casts
Simon Marchi [Sun, 25 Oct 2015 02:40:37 +0000 (22:40 -0400)]
tui-data.c: Remove unnecessary casts

The (void *) casts make the build fail in C++ mode and are unnecessary.

gdb/ChangeLog:

* tui/tui-data.c (tui_add_to_source_windows): Remove void *
cast.
(tui_add_content_elements): Likewise.

9 years agocli-setshow.c: Constify variable
Simon Marchi [Sun, 25 Oct 2015 02:28:56 +0000 (22:28 -0400)]
cli-setshow.c: Constify variable

Fixes:

/home/simark/src/binutils-gdb/gdb/cli/cli-setshow.c:390:13: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
  p = strchr (arg, ' ');
             ^
gdb/ChangeLog:

* cli/cli-setshow.c (do_set_command): Constify p.

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

9 years agoReplace (void *) cast with (gdb_byte *)
Simon Marchi [Sat, 24 Oct 2015 22:36:26 +0000 (18:36 -0400)]
Replace (void *) cast with (gdb_byte *)

Fixes:

/home/simark/src/binutils-gdb/gdb/nat/linux-ptrace.c:207:6: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive]
   pc = (void *) (uintptr_t) l;
         ^

gdb/ChangeLog:

* nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Replace
(void *) cast with (gdb_byte *).

9 years agoproc-service.c: Add (gdb_byte *) cast
Simon Marchi [Sat, 24 Oct 2015 22:36:25 +0000 (18:36 -0400)]
proc-service.c: Add (gdb_byte *) cast

A cast here is necessary, just as it's necessary in ps_pdwrite just
below.  The type of buf can't be changed, since it's fixed in the ps_pd*
API.

gdb/ChangeLog:

* proc-service.c (ps_pdread): Add cast.

9 years agosparc64-tdep.c: Don't assign using memcpy return
Simon Marchi [Sat, 24 Oct 2015 22:36:24 +0000 (18:36 -0400)]
sparc64-tdep.c: Don't assign using memcpy return

This:

  valbuf = memcpy (buf, valbuf, len);

causes a build failure in C++, because memcpy returns the value of
"buf" as a void *.  Instead of adding a cast, we can just do the
assignment separately.

gdb/ChangeLog:

* sparc64-tdep.c (sparc64_store_arguments): Split assignment of
valbuf.

9 years agoia64-tdep.c: Remove (void *) casts
Simon Marchi [Sat, 24 Oct 2015 22:36:23 +0000 (18:36 -0400)]
ia64-tdep.c: Remove (void *) casts

Remove these (void *) casts, which cause a build failure in C++ mode.

gdb/ChangeLog:

* ia64-tdep.c (ia64_pseudo_register_write): Remove cast.
(ia64_push_dummy_call): Remove cast and change type of "to" to
array of gdb_byte.

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

9 years agoAdd mmap casts in linux-btrace.c
Simon Marchi [Fri, 23 Oct 2015 23:48:48 +0000 (19:48 -0400)]
Add mmap casts in linux-btrace.c

gdb/ChangeLog:

* linux-btrace.c (linux_enable_pt): Add cast to mmap return.

9 years agoAdd cast to observer.sh
Simon Marchi [Fri, 23 Oct 2015 20:58:13 +0000 (16:58 -0400)]
Add cast to observer.sh

gdb/ChangeLog:

* observer.h (observer_${event}_notification_stub): Add cast.

9 years agoRemove set_breakpoint_data definition in GDBServer.
Antoine Tremblay [Fri, 23 Oct 2015 17:20:39 +0000 (13:20 -0400)]
Remove set_breakpoint_data definition in GDBServer.

This patch removes the now unused set_breakpoint_data function from mem_break.h

gdb/gdbserver/ChangeLog:

* mem-break.h (set_breakpoint_data): Remove.

9 years agoFix nto,spu and win32 builds of GDBServer.
Antoine Tremblay [Fri, 23 Oct 2015 17:20:39 +0000 (13:20 -0400)]
Fix nto,spu and win32 builds of GDBServer.

This patch fixes the build that was broken by :
https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

It implements the sw_breakpoint_from_kind operation on these targets and removes
the calls to set_breakpoint_data.

Compiliation tested on win32.

Not tested : nto, spu.

gdb/gdbserver/ChangeLog:

* nto-low.c (nto_sw_breakpoint_from_kind): New function.
(struct target_ops) <sw_breakpoint_from_kind>: Initialize.
(initialize_low): Remove set_breakpoint_data call.
* spu-low.c (spu_sw_breakpoint_from_kind): New function.
(struct target_ops) <sw_breakpoint_from_kind>: Iniitalize.
(initialize_low): Remove set_breakpoint_data call.
* win32-low.c (win32_sw_breakpoint_from_kind): New function.
(struct target_ops) <sw_breakpoint_from_kind>: Initialize.
(initialize_low): Remove set_breakpoint_data call.

9 years agoRefactor default_breakpoint_kind_from_pc to be used by all targets in GDBServer.
Antoine Tremblay [Fri, 23 Oct 2015 17:20:39 +0000 (13:20 -0400)]
Refactor default_breakpoint_kind_from_pc to be used by all targets in GDBServer.

This patch moves default_breakpoint_kind_from_pc to target.c and creates a macro
so that all targets can easily use it.

This allows the breakpoint_kind_from_pc operation to be left unimplemented in
targets that do not need it.

This is preparation to fix the win32/nto/spu build that was broken by this
patch: https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended}

gdb/gdbserver/ChangeLog:

* linux-low.c (default_breakpoint_kind_from_pc): Move to target.c.
* mem-break.c (set_breakpoint_at): Use target_breakpoint_kind_from_pc.
* target.c (default_breakpoint_kind_from_pc): Moved from linux-low.c
* target.h (target_breakpoint_kind_from_pc): New macro.

9 years agoHandle __start_* and __stop_* symbols in --gc-sections
Alan Modra [Fri, 23 Oct 2015 11:53:05 +0000 (22:23 +1030)]
Handle __start_* and __stop_* symbols in --gc-sections

PR ld/11133
PR ld/19161
PR ld/19167
* elflink.c (_bfd_elf_gc_mark_hook): Delete code handling __start_*
and __stop_* symbol refs.
(_bfd_elf_gc_mark_rsec): Add start_stop parameter.  Handle __start_*
and __stop_* symbol refs here..
(_bfd_elf_gc_mark_reloc): ..and here.
* elf-bfd.h (_bfd_elf_gc_mark_hook): Update prototype.
* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Update
_bfd_elf_gc_mark_rsec call.

9 years agoAdd a test for PR ld/19167
H.J. Lu [Fri, 23 Oct 2015 11:23:51 +0000 (04:23 -0700)]
Add a test for PR ld/19167

PR ld/19167
* ld-gc/gc.exp: Run pr19167 test.
* ld-gc/pr19167.d: New file.
* ld-gc/pr19167a.s: Likewise.
* ld-gc/pr19167b.s: Likewise.

9 years agoInitialize field insn_count correctly
Yao Qi [Wed, 21 Oct 2015 14:50:55 +0000 (15:50 +0100)]
Initialize field insn_count correctly

This patch initialize dsd.insn_count, otherwise, it triggers the assert
below on testings we did recently.

gdb:

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

* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Set
dsd.insn_count to zero.

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

9 years agoRe: Always keep sections marked with SEC_KEEP
Alan Modra [Thu, 22 Oct 2015 23:44:51 +0000 (10:14 +1030)]
Re: Always keep sections marked with SEC_KEEP

Revert bba037e0, it breaks the gc-sections model.  Instead fix the
underlying problem which is that _bfd_elf_gc_mark_hook is too late to
be setting SEC_KEEP.

PR ld/11133
PR ld/19161
* elflink.c (elf_gc_sweep): Revert last patch.
(_bfd_elf_gc_mark_hook): Don't set SEC_KEEP here.

9 years agoAlways keep sections marked with SEC_KEEP
H.J. Lu [Thu, 22 Oct 2015 19:17:43 +0000 (12:17 -0700)]
Always keep sections marked with SEC_KEEP

SEC_KEEP check in elf_gc_sweep was missing in commit:

commit bde6f3eb6dff94cea1d471e15c6154d55d49820f
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 8 01:43:23 2010 +0000

    Set SEC_KEEP on section XXX for undefined __start_XXX/__stop_XXX

    bfd/

    2010-01-07  H.J. Lu  <hongjiu.lu@intel.com>

      PR ld/11133
      * elflink.c (_bfd_elf_gc_mark_hook): Check section XXX for
      undefined __start_XXX/__stop_XXX in all input files and set
      SEC_KEEP.

This patch adds SEC_KEEP check to elf_gc_sweep.

bfd/

PR ld/19161
* elflink.c (elf_gc_sweep): Always keep sections marked with
SEC_KEEP.

ld/testsuite/

PR ld/19161
* ld-gc/gc.exp: Run pr19161 test.
* ld-gc/pr19161-1.c: New file.
* ld-gc/pr19161-2.c: Likewise.
* ld-gc/pr19161.d: Likewise.

9 years agogarbage collect gdb/infrun.c:stop_after_trap
Pedro Alves [Sun, 18 Oct 2015 11:32:47 +0000 (12:32 +0100)]
garbage collect gdb/infrun.c:stop_after_trap

No longer used anywhere.

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

* infrun.c (stop_after_trap): Delete.
(clear_proceed_status, handle_signal_stop, struct
infcall_control_state, save_infcall_control_state)
(restore_infcall_control_state): Remove references to
stop_after_trap.

9 years agoFix inconsistent breakpoint kinds between breakpoints and tracepoints in GDBServer.
Antoine Tremblay [Thu, 22 Oct 2015 16:21:51 +0000 (12:21 -0400)]
Fix inconsistent breakpoint kinds between breakpoints and tracepoints in GDBServer.

This patch fixes a regression introduced by :
https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

Tests : gdb.trace/trace-break.exp and gdb.trace/trace-mt.exp would fail on x86
with gdbserver-{native,extended}.

Before this patch, the breakpoint kind set by GDB with a Z packet and the one
set in the case of a tracepoint would be inconsistent on targets that did not
implement breakpoint_kind_from_pc. On x86 for example a breakpoint set by GDB
would have a kind of 1 but a breakpoint set by a tracepoint would have a kind of
0.

This created a missmatch when trying to insert a tracepoint and a breakpoint at
the same location. One of the two breakpoints would be removed with debug
message : "Inconsistent breakpoint kind".

This patch fixes the issue by changing the default 0 breakpoint kind to be
the size of the breakpoint according to sw_breakpoint_from_kind.

The default breakpoint kind must be the breakpoint length to keep consistency
between breakpoints set via GDB and the ones set internally by GDBServer.

No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended}

gdb/gdbserver/ChangeLog:

* linux-low.c (default_breakpoint_kind_from_pc): New function.
(linux_breakpoint_kind_from_pc): Use default_breakpoint_kind_from_pc for
the default breakpoint kind.

9 years agoAdd cast in python.c
Simon Marchi [Thu, 22 Oct 2015 16:13:19 +0000 (12:13 -0400)]
Add cast in python.c

gdb/ChangeLog:

* python/python.c (_initialize_python): Add cast.

9 years agoAdd cast in nto-tdep.c
Simon Marchi [Thu, 22 Oct 2015 15:58:38 +0000 (11:58 -0400)]
Add cast in nto-tdep.c

gdb/ChangeLog:

* nto-tdep.c (nto_inferior_data): Add cast.

9 years agogdb/Windows: use windows_wait/windows_resume directly in initial startup
Pedro Alves [Thu, 22 Oct 2015 15:40:45 +0000 (16:40 +0100)]
gdb/Windows: use windows_wait/windows_resume directly in initial startup

Explation below based on what Joel wrote at:

  https://sourceware.org/ml/gdb-patches/2015-10/msg00274.html

The merge async/sync code paths patch broke attaching on Windows.

This is what we observe, after attaching to any process.  At first, it
seems like everything worked fine, since the process stops, and we get
the prompt back:

    (gdb) att 3156
    Attaching to program `C:\[...]\foo.exe', process 3156
    [New Thread 3156.0xcd8]
    [New Thread 3156.0xfe4]
    0x7770000d in ntdll!DbgBreakPoint () from C:\Windows\SysWOW64\ntdll.dll
    (gdb)

However, enter any commands at all, and GDB appears to be hanging.
For instance:

    (gdb) set lang ada
    [nothing happens]

Despite appearances, GDB is not reading from the prompt.  It is
blocked waiting for an event from the inferior.  And since our
inferior is stopped, there aren't going to be any events to read.

In chronological order, what happens is that windows_attach calls
do_initial_windows_stuff, which performs the inferior creation,
and repeatedly waits until we get the first SIGTRAP:

  while (1)
    {
      stop_after_trap = 1;
      wait_for_inferior ();
      tp = inferior_thread ();
      if (tp->suspend.stop_signal != GDB_SIGNAL_TRAP)
        resume (tp->suspend.stop_signal);
      else
        break;
    }

The call to wait_for_inferior triggers a call to do_target_wait to get
the event, followed by handle_inferior_event to process it.  However,
because the first couple of events are "spurious" events, GDB resumes
the execution, and prepares the inferior to wait again:

    case TARGET_WAITKIND_SPURIOUS:
      [...]
      resume (GDB_SIGNAL_0);
      prepare_to_wait (ecs);

And prepare_to_wait just does...

  ecs->wait_some_more = 1;
  if (!target_is_async_p ())
    mark_infrun_async_event_handler ();

... which as a result sets the infrun_async_event_handler "ready"
flag to 1.

We get a couple of spurious events before we get the initial SIGTRAP,
at which point we exit the "while (1)" loop above, after which we
reach the end of the attach_command, followed by the normal
end-of-command processing (normal_stop, bp handling, printing the GDB
prompt), back finally to the root of the event loop.

Notice that, at this point, nothing has unset the "ready" flag for the
infrun_async_event_handler.  So, when another cycle of
gdb_do_one_event from the event loop, we eventually call
check_async_event_handlers, which finds that the infrun async event
handler is "ready", and therefore calls it's associated "proc"
callback, which does...

      inferior_event_handler (INF_REG_EVENT, NULL);

... triggering a blocking call to target_wait, thus hanging forever.

The fix is to use windows_wait and windows_resume directly, similarly
to gdbserver.  This will also allow getting rid of 'stop_after_trap'.

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

* windows-nat.c (do_initial_windows_stuff): Rewrite loop using
windows_wait and windows_resume directly instead of
wait_for_inferior and resume.

9 years agoAdd support for MSP430 silicon errata to the assembler.
Nick Clifton [Thu, 22 Oct 2015 15:25:46 +0000 (16:25 +0100)]
Add support for MSP430 silicon errata to the assembler.

* config/tc-msp430.c (PUSH_1X_WORKAROUND): Delete.
(OPTION_SILICON_ERRATA): Define.
(OPTION_SILICON_WARN): Define.
(md_parse_opton): Handle silicon errata options.
(md_longopts): Add silicon errata options.
(ms_show_usage): Report silicon errata options.
(msp430_srcoperand): Handle silicon errata.
(msp430_operands): Likewise. Improve nop insertion.
(msp430_fix_adjustable): Update warning generation.
* doc/c-msp430.texi: Document silicon errata options.

tests * gas/msp430/errata_fixes.s: New test source file.
* gas/msp430/errata_fixes.d: New test control file.
* gas/msp430/errata_warns.s: New test source file.
* gas/msp430/errata_warns.d: New test control file.
* gas/msp430/errata_warns.l: New test message file.
* gas/msp430/msp430.exp: Run the new tests.
* gas/msp430/bad.l: Update expected warning messages
* gas/msp430/msp430.exp: Run the new tests.

9 years agoProperly check --enable-compressed-debug-sections={yes,all}
H.J. Lu [Thu, 22 Oct 2015 14:44:05 +0000 (07:44 -0700)]
Properly check --enable-compressed-debug-sections={yes,all}

gas/

* configure.ac: Properly check
--enable-compressed-debug-sections={yes,all}.
* configure: Regenerated.

ld/

* configure.ac: Properly check
--enable-compressed-debug-sections={yes,all}.
* configure: Regenerated.

9 years agobfd/mmo.c: handle "objcopy --extract-symbols" generating and reading back.
Hans-Peter Nilsson [Thu, 22 Oct 2015 07:32:30 +0000 (09:32 +0200)]
bfd/mmo.c: handle "objcopy --extract-symbols" generating and reading back.

bfd:
* mmo.c (struct mmo_data_struct): New members
symbol_consistency_override_calculated and ignore_symbol_consistency.
(mmo_section_has_contents, mmo_ignore_symbol_consistency): New
functions.
(mmo_create_symbol): Check with mmo_ignore_symbol_consistency if to
report an error for unexpected value of Main.
(mmo_write_symbols_and_terminator): Similar.

9 years agoAllow mmix-knuth-mmixware adjustments to objcopy --extract-symbols test.
Hans-Peter Nilsson [Thu, 22 Oct 2015 07:28:40 +0000 (09:28 +0200)]
Allow mmix-knuth-mmixware adjustments to objcopy --extract-symbols test.

* ld-scripts/script.exp (extract_symbol_test): Allow nm output of
objcopy --extract-symbols result to differ from original on
mmix-knuth-mmixware.

9 years agobinutils/objcopy.c (setup_section): missing extract_symbol part
Hans-Peter Nilsson [Thu, 22 Oct 2015 14:12:35 +0000 (16:12 +0200)]
binutils/objcopy.c (setup_section): missing extract_symbol part

* objcopy.c (setup_section): Don't omit bfd_copy_private_bfd_data
call when extract_symbol.

9 years agoxtensa: Fix implicit enum conversions
Simon Marchi [Thu, 22 Oct 2015 13:46:32 +0000 (09:46 -0400)]
xtensa: Fix implicit enum conversions

XTREG is used with raw numbers, like:

...
  XTREG( 78,312,32, 4, 4,0x02d7,0x0007,-2, 2,0x1000,excsave7,    0,0,0,0,0,0)
  XTREG( 79,316, 8, 4, 4,0x02e0,0x0007,-2, 2,0x1000,cpenable,    0,0,0,0,0,0)
  XTREG( 80,320,22, 4, 4,0x02e2,0x000b,-2, 2,0x1000,interrupt,   0,0,0,0,0,0)
  XTREG( 81,324,22, 4, 4,0x02e2,0x000d,-2, 2,0x1000,intset,      0,0,0,0,0,0)
...

So just add the explicit cast to the macro.

In file included from /home/pedro/gdb/mygit/src/gdb/xtensa-config.c:25:0:
/home/pedro/gdb/mygit/src/gdb/xtensa-tdep.h:289:2: error: invalid conversion from â€˜int’ to â€˜call_abi_t’ [-fpermissive]
  }
  ^

gdb/ChangeLog:

* xtensa-tdep.h (XTREG): Add casts.
(XTREG_END): Likewise.

9 years agosolib-spu: Add gdb_byte* cast
Simon Marchi [Thu, 22 Oct 2015 13:46:31 +0000 (09:46 -0400)]
solib-spu: Add gdb_byte* cast

Fixes this error:

/home/simark/src/binutils-gdb/gdb/solib-spu.c: In function â€˜file_ptr spu_bfd_iovec_pread(bfd*, void*, void*, file_ptr, file_ptr)’:
/home/simark/src/binutils-gdb/gdb/solib-spu.c:299:55: error: invalid conversion from â€˜void*’ to â€˜gdb_byte* {aka unsigned char*}’ [-fpermissive]
   ret = target_read_memory (addr + offset, buf, nbytes);
                                                       ^
In file included from /home/simark/src/binutils-gdb/gdb/target.h:65:0,
                 from /home/simark/src/binutils-gdb/gdb/exec.h:23,
                 from /home/simark/src/binutils-gdb/gdb/gdbcore.h:29,
                 from /home/simark/src/binutils-gdb/gdb/solib-spu.c:23:
/home/simark/src/binutils-gdb/gdb/target/target.h:35:12: note:   initializing argument 2 of â€˜int target_read_memory(CORE_ADDR, gdb_byte*, ssize_t)’
 extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,

gdb/ChangeLog:

* solib-spu.c (spu_bfd_iovec_pread): Add (gdb_byte *) cast.

9 years agors6000: Add cast for int to enum conversion
Simon Marchi [Thu, 22 Oct 2015 13:46:29 +0000 (09:46 -0400)]
rs6000: Add cast for int to enum conversion

Fixes this error:

/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c:3091:1: error: invalid conversion from â€˜int’ to â€˜bfd_architecture’ [-fpermissive]
 };
 ^
/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c: In function â€˜void powerpc_set_vector_abi(char*, int, cmd_list_element*)’:
/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c:6063:28: error: invalid conversion from â€˜int’ to â€˜powerpc_vector_abi’ [-fpermissive]
  powerpc_vector_abi_global = vector_abi;
                            ^

gdb/ChangeLog:

* rs6000-tdep.c (variants): Add (enum bfd_architecture) cast.

9 years agomips: fix void*/gdb_byte* compilation errors
Simon Marchi [Thu, 22 Oct 2015 13:46:28 +0000 (09:46 -0400)]
mips: fix void*/gdb_byte* compilation errors

The error in mips64_linux_get_longjmp_target is fixed by changing "buf"
to be a gdb_byte*, as usual.  supply_32bit_reg and mips64_fill_gregset
do some more complicated things however, so it's safer just to add the
explicit cast and avoid changing the code too much.

gdb/ChangeLog:

* mips-linux-tdep.c (mips64_linux_get_longjmp_target): Change type of
buf to gdb_byte*.
(supply_32bit_reg): Add cast.
(mips64_fill_gregset): Likewise.

9 years agoHandle --enable-compressed-debug-sections=ld,gas
H.J. Lu [Thu, 22 Oct 2015 12:18:21 +0000 (05:18 -0700)]
Handle --enable-compressed-debug-sections=ld,gas

gas/

PR gas/19109
* configure.ac: Handle --enable-compressed-debug-sections=*,gas,*.
* configure: Regenerated.

ld/

PR gas/19109
* configure.ac: Handle --enable-compressed-debug-sections=*,ld,*.
* configure: Regenerated.

9 years agoGold: Don't fail on R_X86_64_[REX_]GOTPCRELX relocations
H.J. Lu [Thu, 22 Oct 2015 11:56:10 +0000 (04:56 -0700)]
Gold: Don't fail on R_X86_64_[REX_]GOTPCRELX relocations

This patch updates gold to treat the R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX relocations proposed in

https://groups.google.com/forum/#!topic/x86-64-abi/n9AWHogmVY0

the same as R_X86_64_GOTPCREL.  FIXME: Gold should perform the
transformations as suggested.

elfcpp/

* x86_64.h (R_X86_64_GOTPCRELX): New.
(R_X86_64_REX_GOTPCRELX): Likewise.

gold/

* x86_64.cc (Target_x86_64<size>::Scan::get_reference_flags):
Treat R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX the same
as R_X86_64_GOTPCREL.
(Target_x86_64<size>::Scan::local): Likewise.
(Target_x86_64<size>::Scan::possible_function_pointer_reloc):
Likewise.
(Target_x86_64<size>::Scan::global): Likewise.
(Target_x86_64<size>::Relocate::relocate): Likewise.
(Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc):
Likewise.

9 years agoGold: Don't fail on R_386_GOT32X relocation
H.J. Lu [Thu, 22 Oct 2015 11:54:42 +0000 (04:54 -0700)]
Gold: Don't fail on R_386_GOT32X relocation

This patch updates gold to treat the R_386_GOT32X relocation proposed in

https://groups.google.com/forum/#!topic/ia32-abi/GbJJskkid4I

the same as R_386_GOT32.  FIXME: Gold should perform the transformations
as suggested.

elfcpp/

* i386.h (R_386_GOT32X): New.

gold/

* i386.cc (Target_i386::Scan::get_reference_flags(): Treat
R_386_GOT32X the same as R_386_GOT32.
(Target_i386::Scan::local): Likewise.
(Target_i386::Scan::possible_function_pointer_reloc): Likewise.
(Target_i386::Scan::global): Likewise.
(Target_i386::Relocate::relocate): Likewise.
(Target_i386::Relocatable_size_for_reloc::get_size_for_reloc):
Likewise.

9 years agoAdd "-z call-nop=PADDING" option to ld
H.J. Lu [Thu, 22 Oct 2015 11:53:04 +0000 (04:53 -0700)]
Add "-z call-nop=PADDING" option to ld

The ld linker can transform indirect call to a locally defined function,
foo, via its GOT slot, to either "NOP call foo" or "call foo NOP" where
NOP is a 1-byte NOP padding.  This patch adds a "-z call-nop=PADDING"
option to x86 ld to control 1-byte NOP padding for x86 call instruction.
PADDING is one of prefix-addr, prefix-nop, suffix-nop, prefix-NUMBER or
suffix-NUMBER.

bfd/

* elf32-i386.c (elf_i386_convert_load): Use call_nop_byte and
check call_nop_as_suffix for 1-byte NOP padding to pad call.
* elf64-x86-64.c (elf_x86_64_convert_load): Likewise.

include/

* bfdlink.h (bfd_link_info): Add call_nop_as_suffix and
call_nop_byte.

ld/

* ld/ld.texinfo: Document "-z call-nop=PADDING" option.
* emulparams/call_nop.sh: New file.
* emulparams/elf_i386_be.sh: Source
${srcdir}/emulparams/call_nop.sh.
* emulparams/elf_i386_chaos.sh: Likewise.
* emulparams/elf_i386_ldso.sh: Likewise.
* emulparams/elf_i386_vxworks.sh: Likewise.
* emulparams/elf_iamcu.sh: Likewise.
* emulparams/elf_k1om.sh: Likewise.
* emulparams/elf_l1om.sh: Likewise.
* emulparams/elf_x86_64.sh: Likewise.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set
link_info.call_nop_byte if $CALL_NOP_BYTE isn't empty.

ld/testsuite/

* ld-i386/call3.s: New file.
* ld-i386/call3a.d: Likewise.
* ld-i386/call3b.d: Likewise.
* ld-i386/call3c.d: Likewise.
* ld-i386/call3d.d: Likewise.
* ld-i386/call3e.d: Likewise.
* ld-i386/call3f.d: Likewise.
* ld-i386/call3g.d: Likewise.
* ld-i386/call3h.d: Likewise.
* ld-i386/load1-nacl.d: Likewise.
* ld-x86-64/call1.s: Likewise.
* ld-x86-64/call1a.d: Likewise.
* ld-x86-64/call1b.d: Likewise.
* ld-x86-64/call1c.d: Likewise.
* ld-x86-64/call1d.d: Likewise.
* ld-x86-64/call1e.d: Likewise.
* ld-x86-64/call1f.d: Likewise.
* ld-x86-64/call1g.d: Likewise.
* ld-x86-64/call1h.d: Likewise.
* ld-x86-64/call1i.d: Likewise.
* ld-x86-64/load1a-nacl.d: Likewise.
* ld-x86-64/load1b-nacl.d: Likewise.
* ld-x86-64/load1c-nacl.d: Likewise.
* ld-x86-64/load1d-nacl.d: Likewise.

9 years agoAdd R_X86_64_[REX_]GOTPCRELX support to gas and ld
H.J. Lu [Thu, 22 Oct 2015 11:49:20 +0000 (04:49 -0700)]
Add R_X86_64_[REX_]GOTPCRELX support to gas and ld

This patch adds support for the R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX relocations proposed in

https://groups.google.com/forum/#!topic/x86-64-abi/n9AWHogmVY0

to gas and ld.  It updates gas to generate R_X86_64_GOTPCRELX,
R_X86_64_REX_GOTPCRELX if there is a REX prefix, relocation for memory
operand, foo@GOTPCREL(%rip).  With the locally defined symbol, foo, we
convert

  mov foo@GOTPCREL(%rip), %reg

to

   lea foo(%rip), %reg

and convert

   call/jmp *foo@GOTPCREL(%rip)
to

   nop call foo/jmp foo nop

When PIC is false, convert

   test %reg, foo@GOTPCREL(%rip)
to

test $foo, %reg

and convert

   binop foo@GOTPCREL(%rip), %reg

to

   binop $foo, %reg

where binop is one of adc, add, and, cmp, or, sbb, sub, xor instructions.

bfd/

* elf64-x86-64.c: Include opcode/i386.h.
(x86_64_elf_howto_table): Add R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX.
(R_X86_64_standard): Replace R_X86_64_PLT32_BND with
R_X86_64_REX_GOTPCRELX.
(x86_64_reloc_map): Add BFD_RELOC_X86_64_GOTPCRELX and
BFD_RELOC_X86_64_REX_GOTPCRELX.
(need_convert_mov_to_lea): Renamed to ...
(need_convert_load): This.
(elf_x86_64_check_relocs): Handle R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX.  Replace need_convert_mov_to_lea with
need_convert_load.
(elf_x86_64_gc_sweep_hook): Handle R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX.
(elf_x86_64_size_dynamic_sections): Likewise.
(elf_x86_64_relocate_section): Likewise.
(elf_x86_64_convert_mov_to_lea): Renamed to ...
(elf_x86_64_convert_load): This.  Replace need_convert_mov_to_lea
with need_convert_load.  Support R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX transformations.
* reloc.c (BFD_RELOC_X86_64_GOTPCRELX): New.
(BFD_RELOC_X86_64_REX_GOTPCRELX): Likewise.
* bfd-in2.h: Regenerated.
* libbfd.h: Likewise.

gas/

* config/tc-i386.c (tc_i386_fix_adjustable): Handle
BFD_RELOC_X86_64_GOTPCRELX and BFD_RELOC_X86_64_REX_GOTPCRELX.
(tc_gen_reloc): Likewise.
(i386_validate_fix): Generate BFD_RELOC_X86_64_GOTPCRELX or
BFD_RELOC_X86_64_REX_GOTPCRELX if fx_tcbit2 is set.
* config/tc-i386.h (TC_FORCE_RELOCATION_LOCAL): Also return
true for BFD_RELOC_X86_64_GOTPCRELX and
BFD_RELOC_X86_64_REX_GOTPCRELX.

gas/testsuite/

* gas/i386/i386.exp: Run x86-64-gotpcrel.
* gas/i386/x86-64-gotpcrel.d: New file.
* gas/i386/x86-64-gotpcrel.s: Likewise.
* gas/i386/ilp32/x86-64-gotpcrel.d: Likewise.
* gas/i386/x86-64-localpic.d: Replace R_X86_64_GOTPCREL with
R_X86_64_REX_GOTPCRELX.
* gas/i386/ilp32/x86-64-localpic.d: Likewise.

include/elf/

* x86-64.h (R_X86_64_GOTPCRELX): New.
(R_X86_64_REX_GOTPCRELX): Likewise.

ld/testsuite/

* ld-ifunc/ifunc-5r-local-x86-64.d: Replace R_X86_64_GOTPCREL
with R_X86_64_REX_GOTPCRELX.
* ld-x86-64/plt-main1.rd: Likewise.
* ld-x86-64/plt-main3.rd: Likewise.
* ld-x86-64/plt-main4.rd: Likewise.
* ld-x86-64/gotpcrel1.dd: New file.
* ld-x86-64/gotpcrel1.out: Likewise.
* ld-x86-64/gotpcrel1a.S: Likewise.
* ld-x86-64/gotpcrel1b.c: Likewise.
* ld-x86-64/gotpcrel1c.c: Likewise.
* ld-x86-64/gotpcrel1d.S: Likewise.
* ld-x86-64/load1.s: Likewise.
* ld-x86-64/load1a.d: Likewise.
* ld-x86-64/load1b.d: Likewise.
* ld-x86-64/load1c.d: Likewise.
* ld-x86-64/load1d.d: Likewise.
* ld-x86-64/x86-64.exp: Run load1a, load1b, load1c and load1d
tests.  Run gotpcrel1 test.

9 years agoAdd R_386_GOT32X support to gas and ld
H.J. Lu [Thu, 22 Oct 2015 11:46:51 +0000 (04:46 -0700)]
Add R_386_GOT32X support to gas and ld

This patch adds support for the R_386_GOT32X relocation proposed in

https://groups.google.com/forum/#!topic/ia32-abi/GbJJskkid4I

to gas and ld.  It updates gas to generate R_386_GOT32X relocation for
memory operand, foo@GOT[(%reg)].  We must encode "mov foo@GOT, %eax"
with the 0x8b opcode, instead of the 0xb8 opcode, so that it can be
transformed to "lea foo, %eax".  With the locally defined symbol, foo,
we convert

   mov foo@GOT[(%reg1)], %reg2
to
   lea foo[@GOTOFF(%reg1)], %reg2

and convert

   call/jmp *foo@GOT[(%reg)]
to

   nop call foo/jmp foo nop

When PIC is false, convert

   test %reg1, foo@GOT[(%reg2)]
to
   test $foo, %reg1

and convert

binop foo@GOT[(%reg1)], %reg2

to

binop $foo, %reg2

where binop is one of adc, add, and, cmp, or, sbb, sub, xor instructions.

bfd/

* elf32-i386.c: Include opcode/i386.h.
(elf_howto_table): Add R_386_GOT32X.
(R_386_ext2): Replace R_386_IRELATIVE with R_386_GOT32X.
(elf_i386_reloc_type_lookup): Handle BFD_RELOC_386_GOT32X.
(need_convert_mov_to_lea): Renamed to ...
(need_convert_load): This.
(elf_i386_check_relocs): Handle R_386_GOT32X.  Replace
need_convert_mov_to_lea with need_convert_load.
(elf_i386_gc_sweep_hook): Handle R_386_GOT32X.
(elf_i386_size_dynamic_sections): Likewise.
(elf_i386_relocate_section): Likewise.
(elf_i386_convert_mov_to_lea): Renamed to ...
(elf_i386_convert_load): This.  Replace need_convert_mov_to_lea
with need_convert_load.  Support R_386_GOT32X transformations.
* reloc.c (BFD_RELOC_386_GOT32X): New.
* bfd-in2.h: Regenerated.
* libbfd.h: Likewise.

gas/

* config/tc-i386.c (tc_i386_fix_adjustable): Handle
BFD_RELOC_386_GOT32X.
(tc_gen_reloc): Likewise.
(match_template): Force 0x8b encoding for "mov foo@GOT, %eax".
(output_disp): Check for "call/jmp *mem", "mov mem, %reg",
"test %reg, mem" and "binop mem, %reg" where binop is one of
adc, add, and, cmp, or, sbb, sub, xor instructions.  Set
fx_tcbit if the REX prefix is generated.  Set fx_tcbit2 if
BFD_RELOC_386_GOT32X should be generated.
(i386_validate_fix): Generate BFD_RELOC_386_GOT32X if fx_tcbit2
is set.

gas/testsuite/

* gas/i386/got.d: New file.
* gas/i386/got.s: Likewise.
* gas/i386/i386.exp: Run got.
* gas/i386/localpic.d: Replace R_386_GOT32 with R_386_GOT32X.
* gas/i386/mixed-mode-reloc32.d: Likewise.
* gas/i386/reloc32.d: Likewise.

include/elf/

* i386.h (R_386_GOT32X): New relocation.

ld/testsuite/

* ld-i386/branch1.d: New file.
* ld-i386/branch1.s: Likewise.
* ld-i386/call1.d: Likewise.
* ld-i386/call1.s: Likewise.
* ld-i386/call2.d: Likewise.
* ld-i386/call2.s: Likewise.
* ld-i386/got1.dd: Likewise.
* ld-i386/got1.out: Likewise.
* ld-i386/got1a.S: Likewise.
* ld-i386/got1b.c: Likewise.
* ld-i386/got1c.c: Likewise.
* ld-i386/got1d.S: Likewise.
* ld-i386/jmp1.d: Likewise.
* ld-i386/jmp1.s: Likewise.
* ld-i386/jmp2.d: Likewise.
* ld-i386/jmp2.s: Likewise.
* ld-i386/load1.d: Likewise.
* ld-i386/load1.s: Likewise.
* ld-i386/load2.d: Likewise.
* ld-i386/load2.s: Likewise.
* ld-i386/load3.d: Likewise.
* ld-i386/load3.s: Likewise.
* ld-i386/load4.s: Likewise.
* ld-i386/load4a.d: Likewise.
* ld-i386/load4b.d: Likewise.
* ld-i386/load5.s: Likewise.
* ld-i386/load5a.d: Likewise.
* ld-i386/load5b.d: Likewise.
* ld-i386/load6.d: Likewise.
* ld-i386/load6.s: Likewise.
* ld-i386/i386.exp: Run branch1, call1, call2, jmp1, jmp2,
load1, load2, load3, load4a, load4b, load5a, load5b and load6
tests.  Run got1 test.

9 years agoS/390: ifunc: Redirect local function calls to the IPLT.
Andreas Krebbel [Mon, 19 Oct 2015 13:44:35 +0000 (15:44 +0200)]
S/390: ifunc: Redirect local function calls to the IPLT.

bfd/ChangeLog:

* elf32-s390.c (elf_s390_check_relocs): Set the non_got_ref marker
only when linking an executable.
(elf_s390_relocate_section): Redirect PC-relative relocs to a IPLT
slot.
* elf64-s390.c (elf_s390_check_relocs): Set the non_got_ref marker
only when linking an executable.
(elf_s390_relocate_section): Redirect PC-relative relocs to a IPLT
slot.

9 years agoS/390: ifunc: Fix function pointers to hidden ifunc symbols.
Andreas Krebbel [Fri, 16 Oct 2015 19:49:43 +0000 (21:49 +0200)]
S/390: ifunc: Fix function pointers to hidden ifunc symbols.

bfd/ChangeLog:
* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Set the PLT
reference counters for local IFUNC calls.
* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.

9 years agoS/390: ifunc: Handle GOTOFF relocs on ifunc symbols.
Andreas Krebbel [Fri, 16 Oct 2015 19:07:17 +0000 (21:07 +0200)]
S/390: ifunc: Handle GOTOFF relocs on ifunc symbols.

Normally a GOTOFF reloc only uses the GOT pointer to address something
relativ to it without actually requiring a GOT or PLT slot.  Things
change if the target is an ifunc symbol though.

bfd/ChangeLog:

* elf32-s390.c (elf_s390_check_relocs): Fallthrough to the PLT
slot allocating code for GOTOFF relocs on ifunc symbols.
(elf_s390_gc_sweep_hook): Decrement plt refcount for GOTOFF relocs
on ifunc symbols.
(elf_s390_relocate_section): Redirect a GOTOFF reloc to an iplt
slot.

9 years agoS/390: ifunc: Fix PR18841.
Andreas Krebbel [Thu, 22 Oct 2015 08:11:07 +0000 (10:11 +0200)]
S/390: ifunc: Fix PR18841.

In order to get the ifunc relocs properly sorted the correct class
needs to be returned.  The code mimics what has been done for x86.

bfd/ChangeLog:

PR ld/18841
* elf32-s390.c (elf_s390_reloc_type_class): Return
reloc_class_ifunc for ifunc symbols.
* elf64-s390.c (elf_s390_reloc_type_class): Likewise.

9 years agoS/390: ifunc: Fix for undefined ifunc symbols.
Andreas Krebbel [Mon, 12 Oct 2015 15:33:28 +0000 (17:33 +0200)]
S/390: ifunc: Fix for undefined ifunc symbols.

bfd/ChangeLog:

* elf32-s390.c (elf_s390_finish_dynamic_symbol): Call
elf_s390_finish_ifunc_symbol only for actually defined symbols.
* elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise.

9 years agoS/390: ifunc: Enable the ifunc tests.
Andreas Krebbel [Mon, 12 Oct 2015 15:34:11 +0000 (17:34 +0200)]
S/390: ifunc: Enable the ifunc tests.

ld/testsuite/ChangeLog:

* ld-ifunc/ifunc.exp: Run ifunc tests on s390* targets.

9 years agoS/390: Get rid of superfluous parameter to s390_elf_allocate_ifunc_dyn_relocs.
Andreas Krebbel [Mon, 19 Oct 2015 11:08:27 +0000 (13:08 +0200)]
S/390: Get rid of superfluous parameter to s390_elf_allocate_ifunc_dyn_relocs.

bfd/ChangeLog:
* elf-s390-common.c (s390_elf_allocate_ifunc_dyn_relocs): Remove
`head' parameter.
* elf32-s390.c (allocate_dynrelocs): Don't use last parameter.
* elf64-s390.c (allocate_dynrelocs): Don't use last parameter.

9 years agoRun add-symbol test on mips
Alan Modra [Thu, 22 Oct 2015 02:14:24 +0000 (12:44 +1030)]
Run add-symbol test on mips

* binutils-all/add-symbol.d: Run test on mips.  Support either
order of NEW and NEWDATA symbols.

9 years agoFix tests for PR 18500, revisited
Alan Modra [Thu, 22 Oct 2015 00:28:47 +0000 (10:58 +1030)]
Fix tests for PR 18500, revisited

Correct commit a846e9c1.

PR gas/18500
* gas/arm/vfpv2-ldr_immediate.d: Use parentheses, not brackets,
to select alternatives.
* gas/arm/vfpv3-ldr_immediate.d: Likewise.
* gas/arm/vfpv3xd-ldr_immediate.d: Likewise.

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

9 years agoFix accessing a function's fields (parameters) from Python (PR 18073)
Simon Marchi [Wed, 21 Oct 2015 19:57:22 +0000 (15:57 -0400)]
Fix accessing a function's fields (parameters) from Python (PR 18073)

Since 7.4, gdb doesn't allow calling .fields() on a function type, even
though the documentation states it should return a list corresponding to
the function's parameters.  This patch restores the intended behaviour
and adds a test for it.

Reg-tested on Arch Linux x86-64.

gdb/ChangeLog:

PR python/18073
* python/py-type.c (typy_get_composite): Allow returning a
function type.

gdb/testsuite/ChangeLog:

PR python/18073
* gdb.python/py-type.c (C::a_method): New.
(C::a_const_method): New.
(C::a_static_method): New.
(a_function): New.
* gdb.python/py-type.exp (test_fields): Test getting fields
from function and method.

9 years agofort_dyn_array: add basic fortran dyn array support
Keven Boell [Wed, 21 Oct 2015 19:32:30 +0000 (15:32 -0400)]
fort_dyn_array: add basic fortran dyn array support

Fortran provide types whose values may be dynamically allocated
or associated with a variable under explicit program control.
The purpose of this commit is:

  * to read allocated/associated DWARF tags and store them in
    the dynamic property list of main_type.

  * enable GDB to print the value of a dynamic array in Fortran
    in case the type is allocated or associated (pointer to
    dynamic array).

Examples:
    (gdb) p vla_not_allocated
    $1 = <not allocated>

    (gdb) p vla_allocated
    $1 = (1, 2, 3)

    (gdb) p vla_ptr_not_associated
    $1 = <not associated>

    (gdb) p vla_ptr_associated
    $1 = (1, 2, 3)

Add basic test coverage for most dynamic array use-cases in Fortran.
The commit contains the following tests:
  * Ensure that values of Fortran dynamic arrays
    can be evaluated correctly in various ways and states.
  * Ensure that Fortran primitives can be evaluated
    correctly when used as a dynamic array.
  * Dynamic arrays passed to subroutines and handled
    in different ways inside the routine.
  * Ensure that the ptype of dynamic arrays in
    Fortran can be printed in GDB correctly.
  * Ensure that dynamic arrays in different states
    (allocated/associated) can be evaluated.
  * Dynamic arrays passed to functions and returned from
    functions.
  * History values of dynamic arrays can be accessed and
    printed again with the correct values.
  * Dynamic array evaluations using MI protocol.
  * Sizeof output of dynamic arrays in various states.

The patch was tested using the test suite on Ubuntu 12.04 64bit.

gdb/ChangeLog:

        * dwarf2read.c (set_die_type): Add read of
        DW_AT_allocated and DW_AT_associated.
        * f-typeprint.c: New include of typeprint.h
        (f_print_type): Add check for allocated/associated
        status of type.
        (f_type_print_varspec_suffix): Add check for
        allocated/associated status of type.
        * gdbtypes.c (create_array_type_with_stride):
        Add check for valid data location of type in
        case allocated or associated attributes are set.
        Length of an array should be only calculated if
        allocated or associated is resolved as true.
        (is_dynamic_type_internal): Add check for allocated/
        associated.
        (resolve_dynamic_array): Evaluate allocated/associated
        properties.
        * gdbtypes.h (enum dynamic_prop_node_kind): <DYN_PROP_ALLOCATED>
        <DYN_PROP_ASSOCIATED>: New enums.
        (TYPE_ALLOCATED_PROP, TYPE_ASSOCIATED_PROP): New macros.
        (type_not_allocated): New function.
        (type_not_associated): New function.
        * valarith.c (value_subscripted_rvalue): Add check for
        allocated/associated.
        * valprint.c: New include of typeprint.h.
        (valprint_check_validity): Add check for allocated/associated.
        (value_check_printable): Add check for allocated/
        associated.
        * typeprint.h (val_print_not_allocated): New function.
        (val_print_not_associated): New function.
        * typeprint.c (val_print_not_allocated): New function.
        (val_print_not_associated): New function.

gdb/testsuite/ChangeLog:

        * gdb.fortran/vla-alloc-assoc.exp: New file.
        * gdb.fortran/vla-datatypes.exp: New file.
        * gdb.fortran/vla-datatypes.f90: New file.
        * gdb.fortran/vla-history.exp: New file.
        * gdb.fortran/vla-ptype-sub.exp: New file.
        * gdb.fortran/vla-ptype.exp: New file.
        * gdb.fortran/vla-sizeof.exp: New file.
        * gdb.fortran/vla-sub.f90: New file.
        * gdb.fortran/vla-value-sub-arbitrary.exp: New file.
        * gdb.fortran/vla-value-sub-finish.exp: New file.
        * gdb.fortran/vla-value-sub.exp: New file.
        * gdb.fortran/vla-value.exp: New file.
        * gdb.fortran/vla-ptr-info.exp: New file.
        * gdb.mi/mi-vla-fortran.exp: New file.
        * gdb.mi/vla.f90: New file.

9 years agoAdjust timeout in gdb.base/freebpcmd.exp.
Sandra Loosemore [Wed, 21 Oct 2015 16:54:49 +0000 (09:54 -0700)]
Adjust timeout in gdb.base/freebpcmd.exp.

2015-10-21  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.base/freebpcmd.exp: Use with_timeout_factor instead
of hardwired timeout value.

9 years agoFix tests for PR 18500 so that they will pass for big-endian ARM toolchains.
Nick Clifton [Wed, 21 Oct 2015 16:25:28 +0000 (17:25 +0100)]
Fix tests for PR 18500 so that they will pass for big-endian ARM toolchains.

PR gas/18500
* gas/arm/vfpv3xd-ldr_immediate.d: Update test for big-endian ARM
toolchains.
* gas/arm/vfpv3-ldr_immediate.d: Likewise.
* gas/arm/vfpv2-ldr_immediate.d: Likewise.

9 years agoSupport software breakpoints for ARM linux in GDBServer.
Antoine Tremblay [Wed, 21 Oct 2015 15:13:42 +0000 (11:13 -0400)]
Support software breakpoints for ARM linux in GDBServer.

This patch enables software breakpoints via GDB's Z0 packets on ARM.

No regressions, tested on ubuntu 14.04 ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

gdb/gdbserver/ChangeLog:

* linux-arm-low.c (arm_supports_z_point_type): Add software
breakpoint support.

9 years agoRefactor the breakpoint definitions in linux-arm-low.c.
Antoine Tremblay [Wed, 21 Oct 2015 15:13:42 +0000 (11:13 -0400)]
Refactor the breakpoint definitions in linux-arm-low.c.

Before arm_sw_breakpoint_from_kind would use an #ifdef to return the right
arm_breakpoint from the abi or eabi breakpoint type.

arm_breakpoint_at would also check for the arm_breakpoint ||
arm_eabi_breakpoint.

Thus the selected arm_breakpoint would be what arm_sw_breakpoint_from_kind
returned and arm_breakpoint was arm_abi_breakpoint.

This patch makes it more clear by naming those for what they are : 2 separate
entities: arm_abi_breakpoint and arm_eabi_breakpoint and set the current used
one as arm_breakpoint.

This allows a cleaner arm_sw_breakpoint_from_kind as it just returns
arm_breakpoint rather than having the #ifdef in that function.

Any other reference to the arm_breakpoint can now also be clear of #ifdefs...

No regressions on Ubuntu 14.04 on ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

gdb/gdbserver/ChangeLog:

* linux-arm-low.c: Refactor breakpoint definitions.
(arm_breakpoint_at): Adjust for arm_abi_breakpoint.
(arm_sw_breakpoint_from_kind): Adjust for arm_breakpoint.

9 years agoImplement breakpoint_kind_from_pc and sw_breakpoint_from_kind for ARM in GDBServer.
Antoine Tremblay [Wed, 21 Oct 2015 15:13:41 +0000 (11:13 -0400)]
Implement breakpoint_kind_from_pc and sw_breakpoint_from_kind for ARM in GDBServer.

ARM can have multiple breakpoint types based on the instruction set
it's currently in: arm, thumb or thumb2.

GDBServer needs to know what breakpoint is to be inserted at location
when inserting a breakpoint.

This is handled by the breakpoint_kind_from_pc and sw_breakpoint_from_kind
target ops introduced in a previous patch, this patch adds the
arm_breakpoint_kind_from_pc and arm_sw_breakpoint_from_kind implementation so
that the proper breakpoint type is returned based on the pc.

Also in order to share some code with GDB a new file called arm.c have been
introduced in arch/.

While this file does not contain much yet future patches will add more
to it thus the inclusion at this stage.

No regressions on Ubuntu 14.04 on ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

gdb/ChangeLog:

* Makefile.in: Add arm.c/o.
* arch/arm.c: New file.
* arch/arm.h: (IS_THUMB_ADDR): Move macro from arm-tdep.c.
(MAKE_THUMB_ADDR): Likewise.
(UNMAKE_THUMB_ADDR): Likewise.
* arm-tdep.c (int thumb_insn_size): Move to arm.c.
(IS_THUMB_ADDR): Move to arm.h.
(MAKE_THUMB_ADDR): Likewise.
(UNMAKE_THUMB_ADDR): Likewise.
* configure.tgt: Add arm.o to all ARM configs.

gdb/gdbserver/ChangeLog:

* Makefile.in: Add arm.c/o.
* configure.srv: Likewise.
* linux-arm-low.c (arm_breakpoint_kinds): New enum.
(arm_breakpoint_kind_from_pc): New function.
(arm_sw_breakpoint_from_kind): Return proper kind.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize.

9 years agoSupport breakpoint kinds for software breakpoints in GDBServer.
Antoine Tremblay [Wed, 21 Oct 2015 15:13:40 +0000 (11:13 -0400)]
Support breakpoint kinds for software breakpoints in GDBServer.

There's two ways to set breakpoints in GDBServer.

 - GDBServer setting its own breakpoints, through API set_breakpoint_at.

 - GDBServer setting breakpoints according to the information in Z
   packets, through API set_gdb_breakpoint.

Before this patch the breakpoint kinds were a concept unique to GDB and Z
packets, as GDBServer never had to set different kinds of breakpoint on its
own.

This patch teaches GDBServer to handle breakpoint kinds for its own
breakpoints. It generalizes the breakpoint kind as per Z packets to
represent different kinds of breakpoints directly set by GDBServer also.

GDBServer now querys breakpoint_kind_from_pc to know what breakpoint kind to
set on its own.

As the kind is now a differentiating factor equivalent to size for the
breakpoint struct and that it's size can be queried using
sw_breakpoint_from_kind, the size field has been replaced with the kind field.
All references to size are now replaced by kind or a call to bp_size that wraps
sw_breakpoing_from_kind and returns the size of the breakpoint in memory.

To fetch the software breakpoint data bp_opcode is called and wraps the
sw_breakpoint_from_kind call.

No regressions on Ubuntu 14.04 on ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

gdb/gdbserver/ChangeLog:

* linux-low.c (initialize_low): Ajdust for breakpoint global variables
removal.
* mem-break.c : Remove breakpoint_data/breakpoint_len global variables.
(struct raw_breakpoint) <size>: Remove.
(struct raw_breakpoint) <kind>: Add.
(bp_size): New function.
(bp_opcode): Likewise.
(find_raw_breakpoint_at): Adjust for kind.
(insert_memory_breakpoint): Adjust for kind call bp_size,bp_opcode.
(remove_memory_breakpoint): Adjust for kind call bp_size.
(set_raw_breakpoint_at): Adjust for kind.
(set_breakpoint): Likewise.
(set_breakpoint_at): Call breakpoint_kind_from_pc.
(delete_raw_breakpoint): Adjust for kind.
(delete_breakpoint): Likewise.
(find_gdb_breakpoint): Likewise.
(set_gdb_breakpoint_1): Likewise.
(set_gdb_breakpoint): Likewise.
(delete_gdb_breakpoint_1): Likewise.
(delete_gdb_breakpoint): Likewise.
(uninsert_raw_breakpoint): Likewise.
(reinsert_raw_breakpoint): Likewise.
(set_breakpoint_data): Remove.
(validate_inserted_breakpoint): Adjust for kind call bp_size,bp_opcode.
(check_mem_read): Adjust for kind call bp_size.
(check_mem_write): Adjust for kind call bp_size,bp_opcode.
(clone_one_breakpoint): Adjust for kind.
* mem-break.h (set_gdb_breakpoint): Likewise.
(delete_gdb_breakpoint): Likewise.
* server.c (process_serial_event): Likewise.

9 years agoAdd the target_ops needed for software breakpoints in GDBServer.
Antoine Tremblay [Wed, 21 Oct 2015 15:17:26 +0000 (11:17 -0400)]
Add the target_ops needed for software breakpoints in GDBServer.

This patch is in preparation for software breakpoints on ARM linux.  It
refactors breakpoint and breakpoint_len into breakpoint_kind_from_pc and
sw_breakpoint_from kind to prepare the case where we have multiple types of
breakpoints.

Kind is the type of breakpoint (hardware or software) to be inserted, usually it
is the lenght of the software breakpoint but can be something else depending on
the target.

This patch introduces the linux_target_ops breakpoint_kind_from_pc and
sw_breakpoint_from_kind.

breakpoint_kind_from_pc returns the breakpoint kind and adjusts the PC to the
real memory location in case a flag was present in the PC. E.g the instruction
mode on ARM.

sw_breakpoint_from_kind returns the software breakpoint for this kind as a
string of bytes, the length of the breakpoint is adjusted for the breakpoint's
size in memory.

For targets that have only one kind of breakpoint, the default value 0 is
returned by linux_breakpoint_kind_from_pc so that not all targets need to
implement the breakpoint_kind_from_pc operation.

No regressions, tested on Ubuntu 14.04 on ARMv7 and x86
With gdbserver-{native,extended} / { -marm -mthumb }

Also since the target_ops have been changed compilation was tested on
affected archs namely : aarch64, arm, bfin, cris, crisv32, m32r,
m68k, mips, nios2, ppc, s390, sparc, tic6x, tile, x86, steins.

Not tested : sh

gdb/gdbserver/ChangeLog:

* linux-aarch64-low.c (aarch64_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-arm-low.c (arm_breakpoint_kind_from_pc): New function.
(arm_sw_breakpoint_from_kind): New function.
* linux-bfin-low.c (bfin_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-cris-low.c (cris_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-crisv32-low.c (cris_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-low.c (linux_wait_1): Call breakpoint_kind_from_pc
and sw_breakpoint_from_kind to increment the pc.
(linux_breakpoint_kind_from_pc): New function.
(linux_sw_breakpoint_from_kind): New function.
(struct target_ops) <sw_breakpoint_from_kind>: Initialize field.
(initialize_low): Call breakpoint_kind_from_pc and
sw_breakpoint_from_kind to replace breakpoint_data/len.
* linux-low.h (struct linux_target_ops) <breakpoint_kind_from_pc>:
New field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Likewise.
* linux-m32r-low.c (m32r_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-m68k-low.c (m68k_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-mips-low.c (mips_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-nios2-low.c (nios2_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-ppc-low.c (ppc_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-s390-low.c (s390_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-sh-low.c (sh_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-sparc-low.c (sparc_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-tic6x-low.c (tic6x_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-tile-low.c (tile_sw_breakpoint_from_kind): New function.
* linux-x86-low.c (x86_sw_breakpoint_from_kind): New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
* linux-xtensa-low.c (xtensa_sw_breakpoint_from_kind) New function.
(struct linux_target_ops) <breakpoint>: Remove.
(struct linux_target_ops) <breakpoint_len>: Remove.
(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.

9 years agoFix typo in spelling of author's name.
Ronald Hoogenboom [Wed, 21 Oct 2015 15:20:02 +0000 (16:20 +0100)]
Fix typo in spelling of author's name.

9 years agoRemove checking vCont;s in exec_cmd_expect_vCont_count
Yao Qi [Wed, 21 Oct 2015 15:16:25 +0000 (16:16 +0100)]
Remove checking vCont;s in exec_cmd_expect_vCont_count

Nowadays, in the range-stepping tests, we check not only the number of
vCont;r packets but also the number of vCont;s packets, because we think
the remote target which can do range stepping must support single step.

However, if we turn displaced stepping on, the remote target (GDBserver)
can do range stepping, and support single step, but GDB may decide to
resume instructions in the scratchpad rather than single step them one
by one for displaced stepping.  For example, when aarch64 GDB debugs
arm linux program with aarch64 GDBserver, GDBserver supports both range
stepping and single step, but GDB (with the gdbarch for arm-linux)
decides resume instructions in the scratchpad, so in the RSP traffic,
there is no vCont;s packet at all, and some range-stepping.exp tests
fail,

FAIL: gdb.base/range-stepping.exp: multi insns: next: vCont;s=1 vCont;r=1

This patch is to get rid of the checking to the number of vCont;s in
exec_cmd_expect_vCont_count.

gdb/testsuite:

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

* lib/range-stepping-support.exp (exec_cmd_expect_vCont_count):
Remove argument exp_vCont_s.
* gdb.base/range-stepping.exp: Callers updated.
* gdb.trace/range-stepping.exp: Likewise.

9 years ago[nto] Improve ABI sniffing.
Aleksandar Ristovski [Wed, 21 Oct 2015 14:37:33 +0000 (10:37 -0400)]
[nto] Improve ABI sniffing.

Use qnx specific notes to figure out the OS.

gdb/ChangeLog:
* gdb/nto-tdep.c (QNX_NOTE_NAME, QNX_INFO_SECT_NAME): New defines.
(nto_sniff_abi_note_section): New function.
(nto_elf_osabi_sniffer): Use new function to recognize nto specific
binary.

9 years ago[nto] Fix nto target stopped by watchpoint.
Aleksandar Ristovski [Wed, 21 Oct 2015 14:37:33 +0000 (10:37 -0400)]
[nto] Fix nto target stopped by watchpoint.

Fix 'stopped by watchpoint' detection: add inferior data, use inferior data
for storing last stopped flags needed for detection.

gdb/ChangeLog:

* nto-procfs.c (procfs_wait): Set stopped_flags nad stopped_pc.
(procfs_stopped_by_watchpoint): Use flags stored in inferior data.
* nto-tdep.c (nto_new_inferior_data_reg): New definition.
(nto_new_inferior_data, nto_inferior_data_cleanup, nto_inferior_data):
New functions.
(_initialize_nto_tdep): New forward declaration, new function.
* nto-tdep.h (struct nto_inferior_data): New struct.
(nto_inferior_data): New function declaration.

9 years agoAdd ability for objcopy to insert new symbols into a binary.
Ronald Hoogenbllon [Wed, 21 Oct 2015 14:16:35 +0000 (15:16 +0100)]
Add ability for objcopy to insert new symbols into a binary.

PR binutils/19104
binutils * objcopy.c (command_line_switch): Add OPTION_ADD_SYMBOL.
(copy_options): Add add-symbol.
(copy_usage): Likewise.
(parse_symflags): New function.
(need_sym_before): New function.
(create_new_symbol): New function.
(filter_symbols): Add code to insert new symbols.
(copy_main): Process OPTION_ADD_SYMBOL.
* doc/binutils.texi: Document new feature.
* NEWS: Add note about the new feature.

tests * binutils-all/add-symbol.d: New test.
* binutils-all/objcopy.exp: Run the new test.

9 years agoExtend description of the --enable-compressed-debug-sections configure option in...
Nick Clifton [Wed, 21 Oct 2015 13:57:28 +0000 (14:57 +0100)]
Extend description of the --enable-compressed-debug-sections configure option in gas and ld.

9 years agoReset x86 Linux targets to not compressing debug sections by default. Enable compres...
Nick Clifton [Wed, 21 Oct 2015 12:12:19 +0000 (13:12 +0100)]
Reset x86 Linux targets to not compressing debug sections by default.  Enable compression of debug sections by default in the linker, if so configured.

PR gas/19109
. * configure.ac: Note the 'none' is an acceptable argument to
--enable-compressed-debug-sections.
* configure: Regenerate.

gas * configure.ac: Restore --enable-compressed-debug-sections.
Do not enable compressed debug sections by default for x86 Linux
targets.
* configure: Regenerate.

ld * configure.ac: Add --enable-compressed-debug-sections.
* configure: Regenerate.
* config.in: Regenerate.
* ld.texinfo: Document how to determine the default action for
debug sections.
* ldmain.c (main): If DEFAULT_FLAG_COMPRESS_DEBUG is defined then
set the compress_debug field of the link_info structure to
zlib-gabi.
* lexsup.c (elf_static_list_options): Output the default setting
for the --compress-debug-sections option.
* NEWS: Mention the new configure option.

9 years agoFix --host cris-*-linux build of GDBServer.
Antoine Tremblay [Wed, 21 Oct 2015 11:44:26 +0000 (07:44 -0400)]
Fix --host cris-*-linux build of GDBServer.

Compiling GDBServer with --host cris-*-linux yields a compilation error :

linux-cris-low.c:65:21: error: ‘void’ must be the only parameter

This patch fixes the issue by removing the void parameter in cris_get_pc.

gdb/gdbserver/ChangeLog:
* linux-cris-low.c (cris_get_pc): Remove void arg.

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

9 years agoFix internal error on DW_OP_bregx(-1)
Jan Kratochvil [Tue, 20 Oct 2015 18:40:38 +0000 (20:40 +0200)]
Fix internal error on DW_OP_bregx(-1)

https://bugzilla.redhat.com/show_bug.cgi?id=1270564#c15
https://bugzilla.redhat.com/attachment.cgi?id=1081772

clang-3.5.0-9.fc22.x86_64
 <3><22b2>: Abbrev Number: 69 (DW_TAG_variable)
    <22b3>   DW_AT_location    : 7 byte block: 92 ff ff ff ff f 0 (DW_OP_bregx: 4294967295 (r-1) 0)
    <22bb>   DW_AT_name        : (indirect string, offset: 0x2a36): texture_data
    <22c1>   DW_AT_type        : <0x1d3>

(gdb) p variable
warning: Unmapped DWARF Register #-1 encountered.
regcache.c:177: internal-error: register_size: Assertion `regnum >= 0 && regnum < (gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs
(gdbarch))' failed.
[...]
Quit this debugging session? (y or n) FAIL: gdb.dwarf2/dw2-regno-invalid.exp: p variable (GDB internal error)

-> (x86_64)
(gdb) p variable
warning: Unmapped DWARF Register #-1 encountered.
Invalid register #-1, expecting 0 <= # < 220
(gdb) PASS: gdb.dwarf2/dw2-regno-invalid.exp: p variable
-> (i386)
(gdb) p variable
Invalid register #104, expecting 0 <= # < 104
(gdb) PASS: gdb.dwarf2/dw2-regno-invalid.exp: p variable

GDB calls gdbarch_dwarf2_reg_to_regnum() first which returns -1 in the x86_64
case
  if (regnum == -1)
    warning (_("Unmapped DWARF Register #%d encountered."), reg);
but in i386 case it does:
  /* This will hopefully provoke a warning.  */
  return gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
and the default implementation is a nop, leaving whatever register number
the DWARF specified.

gdb/ChangeLog
2015-10-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

* findvar.c (address_from_register): Check REGNUM validity.

gdb/testsuite/ChangeLog
2015-10-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
    Pedro Alves  <palves@redhat.com>

* gdb.dwarf2/dw2-regno-invalid.exp: New file.
* lib/dwarf.exp (Dwarf): Add DW_OP_bregx.

9 years agoFeed right input object to x86_64_mov_to_lea1[12]
H.J. Lu [Tue, 20 Oct 2015 17:43:33 +0000 (10:43 -0700)]
Feed right input object to x86_64_mov_to_lea1[12]

x86_64_mov_to_lea1.o is a 64-bit x86-64 object and x86_64_mov_to_lea2.o
is a 32-bit x86-64 object.  x86_64_mov_to_lea11 should use
x86_64_mov_to_lea2.o and x86_64_mov_to_lea12 should use
x86_64_mov_to_lea1.o.

* testsuite/Makefile.am (x86_64_mov_to_lea11): Replace
x86_64_mov_to_lea1.o with x86_64_mov_to_lea2.o.
(x86_64_mov_to_lea12): Replace x86_64_mov_to_lea2.o with
x86_64_mov_to_lea1.o.
* testsuite/Makefile.in: Regenerated.

9 years ago[nto] Implement procfs_pid_to_exec_file.
Aleksandar Ristovski [Tue, 20 Oct 2015 17:11:53 +0000 (13:11 -0400)]
[nto] Implement procfs_pid_to_exec_file.

gdb/ChangeLog:

* gdb/nto-procfs.c (procfs_pid_to_exec_file): New function.
(init_procfs_targets): Wire new function.

9 years ago[nto] Implement TARGET_OBJECT_AUXV.
Aleksandar Ristovski [Tue, 20 Oct 2015 16:58:47 +0000 (12:58 -0400)]
[nto] Implement TARGET_OBJECT_AUXV.

Fix 'info auxv' for nto.

gdb/ChangeLog:

* nto-procfs.c (sys/auxv.h): Include.
(procfs_xfer_partial): Implement TARGET_OBJECT_AUXV.
* nto-tdep.c (nto_read_auxv_from_initial_stack): New function.
* nto-tdep.h (nto_read_auxv_from_initial_stack): New declaration.

9 years ago[nto] Fixes for nto procfs.
Aleksandar Ristovski [Tue, 20 Oct 2015 16:58:46 +0000 (12:58 -0400)]
[nto] Fixes for nto procfs.

Fix errnoeus construction of procfs path. The issue is, after the first
info pidlist or first run, the path for local node (the most common node)
will be reset to empty which makes subsequent queries and runs impossible.

gdb/ChangeLog:

* nto-procfs.c (nto_procfs_path): Rename to...
(nodestr): ... this, and change type.
(nto_node): Use new variable and logic accordingly.
(procfs_open_1): Use new variable name. Use local buffer to construct
procfrs path.
(procfs_pidlist): Use NODESTR to construct procfs path.
(procfs_files_info): Use NODESTR to output meaningful text.
(do_attach): Construct procfs using NODESTR.
(procfs_create_inferior): Compare pointer to NULL.

9 years agoAdd --enable-compressed-debug-sections={all,gas,gold,ld}
H.J. Lu [Tue, 20 Oct 2015 15:58:10 +0000 (08:58 -0700)]
Add --enable-compressed-debug-sections={all,gas,gold,ld}

This patch removes the gas configure option:

--enable-compressed-debug-sections

and adds a toplevel configure option:

--enable-compressed-debug-sections={all,gas,gold,ld}

to enable compressed debug sections for gas, gold or ld by default.  At
the moment, this configure option is ignored by gold and ld.  For x86
Linux targets, default to compressing debug sections in gas.

PR gas/19109
* configure.ac: Add
--enable-compressed-debug-sections={all,gas,gold,ld}.
* configure: Regenerated.

gas/

PR gas/19109
* NEWS: Update --enable-compressed-debug-sections=.
* configure.ac: Remove --enable-compressed-debug-sections.
(DEFAULT_FLAG_COMPRESS_DEBUG): Check
--enable-compressed-debug-sections={all,gas} instead of
--enable-compressed-debug-sections.  For x86 Linux targets,
default to compressing debug sections.
* configure: Regenerated.

9 years agoCorrect printed value of Main in mmo.c consistency error message.
Hans-Peter Nilsson [Tue, 20 Oct 2015 04:56:33 +0000 (06:56 +0200)]
Correct printed value of Main in mmo.c consistency error message.

9 years agogdb: Improve syscall entry/return tracking on Linux
Josh Stone [Tue, 20 Oct 2015 00:59:38 +0000 (17:59 -0700)]
gdb: Improve syscall entry/return tracking on Linux

The existing logic was simply to flip syscall entry/return state when a
syscall trap was seen, and even then only with active 'catch syscall'.
That can get out of sync if 'catch syscall' is toggled at odd times.

This patch updates the entry/return state for all syscall traps,
regardless of catching state, and also updates known syscall state for
other kinds of traps.  Almost all PTRACE_EVENT stops are delivered from
the middle of a syscall, so this can act like an entry.  Every other
kind of ptrace stop is only delivered outside of syscall event pairs, so
marking them ignored ensures the next syscall trap looks like an entry.

Three new test scenarios are added to catch-syscall.exp:

- Disable 'catch syscall' from an entry to deliberately miss the return
  event, then re-enable to make sure a new entry is recognized.

- Enable 'catch syscall' for the first time from a vfork event, which is
  a PTRACE_EVENT_VFORK in the middle of the syscall.  Make sure the next
  syscall event is recognized as the return.

- Make sure entry and return are recognized for an ENOSYS syscall.  This
  is to defeat a common x86 hack that uses the pre-filled ENOSYS return
  value as a sign of being on the entry side.

gdb/ChangeLog:

2015-10-19  Josh Stone  <jistone@redhat.com>

* linux-nat.c (linux_handle_syscall_trap): Always update entry/
return state, even when not actively catching syscalls at all.
(linux_handle_extended_wait): Mark syscall_state like an entry.
(wait_lwp): Set syscall_state ignored for other traps.
(linux_nat_filter_event): Likewise.

gdb/testsuite/ChangeLog:

2015-10-19  Josh Stone  <jistone@redhat.com>

* gdb.base/catch-syscall.c: Include <sched.h>.
(unknown_syscall): New variable.
(main): Trigger a vfork and an unknown syscall.
* gdb.base/catch-syscall.exp (vfork_syscalls): New variable.
(unknown_syscall_number): Likewise.
(check_call_to_syscall): Accept an optional syscall pattern.
(check_return_from_syscall): Likewise.
(check_continue): Likewise.
(test_catch_syscall_without_args): Check for vfork and ENOSYS.
(test_catch_syscall_skipping_return): New test toggling off 'catch
syscall' to step over the syscall return, then toggling back on.
(test_catch_syscall_mid_vfork): New test turning on 'catch syscall'
during a PTRACE_EVENT_VFORK stop, in the middle of a vfork syscall.
(do_syscall_tests): Call test_catch_syscall_without_args and
test_catch_syscall_mid_vfork.
(test_catch_syscall_without_args_noxml): Check for vfork and ENOSYS.
(fill_all_syscalls_numbers): Initialize unknown_syscall_number.

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

9 years agoMake GDB wait for events after handling target File-I/O
Luis Machado [Mon, 19 Oct 2015 13:33:19 +0000 (11:33 -0200)]
Make GDB wait for events after handling target File-I/O

_ftext () at arm-vector.S:25
25              ldr pc, [pc, #24] @ reset
(gdb) load
Loading section .text, size 0xc01c lma 0x0
Loading section .eh_frame, size 0x48 lma 0xc01c
Loading section .ARM.exidx, size 0x8 lma 0xc064
Loading section .rodata, size 0x398 lma 0xc070
Loading section .data, size 0x8e0 lma 0xc408
Start address 0x40, load size 52452
Transfer rate: 17074 KB/sec, 1748 bytes/write.
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (Thread 1)
infrun: proceed (addr=0xffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 1] at 0x40
Sending packet: $vCont?#49...Ack
Packet received:
Packet vCont (verbose-resume) is NOT supported
Sending packet: $Hc0#db...Ack
Packet received: OK
Sending packet: $c#63...Ack
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
Packet received: Ffstat,00000001,07fffdb0
Sending packet: $M7fffdb0,40:000000000000000000002080000000010000c336000001180000000000000000000000000000000000000200000000000000000055dfb11b55dfb11b55dfb11b#5a...Ack
Packet received: OK
Sending packet: $F0#76...Ack
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = no-resumed
infrun: TARGET_WAITKIND_NO_RESUMED
infrun: stop_waiting
infrun: clear_step_over_info
Sending packet: $qfThreadInfo#bb...Ack
Packet received: m1
Sending packet: $qsThreadInfo#c8...Ack
Packet received: l
No unwaited-for children left.
infrun: infrun_async(0)
(gdb) c
Continuing.
Cannot execute this command while the selected thread is running.
(gdb)
Continuing.
Cannot execute this command while the selected thread is running.

This behavior shows up whenever GDB is in all-stop mode and is handling
target-initiated File-I/O requests, in the middle of, say, a continue
request.

When GDB is done handling the File-I/O request, it doesn't set
rs->waiting_for_stop_reply back to 1, meaning GDB should wait for
further target events.

This seems to be a latent bug, because in the past this didn't really
cause any issues. But it seems to have been uncovered by commit
567420d10895611e03d5ee65e6b24c16a69a6e99, which explicitly checks
for rs->waiting_for_stop_reply == 0, triggering the failures above.

The following patch fixes this by reorganizing the setting of
rs->waiting_for_stop_reply.

infrun: prepare_to_wait
Packet received: Ffstat,00000001,07fffdb0
Sending packet: $M7fffdb0,40:000000000000000000002080000000010000c336000001180000000000000000000000000000000000000200000000000000000055dfb19e55dfb19e55dfb19e#7b...Ack
Packet received: OK
Sending packet: $F0#76...Ack
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
Packet received: Fisatty,00000001
Sending packet: $F1#77...Ack
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
Packet received: Fwrite,00000001,0000d098,00000004
Sending packet: $md098,4#d2...Ack
Packet received: 3732300a
720
Sending packet: $F4#7a...Ack
infrun: target_wait (-1.0.0, status) =
infrun:   -1.0.0 [Thread 0],
infrun:   status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
Packet received: Fwrite,00000001,07ffffac,00000011
Sending packet: $m7ffffac,11#8e...Ack
Packet received: 0a2a2a2a204558495420636f646520300a

*** EXIT code 0

Regression-tested on Ubuntu x86-64 and qemu-system-based debugging
for arm eabi.

gdb/ChangeLog:

2015-10-16  Luis Machado  <lgustavo@codesourcery.com>

* remote.c (remote_wait_as): Set rs->waiting_for_stop_reply to 0
when handling 'E', 'T', 'S', 'X' and 'W' packets.
Do not set rs->waiting_for_stop_reply back to 1.