binutils-gdb.git
9 years agoDWARF: handle non-local references in nested functions
Pierre-Marie de Rodat [Thu, 5 Feb 2015 16:00:06 +0000 (17:00 +0100)]
DWARF: handle non-local references in nested functions

GDB's current behavior when dealing with non-local references in the
context of nested fuctions is approximative:

  - code using valops.c:value_of_variable read the first available stack
    frame that holds the corresponding variable (whereas there can be
    multiple candidates for this);

  - code directly relying on read_var_value will instead read non-local
    variables in frames where they are not even defined.

This change adds the necessary context to symbol reads (to get the block
they belong to) and to blocks (the static link property, if any) so that
GDB can make the proper decisions when dealing with non-local varibale
references.

gdb/ChangeLog:

* ada-lang.c (ada_read_var_value): Add a var_block argument
and pass it to default_read_var_value.
* block.c (block_static_link): New accessor.
* block.h (block_static_link): Declare it.
* buildsym.c (finish_block_internal): Add a static_link
argument.  If there is a static link, associate it to the new
block.
(finish_block): Add a static link argument and pass it to
finish_block_internal.
(end_symtab_get_static_block): Update calls to finish_block and
to finish_block_internal.
(end_symtab_with_blockvector): Update call to
finish_block_internal.
* buildsym.h: Forward-declare struct dynamic_prop.
(struct context_stack): Add a static_link field.
(finish_block): Add a static link argument.
* c-exp.y: Remove an obsolete comment (evaluation of variables
already start from the selected frame, and now they climb *up*
the call stack) and propagate the block information to the
produced expression.
* d-exp.y: Likewise.
* f-exp.y: Likewise.
* go-exp.y: Likewise.
* jv-exp.y: Likewise.
* m2-exp.y: Likewise.
* p-exp.y: Likewise.
* coffread.c (coff_symtab_read): Update calls to finish_block.
* dbxread.c (process_one_symbol): Likewise.
* xcoffread.c (read_xcoff_symtab): Likewise.
* compile/compile-c-symbols.c (convert_one_symbol): Promote the
"sym" parameter to struct block_symbol, update its uses and pass
its block to calls to read_var_value.
(convert_symbol_sym): Update the calls to convert_one_symbol.
* compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update
call to read_var_value.
* dwarf2loc.c (block_op_get_frame_base): New.
(dwarf2_block_frame_base_locexpr_funcs): Implement the
get_frame_base method.
(dwarf2_block_frame_base_loclist_funcs): Likewise.
(dwarf2locexpr_baton_eval): Add a frame argument and use it
instead of the selected frame in order to evaluate the
expression.
(dwarf2_evaluate_property): Add a frame argument.  Update call
to dwarf2_locexpr_baton_eval to provide a frame in available and
to handle the absence of address stack.
* dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument.
* dwarf2read.c (attr_to_dynamic_prop): Add a forward
declaration.
(read_func_scope): Record any available static link description.
Update call to finish_block.
(read_lexical_block_scope): Update call to finish_block.
* findvar.c (follow_static_link): New.
(get_hosting_frame): New.
(default_read_var_value): Add a var_block argument.  Use
get_hosting_frame to handle non-local references.
(read_var_value): Add a var_block argument and pass it to the
LA_READ_VAR_VALUE method.
* gdbtypes.c (resolve_dynamic_range): Update calls to
dwarf2_evaluate_property.
(resolve_dynamic_type_internal): Likewise.
* guile/scm-frame.c (gdbscm_frame_read_var): Update call to
read_var_value, passing it the block coming from symbol lookup.
* guile/scm-symbol.c (gdbscm_symbol_value): Update call to
read_var_value (TODO).
* infcmd.c (finish_command_continuation): Update call to
read_var_value, passing it the block coming from symbol lookup.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* language.h (struct language_defn): Add a var_block argument to
the LA_READ_VAR_VALUE method.
* objfiles.c (struct static_link_htab_entry): New.
(static_link_htab_entry_hash): New.
(static_link_htab_entry_eq): New.
(objfile_register_static_link): New.
(objfile_lookup_static_link): New.
(free_objfile): Free the STATIC_LINKS hashed map if needed.
* objfiles.h: Include hashtab.h.
(struct objfile): Add a static_links field.
(objfile_register_static_link): New.
(objfile_lookup_static_link): New.
* printcmd.c (print_variable_and_value): Update call to
read_var_value.
* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
* python/py-frame.c (frapy_read_var): Update call to
read_var_value, passing it the block coming from symbol lookup.
* python/py-framefilter.c (extract_sym): Add a sym_block
parameter and set the pointed value to NULL (TODO).
(enumerate_args): Update call to extract_sym.
(enumerate_locals): Update calls to extract_sym and to
read_var_value.
* python/py-symbol.c (sympy_value): Update call to
read_var_value (TODO).
* stack.c (read_frame_local): Update call to read_var_value.
(read_frame_arg): Likewise.
(return_command): Likewise.
* symtab.h (struct symbol_block_ops): Add a get_frame_base
method.
(struct symbol): Add a block field.
(SYMBOL_BLOCK): New accessor.
* valops.c (value_of_variable): Remove frame/block handling and
pass the block argument to read_var_value, which does this job
now.
(value_struct_elt_for_reference): Update calls to
read_var_value.
(value_of_this): Pass the block found to read_var_value.
* value.h (read_var_value): Add a var_block argument.
(default_read_var_value): Likewise.

gdb/testsuite/ChangeLog:

* gdb.base/nested-subp1.exp: New file.
* gdb.base/nested-subp1.c: New file.
* gdb.base/nested-subp2.exp: New file.
* gdb.base/nested-subp2.c: New file.
* gdb.base/nested-subp3.exp: New file.
* gdb.base/nested-subp3.c: New file.

9 years ago[AArch64] Fix a typo in the comment for BFD_RELOC_AARCH64_LD64_GOT_LO12_NC
Renlin Li [Tue, 25 Aug 2015 11:37:21 +0000 (12:37 +0100)]
[AArch64] Fix a typo in the comment for BFD_RELOC_AARCH64_LD64_GOT_LO12_NC

2015-08-25  Renlin Li  <renlin.li@arm.com>

bfd/
  * reloc.c (BFD_RELOC_AARCH64_LD64_GOTOFF_LO15): Use LP64 instead of
  ILP64.
  * bfd-in2.h: Regenerate.

9 years agoMove aarch64_linux_new_thread to nat/aarch64-linux.c
Yao Qi [Tue, 25 Aug 2015 10:38:29 +0000 (11:38 +0100)]
Move aarch64_linux_new_thread to nat/aarch64-linux.c

This patch moves aarch64_linux_new_thread in GDB and GDBserver to
nat/aarch64-linux.c.

gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (aarch64_linux_new_thread): Move it to ...
* nat/aarch64-linux.c (aarch64_linux_new_thread): ... here.
* nat/aarch64-linux.h (aarch64_linux_new_thread): Declare.

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_linux_new_thread): Remove.

9 years agoMove aarch64_linux_prepare_to_resume to nat/aarch64-linux.c
Yao Qi [Tue, 25 Aug 2015 10:38:29 +0000 (11:38 +0100)]
Move aarch64_linux_prepare_to_resume to nat/aarch64-linux.c

gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* Makefile.in (aarch64-liunx.o): New rule.
(HFILES_NO_SRCDIR): Add aarch64-linux.h.
* config/aarch64/linux.mh (NAT_FILE): Add aarch64-linux.o.
* aarch64-linux-nat.c: Include nat/aarch64-linux.h.
* aarch64-linux-nat.c (aarch64_get_debug_reg_state): Make it
extern.
(aarch64_linux_prepare_to_resume): Move it nat/aarch64-linux.c.
* nat/aarch64-linux-hw-point.h (aarch64_debug_reg_state): Declare
* nat/aarch64-linux.c: New file.
* nat/aarch64-linux.h: New file.

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* Makefile.in (aarch64-linux.o): New rule.
* configure.srv (aarch64*-*-linux*): Append aarch64-linux.o to
srv_tgtobj.
* linux-aarch64-low.c: Include nat/aarch64-linux.h.
(aarch64_init_debug_reg_state): Make it extern.
(aarch64_linux_prepare_to_resume): Remove.

9 years agoMake aarch64_linux_prepare_to_resume the same on GDB and GDBserver
Yao Qi [Tue, 25 Aug 2015 10:38:29 +0000 (11:38 +0100)]
Make aarch64_linux_prepare_to_resume the same on GDB and GDBserver

gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (aarch64_linux_prepare_to_resume): Use
lwp_arch_private_info and ptid_of_lwp.

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_linux_prepare_to_resume): Use
lwp_arch_private_info and ptid_of_lwp.

9 years agoAdd pid argument in aarch64_get_debug_reg_state
Yao Qi [Tue, 25 Aug 2015 10:38:29 +0000 (11:38 +0100)]
Add pid argument in aarch64_get_debug_reg_state

This patch addes argument pid in aarch64_get_debug_reg_state, so that
its interface is the same on both GDB and GDBserver.

gdb/gdbserver:

2015-018-25  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_get_debug_reg_state): Add argument pid.
Find proc_info by find_process_pid.  All callers updated.

9 years agoMove debug_reg_change_callback and aarch64_notify_debug_reg_change to nat/aarch64...
Yao Qi [Tue, 25 Aug 2015 10:38:29 +0000 (11:38 +0100)]
Move debug_reg_change_callback and aarch64_notify_debug_reg_change to nat/aarch64-linux-hw-point.c

gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (struct arch64_dr_update_callback_param):
Move it to nat/aarch64-linux-hw-point.c.
(debug_reg_change_callback): Likewise.
(aarch64_notify_debug_reg_change): :Likewise.
* nat/aarch64-linux-hw-point.c: Include nat/linux-nat.h.
(aarch64_dr_update_callback_param): New.
(debug_reg_change_callback): New function.
(aarch64_notify_debug_reg_change): Likewise.
* nat/aarch64-linux-hw-point.h (aarch64_notify_debug_reg_change):
Remove the declaration.

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (struct arch64_dr_update_callback_param):
Remove.
(debug_reg_change_callback): Remove.
(aarch64_notify_debug_reg_change): Remove.

9 years agoMake debug_reg_change_callback the same on GDB and GDBserver
Yao Qi [Tue, 25 Aug 2015 10:38:29 +0000 (11:38 +0100)]
Make debug_reg_change_callback the same on GDB and GDBserver

This patch makes function debug_reg_change_callback in GDB and GDBserver
look the same, so that the following patch can move them to
nat/aarch64-linux-hw-point.c.

gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (debug_reg_change_callback): Use
ptid_of_lwp to get ptid of lwp.

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (debug_reg_change_callback): Use
ptid_of_lwp to get ptid of lwp.

9 years agoMake aarch64_notify_debug_reg_change the same on GDB and GDBserver
Yao Qi [Tue, 25 Aug 2015 10:38:29 +0000 (11:38 +0100)]
Make aarch64_notify_debug_reg_change the same on GDB and GDBserver

gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (aarch64_notify_debug_reg_change):
Call current_lwp_ptid.

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_notify_debug_reg_change):
Call current_lwp_ptid.

9 years agoUse debug_printf in debug_reg_change_callback
Yao Qi [Tue, 25 Aug 2015 10:38:29 +0000 (11:38 +0100)]
Use debug_printf in debug_reg_change_callback

gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (debug_reg_change_callback): Use
debug_printf.

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (debug_reg_change_callback): Use
debug_printf.

9 years agoUse phex debug_reg_change_callback
Yao Qi [Tue, 25 Aug 2015 10:38:28 +0000 (11:38 +0100)]
Use phex debug_reg_change_callback

This patch is to use phex in debug_reg_change_callback to make it
identical in GDB and GDBserver.

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (debug_reg_change_callback): Use phex.

9 years agoGet pid rather than lwpid
Yao Qi [Tue, 25 Aug 2015 10:38:28 +0000 (11:38 +0100)]
Get pid rather than lwpid

We print PID rather than LWPID in the debug output, so we need call
ptid_get_pid in debug_reg_change_callback.

gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (debug_reg_change_callback): Call
ptid_get_pid rather than ptid_get_lwp.

9 years agoRemove some comments in debug_reg_change_callback
Yao Qi [Tue, 25 Aug 2015 10:38:28 +0000 (11:38 +0100)]
Remove some comments in debug_reg_change_callback

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (debug_reg_change_callback): Remove comments.

9 years agoRe-indent the code
Yao Qi [Tue, 25 Aug 2015 10:38:28 +0000 (11:38 +0100)]
Re-indent the code

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (debug_reg_change_callback): Re-indent
the code.

9 years ago[gdbserver] Use iterate_over_lwps in aarch64_notify_debug_reg_change
Yao Qi [Tue, 25 Aug 2015 10:38:28 +0000 (11:38 +0100)]
[gdbserver] Use iterate_over_lwps in aarch64_notify_debug_reg_change

This patch makes more bits on aarch64 watchpoint between GDB and GDBserver
look similar.

gdb/gdbserver:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_dr_update_callback_param) <pid>:
Remove.
(debug_reg_change_callback): Remove argument entry and add argument
lwp.  Remove local variable thread.  Don't print thread id in the
debugging output.  Don't check whether pid of thread equals to pid.
(aarch64_notify_debug_reg_change): Don't set param.pid.  Call
iterate_over_lwps instead find_inferior.

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

9 years agogdbserver crashes when multiprocess extensions aren't supported
Pedro Alves [Mon, 24 Aug 2015 18:58:31 +0000 (19:58 +0100)]
gdbserver crashes when multiprocess extensions aren't supported

Ref: https://sourceware.org/ml/gdb-patches/2015-08/msg00675.html

