binutils-gdb.git
9 years agosim: trim old USING_SIM_BASE_H define
Mike Frysinger [Sat, 18 Apr 2015 08:22:25 +0000 (04:22 -0400)]
sim: trim old USING_SIM_BASE_H define

This doesn't appear to have been used since 1998, but wasn't cleaned
up since.  So much for being "quick" ;).

9 years agosim: unify SIM_CPU definition
Mike Frysinger [Sat, 18 Apr 2015 08:19:56 +0000 (04:19 -0400)]
sim: unify SIM_CPU definition

Since every target typedefs this the same way, move it to the common code.

We have to leave Blackfin behind here for now because of inter-dependencies
on types and headers: sim-base.h includes sim-model.h which needs types in
machs.h which needs types in bfim-sim.h which needs SIM_CPU.

9 years agosim: unify sim_cia definition
Mike Frysinger [Sat, 18 Apr 2015 08:08:56 +0000 (04:08 -0400)]
sim: unify sim_cia definition

Almost every target defines sim_cia the same way -- either using the
address_word type directly, or a type of equivalent size.  The only
odd one out is sh64 (who has 32bit address_word and 64bit cia), and
even that case doesn't seem to make sense.  We'll put off clean up
though of sh64 and at least set up a sensible default for everyone.

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

9 years agosolib-svr4.c (svr4_exec_displacement): Rename outer "displacement".
Doug Evans [Fri, 17 Apr 2015 17:57:45 +0000 (10:57 -0700)]
solib-svr4.c (svr4_exec_displacement): Rename outer "displacement".

gdb/ChangeLog:

* solib-svr4.c (svr4_exec_displacement): Rename outer "displacement"
to "exec_displacement" to avoid confusion with inner use of the name.

9 years agoUse LIFO instead of FIFO to implement gc's transitive closure.
Rafael Ávila de Espíndola [Fri, 17 Apr 2015 15:51:36 +0000 (11:51 -0400)]
Use LIFO instead of FIFO to implement gc's transitive closure.

FIFO is harder to implement and has less locality than LIFO. It is
also not necessary to implement a transitive closure, a LIFO works
just as well.

9 years agoMerge include/partition.h from GCC.
Richard Earnshaw [Fri, 17 Apr 2015 15:10:43 +0000 (16:10 +0100)]
Merge include/partition.h from GCC.

2015-03-19  Richard Biener  <rguenther@suse.de>

* partition.h (struct partition_elem): Re-order elements to
avoid padding.

9 years agogdbserver/xtensa: fix typo in XCHAL_HAVE_LOOPS
Max Filippov [Thu, 16 Apr 2015 23:52:50 +0000 (02:52 +0300)]
gdbserver/xtensa: fix typo in XCHAL_HAVE_LOOPS

This fixes lbeg/lend/lcount registers handling through gdbserver.

2015-04-17  Max Filippov  <jcmvbkbc@gmail.com>
gdb/gdbserver/
* linux-xtensa-low.c (xtensa_fill_gregset)
(xtensa_store_gregset): Check XCHAL_HAVE_LOOPS instead of
XCHAL_HAVE_LOOP.

9 years agogdbserver/xtensa: drop xtensa_usrregs_info
Max Filippov [Fri, 17 Apr 2015 00:07:41 +0000 (03:07 +0300)]
gdbserver/xtensa: drop xtensa_usrregs_info

xtensa_usrregs_info refers to undefined variables xtensa_num_regs and
xtensa_regmap. Drop xtensa_usrregs_info and replace pointer to usrregs
in regs_info with NULL since all registers are read/set through regsets.

2015-04-17  Max Filippov  <jcmvbkbc@gmail.com>
gdb/gdbserver/
* linux-xtensa-low.c (xtensa_usrregs_info): Remove.
(regs_info): Replace usrregs pointer with NULL.

9 years agoreturn zero in arm_linux_can_use_hw_breakpoint if HW point isn't supported
Yao Qi [Fri, 17 Apr 2015 12:52:44 +0000 (13:52 +0100)]
return zero in arm_linux_can_use_hw_breakpoint if HW point isn't supported

This patch is to cherry-pick part of Pedro's patch here
https://sourceware.org/ml/gdb-patches/2015-04/msg00527.html in which
zero is returned if the HW point isn't supported.

In arm-linux native gdb testing on a board doesn't support HW breakpoint,
without this patch, the output in gdb.base/breakpoint-in-ro-region.exp is like:

