binutils-gdb.git
9 years agoAdd support for the x86 XSAVE extended state on FreeBSD/x86.
John Baldwin [Sat, 21 Feb 2015 21:43:30 +0000 (16:43 -0500)]
Add support for the x86 XSAVE extended state on FreeBSD/x86.

Recognize NT_X86_XSTATE notes in FreeBSD process cores.  Recent
FreeBSD versions include a note containing the XSAVE state for each
thread in the process when XSAVE is in use.  The note stores a copy of
the current XSAVE mask in a reserved section of the machine-defined
XSAVE state at the same offset as Linux's NT_X86_XSTATE note.

For native processes, use the PT_GETXSTATE_INFO ptrace request to
determine if XSAVE is enabled, and if so the active XSAVE state mask
(that is, the value of %xcr0 for the target process) as well as the
size of XSAVE state area.  Use the PT_GETXSTATE and PT_SETXSTATE requests
to fetch and store the XSAVE state, respectively, in the BSD x86
native targets.

In addition, the FreeBSD amd64 and i386 native targets now include
"read_description" target methods to determine the correct x86 target
description for the current XSAVE mask.  On FreeBSD amd64 this also
properly returns an i386 target description for 32-bit binaries which
allows the 64-bit GDB to run 32-bit binaries.

Note that the ptrace changes are in the BSD native targets, not the
FreeBSD-specific native targets since that is where the other ptrace
register accesses occur.  Of the other BSDs, NetBSD and DragonFly use
XSAVE in the kernel but do not currently export the extended state via
ptrace(2).  OpenBSD does not currently support XSAVE.

bfd/ChangeLog:

* elf.c (elfcore_grok_note): Recognize NT_X86_XSTATE on
FreeBSD.
(elfcore_write_xstatereg): Use correct note name on FreeBSD.

gdb/ChangeLog:

* amd64-tdep.c (amd64_target_description): New function.
* amd64-tdep.h: Export amd64_target_description and tdesc_amd64.
* amd64bsd-nat.c [PT_GETXSTATE_INFO]: New variable amd64bsd_xsave_len.
(amd64bsd_fetch_inferior_registers) [PT_GETXSTATE_INFO]: Handle
x86 extended save area.
(amd64bsd_store_inferior_registers) [PT_GETXSTATE_INFO]: Likewise.
* amd64bsd-nat.h: Export amd64bsd_xsave_len.
* amd64fbsd-nat.c (amd64fbsd_read_description): New function.
(_initialize_amd64fbsd_nat): Set "to_read_description" to
"amd64fbsd_read_description".
* amd64fbsd-tdep.c (amd64fbsd_core_read_description): New function.
(amd64fbsd_supply_xstateregset): New function.
(amd64fbsd_collect_xstateregset): New function.
Add "amd64fbsd_xstateregset".
(amd64fbsd_iterate_over_regset_sections): New function.
(amd64fbsd_init_abi): Set "xsave_xcr0_offset" to
"I386_FBSD_XSAVE_XCR0_OFFSET".
Add "iterate_over_regset_sections" gdbarch method.
Add "core_read_description" gdbarch method.
* i386-tdep.c (i386_target_description): New function.
* i386-tdep.h: Export i386_target_description and tdesc_i386.
* i386bsd-nat.c [PT_GETXSTATE_INFO]: New variable i386bsd_xsave_len.
(i386bsd_fetch_inferior_registers) [PT_GETXSTATE_INFO]: Handle
x86 extended save area.
(i386bsd_store_inferior_registers) [PT_GETXSTATE_INFO]: Likewise.
* i386bsd-nat.h: Export i386bsd_xsave_len.
* i386fbsd-nat.c (i386fbsd_read_description): New function.
(_initialize_i386fbsd_nat): Set "to_read_description" to
"i386fbsd_read_description".
* i386fbsd-tdep.c (i386fbsd_core_read_xcr0): New function.
(i386fbsd_core_read_description): New function.
(i386fbsd_supply_xstateregset): New function.
(i386fbsd_collect_xstateregset): New function.
Add "i386fbsd_xstateregset".
(i386fbsd_iterate_over_regset_sections): New function.
(i386fbsd4_init_abi): Set "xsave_xcr0_offset" to
"I386_FBSD_XSAVE_XCR0_OFFSET".
Add "iterate_over_regset_sections" gdbarch method.
Add "core_read_description" gdbarch method.
* i386fbsd-tdep.h: New file.

9 years agoFix reading of .debug_str_offsets{,.dwo} twice.
Doug Evans [Mon, 13 Apr 2015 19:50:17 +0000 (12:50 -0700)]
Fix reading of .debug_str_offsets{,.dwo} twice.

PR binutils/18218
* readelf.c (printable_section_name): Constify sec argument.
(apply_relocations): Ditto.  New arg "size".  All callers updated.
(load_specific_debug_section): Constify sec argument.
Remove side-effect of modifying sec->sh_size.

9 years agoHarden gdb.base/bp-permanent.exp
Luis Machado [Mon, 13 Apr 2015 17:45:56 +0000 (14:45 -0300)]
Harden gdb.base/bp-permanent.exp

This testcase does not work as expected in QEMU (aarch64 QEMU in my case). It
fails when trying to manually write the breakpoint instruction to a certain
PC address.

(gdb) p /x addr_bp[0] = buffer[0]^M
Cannot access memory at address 0x400834^M
(gdb) PASS: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0: setup: p /x addr_bp[0] = buffer[0]
p /x addr_bp[1] = buffer[1]^M
Cannot access memory at address 0x400835^M
(gdb) PASS: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0: setup: p /x addr_bp[1] = buffer[1]
p /x addr_bp[2] = buffer[2]^M
Cannot access memory at address 0x400836^M
(gdb) PASS: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0: setup: p /x addr_bp[2] = buffer[2]
p /x addr_bp[3] = buffer[3]^M
Cannot access memory at address 0x400837^M
(gdb) PASS: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0: setup: p /x addr_bp[3] = buffer[3]

The following patch prevents a number of failures by detecting this and bailing out in case the target has such a restriction. Writing to .text from within the program isn't any better. It just leads to a SIGSEGV.

Before the patch:

                === gdb Summary ===

After the patch:

                === gdb Summary ===

gdb/testsuite/ChangeLog:
2015-04-13  Luis Machado  <lgustavo@codesourcery.com>

* gdb.base/bp-permanent.exp (test): Handle the case of being unable
to write to the .text section.

9 years agoHarden gdb.base/coredump-filter.exp
Luis Machado [Mon, 13 Apr 2015 17:42:48 +0000 (14:42 -0300)]
Harden gdb.base/coredump-filter.exp

This testcase seems to assume the target is running Linux, so bare metal,
simulators and other debugging stubs running different OS' will have a
hard time executing some of the commands the testcase issues.

Even restricting the testcase to Linux systems (which the patch below does),
there are still problems with, say, QEMU not providing PID information when
"info inferior" is issued. As a consequence, the subsequent tests will either
fail or will not make much sense.

The attached patch checks if PID information is available. If not, it just
bails out and avoids running into a number of failures.

gdb/testsuite/ChangeLog:
2015-04-13  Luis Machado  <lgustavo@codesourcery.com>

* gdb.base/coredump-filter.exp: Restrict test to Linux systems only.
Handle the case of targets that do not provide PID information.

9 years agoCatch exception in lib/gdbserver-support.exp:gdb_exit
Yao Qi [Mon, 13 Apr 2015 11:36:56 +0000 (12:36 +0100)]
Catch exception in lib/gdbserver-support.exp:gdb_exit

I see the error when I run gdb-sigterm.exp with native-gdbserver
on x86_64-linux.

infrun: prepare_to_wait^M
Cannot execute this command while the target is running.^M
Use the "interrupt" command to stop the target^M
and then try again.^M
gdb.base/gdb-sigterm.exp: expect eof #0: got eof
gdb.base/gdb-sigterm.exp: expect eof #0: stepped 12 times
ERROR OCCURED: : spawn id exp8 not open
    while executing