If multiprocess extensions are off (because specific gdbserver port
doesn't support them), then when gdbserver doesn't have a thread
selected yet, and GDB sends Hg packet to select one, gdbserver
crashes.  That's because extracting the desired thread id out of the
packet that GDB sent depends on the current thread to fill in the
missing process id ...  Fix this by getting the process id from the
first (and only) process in the processes list instead.

The GNU/Linux port doesn't trip on this because it always runs with
multiprocess extensions enabled.  To make it easier to catch such
regressions going forward, this commit also adds a new smoke test that
spawns gdbserver, connects to it and runs to main with the
multiprocess extensions force-disabled.

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

* inferiors.c (get_first_process): New function.
* inferiors.h (get_first_process): New declaration.
* remote-utils.c (read_ptid): Default to the first process in the
list, instead of to the current thread's process.

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

* gdb.server/connect-without-multi-process.c: New file.
* gdb.server/connect-without-multi-process.exp: New file.

9 years agoAdd "set remote multiprocess-extensions-packet" command
Pedro Alves [Mon, 24 Aug 2015 18:58:31 +0000 (19:58 +0100)]
Add "set remote multiprocess-extensions-packet" command

Being able to force-disable the RSP multiprocess extensions is useful
for testing.

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

* NEWS (New commands): Mention set/show remote
multiprocess-extensions-packet.
* remote.c (remote_query_supported): Only tell the server to use
the multiprocess extensions if the user hasn't force-disabled them
with "set remote multiprocess-extensions-packet off".

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

* gdb.texinfo (Remote Configuration): Document the "set/show
remote multiprocess-extensions-packet" commands.

9 years agoUpdate gnulib to current upstream master
Pedro Alves [Mon, 24 Aug 2015 17:50:00 +0000 (18:50 +0100)]
Update gnulib to current upstream master

2015-08-24  Pedro Alves  <palves@redhat.com>

* gnulib/update-gnulib.sh (GNULIB_COMMIT_SHA1): Set to
1029a8112290f6eee9d7878a391c49db42c999bd.
* gnulib/configure, gnulib/config.in, gnulib/aclocal.m4:
Regenerate.
* gnulib/import/Makefile.am: Update.
* gnulib/import/Makefile.in: Update.
* gnulib/import/alloca.in.h: Update.
* gnulib/import/basename-lgpl.c: Update.
* gnulib/import/canonicalize-lgpl.c: Update.
* gnulib/import/config.charset: Update.
* gnulib/import/dirent.in.h: Update.
* gnulib/import/dirfd.c: Update.
* gnulib/import/dirname-lgpl.c: Update.
* gnulib/import/dirname.h: Update.
* gnulib/import/dosname.h: Update.
* gnulib/import/errno.in.h: Update.
* gnulib/import/extra/snippet/arg-nonnull.h: Update.
* gnulib/import/extra/snippet/c++defs.h: Update.
* gnulib/import/extra/snippet/warn-on-use.h: Update.
* gnulib/import/extra/update-copyright: Update.
* gnulib/import/float+.h: Update.
* gnulib/import/float.c: Update.
* gnulib/import/float.in.h: Update.
* gnulib/import/fnmatch.c: Update.
* gnulib/import/fnmatch.in.h: Update.
* gnulib/import/fnmatch_loop.c: Update.
* gnulib/import/fpucw.h: Update.
* gnulib/import/frexp.c: Update.
* gnulib/import/frexpl.c: Update.
* gnulib/import/gettimeofday.c: Update.
* gnulib/import/inttypes.in.h: Update.
* gnulib/import/isnan.c: Update.
* gnulib/import/isnand-nolibm.h: Update.
* gnulib/import/isnand.c: Update.
* gnulib/import/isnanl-nolibm.h: Update.
* gnulib/import/isnanl.c: Update.
* gnulib/import/itold.c: Update.
* gnulib/import/localcharset.c: Update.
* gnulib/import/localcharset.h: Update.
* gnulib/import/lstat.c: Update.
* gnulib/import/m4/00gnulib.m4: Update.
* gnulib/import/m4/absolute-header.m4: Update.
* gnulib/import/m4/alloca.m4: Update.
* gnulib/import/m4/canonicalize.m4: Update.
* gnulib/import/m4/codeset.m4: Update.
* gnulib/import/m4/configmake.m4: Update.
* gnulib/import/m4/dirent_h.m4: Update.
* gnulib/import/m4/dirfd.m4: Update.
* gnulib/import/m4/dirname.m4: Update.
* gnulib/import/m4/double-slash-root.m4: Update.
* gnulib/import/m4/eealloc.m4: Update.
* gnulib/import/m4/errno_h.m4: Update.
* gnulib/import/m4/exponentd.m4: Update.
* gnulib/import/m4/exponentl.m4: Update.
* gnulib/import/m4/extensions.m4: Update.
* gnulib/import/m4/extern-inline.m4: Update.
* gnulib/import/m4/fcntl-o.m4: Update.
* gnulib/import/m4/float_h.m4: Update.
* gnulib/import/m4/fnmatch.m4: Update.
* gnulib/import/m4/fpieee.m4: Update.
* gnulib/import/m4/frexp.m4: Update.
* gnulib/import/m4/frexpl.m4: Update.
* gnulib/import/m4/gettimeofday.m4: Update.
* gnulib/import/m4/glibc21.m4: Update.
* gnulib/import/m4/gnulib-cache.m4: Update.
* gnulib/import/m4/gnulib-common.m4: Update.
* gnulib/import/m4/gnulib-comp.m4: Update.
* gnulib/import/m4/gnulib-tool.m4: Update.
* gnulib/import/m4/include_next.m4: Update.
* gnulib/import/m4/inttypes-pri.m4: Update.
* gnulib/import/m4/inttypes.m4: Update.
* gnulib/import/m4/isnand.m4: Update.
* gnulib/import/m4/isnanl.m4: Update.
* gnulib/import/m4/largefile.m4: Update.
* gnulib/import/m4/localcharset.m4: Update.
* gnulib/import/m4/locale-fr.m4: Update.
* gnulib/import/m4/locale-ja.m4: Update.
* gnulib/import/m4/locale-zh.m4: Update.
* gnulib/import/m4/longlong.m4: Update.
* gnulib/import/m4/lstat.m4: Update.
* gnulib/import/m4/malloc.m4: Update.
* gnulib/import/m4/malloca.m4: Update.
* gnulib/import/m4/math_h.m4: Update.
* gnulib/import/m4/mbrtowc.m4: Update.
* gnulib/import/m4/mbsinit.m4: Update.
* gnulib/import/m4/mbsrtowcs.m4: Update.
* gnulib/import/m4/mbstate_t.m4: Update.
* gnulib/import/m4/memchr.m4: Update.
* gnulib/import/m4/memmem.m4: Update.
* gnulib/import/m4/mmap-anon.m4: Update.
* gnulib/import/m4/multiarch.m4: Update.
* gnulib/import/m4/nocrash.m4: Update.
* gnulib/import/m4/off_t.m4: Update.
* gnulib/import/m4/pathmax.m4: Update.
* gnulib/import/m4/readlink.m4: Update.
* gnulib/import/m4/rename.m4: Update.
* gnulib/import/m4/rmdir.m4: Update.
* gnulib/import/m4/ssize_t.m4: Update.
* gnulib/import/m4/stat.m4: Update.
* gnulib/import/m4/stdbool.m4: Update.
* gnulib/import/m4/stddef_h.m4: Update.
* gnulib/import/m4/stdint.m4: Update.
* gnulib/import/m4/stdio_h.m4: Update.
* gnulib/import/m4/stdlib_h.m4: Update.
* gnulib/import/m4/string_h.m4: Update.
* gnulib/import/m4/strstr.m4: Update.
* gnulib/import/m4/strtok_r.m4: Update.
* gnulib/import/m4/sys_socket_h.m4: Update.
* gnulib/import/m4/sys_stat_h.m4: Update.
* gnulib/import/m4/sys_time_h.m4: Update.
* gnulib/import/m4/sys_types_h.m4: Update.
* gnulib/import/m4/time_h.m4: Update.
* gnulib/import/m4/unistd_h.m4: Update.
* gnulib/import/m4/warn-on-use.m4: Update.
* gnulib/import/m4/wchar_h.m4: Update.
* gnulib/import/m4/wchar_t.m4: Update.
* gnulib/import/m4/wctype_h.m4: Update.
* gnulib/import/m4/wint_t.m4: Update.
* gnulib/import/malloc.c: Update.
* gnulib/import/malloca.c: Update.
* gnulib/import/malloca.h: Update.
* gnulib/import/math.in.h: Update.
* gnulib/import/mbrtowc.c: Update.
* gnulib/import/mbsinit.c: Update.
* gnulib/import/mbsrtowcs-impl.h: Update.
* gnulib/import/mbsrtowcs-state.c: Update.
* gnulib/import/mbsrtowcs.c: Update.
* gnulib/import/memchr.c: Update.
* gnulib/import/memmem.c: Update.
* gnulib/import/pathmax.h: Update.
* gnulib/import/readlink.c: Update.
* gnulib/import/ref-add.sin: Update.
* gnulib/import/ref-del.sin: Update.
* gnulib/import/rename.c: Update.
* gnulib/import/rmdir.c: Update.
* gnulib/import/same-inode.h: Update.
* gnulib/import/stat.c: Update.
* gnulib/import/stdbool.in.h: Update.
* gnulib/import/stddef.in.h: Update.
* gnulib/import/stdint.in.h: Update.
* gnulib/import/stdio.c: Update.
* gnulib/import/stdio.in.h: Update.
* gnulib/import/stdlib.in.h: Update.
* gnulib/import/str-two-way.h: Update.
* gnulib/import/streq.h: Update.
* gnulib/import/string.in.h: Update.
* gnulib/import/stripslash.c: Update.
* gnulib/import/strnlen1.c: Update.
* gnulib/import/strnlen1.h: Update.
* gnulib/import/strstr.c: Update.
* gnulib/import/strtok_r.c: Update.
* gnulib/import/sys_stat.in.h: Update.
* gnulib/import/sys_time.in.h: Update.
* gnulib/import/sys_types.in.h: Update.
* gnulib/import/time.in.h: Update.
* gnulib/import/unistd.in.h: Update.
* gnulib/import/verify.h: Update.
* gnulib/import/wchar.in.h: Update.
* gnulib/import/wctype.in.h: Update.
* gnulib/import/gettimeofday.c: New file.
* gnulib/import/m4/absolute-header.m4: New file.
* gnulib/import/m4/gettimeofday.m4: New file.
* gnulib/import/m4/sys_socket_h.m4: New file.
* gnulib/import/m4/sys_time_h.m4: New file.
* gnulib/import/stdio.c: Delete file.
* gnulib/import/sys_time.in.h: New file.

9 years agoPrepare for gnulib update
Pedro Alves [Mon, 24 Aug 2015 17:50:55 +0000 (18:50 +0100)]
Prepare for gnulib update

After the last gnulib import (Dec 2012), gnulib upstream started
replacing mingw's 'struct timeval' with a version with 64-bit time_t,
for POSIX compliance:

 commit f8e84098084b3b53bc6943a5542af1f607ffd477
 Author: Bruno Haible <bruno@clisp.org>
 Date:   Sat Jan 28 18:12:10 2012 +0100
     sys_time: Override 'struct timeval' on some native Windows platforms.

See:

 https://lists.gnu.org/archive/html/bug-gnulib/2012-01/msg00372.html

However, that results in conflicts with native Winsock2's 'select':

select()'s argument
http://sourceforge.net/p/mingw-w64/mailman/message/29610438/

... and libiberty's timeval-utils.h timeval_add/timeval_sub, at the
least.

We don't really need the POSIX compliance, so this patch prepares us
to simply not use gnulib's 'struct timeval' replacement once a more
recent gnulib is imported, thus preserving the current behavior, by
adding a sys/time.h wrapper header that undefs gnulib's replacements,
and including that everywhere instead.

The SIZE -> OSIZE change is necessary because newer gnulib's
sys/time.h also includes windows.h/winsock2.h, which defines a
conflicting SIZE symbol.

Cross build-tested mingw-w64 32-bit and 64-bit.
Regtested on x86_64 Fedora 20.

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

* Makefile.in (HFILES_NO_SRCDIR): Add common/gdb_sys_time.h.
* common/gdb_sys_time.h: New file.
* event-loop.c: Include gdb_sys_time.h instead of sys/time.h.
* gdb_select.h: Likewise.
* gdb_usleep.c: Likewise.
* maint.c: Likewise.
* mi/mi-main.c: Likewise.
* mi/mi-parse.h: Likewise.
* remote-fileio.c: Likewise.
* remote-m32r-sdi.c: Likewise.
* remote.c: Likewise.
* ser-base.c: Likewise.
* ser-pipe.c: Likewise.
* ser-tcp.c: Likewise.
* ser-unix.c: Likewise.
* symfile.c: Likewise.
* symfile.c: Likewise.  Rename OSIZE to SIZE throughout.
* target-memory.c: Include gdb_sys_time.h instead of sys/time.h.
* utils.c: Likewise.

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

* debug.c: Include gdb_sys_time.h instead of sys/time.h.
* event-loop.c: Likewise.
* remote-utils.c: Likewise.
* tracepoint.c: Likewise.

9 years agoFix gdbserver SPU build
Pedro Alves [Mon, 24 Aug 2015 16:58:22 +0000 (17:58 +0100)]
Fix gdbserver SPU build

Ref: https://sourceware.org/ml/gdb-patches/2015-08/msg00675.html

 gdbserver/spu-low.c: In function 'spu_request_interrupt':
 gdbserver/spu-low.c:639: error: incompatible type for argument 1 of 'ptid_get_lwp'

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

* spu-low.c (spu_request_interrupt): Use lwpid_of instead of
ptid_get_lwp.

9 years agoMake z int
Luis Machado [Mon, 24 Aug 2015 16:08:20 +0000 (13:08 -0300)]
Make z int

This makes z an int for gdb/testsuite/gdb.opt/inline-markers.c.

gdb/testsuite/ChangeLog:

2015-08-24  Luis Machado  <lgustavo@codesourcery.com>

* gdb.opt/inline-markers.c: Make z int.

9 years agoMake z volatile.
Luis Machado [Mon, 24 Aug 2015 15:56:15 +0000 (12:56 -0300)]
Make z volatile.

This fixes a typo in gdb/testsuite/gdb.opt/inline-markers.c, making
z a volatile variable.

gdb/testsuite/ChangeLog:

2015-08-24  Luis Machado  <lgustavo@codesourcery.com>

* gdb.opt/inline-markers.c: Make z volatile.

9 years agoPrevent GCC from folding inline test functions
Luis Machado [Mon, 24 Aug 2015 15:33:21 +0000 (12:33 -0300)]
Prevent GCC from folding inline test functions

While doing some powerpc Linux tests on a ppc 476 board using GCC 5.2, i
noticed inline-bt.exp, inline-cmds.exp and inline-locals.exp failing.

FAIL: gdb.opt/inline-bt.exp: continue to bar (1)
FAIL: gdb.opt/inline-bt.exp: backtrace from bar (1)
FAIL: gdb.opt/inline-bt.exp: continue to bar (2)
FAIL: gdb.opt/inline-bt.exp: backtrace from bar (2)
FAIL: gdb.opt/inline-bt.exp: continue to bar (3)
FAIL: gdb.opt/inline-bt.exp: backtrace from bar (3)
FAIL: gdb.opt/inline-cmds.exp: continue to bar (1)
FAIL: gdb.opt/inline-cmds.exp: backtrace from bar (1)
FAIL: gdb.opt/inline-cmds.exp: continue to bar (2)
FAIL: gdb.opt/inline-cmds.exp: backtrace from bar (2)
FAIL: gdb.opt/inline-cmds.exp: continue to marker
FAIL: gdb.opt/inline-cmds.exp: backtrace from marker
FAIL: gdb.opt/inline-cmds.exp: step into finish marker
FAIL: gdb.opt/inline-locals.exp: continue to bar (1)
FAIL: gdb.opt/inline-locals.exp: continue to bar (2)
FAIL: gdb.opt/inline-locals.exp: backtrace from bar (2)
FAIL: gdb.opt/inline-locals.exp: continue to bar (3)
FAIL: gdb.opt/inline-locals.exp: backtrace from bar (3)

They failed because the breakpoint supposedly inserted at bar was actually
inserted at noinline.

(gdb) break inline-markers.c:20^M
Breakpoint 2 at 0x1000079c: file gdb/testsuite/gdb.opt/inline-markers.c, line 20.^M
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, noinline () at gdb/testsuite/gdb.opt/inline-markers.c:35^M
35        inlined_fn (); /* inlined */^M

As we can see, line 20 is really inside bar, not noinline:

18 void bar(void)
19 {
20   x += y; /* set breakpoint 1 here */
21 }

Further investigation shows that this is really due to GCC 5's new
ICF pass (-fipa-icf), now enabled by default at -O2, which folds bar
and marker into noinline, where the call to inlined_fn was inlined.

This breaks the testcase since it expects to stop at specific spots.

I thought about two possible fixes for this issue.

- Disable the ICF pass manually when building the binary (-fno-ipa-icf).

This has the advantage of not having to touch the testcase sources themselves,
but the disadvantage of having to add conditional blocks to test the GCC
version. If we ever change GCC's default, we will have to adjust the
conditional block again to match GCC's behavior.

- Modify the testcase sources to make the identical functions unique.

This solution doesn't touch the testcase itself, but changes the source
code slightly in order to make bar, marker and inlined_fn unique. This
causes GCC's ICF pass to ignore these functions and not fold them into
a common identical function.

I'm good with either of them, but i'm more inclined to go with the second
one.

The attached patch implements this by adding the new global variable z, set
to 0, that gets added in different ways to marker and inlined_fn. Since it
is 0, it doesn't affect any possible value checks that we may wish to do
in the future (we currently only check for values changed by bar).

Ok?

ps: I also noticed GDB doesn't do a great job at stating that the breakpoint
was actually inserted at a different source line than previously requested,
so this sounds like a bug that should be fixed, if it is not just wrong
DWARF information (did not investigate it further).

gdb/testsuite/ChangeLog:

2015-08-24  Luis Machado  <lgustavo@codesourcery.com>

* gdb.opt/inline-bt.c: New volatile global z.
* gdb.opt/inline-cmds.c: Likewise.
* gdb.opt/inline-locals.c: Likewise.
* gdb.opt/inline-markers.c: New extern global z.
(marker): Use z.
(inline_fn): Likewise.

9 years agogdb/testsuite/: garbage collect a few references to dead targets
Pedro Alves [Mon, 24 Aug 2015 14:29:49 +0000 (15:29 +0100)]
gdb/testsuite/: garbage collect a few references to dead targets

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

* config/m32r-stub.exp: Remove file.
* gdb.base/call-ar-st.exp: Remove reference to sparclet.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-strs.exp: Likewise.
* gdb.base/default.exp: Remove references to h8300-*-hms and
*-*-udi*.
* gdb.base/funcargs.exp: Remove reference to sparclet-*-*.

9 years agogdb manual: Remove references to deleted targets
Pedro Alves [Mon, 24 Aug 2015 14:40:26 +0000 (15:40 +0100)]
gdb manual: Remove references to deleted targets

Support for target dbug/picobug/dink32/m32r/mon2000/ppcbug was just
removed, but support for ARM RDI, Sparclet, Sparclite, Z8000, target
r3900, target array, target sds, target op50n and target w89k had
already been removed many years ago.  Drop it all in one go.

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

* gdb.texinfo (Embedded Processors) <ARM>: Remove references to RDI.
<M32R>: Remove references to M32R/D.
<M68K>: Remove references to target dbug.
<MIPS Embedded>: Remove references to target r3900 and target
array.
<PowerPC Embedded>: Remove references to target dink32 and target
ppcbug, target sds
<PA, Sparclet, Sparclite, Z8000>: Delete nodes.

9 years agoDelete the remaining ROM monitor targets
Pedro Alves [Mon, 24 Aug 2015 14:40:26 +0000 (15:40 +0100)]
Delete the remaining ROM monitor targets

Ref: https://sourceware.org/ml/gdb/2015-07/msg00011.html

All of these targets use gdb/monitor.c, which has bit rotted
years ago (I'd guess around ~6), and nobody seems to
have noticed:

 | target         | source               |
 |----------------+----------------------|
 | target dbug    | gdb/dbug-rom.c       |
 | target picobug | gdb/microblaze-rom.c |
 | target dink32  | gdb/dink32-rom.c     |
 | target m32r    | gdb/m32r-rom.c       |
 | target mon2000 | gdb/m32r-rom.c       |
 | target ppcbug  | gdb/ppcbug-rom.c     |

This deletes them, along with finally removing monitor.c.

A manual update will be done separately.

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

* NEWS: Mention removed support for the various ROM monitors.
* Makefile.in (ALL_TARGET_OBS): Remove dbug-rom.o, dink32-rom.o,
ppcbug-rom.o, m32r-rom.o, dsrec.o and monitor.o from gdb_target_obs.
* configure.tgt (h8300-*-*): Remove monitor.o and m32r-rom.o from
gdb_target_obs.
(m68*-*-*): Remove monitor.o dbug-rom.o and dsrec.o from
gdb_target_obs.
(microblaze*-linux-*): Remove microblaze-rom.o, monitor.o and
dsrec.o from gdb_target_obs.
(microblaze*-*-*): Remove microblaze-rom.o, monitor.o and dsrec.o
from gdb_target_obs.
(powerpc-*-lynx*178): Remove monitor.o and dsrec.o from
gdb_target_obs.
(powerpc*-*-*): Remove monitor.o, dsrec.o, ppcbug-rom.o and
dink32-rom.o from gdb_target_obs.
(sh*-*-linux*): Remove monitor.o and dsrec.o from gdb_target_obs.
(sh*): Remove monitor.o and dsrec.o from gdb_target_obs.
* dbug-rom.c, dink32-rom.c, dsrec.c, m32r-rom.c, microblaze-rom.c,
monitor.c, monitor.h, ppcbug-rom.c, srec.h: Delete files.

9 years agoFix the partial disassembly of a broken three byte instruction at the end of a function.
Jan Stancek [Mon, 24 Aug 2015 13:50:15 +0000 (14:50 +0100)]
Fix the partial disassembly of a broken three byte instruction at the end of a function.

opcodes * i386-dis.c (print_insn): Fix decoding of three byte operands.

tests * gas/i386/intel.s: Add test of disassembly of a potential
three byte instuction at the end of a function.
* gas/i386/intel.d: Update expected disassembly.

9 years agognu_vector.exp: Avoid some more known FAILs
Andreas Arnez [Mon, 24 Aug 2015 13:37:40 +0000 (15:37 +0200)]
gnu_vector.exp: Avoid some more known FAILs

This avoids two more types of FAILs with the gnu_vector test case.

First, for POWER targets newer GCCs emit an ABI note when invoked with
"-mcpu=native".  Then the test case fell back to non-native compile,
producing code for a non-vector ABI.  But that is not supported by GDB.
Thus the compiler note is now suppressed with "-Wno-psabi".

Second, on s390 the test case produced FAILs after falling back to a
non-vector ABI when using "finish" or "return" in a vector-valued
function.  This was due to a long-standing known bug (Bug 8549).  This
case is now detected, and KFAILs are emitted instead.

gdb/testsuite/ChangeLog:

* gdb.base/gnu_vector.exp: Try compilation with "-mcpu=native
-Wno-psabi" if "-mcpu=native" fails.  For the tests with "finish"
and "return" use KFAIL when GDB can not read/write the vector
return value.

9 years agoMissing parts of fixes for in-tree libiconv
Yaakov Selkowitz [Mon, 24 Aug 2015 09:57:03 +0000 (10:57 +0100)]
Missing parts of fixes for in-tree libiconv

(Commit d23d1dff missed pushing the config/iconv.m4 change, and to
regenerate binutils' configure.)

Original description:

This is the second in a series of patches to make a build with an
in-tree GNU libiconv work as designed.

Currently GDB is the only toolchain component which actually uses an
in-tree libiconv.  This patch modifies the common AM_ICONV to use an
in-tree libiconv when present and not already provided by libc.
(GDB's workaround uses an in-tree libiconv even when libc provides
iconv(3); I'm not sure when or why that would be desirable.)

config/ChangeLog:
2015-08-24  Yaakov Selkowitz  <yselkowi@redhat.com>

* iconv.m4 (AM_ICONV_LINK): Use in-tree libiconv when present.

binutils/ChangeLog:
2015-08-24  Yaakov Selkowitz  <yselkowi@redhat.com>

* configure: Regenerate.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 24 Aug 2015 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoReorder enum output_type for better code generation
Alan Modra [Sun, 23 Aug 2015 11:24:45 +0000 (20:54 +0930)]
Reorder enum output_type for better code generation

Works around a gcc bug #67328 for the most commonly used of bfd_link_pic
and bfd_link_executable.

* bfdlink.h (enum output_type): Reorder enum.

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

9 years agoUninitialized vd_nodename
Alan Modra [Sat, 22 Aug 2015 03:54:34 +0000 (13:24 +0930)]
Uninitialized vd_nodename

Belt and braces fix.  Either of the changes here is sufficient to
ensure vd_nodename is initialized properly.

* elf.c (_bfd_elf_slurp_version_tables): Always init vd_nodename.
Don't copy fields not set by _bfd_elf_swap_verdef_in.

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 22 Aug 2015 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix ax.c:gdb_eval_agent_expr
Pedro Alves [Fri, 21 Aug 2015 22:59:33 +0000 (23:59 +0100)]
Fix ax.c:gdb_eval_agent_expr

In C++ mode:

 src/gdb/gdbserver/ax.c: In function â€˜eval_result_type gdb_eval_agent_expr(eval_agent_expr_context*, agent_expr*, ULONGEST*)’:
 src/gdb/gdbserver/ax.c:1335:11: error: invalid conversion from â€˜int’ to â€˜eval_result_type’ [-fpermissive]
     return 1;
    ^

"1" as an enum eval_result_type is expr_eval_empty_expression, but
clearly this wants to return expr_eval_unhandled_opcode.

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

* ax.c (gdb_eval_agent_expr): Return expr_eval_unhandled_opcode
instead of literal 1.

9 years agoC++: Initialize a couple const globals
Pedro Alves [Fri, 21 Aug 2015 22:49:37 +0000 (23:49 +0100)]
C++: Initialize a couple const globals

In C++ mode, we get:

 src/gdb/gdbserver/tdesc.c:43:33: error: uninitialized const â€˜default_description’ [-fpermissive]
  static const struct target_desc default_description;
  ^
 In file included from src/gdb/gdbserver/tdesc.c:19:0:
 src/gdb/gdbserver/tdesc.h:26:8: note: â€˜const struct target_desc’ has no user-provided default constructor
  struct target_desc
 ^

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

* frame.c (null_frame_id): Explicitly zero-initialize.

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

* tdesc.c (default_description): Explicitly zero-initialize.

9 years agogdb/dwarf2read.c: rename a field for c++
Tom Tromey [Fri, 21 Aug 2015 22:45:50 +0000 (23:45 +0100)]
gdb/dwarf2read.c: rename a field for c++

Fixes:

 ../../src/gdb/dwarf2read.c:127:15: error: declaration of â€˜asection* dwarf2_section_info::<anonymous union>::asection’ [-fpermissive]
      asection *asection;
^
 In file included from ../../src/gdb/common/common-types.h:35:0,
  from ../../src/gdb/common/common-defs.h:44,
  from ../../src/gdb/defs.h:28,
  from ../../src/gdb/dwarf2read.c:31:
 ../bfd/bfd.h:1596:3: error: changes meaning of â€˜asection’ from â€˜typedef struct bfd_section asection’ [-fpermissive]
  } asection;
    ^

gdb/ChangeLog:
2015-08-21  Tom Tromey  <tromey@redhat.com>

* dwarf2read.c (struct dwarf2_section_info): Rename field
'asection' to 'section'.
(dwarf2_has_info, get_section_bfd_owner, get_section_bfd_section)
(dwarf2_locate_sections, dwarf2_locate_sections)
(locate_dwz_sections, locate_v1_virtual_dwo_sections)
(dwarf2_locate_dwo_sections, dwarf2_locate_dwo_sections)
(dwarf2_locate_v2_dwp_sections): Adjust.

9 years agotui: don't overwrite a secondary prompt that was given no input
Patrick Palka [Fri, 21 Aug 2015 16:28:19 +0000 (12:28 -0400)]
tui: don't overwrite a secondary prompt that was given no input

This patch fixes the following bug in TUI:

  (gdb) break foo
  No symbol table is loaded.  Use the "file" command.
  Make breakpoint pending on future shared library load? (y or [n]) <ENTER>

By submitting an empty command line to a secondary prompt, the line
corresponding to the secondary prompt is undesirably cleared and
overwritten.  Outside of a secondary prompt, clearing the prompt line
after submitting an empty command line is intended behavior which
complements GDB's repeat-command shorthand.  But inside a secondary
prompt, this behavior is undesired since the shorthand is not applicable
in that case.  We should retain the secondary-prompt line even when it's
given no input.

This patch makes sure that a prompt that was given an empty command line
is cleared and overwritten only if it's not a secondary prompt.  To
acheive this, a new predicate is defined which informs us whether the
current input handler is a secondary prompt.

gdb/ChangeLog:

* top.h (gdb_in_secondary_prompt_p): Declare.
* top.c (gdb_secondary_prompt_depth): Define.
(gdb_in_secondary_prompt_p): Define.
(gdb_readline_wrapper_cleanup): Decrement
gdb_secondary_prompt_depth.
(gdb_readline_wrapper): Increment gdb_secondary_prompt_depth.
* tui/tui-io.c (tui_getc): Don't clear the prompt line if we
are in a secondary prompt.

9 years agoUse tui_putc to output newline entered by the user
Patrick Palka [Fri, 21 Aug 2015 16:04:25 +0000 (12:04 -0400)]
Use tui_putc to output newline entered by the user

This is necessary to make sure that start_line is updated after a
command has been entered.  Usually, start_line gets updated anyway
because most commands output text, and outputting text is done through
the function tui_puts, which updates start_line.  However if a command
does not output text, then tui_puts will not get called and start_line
will not get updated in time for the next prompt to be displayed.

One can observe this bug by executing the command "delete" within TUI.
After executing, the prompt line

  (gdb) delete

gets overwritten by the next prompt.  With this patch, the prompt line
gets preserved.

gdb/ChangeLog:

* tui/tui-io.c (tui_getc): Use tui_putc instead of waddch to
emit the newline.

9 years agoFix gdbserver crash exposed by gdb.threads/process-dies-while-handling-bp.exp
Pedro Alves [Fri, 21 Aug 2015 18:52:36 +0000 (19:52 +0100)]
Fix gdbserver crash exposed by gdb.threads/process-dies-while-handling-bp.exp

Running that test in a loop, I found a gdbserver core dump with the
following back trace:

 Core was generated by `../gdbserver/gdbserver --once --multi :2346'.
 Program terminated with signal SIGSEGV, Segmentation fault.
 #0  0x0000000000406ab6 in inferior_regcache_data (inferior=0x0) at src/gdb/gdbserver/inferiors.c:236
 236       return inferior->regcache_data;
 (gdb) up
 #1  0x0000000000406d7f in get_thread_regcache (thread=0x0, fetch=1) at src/gdb/gdbserver/regcache.c:31
 31        regcache = (struct regcache *) inferior_regcache_data (thread);
 (gdb) bt
 #0  0x0000000000406ab6 in inferior_regcache_data (inferior=0x0) at src/gdb/gdbserver/inferiors.c:236
 #1  0x0000000000406d7f in get_thread_regcache (thread=0x0, fetch=1) at src/gdb/gdbserver/regcache.c:31
 #2  0x0000000000409271 in prepare_resume_reply (buf=0x20dd593 "", ptid=..., status=0x20edce0) at src/gdb/gdbserver/remote-utils.c:1147
 #3  0x000000000040ab0a in vstop_notif_reply (event=0x20edcc0, own_buf=0x20dd590 "T05") at src/gdb/gdbserver/server.c:183
 #4  0x0000000000426b38 in notif_write_event (notif=0x66e6c0 <notif_stop>, own_buf=0x20dd590 "T05") at src/gdb/gdbserver/notif.c:69
 #5  0x0000000000426c55 in handle_notif_ack (own_buf=0x20dd590 "T05", packet_len=8) at src/gdb/gdbserver/notif.c:113
 #6  0x000000000041118f in handle_v_requests (own_buf=0x20dd590 "T05", packet_len=8, new_packet_len=0x7fff742c77b8)
     at src/gdb/gdbserver/server.c:2862
 #7  0x0000000000413850 in process_serial_event () at src/gdb/gdbserver/server.c:4148
 #8  0x0000000000413945 in handle_serial_event (err=0, client_data=0x0) at src/gdb/gdbserver/server.c:4196
 #9  0x000000000041a1ef in handle_file_event (event_file_desc=5) at src/gdb/gdbserver/event-loop.c:429
 #10 0x00000000004199b6 in process_event () at src/gdb/gdbserver/event-loop.c:184
 #11 0x000000000041a735 in start_event_loop () at src/gdb/gdbserver/event-loop.c:547
 #12 0x00000000004123d2 in captured_main (argc=4, argv=0x7fff742c7ac8) at src/gdb/gdbserver/server.c:3562
 #13 0x000000000041252e in main (argc=4, argv=0x7fff742c7ac8) at src/gdb/gdbserver/server.c:3631

Clearly this means that a thread pushed a stop reply in the event
queue, and then before GDB confused the event, the whole process died,
along with its thread.  But the pending thread event was left
dangling.  When GDB fetched that event, gdbserver looked up the
corresponding thread, but found NULL; not expecting this, gdbserver
crashes when it tries to read this thread's registers.

gdb/gdbserver/
2015-08-21  Pedro Alves  <palves@redhat.com>

PR gdb/18749
* inferiors.c (remove_thread): Discard any pending stop reply for
this thread.
* server.c (remove_all_on_match_pid): Rename to ...
(remove_all_on_match_ptid): ... this.  Work with a filter ptid
instead of a pid.
(discard_queued_stop_replies): Change parameter to a ptid.  Now
extern.
(handle_v_kill, kill_inferior_callback)
(process_serial_event): Adjust.
(captured_main): Call initialize_notif before starting the
program, thus before threads are created.
* server.h (discard_queued_stop_replies): Declare.

9 years agogdbserver: don't pick a random thread if the current thread dies
Pedro Alves [Fri, 21 Aug 2015 18:20:31 +0000 (19:20 +0100)]
gdbserver: don't pick a random thread if the current thread dies

In all-stop mode, if the current thread disappears while stopping all
threads, gdbserver calls set_desired_thread(0) ['0' means "I want the
continue thread"] which just picks the first thread in the list.

This looks like a dangerous thing to do.  GDBserver continues
processing whatever it was doing, but to the wrong thread.  If
debugging more than one process, we may even pick the wrong process.
Instead, GDBserver should detect the situation and bail out of
whatever is was doing.

The backends used to pay attention to the set 'cont_thread' (the Hc
thread, used in the old way to resume threads, before vCont), but all
such 'cont_thread' checks have been eliminated meanwhile.  The
remaining implicit dependencies that I found on there being a selected
thread in the backends are in the Ctrl-C handling, which some backends
use as thread to send a signal to.  Even that seems to me to be better
handled by always using the first thread in the list or by using the
signal_pid PID.

In order to make this a systematic approach, I'm making
set_desired_thread never fallback to a random thread, and instead end
up with current_thread == NULL, like already done in non-stop mode.
Then I updated all callers to handle the situation.

I stumbled on this while fixing other bugs exposed by
gdb.threads/fork-plus-threads.exp test.  The problems I saw were fixed
in a different way, but in any case, I think the potential for
problems is more or less obvious, and the resulting code looks a bit
less magical to me.

Tested on x86-64 Fedora 20, w/ native-extended-gdbserver board.

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

* linux-low.c (wait_for_sigstop): Always switch to no thread
selected if the previously current thread dies.
* lynx-low.c (lynx_request_interrupt): Use the first thread's
process instead of the current thread's.
* remote-utils.c (input_interrupt): Don't check if there's no
current thread.
* server.c (gdb_read_memory, gdb_write_memory): If setting the
current thread to the general thread fails, error out.
(handle_qxfer_auxv, handle_qxfer_libraries)
(handle_qxfer_libraries_svr4, handle_qxfer_siginfo)
(handle_qxfer_spu, handle_qxfer_statictrace, handle_qxfer_fdpic)
(handle_query): Check if there's a thread selected instead of
checking whether there's any thread in the thread list.
(handle_qxfer_threads, handle_qxfer_btrace)
(handle_qxfer_btrace_conf): Don't error out early if there's no
thread in the thread list.
(handle_v_cont, myresume): Don't set the current thread to the
continue thread.
(process_serial_event) <Hg handling>: Also set thread_id if the
previous general thread is still alive.
(process_serial_event) <g/G handling>: If setting the current
thread to the general thread fails, error out.
* spu-low.c (spu_resume, spu_request_interrupt): Use the first
thread's lwp instead of the current thread's.
* target.c (set_desired_thread): If the desired thread was not
found, leave the current thread pointing to NULL.  Return an int
(boolean) indicating success.
* target.h (set_desired_thread): Change return type to int.

9 years agoMake remote file transfers interruptible
Gary Benson [Fri, 21 Aug 2015 16:10:24 +0000 (17:10 +0100)]
Make remote file transfers interruptible

This commit makes it possible to interrupt remote file transfers.

9 years agoWarn when accessing binaries from remote targets
Gary Benson [Fri, 21 Aug 2015 16:09:20 +0000 (17:09 +0100)]
Warn when accessing binaries from remote targets

GDB provides no indicator of progress during file operations, and can
appear to have locked up during slow remote transfers.  This commit
updates GDB to print a warning each time a file is accessed over RSP.
An additional message detailing how to avoid remote transfers is
printed for the first transfer only.

gdb/ChangeLog:

* target.h (struct target_ops) <to_fileio_open>: New argument
warn_if_slow.  Update comment.  All implementations updated.
(target_fileio_open_warn_if_slow): New declaration.
* target.c (target_fileio_open): Renamed as...
(target_fileio_open_1): ...this.  New argument warn_if_slow.
Pass warn_if_slow to implementation.  Update debug printing.
(target_fileio_open): New function.
(target_fileio_open_warn_if_slow): Likewise.
* gdb_bfd.c (gdb_bfd_iovec_fileio_open): Use new function
target_fileio_open_warn_if_slow.

gdb/testsuite/ChangeLog:

* gdb.trace/pending.exp: Cope with remote transfer warnings.

9 years agoFix stale cleanup left by linux_mntns_access_fs
Gary Benson [Fri, 21 Aug 2015 15:55:53 +0000 (16:55 +0100)]
Fix stale cleanup left by linux_mntns_access_fs

This commit fixes a stale cleanup left by linux_mntns_access_fs.

gdb/ChangeLog:

* nat/linux-namespaces.c (linux_mntns_access_fs):
Do not overwrite old_chain.

9 years agoAllow symbol and label names to be enclosed in double quotes.
Nick Clifton [Fri, 21 Aug 2015 15:42:14 +0000 (16:42 +0100)]
Allow symbol and label names to be enclosed in double quotes.

gas PR gas/18581
* expr.c (get_symbol_end): Rename to get_symbol_name.  Add a
return parameter pointing to the start of the symbol.  Allow
symbol names enclosed in double quotes.
(restore_line_pointer): New function.  Replace the NUL character
inserted into the input stream with the given character.  If the
character was a double quote, advance the input pointer.
* expr.h (get_symbol_end): Delete.
(get_symbol_name): Add prototype.
(restore_line_pointer): Prototype.
* read.h (SKIP_WHITESPACE_AFTER_NAME): New macro.
* doc/as.texinfo (Symbol Intro): Document that symbol names can
now be enclosed in double quotes.
* cond.c (s_ifdef): Replace get_symbol_end with get_symbol_name.
Use restore_line_pointer to replace the NUL in the input stream.
Use SKIP_WHITESPACE_AFTER_NAME to skip past the end of a symbol.
Check for the use of double quoted symbol names.
* expr.c: Likewise.
* config/obj-aout.c: Likewise.
* config/obj-coff-seh.c: Likewise.
* config/obj-coff.c: Likewise.
* config/obj-elf.c: Likewise.
* config/obj-evax.c: Likewise.
* config/obj-macho.c: Likewise.
* config/obj-som.c: Likewise.
* config/tc-alpha.c: Likewise.
* config/tc-arc.c: Likewise.
* config/tc-arm.c: Likewise.
* config/tc-dlx.c: Likewise.
* config/tc-h8300.c: Likewise.
* config/tc-hppa.c: Likewise.
* config/tc-i370.c: Likewise.
* config/tc-i386-intel.c: Likewise.
* config/tc-i386.c: Likewise.
* config/tc-i960.c: Likewise.
* config/tc-ia64.c: Likewise.
* config/tc-iq2000.c: Likewise.
* config/tc-m32r.c: Likewise.
* config/tc-m68hc11.c: Likewise.
* config/tc-m68k.c: Likewise.
* config/tc-microblaze.c: Likewise.
* config/tc-mips.c: Likewise.
* config/tc-mmix.c: Likewise.
* config/tc-mn10200.c: Likewise.
* config/tc-mn10300.c: Likewise.
* config/tc-nios2.c: Likewise.
* config/tc-ppc.c: Likewise.
* config/tc-s390.c: Likewise.
* config/tc-score.c: Likewise.
* config/tc-score7.c: Likewise.
* config/tc-sparc.c: Likewise.
* config/tc-tic4x.c: Likewise.
* config/tc-tic54x.c: Likewise.
* config/tc-tic6x.c: Likewise.
* config/tc-tilegx.c: Likewise.
* config/tc-tilepro.c: Likewise.
* config/tc-v850.c: Likewise.
* config/tc-xtensa.c: Likewise.
* config/tc-z80.c: Likewise.
* dw2gencfi.c: Likewise.
* dwarf2dbgc.: Likewise.
* ecoff.c: Likewise.
* read.c: Likewise.
* stabs.c: Likewise.

tests PR gas/18581
* gas/all/byte.d: Disable this test.  Quoted expressions
are now allowed in .byte directives.
* gas/all/quoted-sym-names.s: New test.
* gas/all/quoted-sym-names.d: Expected output.
* gas/all/gas.exp: Run the new test.

9 years agoxtensa: implement NPTL helpers
Max Filippov [Thu, 2 Jul 2015 12:10:58 +0000 (15:10 +0300)]
xtensa: implement NPTL helpers

These changes allow debugging multithreaded NPTL xtensa applications.

2015-08-20  Max Filippov  <jcmvbkbc@gmail.com>
gdb/gdbserver/
* configure.srv (xtensa*-*-linux*): Add srv_linux_thread_db=yes.
* linux-xtensa-low.c (arch/xtensa.h gdb_proc_service.h): New
#includes.
(ps_get_thread_area): New function.

2015-08-20  Max Filippov  <jcmvbkbc@gmail.com>
gdb/
* arch/xtensa.h: New file.
* xtensa-linux-nat.c (gdb_proc_service.h): New #include.
(ps_get_thread_area): New function.
* xtensa-linux-tdep.c (xtensa_linux_init_abi): Add call to
set_gdbarch_fetch_tls_load_module_address to enable TLS support.
* xtensa-tdep.c (osabi.h): New #include.
(xtensa_gdbarch_init): Call gdbarch_init_osabi to register
xtensa-specific hooks.
* xtensa-tdep.h (struct xtensa_elf_gregset_t): Add threadptr
member and move the structure to arch/xtensa.h.

9 years agoPR binutils/18257: Properly decode x86/Intel mask instructions.
Alexander Fomin [Fri, 21 Aug 2015 11:06:41 +0000 (14:06 +0300)]
PR binutils/18257: Properly decode x86/Intel mask instructions.

opcodes/

PR binutils/18257
* i386-dis.c: Use MOD_TABLE for most of mask instructions.
(MOD enum): Add MOD_VEX_W_0_0F41_P_0_LEN_1, MOD_VEX_W_1_0F41_P_0_LEN_1,
MOD_VEX_W_0_0F41_P_2_LEN_1, MOD_VEX_W_1_0F41_P_2_LEN_1,
MOD_VEX_W_0_0F42_P_0_LEN_1, MOD_VEX_W_1_0F42_P_0_LEN_1,
MOD_VEX_W_0_0F42_P_2_LEN_1, MOD_VEX_W_1_0F42_P_2_LEN_1,
MOD_VEX_W_0_0F44_P_0_LEN_1, MOD_VEX_W_1_0F44_P_0_LEN_1,
MOD_VEX_W_0_0F44_P_2_LEN_1, MOD_VEX_W_1_0F44_P_2_LEN_1,
MOD_VEX_W_0_0F45_P_0_LEN_1, MOD_VEX_W_1_0F45_P_0_LEN_1,
MOD_VEX_W_0_0F45_P_2_LEN_1, MOD_VEX_W_1_0F45_P_2_LEN_1,
MOD_VEX_W_0_0F46_P_0_LEN_1, MOD_VEX_W_1_0F46_P_0_LEN_1,
MOD_VEX_W_0_0F46_P_2_LEN_1, MOD_VEX_W_1_0F46_P_2_LEN_1,
MOD_VEX_W_0_0F47_P_0_LEN_1, MOD_VEX_W_1_0F47_P_0_LEN_1,
MOD_VEX_W_0_0F47_P_2_LEN_1, MOD_VEX_W_1_0F47_P_2_LEN_1,
MOD_VEX_W_0_0F4A_P_0_LEN_1, MOD_VEX_W_1_0F4A_P_0_LEN_1,
MOD_VEX_W_0_0F4A_P_2_LEN_1, MOD_VEX_W_1_0F4A_P_2_LEN_1,
MOD_VEX_W_0_0F4B_P_0_LEN_1, MOD_VEX_W_1_0F4B_P_0_LEN_1,
MOD_VEX_W_0_0F4B_P_2_LEN_1, MOD_VEX_W_0_0F91_P_0_LEN_0,
MOD_VEX_W_1_0F91_P_0_LEN_0, MOD_VEX_W_0_0F91_P_2_LEN_0,
MOD_VEX_W_1_0F91_P_2_LEN_0, MOD_VEX_W_0_0F92_P_0_LEN_0,
MOD_VEX_W_0_0F92_P_2_LEN_0, MOD_VEX_W_0_0F92_P_3_LEN_0,
MOD_VEX_W_1_0F92_P_3_LEN_0, MOD_VEX_W_0_0F93_P_0_LEN_0,
MOD_VEX_W_0_0F93_P_2_LEN_0, MOD_VEX_W_0_0F93_P_3_LEN_0,
MOD_VEX_W_1_0F93_P_3_LEN_0, MOD_VEX_W_0_0F98_P_0_LEN_0,
MOD_VEX_W_1_0F98_P_0_LEN_0, MOD_VEX_W_0_0F98_P_2_LEN_0,
MOD_VEX_W_1_0F98_P_2_LEN_0, MOD_VEX_W_0_0F99_P_0_LEN_0,
MOD_VEX_W_1_0F99_P_0_LEN_0, MOD_VEX_W_0_0F99_P_2_LEN_0,
MOD_VEX_W_1_0F99_P_2_LEN_0, MOD_VEX_W_0_0F3A30_P_2_LEN_0,
MOD_VEX_W_1_0F3A30_P_2_LEN_0, MOD_VEX_W_0_0F3A31_P_2_LEN_0,
MOD_VEX_W_1_0F3A31_P_2_LEN_0, MOD_VEX_W_0_0F3A32_P_2_LEN_0,
MOD_VEX_W_1_0F3A32_P_2_LEN_0, MOD_VEX_W_0_0F3A33_P_2_LEN_0,
MOD_VEX_W_1_0F3A33_P_2_LEN_0.
(vex_w_table): Replace terminals with MOD_TABLE entries for
most of mask instructions.

gas/testsuite

PR binutils/18257
* gas/i386/disassem.s: Add mask instructions with invalid ModR/M byte.
* gas/i386/x86-64-disassem.s: Likewise.
* gas/i386/disassem.d: Updated.
* gas/i386/x86-64-disassem.d: Likewise.

9 years agoAdd readahead cache to gdb's vFile:pread
Pedro Alves [Fri, 21 Aug 2015 09:13:27 +0000 (10:13 +0100)]
Add readahead cache to gdb's vFile:pread

This patch almost halves the time it takes to "target remote + run to
main" on a higher-latency connection.

E.g., I've got a ping time of ~85ms to an x86-64 machine on the gcc
compile farm (almost 2000km away from me), and I'm behind a ~16Mbit
ADSL.  When I connect to a gdbserver debugging itself on that machine
and run to main, it takes almost 55 seconds:

 [palves@gcc76] $ ./gdbserver :9999 ./gdbserver
 [palves@home] $ ssh -L 9999:localhost:9999 gcc76.fsffrance.org
 [palves@home] $ time ./gdb -data-directory=data-directory -ex "tar rem :9999" -ex "b main" -ex "c" -ex "set confirm off" -ex "quit"

 Pristine gdb 7.10.50.20150820-cvs gets us:
 ...
 Remote debugging using :9999
 Reading symbols from target:/home/palves/gdb/build/gdb/gdbserver/gdbserver...done.
 Reading symbols from target:/lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
 0x00007ffff7ddd190 in ?? () from target:/lib64/ld-linux-x86-64.so.2
 Breakpoint 1 at 0x41200c: file ../../../src/gdb/gdbserver/server.c, line 3635.
 Continuing.

 Breakpoint 1, main (argc=1, argv=0x7fffffffe3d8) at ../../../src/gdb/gdbserver/server.c:3635
 3635    ../../../src/gdb/gdbserver/server.c: No such file or directory.
 /home/palves/gdb/build/gdb/gdbserver/gdbserver: No such file or directory.

 real    0m54.803s
 user    0m0.329s
 sys     0m0.064s

While with the readahead cache added by this patch, it drops to:

 real    0m29.462s
 user    0m0.454s
 sys     0m0.054s

I added a few counters to show cache hit/miss, and got:

 readahead cache miss 142
 readahead cache hit 310

Tested on x86_64 Fedora 20.

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

* remote.c (struct readahead_cache): New.
(struct remote_state) <readahead_cache>: New field.
(remote_open_1): Invalidate the cache.
(readahead_cache_invalidate, readahead_cache_invalidate_fd): New
functions.
(remote_hostio_pwrite): Invalidate the readahead cache.
(remote_hostio_pread): Rename to ...
(remote_hostio_pread_vFile): ... this.
(remote_hostio_pread_from_cache): New function.
(remote_hostio_pread): Reimplement.
(remote_hostio_close): Invalidate the readahead cache.

9 years agoprocfs.c: Include "filestuff.h"
Marcin Cieslak [Wed, 19 Aug 2015 16:51:31 +0000 (16:51 +0000)]
procfs.c: Include "filestuff.h"

Fixes implicit function declaration
error in gdb/procfs.c:4927 about undeclared
make_cleanup_close().

gdb/ChangeLog:

PR build/18843
* procfs.c: Include "filestuff.h".

9 years agoRemove fields curch and cur_line from TUI_CMD_WIN
Patrick Palka [Wed, 19 Aug 2015 01:08:57 +0000 (21:08 -0400)]
Remove fields curch and cur_line from TUI_CMD_WIN

These fields are currently used to track the location of the cursor
inside the command window.  But their usefulness is questionable because
ncurses already internally keeps track of the location of the cursor,
whose coordinates we can query using the functions getyx(), getcurx() or
getcury().  It is an unnecessary pain to keep these fields in sync with
ncurses, and their meaning is not well-defined anyway.  For instance, it
is not clear whether the coordinates held in these fields are
authoritative, or whether the coordinates reported by ncurses are.

So to keep things simple, this patch removes these fields and replaces
existing reads of these fields with calls to the appropriate ncurses
querying functions, and replaces writes to these fields with calls to
wmove() (when necessary and applicable).

In the function tui_cont_sig(), I removed the call to wmove() entirely
because moving to (start_line, curch) makes no sense.  The move should
have been to (cur_line, curch) -- which would now be a no-op.

Tested on x86_64 Fedora 22, no obvious regressions.

gdb/ChangeLog:

* tui/tui-data.h (tui_command_info): Remove fields cur_line and
curch.
* tui/tui-data.c (tui_clear_win_detail) [CMD_WIN]: Don't set
cur_line or curch, instead call wmove().
(init_win_info) [CMD_WIN]: Likewise.
* tui/tui-io.c (tui_puts): Likewise. Don't read cur_line,
instead call getcury().
(tui_redisplay_readline): Don't set cur_line or curch.
(tui_mld_erase_entire_line): Don't read cur_line, instead call
getcury().
(tui_cont_sig): Remove call to wmove.
(tui_getc): Don't read cur_line or curch, instead call getcury()
or getyx().  Don't set curch.
* tui/tui-win.c (make_visible_with_new_height) [CMD_WIN]: Don't
set cur_line or curch.  Always move cursor to (0,0).

9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 21 Aug 2015 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix gdb.server/solib-list.exp native-extended-gdbserver regression
Pedro Alves [Thu, 20 Aug 2015 19:08:48 +0000 (20:08 +0100)]
Fix gdb.server/solib-list.exp native-extended-gdbserver regression

Commit 221e1a37 (remote non-stop: Process initially stopped threads
before other commands) caused a test regression when testing with the
native-extended-gdbserver board:

  FAIL: gdb.server/solib-list.exp: non-stop 1: non-stop interior stop (timeout)

This "interior stop" now happens before "target remote" prints the
prompt, so we should no longer explicitly expect it.

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

* gdb.server/solib-list.exp: No longer expect an interior stop in
non-stop mode.

9 years agoremote non-stop: Process initially stopped threads before other commands
Pedro Alves [Thu, 20 Aug 2015 17:27:55 +0000 (18:27 +0100)]
remote non-stop: Process initially stopped threads before other commands

The main motivation for this is making non-stop / all-stop behave
similarly on initial connection, in order to move in the direction of
reimplementing all-stop mode with the remote target always running in
non-stop mode.

When we connect to a remote target in non-stop mode, we may find
threads either running or already stopped.  The act of connecting
itself does not force threads to stop.  To handle that, the remote
non-stop connection is currently roughly like this:

 #1 - Fetch list of remote threads (qXfer:threads:read, qfThreadInfo,
    etc).  All threads are assumed to be running until the target
    reports an asynchronous stop reply for them.

 #2 - Fetch the initial set of threads that were already stopped, with
    the '?'  packet.  (In non-stop, this is coupled with the vStopped
    mechanism to be able to retrieve the status of more than one
    thread.)

The stop replies fetched in #2 are placed in the pending stop reply
queue, and left for the regular event loop to process.  That is,
"target remote" finishes and returns _before_ those stops are
processed.

That means that it's possible to have GDB process further commands
before the initial set of stopped threads is reported to the user.

E.g., before the patch, note how the prompt is printed before the
frame:

 Remote debugging using :9999
 (gdb)
 [Thread 15296] #1 stopped.
 0x0000003615a011f0 in ?? ()

Even though thread #1 was not running, for a moment, the user can see
it as such:

 $ gdb a.out -ex "set non-stop 1" -ex "tar rem :9999"  -ex "info threads" -ex "info registers"
 Remote debugging using :9999
   Id   Target Id         Frame
 * 1    Thread 4772       (running)
 Target is executing.                 <<<<<<< info registers
 (gdb)
 [Thread 4772] #1 stopped.
 0x0000003615a011f0 in ?? ()

To fix that, this commit makes gdb process all threads found already
stopped at connection time, before giving the prompt to the user.

The fix takes a cue from fork-child.c:startup_inferior [1], and
processes the events locally in remote.c, avoiding the whole
wait_for_inferior/handle_inferior_event path.  I decided to try this
approach after noticing that:

 - several cases in handle_inferior_event miss checking stop_soon.
 - we don't want to fetch the thread list in normal_stop.

and trying to fix them was resulting in sprinkling stop_soon checks in
many places, and uglifying normal_stop even more.

While with this patch, I'm avoiding changing GDB's output other than
when the prompt is printed, I think this approach is more flexible if
we do want to change it.  And also, it's likely easier to get rid of
the MI *running event that is still sent for threads that are
initially found stopped, if we want to.

This happens to fix the testsuite too.  All non-stop tests are racy
against "target remote" / gdbserver testing currently.  That is,
sometimes the tests run, but other times they're just skipped without
any indication of PASS/FAIL.  When that happens, the logs show:

 target remote localhost:2346
 Remote debugging using localhost:2346
 (gdb)
 [Thread 25418] #1 stopped.
 0x0000003615a011f0 in ?? ()
 ^CQuit
 (gdb) Remote debugging from host 127.0.0.1
 Killing process(es): 25418
 monitor exit
 (gdb) Remote connection closed
 (gdb) testcase /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp completed in 61 seconds

The trouble here is that there's output after the prompt, and the
regex in question doesn't expect that:

   -re "Remote debugging using .*$serialport_re.*$gdb_prompt $" {
verbose "Set target to $targetname"
return 0
    }

[1] - before startup_inferior was added, we'd go through
wait_for_inferior/handle_inferior_event while going through the shell,
and that turned out problematic.

Tested on x86_64 Fedora 20, gdbserver.

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

* infrun.c (print_target_wait_results): Make extern.
* infrun.h (print_target_wait_results): Declare.
* remote.c (set_stop_requested_callback): Delete.
(process_initial_stop_replies): New function.
(remote_start_remote): Use it.
(stop_reply_queue_length): New function.

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

* gdb.server/connect-stopped-target.c: New file.
* gdb.server/connect-stopped-target.exp: New file.

9 years agoFix language of compilation unit with unknown file extension
Pedro Alves [Thu, 20 Aug 2015 11:30:08 +0000 (12:30 +0100)]
Fix language of compilation unit with unknown file extension

Here, in dwarfread.c:process_full_comp_unit:

      /* Set symtab language to language from DW_AT_language.  If the
 compilation is from a C file generated by language preprocessors, do
 not set the language if it was already deduced by start_subfile.  */
      if (!(cu->language == language_c
    && COMPUNIT_FILETABS (cust)->language != language_c))
COMPUNIT_FILETABS (cust)->language = cu->language;

in case start_subfile doesn't manage to deduce a language
COMPUNIT_FILETABS(cust)->language ends up as language_unknown, not
language_c.  So the condition above evals false and we never set the
language from the cu's language.

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

* dwarf2read.c (process_full_comp_unit): To tell whether
start_subfile managed to deduce a language, test for
language_unknown instead of language_c.

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

* gdb.dwarf2/comp-unit-lang.exp: New file.
* gdb.dwarf2/comp-unit-lang.c: New file.

9 years ago[Ada] Fix parsing for expressions with attributes and characters
Pierre-Marie de Rodat [Wed, 19 Aug 2015 15:12:48 +0000 (17:12 +0200)]
[Ada] Fix parsing for expressions with attributes and characters

Before this change, trying to evaluate the following Ada expression
yielded a syntax error, even though it's completely legal:

    (gdb) p s'first = 'a'
    Error in expression, near `'.

The problem lies in the lexer (gdb/ada-lex.l): at the point we reach "'a'",
we're still in the BEFORE_QUAL_QUOTE start condition (the mechanism to
distinguish character literals from other "tick" usages: qualified
expressions and attributes), so we consider that this quote is actually a
separate "tick".

This changes resets the start condition to INITIAL in the
{TICK}[a-zA-Z][a-zA-Z]+ rule (for attributes): attributes activate this
BEFORE_QUAL_QUOTE condition and in this case the above rule is always
executed rather than the <BEFORE_QUAL_QUOTE>"'" one (in flex, it's
always the longest match that is chosen). We now have instead:

    (gdb) p s'first = 'a'
    $1 = true

gdb/ChangeLog:

* ada-lex.l: Reset the start condition to INITIAL in the rule
that matches attributes.

gdb/testsuite/ChangeLog:

* gdb.ada/attr_ref_and_charlit.exp: New testcase.
* gdb.ada/attr_ref_and_charlit/foo.adb: New file.

Tested on x86_64-linux, no regression.

9 years agogold --emit-relocs
Alan Modra [Thu, 20 Aug 2015 02:32:45 +0000 (12:02 +0930)]
gold --emit-relocs

A symbol value in an ELF final linked binary is absolute, in contrast
to a relocatable object file where the value is section relative.  For
--emit-relocs it is therefore incorrect to use the value of a section
symbol as the addend when adjusting relocs against input section
symbols to output section symbols.

PR gold/18846
* target-reloc.h (relocate_relocs <RELOC_ADJUST_FOR_SECTION_RELA>):
Subtract os->address() from addend.
* powerpc.cc (relocate_relocs): Likewise.

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

9 years agodwarf2read.c: Check type of string valued attributes prior to decoding.
Kevin Buettner [Mon, 3 Aug 2015 21:17:17 +0000 (14:17 -0700)]
dwarf2read.c: Check type of string valued attributes prior to decoding.

This change introduces a new function, dwarf2_string_attr(), which is
a wrapper for dwarf2_attr().  dwarf2read.c has been updated to
call dwarf2_string_attr in most instances where a string-valued
attribute is decoded to produce a string value.  In most cases, it
simplifies the code; in some instances, the complexity of the code
remains unchanged.

I performed this change by looking for instances where the
result of DW_STRING was used in an assignment.  Many of these
had a pattern which (roughly) looks something like this:

  struct attribute *attr = NULL;

  attr = dwarf2_attr (die, name, cu);
  if (attr != NULL && DW_STRING (attr))
    {
      const char *str;
      ...
      str = DW_STRING (attr);
      ... /* Use str in some fashion.  */
    }

Code of this form is transformed to look like this instead:

  const char *str;

  str = dwarf2_string_attr (die, name, cu)
  if (str != NULL)
    {
       ...
       /* Use str in some fashion.  */
       ...
    }

In addition to invoking dwarf2_attr() and DW_STRING(),
dwarf2_string_attr() checks to make sure that the attribute's
`form' field matches one of DW_FORM_strp, DW_FORM_string, or
DW_FORM_GNU_strp_alt.  If it does not match one of these forms,
it will return a NULL value in addition to calling complaint().

An earlier version of this patch did this type checking for one
particular instance where a string attribute was being decoded.
The situation that I was attempting to handle in that earlier patch is
this:

The Texas Instruments compiler uses the encoding for
DW_AT_MIPS_linkage_name for other purposes.  TI uses the encoding,
0x2007, for TI_AT_TI_end_line which, unlike DW_AT_MIPS_linkage_name,
does not have a string-typed value.  In this instance, GDB was attempting
to use an integer value as a string pointer, with predictable results.
(GDB would die with a segmentation fault.)

I've added a test which reproduces the problem that I was orignally
wanting to fix.  It uses DW_AT_MIPS_linkage name with an associate
value which is a string, and again, where the value is a small
integer.

My test case causes GDB to segfault in an unpatched GDB.  There
will be two PASSes in a patched GDB.

Unpatched GDB:

(gdb) ptype f
ERROR: Process no longer exists
UNRESOLVED: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype f
ERROR: Couldn't send ptype g to GDB.
UNRESOLVED: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype g

Patched GDB:

(gdb) ptype f
type = bool ()
(gdb) PASS: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype f
ptype g
type = bool ()
(gdb) PASS: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype g

I see no regressions on an x86_64 native target.

gdb/ChangeLog:

* dwarf2read.c (dwarf2_string_attr): New function.
(lookup_dwo_unit, process_psymtab_comp_unit_reader)
(dwarf2_compute_name, dwarf2_physname, find_file_and_directory)
(read_call_site_scope, namespace_name, guess_full_die_structure_name)
(anonymous_struct_prefix, prepare_one_comp_unit): Use
dwarf2_string_attr in place of dwarf2_attr and DW_STRING.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-bad-mips-linkage-name.c: New file.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp: New file.

9 years ago[AArch64][6/6] LD support TLSLD load/store relocation types
Jiong Wang [Wed, 19 Aug 2015 10:26:56 +0000 (11:26 +0100)]
[AArch64][6/6] LD support TLSLD load/store relocation types

2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize new relocation
  types, including BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC.
  (elfNN_aarch64_final_link_relocate): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/emit-relocs-531.s: New testcase.
  * ld-aarch64/emit-relocs-531-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-532.s: Likewise.
  * ld-aarch64/emit-relocs-533.s: Likewise.
  * ld-aarch64/emit-relocs-533-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-534.s: Likewise.
  * ld-aarch64/emit-relocs-535.s: Likewise.
  * ld-aarch64/emit-relocs-535-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-536.s: Likewise.
  * ld-aarch64/emit-relocs-537.s: Likewise.
  * ld-aarch64/emit-relocs-537-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-538.s: Likewise.
  * ld-aarch64/emit-relocs-531.d: New expectation file.
  * ld-aarch64/emit-relocs-531-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-532.d: Likewise.
  * ld-aarch64/emit-relocs-533.d: Likewise.
  * ld-aarch64/emit-relocs-533-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-534.d: Likewise.
  * ld-aarch64/emit-relocs-535.d: Likewise.
  * ld-aarch64/emit-relocs-535-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-536.d: Likewise.
  * ld-aarch64/emit-relocs-537.d: Likewise.
  * ld-aarch64/emit-relocs-537-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-538.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new testcases.

9 years ago[AArch64][5/6] GAS support TLSLD load/store relocation types
Jiong Wang [Wed, 19 Aug 2015 10:22:22 +0000 (11:22 +0100)]
[AArch64][5/6] GAS support TLSLD load/store relocation types

2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * reloc.c: New entries, including
  BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC.
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC.
  * elfnn-aarch64.c (elfNN_aarch64_howto_table): Likewise.
  * bfd-in2.h: Regenerate.
  * libbfd.h: Regenerate.

gas/
  * config/tc-aarch64.c (reloc_table): New relocation types support for
  dtprel_lo12.
  (ldst_lo12_determine_real_reloc_type): Support
  BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC.
  (parse_operands): Likewise.
  (md_apply_fix): Likewise
  (aarch64_force_relocation): Likewise.
  (process_movw_reloc_info): Likewise.

gas/testsuite/
  * gas/aarch64/reloc-dtprel_lo12-ldst8.s: New testcase.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldstc.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst16.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst16.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst32.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst32.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst64.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst64.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst8.d: New expectation file.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst8.d: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst16.d: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst16.d: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst32.d: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst32.d: Likewise.
  * gas/aarch64/reloc-dtprel-lo12-ldst64.d: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst64.d: Likewise.

9 years ago[AArch64][4/6] LD support TLSLD move/add relocation types
Jiong Wang [Wed, 19 Aug 2015 10:18:25 +0000 (11:18 +0100)]
[AArch64][4/6] LD support TLSLD move/add relocation types

2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  PR ld/18276
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize new relocation
  types, including BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2.
  (elfNN_aarch64_final_link_relocate): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/emit-relocs-87.s: New testcase.
  * ld-aarch64/emit-relocs-88.s: Likewise.
  * ld-aarch64/emit-relocs-88-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-89.s: Likewise.
  * ld-aarch64/emit-relocs-90.s: Likewise.
  * ld-aarch64/emit-relocs-90-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-523.s: Likewise.
  * ld-aarch64/emit-relocs-524.s: Likewise.
  * ld-aarch64/emit-relocs-525.s: Likewise.
  * ld-aarch64/emit-relocs-527.s: Likewise.
  * ld-aarch64/emit-relocs-526.s: Likewise.
  * ld-aarch64/emit-relocs-528.s: Likewise.
  * ld-aarch64/emit-relocs-528-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-87.d: New expectation file.
  * ld-aarch64/emit-relocs-88.d: Likewise.
  * ld-aarch64/emit-relocs-88-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-89.d: Likewise.
  * ld-aarch64/emit-relocs-90.d: Likewise.
  * ld-aarch64/emit-relocs-90-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-91.d: Likewise.
  * ld-aarch64/emit-relocs-523.d: Likewise.
  * ld-aarch64/emit-relocs-524.d: Likewise.
  * ld-aarch64/emit-relocs-525.d: Likewise.
  * ld-aarch64/emit-relocs-526.d: Likewise.
  * ld-aarch64/emit-relocs-527.d: Likewise.
  * ld-aarch64/emit-relocs-528.d: Likewise.
  * ld-aarch64/emit-relocs-528-overflow.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new testcases.

9 years ago[AArch64][3/6] GAS support TLSLD move/add relocation types
Jiong Wang [Wed, 19 Aug 2015 10:02:34 +0000 (11:02 +0100)]
[AArch64][3/6] GAS support TLSLD move/add relocation types

2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * reloc.c (BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2): New entries.
  * elfnn-aarch64.c (elfNN_aarch64_howto_table): Likewise.
  * bfd-in2.h: Regenerate.
  * libbfd.h: Regenerate.

gas/
  * config/tc-aarch64.c (reloc_table): New relocation modifiers,
  "dtprel_hi12", "dtprel_g0", "dtprel_g0_nc", "dtprel_g1",
  "dtprel_g1_nc", "dtprel_g2".
  (md_apply_fix): Support new relocation types.
  (aarch64_force_relocation): Likewise.
  (process_movw_reloc_info): Likewise.

gas/testsuite/
  * gas/aarch64/reloc-dtprel_g0.s: New testcase.
  * gas/aarch64/reloc-dtprel_g0-ilp32.s: Likewise.
  * gas/aarch64/reloc-dtprel_g0_nc.s: Likewise.
  * gas/aarch64/reloc-dtprel_g0_nc-ilp32.s: Likewise.
  * gas/aarch64/reloc-dtprel_g1.s: Likewise.
  * gas/aarch64/reloc-dtprel_g1-ilp32.s: Likewise.
  * gas/aarch64/reloc-dtprel_g1_nc.s: Likewise.
  * gas/aarch64/reloc-dtprel_g2.s: Likewise.
  * gas/aarch64/reloc-dtprel_hi12.s: Likewise.
  * gas/aarch64/reloc-dtprel_hi12-ilp32.s: Likewise.
  * gas/aarch64/reloc-dtprel_g0.d: New expectation file.
  * gas/aarch64/reloc-dtprel_g0-ilp32.d: Likewise.
  * gas/aarch64/reloc-dtprel_g0_nc.d: Likewise.
  * gas/aarch64/reloc-dtprel_g0_nc-ilp32.d: Likewise.
  * gas/aarch64/reloc-dtprel_g1.d: Likewise.
  * gas/aarch64/reloc-dtprel_g1-ilp32.d: Likewise.
  * gas/aarch64/reloc-dtprel_g1_nc.d: Likewise.
  * gas/aarch64/reloc-dtprel_g2.d: Likewise.
  * gas/aarch64/reloc-dtprel_hi12.d: Likewise.
  * gas/aarch64/reloc-dtprel_hi12-ilp32.d: Likewise.

9 years ago[AArch64][2/6] LD support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC
Jiong Wang [Wed, 19 Aug 2015 09:58:13 +0000 (10:58 +0100)]
[AArch64][2/6] LD support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC

2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize
  BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC.
  (aarch64_reloc_got_type): Likewise.
  (elfNN_aarch64_final_link_relocate): Likewise.
  (elfNN_aarch64_relocate_section): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/emit-relocs-530.s: New testcase.
  * ld-aarch64/emit-relocs-92.s: Likewise.
  * ld-aarch64/emit-relocs-530.d: New expectation file.
  * ld-aarch64/emit-relocs-92.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new testcases.

9 years ago[AArch64][1/6] GAS support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC
Jiong Wang [Wed, 19 Aug 2015 09:57:34 +0000 (10:57 +0100)]
[AArch64][1/6] GAS support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC

2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * reloc.c (BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC): New entry.
  * bfd-in2.h: Regenerate.
  * libbfd.h: Regenerate.
  * elfnn-aarch64.c (elfNN_aarch64_howto_table): New entry for
  BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC.

gas/
  * config/tc-aarch64.c (reloc_table): New relocation modifiers.
  (md_apply_fix): Support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC.
  (aarch64_force_relocation): Likewise.

gas/testsuite/
  * gas/aarch64/reloc-dtprel_lo12_nc.s: New testcase.
  * gas/aarch64/reloc-dtprel_lo12_nc-ilp32.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc.d: New expectation file.
  * gas/aarch64/reloc-dtprel_lo12_nc-ilp32.d: Likewise.

9 years agoPrelimit number of bytes to read in "vFile:pread:"
Gary Benson [Wed, 19 Aug 2015 12:53:24 +0000 (13:53 +0100)]
Prelimit number of bytes to read in "vFile:pread:"

While handling "vFile:pread:" packets, gdbserver would read the
number of bytes requested regardless of whether this would fit
into the reply packet.  gdbserver would then return a packet's
worth of data and discard the remainder.  When accessing large
binaries GDB (via BFD) routinely makes large "vFile:pread:"
requests, resulting in gdbserver allocating large unnecessary
buffers and reading some portions of the file many times over.

This commit causes gdbserver to limit the number of bytes to be
read to a sensible maximum prior to allocating buffers and reading
data.

gdb/gdbserver/ChangeLog:

* hostio.c (handle_pread): Do not attempt to read more data
than hostio_reply_with_data can fit in a packet.

9 years agoRemove link_info.pic
Alan Modra [Wed, 19 Aug 2015 03:02:54 +0000 (12:32 +0930)]
Remove link_info.pic

Adding type_pie to output_type allows us to remove link_info.pic and
with some reordering of the enum, produces better code.

include/
* bfdlink.h (enum output_type): Delete type_executable, add type_pde
and type_pie.  Reorder.
(struct bfd_link_info): Delete pic field.
(bfd_link_executable, bfd_link_pde, bfd_link_pie, bfd_link_pic): Adjust.
ld/
* emultempl/aix.em: Don't set link_info.pic.
* emultempl/pe.em: Likewise.
* emultempl/pep.em: Likewise.
* emultempl/sunos.em: Likewise.
* lexsup.c (parse_args): Likewise.  Set type_pie for -pie.
* plugin.c (set_tv_header <LDPT_LINKER_OUTPUT>): Simplify.

9 years agoAdd bfd_link_pde, and simplify some tests of link_info.type
Alan Modra [Wed, 19 Aug 2015 02:27:40 +0000 (11:57 +0930)]
Add bfd_link_pde, and simplify some tests of link_info.type

include/
* bfdlink.h (bfd_link_pde): Define.
bfd/
* elf-s390-common.c: Simplify expressions using
bfd_linke_executable, bfd_link_pie and bfd_link_pic.
* elf32-arm.c: Likewise.
* elf32-bfin.c: Likewise.
* elf32-frv.c: Likewise.
* elf32-m68k.c: Likewise.
* elf32-nios2.c: Likewise.
* elf32-ppc.c: Likewise.
* elf32-s390.c: Likewise.
* elf32-sh.c: Likewise.
* elf64-alpha.c: Likewise.
* elf64-ppc.c: Likewise.
* elf64-s390.c: Likewise.
* elflink.c: Likewise.

9 years agoFix symbol versioning problems in PR 18703.
Cary Coutant [Mon, 27 Jul 2015 22:09:08 +0000 (15:09 -0700)]
Fix symbol versioning problems in PR 18703.

If a symbol is defined with ".symver foo,foo@VER", the assembler
creates two symbols in the object: one unversioned, and one with
the (non-default) version "VER". If foo is listed in a version
script, gold would then make the first of those symbols the
default version, and would ignore the second symbol as a
duplicate, without making it a non-default version. While this is
arguably reasonable behavior, it doesn't match Gnu ld behavior,
so this patch fixes that by allowing the second definition to
override the first by resetting the "default version" indication.

Several test cases from the Gnu ld testsuite also exposed another
related problem, where a symbol defined with ".symver foo,foo@",
placed into a shared library, is not handled properly by gold.
This patch also fixes that case, binding the symbol to the base
version.

gold/
PR gold/18703
* dynobj.cc (Versions::record_version): Handle symbol defined with
base version.
(Versions::symbol_section_contents): Likewise.
* symtab.h (Symbol::set_is_not_default): New class method.
(Symbol_table::resolve): Add is_default_version parameter.
(Symbol_table::should_override): Likewise.
* resolve.cc (Symbol_table::resolve): Add is_default_version parameter,
and pass to should_override. Adjust all callers and explicit
instantiations.
(Symbol_table::should_override): Add is_default_value parameter;
allow default version in a dynamic object to override existing
definition from same object.
* symtab.cc (Symbol_table::add_from_object): Handle case where same
symbol is defined as unversioned and non-default version in the same
object.
* testsuite/Makefile.am (ver_test_13): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/ver_test_4.cc: Add test for symbol with base version.
* testsuite/ver_test_4.sh: Likewise.
* testsuite/ver_test_13.c: New source file.
* testsuite/ver_test_13.script: New version script.
* testsuite/ver_test_13.sh: New test case.

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

9 years agogdbserver/linux-aarch32-low: build failure when NT_ARM_VFP not defined
Joel Brobecker [Tue, 11 Aug 2015 19:28:19 +0000 (15:28 -0400)]
gdbserver/linux-aarch32-low: build failure when NT_ARM_VFP not defined

On some older versions of GNU/Linux, gdbserver now fails to build
due to an undefined reference to NT_ARM_VFP. Same issue on Android,
where this macros is undefined until Android API level 21 (Android
5.0 "Lollipop").

This patch modifies linux-aarch32-low.c to define that macros when
not already defined.

gdb/gdbserver/ChangeLog:

        * linux-aarch32-low.c (NT_ARM_VFP): Define if not already defined.

9 years agoPR mi/18833 gdb.execute ("set param value", to_string=True) will crash gdb if using MI
Doug Evans [Tue, 18 Aug 2015 21:02:03 +0000 (14:02 -0700)]
PR mi/18833 gdb.execute ("set param value", to_string=True) will crash gdb if using MI

gdb/ChangeLog:

* cli/cli-logging.c (pop_output_files): Don't restore redirection
if MI-like.
* mi/mi-out.c: #include "vec.h".
(ui_filep): New type.
(DEV_VEC_P (ui_filep)): New type.
(struct ui_out_data) <buffer, original_buffer>: Delete.
(struct ui_out_data) <streams>: New member.
(mi_ui_out_impl): Add data_destroy field.
(mi_field_string, mi_field_fmt): Update.
(mi_flush, mi_redirect, field_separator): Update.
(mi_open, mi_close): Update.
(mi_out_buffered, mi_out_rewind, mi_out_put): Update.
(mi_out_data_ctor, mi_out_data_dtor): New functions.
(mi_out_new): Call mi_out_data_ctor.

testsuite/gdb/ChangeLog:

* lib/gdb.exp (skip_python_tests_prompt): Renamed from
skip_python_tests.  New arg prompt_regexp.
(skip_python_tests): New function.
* lib/mi-support.exp (mi_skip_python_tests): New function.
* gdb.python/py-mi-objfile-gdb.py: New file.
* gdb.python/py-mi-objfile.c: New file.
* gdb.python/py-mi-objfile.exp: New file.

9 years agoAdd another test for PR ld/18841
H.J. Lu [Tue, 18 Aug 2015 17:43:19 +0000 (10:43 -0700)]
Add another test for PR ld/18841

PR ld/18841
* ld-ifunc/ifunc.exp: Add another test for PR ld/18841.
* ld-ifunc/pr18841c.c: New file.

9 years agoFix mis-parsing of hex register numbers in 'T' stop replies.
Sandra Loosemore [Tue, 18 Aug 2015 17:29:54 +0000 (10:29 -0700)]
Fix mis-parsing of hex register numbers in 'T' stop replies.

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

gdb/
* remote.c (strprefix): New.
(remote_parse_stop_reply): Use strprefix instead of strncmp
to ensure exact match of keyword.

9 years agoReturn reloc_class_ifunc for reloc against IFUNC
H.J. Lu [Tue, 18 Aug 2015 16:47:59 +0000 (09:47 -0700)]
Return reloc_class_ifunc for reloc against IFUNC

elf_XXX_reloc_type_class should return reloc_class_ifunc for relocation
against STT_GNU_IFUNC symbol.

bfd/

PR ld/18841
* elf-bfd.h (elf_link_hash_table): Add dynsym.
* elf32-i386.c (elf_i386_reloc_type_class): Return
reloc_class_ifunc for relocation against STT_GNU_IFUNC symbol.
* elf64-x86-64.c (elf_x86_64_reloc_type_class): Likewise.
* elflink.c (_bfd_elf_link_create_dynamic_sections): Set dynsym.
(bfd_elf_size_dynsym_hash_dynstr): Use dynsym.
(elf_final_link_info): Remove dynsym_sec.
(elf_link_output_extsym): Replace dynsym_sec with dynsym.
(bfd_elf_final_link): Remove reference to dynsym_sec.  Replace
dynsym_sec with dynsym.

ld/testsuite/

PR ld/18841
* ld-ifunc/ifunc.exp: Add a test for PR ld/18841.
* ld-ifunc/pr18841.out: New file.
* ld-ifunc/pr18841a.c: Likewise.
* ld-ifunc/pr18841b.c: Likewise.

9 years agogdb/doc: Fix build of 'info' manual.
Andrew Burgess [Tue, 18 Aug 2015 16:09:41 +0000 (17:09 +0100)]
gdb/doc: Fix build of 'info' manual.

In commit 18989b3c5642e2ba533e02737797dcf06134229b I broke the creation
of gdb's info manual; I added a new section without adding a suitable
menu entry.

This commit adds the missing menu entry and fixes the build of gdb's
info manual.

gdb/doc/ChangeLog:

* gdb.texinfo (GDB Files): Add 'File Caching' menu entry.

9 years ago[AArch64] Cleanup TLS relocation types which don't go through GOT table
Jiong Wang [Tue, 18 Aug 2015 15:50:56 +0000 (16:50 +0100)]
[AArch64] Cleanup TLS relocation types which don't go through GOT table

This patch done two types of cleanup:

  * in aarch64_reloc_got_type and elfNN_aarch64_relocate_section

    We don't need those redundant "case" check, as they can be merged
    with the "default" which just "break".

  * in elfNN_aarch64_gc_sweep_hook and elfNN_aarch64_check_relocs

    All TLS local executable relocations and some local dynamic
    relocations (those calculate module offset) actually don't need GOT
    entry, so remove them from GOT entry counting.

2015-08-18  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (aarch64_reloc_got_type): Delete useless check.
  (elfNN_aarch64_relocate_section): Likewise.
  (elfNN_aarch64_gc_sweep_hook): Likewise.
  (elfNN_aarch64_check_relocs): Likewise.

9 years agogdb: Add debug tracing for bfd cache activity.
Andrew Burgess [Mon, 13 Apr 2015 15:56:23 +0000 (16:56 +0100)]
gdb: Add debug tracing for bfd cache activity.

This patch adds a new debug flag bfd-cache, which when set to non-zero
produces debugging log messages relating to gdb's bfd cache.

gdb/ChangeLog:

* gdb_bfd.c (debug_bfd_cache): New variable.
(show_bfd_cache_debug): New function.
(gdb_bfd_open): Add debug logging.
(gdb_bfd_ref): Likewise.
(gdb_bfd_unref): Likewise.
(_initialize_gdb_bfd): Add new set/show command.
* NEWS: Mention new command.

gdb/doc/ChangeLog:

* gdb.texinfo (File Caching): Document "set/show debug bfd-cache".

9 years agogdb: New maintenance command to disable bfd sharing.
Andrew Burgess [Mon, 13 Apr 2015 15:31:21 +0000 (16:31 +0100)]
gdb: New maintenance command to disable bfd sharing.

In some rare maintainer cases it is desirable to be able to disable bfd
sharing.  This patch adds new commands maintenance set/show commands for
bfd-sharing, allowing gdb's bfd cache to be turned off.

gdb/ChangeLog:

* gdb_bfd.c (bfd_sharing): New variable.
(show_bfd_sharing): New function.
(gdb_bfd_open): Check bfd_sharing variable.
(_initialize_gdb_bfd): Add new set/show command.
* NEWS: Mention new command.

gdb/doc/ChangeLog:

* gdb.texinfo (Maintenance Commands): Move documentation of "main
info bfds" to...
(File Caching): A New section.  Outline bfd caching, and add new
description for "main set/show bfd-sharing".

9 years agogdb: Improve cache matching criteria for the bfd cache.
Andrew Burgess [Mon, 13 Apr 2015 13:53:48 +0000 (14:53 +0100)]
gdb: Improve cache matching criteria for the bfd cache.

Within gdb open bfd objects are reused where possible if an attempt is
made to reopen a file that is already being debugged.  To spot if the on
disc file has changed gdb currently examines the mtime of the file and
compares it to the mtime of the open bfd in the cache.

A problem exists when the on disc file is being rapidly regenerated, as
happens, for example, with automated testing.  In some cases the file is
generated so quickly that the mtime appears not to change, while the on
disc file has changed.

This patch extends the bfd cache to also hold the file size of the file,
the inode of the file, and the device id of the file; gdb can then
compare filename, file size, mtime, inode, and device id to determine if
an existing bfd object can be reused.

gdb/ChangeLog:

* gdb_bfd.c (struct gdb_bfd_data): Add size, inode, and device id
field.
(struct gdb_bfd_cache_search): Likewise.
(eq_bfd): Compare the size, inode, and device id fields.
(gdb_bfd_open): Initialise the size, inode, and device id fields.
(gdb_bfd_ref): Likewise.
(gdb_bfd_unref): Likewise.

9 years agoAdd output_type to bfd_link_info
H.J. Lu [Tue, 18 Aug 2015 12:51:03 +0000 (05:51 -0700)]
Add output_type to bfd_link_info

The "shared" field in bfd_link_info is set for both DSO and and PIE.
There are separate fields for executable and relocatable outputs.  This
patch adds an "output_type" field:

enum output_type
{
  type_unknown = 0,
  type_executable,
  type_dll,
  type_relocatable
};

and a "pic" field to bfd_link_info to replace shared, executable and
relocatable fields so that we can use the "output_type" field to check
for output type and the "pic" field check if output is PIC.  Macros,
bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic
and bfd_link_pie, are provided to check for output features.

bfd/

* bfd/aoutx.h: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* bfd/bout.c: Likewise.
* bfd/coff-alpha.c: Likewise.
* bfd/coff-arm.c: Likewise.
* bfd/coff-i386.c: Likewise.
* bfd/coff-i960.c: Likewise.
* bfd/coff-m68k.c: Likewise.
* bfd/coff-mcore.c: Likewise.
* bfd/coff-mips.c: Likewise.
* bfd/coff-ppc.c: Likewise.
* bfd/coff-rs6000.c: Likewise.
* bfd/coff-sh.c: Likewise.
* bfd/coff-tic80.c: Likewise.
* bfd/coff-x86_64.c: Likewise.
* bfd/coff64-rs6000.c: Likewise.
* bfd/coffgen.c: Likewise.
* bfd/cofflink.c: Likewise.
* bfd/ecoff.c: Likewise.
* bfd/ecofflink.c: Likewise.
* bfd/elf-bfd.h: Likewise.
* bfd/elf-eh-frame.c: Likewise.
* bfd/elf-ifunc.c: Likewise.
* bfd/elf-m10200.c: Likewise.
* bfd/elf-m10300.c: Likewise.
* bfd/elf-s390-common.c: Likewise.
* bfd/elf-vxworks.c: Likewise.
* bfd/elf.c: Likewise.
* bfd/elf32-arm.c: Likewise.
* bfd/elf32-avr.c: Likewise.
* bfd/elf32-bfin.c: Likewise.
* bfd/elf32-cr16.c: Likewise.
* bfd/elf32-cr16c.c: Likewise.
* bfd/elf32-cris.c: Likewise.
* bfd/elf32-crx.c: Likewise.
* bfd/elf32-d10v.c: Likewise.
* bfd/elf32-dlx.c: Likewise.
* bfd/elf32-epiphany.c: Likewise.
* bfd/elf32-fr30.c: Likewise.
* bfd/elf32-frv.c: Likewise.
* bfd/elf32-ft32.c: Likewise.
* bfd/elf32-h8300.c: Likewise.
* bfd/elf32-hppa.c: Likewise.
* bfd/elf32-i370.c: Likewise.
* bfd/elf32-i386.c: Likewise.
* bfd/elf32-i860.c: Likewise.
* bfd/elf32-ip2k.c: Likewise.
* bfd/elf32-iq2000.c: Likewise.
* bfd/elf32-lm32.c: Likewise.
* bfd/elf32-m32c.c: Likewise.
* bfd/elf32-m32r.c: Likewise.
* bfd/elf32-m68hc11.c: Likewise.
* bfd/elf32-m68hc1x.c: Likewise.
* bfd/elf32-m68k.c: Likewise.
* bfd/elf32-mcore.c: Likewise.
* bfd/elf32-mep.c: Likewise.
* bfd/elf32-metag.c: Likewise.
* bfd/elf32-microblaze.c: Likewise.
* bfd/elf32-moxie.c: Likewise.
* bfd/elf32-msp430.c: Likewise.
* bfd/elf32-mt.c: Likewise.
* bfd/elf32-nds32.c: Likewise.
* bfd/elf32-nios2.c: Likewise.
* bfd/elf32-or1k.c: Likewise.
* bfd/elf32-ppc.c: Likewise.
* bfd/elf32-rl78.c: Likewise.
* bfd/elf32-rx.c: Likewise.
* bfd/elf32-s390.c: Likewise.
* bfd/elf32-score.c: Likewise.
* bfd/elf32-score7.c: Likewise.
* bfd/elf32-sh-symbian.c: Likewise.
* bfd/elf32-sh.c: Likewise.
* bfd/elf32-sh64.c: Likewise.
* bfd/elf32-spu.c: Likewise.
* bfd/elf32-tic6x.c: Likewise.
* bfd/elf32-tilepro.c: Likewise.
* bfd/elf32-v850.c: Likewise.
* bfd/elf32-vax.c: Likewise.
* bfd/elf32-visium.c: Likewise.
* bfd/elf32-xc16x.c: Likewise.
* bfd/elf32-xstormy16.c: Likewise.
* bfd/elf32-xtensa.c: Likewise.
* bfd/elf64-alpha.c: Likewise.
* bfd/elf64-hppa.c: Likewise.
* bfd/elf64-ia64-vms.c: Likewise.
* bfd/elf64-mmix.c: Likewise.
* bfd/elf64-ppc.c: Likewise.
* bfd/elf64-s390.c: Likewise.
* bfd/elf64-sh64.c: Likewise.
* bfd/elf64-x86-64.c: Likewise.
* bfd/elflink.c: Likewise.
* bfd/elfnn-aarch64.c: Likewise.
* bfd/elfnn-ia64.c: Likewise.
* bfd/elfxx-mips.c: Likewise.
* bfd/elfxx-sparc.c: Likewise.
* bfd/elfxx-tilegx.c: Likewise.
* bfd/i386linux.c: Likewise.
* bfd/linker.c: Likewise.
* bfd/m68klinux.c: Likewise.
* bfd/pdp11.c: Likewise.
* bfd/pe-mips.c: Likewise.
* bfd/peXXigen.c: Likewise.
* bfd/reloc.c: Likewise.
* bfd/reloc16.c: Likewise.
* bfd/sparclinux.c: Likewise.
* bfd/sunos.c: Likewise.
* bfd/vms-alpha.c: Likewise.
* bfd/xcofflink.c: Likewise.

include/

* include/bfdlink.h (output_type): New enum.
(bfd_link_executable): New macro.
(bfd_link_dll): Likewise.
(bfd_link_relocatable): Likewise.
(bfd_link_pic): Likewise.
(bfd_link_pie): Likewise.
(bfd_link_info): Remove shared, executable, pie and relocatable.
Add output_type and pic.

ld/

* ld/ldctor.c: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* ld/ldemul.c: Likewise.
* ld/ldfile.c: Likewise.
* ld/ldlang.c: Likewise.
* ld/ldmain.c: Likewise.
* ld/ldwrite.c: Likewise.
* ld/lexsup.c: Likewise.
* ld/pe-dll.c: Likewise.
* ld/plugin.c: Likewise.
* ld/emultempl/aarch64elf.em: Likewise.
* ld/emultempl/aix.em: Likewise.
* ld/emultempl/alphaelf.em: Likewise.
* ld/emultempl/armcoff.em: Likewise.
* ld/emultempl/armelf.em: Likewise.
* ld/emultempl/avrelf.em: Likewise.
* ld/emultempl/beos.em: Likewise.
* ld/emultempl/cr16elf.em: Likewise.
* ld/emultempl/elf-generic.em: Likewise.
* ld/emultempl/elf32.em: Likewise.
* ld/emultempl/genelf.em: Likewise.
* ld/emultempl/generic.em: Likewise.
* ld/emultempl/gld960.em: Likewise.
* ld/emultempl/gld960c.em: Likewise.
* ld/emultempl/hppaelf.em: Likewise.
* ld/emultempl/irix.em: Likewise.
* ld/emultempl/linux.em: Likewise.
* ld/emultempl/lnk960.em: Likewise.
* ld/emultempl/m68hc1xelf.em: Likewise.
* ld/emultempl/m68kcoff.em: Likewise.
* ld/emultempl/m68kelf.em: Likewise.
* ld/emultempl/metagelf.em: Likewise.
* ld/emultempl/mipself.em: Likewise.
* ld/emultempl/mmo.em: Likewise.
* ld/emultempl/msp430.em: Likewise.
* ld/emultempl/nds32elf.em: Likewise.
* ld/emultempl/needrelax.em: Likewise.
* ld/emultempl/nios2elf.em: Likewise.
* ld/emultempl/pe.em: Likewise.
* ld/emultempl/pep.em: Likewise.
* ld/emultempl/ppc32elf.em: Likewise.
* ld/emultempl/ppc64elf.em: Likewise.
* ld/emultempl/sh64elf.em: Likewise.
* ld/emultempl/solaris2.em: Likewise.
* ld/emultempl/spuelf.em: Likewise.
* ld/emultempl/sunos.em: Likewise.
* ld/emultempl/tic6xdsbt.em: Likewise.
* ld/emultempl/ticoff.em: Likewise.
* ld/emultempl/v850elf.em: Likewise.
* ld/emultempl/vms.em: Likewise.
* ld/emultempl/vxworks.em: Likewise.

9 years agox86/Linux: disable all-stop on top of non-stop
Pedro Alves [Tue, 18 Aug 2015 10:04:30 +0000 (11:04 +0100)]
x86/Linux: disable all-stop on top of non-stop

Markus reported that ASNS breaks target record-btrace.  In particular,
the gdb.btrace/multi-thread-step.exp test fails (both with BTS and PT
tracing) with a crash in py-inferior.c:

 Program received signal SIGSEGV, Segmentation fault.

 0x00000000006aa40d in add_thread_object (tp=0x27d32d0)

     at /users/mmetzger/team/gdb/git/gdb/python/py-inferior.c:337

 337       entry->next = inf_obj->threads;

My machine doesn't support BTS nor PT, so I missed this...

Disabling ASNS temporarily on x86 until this is addressed.

Tested on x86_64 Fedora 20.

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

* linux-nat.c (linux_nat_always_non_stop_p): If the linux_ops
target implements to_always_non_stop_p, call it.
* x86-linux-nat.c (x86_linux_always_non_stop_p): New function.
(x86_linux_create_target): Install it as to_always_non_stop_p
method.

9 years agoUse $SED in bfd Makefile
Alan Modra [Tue, 18 Aug 2015 07:14:48 +0000 (16:44 +0930)]
Use $SED in bfd Makefile

PR 18667
* Makefile.am: Use $(SED) in place of sed throughout.
* Makefile.in: Regenerate.

9 years agoPPC64: Allow .TOC. in linker script to override backend calculated value
Alan Modra [Tue, 18 Aug 2015 07:13:18 +0000 (16:43 +0930)]
PPC64: Allow .TOC. in linker script to override backend calculated value

bfd/
* elf64-ppc.c (ppc64_elf_func_desc_adjust): Don't redefine .TOC.
if already defined, and set linker_def.
(ppc64_elf_set_toc): Use .TOC. value if defined other than by
the backend.
ld/
* ldexp.c (exp_fold_tree_1): Clear linker_def on symbol assignment.

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

9 years agoui-out.c (default_ui_out_impl): Add comment.
Doug Evans [Mon, 17 Aug 2015 20:07:11 +0000 (13:07 -0700)]
ui-out.c (default_ui_out_impl): Add comment.

gdb/ChangeLog:

* ui-out.c (default_ui_out_impl): Add comment.

9 years ago[D] Implement looking up members of D enums.
Iain Buclaw [Mon, 17 Aug 2015 19:45:42 +0000 (21:45 +0200)]
[D] Implement looking up members of D enums.

In D, all named enums are explicitly scoped (the C++ equivalent of enum class)
so they should be handled as such in the language-specific symbol lookup
routines.  However so as to support D compilers that don't emit enums as
DW_AT_enum_class, need to make sure that appropriate checks for
TYPE_DECLARED_CLASS are done.

gdb/ChangeLog

* d-exp.y (type_aggregate_p): New function.
(PrimaryExpression : TypeExp '.' IdentifierExp): Use it.
(classify_inner_name): Likewise.
* d-namespace.c (d_lookup_nested_symbol): Handle TYPE_CODE_ENUM.

9 years agoMove strace -m/explicit location test to strace.exp
Keith Seitz [Thu, 13 Aug 2015 18:56:50 +0000 (11:56 -0700)]
Move strace -m/explicit location test to strace.exp

One of the build slaves shows this error running explicit.exp:

(gdb) strace -m gdbfoobarbaz
Remote failure reply: E.In-process agent library not loaded in process.
Fast and static tracepoints unavailable.
(gdb) FAIL: gdb.linespec/explicit.exp: strace -m gdbfoobarbaz

There are two big problems with this test:
1) The expected output is actually not what the test is meant to test for.
2) This test should really only run where it is supported.

This is most easily fixed by moving the test to gdb.trace/strace.exp.

gdb/testsuite/ChangeLog

* gdb.linespec/explicit.exp: Move strace test from here ...
* gdb.trace/strace.exp: ... to here.

9 years agoRegen binutils/configure
Alan Modra [Mon, 17 Aug 2015 02:31:58 +0000 (12:01 +0930)]
Regen binutils/configure

Looks like previous regen wasn't using current sources.

* configure: Regenerate.

9 years agoTrailing space in opcodes/ generated files
Alan Modra [Mon, 17 Aug 2015 02:21:44 +0000 (11:51 +0930)]
Trailing space in opcodes/ generated files

HJ recently removed trailing space in binutils files, but unfortunately
they return when regenerating files in opcodes.  This fixes the regen
process.

* cgen.sh: Trim trailing space from cgen output.
* ia64-gen.c (print_dependency_table): Don't generate trailing space.
(print_dis_table): Likewise.
* opc2c.c (dump_lines): Likewise.
(orig_filename): Warning fix.
* ia64-asmtab.c: Regenerate.

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

9 years agoRationalize ARM .align
Alan Modra [Sun, 16 Aug 2015 23:35:42 +0000 (09:05 +0930)]
Rationalize ARM .align

* gas/config/tc-arm.c (s_align): Delete.
(md_pseudo_table): Use s_align_ptwo for "align".
* gas/config/tc-arm.h (TC_ALIGN_ZERO_IS_DEFAULT): Define.
* read.c (s_align): Modify for TC_ALIGN_ZERO_IS_DEFAULT.

9 years agopsymtab.c (add_psymbol_to_bcache): Remove "val" arg.
Doug Evans [Sun, 16 Aug 2015 05:08:47 +0000 (22:08 -0700)]
psymtab.c (add_psymbol_to_bcache): Remove "val" arg.

gdb/ChangeLog:

* psymtab.c (add_psymbol_to_bcache): Remove "val" arg.  All callers
updated.
(add_psymbol_to_list): Ditto.

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

9 years agoAdd end_psymtab_common, have all debug info readers call it.
Doug Evans [Sat, 15 Aug 2015 23:46:20 +0000 (16:46 -0700)]
Add end_psymtab_common, have all debug info readers call it.

gdb/ChangeLog:

* dbxread.c (dbx_end_psymtab): Renamed from end_psymtab.  All callers
updated.  Call end_psymtab_common.
* dwarf2read.c (process_psymtab_comp_unit_reader): Call
end_psymtab_common.
(build_type_psymtabs_reader): Ditto.
* psympriv.h (sort_pst_symbols): Delete.
(end_psymtab_common): Declare.
* psymtab.c (sort_pst_symbols): Make static.
(end_psymtab_common): New function.
* xcoffread.c (xcoff_end_psymtab): Call end_psymtab_common.

9 years agoUse macros for some enum bit field sizes.
Doug Evans [Sat, 15 Aug 2015 23:25:53 +0000 (16:25 -0700)]
Use macros for some enum bit field sizes.

gdb/ChangeLog:

* defs.h (LANGUAGE_BITS): Define.
* psympriv.h (partial_symbol) <domain>: Use SYMBOL_DOMAIN_BITS.
(partial_symbol) <aclass>: Use SYMBOL_ACLASS_BITS.
* symtab.h (general_symbol_info> <language>: Usage LANGUAGE_BITS.
(minimal_symbol_type): Add nr_minsym_types.
(MINSYM_TYPE_BITS): Define.
(minimal_symbol) <type>: Use MINSYM_TYPE_BITS.
(domain_enum_tag): Add NR_DOMAINS.
(SYMBOL_DOMAIN_BITS): Change from 4 to 3.
(SYMBOL_ACLASS_BITS): Define from 6 to 5.

9 years agoobjfiles.h,psympriv.h,psymtab.c: Whitespace.
Doug Evans [Sat, 15 Aug 2015 22:51:00 +0000 (15:51 -0700)]
objfiles.h,psympriv.h,psymtab.c: Whitespace.

gdb/ChangeLog:

* objfiles.h: Whitespace cleanup.
* psympriv.h: Whitespace cleanup.
* psymtab.c: Whitespace/coding convention cleanup.

9 years agoFix invoking "[kill|detach] inferiors" on inferiors that are not running
Patrick Palka [Tue, 28 Jul 2015 19:00:58 +0000 (15:00 -0400)]
Fix invoking "[kill|detach] inferiors" on inferiors that are not running

Invoking either of the above commands on an inferior that's not running
triggers the following assert failure:

  .../binutils-gdb/gdb/thread.c:514: internal-error: any_thread_of_process: Assertion `pid != 0' failed.

The fix is straightforward.  This patch also adds a test to check the
basic functionality of these commands, along with testing this fix in
particular.  Tested on x86_64 Linux.

gdb/ChangeLog:

* inferior.c (detach_inferior_command): Don't call
any_thread_of_process when pid is 0.
(kill_inferior_command): Likewise.

gdb/testsuite/ChangeLog:

* gdb.base/kill-detach-inferiors-cmd.exp: New test file.
* gdb.base/kill-detach-inferiors-cmd.c: New test file.

9 years agoperftest/utils.py (select_file): Kill any existing inferior before selecting a new...
Doug Evans [Sat, 15 Aug 2015 06:29:04 +0000 (23:29 -0700)]
perftest/utils.py (select_file): Kill any existing inferior before selecting a new file.

gdb/testsuite/ChangeLog:

* gdb.perf/lib/perftest/utils.py (select_file): Kill any existing
inferior before selecting a new file.

9 years agoNew /s modifier for the disassemble command.
Doug Evans [Sat, 15 Aug 2015 04:45:54 +0000 (21:45 -0700)]
New /s modifier for the disassemble command.

The "source centric" /m option to the disassemble command is often
unhelpful, e.g., in the presence of optimized code.
This patch adds a /s modifier that is better.
For one, /m only prints instructions from the originating source file,
leaving out instructions from e.g., inlined functions from other files.

gdb/ChangeLog:

PR gdb/11833
* NEWS: Document new /s modifier for the disassemble command.
* cli/cli-cmds.c (disassemble_command): Add support for /s.
(_initialize_cli_cmds): Update online docs of disassemble command.
* disasm.c: #include "source.h".
(struct deprecated_dis_line_entry): Renamed from dis_line_entry.
All uses updated.
(dis_line_entry): New struct.
(hash_dis_line_entry, eq_dis_line_entry): New functions.
(allocate_dis_line_table): New functions.
(maybe_add_dis_line_entry, line_has_code_p): New functions.
(dump_insns): New arg end_pc.  All callers updated.
(do_mixed_source_and_assembly_deprecated): Renamed from
do_mixed_source_and_assembly.  All callers updated.
(do_mixed_source_and_assembly): New function.
(gdb_disassembly): Handle /s (DISASSEMBLY_SOURCE).
* disasm.h (DISASSEMBLY_SOURCE_DEPRECATED): Renamed from
DISASSEMBLY_SOURCE.  All uses updated.
(DISASSEMBLY_SOURCE): New macro.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): New modes 4,5.

gdb/doc/ChangeLog:

* gdb.texinfo (Machine Code): Update docs for mixed source/assembly
disassembly.
(GDB/MI Data Manipulation): Update docs for new disassembly modes.

gdb/testsuite/ChangeLog:

* gdb.mi/mi-disassemble.exp: Update.
* gdb.base/disasm-optim.S: New file.
* gdb.base/disasm-optim.c: New file.
* gdb.base/disasm-optim.h: New file.
* gdb.base/disasm-optim.exp: New file.