(gdb) hbreak *0x83bc^M
Hardware breakpoints used exceeds limit.^M
(gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: probe hbreak support (support)

with this patch, the output becomes:

(gdb) hbreak *0x83bc^M
No hardware breakpoint support in the target.^M
(gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: probe hbreak support (no support)

As a result, the following fails are fixed.

-FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: step in ro region (cannot insert hw break)
-FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: thread advanced
-FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: step in ro region (cannot insert hw break)
-FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: thread advanced

gdb:

2015-04-17  Pedro Alves  <palves@redhat.com>

* arm-linux-nat.c (arm_linux_can_use_hw_breakpoint): Return zero
if HW point of TYPE isn't supported.

9 years agoUpdate comments to target_can_use_hardware_watchpoint
Yao Qi [Fri, 17 Apr 2015 12:45:53 +0000 (13:45 +0100)]
Update comments to target_can_use_hardware_watchpoint

The return value of target_can_use_hardware_watchpoint isn't well
documented, so this patch is to update the comments to reflect the
fact.  This patch also removes a trailing ";" which is picked up
from Pedro's patch https://sourceware.org/ml/gdb-patches/2015-04/msg00527.html

gdb:

2015-04-17  Yao Qi  <yao.qi@linaro.org>
    Pedro Alves  <palves@redhat.com>

* target.h (target_can_use_hardware_watchpoint): Update comments.
Remove trailing ";".

9 years agoFix avr compiler warning
Senthil Kumar Selvaraj [Fri, 17 Apr 2015 11:25:54 +0000 (20:55 +0930)]
Fix avr compiler warning

declaration of "link" shadows a global declaration

* config/tc-avr.c (create_record_for_frag): Rename link to
prop_rec_link.

9 years agoAccess executable from remote system when first inferior appears
Gary Benson [Fri, 17 Apr 2015 08:47:30 +0000 (09:47 +0100)]
Access executable from remote system when first inferior appears

This commit modifies remote_add_inferior to take an extra argument
try_open_exec.  If this is nonzero, remote_add_inferior will attempt
to open this inferior's executable as the main executable if no main
executable is open already.  Callers are updated appropriately.

With this commit, remote debugging can now be initiated using only a
"target remote" or "target extended-remote" command; no "set sysroot"
or "file" commands are required, e.g.

  bash$ gdb -q
  (gdb) target remote | gdbserver - /bin/sh
  Remote debugging using | gdbserver - /bin/sh
  Process /bin/sh created; pid = 32166
  stdin/stdout redirected
  Remote debugging using stdio
  Reading symbols from target:/bin/bash...

One testcase required updating as a result of this commit.  The test
checked that GDB's "info files" command does not crash if no main
executable is open, and relied on GDB's inability to access the main
executable over the remote protocol.  The test was updated to inhibit
this new behavior.

gdb/ChangeLog:

* remote.c (remote_add_inferior): New argument try_open_exec.
If nonzero, attempt to open the inferior's executable file as
the main executable if no main executable is open already.
All callers updated.
* NEWS: Mention that GDB now supports automatic location and
retrieval of executable + files from remote targets.

gdb/doc/ChangeLog:

* gdb.texinfo (Connecting to a Remote Target): Mention that
GDB can access program files from remote targets that support
qXfer:exec-file:read and Host I/O packets.

gdb/testsuite/ChangeLog:

* gdb.server/server-exec-info.exp: Inhibit GDB from accessing
the main executable over the remote protocol.

9 years agoImplement qXfer:exec-file:read in gdbserver
Gary Benson [Fri, 17 Apr 2015 08:47:30 +0000 (09:47 +0100)]
Implement qXfer:exec-file:read in gdbserver

This commit implements the "qXfer:exec-file:read" packet in gdbserver.

gdb/gdbserver/ChangeLog:

* target.h (struct target_ops) <pid_to_exec_file>: New field.
* linux-low.c (linux_target_ops): Initialize pid_to_exec_file.
* server.c (handle_qxfer_exec_file): New function.
(qxfer_packets): Add exec-file entry.
(handle_query): Report qXfer:exec-file:read as supported packet.

9 years agoImplement remote_pid_to_exec_file using qXfer:exec-file:read
Gary Benson [Fri, 17 Apr 2015 08:47:30 +0000 (09:47 +0100)]
Implement remote_pid_to_exec_file using qXfer:exec-file:read

This commit adds a new packet "qXfer:exec-file:read" to the remote
protocol that can be used to obtain the pathname of the file that
was executed to create a process on the remote system.  Support for
this packet is added to GDB and remote_ops.to_pid_to_exec_file is
implemented using it.

gdb/ChangeLog:

* target.h (TARGET_OBJECT_EXEC_FILE): New enum value.
* remote.c (PACKET_qXfer_exec_file): Likewise.
(remote_protocol_features): Register the
"qXfer:exec-file:read" feature.
(remote_xfer_partial): Handle TARGET_OBJECT_EXEC_FILE.
(remote_pid_to_exec_file): New function.
(init_remote_ops): Initialize to_pid_to_exec_file.
(_initialize_remote): Register new "set/show remote
pid-to-exec-file-packet" command.
* NEWS: Announce new qXfer:exec-file:read packet.

gdb/doc/ChangeLog:

* gdb.texinfo (Remote Configuration): Document the "set/show
remote pid-to-exec-file-packet" command.
(General Query Packets): Document the qXfer:exec-file:read
qSupported features.  Document the qXfer:exec-file:read packet.

9 years agoIntroduce linux_proc_pid_to_exec_file
Gary Benson [Fri, 17 Apr 2015 08:47:30 +0000 (09:47 +0100)]
Introduce linux_proc_pid_to_exec_file

This commit introduces a new function linux_proc_pid_to_exec_file
that shared Linux code can use to discover the filename of the
executable that was run to create a process on the system.

gdb/ChangeLog:

* nat/linux-procfs.h (linux_proc_pid_to_exec_file):
New declaration.
* nat/linux-procfs.c (linux_proc_pid_to_exec_file):
New function, factored out from...
* linux-nat.c (linux_child_pid_to_exec_file): ...here.

9 years agoUse gdb_sysroot for main executable on attach
Gary Benson [Fri, 17 Apr 2015 08:47:30 +0000 (09:47 +0100)]
Use gdb_sysroot for main executable on attach

This commit updates exec_file_locate_attach to use exec_file_find
to compute the full pathname of the main executable in some cases.
The net effect of this is that the main executable's path will be
prefixed with gdb_sysroot in the same way that shared library paths
currently are.

gdb/ChangeLog:

* exec.c (solist.h): New include.
(exec_file_locate_attach): Prefix absolute executable
paths with gdb_sysroot if set.
* NEWS: Mention that executable paths may be prepended
with sysroot.

gdb/doc/ChangeLog:

* gdb.texinfo (set sysroot): Document that "set sysroot" also
applies to executable paths if supplied to GDB as absolute.

9 years agoIntroduce exec_file_find
Gary Benson [Fri, 17 Apr 2015 08:47:30 +0000 (09:47 +0100)]
Introduce exec_file_find

This commit adds a new function, exec_file_find, which computes the
full pathname of the main executable in much the same way solib_find
does for pathnames of shared libraries.  The bulk of the existing
solib_find was moved into a new static function solib_find_1, with
exec_file_find and solib_find being small wrappers for solib_find_1.

gdb/ChangeLog:

* solist.h (exec_file_find): New declaration.
* solib.c (solib_find_1): New function, factored out from...
(solib_find): ...here.
(exec_file_find): New function.

9 years agoIntroduce exec_file_locate_attach
Gary Benson [Fri, 17 Apr 2015 08:47:30 +0000 (09:47 +0100)]
Introduce exec_file_locate_attach

This commit adds a new function, exec_file_locate_attach, which works
like exec_file_attach except that, instead of a filename argument, it
takes an integer process ID and attempts to determine the executable
filename from that.

gdb/ChangeLog:

* gdbcore.h (exec_file_locate_attach): New declaration.
* exec.c (exec_file_locate_attach): New function, factored
out from...
* infcmd.c (attach_command_post_wait): ...here.

9 years agogdb: add myself to blackfin/write-after-approval
Mike Frysinger [Thu, 2 Apr 2015 04:51:25 +0000 (00:51 -0400)]
gdb: add myself to blackfin/write-after-approval

9 years agosim: microblaze: switch to common memory functions
Mike Frysinger [Sun, 12 Apr 2015 09:49:31 +0000 (05:49 -0400)]
sim: microblaze: switch to common memory functions

Re-use the existing memory core that handles reads/writes.

This drops support for the dumpmem command, but gdb itself has
support for dumping memory regions.

The verbose command is converted to the common --verbose flag
since only two call sites use it now.

Support for the clearstats command is dropped entirely, but no
other sim really does this, and the same thing can be done by
reloading.  If it's important (clearing cycle stats) to someone,
we can add a common function for it.

9 years agosim: replace CIA_{GET,SET} with CPU_PC_{GET,SET}
Mike Frysinger [Thu, 16 Apr 2015 06:11:12 +0000 (02:11 -0400)]
sim: replace CIA_{GET,SET} with CPU_PC_{GET,SET}

The CIA_{GET,SET} macros serve the same function as CPU_PC_{GET,SET}
except the latter adds a layer of indirection via the sim state.  This
lets models set up different functions at runtime and doesn't reach so
directly into the arch-specific cpu state.

It also doesn't make sense to have two sets of macros that do exactly
the same thing, so lets standardize on the one that gets us more.

9 years agosim: arm/cr16/d10v/h8300/microblaze/sh: fill out sim-cpu pc fetch/store helpers
Mike Frysinger [Fri, 17 Apr 2015 06:16:10 +0000 (02:16 -0400)]
sim: arm/cr16/d10v/h8300/microblaze/sh: fill out sim-cpu pc fetch/store helpers

This makes the common sim-cpu logic work.

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

9 years ago[gold] The first patch to address cortex-a53 erratum-843419.
Han Shen [Thu, 16 Apr 2015 22:17:08 +0000 (15:17 -0700)]
[gold] The first patch to address cortex-a53 erratum-843419.

It implemented scanning the binary and reporting occurrences to users
when '--fix-cortex-a53' is turned on. With this, gold users will be
able to see if or not there are such erratum occurrences in the output
binary. Also included in the CL is reading/recording mapping symbols,
which is needed during scan.

gold/ChangeLog:
    * aarch64.cc (AArch64_insn_utilities): New utility class.
    (AArch64_relobj::Mapping_symbol_position): New struct.
    (AArch64_relobj::Mapping_symbol_info): New typedef.
    (AArch64_relobj::do_count_local_symbols): New function overriding
    parent's implementation.
    (AArch64_relobj::mapping_symbol_info_): New member
    (AArch64_relobj::scan_erratum_843419): New method.
    (Target_aarch64::scan_erratum_843419_span): New method.
    (Target_aarch64::is_erratum_843419_sequence): New method.
    * options.h (fix_cortex_a53): New option.

9 years agoFix {mi-tracepoint-changed, mi-tsv-changed}.exp with native-extended-gdbserver
Pedro Alves [Thu, 16 Apr 2015 11:23:26 +0000 (12:23 +0100)]
Fix {mi-tracepoint-changed, mi-tsv-changed}.exp with native-extended-gdbserver

Fixes:

 -FAIL: gdb.trace/mi-tracepoint-changed.exp: reconnect: break-info 1
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: tracepoint created
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: tracepoint on marker is installed
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: break-info 1

 -FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv1 created
 -FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv2 created
 +PASS: gdb.trace/mi-tsv-changed.exp: upload: tsv1 created
 +PASS: gdb.trace/mi-tsv-changed.exp: upload: tsv2 created

These tests do something like this:

 #0 - start gdb/gdbserver normally
 #1 - setup some things in the debug session
 #2 - disconnect from gdbserver
 #3 - restart gdb
 #4 - reconnect to gdbserver

The problem is that the native-extended-gdbserver board always spawns
a new gdbserver instance in #3 (and has gdb connect to that).  So when
the test gets to #4, it connects to that new instance instead of the
old one:

 (gdb) spawn ../gdbserver/gdbserver --multi :2354
 Listening on port 2354
 target extended-remote localhost:2354
 Remote debugging using localhost:2354
 ...
 spawn ../gdbserver/gdbserver --multi :2355
 Listening on port 2355
 47-target-select extended-remote localhost:2355
 =tsv-created,name="trace_timestamp",initial="0"\n
 47^connected
 (gdb)
 ...
 47-target-select extended-remote localhost:2355
 47^connected
 (gdb)
 FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv1 created
 FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv2 created

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

* boards/native-extended-gdbserver.exp (mi_gdb_start): Don't start
a new gdbserver if gdbserver_reconnect_p is set.

9 years agoFix gdbserver_reconnect_p handling
Pedro Alves [Thu, 16 Apr 2015 13:26:59 +0000 (14:26 +0100)]
Fix gdbserver_reconnect_p handling

Commit 6423214f (testsuite: Don't use expect_background to reap
gdbserver) broke a couple tests that set gdbserver_reconnect_p and
restart gdb before reconnecting, because a gdb_exit (e.g., through
clean_restart) exits gdbserver unconditionally.

Fixes, with --target_board=native-gdbserver:

 -FAIL: gdb.trace/mi-tracepoint-changed.exp: reconnect: break-info 1
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: tracepoint created
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: tracepoint on marker is installed
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: break-info 1

 -FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv1 created
 -FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv2 created
 +PASS: gdb.trace/mi-tsv-changed.exp: upload: tsv1 created
 +PASS: gdb.trace/mi-tsv-changed.exp: upload: tsv2 created

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

* lib/gdbserver-support.exp (gdb_exit): If gdbserver_reconnect_p
is set, don't exit gdbserver.

9 years agoHonour software single step in fallback of displaced stepping
Yao Qi [Thu, 16 Apr 2015 12:48:10 +0000 (13:48 +0100)]
Honour software single step in fallback of displaced stepping

Hi,
When I run gdb.threads/non-stop-fair-events.exp on arm-linux target,
I see the following message in the debugging log,

  displaced: breakpoint is gone: Thread 22518, step(1)^M
  Sending packet: $vCont;s:p57f3.57f6#9d...
                  ^^^^^^^^^
GDB sends vCont;s by mistake, and GDBserver fails on assert.  GDB
doesn't consider software single step in infrun.c:displaced_step_fixup,

  /* Go back to what we were trying to do.  */
  step = currently_stepping (tp);

  if (debug_displaced)
    fprintf_unfiltered (gdb_stdlog,
"displaced: breakpoint is gone: %s, step(%d)\n",
target_pid_to_str (tp->ptid), step);

  target_resume (ptid, step, GDB_SIGNAL_0);

The patch is to let GDB consider software single step here.  It fixes
fails in gdb.threads/non-stop-fair-events.exp on arm.

gdb:

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

* infrun.c (maybe_software_singlestep): Declare.
(displaced_step_fixup): Call maybe_software_singlestep.

9 years agos390-vregs.exp: Avoid compile errors with older GCCs and on 31-bit targets
Andreas Arnez [Thu, 16 Apr 2015 11:03:48 +0000 (13:03 +0200)]
s390-vregs.exp: Avoid compile errors with older GCCs and on 31-bit targets

The test case s390-vregs.exp yields compile errors on 31-bit targets
as well as when using a GCC that defaults to an older "-march=".  This
patch fixes these issues.

gdb/testsuite/ChangeLog:

* gdb.arch/s390-vregs.S (change_vrs): Replace exrl by an
appropriate .insn, such that an older assembler can be used.
* gdb.arch/s390-vregs.exp: Add the compile flag -mzarch, to enable
the z/Architecture instruction set on 31-bit targets as well.

9 years agoGDB tests for Go language support: remove unnecessary first breakpoint
Andreas Arnez [Thu, 16 Apr 2015 11:03:47 +0000 (13:03 +0200)]
GDB tests for Go language support: remove unnecessary first breakpoint

On s390x targets some of the Go test cases fail because the first
breakpoint happens to be at the same spot as the breakpoint at
main.main.  When such a test case tries to continue to the first
breakpoint, the program runs until the end instead, and the test fails
like this:

FAIL: gdb.go/handcall.exp: Going to first breakpoint (the program exited)

This patch removes all the handling related to the first breakpoint in
those cases.  After applying the patch, the tests run successfully on
s390x.

gdb/testsuite/ChangeLog:

* gdb.go/handcall.exp: Remove all logic related to the first
breakpoint and rely on go_runto_main instead.
* gdb.go/strings.exp: Likewise.
* gdb.go/unsafe.exp: Likewise.
* gdb.go/hello.exp: Likewise.  Also rename the remaining
breakpoint marker to "breakpoint 1".
* gdb.go/handcall.go: Remove comment "set breakpoint 1 here".
* gdb.go/strings.go: Likewise.
* gdb.go/unsafe.go: Likewise.
* gdb.go/hello.go: Likewise.  Also remove the second occurrence of
"set breakpoint 2 here" and rename the remaining breakpoint marker
to "breakpoint 1".

9 years agosim: avr/mcore/moxie: fill out sim-cpu pc fetch/store helpers
Mike Frysinger [Thu, 16 Apr 2015 06:07:33 +0000 (02:07 -0400)]
sim: avr/mcore/moxie: fill out sim-cpu pc fetch/store helpers

This makes the common sim-cpu logic work.

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

9 years agoRemove the unused PREFIX_UD_XXX
H.J. Lu [Wed, 15 Apr 2015 22:58:45 +0000 (15:58 -0700)]
Remove the unused PREFIX_UD_XXX

Remove the unused PREFIX_UD_XXX.  Invalid opcodes should be handled by
prefix_table.

* i386-dis.c (PREFIX_UD_SHIFT): Removed.
(PREFIX_UD_REPZ): Likewise.
(PREFIX_UD_REPNZ): Likewise.
(PREFIX_UD_DATA): Likewise.
(PREFIX_UD_ADDR): Likewise.
(PREFIX_UD_LOCK): Likewise.

9 years agoMake info fun|var|types interruptable for psyms.
Doug Evans [Wed, 15 Apr 2015 21:04:35 +0000 (14:04 -0700)]
Make info fun|var|types interruptable for psyms.

gdb/ChangeLog:

* psymtab.c (psym_expand_symtabs_matching): Add QUIT call.

9 years agoMake info fun|var|types interruptable.
Doug Evans [Wed, 15 Apr 2015 20:25:42 +0000 (13:25 -0700)]
Make info fun|var|types interruptable.

"info fun foo" can be a pain when it's not interruptable,
especially if you're not exactly sure of what you're looking for
and provide something that matches too much.

gdb/ChangeLog:

* dwarf2read.c (dw2_expand_symtabs_matching): Add some QUIT calls.

9 years agoCheck dp->prefix_requirement instead
H.J. Lu [Wed, 15 Apr 2015 18:28:16 +0000 (11:28 -0700)]
Check dp->prefix_requirement instead

This patch removes prefix_requirement and checks dp->prefix_requirement
instead.

* i386-dis.c (prefix_requirement): Removed.
(print_insn): Don't set prefix_requirement.  Check
dp->prefix_requirement instead of prefix_requirement.

9 years agoHandle invalid prefixes for rdrand and rdseed
H.J. Lu [Wed, 15 Apr 2015 16:53:13 +0000 (09:53 -0700)]
Handle invalid prefixes for rdrand and rdseed

This patch puts rdrand and rdseed in prefix_table so that invalid
prefixes for rdrand and rdseed are handled properly.

gas/testsuite/

PR binutils/17898
* gas/i386/prefix.s: Add rdrand/rdseed prefix tests.
* gas/i386/prefix.d: Updated.

opcodes/

PR binutils/17898
* i386-dis.c (PREFIX_0FC7_REG_6): Renamed to ...
(PREFIX_MOD_0_0FC7_REG_6): This.
(PREFIX_MOD_3_0FC7_REG_6): New.
(PREFIX_MOD_3_0FC7_REG_7): Likewise.
(prefix_table): Replace PREFIX_0FC7_REG_6 with
PREFIX_MOD_0_0FC7_REG_6.  Add PREFIX_MOD_3_0FC7_REG_6 and
PREFIX_MOD_3_0FC7_REG_7.
(mod_table): Replace PREFIX_0FC7_REG_6 with
PREFIX_MOD_0_0FC7_REG_6.  Use PREFIX_MOD_3_0FC7_REG_6 and
PREFIX_MOD_3_0FC7_REG_7.

9 years agoReplace mandatory_prefix with prefix_requirement
H.J. Lu [Wed, 15 Apr 2015 16:24:45 +0000 (09:24 -0700)]
Replace mandatory_prefix with prefix_requirement

* i386-dis.c (PREFIX_MANDATORY_REPZ): Removed.
(PREFIX_MANDATORY_REPNZ): Likewise.
(PREFIX_MANDATORY_DATA): Likewise.
(PREFIX_MANDATORY_ADDR): Likewise.
(PREFIX_MANDATORY_LOCK): Likewise.
(PREFIX_MANDATORY): Likewise.
(PREFIX_UD_SHIFT): Set to 8
(PREFIX_UD_REPZ): Updated.
(PREFIX_UD_REPNZ): Likewise.
(PREFIX_UD_DATA): Likewise.
(PREFIX_UD_ADDR): Likewise.
(PREFIX_UD_LOCK): Likewise.
(PREFIX_IGNORED_SHIFT): New.
(PREFIX_IGNORED_REPZ): Likewise.
(PREFIX_IGNORED_REPNZ): Likewise.
(PREFIX_IGNORED_DATA): Likewise.
(PREFIX_IGNORED_ADDR): Likewise.
(PREFIX_IGNORED_LOCK): Likewise.
(PREFIX_OPCODE): Likewise.
(PREFIX_IGNORED): Likewise.
(Bad_Opcode): Replace PREFIX_MANDATORY with 0.
(dis386_twobyte): Replace PREFIX_MANDATORY with PREFIX_OPCODE.
(three_byte_table): Likewise.
(mod_table): Likewise.
(mandatory_prefix): Renamed to ...
(prefix_requirement): This.
(prefix_table): Replace PREFIX_MANDATORY with PREFIX_OPCODE.
Update PREFIX_90 entry.
(get_valid_dis386): Check prefix_requirement to see if a prefix
should be ignored.
(print_insn): Replace mandatory_prefix with prefix_requirement.

9 years ago[ARM] Disassembles SSAT and SSAT16 instructions incorrectly for Thumb-2
Renlin Li [Wed, 15 Apr 2015 16:44:03 +0000 (17:44 +0100)]
[ARM] Disassembles SSAT and SSAT16 instructions incorrectly for Thumb-2

2015-04-15  Renlin Li  <renlin.li@arm.com>
opcodes/:
    * arm-dis.c (thumb32_opcodes): Define 'D' format control code,
    use it for ssat and ssat16.
    (print_insn_thumb32): Add handle case for 'D' control code.

gas/testsuite/:
    * gas/arm/arch7em.d: Adjust required ssat and ssat16 immediate field.
    * gas/arm/thumb32.d: Likewise.

9 years agogdbserver: fix uClibc build whithout MMU.
Romain Naour [Tue, 14 Apr 2015 21:07:34 +0000 (23:07 +0200)]
gdbserver: fix uClibc build whithout MMU.

Since commit d86d4aafd4fa22fa4cccb83253fb187b03f97f48, the pid
must be retrieved from current_thread.

The change has not been made in the function linux_read_offsets().

Fixes:
http://autobuild.buildroot.net/results/9e4/9e4df085319e346803c26c65478accb27eb950ae/build-end.log

2015-04-14  Romain Naour <romain.naour@openwide.fr>  (tiny change)

* linux-low.c (linux_read_offsets): Remove get_thread_lwp.

Signed-off-by: Romain Naour <romain.naour@openwide.fr>
9 years agoSome Python 3 fixes
Simon Marchi [Wed, 15 Apr 2015 15:54:33 +0000 (11:54 -0400)]
Some Python 3 fixes

Some missing parentheses and one itertools.imap (Py2) vs map (Py3) issue.

gdb/ChangeLog:

* python/lib/gdb/command/unwinders.py: Add parentheses.

gdb/testsuite/ChangeLog:

* gdb.python/py-framefilter.py (ErrorFilter.filter): Use map function
if itertools.imap is not present.
* gdb.python/py-objfile.exp: Add parentheses.
* gdb.python/py-type.exp: Same.
* gdb.python/py-unwind-maint.py: Same.

9 years ago[arm] Update displaced stepping debug message
Yao Qi [Wed, 15 Apr 2015 14:09:53 +0000 (15:09 +0100)]
[arm] Update displaced stepping debug message

When I "set debug displaced 1" to fix fail in
gdb.base/disp-step-syscall.exp, the debug message is wrong.  This
patch is to fix it.

gdb:

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

* arm-linux-tdep.c (arm_linux_copy_svc): Update debug message.

9 years agoFix code indentation
Yao Qi [Wed, 15 Apr 2015 13:55:04 +0000 (14:55 +0100)]
Fix code indentation

gdb:

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

* arm-linux-tdep.c (arm_linux_copy_svc): Fix indentation.

9 years ago[arm] Fix fails in gdb.base/disp-step-syscall.exp
Yao Qi [Wed, 15 Apr 2015 13:34:03 +0000 (14:34 +0100)]
[arm] Fix fails in gdb.base/disp-step-syscall.exp

Hi,
I see this fail on arm-linux target,

 FAIL: gdb.base/disp-step-syscall.exp: fork: single step over fork final pc

which is caused by the PC isn't expected after displaced stepping the
svc instruction.  The code is:

=> 0xb6ead9a4 <__libc_do_syscall+4>:    svc     0
   0xb6ead9a6 <__libc_do_syscall+6>:    pop     {r7, pc}
   0xb6ead9a8:  nop.w^M
   0xb6ead9ac:  nop.w

after single step svc instruction, pc should be 0xb6ead9a6, but the
actual value of pc is 0xb6ead9a8.  The problem is illustrated by
turning on debug message of displaced stepping,

stepi^M
displaced: stepping Thread 12031 now^M
displaced: saved 0x8574: 02 bc 6a 46 04 b4 01 b4 df f8 10 c0 4d f8 04 cd 03 48 04 4b ff f7 d2 ef ff f7 e8 ef 0d 87 00 00 ^M
displaced: process thumb insn df00 at b6ead9a4^M
displaced: copying svc insn df00^M
displaced: read r7 value 00000078^M
displaced: sigreturn/rt_sigreturn SVC call not in signal trampoline frame^M
displaced: writing insn df00 at 00008574^M
displaced: copy 0xb6ead9a4->0x8574: displaced: check mode of b6ead9a4 instead of 00008574^M
displaced: displaced pc to 0x8574^M
displaced: run 0x8574: 00 df 01 de ^M
displaced: restored Thread 12031 0x8574^M
displaced: PC is apparently 00008576 after SVC step (within scratch space)^M
displaced: writing pc b6ead9a8  <----- WRONG ADDRESS

GDB writes the wrong address back to pc because GDB thinks the
instruction size is 4, which isn't true for thumb instruction.
This patch is to replace 4 with dsc->insn_size.

gdb:

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

* arm-linux-tdep.c (arm_linux_cleanup_svc): Use
dsc->insn_size instead of 4.

9 years agoFix fails in gdb.dwarf2/dynarr-ptr.exp
Yao Qi [Wed, 15 Apr 2015 13:04:40 +0000 (14:04 +0100)]
Fix fails in gdb.dwarf2/dynarr-ptr.exp

I see many fails in gdb.dwarf2/dynarr-ptr.exp on arm-linux target,
started from this

print foo.three_ptr.all^M
Cannot access memory at address 0x107c8^M
(gdb) FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr.all
print foo.three_ptr.all(1)^M
Cannot access memory at address 0x107c8

It turns out that ":$ptr_size" is used incorrectly.

             array_ptr_label: DW_TAG_pointer_type {
                 {DW_AT_byte_size :$ptr_size }
                                  ^^^^^^^^^^
                 {DW_AT_type :$array_label}
             }

Since the FORM isn't given, and it starts with the ":", it is regarded
as a label reference by dwarf assembler.  The generated asm file on
x86_64 is

        .uleb128        6               /* Abbrev (DW_TAG_pointer_type) */
        .4byte        8 - .Lcu1_begin   <----- WRONG
        .4byte        .Llabel2 - .Lcu1_begin

Looks .Lcu1_begin is 0 on x86_64 and that is why this test passes on
x86_64.  On arm, .Lcu1_begin is an address somewhere, and the value
of DW_AT_byte_size is a very large number, so memory read request
of such large length failed.

This patch is to remove ":" and set the form explicitly.  The generated
asm file on x86_64 becomes

        .uleb128        6               /* Abbrev (DW_TAG_pointer_type) */
        .byte        8
        .4byte        .Llabel2 - .Lcu1_begin

gdb/testsuite:

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

* gdb.dwarf2/dynarr-ptr.exp (assemble): Use $ptr_size instead
of ":$ptr_size" and set its form explicitly.

9 years agoMention --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]
H.J. Lu [Wed, 15 Apr 2015 12:25:58 +0000 (05:25 -0700)]
Mention --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]

