Joel Brobecker [Wed, 13 May 2015 17:48:31 +0000 (10:48 -0700)]
Document the GDB 7.9.1 release in gdb/ChangeLog
gdb/ChangeLog:
GDB 7.9.1 released.
Joel Brobecker [Wed, 13 May 2015 17:31:00 +0000 (10:31 -0700)]
gdb/NEWS: Move "Xmethods can now specify a result type" to GDB 7.9.1 section.
As this change was ported to GDB 7.9.1, the NEWS entry is moved to
a newly-created "Changes in GDB 7.9.1" section, matching the NEWS
file which is going to be distributed with the GDB 7.9.1 release.
gdb/ChangeLog:
* NEWS: Create "Changes in GDB 7.9.1" section. Move news about
Xmethods now being able to specify a result type to that new
section.
John David Anglin [Wed, 13 May 2015 16:32:01 +0000 (17:32 +0100)]
Disable the configuration of GDB for HPUX targets.
* configure.ac: Disable configuration of GDB for HPUX targets.
* configure: Regenerate.
Max Filippov [Sat, 9 May 2015 22:02:31 +0000 (01:02 +0300)]
xtensa: fix gas trampolines regression
Extra condition 'abs (addr - trampaddr) < J_RANGE / 2' for trampoline
selection results in regressions: when relaxable jump is little longer
than J_RANGE so that single trampoline makes two new jumps, one longer
than J_RANGE / 2 and one shorter, correct trampoline cannot be found.
Drop that condition.
2015-05-13 Max Filippov <jcmvbkbc@gmail.com>
gas/
* config/tc-xtensa.c (xtensa_relax_frag): Allow trampoline to be
closer than J_RANGE / 2 to jump frag.
gas/testsuite/
* gas/xtensa/trampoline.s: Add regression testcase.
Patrick Palka [Wed, 13 May 2015 15:57:06 +0000 (11:57 -0400)]
Add missing ChangeLog entry for previous commit
Patrick Palka [Tue, 28 Apr 2015 01:37:48 +0000 (21:37 -0400)]
Avoid race condition when handling a SIGWINCH signal
The control variable win_resized must be cleared before responding to
it.
Otherwise there is a small window where another SIGWINCH might occur in
between the handling of an earlier SIGWINCH and the clearing of
win_resized, at which point win_resized would be set (again) by the
signal handler. Shortly thereafter we would clear win_resized even
though we only handled the earlier SIGWINCH but not the latest one.
This chain of events is all avoided if we clear win_resized first.
gdb/ChangeLog:
* tui/tui-win.c (tui_async_resize_screen): Clear win_resized
first before resizing the window.
* tui.c (tui_enable): Likewise.
Jan Kratochvil [Wed, 13 May 2015 13:55:09 +0000 (15:55 +0200)]
dummy_frame_dtor_ftype vs. call_function_by_hand_dummy_dtor_ftype cleanup
Both dummy_frame_dtor_ftype and call_function_by_hand_dummy_dtor_ftype
represent the same type, there was some mistake/duplication during check-in.
gdb/ChangeLog
2015-05-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* dummy-frame.c (struct dummy_frame): Use proper typedef for dtor.
* dummy-frame.h (dummy_frame_dtor_ftype): Add its comment.
* infcall.c (call_function_by_hand_dummy): Use proper typedef for
dummy_dtor parameter.
* infcall.h: Include dummy-frame.h.
(call_function_by_hand_dummy_dtor_ftype): Remove.
(call_function_by_hand_dummy): Use proper typedef for dummy_dtor
parameter.
Patrick Palka [Sun, 26 Apr 2015 18:13:59 +0000 (14:13 -0400)]
Fix PR gdb/17820
This patch is a comprehensive fix for PR 17820 which reports that
using "set history size unlimited" inside one's gdbinit file doesn't
really work.
There are three small changes in this patch. The most important change
this patch makes is to decode the argument of the "size" subcommand
using add_setshow_zuinteger_unlimited_cmd() instead of using
add_setshow_uinteger_cmd(). The new decoder takes an int * and maps
unlimited to -1 whereas the old decoder takes an unsigned int * and maps
unlimited to UINT_MAX. Using the new decoder simplifies our handling of
unlimited and makes it easier to interface with readline which itself
expects a signed-int history size.
The second change is the factoring of the [stifle|unstifle]_history logic
into a common function which is now used by both init_history() and
set_history_size_command(). This is technically the change that fixes
the PR itself.
Thirdly, this patch initializes history_size_setshow_var to -2 to mean
that the variable has not been set yet. Now init_history() tests for -2
instead of 0 to determine whether to give the variable a default value.
This means that having "set history size 0" in one's gdbinit file will
actually keep the history size at 0 and not reset it to 256.
gdb/ChangeLog:
PR gdb/17820
* top.c (history_size_setshow_var): Change type to signed.
Initialize to -2. Update documentation.
(set_readline_history_size): Define.
(set_history_size_command): Use it. Remove logic for handling
out-of-range sizes.
(init_history): Use set_readline_history_size(). Test for a
value of -2 instead of 0 when determining whether to set a
default history size.
(init_main): Decode the argument of the "size" command as a
zuinteger_unlimited.
gdb/testsuite/ChangeLog:
PR gdb/17820
* gdb.base/gdbinit-history.exp: New test.
* gdb.base/gdbinit-history/unlimited/.gdbinit: New file.
* gdb.base/gdbinit-history/zero/.gdbinit: New file.
H.J. Lu [Wed, 13 May 2015 11:47:59 +0000 (04:47 -0700)]
Revert "Add -mno-shared to x86 assembler"
This reverts commit
573cc2e57db66165b390044338d3a4ad51f36bf8.
H.J. Lu [Wed, 13 May 2015 11:33:45 +0000 (04:33 -0700)]
Add missing ChangeLog entries for PR binutis/18386
H.J. Lu [Wed, 13 May 2015 10:57:46 +0000 (03:57 -0700)]
Return ELF_CLASS_BOTH by default
* elfedit.c (elf_class): Return ELF_CLASS_BOTH by default.
Andreas Krebbel [Wed, 13 May 2015 06:19:45 +0000 (08:19 +0200)]
MAINTAINERS: Add myself as s390 and s390x maintainer.
binutils/
* MAINTAINERS: Add myself as s390 and s390x maintainer.
GDB Administrator [Wed, 13 May 2015 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Tue, 12 May 2015 20:11:48 +0000 (13:11 -0700)]
Allocate the first .plt entry space only if needed
Commit
dd7e64d45b317128f5fe813a8da0b13b4ad046ae may optimize out
i386/x86-64 JUMP_SLOT relocation. If there is no JUMP_SLOT relocation
left, we don't need to the first .plt entry. This patch allocates
space for the first .plt entry only if we also reserve space for a PLT
slot for JUMP_SLOT relocation.
bfd/
* elf32-i386.c (elf_i386_allocate_dynrelocs): Allocate space
for the first .plt entry only if needed.
* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Likewise.
ld/testsuite/
* ld-i386/i386.exp: Run pltgot-1 for Linux targets.
* ld-x86-64/x86-64.exp: Likewise.
* ld-i386/pltgot-1.d: New file.
* ld-i386/pltgot-1.s: Likewise.
* ld-x86-64/pltgot-1.d: Likewise.
* ld-x86-64/pltgot-1.s: Likewise.
H.J. Lu [Tue, 12 May 2015 19:47:27 +0000 (12:47 -0700)]
Also skip x86_64-*-nacl*
* binutils-all/elfedit-1.d: Also skip x86_64-*-nacl*.
Doug Evans [Tue, 12 May 2015 17:42:49 +0000 (10:42 -0700)]
tweak some comments
gdb/ChangeLog:
* dwarf2read.c (struct file_entry): Tweak comments.
(get_debug_line_section): Tweak comments.
Don Breazeal [Tue, 12 May 2015 16:52:47 +0000 (09:52 -0700)]
Extended-remote fork event docs
This patch contains the accumulated documentation changes for the
rest of the extended-remote follow fork patchset.
gdb/ChangeLog:
* NEWS: Announce fork support in the RSP and support
for fork debugging in extended mode.
gdb/doc/ChangeLog:
* gdb.texinfo (Forks): Note that fork debugging is
supported in extended mode.
(Remote Configuration): Add fork event features to table
of packet settings.
(Stop Reply Packets): Add fork events to list of stop reasons.
(General Query Packets): Add fork events to tables of
'gdbfeatures' and 'stub features' supported in the qSupported
packet, as well as to the list containing stub feature
details.
Don Breazeal [Tue, 12 May 2015 16:52:46 +0000 (09:52 -0700)]
Extended-remote fork catch
This patch implements catchpoints for fork events on extended-remote
Linux targets.
Implementation appeared to be straightforward, requiring four new functions
in remote.c to implement insert/remove of fork/vfork catchpoints. These
functions are essentially stubs that just return 0 ('success') if the
required features are enabled. If the fork events are being reported, then
catchpoints are set and hit.
However, there are some extra issues that arise with catchpoints.
1) Thread creation reporting -- fork catchpoints are hit before the
follow_fork has been completed. When stopped at a fork catchpoint
in the native implementation, the new process is not 'reported'
until after the follow is done. It doesn't show up in the inferiors
list or the threads list. However, in the gdbserver case, an
'info threads' while stopped at a fork catchpoint will retrieve the
new thread info from the target and add it to GDB's data structures,
prior to the follow operations. Because of this premature report,
things on the GDB side eventually get very confused.
So in remote.c:remote_update_thread_list, we check to see if there
are any pending fork parent threads. If there are we remove the
related fork child thread from the thread list sent by the target.
2) Kill process before fork is followed -- on the native side in
linux-nat.c:linux_nat_kill, there is some code to handle the case where
a fork has occurred but follow_fork hasn't been called yet. It does
this by using the last status to determine if a follow is pending, and
if it is, to kill the child task. The use of last_status is fragile
in situations like non-stop mode where other events may have occurred
after the fork event. This patch identifies a fork parent
in remote.c:extended_remote_kill in a way similar to that used in
thread creation reporting above. If one is found, it kills the new
child as well.
Tested on x64 Ubuntu Lucid, native, remote, extended-remote. Tested the
case of killing the forking process before the fork has been followed
manually.
gdb/ChangeLog:
* remote.c (remote_insert_fork_catchpoint): New function.
(remote_remove_fork_catchpoint): New function.
(remote_insert_vfork_catchpoint): New function.
(remote_remove_vfork_catchpoint): New function.
(pending_fork_parent_callback): New function.
(remove_new_fork_child): New function.
(remote_update_thread_list): Call remote_notif_get_pending_events
and remove_new_fork_child.
(extended_remote_kill): Kill fork child when killing the
parent before follow_fork completes.
(init_extended_remote_ops): Initialize target vector with
new fork catchpoint functions.
Don Breazeal [Tue, 12 May 2015 16:52:45 +0000 (09:52 -0700)]
Extended-remote follow vfork
This patch implements follow-fork for vfork on extended-remote Linux targets.
The implementation follows the native implementation as much as possible.
Most of the work is done on the GDB side in the existing code now in
infrun.c. GDBserver just has to report the events and do a little
bookkeeping.
Implementation includes:
* enabling VFORK events by adding ptrace options for VFORK and VFORK_DONE
to linux-low.c:linux_low_ptrace_options.
* handling VFORK and VFORK_DONE events in linux-low.c:handle_extended_wait
and reporting them to GDB.
* including VFORK and VFORK_DONE events in the predicate
linux-low.c:extended_event_reported.
* adding support for VFORK and VFORK_DONE events in RSP by adding stop
reasons "vfork" and "vforkdone" to the 'T' Stop Reply Packet in both
gdbserver/remote-utils.c and gdb/remote.c.
Tested on x64 Ubuntu Lucid, native, remote, extended-remote.
gdb/gdbserver/ChangeLog:
* linux-low.c (handle_extended_wait): Handle PTRACE_EVENT_FORK and
PTRACE_EVENT_VFORK_DONE.
(linux_low_ptrace_options, extended_event_reported): Add vfork
events.
* remote-utils.c (prepare_resume_reply): New stop reasons "vfork"
and "vforkdone" for RSP 'T' Stop Reply Packet.
* server.h (report_vfork_events): Declare
global variable.
gdb/ChangeLog:
* remote.c (remove_vfork_event_p): New function.
(remote_follow_fork): Add vfork event type to event checking.
(remote_parse_stop_reply): New stop reasons "vfork" and
"vforkdone" for RSP 'T' Stop Reply Packet.
Don Breazeal [Tue, 12 May 2015 16:52:44 +0000 (09:52 -0700)]
Arch-specific remote follow fork
This patch implements the architecture-specific pieces of follow-fork
for remote and extended-remote Linux targets, which in the current
implementation copyies the parent's debug register state into the new
child's data structures. This is required for x86, arm, aarch64, and
mips.
This follows the native implementation as closely as possible by
implementing a new linux_target_ops function 'new_fork', which is
analogous to 'linux_nat_new_fork' in linux-nat.c. In gdbserver, the debug
registers are stored in the process list, instead of an
architecture-specific list, so the function arguments are process_info
pointers instead of an lwp_info and a pid as in the native implementation.
In the MIPS implementation the debug register mirror is stored differently
from x86, ARM, and aarch64, so instead of doing a simple structure assignment
I had to clone the list of watchpoint structures.
Tested using gdb.threads/watchpoint-fork.exp on x86, and ran manual tests
on a MIPS board and an ARM board. Aarch64 hasn't been tested.
gdb/gdbserver/ChangeLog:
* linux-aarch64-low.c (aarch64_linux_new_fork): New function.
(the_low_target) <new_fork>: Initialize new member.
* linux-arm-low.c (arm_new_fork): New function.
(the_low_target) <new_fork>: Initialize new member.
* linux-low.c (handle_extended_wait): Call new target function
new_fork.
* linux-low.h (struct linux_target_ops) <new_fork>: New member.
* linux-mips-low.c (mips_add_watchpoint): New function
extracted from mips_insert_point.
(the_low_target) <new_fork>: Initialize new member.
(mips_linux_new_fork): New function.
(mips_insert_point): Call mips_add_watchpoint.
* linux-x86-low.c (x86_linux_new_fork): New function.
(the_low_target) <new_fork>: Initialize new member.
Don Breazeal [Tue, 12 May 2015 16:52:43 +0000 (09:52 -0700)]
Extended-remote Linux follow fork
This patch implements basic support for follow-fork and detach-on-fork on
extended-remote Linux targets. Only 'fork' is supported in this patch;
'vfork' support is added n a subsequent patch. This patch depends on
the previous patches in the patch series.
Sufficient extended-remote functionality has been implemented here to pass
gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the
catchpoint tests commented out. Some other fork tests fail with this
patch because it doesn't provide the architecture support needed for
watchpoint inheritance or fork catchpoints.
The implementation follows the same general structure as for the native
implementation as much as possible.
This implementation includes:
* enabling fork events in linux-low.c in initialize_low and
linux_enable_extended_features
* handling fork events in gdbserver/linux-low.c:handle_extended_wait
- when a fork event occurs in gdbserver, we must do the full creation
of the new process, thread, lwp, and breakpoint lists. This is
required whether or not the new child is destined to be
detached-on-fork, because GDB will make target calls that require all
the structures. In particular we need the breakpoint lists in order
to remove the breakpoints from a detaching child. If we are not
detaching the child we will need all these structures anyway.
- as part of this event handling we store the target_waitstatus in a new
member of the parent lwp_info structure, 'waitstatus'. This
is used to store extended event information for reporting to GDB.
- handle_extended_wait is given a return value, denoting whether the
handled event should be reported to GDB. Previously it had only
handled clone events, which were never reported.
* using a new predicate in gdbserver to control handling of the fork event
(and eventually all extended events) in linux_wait_1. The predicate,
extended_event_reported, checks a target_waitstatus.kind for an
extended ptrace event.
* implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in
gdbserver/remote-utils.c and remote.c.
* implementing new target and RSP support for target_follow_fork with
target extended-remote. (The RSP components were actually defined in
patch 1, but they see their first use here).
- remote target routine remote_follow_fork, which just sends the 'D;pid'
detach packet to detach the new fork child cleanly. We can't just
call target_detach because the data structures for the forked child
have not been allocated on the host side.
Tested on x64 Ubuntu Lucid, native, remote, extended-remote.
gdb/gdbserver/ChangeLog:
* linux-low.c (handle_extended_wait): Implement return value,
rename argument 'event_child' to 'event_lwp', handle
PTRACE_EVENT_FORK, call internal_error for unrecognized event.
(linux_low_ptrace_options): New function.
(linux_low_filter_event): Call linux_low_ptrace_options,
use different argument fo linux_enable_event_reporting,
use return value from handle_extended_wait.
(extended_event_reported): New function.
(linux_wait_1): Call extended_event_reported and set
status to report fork events.
(linux_write_memory): Add pid to debug message.
(reset_lwp_ptrace_options_callback): New function.
(linux_handle_new_gdb_connection): New function.
(linux_target_ops): Initialize new structure member.
* linux-low.h (struct lwp_info) <waitstatus>: New member.
* lynx-low.c: Initialize new structure member.
* remote-utils.c (prepare_resume_reply): Implement stop reason
"fork" for "T" stop message.
* server.c (handle_query): Call handle_new_gdb_connection.
* server.h (report_fork_events): Declare global flag.
* target.h (struct target_ops) <handle_new_gdb_connection>:
New member.
(target_handle_new_gdb_connection): New macro.
* win32-low.c: Initialize new structure member.
gdb/ChangeLog:
* linux-nat.c (linux_nat_ptrace_options): New function.
(linux_init_ptrace, wait_lwp, linux_nat_filter_event):
Call linux_nat_ptrace_options and use different argument to
linux_enable_event_reporting.
(_initialize_linux_nat): Delete call to
linux_ptrace_set_additional_flags.
* nat/linux-ptrace.c (current_ptrace_options): Rename to
supported_ptrace_options.
(additional_flags): Delete variable.
(linux_check_ptrace_features): Use supported_ptrace_options.
(linux_test_for_tracesysgood, linux_test_for_tracefork):
Likewise, and remove additional_flags check.
(linux_enable_event_reporting): Change 'attached' argument to
'options'. Use supported_ptrace_options.
(ptrace_supports_feature): Change comment. Use
supported_ptrace_options.
(linux_ptrace_set_additional_flags): Delete function.
* nat/linux-ptrace.h (linux_ptrace_set_additional_flags):
Delete function prototype.
* remote.c (remote_fork_event_p): New function.
(remote_detach_pid): New function.
(remote_detach_1): Call remote_detach_pid, don't mourn inferior
if doing detach-on-fork.
(remote_follow_fork): New function.
(remote_parse_stop_reply): Handle new "T" stop reason "fork".
(remote_pid_to_str): Print "process" strings for pid/0/0 ptids.
(init_extended_remote_ops): Initialize to_follow_fork.
Don Breazeal [Tue, 12 May 2015 16:52:42 +0000 (09:52 -0700)]
Clone remote breakpoints
This patch implements gdbserver routines to clone the breakpoint lists of a
process, duplicating them for another process. In gdbserver, each process
maintains its own independent breakpoint list. When a fork call creates a
child, all of the breakpoints currently inserted in the parent process are
also inserted in the child process, but there is nothing to describe them
in the data structures related to the child. The child must have a
breakpoint list describing them so that they can be removed (if detaching)
or recognized (if following). Implementation is a mechanical process of
just cloning the lists in several new functions in gdbserver/mem-break.c.
Tested by building, since none of the new functions are called yet. This
was tested with another patch in the series that implements follow-fork.
gdb/gdbserver/ChangeLog:
* mem-break.c (APPEND_TO_LIST): Define macro.
(clone_agent_expr): New function.
(clone_one_breakpoint): New function.
(clone_all_breakpoints): New function.
* mem-break.h: Declare new functions.
Don Breazeal [Tue, 12 May 2015 16:52:41 +0000 (09:52 -0700)]
Identify remote fork event support
This patch implements a mechanism for GDB to determine whether fork
events are supported in gdbserver. This is a preparatory patch for
remote fork and exec event support.
Two new RSP packets are defined to represent fork and vfork event
support. These packets are used just like PACKET_multiprocess_feature
to denote whether the corresponding event is supported. GDB sends
fork-events+ and vfork-events+ to gdbserver to inquire about fork
event support. If the response enables these packets, then GDB
knows that gdbserver supports the corresponding events and will
enable them.
Target functions used to query for support are included along with
each new packet.
In order for gdbserver to know whether the events are supported at the
point where the qSupported packet arrives, the code in nat/linux-ptrace.c
had to be reorganized. Previously it would test for fork/exec event
support, then enable the events using the pid of the inferior. When the
qSupported packet arrives there may not be an inferior. So the mechanism
was split into two parts: a function that checks whether the events are
supported, called when gdbserver starts up, and another that enables the
events when the inferior stops for the first time.
Another gdbserver change was to add some global variables similar to
multi_process, one per new packet. These are used to control whether
the corresponding fork events are enabled. If GDB does not inquire
about the event support in the qSupported packet, then gdbserver will
not set these "report the event" flags. If the flags are not set, the
events are ignored like they were in the past. Thus, gdbserver will
never send fork event notification to an older GDB that doesn't
recognize fork events.
Tested on Ubuntu x64, native/remote/extended-remote, and as part of
subsequent patches in the series.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_supports_fork_events): New function.
(linux_supports_vfork_events): New function.
(linux_target_ops): Initialize new structure members.
(initialize_low): Call linux_check_ptrace_features.
* lynx-low.c (lynx_target_ops): Initialize new structure
members.
* server.c (report_fork_events, report_vfork_events):
New global flags.
(handle_query): Add new features to qSupported packet and
response.
(captured_main): Initialize new global variables.
* target.h (struct target_ops) <supports_fork_events>:
New member.
<supports_vfork_events>: New member.
(target_supports_fork_events): New macro.
(target_supports_vfork_events): New macro.
* win32-low.c (win32_target_ops): Initialize new structure
members.
gdb/ChangeLog:
* nat/linux-ptrace.c (linux_check_ptrace_features): Change
from static to extern.
* nat/linux-ptrace.h (linux_check_ptrace_features): Declare.
* remote.c (anonymous enum): <PACKET_fork_event_feature,
* PACKET_vfork_event_feature>: New enumeration constants.
(remote_protocol_features): Add table entries for new packets.
(remote_query_supported): Add new feature queries to qSupported
packet.
(_initialize_remote): Exempt new packets from the requirement
to have 'set remote' commands.
Jiong Wang [Tue, 12 May 2015 12:47:15 +0000 (13:47 +0100)]
[AArch64] Add R_AARCH64_P32_LD32_GOTPAGE_LO14 to elf header
2015-05-12 Jiong. Wang <jiong.wang@arm.com>
include/
* elf/aarch64.h (R_AARCH64_P32_LD32_GOTPAGE_LO14): New enumeration.
Gary Benson [Tue, 12 May 2015 10:57:52 +0000 (11:57 +0100)]
Locate executables on remote stubs without multiprocess extensions
This commit allows GDB to determine filenames of main executables
when debugging using remote stubs without multiprocess extensions.
The qXfer:exec-file:read packet is extended to allow an empty
annex, with the meaning that the remote stub should supply the
filename of whatever it thinks is the current process.
gdb/ChangeLog:
* remote.c (remote_add_inferior): Call exec_file_locate_attach
for fake PIDs as well as real ones.
(remote_pid_to_exec_file): Send empty annex if PID is fake.
gdb/doc/ChangeLog:
* gdb.texinfo (General Query Packets): Document
qXfer:exec-file:read with empty annex.
gdb/gdbserver/ChangeLog:
* server.c (handle_qxfer_exec_file): Use current process
if annex is empty.
Stephen Kitt [Tue, 12 May 2015 10:16:03 +0000 (11:16 +0100)]
Enables the -t abbreviated form of the --temp-prefix command line option for dlltool.
* dlltool.c (main): Accept -t as an abbreviation for
--temp-prefix.
GDB Administrator [Tue, 12 May 2015 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Mon, 11 May 2015 21:20:37 +0000 (14:20 -0700)]
Remove Disp16|Disp32 from 64-bit direct branches
Disp16 and Disp32 aren't supported by direct branches in 64-bit mode.
This patch removes them from 64-bit direct branches.
* opcodes/i386-opc.tbl (call): Remove Disp16|Disp32 from 64-bit
direct branch.
(jmp): Likewise.
* i386-tbl.h: Regenerated.
H.J. Lu [Mon, 11 May 2015 19:29:27 +0000 (12:29 -0700)]
Allow mixing target and not-target directives
Mixing target and not-target directives can be used to run for x86_64-*-*
target while skipping x86_64-*-gnux32 target. This patch allows mixing
target and not-target directives. It is used to skip elfedit-1 for
x86_64-*-gnux32.
* binutils-all/elfedit-1.d: Skip x86_64-*-gnux32.
* lib/utils-lib.exp (run_dump_test): Allow mixing target and
not-target directives.
H.J. Lu [Mon, 11 May 2015 19:01:57 +0000 (12:01 -0700)]
Default e_machine to EM_IAMCU for i?86-*-elfiamcu
This patch sets the default ELF output format of assembler and linker to
EM_IAMCU when binutils is configured to i?86-*-elfiamcu target.
gas/
* configure.tgt (arch): Set to iamcu for i386-*-elfiamcu target.
* config/tc-i386.c (i386_mach): Support iamcu.
(i386_target_format): Likewise.
ld/
* configure.tgt: Support i[3-7]86-*-elfiamcu target.
ld/testsuite/
* ld-i386/i386.exp (iamcu_tests): Run iamcu-4.
* ld-i386/iamcu-4.d: New file.
H.J. Lu [Mon, 11 May 2015 18:27:34 +0000 (11:27 -0700)]
Add Intel MCU support to ld
-m elf_iamcu must be passed to i386 linker to generate Intel MCU binary.
ld/
* Makefile.am (ALL_EMULATION_SOURCES): Add eelf_iamcu.c.
(eelf_iamcu.c): New.
* configure.tgt (targ_extra_emuls): Add elf_iamcu if elf_i386 is
enabled in BFD.
* Makefile.in: Regenerated.
* emulparams/elf_iamcu.sh: New file.
ld/testsuite/
* ld-i386/abs-iamcu.d: New file.
* ld-i386/dummy.s: Likewise.
* ld-i386/foo.s: Likewise.
* ld-i386/iamcu-1.d: Likewise.
* ld-i386/iamcu-2.d: Likewise.
* ld-i386/iamcu-3.d: Likewise.
* ld-i386/start.s: Likewise.
* ld-i386/i386.exp (iamcu_tests): New.
Run iamcu_tests.
H.J. Lu [Mon, 11 May 2015 18:11:19 +0000 (11:11 -0700)]
Add Intel MCU support to gas
-march=iamcu must be passed to i386 assembler to generate Intel MCU object
file.
gas/
* config/tc-i386.c (cpu_arch): Add iamcu.
(i386_align_code): Handle PROCESSOR_IAMCU.
(i386_arch): Likewise.
(i386_mach): Likewise.
(i386_target_format): Likewise.
(valid_iamcu_cpu_flags): New function.
(check_cpu_arch_compatible): Only allow Intel MCU instructions
when targeting Intel MCU.
(set_cpu_arch): Call valid_iamcu_cpu_flags to check if CPU flags
are valid for Intel MCU.
(md_parse_option): Likewise.
* tc-i386.h (ELF_TARGET_IAMCU_FORMAT): New.
(processor_type): Add PROCESSOR_IAMCU.
* doc/c-i386.texi: Document iamcu.
gas/testsuite/
* gas/i386/i386.exp: Run iamcu-1, iamcu-2, iamcu-3, iamcu-inval-1,
iamcu-inval-2 and iamcu-inval-3.
* gas/i386/iamcu-1.d: New file.
* gas/i386/iamcu-1.s: Likewise.
* gas/i386/iamcu-2.d: Likewise.
* gas/i386/iamcu-2.s: Likewise.
* gas/i386/iamcu-3.d: Likewise.
* gas/i386/iamcu-3.s: Likewise.
* gas/i386/iamcu-inval-1.l: Likewise.
* gas/i386/iamcu-inval-1.s: Likewise.
* gas/i386/iamcu-inval-2.l: Likewise.
* gas/i386/iamcu-inval-2.s: Likewise.
* gas/i386/iamcu-inval-3.l: Likewise.
* gas/i386/iamcu-inval-3.s: Likewise.
H.J. Lu [Mon, 11 May 2015 17:47:55 +0000 (10:47 -0700)]
Add Intel MCU support to opcodes
* configure.ac: Support bfd_iamcu_arch.
* disassemble.c (disassembler): Support bfd_iamcu_arch.
* i386-gen.c (cpu_flag_init): Add CPU_IAMCU_FLAGS and
CPU_IAMCU_COMPAT_FLAGS.
(cpu_flags): Add CpuIAMCU.
* i386-opc.h (CpuIAMCU): New.
(i386_cpu_flags): Add cpuiamcu.
* configure: Regenerated.
* i386-init.h: Likewise.
* i386-tbl.h: Likewise.
H.J. Lu [Mon, 11 May 2015 17:41:00 +0000 (10:41 -0700)]
Add init_dwarf_regnames_iamcu
* dwarf.c (dwarf_regnames_iamcu): New.
(init_dwarf_regnames_iamcu): Likewise.
(init_dwarf_regnames): Call init_dwarf_regnames_iamcu for EM_IAMCU.
* dwarf.h (init_dwarf_regnames_iamcu): New.
* objdump.c (dump_dwarf): Call init_dwarf_regnames_iamcu for
bfd_arch_iamcu.
H.J. Lu [Mon, 11 May 2015 17:30:32 +0000 (10:30 -0700)]
Add Intel MCU support to bfd
bfd/
* Makefile.am (ALL_MACHINES): Add cpu-iamcu.lo.
(ALL_MACHINES_CFILES): Likewise.
* archures.c (bfd_mach_iamcu): New.
(bfd_mach_i386_iamcu): Likewise.
(bfd_mach_i386_iamcu_intel_syntax): Likewise.
(bfd_iamcu_arch): Likewise.
(bfd_archures_list): Add &bfd_iamcu_arch.
* config.bfd (targ_selvecs): Add iamcu_elf32_vec to
i386_elf32_vec.
(targ_archs): Add bfd_iamcu_arch if needed.
* configure.ac: Support iamcu_elf32_vec.
* cpu-iamcu.c: New file.
* elf32-i386.c (elf32_iamcu_elf_object_p): New function.
Add support for iamcu_elf32_vec and elf32_iamcu_bed.
* targets.c (iamcu_elf32_vec): New.
(_bfd_target_vector): Add iamcu_elf32_vec.
* Makefile.in: Regenerated.
* bfd-in2.h: Likewise.
* configure: Likewise.
binutils/testsuite/
* binutils-all/objdump.exp (cpus_expected): Append iamcu.
H.J. Lu [Mon, 11 May 2015 16:57:20 +0000 (09:57 -0700)]
Add EM_386/EM_IAMCU support to elfedit.c
binutils/
* elfedit.c (enum elfclass): New.
(input_elf_class): Change type to enum elfclass.
(output_elf_class): New.
(elf_class): Change return type to enum elfclass. Support EM_386
and EM_IAMCU.
(update_elf_header): Check if input and output ELF classes match.
(elf_machine): Support EM_386 and EM_IAMCU.
(main): Update input_elf_class. Set output_elf_class.
* doc/binutils.texi: Update elfedit.
binutils/testsuite/
* binutils-all/elfedit-5.d: New file.
* binutils-all/elfedit.exp: Run elfedit-5.
H.J. Lu [Mon, 11 May 2015 15:52:43 +0000 (08:52 -0700)]
Rename EM_486 to EM_IAMCU
bfd/
* elfcode.h (elf_object_p): Replace EM_486 with EM_IAMCU.
binutils/
* dwarf.c (init_dwarf_regnames): Replace EM_486 with EM_IAMCU.
* readelf.c (guess_is_rela): Likewise.
(dump_relocations): Likewise.
(get_machine_name): Likewise.
(get_elf_section_flags): Likewise.
(process_section_headers): Likewise.
(is_32bit_abs_reloc): Likewise.
(is_32bit_pcrel_reloc): Likewise.
include/elf/
* common.h (EM_486): Renamed to ...
(EM_IAMCU): This.
GDB Administrator [Mon, 11 May 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sun, 10 May 2015 13:44:12 +0000 (06:44 -0700)]
Replace input_bfd and output_bfd with abfd
The first argument to bfd_get_8/bfd_put_8 isn't used. But we should
use something real. Replace input_bfd and output_bfd with abfd.
* elf32-i386.c (elf_i386_convert_mov_to_lea): Replace input_bfd
and output_bfd with abfd.
* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.
Siva Chandra [Sat, 25 Apr 2015 14:04:40 +0000 (07:04 -0700)]
[Python] Add methods reference_value and const_value to gdb.Value.
gdb/ChangeLog:
* NEWS (Python Scripting): Mention the new gdb.Value methods.
* python/py-value.c (valpy_reference_value): New function.
(valpy_const_value): Likewise.
(value_object_methods): Add new methods.
* value.c (make_cv_value): New function.
* value.h (make_cv_value): Declare.
gdb/doc/ChangeLog:
* python.texi (Values From Inferior): Add descriptions of new
methods gdb.Value.reference_value and gdb.Value.const_value.
gdb/testsuite/ChangeLog:
* gdb.python/py-xmethods.cc: Enhance test case.
* gdb.python/py-xmethods.exp: New tests.
* gdb.python/py-xmethods.py (A_indexoper): New xmethod worker
function.
(B_indexoper): Likewise.
(global_dm_list) : Add new xmethod worker functions.
GDB Administrator [Sun, 10 May 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sat, 9 May 2015 00:13:30 +0000 (17:13 -0700)]
Ignore 0x66 prefix for call/jmp/jcc in 64-bit mode
The operand size prefix (0x66) is ignored for 32-bit PC-relative call,
jmp and jcc in 64-bit mode.
gas/testsuite/
PR binutis/18386
* gas/i386/i386.exp: Run x86-64-jump.
* gas/i386/x86-64-branch.d: Updated.
* gas/i386/ilp32/x86-64-branch.d: Likewise.
* gas/i386/x86-64-branch.s: Add tests for the operand size prefix
with call, jmp and jb.
* gas/i386/x86-64-jump.d: New file.
* gas/i386/x86-64-jump.s: Likewise.
ld/testsuite/
PR binutis/18386
* ld-x86-64/tlsgdesc.dd: Updated.
* ld-x86-64/tlspic.dd: Likewise.
opcodes/
PR binutis/18386
* i386-dis.c (X86_64_E8): New.
(X86_64_E9): Likewise.
Update comments on 'T', 'U', 'V'. Add comments for '^'.
(dis386): Replace callT/jmpT with X86_64_E8/X86_64_E9.
(x86_64_table): Add X86_64_E8 and X86_64_E9.
(mod_table): Replace {T|} with ^ on Jcall/Jmp.
(putop): Handle '^'.
(OP_J): Ignore the operand size prefix in 64-bit. Don't check
REX_W.
GDB Administrator [Sat, 9 May 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
Sandra Loosemore [Fri, 8 May 2015 19:43:39 +0000 (12:43 -0700)]
Avoid segfault on missing directory table.
2015-05-08 Yao Qi <yao@codesourcery.com>
Sandra Loosemore <sandra@codesourcery.com>
gdb/
* dwarf2read.c (setup_type_unit_groups): Do NULL pointer check
to 'lh->include_dirs' before accessing to it.
(psymtab_include_file_name): Likewise.
(dwarf_decode_lines_1): Likewise.
(dwarf_decode_lines): Likewise.
(file_file_name): Likewise.
Sandra Loosemore [Fri, 8 May 2015 19:34:52 +0000 (12:34 -0700)]
Fix register save offset for nios2 signal handler trampolines.
2015-05-08 Sandra Loosemore <sandra@codesourcery.com>
gdb/
* nios2-linux-tdep.c (NIOS2_SIGRETURN_TRAMP_ADDR): Define.
(NIOS2_SIGRETURN_REGSAVE_OFFSET): Define.
(nios2_linux_rt_sigreturn_init): Adjust base address of
register save area.
Sandra Loosemore [Fri, 8 May 2015 19:32:43 +0000 (12:32 -0700)]
Use PTRACE_GETREGSET/SETREGSET in nios2 gdbserver.
2015-05-08 Sandra Loosemore <sandra@codesourcery.com>
gdb/gdbserver/
* linux-nios2-low.c: Include elf/common.h. Adjust comments.
Remove HAVE_PTRACE_GETREGS conditionals.
(nios2_regsets): Use PTRACE_GETREGSET and PTRACE_SETREGSET
instead of PTRACE_GETREGS and PTRACE_SETREGS.
Sandra Loosemore [Fri, 8 May 2015 19:24:41 +0000 (12:24 -0700)]
Revert to using "trap 31" for breakpoints on nios2.
2015-05-08 Sandra Loosemore <sandra@codesourcery.com>
gdb/
* nios2-tdep.c (nios2_breakpoint_from_pc): Revert to using
"trap 31" as the breakpoint instruction on all targets.
Sergio Durigan Junior [Fri, 8 May 2015 17:19:19 +0000 (13:19 -0400)]
Fix coredump-filter.exp by correctly unsetting array
In my last commit to make gdb.base/coredump-filter.exp be more robust
regarding using arrays in the global namespace, I cleared the
"coredump_var_addr" array like this:
set coredump_var_addr ""
# use coredump_var_addr as an array...
This causes DejaGNU to complain because the variable is first set as
non-array, and the used as an array. The correct way to do this is to
unset the variable using:
unset -nocomplain coredump_var_addr
# use coredump_var_addr as an array...
The "-nocomplain" part is necessary because if the variable doesn't
exist "unset" will not error.
Tested on Fedora 20 x86_64.
gdb/testsuite/ChangeLog:
2015-05-08 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/coredump-filter.exp: Correctly unset
"coredump_var_addr" array.
Joel Brobecker [Tue, 16 Sep 2014 18:32:09 +0000 (14:32 -0400)]
libiberty/mkstemps.c: Include <time.h> if <sys/time.h> not available.
Attempting to build libiberty on LynxOS-178 fails trying to compile
mkstemps.c with the following error:
mkstemps.c:84:18: error: storage size of 'tv' isn't known
struct timeval tv;
^
This file would normally include <sys/time.h> to get the type's
definition, but unfortunately LynxOS-178 does not want us to use
<sys/time.h>, only <time.h>. The configure script correctly finds
this out and generates a config.h file where HAVE_SYS_TIME_H is
undefined:
/* Define to 1 if you have the <sys/time.h> header file. */
/* #undef HAVE_SYS_TIME_H */
This patch fixes the build issue by falling back on including <time.h>
if <sys/time.h> could not be included (and provided that HAVE_TIME_H
is defined, of course).
libiberty/ChangeLog:
* mkstemps.c: #include <time.h> if HAVE_TIME_H is defined
but not HAVE_SYS_TIME_H.
Pedro Alves [Fri, 8 May 2015 17:06:46 +0000 (18:06 +0100)]
Fix sequential gdb test runs
Sequential test runs are stopping prematurely like this:
$ make check RUNTESTFLAGS="non-existing-program.exp server-exec-info.exp"
Running /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.server/non-existing-program.exp ...
Running /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.server/server-exec-info.exp ...
can not find channel named "exp6"
while executing
"match_max [match_max -d]"
(procedure "default_gdb_init" line 26)
invoked from within
"default_gdb_init $test_file_name"
(procedure "gdb_init" line 83)
invoked from within
"${tool}_init $test_file_name"
(procedure "runtest" line 18)
invoked from within
"runtest $test_name"
("foreach" body line 42)
invoked from within
...
make[2]: *** [check-single] Error 1
make[2]: Leaving directory `/home/pedro/gdb/mygit/build/gdb/testsuite'
make[1]: *** [check] Error 2
make[1]: Leaving directory `/home/pedro/gdb/mygit/build/gdb/testsuite'
make: *** [check] Error 2
default_gdb_init has this:
# Unlike most tests, we have a small number of tests that generate
# a very large amount of output. We therefore increase the expect
# buffer size to be able to contain the entire test output. This
# is especially needed by gdb.base/info-macros.exp.
match_max -d 65536
# Also set this value for the currently running GDB.
match_max [match_max -d]
It's the second match_max that is erroring. As that call does not
specify an explicit channel name with -i, expect defaults to
$spawn_id, which is pointing at a channel that is already gone. (If
the spawn_id variable is not set, match_max defaults to
$user_spawn_id / stdin/out).
gdb/testsuite/ChangeLog:
2015-05-08 Pedro Alves <palves@redhat.com>
* gdb.server/non-existing-program.exp: Unset spawn_id.
Nick Clifton [Fri, 8 May 2015 16:28:26 +0000 (17:28 +0100)]
Change ARM symbol name verification code so that it only triggers when the form "name = val" is used.
PR gas/18347
* config/tc-arm.h (TC_EQUAL_IN_INSN): Define.
* config/tc-arm.c (arm_tc_equal_in_insn): New function. Move
the symbol name checking code to here from...
(md_undefined_symbo): ... here.
Jan Kratochvil [Fri, 8 May 2015 15:58:21 +0000 (17:58 +0200)]
Remove unused declaration of print_return_value.
gdb/ChangeLog
2015-05-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* infcmd.c (print_return_value): Remove unused declaration.
Joel Brobecker [Fri, 20 Mar 2015 17:57:36 +0000 (13:57 -0400)]
Problem printing record with array whose upper bound is record component
Consider the following declarations...
type Obj_T (Selected_Flights_Length : Natural) is
record
Selected_Flights : Flights.List.T (1 .. Selected_Flights_Length);
end record;
Broken : Obj_T;
... which defines a variable named "broken" which is a discrimated
record where broken.Selected_Flights is an array whose upper bound
is stored in the record's Selected_Flights_Length component.
Trying to print the value of that object currently fails:
(gdb) print broken
cannot find reference address for offset property
Looking at the debugging info, we see that variable "Broken" is
a reference...
<1><8e3>: Abbrev Number: 21 (DW_TAG_const_type)
<8e4> DW_AT_type : <0x8e8>
<1><8e8>: Abbrev Number: 22 (DW_TAG_reference_type)
<8e9> DW_AT_byte_size : 8
<8ea> DW_AT_type : <0x7ec>
... to ...
<1><7ec>: Abbrev Number: 12 (DW_TAG_structure_type)
<7ed> DW_AT_name : (indirect string, offset: 0xc6d): reprod__obj_t
<7f1> DW_AT_decl_file : 2
<7f2> DW_AT_decl_line : 15
<7f3> DW_AT_GNAT_descriptive_type: <0x87e>
<7f7> DW_AT_sibling : <0x87e>
... which has 2 members, the first one being the discriminant...
<2><7fb>: Abbrev Number: 9 (DW_TAG_member)
<7fc> DW_AT_name : (indirect string, offset: 0xc98): selected_flights_length
<800> DW_AT_decl_file : 2
<801> DW_AT_decl_line : 15
<802> DW_AT_type : <0x807>
<806> DW_AT_data_member_location: 0
... and the second one being the one that causes trouble...
<2><83d>: Abbrev Number: 9 (DW_TAG_member)
<83e> DW_AT_name : (indirect string, offset: 0xd17): selected_flights
<842> DW_AT_decl_file : 2
<843> DW_AT_decl_line : 17
<844> DW_AT_type : <0x815>
<848> DW_AT_data_member_location: 4
The second field's type is an array....
<2><815>: Abbrev Number: 14 (DW_TAG_array_type)
<816> DW_AT_name : (indirect string, offset: 0xd2f): reprod__obj_t__T5sP
<81a> DW_AT_GNAT_descriptive_type: <0x7e1>
<81e> DW_AT_type : <0x748>
<822> DW_AT_sibling : <0x830>
... whose uppper bound is a reference to <0x7fb>...
<3><826>: Abbrev Number: 15 (DW_TAG_subrange_type)
<827> DW_AT_type : <0x830>
<82b> DW_AT_upper_bound : <0x7fb>
<3><82f>: Abbrev Number: 0
Because the upper bound is dynamic, we try to resolve it.
As it happens, the upper-bound resolution for this range type
works fine. What breaks is when we try to resolve this range
type's target type, which is:
<2><830>: Abbrev Number: 16 (DW_TAG_subrange_type)
<831> DW_AT_upper_bound : <0x7fb>
<835> DW_AT_name : (indirect string, offset: 0xc7b): reprod__obj_t__T4s___XDLU_1__selected_flights_length
<839> DW_AT_type : <0x766>
<83d> DW_AT_artificial : 1
It is actually pretty much the same as the first subrange type,
so you might ask why this is causing trouble, when the resolution
of the previous DIE worked like a charm???
Well, for that, we need to backtrack a bit, and notice that, ahead
of the DW_TAG_structure_type's DIE, there is the following DIE:
<1><7e1>: Abbrev Number: 6 (DW_TAG_typedef)
<7e2> DW_AT_name : (indirect string, offset: 0xbae): reprod__obj_t__T5s
<7e6> DW_AT_decl_file : 2
<7e7> DW_AT_decl_line : 17
<7e8> DW_AT_type : <0x849>
... and that DIE references an array type...
<2><849>: Abbrev Number: 14 (DW_TAG_array_type)
<84a> DW_AT_name : (indirect string, offset: 0xbae): reprod__obj_t__T5s
<84e> DW_AT_GNAT_descriptive_type: <0x864>
<852> DW_AT_type : <0x748>
<856> DW_AT_sibling : <0x864>
... whose subrange is...
<3><85a>: Abbrev Number: 15 (DW_TAG_subrange_type)
<85b> DW_AT_type : <0x830>
<85f> DW_AT_upper_bound : <0x7fb>
... where the subrange's base type is the DW_TAG_subrange_type DIE
that is causing problem.
In summary, we process the typedef first, which causes us to process
the second subrange BEFORE we process the struct DIE itself, and
therefore the struct's discriminent (DW_TAG_member #1). As a result,
while trying to handle the reference to that DW_TAG_member #1 as
the upper bound of the second range type, we do...
case DW_AT_data_member_location:
{
[...]
baton->referenced_type = get_die_type (target_die->parent,
target_cu);
... where target_die->parent (DW_TAG_member #1) hasn't been processed
yet, and thus get_die_type returns NULL.
This is what later causes us problems trying to find the right address
to use as the base address for our field, which then triggers the
error message we are seeing.
This patch fixes the issue by calling read_type_die instead of
get_die_type. If the DIE has already been processed, then this
is the same as get_die_type. If not, the it'll get the parent
die to be read, and then get its type.
gdb/ChangeLog:
* dwarf2read.c (attr_to_dynamic_prop)
<DW_AT_data_member_location>: Use read_type_die isntead of
get_die_type.
Tested on x86_64-linux, no regression.
No testcase, unfortunately, as the reproducer was given to us by
a customer, and it's been otherwise surprisingly difficult to
reproduce the same error outside of that reproducer.
Joel Brobecker [Fri, 30 Jan 2015 13:51:19 +0000 (08:51 -0500)]
[Ada] error trying to call function when parameter is aligner type.
We observed on x86-windows that trying to call a function from
GDB leads to a mysterious "Invalid cast" error. This can be
observed in gdb.ada/float_param.exp:
(gdb) call set_long_double(1, global_small_struct, 4.0)
Invalid cast.
This happens because the 3rd parameter, a Long_Long_Float, is
actually passed wrapped inside a PAD structure. As documented
in GNAT's exp_dbug.ads, PAD types are simple wrappers that GNAT
uses to handle types with size or alignment constraints.
We already support those when printing an object encapsulated
in a PAD type, but not when trying to pass an argument that
is wrapped inside a PAD type. As a result, what happens is that
call_function_by_hand ends up with an argument with a type
that looks incompatible with the expected type of the argument.
The error comes when trying to push the arguments in inferior
memory, while trying to coerce each one of them to their expected
types (in value_arg_coerce).
Note that the problem is not specific to Windows, but so far, this is
the only platform where we've seen this happen.
gdb/ChangeLog:
* ada-lang.c (ada_convert_actual): Add handling of formals
passed inside an aligner type.
Tested on x86-windows (AdaCore testsuite) and x86_64-linux (official
testsuite as well as AdaCore's testsuite).
Joel Brobecker [Fri, 8 May 2015 14:19:42 +0000 (07:19 -0700)]
gdb/copyright.py: Remove sim/erc32 files from NOT_FSF_LIST.
Now that the erc32 files have been updated to contain an FSF copyright
header, these files should no longer be in the exclude list.
gdb/ChangeLog:
* copyright.py (NOT_FSF_LIST): Remove sim/erc32 entries.
Joel Brobecker [Fri, 8 May 2015 14:11:38 +0000 (07:11 -0700)]
Switch erc32 simulator copyright headers to FSF.
Permission was granted by Jiri Gaisler, who has a copyright assignment
on file for GDB.
sim/erc32/ChangeLog:
* configure.ac: Add copyright header.
* erc32.c: Change copyright holder to FSF. Reformat.
* exec.c, float.c, func.c, interf.c, sis.c, sis.h: Likewise.
* help.c, startsim: Add copyright header.
Siva Chandra [Sun, 26 Apr 2015 00:10:30 +0000 (17:10 -0700)]
[PR python/18291] Fix printing of "disabled" status of xmethod matchers.
gdb/ChangeLog:
PR python/18291
* python/lib/gdb/command/xmethods.py (print_xm_info): Fix typo.
Print xmethod matcher status.
gdb/testsuite/ChangeLog:
PR python/18291
* gdb.python/py-xmethods.exp: Add tests.
H.J. Lu [Fri, 8 May 2015 12:04:12 +0000 (05:04 -0700)]
Add -mno-shared to x86 assembler
On ELF target, the assembler normally generates code which can go into a
shared library where non-weak symbols can be preempted. The -mno-shared
option tells the assembler to generate code not for a shared library,
where non-weak symbols won't be preempted. The resulting code is slightly
smaller. This option mainly affects the handling of branch instructions.
gas/
* config/tc-i386.c (no_shared): New.
(OPTION_MNO_SHARED): Likewise.
(elf_symbol_resolved_in_segment_p): Check no_shared.
(md_longopts): Add mno-shared.
(md_parse_option): Handle OPTION_MNO_SHARED.
(md_show_usage): Add -mno-shared.
* doc/c-i386.texi: Document -mno-shared.
gas/testsuite/
* gas/i386/i386.exp: Run relax-4 and x86-64-relax-3.
* gas/i386/relax-4.d: New file.
* gas/i386/x86-64-relax-3.d: Likewise.
Yao Qi [Fri, 8 May 2015 11:37:48 +0000 (12:37 +0100)]
Fix PR 18208: update /proc/pid/coredump_filter by c code
Hi,
We see some fails in gdb.base/coredump-filter.exp when we do remote
gdbserver testing, like what I did for arm/aarch64 linux testing or
run it with board file remote-gdbserver-on-localhost
$ make check RUNTESTFLAGS='--target_board=remote-gdbserver-on-localhost coredump-filter.exp'
we find that this line in the test doesn't work as expected,
remote_exec target "sh -c \"echo $filter_flag > /proc/$ipid/coredump_filter\""
although such pattern has been used in gdb testsuite somewhere else,
but the special thing here is that we redirect the output to
/proc/$ipid/coredump_filter on the remote target. DejaGNU will
redirect the output from the remote target to local, and looks tcl
gets confused by these two redirection.
After trying pass different parameters to remote_exec and hacking
remote_exec/rsh_exec/local_exec, I got no success, I decide
to give up, and try to update /proc/$ipid/coredump_filter by the c
code directly.
This patch adds a c function set_coredump_filter to update
coredump_filter, and GDB calls it.
gdb/testsuite:
2015-05-08 Yao Qi <yao.qi@linaro.org>
PR gdb/18208
* gdb.base/coredump-filter.c (set_coredump_filter): New function.
* gdb.base/coredump-filter.exp (do_save_core): Call inferior
function set_coredump_filter, and remove remote_exec call.
Remove argument ipid. Callers update.
(top level): Don't get inferior's PID.
Yao Qi [Fri, 8 May 2015 11:29:13 +0000 (12:29 +0100)]
[gdbserver] Disable conditional breakpoints on no-hardware-single-step targets
GDBserver steps over breakpoint if the condition is false, but if target
doesn't support hardware single step, the step over is very simple, if
not incorrect, in linux-arm-low.c:
/* We only place breakpoints in empty marker functions, and thread locking
is outside of the function. So rather than importing software single-step,
we can just run until exit. */
static CORE_ADDR
arm_reinsert_addr (void)
{
struct regcache *regcache = get_thread_regcache (current_thread, 1);
unsigned long pc;
collect_register_by_name (regcache, "lr", &pc);
return pc;
}
and linux-mips-low.c does the same. GDBserver sets a breakpoint at the
return address of the current function, resume and wait the program hits
the breakpoint in order to achieve "breakpoint step over". What if
program hits other user breakponits during this "step over"?
It is worse if the arm/thumb interworking is considered. Nowadays,
GDBserver arm backend unconditionally inserts arm breakpoint,
/* Define an ARM-mode breakpoint; we only set breakpoints in the C
library, which is most likely to be ARM. If the kernel supports
clone events, we will never insert a breakpoint, so even a Thumb
C library will work; so will mixing EABI/non-EABI gdbserver and
application. */
(const unsigned char *) &arm_breakpoint,
(const unsigned char *) &arm_eabi_breakpoint,
note that the comments are no longer valid as C library can be compiled
in thumb mode.
When GDBserver steps over a breakpoint in arm mode function, which
returns to thumb mode, GDBserver will insert arm mode breakpoint by
mistake and the program will crash. GDBserver alone is unable to
determine the arm/thumb mode given a PC address. See how GDB does
it in arm-tdep.c:arm_pc_is_thumb.
After thinking about how to teach GDBserver inserting right breakpoint
(arm or thumb) for a while, I reconsider it from a different direction
that it may be unreasonable to run target-side conditional breakpoint for
targets without hardware single step. Pedro also pointed this out here
https://sourceware.org/ml/gdb-patches/2015-04/msg00337.html
This patch is to add a new target_ops hook
supports_conditional_breakpoints, and only reply
";ConditionalBreakpoints+" if it is true. On linux targets,
supports_conditional_breakpoints returns true if target has hardware
single step, on other targets, (win32, lynx, nto, spu), set it to NULL,
because conditional breakpoint is a linux-specific feature.
gdb/gdbserver:
2015-05-08 Yao Qi <yao.qi@linaro.org>
* linux-low.c (linux_supports_conditional_breakpoints): New
function.
(linux_target_ops): Install new target method.
* lynx-low.c (lynx_target_ops): Install NULL hook for
supports_conditional_breakpoints.
* nto-low.c (nto_target_ops): Likewise.
* spu-low.c (spu_target_ops): Likewise.
* win32-low.c (win32_target_ops): Likewise.
* server.c (handle_query): Check
target_supports_conditional_breakpoints.
* target.h (struct target_ops) <supports_conditional_breakpoints>:
New field.
(target_supports_conditional_breakpoints): New macro.
Andreas Arnez [Fri, 8 May 2015 10:50:47 +0000 (12:50 +0200)]
S390: Fix for inadvertently setting 24-bit mode in fill_gregset
On 64-bit S390 platforms, for programs compiled with -m31, it could
happen that GDB inadvertently cleared the inferior's 31-bit addressing
mode bit and left the inferior running in 24-bit addressing mode. In
particular this occurred with checkpoint.exp, when the "restore"
command needed to create a new regcache copy: At the time when the
PSWM register was copied over, the addressing mode bit was taken from
the PSWA register, which was still zero since it had not been copied
yet. And when the PSWA register was copied, the addressing mode was
not updated again.
The fix affects fill_gregset, where the bits "belonging" to each of
the PSWA and PSWM registers are now carefully separated. The
addressing mode bit is no longer touched when writing PSWM, and --
more importantly -- it *is* written when writing PSWA.
gdb/ChangeLog:
* s390-linux-nat.c (fill_gregset): Avoid relying on the PSWA
register in the regcache when treating the PSWM register, and vice
versa.
Andreas Arnez [Fri, 8 May 2015 10:50:47 +0000 (12:50 +0200)]
Skip watch_thread_num.exp on targets without access watchpoints
Since watch_thread_num.exp was changed to use access watchpoints, the
test case fails on s390 and s390x, since those targets do not support
access watchpoints. This patch skips the test case on such targets.
gdb/testsuite/ChangeLog:
* gdb.base/watch_thread_num.exp: Skip test on targets without
access watchpoints.
GDB Administrator [Fri, 8 May 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Thu, 7 May 2015 16:13:39 +0000 (09:13 -0700)]
Optimize branches to non-weak symbols with visibility
Branches to global non-weak symbols defined in the same segment with
non-default visibility can be optimized the same way as branches to
local symbols.
gas/
* config/tc-i386.c (elf_symbol_resolved_in_segment_p): New.
(md_estimate_size_before_relax): Use it.
gas/testsuite/
* gas/i386/i386.exp: Run relax-3 and x86-64-relax-2.
* gas/i386/relax-3.d: New file.
* gas/i386/relax-3.s: Likewise.
* gas/i386/x86-64-relax-2.d: Likewise.
Gary Benson [Thu, 7 May 2015 14:41:43 +0000 (15:41 +0100)]
Remove unused td_ta_map_id2thr code
linux-thread-db.c initializes td_ta_map_id2thr but never uses it.
This commit removes this dead code.
gdb/ChangeLog:
* linux-thread-db.c (struct thread_db_info)
<td_ta_map_id2thr_p>: Remove field.
(try_thread_db_load_1): Remove initialization for the above.
Gary Benson [Thu, 7 May 2015 13:52:59 +0000 (14:52 +0100)]
Remove unused td_thr_validate code
linux-thread-db.c initializes td_thr_validate but never uses it.
This commit removes this dead code.
gdb/ChangeLog:
* linux-thread-db.c (struct thread_db_info)
<td_thr_validate_p>: Remove field.
(try_thread_db_load_1): Remove initialization for the above.
GDB Administrator [Thu, 7 May 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
Jan Kratochvil [Wed, 6 May 2015 18:59:19 +0000 (20:59 +0200)]
compile: Support relocation to GNU-IFUNCs
Calling memcpy() could fail as memcpy() from libc is GNU-IFUNC.
gdb/ChangeLog
2015-05-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* compile/compile-object-load.c (compile_object_load): Support
mst_text_gnu_ifunc.
Jan Kratochvil [Wed, 6 May 2015 18:57:41 +0000 (20:57 +0200)]
Code cleanup: compile: Constify some parameters
gdb/ChangeLog
2015-05-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* compile/compile.c (compile_to_object): Make the cmd_string parameter
const. Use new variables for the const compatibility.
(eval_compile_command): Make the cmd_string parameter const.
* compile/compile.h (eval_compile_command): Make the cmd_string
parameter const.
Pedro Alves [Wed, 6 May 2015 17:50:03 +0000 (18:50 +0100)]
PR server/18081: gdbserver crashes when providing an unexisting binary
$ ./gdbserver :1234 blah
Process blah created; pid = 16471
Cannot exec blah: No such file or directory.
Child exited with status 127
Killing process(es): 16471
../../../../src/binutils-gdb/gdb/gdbserver/linux-low.c:920: A problem internal to GDBserver has been detected.
kill_wait_lwp: Assertion `res > 0' failed.
GDBserver shouldn't even be trying to kill that process. GDBserver
kills or detaches from all processes on exit, and due to a missing
mourn_inferior call, GDBserver tries to kill the process that it had
already seen exit.
Tested on x86_64 Fedora 20. New test included. I emulated what
Windows outputs by hacking an error call in linux_create_inferior.
gdb/gdbserver/ChangeLog:
2015-05-06 Pedro Alves <palves@redhat.com>
PR server/18081
* server.c (start_inferior): If the process exits, mourn it.
gdb/testsuite/ChangeLog:
2015-05-06 Pedro Alves <palves@redhat.com>
PR server/18081
* gdb.server/non-existing-program.exp: New file.
Joel Brobecker [Wed, 6 May 2015 17:40:52 +0000 (10:40 -0700)]
Get rid of deprecated_init_ui_hook
This hook is no longer used, and can therefore be eliminated.
gdb/ChangeLog:
* defs.h (deprecated_init_ui_hook): Delete. Remove associated
comment.
* top.c (deprecated_init_ui_hook): Delete.
(gdb_init): Remove handling of deprecated_init_ui_hook.
* interps.c (clear_interpreter_hooks): Remove handling of
deprecated_init_ui_hook.
* main.c (captured_main): Update comment.
Joel Brobecker [Sat, 2 May 2015 11:46:47 +0000 (04:46 -0700)]
Make the "info dll" command available on all platform.
The "info dll", an alias of the "info sharedlibrary" command, is
currently only defined in windows native versions. This patch makes
it universally available by moving the alias declaration to solib.c,
and adjusts the documentation accordingly.
Making it universally available has two benefits:
- Windows users moving to a Unix platforms are still able to use
the same command for getting the list of shared libraries;
- Unix to Windows cross debuggers now provide that command also.
gdb/ChangeLog:
* solib.c (_initialize_solib): Add "info dll" alias creation.
* windows-nat.c (set_windows_aliases): Delete.
(_initialize_windows_nat): Remove deprecated_init_ui_hook
assignment.
* NEWS: Add news entry about "info dll" now being available
on all platforms.
gdb/doc/ChangeLog:
* gdb.texinfo (Files): Add "info dll" documentation.
(Cygwin Native): Remove "info dll" documentation.
Jose E. Marchesi [Fri, 1 May 2015 17:16:59 +0000 (10:16 -0700)]
gas: typo in comment fixed.
gas/ChangeLog:
2015-05-06 Jose E. Marchesi <jose.marchesi@oracle.com>
* config/tc-sparc.c: Typo in comment fixed.
Jose E. Marchesi [Fri, 1 May 2015 17:14:11 +0000 (10:14 -0700)]
gas: added tests for the sparc natural instructions.
gas/ChangeLog:
2015-05-06 Jose E. Marchesi <jose.marchesi@oracle.com>
* gas/sparc/natural-32.d: Test ldn, ldna, stn, stna, slln, srln,
sran, casn, casna and clrn.
* gas/sparc/natural-32.s: Likewise.
* gas/sparc/natural.s: Likewise.
* gas/sparc/natural.d: Likewise.
Jose E. Marchesi [Fri, 1 May 2015 00:17:20 +0000 (17:17 -0700)]
gas: support for the sparc %ncc condition codes register.
gas/ChangeLog:
2015-05-06 Jose E. Marchesi <jose.marchesi@oracle.com>
* config/tc-sparc.c (sparc_ip): Support the %ncc "natural"
condition codes
* doc/c-sparc.texi (Sparc-Regs): Document %ncc.
gas/testsuite/ChangeLog:
2015-05-06 Jose E. Marchesi <jose.marchesi@oracle.com>
* gas/sparc/natural.s: New file.
* gas/sparc/natural-32.s: Likewise.
* gas/sparc/natural.d: Likewise.
* gas/sparc/natural-32.d: Likewise.
* gas/sparc/sparc.exp (sparc_elf_setup): Run the tests natural and
natural-32.
Toni Spets [Wed, 6 May 2015 13:18:34 +0000 (14:18 +0100)]
Skip discarded resource sections when building a PE resource table.
PR ld/18372
* peXXigen.c (rsrc_process_section): Skip discarded resource
sections.
Nick Clifton [Wed, 6 May 2015 12:13:10 +0000 (13:13 +0100)]
Update GAS documentation to note that dollar local labels are only supported on some targets.
* doc/as.texinfo (Dollar Local Labels): Note that these are only
supported on some targets.
Renlin Li [Wed, 6 May 2015 11:18:19 +0000 (12:18 +0100)]
[AArch64] Record instruction alignment for .inst directive
2015-05-06 Renlin Li <renlin.li@arm.com>
gas/
* config/tc-aarch64.c (mapping_state): Recording alignment before exit.
gas/testsuite/
* gas/aarch64/codealign_1.s: New.
* gas/aarch64/codealign_1.d: New.
GDB Administrator [Wed, 6 May 2015 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in
Joel Brobecker [Fri, 30 Jan 2015 12:33:04 +0000 (16:33 +0400)]
Further document ada-lang.c::value_assign_to_component & fix whitespaces.
This patch improves the documentation of ada-lang.c's
value_assign_to_component to publish the fact that it also works
with not_lval values.
And touching this area of the code showed that there were a number
of whitespace issues, as well as a formatting issue of the main comment
(no leading '*' on each line). This patch fixes those while at it.
No functional change, however.
gdb/ChangeLog:
* ada-lang.c (value_assign_to_component): Reformat and improve
documentation. Remove all trailing spaces.
Joel Brobecker [Tue, 21 Apr 2015 17:34:04 +0000 (10:34 -0700)]
out of line functions nested inside inline functions.
This patch improves the handling of out-of-line functions nested
inside functions that have been inlined.
Consider for instance a situation where function Foo_O224_021
has a function Child1 declared in it, which itself has a function
Child2 nested inside Child1. After compiling the program with
optimization on, Child1 gets inlined, but not Child2.
After inserting a breakpoint on Child2, and running the program
until reaching that breakpoint, we get the following backtrace:
% gdb foo_o224_021
(gdb) break foo_o224_021.child1.child2
(gdb) run
[...]
Breakpoint 1, foo_o224_021 () at foo_o224_021.adb:28
28 Child1;
(gdb) bt
#0 0x0000000000402400 in foo_o224_021 () at foo_o224_021.adb:28
#1 0x00000000004027a4 in foo_o224_021.child1 () at foo_o224_021.adb:23
#2 0x00000000004027a4 in foo_o224_021 () at foo_o224_021.adb:28
GDB reports the wrong function name for frame #0. We also get the same
kind of error in the "Breakpoint 1, foo_o224_021 () [...]" message.
In both cases, the function name should be foo_o224_021.child1.child2,
and the parameters should be "s=...".
What happens is that the inlined frame handling does not handle well
the case where an inlined function is calling an out-of-line function
which was declared inside the inlined function's scope.
In particular, looking first at the inlined-frame sniffer when applying
to frame #0:
/* Calculate DEPTH, the number of inlined functions at this
location. */
depth = 0;
cur_block = frame_block;
while (BLOCK_SUPERBLOCK (cur_block))
{
if (block_inlined_p (cur_block))
depth++;
cur_block = BLOCK_SUPERBLOCK (cur_block);
}
What happens is that cur_block starts as the block associated
to child2, which is not inlined. We shoud be stopping here, but
instead, we keep walking the superblock chain, which takes us
all the way to Foo_O224_021's block, via Child2's block. And
since Child1 was inlined, we end up with a depth count of 1,
wrongly making GDB think that frame #0 is an inlined frame.
Same kind of issue inside skip_inline_frames.
The fix is to stop checking for inlined frames as soon as we see
a block corresponding to a function which is not inlined. This is
the behavior we now obtain:
(gdb) run
[...]
Breakpoint 1, foo_o224_021.child1.child2 (s=...) at foo_o224_021.adb:9
9 function Child2 (S : String) return Boolean is
(gdb) bt
#0 0x0000000000402400 in foo_o224_021.child1.child2 (s=...)
at foo_o224_021.adb:9
#1 0x00000000004027a4 in foo_o224_021.child1 () at foo_o224_021.adb:23
#2 0x00000000004027a4 in foo_o224_021 () at foo_o224_021.adb:28
gdb/ChangeLog:
* inline-frame.c (inline_frame_sniffer, skip_inline_frames):
Stop counting inlined frames as soon as an out-of-line function
is found.
gdb/testsuite/ChangeLog:
* gdb.ada/out_of_line_in_inlined.exp: Add run and "bt" tests.
Pierre-Marie de Rodat [Mon, 20 Apr 2015 15:53:00 +0000 (17:53 +0200)]
DWARF: cannot break on out-of-line function nested inside inlined function.
Consider the following code, which defines a function, Child2,
which is itself nested inside Child1:
procedure Foo_O224_021 is
O1 : constant Object_Type := Get_Str ("Foo");
procedure Child1 is
O2 : constant Object_Type := Get_Str ("Foo");
function Child2 (S : String) return Boolean is -- STOP
begin
for C of S loop
Do_Nothing (C);
if C = 'o' then
return True;
end if;
end loop;
return False;
end Child2;
R : Boolean;
begin
R := Child2 ("Foo");
R := Child2 ("Bar");
R := Child2 ("Foobar");
end Child1;
begin
Child1;
end Foo_O224_021;
On x86_64-linux, when compiled at -O2, GDB is unable to insert
a breakpoint on Child2:
% gnatmake -g -O2 foo_o224_021
% gdb foo_o224_021
(gdb) b child2
Function "child2" not defined.
(gdb) b foo_o224_021.child1.child2
Function "foo_o224_021.child1.child2" not defined.
The problem is caused by the fact that GDB did not create a symbol
for Child2, and this, in turn, is caused by the fact that the compiler
decided to inline Child1, but not Child2. The DWARF debugging info
first provides an abstract instance tree for Child1...
<3><1b7b>: Abbrev Number: 29 (DW_TAG_subprogram)
<1b7c> DW_AT_name : (indirect string, offset: 0x23f8): foo_o224_021__child1
<1b82> DW_AT_inline : 1 (inlined)
<1b83> DW_AT_sibling : <0x1c01>
... where that subprogram is given the DW_AT_inline attribute.
Inside that function there is a lexical block which has no PC
range (corresponding to the fact that this is the abstract tree):
<4><1b87>: Abbrev Number: 30 (DW_TAG_lexical_block)
... inside which our subprogram Child2 is described:
<5><1b92>: Abbrev Number: 32 (DW_TAG_subprogram)
<1b93> DW_AT_name : (indirect string, offset: 0x2452): foo_o224_021__child1__child2
<1b99> DW_AT_type : <0x1ab1>
<1b9d> DW_AT_low_pc : 0x402300
<1ba5> DW_AT_high_pc : 0x57
[...]
Then, later on, we get the concrete instance tree, starting at:
<3><1c5e>: Abbrev Number: 41 (DW_TAG_inlined_subroutine)
<1c5f> DW_AT_abstract_origin: <0x1b7b>
<1c63> DW_AT_entry_pc : 0x4025fd
<1c6b> DW_AT_ranges : 0x150
... which refers to Child1. One of that inlined subroutine children
is the concrete instance of the empty lexical block we saw above
(in the abstract instance tree), which gives the actual address
range for this inlined instance:
<5><1c7a>: Abbrev Number: 43 (DW_TAG_lexical_block)
<1c7b> DW_AT_abstract_origin: <0x1b87>
<1c7f> DW_AT_ranges : 0x180
This is the DIE which provides the context inside which we can
record Child2. But unfortunately, GDB does not take the abstract
origin into account when handling lexical blocks, causing it
to miss the fact that this block contains some symbols described
in the abstract instance tree. This is the first half of this patch:
modifying GDB to follow DW_AT_abstract_origin attributes for
lexical blocks.
But this not enough to fix the issue, as we're still unable to
break on Child2 with just that change. The second issue can be
traced to the way inherit_abstract_dies determines the list of
DIEs to inherit from. For that, it iterates over all the DIEs in
the concrete instance tree, and finds the list of DIEs from the
abstract instance tree that are not referenced from the concrete
instance tree. As it happens, there is one type of DIE in the
concrete instance tree which does reference Child2's DIE, but
in fact does otherwise define a concrete instance of the reference
DIE; that's (where <0x1b92> is Child2's DIE):
<6><1d3c>: Abbrev Number: 35 (DW_TAG_GNU_call_site)
<1d3d> DW_AT_low_pc : 0x4026a4
<1d45> DW_AT_abstract_origin: <0x1b92>
So, the second part of the patch is to modify inherit_abstract_dies
to ignore DW_TAG_GNU_call_site DIEs when iterating over the concrete
instance tree.
This patch also includes a testcase which can be used to reproduce
the issue. Unfortunately, for it to actually pass, a smal patch in
GCC is also necessary to make sure that GCC provides lexical blocks'
DW_AT_abstract_origin attributes from the concrete tree back to
the abstract tree. We hope to be able to submit and integrate that
patch in the GCC tree soon. Meanwhile, a setup_xfail has been added.
gdb/ChangeLog:
2014-05-05 Pierre-Marie de Rodat <derodat@adacore.com>
* dwarf2read.c (inherit_abstract_dies): Skip
DW_TAG_GNU_call_site dies while inheriting children of an
abstract DIE into a scope.
(read_lexical_block_scope): Inherit abstract DIE's for
lexical scopes.
gdb/testsuite/ChangeLog:
* gdb.ada/out_of_line_in_inlined: New testcase.
Joel Brobecker [Thu, 30 Apr 2015 21:04:25 +0000 (23:04 +0200)]
compare object sizes before comparing them with value_contents_eq
This is an issue which I noticed while working on trying to print
an array of variant records. For instance, trying to print "A1",
an array of elements whose size is variable, defined as follow
(see gdb.ada/var_rec_arr testcase):
subtype Small_Type is Integer range 0 .. 10;
type Record_Type (I : Small_Type := 0) is record
S : String (1 .. I);
end record;
function Ident (R : Record_Type) return Record_Type;
type Array_Type is array (Integer range <>) of Record_Type;
A1 : Array_Type := (1 => (I => 0, S => <>),
2 => (I => 1, S => "A"),
3 => (I => 2, S => "AB"));
The debugger sometimes prints the array as follow:
(gdb) print A1
$1 = ((i => 0, s => ""), (i => 0, s => ""), (i => 0, s => ""))
The problem happens inside the part of the loop printing the array's
elements, while trying to count the number of consecutive elements
that have the same value (in order to replace them by the "<repeats
nnn times>" message when the number exceeds a threshold). In particular,
in ada-valprint.c::val_print_packed_array_elements:
elttype = TYPE_TARGET_TYPE (type);
eltlen = TYPE_LENGTH (check_typedef (elttype));
while (...)
{
if (!value_contents_eq (v0, value_embedded_offset (v0),
v1, value_embedded_offset (v1),
eltlen))
break;
The value comparison is performed using value_contents_eq but makes
the assumption that elttype is not dynamic, which is not always true.
In particular, in the case above, elttype is dynamic and therefore
its TYPE_LENGTH changes from element to element.
As it happens in this case, the eltlen is zero, which causes the call
to value_contents_eq to return true, and therefore GDB thinks all
3 elements of the array are equal.
This patch fixes the issue by making sure that both v0 and v1, which
are values whose type we expect to be resolved, have identical lengths.
If not, then the two elements of the array cannot possibly have the
same value and we do not even need to do the binary comparison.
Unfortunately, this is still not enough to get GDB to print the correct
value for our array, because the assumption that v0 and v1 have a type
which has been resolved is actually not met. So, the second part of
the patch modifies the function that constructed the values to make
sure dynamic types do get resolved.
gdb/ChangeLog:
* ada-valprint.c (val_print_packed_array_elements): Delete
variable "len". Add a type-length check when comparing two
consecutive elements of the array. Use the element's actual
length in call to value_contents_eq.
* ada-lang.c (ada_value_primitive_packed_val): Always return
a value whose type has been resolved.
Joel Brobecker [Tue, 21 Apr 2015 15:32:52 +0000 (08:32 -0700)]
testsuite/gdb.ada/var_rec_arr: New testcase.
gdb/testsuite/ChangeLog:
* gdb.ada/var_rec_arr: New testcase.
Joel Brobecker [Tue, 14 Apr 2015 18:55:57 +0000 (11:55 -0700)]
GDB crash trying to subscript array of variant record.
Consider the following declarations:
subtype Small_Type is Integer range 0 .. 10;
type Record_Type (I : Small_Type := 0) is record
S : String (1 .. I);
end record;
A2 : Array_Type := (1 => (I => 2, S => "AB"),
2 => (I => 1, S => "A"),
3 => (I => 0, S => <>));
Compiled with -fgnat-encodings=minimal, and trying to print
one element of our array, valgrind reports an invalid memory
access. On certain GNU/Linux boxes, malloc even reports it as
well, and causes GDB to crash.
(gdb) print a2(1)
*** glibc detected *** /[...]/gdb:
malloc(): memory corruption: 0x0a30ba48 ***
[crash]
The invalid memory access occurs because of a simple buffer
overflow in ada_value_primitive_packed_val. When this function
is called, it is given a bit_size of 128 (or 16 bytes), which
corresponds to the stride of our array. But the actual size of
each element depends on its value. In particular, A2(1) is a record
whose size is only 6 bytes.
What happens in our example is that we start building a new value
(v) where the element is to be unpacked, with any of its dynamic
properties getting resolved as well. We then unpack the data into
this value's buffer:
unpacked = (unsigned char *) value_contents (v);
[...]
nsrc = len;
[...]
while (nsrc > 0)
{
[...]
unpacked[targ] = accum & ~(~0L << HOST_CHAR_BIT);
[...]
targ += delta;
[...]
nsrc -= 1;
[...]
}
In the loop above, targ starts at zero (for LE architectures),
and len is 16. With delta being +1, we end up iterating 16 times,
writing 16 bytes into a 6-bytes buffer.
This patch fixes the issue by adjusting BIT_SIZE and recomputing
LEN after having resolved our type if the resolved type turns out
to be smaller than bit_size.
gdb/ChangeLog:
* ada-lang.c (ada_value_primitive_packed_val): Recompute
BIT_SIZE and LEN if the size of the resolved type is smaller
than BIT_SIZE * HOST_CHAR_BIT.
Joel Brobecker [Thu, 2 Apr 2015 18:09:15 +0000 (11:09 -0700)]
[Ada] array of variant record subscripting
Consider the following (Ada) array...
A1 : Array_Type := (1 => (I => 0, S => <>),
2 => (I => 1, S => "A"),
3 => (I => 2, S => "AB"));
... where Array_Type is declared as follow:
subtype Small_Type is Integer range 0 .. 10;
type Record_Type (I : Small_Type := 0) is record
S : String (1 .. I);
end record;
type Array_Type is array (Integer range <>) of Record_Type;
Trying to print the value of each element individually does not
always work. Printing the value of the first one does:
(gdb) p a1(1)
$1 = (i => 0, s => "")
But printing the value of the subsequent ones often does not.
For instance:
(gdb) p a1(2)
$2 = (i => 1, s => "") <<<--- s should be "A"
(gdb) p a1(3)
$3 = (i => 2, s => "") <<<--- s should be "AB"
I traced the problem to ada_value_primitive_packed_val,
which is trying to perform the array subscripting by
extracting the value of the corresponding array element
into a buffer where the contents is now byte-aligned.
The element type that ada_value_primitive_packed_val gets passed
is a dynamic type. As it happens, that dynamic type can get resolved
thanks to:
v = value_at (type, value_address (obj));
type = value_type (v);
However, obj represents the array, so the address given in the call
to value_at represents the value of the first element. As a result,
the solution of component S's upper bound always gets resolved based
on the value of component I in the first element of the array, whose
value is 0, thus leading to GDB mistakely resolving the element type
where S's upper bound is always 0.
The proper fix would be to systematically resolve the element type
first. But, this requires us to extract-and-realign the element's
value so as to be able to pass it as "valaddr" to resolve_dynamic_type.
In the meantime, it's easy to make the situation a little better by
passing "value_address (obj) + offset" as the object address. This
only works when BIT_OFFSET is nul, but that should be the case when
the element type is anything but a scalar, which seems to be the only
situation where it seems important to resolve the type now. And we're
not that worse off otherwise.
But we'll try to find a better solution in a separate patch.
gdb/ChangeLog:
* ada-lang.c (ada_value_primitive_packed_val): Use a more
correct address in call to value_at. Adjust call to
value_address accordingly.
Joel Brobecker [Wed, 1 Apr 2015 22:46:54 +0000 (15:46 -0700)]
[Ada] Resolve dynamic type before trying to print it.
This is another required step towards trying to print the value of
an array of variant records. For instance:
A1 : Array_Type := (1 => (I => 0, S => <>),
2 => (I => 1, S => "A"),
3 => (I => 2, S => "AB"));
... where Array_Type is an array of records whose size is variable:
subtype Small_Type is Integer range 0 .. 10;
type Record_Type (I : Small_Type := 0) is record
S : String (1 .. I);
end record;
type Array_Type is array (Integer range <>) of Record_Type;
What happens is that the ada-valprint modules gets passed an array
whose element type is not resolved yet (since each element of the
array needs to be resolved separately). the module then recurses,
and eventually gets called with the first element of the array.
But because the element hasn't been resolved yet, we end up having
trouble printing its value soon after.
This patch fixes the issue by calling resolve_dynamic_type before
trying to print it.
With this patch, GDB is finally able to print the complete value
for variable "A1":
(gdb) p a1
$1 = ((i => 0, s => ""), (i => 1, s => "A"), (i => 2, s => "AB"))
gdb/ChangeLog:
* ada-valprint.c (ada_val_print_1): Resolve TYPE before trying
to print it.
Joel Brobecker [Wed, 1 Apr 2015 17:00:13 +0000 (10:00 -0700)]
Add valaddr support in dynamic property resolution.
This is the second part of enhancing the debugger to print the value
of arrays of records whose size is variable when only standard DWARF
info is available (no GNAT encoding). For instance:
subtype Small_Type is Integer range 0 .. 10;
type Record_Type (I : Small_Type := 0) is record
S : String (1 .. I);
end record;
type Array_Type is array (Integer range <>) of Record_Type;
A1 : Array_Type := (1 => (I => 0, S => <>),
2 => (I => 1, S => "A"),
3 => (I => 2, S => "AB"));
Currently, GDB prints the following output:
(gdb) p a1
$1 = (
The error happens while the ada-valprint module is trying to print
the value of an element of our array. Because of the fact that
the array's element (type Record_Type) has a variant size, the DWARF
info for our array provide the array's stride:
<1><749>: Abbrev Number: 10 (DW_TAG_array_type)
<74a> DW_AT_name : (indirect string, offset: 0xb6d): pck__T18s
<74e> DW_AT_byte_stride : 16
<74f> DW_AT_type : <0x6ea>
And because our array has a stride, ada-valprint treats it the same
way as packed arrays (see ada-valprint.c::ada_val_print_array):
if (TYPE_FIELD_BITSIZE (type, 0) > 0)
val_print_packed_array_elements (type, valaddr, offset_aligned,
0, stream, recurse,
original_value, options);
The first thing that we should notice in the call above is that
the "valaddr" buffer and the associated offset (OFFSET_ALIGNED)
is passed, but that the corresponding array's address is not.
This can be explained by looking inside val_print_packed_array_elements,
where we see that the function unpacks each element of our array from
the buffer alone (ada_value_primitive_packed_val), and then prints
the resulting artificial value instead:
v0 = ada_value_primitive_packed_val (NULL, valaddr + offset,
(i0 * bitsize) / HOST_CHAR_BIT,
(i0 * bitsize) % HOST_CHAR_BIT,
bitsize, elttype);
[...]
val_print (elttype, value_contents_for_printing (v0),
value_embedded_offset (v0), 0, stream,
recurse + 1, v0, &opts, current_language);
Of particular interest, here, is the fact that we call val_print
with a null address, which is OK, since we're providing a buffer
instead (value_contents_for_printing). Also, providing an address
might not always possible, since packing could place elements at
boundaries that are not byte-aligned.
Things go south when val_print tries to see if there is a pretty-printer
that could be applied. In particular, one of the first things that
the Python pretty-printer does is to create a value using our buffer,
and the given address, which in this case is null (see call to
value_from_contents_and_address in gdbpy_apply_val_pretty_printer).
value_from_contents_and_address, in turn immediately tries to resolve
the type, using the given address, which is null. But, because our
array element is a record containing an array whose bound is the value
of one of its elements (the "s" component), the debugging info for
the array's upper bound is a reference...
<3><71a>: Abbrev Number: 7 (DW_TAG_subrange_type)
<71b> DW_AT_type : <0x724>
<71f> DW_AT_upper_bound : <0x703>
... to component "i" of our record...
<2><703>: Abbrev Number: 5 (DW_TAG_member)
<704> DW_AT_name : i
<706> DW_AT_decl_file : 2
<707> DW_AT_decl_line : 6
<708> DW_AT_type : <0x6d1>
<70c> DW_AT_data_member_location: 0
... where that component is located at offset 0 of the start
of the record. dwarf2_evaluate_property correctly determines
the offset where to load the value of the bound from, but then
tries to read that value from inferior memory using the address
that was given, which is null. See case PROP_ADDR_OFFSET in
dwarf2_evaluate_property:
val = value_at (baton->offset_info.type,
pinfo->addr + baton->offset_info.offset);
This triggers a memory error, which then causes the printing to terminate.
Since there are going to be situations where providing an address
alone is not going to be sufficient (packed arrays where array elements
are not stored at byte boundaries), this patch fixes the issue by
enhancing the type resolution to take both address and data. This
follows the same principle as the val_print module, where both
address and buffer ("valaddr") can be passed as arguments. If the data
has already been fetched from inferior memory (or provided by the
debugging info in some form -- Eg a constant), then use that data
instead of reading it from inferior memory.
Note that this should also be a good step towards being able to handle
dynamic types whose value is stored outside of inferior memory
(Eg: in a register).
With this patch, GDB isn't able to print all of A1, but does perform
a little better:
(gdb) p a1
$1 = ((i => 0, s => , (i => 1, s => , (i => 2, s => )
There is another issue which is independent of this one, and will
therefore be patched separately.
gdb/ChangeLog:
* dwarf2loc.h (struct property_addr_info): Add "valaddr" field.
* dwarf2loc.c (dwarf2_evaluate_property): Add handling of
pinfo->valaddr.
* gdbtypes.h (resolve_dynamic_type): Add "valaddr" parameter.
* gdbtypes.c (resolve_dynamic_struct): Set pinfo.valaddr.
(resolve_dynamic_type_internal): Set pinfo.valaddr.
Add handling of addr_stack->valaddr.
(resolve_dynamic_type): Add "valaddr" parameter.
Set pinfo.valaddr field.
* ada-lang.c (ada_discrete_type_high_bound): Update call to
resolve_dynamic_type.
(ada_discrete_type_low_bound): Likewise.
* findvar.c (default_read_var_value): Likewise.
* value.c (value_from_contents_and_address): Likewise.
Joel Brobecker [Tue, 31 Mar 2015 14:59:35 +0000 (07:59 -0700)]
preserve the bit stride when resolving an array type.
Consider the following (Ada) variable...
A1 : Array_Type := (1 => (I => 0, S => <>),
2 => (I => 1, S => "A"),
3 => (I => 2, S => "AB"));
... where Array_Type is an array of records whose size is variable:
subtype Small_Type is Integer range 0 .. 10;
type Record_Type (I : Small_Type := 0) is record
S : String (1 .. I);
end record;
type Array_Type is array (Integer range <>) of Record_Type;
Trying to print the value of this array currently results in the following
error:
(gdb) p a1
Cannot access memory at address 0x61c000
What happens in this case, is that the compiler describes our array
as an array with a specific stride (and bounds being static 1..3):
<1><749>: Abbrev Number: 10 (DW_TAG_array_type)
<74a> DW_AT_name : (indirect string, offset: 0xb6d): pck__T18s
<74e> DW_AT_byte_stride : 16
<74f> DW_AT_type : <0x6ea>
<2><757>: Abbrev Number: 11 (DW_TAG_subrange_type)
<758> DW_AT_type : <0x75e>
<75c> DW_AT_upper_bound : 3
This is because we cannot use, in this case, the size of the record
to determine that stride, since the size of the record depends on
its contents. So the compiler helps us by providing that stride.
The problems start when trying to resolve that type. Because the elements
contained in that array type are dynamic, the array itself is considered
dynamic, and thus we end up creating a resolved version of that array.
And during that resolution, we were not handling the case where the array
had a stride. See gdbtypes.c::resolve_dynamic_array...
return create_array_type (copy_type (type),
elt_type,
range_type);
As a result, we created an array whose stride was based on the size
of elt_type, which a record whose size isn't static and irrelevant
regardless.
This patch fixes is by calling create_array_type_with_stride instead.
As it happens, there is another issue for us to be able to print
the value of our array, but those are independent of this patch
and will be handled separately. For now, the patch allows us to
get rid of the first error, and the output is now:
(gdb) p a1
$1 = (
gdb/ChangeLog:
* gdbtypes.c (resolve_dynamic_array): Use
create_array_type_with_stride instead of create_array_type.
Renlin Li [Tue, 5 May 2015 16:48:18 +0000 (17:48 +0100)]
[AARCH64] Positively emit symbols for alignment
2015-05-05 Renlin Li <renlin.li@arm.com>
gas/
* config/tc-aarch64.c (aarch64_init_frag): Always generate mapping symbols.
gas/testsuite/
* gas/aarch64/mapping_5.d: New.
* gas/aarch64/mapping_5.s: New.
* gas/aarch64/mapping_6.d: New.
* gas/aarch64/mapping_6.s: New.
Nick Clifton [Tue, 5 May 2015 12:38:00 +0000 (13:38 +0100)]
Add support to the MSP430 linker for the automatic placement of code and data into either low or high memory regions.
gas * config/tc-msp430.c (MAX_OP_LEN): Increase to 4096.
(msp430_make_init_symbols): New function.
(msp430_section): Call it.
(msp430_frob_section): Likewise.
ld * emulparams/msp430elf.sh (TEMPLATE_NAME): Change to msp430.
* scripttempl/msp430.sc (.text): Add .lower.text and .either.text.
(.data): Add .lower.data and .either.data.
(.bss): Add .lower.bss and .either.bss.
(.rodata): Add .lower.rodata and .either.rodata.
* emultempl/msp430.em: New file. Implements a new orphan
placement algorithm that divides sections between lower and upper
memory regions.
* Makefile.am (emsp430elf.c): Depend upon msp430.em.
*emsp430X.c): Likewise.
* Makefine.in: Regenerate.
Max Filippov [Fri, 1 May 2015 08:39:12 +0000 (11:39 +0300)]
xtensa: optimize trampolines relaxation
Currently every fixup in the current segment is checked when relaxing
trampoline frag. This is very expensive. Make a searchable array of
fixups pointing at potentially oversized jumps at the beginning of every
relaxation pass and only check subset of this cache in the reach of
single jump from the trampoline frag currently being relaxed.
Original profile:
% time self children called name
-----------------------------------------
370.16 593.38
12283048/
12283048 relax_segment
98.4 370.16 593.38
12283048 xtensa_relax_frag
58.91 269.26
2691463834/
2699602236 xtensa_insnbuf_from_chars
68.35 68.17
811266668/
813338977 S_GET_VALUE
36.85 29.51
2684369246/
2685538060 xtensa_opcode_decode
28.34 8.84
2684369246/
2685538060 xtensa_format_get_slot
12.39 5.94
2691463834/
2699775044 xtensa_format_decode
0.03 4.60
4101109/
4101109 relax_frag_for_align
0.18 1.76 994617/994617 relax_frag_immed
0.07 0.09
24556277/
24851220 new_logical_line
0.06 0.00
12283048/
14067410 as_where
0.04 0.00
7094588/
15460506 xtensa_format_num_slots
0.00 0.00 1/712477 xtensa_insnbuf_alloc
-----------------------------------------
Same data, after optimization:
% time self children called name
-----------------------------------------
0.51 7.47
12283048/
12283048 relax_segment
58.0 0.51 7.47
12283048 xtensa_relax_frag
0.02 4.08
4101109/
4101109 relax_frag_for_align
0.18 1.39 994617/994617 relax_frag_immed
0.01 0.98 555/555 xtensa_cache_relaxable_fixups
0.21 0.25
7094588/
16693271 xtensa_insnbuf_from_chars
0.06 0.12
24556277/
24851220 new_logical_line
0.06 0.00
7094588/
15460506 xtensa_format_num_slots
0.02 0.04
7094588/
16866079 xtensa_format_decode
0.05 0.00
12283048/
14067410 as_where
0.00 0.00 1/712477 xtensa_insnbuf_alloc
0.00 0.00 93808/93808 xtensa_find_first_cached_fixup
-----------------------------------------
2015-05-02 Max Filippov <jcmvbkbc@gmail.com>
gas/
* config/tc-xtensa.c (cached_fixupS, fixup_cacheS): New typedefs.
(struct cached_fixup, struct fixup_cache): New structures.
(fixup_order, xtensa_make_cached_fixup),
(xtensa_realloc_fixup_cache, xtensa_cache_relaxable_fixups),
(xtensa_find_first_cached_fixup, xtensa_delete_cached_fixup),
(xtensa_add_cached_fixup): New functions.
(xtensa_relax_frag): Cache fixups pointing at potentially
oversized jumps at the beginning of every relaxation pass. Only
check subset of this cache in the reach of single jump from the
trampoline frag currently being relaxed.
GDB Administrator [Tue, 5 May 2015 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Mon, 4 May 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 3 May 2015 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
Cary Coutant [Sat, 2 May 2015 15:40:09 +0000 (08:40 -0700)]
Change Section_id type to use Relobj* instead of Object*.
2015-04-29 Cary Coutant <cary@google.com>
Rafael Ávila de Espíndola <rafael.espindola@gmail.com>
gold/
* gc.h (Garbage_collection::is_section_garbage): Change Object*
to Relobj*.
(Garbage_collection::add_reference): Likewise.
(Garbage_collection::gc_process_relocs): Likewise. Don't push
object/shndx pair onto *secvec for dynamic objects. Don't follow
relocations pointing to dynamic objects for GC.
* icf.cc (Icf::find_identical_sections): Change Object* to Relobj*.
(Icf::unfold_section): Likewise.
(Icf::is_section_folded): Likewise.
(Icf::get_folded_section): Likewise.
* icf.h: (Icf::get_folded_section): Likewise.
(Icf::unfold_section): Likewise.
(Icf::is_section_folded): Likewise.
(Icf::section_has_function_pointers): Likewise.
(Icf::set_section_has_function_pointers): Likewise.
* object.h (Section_id): Likewise.
(Const_section_id): Likewise.
* output.cc (Output_section::update_section_layout): Likewise.
* output.h: (Output_section_lookup_maps::find_relaxed_input_section):
Likewise.
* plugin.cc (update_section_order): Likewise.
(unique_segment_for_sections): Likewise.
* powerpc.cc (Powerpc_relobj::add_reference): Likewise.
(Target_powerpc::do_gc_add_reference): Likewise.
(Target_powerpc::gc_process_relocs): Likewise.
(Target_powerpc::do_gc_add_reference): Likewise.
* symtab.cc (Symbol_table::is_section_folded): Likewise.
(Symbol_table::gc_mark_symbol): Likewise.
* symtab.h: (Symbol_table::is_section_folded): Likewise.
* target.h: (Sized_target::gc_add_reference): Likewise.
(Sized_target::do_gc_add_reference): Likewise.
GDB Administrator [Sat, 2 May 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
DJ Delorie [Fri, 1 May 2015 19:08:07 +0000 (15:08 -0400)]
Fix typos in previous patch.
* config/rl78-parse.y (MULU): Remove ISA_G14.
(MULH, DIVHU, DIVWU, MACHI, MACH): Update error strings.
H.J. Lu [Fri, 1 May 2015 16:10:03 +0000 (09:10 -0700)]
Sync filenames.h with gcc
Merge with gcc:
2014-11-11 Anthony Brandon <anthony.brandon@gmail.com>
Manuel López-Ibáñez <manu@gcc.gnu.org>
PR driver/36312
* filenames.h: Add prototype for canonical_filename_eq.
H.J. Lu [Fri, 1 May 2015 15:33:55 +0000 (08:33 -0700)]
Configure zlib with --enable-host-shared for shared bfd
When bfd is configured as a shared library, we need to configure zlib
with --enable-host-shared since zlib is used by bfd.
PR ld/18355
* Makefile.def: Add extra_configure_flags to host zlib.
* configure.ac (extra_host_zlib_configure_flags): New. Set
to --enable-host-shared When bfd is to be built as shared
library. AC_SUBST.
* Makefile.in: Regenerated.
* configure: Likewise.