"expect {
-i exp8 -timeout 10
            -re "$gdb_prompt $" {
                exp_continue
            }
            -i "$server_spawn_id" eof {
                wait -i $expect_out(spawn_id)
                unse..."
    ("uplevel" body line 1)
    invoked from within

In gdb-sigterm.exp, SIGTERM is sent to GDB and it exits.  However,
Dejagnu or tcl doesn't know this.

This patch is to catch the exception, but error messages are still
shown in the console and gdb.log.  In order to avoid this, we also
replace gdb_expect with expect.

gdb/testsuite:

2015-04-13  Yao Qi  <yao.qi@linaro.org>

* lib/gdbserver-support.exp (gdb_exit): Catch exception
and use expect instead of gdb_expect.

9 years agoDon't check object claimed by plugin
H.J. Lu [Mon, 13 Apr 2015 11:58:16 +0000 (04:58 -0700)]
Don't check object claimed by plugin

When ELF linker backend searchs the symbol table of an archive element,
it should skip the object which has been claimed by plugin.

PR ld/18250
* elflink.c (elf_link_is_defined_archive_symbol): Return FALSE
if the object has been claimed by plugin.

9 years agoRename variable "addr" to "coredump_var_addr" in gdb.base/coredump-filter.exp
Sergio Durigan Junior [Mon, 13 Apr 2015 06:40:08 +0000 (02:40 -0400)]
Rename variable "addr" to "coredump_var_addr" in gdb.base/coredump-filter.exp

This commit renames the global array variable "addr" to an unique name
"coredump_var_addr" in the test gdb.base/coredump-filter.exp.  This is
needed because global arrays can have name conflicts between tests.
For example, this specific test was conflicting with dmsym.exp,
causing errors like:

  ERROR: tcl error sourcing ../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp.
  ERROR: can't set "addr": variable is array
      while executing
  "set addr "0x\[0-9a-zA-Z\]+""
      (file "../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp" line 45)
      invoked from within
  "source ../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp"
      ("uplevel" body line 1)
      invoked from within
  "uplevel #0 source ../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp"
      invoked from within
  "catch "uplevel #0 source $test_file_name""

This problem was reported by Yao Qi at:

  <https://sourceware.org/ml/gdb-patches/2015-04/msg00373.html>
  Message-Id: <1428666671-12926-1-git-send-email-qiyaoltc@gmail.com>

gdb/testsuite/ChangeLog:
2015-04-13  Sergio Durigan Junior  <sergiodj@redhat.com>

* gdb.base/coredump-filter.exp: Rename variable "addr" to
"coredump_var_addr" to avoid naming conflict with other testcases.

9 years agosim: fix the PKGVERSION define
Mike Frysinger [Mon, 13 Apr 2015 06:38:57 +0000 (02:38 -0400)]
sim: fix the PKGVERSION define

This should be SIM, not GDB.

9 years agosim: options: add --version support
Mike Frysinger [Mon, 13 Apr 2015 06:33:26 +0000 (02:33 -0400)]
sim: options: add --version support

The old run frontend had a --version option, but the new common
sim-options file does not.  Restore support for that so we can
get version info out of `run` when using the new frontend.

9 years agosim: switch to gdb version script
Mike Frysinger [Fri, 10 Apr 2015 23:40:54 +0000 (19:40 -0400)]
sim: switch to gdb version script

Since the local create-version.sh already points directly into the gdb
source tree, we might as well use the gdb script directly too.

9 years agosim: mn10300: convert to sim-cpu
Mike Frysinger [Mon, 13 Apr 2015 06:13:48 +0000 (02:13 -0400)]
sim: mn10300: convert to sim-cpu

Make cpu allocation fully dynamic so we can leverage the common
sim-cpu and its APIs.

9 years agosim: v850: convert to sim-cpu
Mike Frysinger [Mon, 13 Apr 2015 06:11:24 +0000 (02:11 -0400)]
sim: v850: convert to sim-cpu

Make cpu allocation fully dynamic so we can leverage the common
sim-cpu and its APIs.

9 years agosim: mips: convert to sim-cpu
Mike Frysinger [Mon, 13 Apr 2015 06:09:55 +0000 (02:09 -0400)]
sim: mips: convert to sim-cpu

Make cpu allocation fully dynamic so we can leverage the common
sim-cpu and its APIs.

9 years agosim: m68hc11: convert to sim-cpu
Mike Frysinger [Mon, 13 Apr 2015 06:07:23 +0000 (02:07 -0400)]
sim: m68hc11: convert to sim-cpu

Make cpu allocation fully dynamic so we can leverage the common
sim-cpu and its APIs.

9 years agosim: mips: fix prototype warnings
Mike Frysinger [Mon, 13 Apr 2015 05:56:13 +0000 (01:56 -0400)]
sim: mips: fix prototype warnings

Convert a bunch of old style prototypes and tweak various casts
to match the function signatures.

9 years agosim: ft32: fix ft32_pc_get logic
Mike Frysinger [Mon, 13 Apr 2015 05:54:33 +0000 (01:54 -0400)]
sim: ft32: fix ft32_pc_get logic

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

9 years agoDo unset_currtarget_info ldscript for all simulator testsuites.
Hans-Peter Nilsson [Sun, 12 Apr 2015 23:54:43 +0000 (01:54 +0200)]
Do unset_currtarget_info ldscript for all simulator testsuites.

sim/testsuite:
* sim-defs.exp (sim_init): Unset target ldscript here.

sim/testsuite/sim/mips:
* basic.exp: Don't unset target ldscript here.

9 years agosim: arm/mips: fix sim_read/sim_write linkage errors
Mike Frysinger [Sun, 12 Apr 2015 09:47:39 +0000 (05:47 -0400)]
sim: arm/mips: fix sim_read/sim_write linkage errors

With sim-hrw.o being built & linked in the common list, some people are
getting linking errors now for these targets.  Move the main objects that
provide these functions before the common list to avoid that.

9 years agosim: ft32: delete sim_read/sim_write funcs
Mike Frysinger [Sun, 12 Apr 2015 09:13:23 +0000 (05:13 -0400)]
sim: ft32: delete sim_read/sim_write funcs

The common sim-hrw.o provides both of these, so simply use them.

9 years agoRevert the last 2 commits on pagesize_m1
H.J. Lu [Sun, 12 Apr 2015 00:05:04 +0000 (17:05 -0700)]
Revert the last 2 commits on pagesize_m1

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

9 years agoDon't call getpagesize more than once
H.J. Lu [Sat, 11 Apr 2015 23:49:09 +0000 (16:49 -0700)]
Don't call getpagesize more than once

9 years agoInitialize pagesize_m1 in bfd_cache_init
H.J. Lu [Sat, 11 Apr 2015 22:12:08 +0000 (15:12 -0700)]
Initialize pagesize_m1 in bfd_cache_init

There is no need to check and initialize pagesize_m1 in cache_bmmap.

* cache.c (cache_bmmap): Move pagesize_m1 ... to
(pagesize_m1): Here.
(bfd_cache_init): Initialize pagesize_m1.

9 years agoRemove an extra ';'
H.J. Lu [Sat, 11 Apr 2015 19:06:33 +0000 (12:06 -0700)]
Remove an extra ';'

* plugin.c (plugin_load_plugins): Removed an extra ';'.

9 years agoRemove --xdb
Jan Kratochvil [Sat, 11 Apr 2015 17:49:03 +0000 (19:49 +0200)]
Remove --xdb

Pedro Alves:

The commands that enables aren't even documented in the manual.
Judging from that, I assume that only wdb users would ever really
be using the --xdb switch.

I think it's time to drop "support" for the --xdb switch too.  I
looked through the commands that that exposes, the only that looked
potentially interesting was "go", but then it's just an alias
for "tbreak+jump", which can easily be done with "define go...end".
I'd rather free up the "go" name for something potentially
more interesting (either run control, or maybe even unrelated,
e.g., for golang).

gdb/ChangeLog
2015-04-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

* NEWS (Changes since GDB 7.9): Add removed -xdb.
* breakpoint.c (command_line_is_silent): Remove xdb_commands
conditional.
(_initialize_breakpoint): Remove xdb_commands for bc, ab, sb, db, ba
and lb.
* cli/cli-cmds.c (_initialize_cli_cmds): Remove xdb_commands for v and
va.
* cli/cli-decode.c (find_command_name_length): Remove xdb_commands
conditional.
* defs.h (xdb_commands): Remove declaration.
* f-valprint.c (_initialize_f_valprint): Remove xdb_commands for lc.
* guile/scm-cmd.c (command_classes): Remove xdb from comment.
* infcmd.c (run_no_args_command, go_command): Remove.
(_initialize_infcmd): Remove xdb_commands for S, go, g, R and lr.
* infrun.c (xdb_handle_command): Remove.
(_initialize_infrun): Remove xdb_commands for lz and z.
* main.c (xdb_commands): Remove variable.
(captured_main): Remove "xdb" from long_options.
(print_gdb_help): Remove --xdb from help.
* python/py-cmd.c (gdbpy_initialize_commands): Remove xdb from comment.
* source.c (_initialize_source): Remove xdb_commands for D, ld, / and ?.
* stack.c (backtrace_full_command, args_plus_locals_info)
(current_frame_command): Remove.
(_initialize_stack): Remove xdb_commands for t, T and l.
* symtab.c (_initialize_symtab): Remove xdb_commands for lf and lg.
* thread.c (_initialize_thread): Remove xdb_commands condition.
* tui/tui-layout.c (tui_toggle_layout_command)
(tui_toggle_split_layout_command, tui_handle_xdb_layout): Remove.
(_initialize_tui_layout): Remove xdb_commands for td and ts.
* tui/tui-regs.c (tui_scroll_regs_forward_command)
(tui_scroll_regs_backward_command): Remove.
(_initialize_tui_regs): Remove xdb_commands for fr, gr, sr, +r and -r.
* tui/tui-win.c (tui_xdb_set_win_height_command): Remove.
(_initialize_tui_win): Remove xdb_commands for U and w.
* utils.c (pagination_on_command, pagination_off_command): Remove.
(initialize_utils): Remove xdb_commands for am and sm.

gdb/doc/ChangeLog
2015-04-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.texinfo (Mode Options): Remove -xdb.

9 years agoReplace SYMBOLIC_BIND with SYMBOL_REFERENCES_LOCAL
H.J. Lu [Sat, 11 Apr 2015 14:34:49 +0000 (07:34 -0700)]
Replace SYMBOLIC_BIND with SYMBOL_REFERENCES_LOCAL

When checking R_386_GOTOFF/R_X86_64_GOTOFF64 for building shared library,
we should check SYMBOL_REFERENCES_LOCAL instead of SYMBOLIC_BIND to cover
more cases.

bfd/

* elf32-i386.c (elf_i386_relocate_section): Replace SYMBOLIC_BIND
with SYMBOL_REFERENCES_LOCAL when checking R_386_GOTOFF against
protected data symbol when building shared library.
* elf64-x86-64.c (elf_x86_64_relocate_section): Check
R_X86_64_GOTOFF64 against undefined symbol and replace
SYMBOLIC_BIND with SYMBOL_REFERENCES_LOCAL when checking
R_X86_64_GOTOFF64 against protected data symbol when building
shared library.

ld/testsuite/

* ld-i386/i386.exp: Run protected6a.
* ld-i386/protected6.d: Renamed to ...
* ld-i386/protected6a.d: This.
* ld-x86-64/hidden4.d: New file.
* ld-x86-64/hidden4.s: Likewise.
* ld-x86-64/hidden5.d: Likewise.
* ld-x86-64/hidden5.s: Likewise.
* ld-x86-64/protected6.d: Renamed to ...
* ld-x86-64/protected6a.d: This.
* ld-x86-64/x86-64.exp: Run hidden4, hidden5, protected6a,
protected7a and protected7b.

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

9 years agoCheck GOTOFF reloc against protected data on x86
H.J. Lu [Fri, 10 Apr 2015 21:02:23 +0000 (14:02 -0700)]
Check GOTOFF reloc against protected data on x86

R_386_GOTOFF/R_X86_64_GOTOFF64 relocation shouldn't be used against
protected data symbol on x86 since with copy relocation, address of
protected data defined in the shared library may be external.

This patch will break building shared libraries with protected data
symbols using GCCs older than GCC 5 without the bug fix for

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

GCC backport request should be made in the GCC bug report above.

bfd/

PR ld/pr17709
* elf32-i386.c (elf_i386_relocate_section): Also check R_386_GOTOFF
against protected data symbol when building shared library.
* elf64-x86-64.c (elf_x86_64_relocate_section): Also check
R_X86_64_GOTOFF64 against protected data symbol when building
shared library.

ld/testsuite/

PR ld/pr17709
* ld-i386/protected6.d: New file.
* ld-i386/protected6.s: Likewise.
* ld-x86-64/protected6.d: Likewise.
* ld-x86-64/protected6.s: Likewise.
* ld-x86-64/protected7.d: Likewise.
* ld-x86-64/protected7.s: Likewise.
* ld-x86-64/protected7a.d: Likewise.
* ld-x86-64/protected7b.d: Likewise.

9 years agoCleanup signal-while-stepping-over-bp-other-thread.exp
Pedro Alves [Mon, 9 Mar 2015 19:02:30 +0000 (19:02 +0000)]
Cleanup signal-while-stepping-over-bp-other-thread.exp

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

* gdb.threads/signal-while-stepping-over-bp-other-thread.exp: Use
gdb_test_sequence and gdb_assert.

9 years agostep-over-trips-on-watchpoint.exp: Don't put addresses in test messages
Pedro Alves [Fri, 10 Apr 2015 18:23:24 +0000 (19:23 +0100)]
step-over-trips-on-watchpoint.exp: Don't put addresses in test messages

Diffing test results, I noticed:

 -PASS: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=on: with thread-specific bp: next: b *0x0000000000400811 thread 1
 +PASS: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=on: with thread-specific bp: next: b *0x00000000004007d1 thread 1

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

* gdb.threads/step-over-trips-on-watchpoint.exp (do_test): Use
test messages that don't include the breakpoint address.

9 years agoAdd extern_protected_data and set it for x86
H.J. Lu [Thu, 5 Mar 2015 14:34:39 +0000 (06:34 -0800)]
Add extern_protected_data and set it for x86

Re-apply: commit ca3fe95e469b9daec153caa2c90665f5daaec2b5

With copy relocation, address of protected data defined in the shared
library may be external.  This patch adds extern_protected_data and
changes _bfd_elf_symbol_refs_local_p to return false for protected data
if extern_protected_data is true.

This patch will break building shared libraries with protected data
symbols using GCCs older than GCC 5 without the bug fix for

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

GCC backport request should be made in the GCC bug report above.

To get correct run-time behavior on Linux, glibc 2.22 or above are
required, which have the bug fix for

https://sourceware.org/bugzilla/show_bug.cgi?id=17711

Backports for glibc 2.21, 2.20, 2.19 and 2.18 are on hjl/pr17711/2.21,
hjl/pr17711/2.20, hjl/pr17711/2.19 and hjl/pr17711/2.18 branches,
respectively, at

https://sourceware.org/git/?p=glibc.git;a=summary

bfd/

PR ld/pr15228
PR ld/pr17709
* elf-bfd.h (elf_backend_data): Add extern_protected_data.
* elf32-i386.c (elf_backend_extern_protected_data): New.
Defined to 1.
* elf64-x86-64.c (elf_backend_extern_protected_data): Likewise.
* elflink.c (_bfd_elf_adjust_dynamic_copy): Don't error on
copy relocs against protected symbols if extern_protected_data
is true.
(_bfd_elf_symbol_refs_local_p): Don't return true on protected
non-function symbols if extern_protected_data is true.
* elfxx-target.h (elf_backend_extern_protected_data): New.
Default to 0.
(elfNN_bed): Initialize extern_protected_data with
elf_backend_extern_protected_data.

ld/testsuite/

PR ld/pr15228
PR ld/pr17709
* ld-i386/i386.exp (i386tests): Add a test for PR ld/17709.
* ld-i386/pr17709-nacl.rd: New file.
* ld-i386/pr17709.rd: Likewise.
* ld-i386/pr17709a.s: Likewise.
* ld-i386/pr17709b.s: Likewise.
* ld-i386/protected3.d: Updated.
* ld-i386/protected3.s: Likewise.
* ld-x86-64/pr17709-nacl.rd: New file.
* ld-x86-64/pr17709.rd: Likewise.
* ld-x86-64/pr17709a.s: Likewise.
* ld-x86-64/pr17709b.s: Likewise.
* ld-x86-64/protected3.d: Updated.
* ld-x86-64/protected3.s: Likewise.
* ld-x86-64/x86-64.exp (x86_64tests): Add a test for PR ld/17709.

9 years ago[arm] watchpoint-reuse-slot.exp: skip setting HW points on some address
Yao Qi [Fri, 10 Apr 2015 15:23:13 +0000 (16:23 +0100)]
[arm] watchpoint-reuse-slot.exp: skip setting HW points on some address

Hi,
ARM linux kernel has some requirements on the address/length setting
for HW breakpoints/watchpoints, but watchpoint-reuse-slot.exp doesn't
consider them and sets HW points on various addresses.  Many fails
are causes as a result:

stepi^M
Warning:^M
Could not insert hardware watchpoint 20.^M
Could not insert hardware breakpoints:^M
You may have requested too many hardware breakpoints/watchpoints.^M
^M
(gdb) FAIL: gdb.base/watchpoint-reuse-slot.exp: always-inserted off: watch x watch: : width 2, iter 2: base + 1: stepi advanced

watch *(buf.byte + 2 + 1)@2^M
Hardware watchpoint 388: *(buf.byte + 2 + 1)@2^M
Warning:^M
Could not insert hardware watchpoint 388.^M
Could not insert hardware breakpoints:^M
You may have requested too many hardware breakpoints/watchpoints.^M
^M
(gdb) FAIL: gdb.base/watchpoint-reuse-slot.exp: always-inserted on: watch x watch: : width 2, iter 2: base + 1: watch *(buf.byte + 2 + 1)@2

This patch is to reflect kernel requirements in watchpoint-reuse-slot.exp
in order to skip some tests.

gdb/testsuite:

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

* gdb.base/watchpoint-reuse-slot.exp (valid_addr_p): Return
false for some offset and width combinations which aren't
supported by linux kernel.

9 years agoPPC64: Fix step-over-trips-on-watchpoint.exp with displaced stepping on
Pedro Alves [Fri, 10 Apr 2015 12:08:32 +0000 (13:08 +0100)]
PPC64: Fix step-over-trips-on-watchpoint.exp with displaced stepping on

PPC64 currently fails this test like:

 FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=on: no thread-specific bp: step: step
 FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=on: no thread-specific bp: next: next
 FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=on: no thread-specific bp: continue: continue (the program exited)
 FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=on: with thread-specific bp: step: step
 FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=on: with thread-specific bp: next: next
 FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: displaced=on: with thread-specific bp: continue: continue (the program exited)

The problem is that PPC is a non-continuable watchpoints architecture
and the displaced stepping code isn't coping with that correctly.  On
such targets/architectures, a watchpoint traps _before_ the
instruction executes/completes.  On a watchpoint trap, the PC points
at the instruction that triggers the watchpoint (side effects haven't
happened yet).  In order to move past the watchpoint, GDB needs to
remove the watchpoint, single-step, and reinsert the watchpoint, just
like when stepping past a breakpoint.

The trouble is that if GDB is stepping over a breakpoint with
displaced stepping, and the instruction under the breakpoint triggers
a watchpoint, we get the watchpoint SIGTRAP, expecting a finished
(hard or software) step trap.  Even though the thread's PC hasn't
advanced yet (must remove watchpoint for that), since we get a
SIGTRAP, displaced_step_fixup thinks the single-step finished
successfuly anyway, and calls gdbarch_displaced_step_fixup, which then
adjusts the thread's registers incorrectly.

The fix is to cancel the displaced step if we trip on a watchpoint.
handle_inferior_event then processes the watchpoint event, and starts
a new step-over, here:

...
      /* At this point, we are stopped at an instruction which has
         attempted to write to a piece of memory under control of
         a watchpoint.  The instruction hasn't actually executed
         yet.  If we were to evaluate the watchpoint expression
         now, we would get the old value, and therefore no change
         would seem to have occurred.
...
      ecs->event_thread->stepping_over_watchpoint = 1;
      keep_going (ecs);
      return;
...

but this time, since we have a watchpoint to step over, watchpoints
are removed from the target, so the step-over succeeds.

The keep_going/resume changes are necessary because if we're stepping
over a watchpoint, we need to remove it from the target - displaced
stepping doesn't help, the copy of the instruction in the scratch pad
reads/writes to the same addresses, thus triggers the watchpoint
too...  So without those changes we keep triggering the watchpoint
forever, never making progress.  With non-stop that means we'll need
to pause all threads momentarily, which we can't today.  We could
avoid that by removing the watchpoint _only_ from the thread that is
moving past the watchpoint, but GDB is not prepared for that today
either.  For remote targets, that would need new packets, so good to
be able to step over it in-line as fallback anyway.

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

* infrun.c (displaced_step_fixup): Switch to the event ptid
earlier.  If the thread stopped for a watchpoint and the
target/arch has non-continuable watchpoints, cancel the displaced
step.
(resume): Don't start a displaced step if in-line step-over info
is valid.

9 years agoTest step-over-{lands-on-breakpoint|trips-on-watchpoint}.exp with displaced stepping
Pedro Alves [Fri, 10 Apr 2015 14:22:38 +0000 (15:22 +0100)]
Test step-over-{lands-on-breakpoint|trips-on-watchpoint}.exp with displaced stepping

These tests exercise the infrun.c:proceed code that needs to know to
start new step overs (along with switch_back_to_stepped_thread, etc.).
That code is tricky to get right in the multitude of possible
combinations (at least):

 (native | remote)
  X (all-stop | all-stop-but-target-always-in-non-stop)
  X (displaced-stepping | in-line step-over).

The first two above are properties of the target, but the different
step-over-breakpoint methods should work with any target that supports
them.  This patch makes sure we always test both methods on all
targets.

Tested on x86-64 Fedora 20.

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

* gdb.threads/step-over-lands-on-breakpoint.exp (do_test): New
procedure, factored out from ...
(top level): ... here.  Add "set displaced-stepping" testing axis.
* gdb.threads/step-over-trips-on-watchpoint.exp (do_test): New
parameter "displaced".  Use it.
(top level): Use foreach and add "set displaced-stepping" testing
axis.

9 years agoMake gdb.threads/step-over-trips-on-watchpoint.exp effective on !x86
Pedro Alves [Fri, 10 Apr 2015 12:11:32 +0000 (13:11 +0100)]
Make gdb.threads/step-over-trips-on-watchpoint.exp effective on !x86

This test is currently failing like this on (at least) PPC64 and s390x:

 FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: step: step
 FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: next: next
 FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: with thread-specific bp: step: step
 FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: with thread-specific bp: next: next

gdb.log:

 (gdb) PASS: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: step: set scheduler-locking off
 step
 wait_threads () at ../../../src/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.c:49
 49        return 1; /* in wait_threads */
 (gdb) FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: step: step

The problem is that the test assumes that both the "watch_me = 1;" and
the "other = 1;" lines compile to a single instruction each, which
happens to be true on x86, but no necessarily true everywhere else.
The result is that the test doesn't really test what it wants to test.

Fix it by looking for the instruction that triggers the watchpoint.

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

* gdb.threads/step-over-trips-on-watchpoint.c (child_function):
Remove comment.
* gdb.threads/step-over-trips-on-watchpoint.exp (do_test): Find
both the address of the instruction that triggers the watchpoint
and the address of the instruction immediately after, and use
those addresses for the test.  Fix comment.

9 years agoAdd a testcase for PR ld/18223
H.J. Lu [Fri, 10 Apr 2015 11:15:53 +0000 (04:15 -0700)]
Add a testcase for PR ld/18223

PR ld/18223
* ld-gc/gc.exp: Run pr18223.
* ld-gc/pr18223.d: New file.
* ld-gc/pr18223.s: Likewise.

9 years agoUse bfd_alloc for compressed section contents
H.J. Lu [Fri, 10 Apr 2015 10:54:41 +0000 (03:54 -0700)]
Use bfd_alloc for compressed section contents

Compressed section contents should be bfd_alloced to avoid memory leak.
This patch replaces bfd_malloc and free with bfd_alloc and bfd_release
on compressed buffer in bfd_compress_section_contents.  There is still
a very small memory leak when compressed section isn't smaller.

* compress.c (bfd_compress_section_contents): Replace bfd_malloc
and free with bfd_alloc and bfd_release on compressed buffer.
Release buffer if compressed section isn't smaller.

9 years agoFix gdb.base/sigstep.exp with displaced stepping on software single-step targets
Pedro Alves [Fri, 10 Apr 2015 09:55:09 +0000 (10:55 +0100)]
Fix gdb.base/sigstep.exp with displaced stepping on software single-step targets

TL;DR:

When stepping over a breakpoint with displaced stepping, the core must
be notified of all signals, otherwise the displaced step fixup code
confuses a breakpoint trap in the signal handler for the expected trap
indicating the displaced instruction was single-stepped
normally/successfully.

Detailed version:

Running sigstep.exp with displaced stepping on, against my x86
software single-step branch, I got:

 FAIL: gdb.base/sigstep.exp: step on breakpoint, to handler: performing step
 FAIL: gdb.base/sigstep.exp: next on breakpoint, to handler: performing next
 FAIL: gdb.base/sigstep.exp: continue on breakpoint, to handler: performing continue

Turning on debug logs, we see:

 (gdb) step
 infrun: clear_proceed_status_thread (process 32147)
 infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
 infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=1, current thread [process 32147] at 0x400842
 displaced: stepping process 32147 now
 displaced: saved 0x400622: 49 89 d1 5e 48 89 e2 48 83 e4 f0 50 54 49 c7 c0
 displaced: %rip-relative addressing used.
 displaced: using temp reg 2, old value 0x3615eafd37, new value 0x40084c
 displaced: copy 0x400842->0x400622: c7 81 1c 08 20 00 00 00 00 00
 displaced: displaced pc to 0x400622
 displaced: run 0x400622: c7 81 1c 08
 LLR: Preparing to resume process 32147, 0, inferior_ptid process 32147
 LLR: PTRACE_CONT process 32147, 0 (resume event thread)
 linux_nat_wait: [process -1], [TARGET_WNOHANG]
 LLW: enter
 LNW: waitpid(-1, ...) returned 32147, No child processes
 LLW: waitpid 32147 received Alarm clock (stopped)
 LLW: PTRACE_CONT process 32147, Alarm clock (preempt 'handle')
 LNW: waitpid(-1, ...) returned 0, No child processes
 LLW: exit (ignore)
 sigchld
 infrun: target_wait (-1.0.0, status) =
 infrun:   -1.0.0 [process -1],
 infrun:   status->kind = ignore
 infrun: TARGET_WAITKIND_IGNORE
 infrun: prepare_to_wait
 linux_nat_wait: [process -1], [TARGET_WNOHANG]
 LLW: enter
 LNW: waitpid(-1, ...) returned 32147, No child processes
 LLW: waitpid 32147 received Trace/breakpoint trap (stopped)
 CSBB: process 32147 stopped by software breakpoint
 LNW: waitpid(-1, ...) returned 0, No child processes
 LLW: trap ptid is process 32147.
 LLW: exit
 infrun: target_wait (-1.0.0, status) =
 infrun:   32147.32147.0 [process 32147],
 infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
 infrun: TARGET_WAITKIND_STOPPED
 displaced: restored process 32147 0x400622
 displaced: fixup (0x400842, 0x400622), insn = 0xc7 0x81 ...
 displaced: restoring reg 2 to 0x3615eafd37
 displaced: relocated %rip from 0x400717 to 0x400937
 infrun: stop_pc = 0x400937
 infrun: delayed software breakpoint trap, ignoring
 infrun: no line number info
 infrun: stop_waiting
 0x0000000000400937 in __dso_handle ()
 1: x/i $pc
 => 0x400937:    and    %ah,0xa0d64(%rip)        # 0x4a16a1
 (gdb) FAIL: gdb.base/sigstep.exp: displaced=on: step on breakpoint, to handler: performing step

What should have happened is that the breakpoint hit in the signal
handler should have been presented to the user.  But note that
"preempt 'handle'" -- what happened instead is that
displaced_step_fixup confused the breakpoint in the signal handler for
the expected SIGTRAP indicating the displaced instruction was
single-stepped normally/successfully.

This should be affecting all software single-step targets in the same
way.

The fix is to make sure the core sees all signals when displaced
stepping, just like we already must see all signals when doing an
stepping over a breakpoint in-line.  We now get:

 infrun: target_wait (-1.0.0, status) =
 infrun:   570.570.0 [process 570],
 infrun:   status->kind = stopped, signal = GDB_SIGNAL_ALRM
 infrun: TARGET_WAITKIND_STOPPED
 displaced: restored process 570 0x400622
 infrun: stop_pc = 0x400842
 infrun: random signal (GDB_SIGNAL_ALRM)
 infrun: signal arrived while stepping over breakpoint
 infrun: inserting step-resume breakpoint at 0x400842
 infrun: resume (step=0, signal=GDB_SIGNAL_ALRM), trap_expected=0, current thread [process 570] at 0x400842
 LLR: Preparing to resume process 570, Alarm clock, inferior_ptid process 570
 LLR: PTRACE_CONT process 570, Alarm clock (resume event thread)
 infrun: prepare_to_wait
 linux_nat_wait: [process -1], [TARGET_WNOHANG]
 LLW: enter
 LNW: waitpid(-1, ...) returned 0, No child processes
 LLW: exit (ignore)
 infrun: target_wait (-1.0.0, status) =
 infrun:   -1.0.0 [process -1],
 infrun:   status->kind = ignore
 sigchld
 infrun: TARGET_WAITKIND_IGNORE
 infrun: prepare_to_wait
 linux_nat_wait: [process -1], [TARGET_WNOHANG]
 LLW: enter
 LNW: waitpid(-1, ...) returned 570, No child processes
 LLW: waitpid 570 received Trace/breakpoint trap (stopped)
 CSBB: process 570 stopped by software breakpoint
 LNW: waitpid(-1, ...) returned 0, No child processes
 LLW: trap ptid is process 570.
 LLW: exit
 infrun: target_wait (-1.0.0, status) =
 infrun:   570.570.0 [process 570],
 infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
 infrun: TARGET_WAITKIND_STOPPED
 infrun: stop_pc = 0x400717
 infrun: BPSTAT_WHAT_STOP_NOISY
 infrun: stop_waiting

 Breakpoint 3, handler (sig=14) at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/sigstep.c:35
 35        done = 1;

Hardware single-step targets already behave this way, because the
Linux backends (both native and gdbserver) always report signals to
the core if the thread was single-stepping.

As mentioned in the new comment in do_target_resume, we can't fix this
by instead making the displaced_step_fixup phase skip fixing up the PC
if the single step stopped somewhere we didn't expect.  Here's what
the backtrace would look like if we did that:

 Breakpoint 3, handler (sig=14) at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/sigstep.c:35
 35        done = 1;
 1: x/i $pc
 => 0x400717 <handler+7>:        movl   $0x1,0x200943(%rip)        # 0x601064 <done>
 (gdb) bt
 #0  handler (sig=14) at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/sigstep.c:35
 #1  <signal handler called>
 #2  0x0000000000400622 in _start ()
 (gdb) FAIL: gdb.base/sigstep.exp: displaced=on: step on breakpoint, to handler: backtrace

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

* infrun.c (displaced_step_in_progress): New function.
(do_target_resume): Advise target to report all signals if
displaced stepping.

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

* gdb.base/sigstep.exp (breakpoint_to_handler)
(breakpoint_to_handler_entry): New parameter 'displaced'.  Use it.
Test "backtrace" in handler.
(breakpoint_over_handler): New parameter 'displaced'.  Use it.
(top level): Add new "displaced" test axis to
breakpoint_to_handler, breakpoint_to_handler_entry and
breakpoint_over_handler.

9 years agoDowngrade linker error on protected symbols in .dynbss to a warning
Alan Modra [Fri, 10 Apr 2015 00:39:34 +0000 (10:09 +0930)]
Downgrade linker error on protected symbols in .dynbss to a warning

PR ld/18222
* elflink.c (_bfd_elf_adjust_dynamic_copy): Don't report an error
on adding a protected visibility variable to .dynbss.

9 years agoRevert "Add extern_protected_data and set it for x86"
Alan Modra [Thu, 9 Apr 2015 12:06:24 +0000 (21:36 +0930)]
Revert "Add extern_protected_data and set it for x86"

This reverts commit ca3fe95e469b9daec153caa2c90665f5daaec2b5.

9 years agogdb/18216: displaced step+deliver signal, a thread needs step-over, crash
Pedro Alves [Fri, 10 Apr 2015 09:36:23 +0000 (10:36 +0100)]
gdb/18216: displaced step+deliver signal, a thread needs step-over, crash

The problem is that with hardware step targets and displaced stepping,
"signal FOO" when stopped at a breakpoint steps the breakpoint
instruction at the same time it delivers a signal.  This results in
tp->stepped_breakpoint set, but no step-resume breakpoint set.  When
the next stop event arrives, GDB crashes.  Irrespective of whether we
should do something more/different to step past the breakpoint in this
scenario (e.g., PR 18225), it's just wrong to assume there'll be a
step-resume breakpoint set (and was not the original intention).

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

PR gdb/18216
* infrun.c (process_event_stop_test): Don't assume a step-resume
is set if tp->stepped_breakpoint is true.

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

PR gdb/18216
* gdb.threads/multiple-step-overs.exp: Remove expected eof.

9 years ago[arm] Fix displaced stepping for thumb alu reg instruction
Yao Qi [Fri, 10 Apr 2015 09:33:01 +0000 (10:33 +0100)]
[arm] Fix displaced stepping for thumb alu reg instruction

Recent patch series "V2 All-stop on top of non-stop" causes a SIGSEGV
in the test case,

> -PASS: gdb.base/info-shared.exp: continue to breakpoint: library function #4
> +FAIL: gdb.base/info-shared.exp: continue to breakpoint: library function #4
>
> continue^M
> Continuing.^M
> ^M
> Program received signal SIGSEGV, Segmentation fault.^M
> 0x40021564 in ?? () gdb/testsuite/gdb.base/info-shared-solib1.so^M
> (gdb) FAIL: gdb.base/info-shared.exp: continue to breakpoint: library function #4

and an ARM displaced stepping bug is exposed.  It can be reproduced by
the modified gdb.arch/arm-disp-step.exp as below,

continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0xa713cfcc in ?? ()^M
(gdb) FAIL: gdb.arch/arm-disp-step.exp: continue to breakpoint: continue to test_add_rn_pc_end

This patch is to fix it.

gdb:

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

* arm-tdep.c (install_alu_reg): Update comment.
(thumb_copy_alu_reg): Remove local variable rn.  Update
debugging message.  Use r2 instead of r1 in the modified
instruction.

gdb/testsuite:

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

* gdb.arch/arm-disp-step.S (main): Call test_add_rn_pc.
(test_add_rn_pc): New function.
* gdb.arch/arm-disp-step.exp (test_add_rn_pc): New proc.
(top level): Invoke test_add_rn_pc.

9 years agoPR13858 - Can't do displaced stepping with no symbols
Pedro Alves [Fri, 10 Apr 2015 09:07:02 +0000 (10:07 +0100)]
PR13858 - Can't do displaced stepping with no symbols

Running break-interp.exp with the target always in non-stop mode trips
on PR13858, as enabling non-stop also enables displaced stepping.

The problem is that when GDB doesn't know where the entry point is, it
doesn't know where to put the displaced stepping scratch pad.  The
test added by this commit exercises this.  Without the fix, we get:

 (gdb) PASS: gdb.base/step-over-no-symbols.exp: displaced=on: break *$pc
 set displaced-stepping on
 (gdb) PASS: gdb.base/step-over-no-symbols.exp: displaced=on: set displaced-stepping on
 stepi
 0x00000000004005be in ?? ()
 Entry point address is not known.
 (gdb) PASS: gdb.base/step-over-no-symbols.exp: displaced=on: stepi
 p /x $pc
 $2 = 0x4005be
 (gdb) PASS: gdb.base/step-over-no-symbols.exp: displaced=on: get after PC
 FAIL: gdb.base/step-over-no-symbols.exp: displaced=on: advanced

The fix switches all GNU/Linux ports to get the entry point from
AT_ENTRY in the target auxiliary vector instead of from symbols.  This
is currently only done by PPC when Cell debugging is enabled, but I
think all archs should be able to do the same.  Note that
ppc_linux_displaced_step_location cached the result, I'm guessing to
avoid constantly re-fetching the auxv out of remote targets, but
that's no longer necessary nowadays, as the auxv blob is itself cached
in the inferior object.  The ppc_linux_entry_point_addr global is
obviously bad for multi-process too nowadays.

Tested on x86-64 (-m64/-m32), PPC64 (-m64/-m32) and S/390 GNU/Linux.
Yao tested the new test on ARM as well.

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

PR gdb/13858
* amd64-linux-tdep.c (amd64_linux_init_abi_common): Install
linux_displaced_step_location as gdbarch_displaced_step_location
hook.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
* linux-tdep.c (linux_displaced_step_location): New function,
based on ppc_linux_displaced_step_location.
* linux-tdep.h (linux_displaced_step_location): New declaration.
* ppc-linux-tdep.c (ppc_linux_entry_point_addr): Delete.
(ppc_linux_inferior_created, ppc_linux_displaced_step_location):
Delete.
(ppc_linux_init_abi): Install linux_displaced_step_location as
gdbarch_displaced_step_location hook, even without Cell/B.E..
(_initialize_ppc_linux_tdep): Don't install
ppc_linux_inferior_created as inferior_created observer.
* s390-linux-tdep.c (s390_gdbarch_init): Install
linux_displaced_step_location as gdbarch_displaced_step_location
hook.

gdb/testsuite/
2015-04-10  Pedro Alves  <palves@redhat.com>

PR gdb/13858
* gdb.base/step-over-no-symbols.exp: New file.

9 years agoCorrect setting of elf_list_options
Alan Modra [Fri, 10 Apr 2015 08:51:32 +0000 (18:21 +0930)]
Correct setting of elf_list_options

* configure.ac: Set elf_list_options etc. in proper case.
* configure: Regenerate.

9 years agodoc patch: compile: missing bits
Jan Kratochvil [Fri, 10 Apr 2015 08:34:51 +0000 (10:34 +0200)]
doc patch: compile: missing bits

gdb/doc/ChangeLog
2015-04-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
    Eli Zaretskii  <eliz@gnu.org>

* gdb.texinfo (Compiling and Injecting Code): Describe set debug
compile, show debug compile.  New subsection Compilation options for
the compile command.  New subsection Compiler search for the compile
command.

9 years agoAdd documentation about the interation of the ARM assembler's -EB option and the...
Nick Clifton [Fri, 10 Apr 2015 07:26:07 +0000 (08:26 +0100)]
Add documentation about the interation of the ARM assembler's -EB option and the linker's --be8 option.

PR binutils/18198
* ld.texinfo (--be8): Add a note about the interaction of this
option with the assembler's -EB option.

* doc/c-arm.texi (ARM Options): Add a note about the interaction of
the -EB option with the linker's --be8 option.

9 years agoMark _init and _fini for --gc-sections
Alan Modra [Thu, 9 Apr 2015 09:08:03 +0000 (18:38 +0930)]
Mark _init and _fini for --gc-sections

gold marks _init and _fini via symbol, ld marks them via section
(default scripts set .init and .fini section KEEP).  This makes it
possible for people to write their own _init and not bother to put the
function into the right section.

PR ld/18223
* ldlang.c (lang_process): Add _init and _fini to gc_sym_list.

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

9 years agoAllow gold to resolve defined TLS symbols in a PIE link.
Cary Coutant [Thu, 9 Apr 2015 22:47:13 +0000 (15:47 -0700)]
Allow gold to resolve defined TLS symbols in a PIE link.

This patch fixes Symbol::final_value_is_known so that a defined TLS symbol
in a PIE link is treated as having a known final value, thus allowing
GD->LE TLS optimization, eliminating an unnecessary GOT entry and dynamic
relocation.

gold/
* symtab.cc (Symbol::final_value_is_known): Check for TLS symbol
in a PIE link.
* testsuite/Makefile.am (tls_pie_test.sh): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/tls_pie_test.sh: New.

9 years agoUpdate comments in compress.c
H.J. Lu [Thu, 9 Apr 2015 19:48:49 +0000 (12:48 -0700)]
Update comments in compress.c

* compress.c (bfd_compress_section_contents): Update comments.
(bfd_init_section_decompress_status): Likewise.
(bfd_init_section_compress_status): Likewise.

9 years agodoc/c-rx.texi: Fix markup typos in last change.
Hans-Peter Nilsson [Thu, 9 Apr 2015 19:09:02 +0000 (21:09 +0200)]
doc/c-rx.texi: Fix markup typos in last change.

9 years agoImprove ODR checking in gold.
Cary Coutant [Thu, 9 Apr 2015 18:52:21 +0000 (11:52 -0700)]
Improve ODR checking in gold.

gold/
* debug.h (DEBUG_LOCATION): New.
(DEBUG_ALL): Include DEBUG_LOCATION.
(debug_string_to_enum): Add DEBUG_LOCATION.
* dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Fix debug
output to print correct context.
(Sized_dwarf_line_info::do_addr2line): Add debug output. Return
up to 4 more locations at the beginning of the function.
* symtab.cc (Symbol_table::detect_odr_violations): Get canonical
result before sorting list of line numbers.
* testsuite/debug_msg.sh: Allow range of line numbers for
canonical results on optimized code.

9 years agoProperly check --compress-debug-sections=XXX
H.J. Lu [Thu, 9 Apr 2015 17:56:28 +0000 (10:56 -0700)]
Properly check --compress-debug-sections=XXX

We can't check if input is ELF in copy_file since some targets may only
set xvec after bfd_check_format_matches is called.  This patch moves
this check to copy_object.

bfd/

* elfxx-target.h (TARGET_BIG_SYM): Add BFD_COMPRESS_GABI to
object_flags.
(TARGET_LITTLE_SYM): Likewise.

binutils/

* objcopy.c (do_debug_sections): Use bit patterns.
(copy_object): Return FALSE for compress_zlib, compress_gnu_zlib
and compress_gabi_zlib on non-ELF input.
(copy_file): Don't check non-ELF input here.

9 years agoxtensa: update bfd/Changelog
Max Filippov [Thu, 9 Apr 2015 16:27:53 +0000 (19:27 +0300)]
xtensa: update bfd/Changelog

9 years agoxtensa: replace action list with splay tree
Max Filippov [Sun, 5 Apr 2015 14:04:22 +0000 (17:04 +0300)]
xtensa: replace action list with splay tree

text_action_add uses linear list search to order text actions list by
action VMA. The list is used at the first relaxation pass, when it's not
fixed yet.
Replace the list with splay tree from libiberty.

Original profile:

% time    self  children    called     name
-----------------------------------------
          0.00    0.00      14/158225      compute_text_actions
          3.62    0.00   25211/158225      remove_dead_literal
          8.42    0.00   58645/158225      coalesce_shared_literal
         10.68    0.00   74355/158225      text_action_add_proposed
  38.8   22.73    0.00  158225         text_action_add
          0.00    0.00  144527/293246      bfd_zmalloc
-----------------------------------------

Same data, after optimization:

% time    self  children    called     name
-----------------------------------------
          0.00    0.00      14/158225      compute_text_actions
          0.00    0.00   25211/158225      remove_dead_literal
          0.00    0.01   58645/158225      coalesce_shared_literal
          0.00    0.01   74355/158225      text_action_add_proposed
   0.1    0.00    0.02  158225         text_action_add
          0.01    0.00  144527/144527      splay_tree_insert
          0.00    0.00  144527/195130      splay_tree_lookup
          0.00    0.00  144527/293246      bfd_zmalloc
-----------------------------------------

2015-04-03  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (splay-tree.h): include header.
(text_action_struct): drop next pointer.
(text_action_list_struct): drop head pointer, add count and
tree fields.
(find_fill_action): instead of linear search in text_action_list
search in the tree.
(text_action_compare, action_first, action_next): new functions.
(text_action_add, text_action_add_literal): instead of linear
search and insertion insert new node into the tree.
(removed_by_actions): pass additional parameter: action_list,
use it to traverse the tree.
(offset_with_removed_text): pass additional action_list parameter
to removed_by_actions.
(map_action_fn_context): new typedef.
(map_action_fn_context_struct): new structure.
(map_action_fn): new function.
(map_removal_by_action): use splay_tree_foreach to build map.
(find_insn_action): replace linear search in text_action_list
with series of splay_tree_lookups.
(print_action, print_action_list_fn): new functions.
(print_action_list): use splay_tree_foreach.
(init_xtensa_relax_info): drop action_list.head initialization.
Initialize the tree.
(compute_text_actions): use non-zero action_list_count instead of
non-NULL action list.
(xlate_map_context): new typedef.
(xlate_map_context_struct): new structure.
(xlate_map_fn): new function.
(build_xlate_map): use splay_tree_foreach to build map.
(action_remove_bytes_fn): new function.
(relax_section): use zero action_list_count instead of NULL
action list. Use splay_tree_foreach to count final section size.
Drop unused variable 'removed'.

9 years agoxtensa: optimize find_removed_literal
Max Filippov [Sat, 4 Apr 2015 11:49:42 +0000 (14:49 +0300)]
xtensa: optimize find_removed_literal

find_removed_literal uses linear search to find removed literal by its
VMA. The list of literals is fixed at that point, build an ordered index
array and use binary search instead.

Original profile:

% time    self  children    called     name
-----------------------------------------
         56.72    0.00  297578/669392      translate_reloc
         70.86    0.00  371814/669392      relax_section
  67.9  127.58    0.00  669392         find_removed_literal
-----------------------------------------

Same data, after optimization:

% time    self  children    called     name
-----------------------------------------
          0.00    0.00  297578/669392      translate_reloc
          0.00    0.00  371814/669392      relax_section
   0.0    0.00    0.00  669392         find_removed_literal
          0.00    0.00   23838/23838       map_removed_literal
-----------------------------------------

2015-04-03  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (removed_literal_map_entry): new typedef.
(removed_literal_map_entry_struct): new structure.
(removed_literal_list_struct): add new fields: n_map and map.
(map_removed_literal, removed_literal_compare): new functions.
(find_removed_literal): build index array for literals ordered
by VMA, use binary search to find removed literal.

9 years agoxtensa: optimize removed_by_actions
Max Filippov [Sat, 28 Mar 2015 05:46:28 +0000 (08:46 +0300)]
xtensa: optimize removed_by_actions

The function removed_by_actions iterates through text actions to
calculate an offset applied by text actions to a given VMA. Although it
has a parameter p_start_action that allows for incremental offset
calculation, in many places it's used with p_start_action explicitly set
to the first action. After the first relaxation pass when the list of
text actions is finalized, an array of offsets sorted by VMA may be used
to speed up this function.

Original profile:

% time    self  children    called     name
-----------------------------------------
          0.35    0.00   33872/4808961     relax_section_symbols
          3.32    0.00  326022/4808961     relax_property_section
         12.83    0.00 1259379/4808961     offset_with_removed_text
         32.50    0.00 3189688/4808961     translate_reloc
  71.5   49.00    0.00 4808961         removed_by_actions
-----------------------------------------

Same data, after optimization:

% time    self  children    called     name
-----------------------------------------
          0.00    0.00   33872/4808537     relax_section_symbols
          0.01    0.00  326022/4808537     relax_property_section
          0.05    0.00 1258955/4808537     offset_with_removed_text_map
          0.13    0.00 3189688/4808537     translate_reloc
   1.0    0.20    0.00 4808537         removed_by_actions_map
          0.00    0.00     120/120         map_removal_by_action
-----------------------------------------

2015-04-01  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (removal_by_action_entry_struct,
removal_by_action_map_struct): new structures.
(removal_by_action_entry, removal_by_action_map): new typedefs.
(text_action_list_struct): add new field: map.
(map_removal_by_action, removed_by_actions_map,
offset_with_removed_text_map): new functions.
(relax_section): replace offset_with_removed_text with
offset_with_removed_text_map.
(translate_reloc, relax_property_section, relax_section_symbols):
replace removed_by_actions with removed_by_actions_map.

9 years agoxtensa: optimize check_section_ebb_pcrels_fit
Max Filippov [Fri, 27 Mar 2015 04:13:55 +0000 (07:13 +0300)]
xtensa: optimize check_section_ebb_pcrels_fit

The original check_section_ebb_pcrels_fit algorithm checks that text
actions proposed for current EBB are OK for every relocation in a
section. There's no need to check every relocation, because text actions
for EBB can only change size of that EBB, thus only affecting
relocations that in any way cross that EBB. In addition EBBs are
iterated in ascending order of their VMA, making it easier to track
relevant relocations.

Introduce a structure that can track relocations that cross the range of
VMAs of EBB and use it to only check relocations relevant to current EBB
in check_section_ebb_pcrels_fit.
It takes O(N log N) operations to build it and O(N) operations to move
current EBB VMA window through its entire range, where N is the number
of relocations in a section. The resulting complexity of
compute_text_actions is thus reduced from O(N^2) to O(N log N + N * M),
where M is the average number of relocations crossing each EBB.

Original profile:

% time    self  children    called     name
-----------------------------------------
         44.26   71.53    6429/6429        compute_text_actions
  50.2   44.26   71.53    6429         check_section_ebb_pcrels_fit
          1.16   20.12 347506666/347576152     pcrel_reloc_fits
          2.95   16.52 347506666/348104944     get_relocation_opnd
          2.01    9.74 347575100/361252208     r_reloc_init
          0.55    7.53 347575100/363381467     r_reloc_get_section
          5.76    0.02 695013332/695013332     xlate_offset_with_removed_text
          0.68    3.89 347575100/363483827     bfd_octets_per_byte
          0.32    0.00 347506666/349910253     is_alt_relocation
          0.18    0.11    6391/6391        build_xlate_map
          0.00    0.00    6429/19417168     get_xtensa_relax_info
          0.00    0.00    6391/6391        free_xlate_map
-----------------------------------------

Same data, after optimization:

% time    self  children    called     name
-----------------------------------------
          2.56    3.08    6429/6429        compute_text_actions
   8.2    2.56    3.08    6429         check_section_ebb_pcrels_fit
          0.08    0.91 17721075/17790561     pcrel_reloc_fits
          0.17    0.47 17721075/31685977     r_reloc_init
          0.43    0.00 35442150/35442150     xlate_offset_with_removed_text
          0.02    0.37 17721075/33815236     r_reloc_get_section
          0.22    0.11    6391/6391        build_xlate_map
          0.05    0.22 17721075/33917596     bfd_octets_per_byte
          0.03    0.00 17721075/20405299     is_alt_relocation
          0.01    0.00    6429/6429        reloc_range_list_update_range
          0.00    0.00    6429/19417168     get_xtensa_relax_info
          0.00    0.00    6391/6391        free_xlate_map
-----------------------------------------

2015-04-01  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (reloc_range_list, reloc_range_list_entry,
reloc_range): new typedef.
(reloc_range_list_struct, reloc_range_list_entry_struct,
reloc_range_struct): new structures.
(reloc_range_compare, build_reloc_ranges,
reloc_range_list_append, reloc_range_list_remove,
reloc_range_list_update_range, free_reloc_range_list): new
functions.
(compute_text_actions): precompute relocation opcodes before the
loop. Add relevant_relocs variable, initialize it before the
loop, pass it to the check_section_ebb_pcrels_fit.
(check_section_ebb_pcrels_fit): add new parameter:
relevant_relocs. Update address range in the relevant_relocs if
it's non-NULL and iterate only over relevant relocations.

9 years agoRemove BNDPLT and add PARSE_AND_LIST_ARGS_CASE_Z
H.J. Lu [Thu, 9 Apr 2015 14:46:21 +0000 (07:46 -0700)]
Remove BNDPLT and add PARSE_AND_LIST_ARGS_CASE_Z

* emulparams/elf_x86_64.sh (BNDPLT): Removed.
(PARSE_AND_LIST_OPTIONS): New.
(PARSE_AND_LIST_ARGS_CASE_Z): Likewise.
* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Remove
BNDPLT check.  Handle PARSE_AND_LIST_ARGS_CASE_Z.
(gld${EMULATION_NAME}_list_options): Remove BNDPLT check.

9 years agoRename common-remote-fileio.[ch] as fileio.[ch]
Gary Benson [Thu, 9 Apr 2015 13:22:56 +0000 (14:22 +0100)]
Rename common-remote-fileio.[ch] as fileio.[ch]

This commit renames common-remote-fileio.[ch] as fileio.[ch]
and renames all functions in these files.

gdb/ChangeLog:

* common/common-remote-fileio.h: Rename to...
* common/fileio.h: ...this.  Update all references.
(remote_fileio_to_fio_error): Rename to...
(host_to_fileio_error): ...this.
(remote_fileio_to_be): Rename to...
(host_to_bigendian): ...this.  Update all callers.
(remote_fileio_to_fio_uint): Rename to...
(host_to_fileio_uint): ...this.  Update all callers.
(remote_fileio_to_fio_time): Rename to...
(host_to_fileio_time): ...this.  Update all callers.
(remote_fileio_to_fio_stat): Rename to...
(host_to_fileio_stat): ...this.
Update all references.
* common/common-remote-fileio.c: Rename to...
* common/fileio.c: ...this.  Update all references.
(remote_fileio_to_fio_error): Rename to...
(host_to_fileio_error): ...this.  Update all callers.
(remote_fileio_mode_to_target): Rename to...
(fileio_mode_pack): ...this.  Update all callers.
(remote_fileio_to_fio_mode): Rename to...
(host_to_fileio_mode): ...this.  Update all callers.
(remote_fileio_to_fio_ulong): Rename to...
(host_to_fileio_ulong): ...this.  Update all callers.
(remote_fileio_to_fio_stat): Rename to...
(host_to_fileio_stat): ...this.  Update all callers.

9 years agoUpdate French translation of ld strings.
Nick Clifton [Thu, 9 Apr 2015 13:56:29 +0000 (14:56 +0100)]
Update French translation of ld strings.

* po/fr.po: Updated French translation.

9 years agoAdd Guile frame-read-register command
Andy Wingo [Thu, 9 Apr 2015 12:06:41 +0000 (13:06 +0100)]
Add Guile frame-read-register command

gdb/ChangeLog:

* guile/scm-frame.c (gdbscm_frame_read_register): New function.
(frame_functions): Bind gdbscm_frame_read_register to
frame-read-register.
* guile/lib/gdb.scm (frame-read-register): Export.

gdb/doc/ChangeLog:

* guile.texi (Frames In Guile): Describe frame-read-register.

gdb/testsuite/ChangeLog:

* gdb.guile/scm-frame.exp: Add frame-read-register tests, modelled
after the Python tests.

9 years agoIntroduce new shared function remote_fileio_to_fio_error
Gary Benson [Thu, 9 Apr 2015 09:28:05 +0000 (10:28 +0100)]
Introduce new shared function remote_fileio_to_fio_error

This commit introduces a new shared function to replace three
identical functions in various places in the codebase.

gdb/ChangeLog:

* common/common-remote-fileio.h (remote_fileio_to_fio_error):
New declaration.
* common/common-remote-fileio.c (remote_fileio_to_fio_error):
New function, factored out the named functions below.
* inf-child.c (gdb/fileio.h): Remove include.
(common-remote-fileio.h): New include.
(inf_child_errno_to_fileio_error): Remove function.  Update
all callers to use remote_fileio_to_fio_error.
* remote-fileio.c (remote_fileio_errno_to_target): Likewise.

gdb/gdbserver/ChangeLog:

* hostio-errno.c (errno_to_fileio_error): Remove function.
Update caller to use remote_fileio_to_fio_error.

9 years agoAdd myself to Write After Approval list.
Andy Wingo [Thu, 9 Apr 2015 09:33:22 +0000 (11:33 +0200)]
Add myself to Write After Approval list.

gdb/ChangeLog:

* MAINTAINERS (Write After Approval): Add Andy Wingo.

9 years agoAdd support to the RX toolchain to restrict the use of string instructions.
Nick Clifton [Thu, 9 Apr 2015 11:48:37 +0000 (12:48 +0100)]
Add support to the RX toolchain to restrict the use of string instructions.

bfd * elf32-rx.c (describe_flags): Report the settings of the string
insn using bits.
(rx_elf_merge_private_bfd_data): Handle merging of the string insn
using bits.

bin * readelf.c (get_machine_flags): Report the setting of the string
insn using bits.

gas * config/tc-rx.c (enum options): Add OPTION_DISALLOW_STRING_INSNS.
(md_longopts): Add -mno-allow-string-insns.
(md_parse_option): Handle -mno-allow-string-insns.
(md_show_usage): Mention -mno-allow-string-insns.
(rx_note_string_insn_use): New function.  Produces an error
message if a string insn is used when it is not allowed.
* config/rx-parse.y (SCMPU): Call rx_note_string_insn_use.
(SMOVU, SMOVB, SMOVF, SUNTIL, SWHILE, RMPA): Likewise.
* config/rx-defs.h (rx_note_string_insn_use): Prototype.
* doc/c-rx.texi: Document -mno-allow-string-insns.

elf * rx.h (E_FLAG_RX_SINSNS_SET): New bit in e_flags field.
(E_FLAG_RX_SINSNS_YES): Likewise.
(E_FLAG_RX_SINSNS_MASK): New define.

9 years agoReplace $zlibdir with $ZLIBDIR in LDFLAGS
H.J. Lu [Thu, 9 Apr 2015 11:43:57 +0000 (04:43 -0700)]
Replace $zlibdir with $ZLIBDIR in LDFLAGS

* acinclude.m4: (GDB_AC_CHECK_BFD): Set ZLIBDIR with $zlibdir.
Replace $zlibdir with $ZLIBDIR in LDFLAGS.
* configure: Regenerated.

9 years agoImport strtok_r gnulib module
Pedro Alves [Wed, 8 Apr 2015 17:10:21 +0000 (18:10 +0100)]
Import strtok_r gnulib module

gdb/linux-tdep.c recently gained a strtok_r use.  That broke
--enable-targets=all with some versions of mingw64, which don't have
strtok_r:

  https://sourceware.org/ml/gdb-patches/2015-04/msg00266.html

Fix that by importing the strtok_r gnulib module.

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

* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add strtok_r.
* gnulib/Makefile.in (aclocal_m4_deps): Add import/m4/strtok_r.m4.
* gnulib/configure, gnulib/config.in, gnulib/aclocal.m4: Regenerate.
* gnulib/import/Makefile.am: Update.
* gnulib/import/Makefile.in: Update.
* gnulib/import/m4/gnulib-cache.m4: Update.
* gnulib/import/m4/gnulib-comp.m4: Update.
* gnulib/import/m4/strtok_r.m4: New file.
* gnulib/import/strtok_r.c: New file.

9 years agoupdate-gnulib.sh: work around aclocal warning with Perl >= 5.16
Pedro Alves [Thu, 9 Apr 2015 09:35:29 +0000 (10:35 +0100)]
update-gnulib.sh: work around aclocal warning with Perl >= 5.16

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

* gnulib/update-gnulib.sh (aclocal version check): Filter out
"called too early to check prototype".

9 years agogdbserver gnu/linux: stepping over breakpoint
Yao Qi [Thu, 9 Apr 2015 09:20:48 +0000 (10:20 +0100)]
gdbserver gnu/linux: stepping over breakpoint

Hi,
I see the following error on arm linux gdbserver,

continue^M
Continuing.^M
../../../binutils-gdb/gdb/gdbserver/linux-arm-low.c:458: A problem internal to GDBserver has been detected.^M
raw_bkpt_type_to_arm_hwbp_type: unhandled raw type^M
Remote connection closed^M
(gdb) FAIL: gdb.base/cond-eval-mode.exp: hbreak: continue

After we make GDBserver handling Zx/zx packet idempotent,

  [PATCH 3/3] [GDBserver] Make Zx/zx packet handling idempotent.
  https://sourceware.org/ml/gdb-patches/2014-04/msg00480.html

> Now removal/insertion of all kinds of breakpoints/watchpoints, either
> internal, or from GDB, always go through the target methods.

GDBserver handles all kinds of breakpoints/watchpoints through target
methods.  However, some target backends, such as arm, don't support Z0
packet but need software breakpoint to do breakpoint stepping over in
linux-low.c:start_step_over,

  if (can_hardware_single_step ())
    {
      step = 1;
    }
  else
    {
      CORE_ADDR raddr = (*the_low_target.breakpoint_reinsert_addr) ();
      set_reinsert_breakpoint (raddr);
      step = 0;
    }

a software breakpoint is requested to the backend, and the error is
triggered.  This problem should affect targets having
breakpoint_reinsert_addr hooked.

Instead of handling memory breakpoint in these affected linux backend,
this patch handles memory breakpoint in linux_{insert,remove}_point,
that, if memory breakpoint is requested, call
{insert,remove}_memory_breakpoint respectively.  Then, it becomes
unnecessary to handle memory breakpoint for linux x86 backend, so
this patch removes the code there.

This patch is tested with GDBserver on x86_64-linux and arm-linux
(-marm, -mthumb).  Note that there are still some fails in
gdb.base/cond-eval-mode.exp with -mthumb, because GDBserver doesn't
know how to select the correct breakpoint instruction according to
the arm-or-thumb-mode of requested address.  This is a separate
issue, anyway.

gdb/gdbserver:

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

* linux-low.c (linux_insert_point): Call
insert_memory_breakpoint if TYPE is raw_bkpt_type_sw.
(linux_remove_point): Call remove_memory_breakpoint if type is
raw_bkpt_type_sw.
* linux-x86-low.c (x86_insert_point): Don't call
insert_memory_breakpoint.
(x86_remove_point): Don't call remove_memory_breakpoint.

9 years agoEnable ELF ld_list_options for --enable-targets=all
H.J. Lu [Thu, 9 Apr 2015 00:05:54 +0000 (17:05 -0700)]
Enable ELF ld_list_options for --enable-targets=all

When --enable-targets=all is used with non-ELF target, we should enable
ELF ld_list_options.

* configure.ac (elf_list_options): Set to TRUE for
--enable-targets=all.
(elf_shlib_list_options): Likewise.
(elf_plt_unwind_list_options): Likewise.
* configure: Regenerated.

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

9 years agoFix Python completion when using the "complete" command
Sergio Durigan Junior [Wed, 8 Apr 2015 22:27:10 +0000 (18:27 -0400)]
Fix Python completion when using the "complete" command

This patch is related to PR python/16699, and is an improvement over the
patch posted here:

  <https://sourceware.org/ml/gdb-patches/2014-03/msg00301.html>

Keith noticed that, when using the "complete" command on GDB to complete
a Python command, some strange things could happen.  In order to
understand what can go wrong, I need to explain how the Python
completion mechanism works.

When the user requests a completion of a Python command by using TAB,
GDB will first try to determine the right set of "brkchars" that will be
used when doing the completion.  This is done by actually calling the
"complete" method of the Python class.  Then, when we already know the
"brkchars" that will be used, we call the "complete" method again, for
the same values.

If you read the thread mentioned above, you will see that one of the
design decisions was to make the "cmdpy_completer_helper" (which is the
function the does the actual calling of the "complete" method) cache the
first result of the completion, since this result will be used in the
second call, to do the actual completion.

The problem is that the "complete" command does not process the
brkchars, and the current Python completion mechanism (improved by the
patch mentioned above) relies on GDB trying to determine the brkchars,
and then doing the completion itself.  Therefore, when we use the
"complete" command instead of doing a TAB-completion on GDB, there is a
scenario where we can use the invalid cache of a previous Python command
that was completed before.  For example:

  (gdb) A <TAB>
  (gdb) complete B
  B value1
  B value10
  B value2
  B value3
  B value4
  B value5
  B value6
  B value7
  B value8
  B value9
  (gdb) B <TAB>
  comp1   comp2   comp4   comp6   comp8
  comp10  comp3   comp5   comp7   comp9

Here, we see that "complete B " gave a different result than "B <TAB>".
The reason for that is because "A <TAB>" was called before, and its
completion results were "value*", so when GDB tried to "complete B " it
wrongly answered with the results for A.  The problem here is using a
wrong cache (A's cache) for completing B.

We tried to come up with a solution that would preserve the caching
mechanism, but it wasn't really possible.  So I decided to completely
remove the cache, and doing the method calling twice for every
completion.  This is not optimal, but I do not think it will impact
users noticeably.

It is worth mentioning another small issue that I found.  The code was
doing:

  wordobj = PyUnicode_Decode (word, sizeof (word), host_charset (), NULL);

which is totally wrong, because using "sizeof" here will lead to always
the same result.  So I changed this to use "strlen".  The testcase also
catches this problem.

Keith kindly expanded the existing testcase to cover the problem
described above, and everything is passing.

gdb/ChangeLog:
2015-04-08  Sergio Durigan Junior  <sergiodj@redhat.com>

PR python/16699
* python/py-cmd.c (cmdpy_completer_helper): Adjust function to not
use a caching mechanism.  Adjust comments and code to reflect
that.  Replace 'sizeof' by 'strlen' when fetching 'wordobj'.
(cmdpy_completer_handle_brkchars): Adjust call to
cmdpy_completer_helper.  Call Py_XDECREF for 'resultobj'.
(cmdpy_completer): Likewise.

gdb/testsuite/ChangeLog:
2015-04-08  Keith Seitz  <keiths@redhat.com>

PR python/16699
* gdb.python/py-completion.exp: New tests for completion.
* gdb.python/py-completion.py (CompleteLimit1): New class.
(CompleteLimit2): Likewise.
(CompleteLimit3): Likewise.
(CompleteLimit4): Likewise.
(CompleteLimit5): Likewise.
(CompleteLimit6): Likewise.
(CompleteLimit7): Likewise.

9 years agoAdd test for PR18214 and PR18216 - multiple step-overs with queued signals
Pedro Alves [Wed, 8 Apr 2015 18:59:03 +0000 (19:59 +0100)]
Add test for PR18214 and PR18216 - multiple step-overs with queued signals

Both PRs are triggered by the same use case.

PR18214 is about software single-step targets.  On those, the 'resume'
code that detects that we're stepping over a breakpoint and delivering
a signal at the same time:

  /* Currently, our software single-step implementation leads to different
     results than hardware single-stepping in one situation: when stepping
     into delivering a signal which has an associated signal handler,
     hardware single-step will stop at the first instruction of the handler,
     while software single-step will simply skip execution of the handler.
...
     Fortunately, we can at least fix this particular issue.  We detect
     here the case where we are about to deliver a signal while software
     single-stepping with breakpoints removed.  In this situation, we
     revert the decisions to remove all breakpoints and insert single-
     step breakpoints, and instead we install a step-resume breakpoint
     at the current address, deliver the signal without stepping, and
     once we arrive back at the step-resume breakpoint, actually step
     over the breakpoint we originally wanted to step over.  */

doesn't handle the case of _another_ thread also needing to step over
a breakpoint.  Because the other thread is just resumed at the PC
where it had stopped and a breakpoint is still inserted there, the
thread immediately re-traps the same breakpoint.  This test exercises
that.  On software single-step targets, it fails like this:

 KFAIL: gdb.threads/multiple-step-overs.exp: displaced=off: signal thr3: continue to sigusr1_handler
 KFAIL: gdb.threads/multiple-step-overs.exp: displaced=off: signal thr2: continue to sigusr1_handler

gdb.log (simplified):

 (gdb) continue
 Continuing.

 Breakpoint 4, child_function_2 (arg=0x0) at src/gdb/testsuite/gdb.threads/multiple-step-overs.c:66
 66            callme (); /* set breakpoint thread 2 here */
 (gdb) thread 3
 (gdb) queue-signal SIGUSR1
 (gdb) thread 1
 [Switching to thread 1 (Thread 0x7ffff7fc1740 (LWP 24824))]
 #0  main () at src/gdb/testsuite/gdb.threads/multiple-step-overs.c:106
 106       wait_threads (); /* set wait-threads breakpoint here */
 (gdb) break sigusr1_handler
 Breakpoint 5 at 0x400837: file src/gdb/testsuite/gdb.threads/multiple-step-overs.c, line 31.
 (gdb) continue
 Continuing.
 [Switching to Thread 0x7ffff7fc0700 (LWP 24828)]

 Breakpoint 4, child_function_2 (arg=0x0) at src/gdb/testsuite/gdb.threads/multiple-step-overs.c:66
 66            callme (); /* set breakpoint thread 2 here */
 (gdb) KFAIL: gdb.threads/multiple-step-overs.exp: displaced=off: signal thr3: continue to sigusr1_handler

For good measure, I made the test try displaced stepping too.  And
then I found it crashes GDB on x86-64 (a hardware step target), but
only when displaced stepping... :

 KFAIL: gdb.threads/multiple-step-overs.exp: displaced=on: signal thr1: continue to sigusr1_handler (PRMS: gdb/18216)
 KFAIL: gdb.threads/multiple-step-overs.exp: displaced=on: signal thr2: continue to sigusr1_handler (PRMS: gdb/18216)
 KFAIL: gdb.threads/multiple-step-overs.exp: displaced=on: signal thr3: continue to sigusr1_handler (PRMS: gdb/18216)

 Program terminated with signal SIGSEGV, Segmentation fault.
 #0  0x000000000062a83a in process_event_stop_test (ecs=0x7fff847eeee0) at src/gdb/infrun.c:4964
 4964          if (sr_bp->loc->permanent
 Setting up the environment for debugging gdb.
 Breakpoint 1 at 0x79fcfc: file src/gdb/common/errors.c, line 54.
 Breakpoint 2 at 0x50a26c: file src/gdb/cli/cli-cmds.c, line 217.
 (top-gdb) p sr_bp
 $1 = (struct breakpoint *) 0x0
 (top-gdb) bt
 #0  0x000000000062a83a in process_event_stop_test (ecs=0x7fff847eeee0) at src/gdb/infrun.c:4964
 #1  0x000000000062a1af in handle_signal_stop (ecs=0x7fff847eeee0) at src/gdb/infrun.c:4715
 #2  0x0000000000629097 in handle_inferior_event (ecs=0x7fff847eeee0) at src/gdb/infrun.c:4165
 #3  0x0000000000627482 in fetch_inferior_event (client_data=0x0) at src/gdb/infrun.c:3298
 #4  0x000000000064ad7b in inferior_event_handler (event_type=INF_REG_EVENT, client_data=0x0) at src/gdb/inf-loop.c:56
 #5  0x00000000004c375f in handle_target_event (error=0, client_data=0x0) at src/gdb/linux-nat.c:4658
 #6  0x0000000000648c47 in handle_file_event (file_ptr=0x2e0eaa0, ready_mask=1) at src/gdb/event-loop.c:658

The all-stop-non-stop series fixes this, but meanwhile, this augments
the multiple-step-overs.exp test to cover this, KFAILed.

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

PR gdb/18214
PR gdb/18216
* gdb.threads/multiple-step-overs.c (sigusr1_handler): New
function.
(main): Install it as SIGUSR1 handler.
* gdb.threads/multiple-step-overs.exp (setup): Remove 'prefix'
parameter.  Always use "setup" as prefix.  Toggle "set
displaced-stepping" off/on depending on global.  Don't switch to
thread 1 here.
(top level): Add displaced stepping "off/on" test axis.  Update
"setup" calls.  Wrap each subtest with with_test_prefix.  Test
continuing with a queued signal in each thread.

9 years agoAdd chdr_size, Chdr, Chdr_write and Chdr_data
H.J. Lu [Wed, 8 Apr 2015 17:29:23 +0000 (10:29 -0700)]
Add chdr_size, Chdr, Chdr_write and Chdr_data

* elfcpp.h (Elf_sizes): Add chdr_size.
(Chdr): New.
(Chdr_write): Likewise.
* elfcpp_internal.h (Chdr_data): Likewise.

9 years agoAdd SHF_COMPRESSED and ELFCOMPRESS_XXX to elfcpp.h
H.J. Lu [Wed, 8 Apr 2015 17:27:55 +0000 (10:27 -0700)]
Add SHF_COMPRESSED and ELFCOMPRESS_XXX to elfcpp.h

* elfcpp.h (SHF): Add SHF_COMPRESSED.
(ELFCOMPRESS_ZLIB): New.
(ELFCOMPRESS_LOOS): Likewise.
(ELFCOMPRESS_HIOS): Likewise.
(ELFCOMPRESS_LOPROC): Likewise.
(ELFCOMPRESS_HIPROC): Likewise.

9 years agoSkip empty EMULATION_NAME
H.J. Lu [Wed, 8 Apr 2015 16:46:50 +0000 (09:46 -0700)]
Skip empty EMULATION_NAME

* emulparams/elf32bmipn32-defs.sh: Skip empty EMULATION_NAME.

9 years agoWork around a GCC uninitialized warning bug
H.J. Lu [Wed, 8 Apr 2015 16:25:08 +0000 (09:25 -0700)]
Work around a GCC uninitialized warning bug

* compress.c (bfd_compress_section_contents): Work around a GCC
uninitialized warning bug fixed in GCC 4.7.

9 years ago[spu] Don't call set_gdbarch_cannot_step_breakpoint in spu_gdbarch_init
Yao Qi [Wed, 8 Apr 2015 15:04:07 +0000 (16:04 +0100)]
[spu] Don't call set_gdbarch_cannot_step_breakpoint in spu_gdbarch_init

Nowadays, in infrun.c:resume, the setting to 'step' variable is like:

  if (use_displaced_stepping (gdbarch)
      && tp->control.trap_expected
      && sig == GDB_SIGNAL_0
      && !current_inferior ()->waiting_for_vfork_done)
    {
    }
  /* Do we need to do it the hard way, w/temp breakpoints?  */
  else if (step)
    step = maybe_software_singlestep (gdbarch, pc); <-- [1]

  ...

  if (execution_direction != EXEC_REVERSE
      && step && breakpoint_inserted_here_p (aspace, pc))
    {
      ...
      if (gdbarch_cannot_step_breakpoint (gdbarch)) <-- [2]
        step = 0;
    }

spu doesn't have displaced stepping and uses software single step,
so 'step' is set to zero in [1], and [2] becomes unreachable as a
result.  So don't have to call set_gdbarch_cannot_step_breakpoint
in spu_gdbarch_init.

gdb:

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

* spu-tdep.c (spu_gdbarch_init): Don't call
set_gdbarch_cannot_step_breakpoint.

9 years agoAdd SHF_COMPRESSED support to gas and objcopy
H.J. Lu [Wed, 8 Apr 2015 14:53:54 +0000 (07:53 -0700)]
Add SHF_COMPRESSED support to gas and objcopy

This patch adds --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}
options to gas and objcopy for ELF files. They control how DWARF debug
sections are compressed.  --compress-debug-sections=none is equivalent to
--nocompress-debug-sections.  --compress-debug-sections=zlib and
--compress-debug-sections=zlib-gnu are equivalent to
--compress-debug-sections.  --compress-debug-sections=zlib-gabi compresses
DWARF debug sections with SHF_COMPRESSED from the ELF ABI.  No linker
changes are required to support SHF_COMPRESSED.

bfd/

* archive.c (_bfd_get_elt_at_filepos): Also copy BFD_COMPRESS_GABI
bit.
* bfd.c (bfd::flags): Increase size to 18 bits.
(BFD_COMPRESS_GABI): New.
(BFD_FLAGS_SAVED): Add BFD_COMPRESS_GABI.
(BFD_FLAGS_FOR_BFD_USE_MASK): Likewise.
(bfd_update_compression_header): New fuction.
(bfd_check_compression_header): Likewise.
(bfd_get_compression_header_size): Likewise.
(bfd_is_section_compressed_with_header): Likewise.
* compress.c (MAX_COMPRESSION_HEADER_SIZE): New.
(bfd_compress_section_contents): Return the uncompressed size if
the full section contents is compressed successfully.  Support
converting from/to .zdebug* sections.
(bfd_get_full_section_contents): Call
bfd_get_compression_header_size to get compression header size.
(bfd_is_section_compressed): Renamed to ...
(bfd_is_section_compressed_with_header): This.  Add a pointer
argument to return compression header size.
(bfd_is_section_compressed): Use it.
(bfd_init_section_decompress_status): Call
bfd_get_compression_header_size to get compression header size.
Return FALSE if uncompressed section size is 0.
* elf.c (_bfd_elf_make_section_from_shdr): Support converting
from/to .zdebug* sections.
* bfd-in2.h: Regenerated.

binutils/

* objcopy.c (do_debug_sections): Add compress_zlib,
compress_gnu_zlib and compress_gabi_zlib.
(copy_options): Use optional_argument on compress-debug-sections.
(copy_usage): Update --compress-debug-sections.
(copy_file): Handle compress_zlib, compress_gnu_zlib and
compress_gabi_zlib.
(copy_main): Handle
--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
* doc/binutils.texi: Document
--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.

binutils/testsuite/

* compress.exp: Add tests for
--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
* binutils-all/dw2-3.rS: New file.
* binutils-all/dw2-3.rt: Likewise.
* binutils-all/libdw2-compressedgabi.out: Likewise.

gas/

* as.c (show_usage): Update --compress-debug-sections.
(std_longopts): Use optional_argument on compress-debug-sections.
(parse_args): Handle
--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
* as.h (compressed_debug_section_type): New.
(flag_compress_debug): Change type to compressed_debug_section_type.
--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
* write.c (compress_debug): Set BFD_COMPRESS_GABI for
--compress-debug-sections=zlib-gabi.  Call
bfd_get_compression_header_size to get compression header size.
Don't rename section name for --compress-debug-sections=zlib-gabi.
* config/tc-i386.c (compressed_debug_section_type): Set to
COMPRESS_DEBUG_ZLIB.
* doc/as.texinfo: Document
--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.

gas/testsuite/

* gas/i386/dw2-compressed-1.d: New file.
* gas/i386/dw2-compressed-2.d: Likewise.
* gas/i386/dw2-compressed-3.d: Likewise.
* gas/i386/x86-64-dw2-compressed-2.d: Likewise.
* gas/i386/i386.exp: Run dw2-compressed-2, dw2-compressed-1,
dw2-compressed-3 and x86-64-dw2-compressed-2.

ld/testsuite/

* ld-elf/compress.exp: Add a test for
--compress-debug-sections=zlib-gabi.
(build_tests): Add 2 tests for --compress-debug-sections=zlib-gabi.
(run_tests): Likewise.
Verify linker output with zlib-gabi compressed debug input.
* ld-elf/compressed1a.d: New file.
* ld-elf/compressed1b.d: Likewise.
* ld-elf/compressed1c.d: Likewise.

9 years agoDisplay --interleave[=<number>]
H.J. Lu [Wed, 8 Apr 2015 12:04:13 +0000 (05:04 -0700)]
Display --interleave[=<number>]

Optional argument of a command line option must start with "=".

* objcopy.c (copy_usage): Replace "--interleave [<number>]" with
--interleave[=<number>].

9 years agoAdd ld_list_options
H.J. Lu [Wed, 8 Apr 2015 11:55:07 +0000 (04:55 -0700)]
Add ld_list_options

This patch adds ld_list_options for ELF targets to avoid duplicated
outputs from ld --help.

* Makefile.am (ELF_CLFAGS): New.
(AM_CFLAGS): Add $(ELF_CLFAGS).
* configure.ac (elf_list_options): New.  AC_SUBST.
(elf_shlib_list_options): Likewise.
(elf_plt_unwind_list_options): Likewise.
* lexsup.c (elf_shlib_list_options): New.
(elf_static_list_options): Likewise.
(elf_plt_unwind_list_options): Likewise.
(ld_list_options): Likewise.
(help): Call ld_list_options.
* Makefile.in: Regenerated.
* configure: Likewise.
* emulparams/plt_unwind.sh (PLT_UNWIND): New.
(PARSE_AND_LIST_OPTIONS): Removed.
* emultempl/elf32.em (gld_list_options): New.
(gld${EMULATION_NAME}_list_options): Define only if BNDPLT or
PARSE_AND_LIST_OPTIONS is defined.
(ld_${EMULATION_NAME}_emulation): Replace
gld${EMULATION_NAME}_list_options with ${gld_list_options.

9 years agoFix gdb.trace/{actions,infotrace,while-stepping}.exp with extended-remote
Pedro Alves [Wed, 8 Apr 2015 09:39:43 +0000 (10:39 +0100)]
Fix gdb.trace/{actions,infotrace,while-stepping}.exp with extended-remote

The recent actions.exp change to check gdb_run_cmd succeeded caught
further problems.  The test now fails like this
with --target_board=native-extended-gdbserver:

 FAIL: gdb.trace/actions.exp: Can't run to main

gdb.log shows:

 (gdb) run
 Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.trace/actions
 Running the default executable on the remote target failed; try "set remote exec-file"?
 (gdb) FAIL: gdb.trace/actions.exp: Can't run to main

The problem is that a gdb_load call is missing.

Grepping around for similar problems in other tests, I found that
infotrace.exp and while-stepping.exp should be likewise affected.  And
indeed this is what we get today:

 FAIL: gdb.trace/infotrace.exp: tstart
 FAIL: gdb.trace/infotrace.exp: continue to end (the program is no longer running)
 FAIL: gdb.trace/infotrace.exp: tstop
 FAIL: gdb.trace/infotrace.exp: 2.6: info tracepoints (trace buffer usage)
 FAIL: gdb.trace/while-stepping.exp: tstart
 FAIL: gdb.trace/while-stepping.exp: tstop
 FAIL: gdb.trace/while-stepping.exp: tfile: info tracepoints
 FAIL: gdb.trace/while-stepping.exp: ctf: info tracepoints

while-stepping.exp even has the same race bug actions.exp had.

After this, {actions,infotrace,while-stepping}.exp all pass cleanly
with the native-extended-gdbserver board.

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

* gdb.trace/actions.exp: Use gdb_load before gdb_run_cmd.
* gdb.trace/infotrace.exp: Use gdb_load before gdb_run_cmd.  Use
gdb_breakpoint instead of gdb_test that doesn't expect anything.
Return early if running to main fails.
* gdb.trace/while-stepping.exp: Likewise.

9 years agoAdd AArch32 support for arm gold linker.
Han Shen [Wed, 8 Apr 2015 00:20:11 +0000 (17:20 -0700)]
Add AArch32 support for arm gold linker.

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

9 years agoInitialize variable on gdb/linux-tdep.c:decode_vmflags
Sergio Durigan Junior [Tue, 7 Apr 2015 19:19:07 +0000 (15:19 -0400)]
Initialize variable on gdb/linux-tdep.c:decode_vmflags

This obvious commit initializes the 'saveptr' variable on
gdb/linux-tdep.c:decode_vmflags.  This was causing a build failure on
Fedora 21 x86_64, caught by the BuildBot here:

  <https://sourceware.org/ml/gdb-testers/2015-q2/msg00450.html>

9 years agogdb.base/interrupt.exp: Use send_inferior/$inferior_spawn_id
Pedro Alves [Tue, 7 Apr 2015 17:19:31 +0000 (18:19 +0100)]
gdb.base/interrupt.exp: Use send_inferior/$inferior_spawn_id

The gdb.base/interrupt.exp test is important for testing system call
restarting, but because it depends on inferior I/O, it ends up skipped
against gdbserver.  This patch adjusts the test to use send_inferior
and $inferior_spawn_id so it works against GDBserver.

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

* gdb.base/interrupt.exp: Don't skip if $inferior_spawn_id !=
$gdb_spawn_id.  Use send_inferior and $inferior_spawn_id to
interact with inferior program.

9 years agotestsuite: Introduce $inferior_spawn_id
Pedro Alves [Tue, 7 Apr 2015 17:19:30 +0000 (18:19 +0100)]
testsuite: Introduce $inferior_spawn_id

Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.

This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior.  By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID.  Otherwise, the board may set this
to some other spawn ID.  When debugging with GDBserver, this will be
set to GDBserver's spawn ID.

Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output.  That is, something like this will now
work:

  send_inferior "echo me\n"
  gdb_test_multiple "continue" "test msg" {
    -i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
      ...
    }
  }

Or even:

  gdb_test_multiple "continue" "test msg" {
    -i "$inferior_spawn_id" -re "hello world" {
      ...
    }
    -i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
      ...
    }
  }

Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.

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

* lib/gdb.exp (inferior_spawn_id): New global.
(gdb_test_multiple): Handle "-i".  Reset the spawn id to GDB's
spawn id after processing the user code.
(default_gdb_start): Set inferior_spawn_id.
(send_inferior): New procedure.
* lib/gdbserver-support.exp (gdbserver_start): Set
inferior_spawn_id.
(close_gdbserver, gdb_exit): Unset inferior_spawn_id.

9 years agotestsuite: Don't use expect_background to reap gdbserver
Pedro Alves [Tue, 7 Apr 2015 17:19:30 +0000 (18:19 +0100)]
testsuite: Don't use expect_background to reap gdbserver

I adjusted a test to do 'expect -i $server_spawn_id -re ...', and saw
really strange behavior.  Whether that expect would work, depended on
whether GDB would also send output and the same expect matched it too
(on $gdb_spawn_id).  I was perplexed until I noticed that
gdbserver_spawn spawns gdbserver and then uses expect_background to
reap gdbserver.  That expect_background conflicts/races with any
"expect -i $server_spawn_id" done anywhere else in parallel...

In order to make it possible for tests to read inferior I/O out of
$server_spawn_id, we to get rid of that expect_background.  This patch
makes us instead reap gdbserver's spawn id when GDB exits.  If GDB is
still around, this gives a chance for gdbserver to exit cleanly.  The
current code in gdb_finish uses "kill", but that doesn't work with
extended-remote (gdbserver doesn't exit).  We now use "monitor exit"
instead which works in both remote and extended-remote modes.

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

* lib/gdb.exp (gdb_finish): Delete persistent gdbserver handling.
* lib/gdbserver-support.exp (gdbserver_start): Make
$server_spawn_id global.
(gdbserver_start): Don't wait for gdbserver's spawn id with
expect_background.
(close_gdbserver): New procedure.
(gdb_exit): Rename the default version and reimplement.

9 years agogdb_test_multiple: Fix user code argument processing
Pedro Alves [Tue, 7 Apr 2015 17:19:30 +0000 (18:19 +0100)]
gdb_test_multiple: Fix user code argument processing

While teaching gdb_test_multiple to forward "-i" to gdb_expect, I
found that with:

      gdb_test_multiple (...) {
        -i $some_variable -re "..." {}
      }

$some_variable was not getting expanded in the gdb_test_multiple
caller's scope.  This is a bug inside gdb_test_multiple.  When
processing an argument in passed in user code, it was appending the
original argument literally, instead of appending the uplist'ed
argument.

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

        * lib/gdb.exp (gdb_test_multiple): When processing an argument,
append the substituted item, not the original item.

9 years agogdb.base/interrupt.exp: Use gdb_test_multiple instead of gdb_expect
Pedro Alves [Tue, 7 Apr 2015 17:19:29 +0000 (18:19 +0100)]
gdb.base/interrupt.exp: Use gdb_test_multiple instead of gdb_expect

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

* gdb.base/interrupt.exp: Use gdb_test_multiple instead of
gdb_expect.

9 years agogdb.base/interrupt.exp: Fix race
Pedro Alves [Tue, 7 Apr 2015 17:19:29 +0000 (18:19 +0100)]
gdb.base/interrupt.exp: Fix race

Working on splitting gdb and inferior output handling in this test, I
noticed a race that happens to be masked out today.

The test sends "a\n" to the inferior, and then inferior echoes back
"a\n".

If expect manages to read only the first "a\r\n" into its buffer, then
this matches:

    -re "^a\r\n(|a\r\n)$" {

and leaves the second "a\r\n" in output.

Then the next test that processes inferior I/O sends "data\n", and expects:

    -re "^(\r\n|)data\r\n(|data\r\n)$"

which fails given the anchor and given "a\r\n" is still in the buffer.

This is masked today because the test relies on inferior I/O being
done on GDB's terminal, and there are tested GDB commands in between,
which consume the "a\r\n" that was left in the output.

We don't support SunOS4 anymore, so just remove the workaround.

gdb/testsuite/ChangeLog
2015-04-07  Pedro Alves  <palves@redhat.com>

* gdb.base/interrupt.exp: Don't handle the case of the inferior
output appearing once only.

9 years ago[AArch64] use subseg_text_p to check .text
Renlin Li [Tue, 7 Apr 2015 17:10:33 +0000 (18:10 +0100)]
[AArch64] use subseg_text_p to check .text

2015-04-07  Renlin Li  <renlin.li@arm.com>

gas/
  * config/tc-aarch64.c (mapping_state): Use subseg_text_p.
  (s_aarch64_inst): Likewise.
  (md_assemble): Likewise.

9 years agoFix gdb.trace/actions.exp race
Pedro Alves [Thu, 5 Mar 2015 22:01:06 +0000 (22:01 +0000)]
Fix gdb.trace/actions.exp race

I saw this on PPC64 once:

  not installed on target
  (gdb) PASS: gdb.trace/actions.exp: 5.10a: verify teval actions set for two tracepoints
  break main
  Breakpoint 4 at 0x10000c6c: file ../../../src/gdb/testsuite/gdb.trace/actions.c, line 139.
  (gdb) PASS: gdb.trace/actions.exp: break main
  run
  Starting program: /home/palves/gdb/build/gdb/testsuite/outputs/gdb.trace/actions/actions
  tstatus

  Breakpoint 4, main (argc=1, argv=0x3fffffffebb8, envp=0x3fffffffebc8) at ../../../src/gdb/testsuite/gdb.trace/actions.c:139
  139       begin ();
  (gdb) tstatus
  Trace can not be run on this target.
  (gdb) actions 1
  Enter actions for tracepoint 1, one per line.
  End with a line saying just "end".
  >collect $regs
  >end
  (gdb) PASS: gdb.trace/actions.exp: set actions for first tracepoint
  tstart
  You can't do that when your target is `native'
  (gdb) FAIL: gdb.trace/actions.exp: tstart
  info tracepoints 1
  Num     Type           Disp Enb Address            What
  1       tracepoint     keep y   0x00000000100007c8 in gdb_c_test at ../../../src/gdb/testsuite/gdb.trace/actions.c:74
  collect $regs
  not installed on target
  ...

followed by a cascade of FAILs.  The "tstatus" was supposed to detect
that this target (native) can't do tracepoints, but, alas, it didn't.

That detection failed because 'gdb_test "break main"' doesn't expect
anything, and then the output was slow enough that 'gdb_test ""
"Breakpoint .*"' matched the output of "break main"...

The fix is to use gdb_breakpoint instead.  Also check the result of
gdb_test while at it.

Tested on x86-64 Fedora 20, native and gdbserver.

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

* gdb.trace/actions.exp: Use gdb_breakpoint instead of gdb_test
that doesn't expect anything.  Return early if running to main
fails.

9 years agoAdd new linker option: --warn-orphan which generates warning messages when orphan...
Nick Clifton [Tue, 7 Apr 2015 15:29:41 +0000 (16:29 +0100)]
Add new linker option: --warn-orphan  which generates warning messages when orphan sections are detected.

ld * ld.h (struct ld_config_type): Add new field: warn_orphan.
* ldlex.h (enum option_values): Add OPTION_WARN_ORPHAN and
OPTION_NO_WARN_ORPHAN.
* lexsup.c (ld_options): Add --warn-orphan and --no-warn-orphan.
(parse_args): Handle the new options.
* ldemul.c (ldemul_place_orphan): If requested, generate a warning
message when an orphan section is placed in the output file.
* ld.texinfo: Document the new option.
* NEWS: Mention the new feature.

tests * ld-elf/orphan-5.l: New test - checks the linker's output with
--warn-orphan enabled.
* ld-elf/elf.exp: Run the new test.

9 years agoupdate thread list, delete exited threads
Pedro Alves [Tue, 7 Apr 2015 14:47:22 +0000 (15:47 +0100)]
update thread list, delete exited threads

On GNU/Linux, if the running kernel supports clone events, then
linux-thread-db.c defers thread listing to the target beneath:

static void
thread_db_update_thread_list (struct target_ops *ops)
{
...
  if (target_has_execution && !thread_db_use_events ())
    ops->beneath->to_update_thread_list (ops->beneath);
  else
    thread_db_update_thread_list_td_ta_thr_iter (ops);
...
}

However, when live debugging, the target beneath, linux-nat.c, does
not implement the to_update_thread_list method.  The result is that if
a thread is marked exited (because it can't be deleted right now,
e.g., it was the selected thread), then it won't ever be deleted,
until the process exits or is killed/detached.

A similar thing happens with the remote.c target.  Because its
target_update_thread_list implementation skips exited threads when it
walks the current thread list looking for threads that no longer exits
on the target side, using ALL_NON_EXITED_THREADS_SAFE, stale exited
threads are never deleted.

This is not a big deal -- I can't think of any way this might be user
visible, other than gdb's memory growing a tiny bit whenever a thread
gets stuck in exited state.  Still, might as well clean things up
properly.

All other targets use prune_threads, so are unaffected.

The fix adds a ALL_THREADS_SAFE macro, that like
ALL_NON_EXITED_THREADS_SAFE, walks the thread list and allows deleting
the iterated thread, and uses that in places that are walking the
thread list in order to delete threads.  Actually, after converting
linux-nat.c and remote.c to use this, we find the only other user of
ALL_NON_EXITED_THREADS_SAFE is also walking the list to delete
threads.  So we convert that too, and end up deleting
ALL_NON_EXITED_THREADS_SAFE.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/ChangeLog
2015-04-07  Pedro Alves  <palves@redhat.com>

* gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): Rename to ...
(ALL_THREADS_SAFE): ... this, and don't skip exited threads.
(delete_exited_threads): New declaration.
* infrun.c (follow_exec): Use ALL_THREADS_SAFE.
* linux-nat.c (linux_nat_update_thread_list): New function.
(linux_nat_add_target): Install it.
* remote.c (remote_update_thread_list): Use ALL_THREADS_SAFE.
* thread.c (prune_threads): Use ALL_THREADS_SAFE.
(delete_exited_threads): New function.

9 years agoModify get_reloc_section for targets that map .got.plt to .got
Alan Modra [Tue, 7 Apr 2015 12:53:21 +0000 (22:23 +0930)]
Modify get_reloc_section for targets that map .got.plt to .got

Fixes tic6x testsuite failures due to .rela.plt having a zero sh_info.
I considered passing link_info to get_reloc_section so we could
directly return the .got.plt output section, but we need the fallback
to name lookup anyway for objcopy.

bfd/
* elf.c (_bfd_elf_get_reloc_section): Allow for .got.plt being
mapped to output .got section.
ld/testsuite/
* ld-arm/tls-gdesc-nlazy.g: Adjust for readelf note.
* ld-tic6x/shlib-1.rd: Expect corrected .rela.plt sh_info.
* ld-tic6x/shlib-1b.rd: Likewise.
* ld-tic6x/shlib-1r.rd: Likewise.
* ld-tic6x/shlib-1rb.rd: Likewise.
* ld-tic6x/shlib-app-1.rd: Likewise.
* ld-tic6x/shlib-app-1b.rd: Likewise.
* ld-tic6x/shlib-app-1r.rd: Likewise.
* ld-tic6x/shlib-app-1rb.rd: Likewise.
* ld-tic6x/shlib-noindex.rd: Likewise.

9 years agoCast shift expression
Alan Modra [Tue, 7 Apr 2015 01:09:59 +0000 (10:39 +0930)]
Cast shift expression

PR ld/18176
* ldlang.c (lang_size_sections): Cast shift expression.

9 years agoPowerPC non-PIC to PIC editing for protected var access
Alan Modra [Tue, 31 Mar 2015 23:29:46 +0000 (09:59 +1030)]
PowerPC non-PIC to PIC editing for protected var access

This is a linker-only solution to the incompatibility between shared
library protected visibility variables and using .dynbss and copy
relocs for non-PIC access to shared library variables.

bfd/
* elf32-ppc.c (struct ppc_elf_link_hash_entry): Add has_addr16_ha
and has_addr16_lo.  Make has_sda_refs a bitfield.
(ppc_elf_check_relocs): Set new flags.
(ppc_elf_link_hash_table_create): Update default_params.
(ppc_elf_adjust_dynamic_symbol): Clear protected_def in cases
where we won't be making .dynbss entries or editing code.  Set
params->pic_fixup when we'll edit code for protected var access.
(allocate_dynrelocs): Allocate got entry for edited code and
discard dyn_relocs.
(struct ppc_elf_relax_info): Add picfixup_size.
(ppc_elf_relax_section): Rename struct one_fixup to struct
one_branch_fixup.  Rename fixups to branch_fixups.  Size space for
pic fixups.
(ppc_elf_relocate_section): Edit non-PIC accessing protected
visibility variables to PIC.  Don't emit dyn_relocs for code
we've edited.
* elf32-ppc.h (struct ppc_elf_params): Add pic_fixup.
ld/
* emultempl/ppc32elf.em: Handle --no-pic-fixup.
(params): Init new field.
(ppc_before_allocation): Enable relaxation for pic_fixup.

9 years agoDisplaced stepping debug: fetch the right regcache
Pedro Alves [Tue, 7 Apr 2015 10:42:09 +0000 (11:42 +0100)]
Displaced stepping debug: fetch the right regcache

Although not currently possible in practice when we get here,
'resume_ptid' can also be a wildcard throughout this function.  It's
clearer to fetch the regcache using the thread's ptid.

gdb/ChangeLog:
2015-04-07  Pedro Alves  <pedro@codesourcery.com>

* infrun.c (resume) <displaced stepping debug output>: Get the
leader thread's regcache, not resume_ptid's.