binutils/

* NEWS: Mention
--compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi].

gas/

* NEWS: Mention
--compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi].

ld/

* NEWS: Mention
--compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi].

9 years agoIncrease timeout in watch-bitfields.exp for software watchpoint
Yao Qi [Wed, 15 Apr 2015 11:46:58 +0000 (12:46 +0100)]
Increase timeout in watch-bitfields.exp for software watchpoint

I see the following two timeout fails on pandaboard (arm-linux target),

 FAIL: gdb.base/watch-bitfields.exp: -location watch against bitfields: continue until exit (timeout)
 FAIL: gdb.base/watch-bitfields.exp: regular watch against bitfields: continue until exit (timeout)

In this test, more than one watchpoint is used, so the following
watchpoint requests fall back to software watchpoint, so that GDB
will single step all the way and it is very slow.

This patch is to copy the fix from

  [PATCH] GDB/testsuite: Correct gdb.base/watchpoint-solib.exp timeout tweak
  https://sourceware.org/ml/gdb-patches/2014-07/msg00716.html

I find the left-over of this patch review is to factor out code into
a procedure, so I do that in this patch.

Re-run tests watch-bitfields.exp, watchpoint-solib.exp, sigall-reverse.exp,
and until-precsave.exp on pandaboard, no regression.

gdb/testsuite:

2015-04-15  Pedro Alves  <palves@redhat.com>
    Yao Qi  <yao.qi@linaro.org>

* gdb.base/watch-bitfields.exp (test_watch_location): Increase
timeout by factor of 4.
(test_regular_watch): Likewise.
* gdb.base/watchpoint-solib.exp: Use with_timeout_factor.
* gdb.reverse/sigall-reverse.exp: Likewise.
* gdb.reverse/until-precsave.exp: Likewise.
* lib/gdb.exp (with_timeout_factor): New proc.
(gdb_expect): Move some code to ...
(get_largest_timeout): ... here.  New procedure.

9 years agosim: unify sim-cpu usage
Mike Frysinger [Wed, 15 Apr 2015 06:13:23 +0000 (02:13 -0400)]
sim: unify sim-cpu usage

Now that all the targets are utilizing CPU_PC_{FETCH,STORE}, and the
cpu state is multicore, and the STATE_CPU defines match, we can move
it all to the common code.

9 years agosim: cris/frv/h8300/iq2000/lm32/m32r/sh64: standardize cpu state
Mike Frysinger [Wed, 15 Apr 2015 05:22:34 +0000 (01:22 -0400)]
sim: cris/frv/h8300/iq2000/lm32/m32r/sh64: standardize cpu state

This sets up the sim_state structure and the cpu member to match what we
do in most other sims, and what the common code suggests.  This is a step
to unifying on the sim-cpu.o object.

9 years agoAdd --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]
H.J. Lu [Wed, 15 Apr 2015 05:01:25 +0000 (22:01 -0700)]
Add --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]

This patch adds --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]
to ld for ELF targets to support generating compressed DWARF debug
sections.  We always generate .zdebug_* section since section names have
been finalized and they can't be changed easily when compression is
being performed.

bfd/

* bfd-in.h (compressed_debug_section_type): New.
* compress.c (bfd_compress_section_contents): Add an argument
for linker write compression and always generate .zdebug_*
section when linking.
(bfd_init_section_compress_status): Pass FALSE to
bfd_compress_section_contents.
(bfd_compress_section): New function.
* elf.c (elf_fake_sections): For linking, set SEC_ELF_COMPRESS
on DWARF debug sections if COMPRESS_DEBUG is set and rename
section if COMPRESS_DEBUG_GABI_ZLIB isn't set.
(assign_file_positions_for_non_load_sections): Set sh_offset
to -1 if SEC_ELF_COMPRESS is set.
(assign_file_positions_except_relocs): Likwise.
(_bfd_elf_assign_file_positions_for_relocs): Renamed to ...
(_bfd_elf_assign_file_positions_for_non_load): This.  Change
return time to bfd_boolean.  Compress the section if
SEC_ELF_COMPRESS is set.
(_bfd_elf_write_object_contents): Updated.
(_bfd_elf_set_section_contents): Write section contents to
the buffer if SEC_ELF_COMPRESS is set.
* merge.c: Include "elf-bfd.h".
(sec_merge_emit): Add arguments for contents and offset.  Write
to contents with offset if contents isn't NULL.
(_bfd_write_merged_section): Write section contents to the
buffer if SEC_ELF_COMPRESS is set.  Pass contents and
output_offset to sec_merge_emit.
* elflink.c (bfd_elf_final_link): Allocate the buffer for
output section contents if SEC_ELF_COMPRESS is set.
* section.c (SEC_ELF_COMPRESS): New.
* bfd-in2.h: Regenerated.

gas/

* as.h (compressed_debug_section_type): Removed.

include/

* bfdlink.h (bfd_link_info): Add compress_debug.

ld/

* ld.texinfo: Document --compress-debug-sections=.
* ldmain.c (main): Set BFD_COMPRESS on output_bfd if
COMPRESS_DEBUG is set.  Set BFD_COMPRESS_GABI on output_bfd
for COMPRESS_DEBUG_GABI_ZLIB.
* lexsup.c (elf_static_list_options): Add
--compress-debug-sections=.
* emultempl/elf32.em (OPTION_COMPRESS_DEBUG): New.
(xtra_long): Add "compress-debug-sections".
(gld${EMULATION_NAME}_handle_option): Handle
OPTION_COMPRESS_DEBUG.

ld/testsuite/

* ld-elf/compress.exp (build_tests): Add tests for
--compress-debug-sections=.
(run_tests): Likewise.
Add additonal tests for --compress-debug-sections=.
* ld-elf/gabiend.rt: New file.
* ld-elf/gabinormal.rt: Likewise.
* ld-elf/gnubegin.rS: Likewise.
* ld-elf/gnunormal.rS: Likewise.
* ld-elf/zlibbegin.rS: Likewise.
* ld-elf/zlibnormal.rS: Likewise.

9 years agoxfail pr18223 test for tic6x
Alan Modra [Wed, 15 Apr 2015 02:29:10 +0000 (11:59 +0930)]
xfail pr18223 test for tic6x

Fails due to
warning: generating a shared library containing non-PIC/PID code

* ld-gc/pr18223.d: xfail tic6x.

9 years agoFix typo in last ChangeLog.
Hans-Peter Nilsson [Wed, 15 Apr 2015 02:11:18 +0000 (04:11 +0200)]
Fix typo in last ChangeLog.

9 years agoAdjust src-release.sh for sim using the gdb create-version.sh.
Hans-Peter Nilsson [Wed, 15 Apr 2015 02:08:21 +0000 (04:08 +0200)]
Adjust src-release.sh for sim using the gdb create-version.sh.

* sim-release.sh (tar_compress): If there's a fifth parameter,
use that in the getver call instead of $tool.
(sim_release): Pass gdb as fifth parameter to tar_compress.
(SIM_SUPPORT_DIRS): Add gdb/common/create-version.sh.

9 years agoFix typo in commit 6ff71e76
Alan Modra [Wed, 15 Apr 2015 01:54:30 +0000 (11:24 +0930)]
Fix typo in commit 6ff71e76

* elf32-rl78.c (rl78_elf_relocate_section): Typo fix.

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

9 years agoAdds support to the RL78 port for linker relaxation affecting .debug sections.
Nick Clifton [Tue, 14 Apr 2015 15:23:33 +0000 (16:23 +0100)]
Adds support to the RL78 port for linker relaxation affecting .debug sections.

gas * config/tc-rl78.h (TC_LINKRELAX_FIXUP): Define.
(TC_FORCE_RELOCATION_SUB_SAME): Define.
(DWARF2_USE_FIXED_ADVANCE_PC): Define.

* gas/lns/lns.exp: Add RL78 to list of targets using
DW_LNS_fixed_advance_pc.

bfd * elf32-rl78.c (RL78_OP_REL): New macro.
(rl78_elf_howto_table): Use it for complex relocs.
(get_symbol_value): Handle the cases when the info or status
arguments are NULL.
(get_romstart): Cache the status returned by get_symbol_value.
(get_ramstart): Likewise.
(RL78_STACK_PUSH): Generate an error message if the stack
overflows.
(RL78_STACK_POP): Likewise for underflows.
(rl78_compute_complex_reloc): New function.  Contains the basic
processing code for all RL78 complex relocs.
(rl78_special_reloc): New function.  Provides special reloc
handling for complex relocs.
(rl78_elf_relocate_section): Use rl78_compute_complex_reloc.
(rl78_offset_for_reloc): Likewise.

binutils* readelf.c (target_specific_reloc_handling): Add code to handle
RL78 complex relocs.

9 years agoHarden gdb.base/bp-permanent.exp
Luis Machado [Tue, 14 Apr 2015 12:22:53 +0000 (09:22 -0300)]
Harden gdb.base/bp-permanent.exp

Reinstate test message and replace hardcoded test command with a variable.

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

* gdb.base/bp-permanent.exp (test): Reinstate correct test message.

9 years agoZero supplied stat buffers in functions that pretend to stat
Gary Benson [Tue, 14 Apr 2015 11:35:30 +0000 (12:35 +0100)]
Zero supplied stat buffers in functions that pretend to stat

GDB has five places where it pretends to stat for bfd_openr_iovec.
Four of these only set the incoming buffer's st_size, leaving the
other fields unchanged, which is to say very likely populated with
random values from the stack.  remote_bfd_iovec_stat was fixed in
0a93529c56714b1da3d7106d3e0300764f8bb81c; this commit fixes the
other four.

gdb/ChangeLog:

* jit.c (mem_bfd_iovec_stat): Zero supplied buffer.
* minidebug.c (lzma_stat): Likewise.
* solib-spu.c (spu_bfd_iovec_stat): Likewise.
* spu-linux-nat.c (spu_bfd_iovec_stat): Likewise.

9 years agoAdd -z noextern-protected-data to ld for ELF/x86
H.J. Lu [Tue, 14 Apr 2015 11:12:55 +0000 (04:12 -0700)]
Add -z noextern-protected-data to ld for ELF/x86

Address of protected data defined in the shared library may be external,
i.e., due to copy relocation.  By default, linker backend checks if
relocations against protected data symbols are valid for building shared
library and issues an error if relocation isn't allowed.  The new option
override linker backend default.  When -z noextern-protected-data is used,
updates on protected data symbols by another module won't be visibile
to the resulting shared library.  This option is specific to ELF/i386
and ELF/x86-64.

bfd/

PR ld/pr17709
* elflink.c (_bfd_elf_adjust_dynamic_copy): Check
info->extern_protected_data when warning copy relocs against
protected symbols.
(_bfd_elf_symbol_refs_local_p): Check info->extern_protected_data
when checking protected non-function symbols.

include/

PR ld/pr17709
* bfdlink.h (bfd_link_info): Add extern_protected_data.

ld/

PR ld/pr17709
* ld.texinfo: Document "-z noextern-protected-data".
* ldmain.c (main): Initialize link_info.extern_protected_data
to -1.
* lexsup.c (elf_shlib_list_options): Add
"-z [no]extern-protected-data".
* emulparams/elf32_x86_64.sh: Source extern_protected_data.sh.
* emulparams/elf_i386.sh: Likewise.
* emulparams/elf_i386_be.sh: Likewise.
* emulparams/elf_i386_chaos.sh: Likewise.
* emulparams/elf_i386_ldso.sh: Likewise.
* emulparams/elf_i386_vxworks.sh: Likewise.
* emulparams/elf_k1om.sh: Likewise.
* emulparams/elf_l1om.sh: Likewise.
* emulparams/elf_x86_64.sh: Source extern_protected_data.sh.
(PARSE_AND_LIST_OPTIONS): Renamed to ...
(PARSE_AND_LIST_OPTIONS_BNDPLT): This.
(PARSE_AND_LIST_ARGS_CASE_Z): Renamed to ...
(PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT): This.
(PARSE_AND_LIST_OPTIONS): Append $PARSE_AND_LIST_OPTIONS_BNDPLT.
(PARSE_AND_LIST_ARGS_CASE_Z): Append
$PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT.
* emulparams/extern_protected_data.sh: New file.

ld/testsuite/

PR ld/pr17709
* ld-i386/i386.exp: Run protected6b.
* ld-i386/protected6b.d: New file.
* ld-x86-64/protected6b.d: Likewise.
* ld-x86-64/x86-64.exp:  Run protected6b.

9 years agosim: ppc: fix up version script
Mike Frysinger [Tue, 14 Apr 2015 03:16:46 +0000 (23:16 -0400)]
sim: ppc: fix up version script

The common sim code has switched to using gdb directly; update the
ppc copy too.

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

9 years ago * MAINTAINERS: Update my email address.
Stan Shebs [Fri, 10 Apr 2015 18:06:52 +0000 (11:06 -0700)]
    * MAINTAINERS: Update my email address.

diff --git a/gdb/MAINTAINERS b/gdb/MAINTAINERS
index a67a1a8..0fdd8e5 100644
--- a/gdb/MAINTAINERS
+++ b/gdb/MAINTAINERS
@@ -156,7 +156,7 @@ Doug Evans                  dje@google.com
 Daniel Jacobowitz              drow@false.org
 Mark Kettenis                  kettenis@gnu.org
 Yao Qi                         yao.qi@arm.com
-Stan Shebs                     stan@codesourcery.com
+Stan Shebs                     stanshebs@google.com
 Ulrich Weigand                 Ulrich.Weigand@de.ibm.com
 Elena Zannoni                  elena.zannoni@oracle.com
 Eli Zaretskii                  eliz@gnu.org
@@ -631,7 +631,7 @@ Keith Seitz                                 keiths@redhat.com
 Carlos Eduardo Seo                             cseo@linux.vnet.ibm.com
 Ozkan Sezer                                    sezeroz@gmail.com
 Marcus Shawcroft                               marcus.shawcroft@arm.com
-Stan Shebs                                     stan@codesourcery.com
+Stan Shebs                                     stanshebs@google.com
 Joel Sherrill                                  joel.sherrill@oarcorp.com
 Mark Shinwell                                  shinwell@codesourcery.com
 Craig Silverstein                              csilvers@google.com

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.