Alan Modra [Mon, 2 Dec 2013 23:00:01 +0000 (09:30 +1030)]
daily update
Jan Kratochvil [Mon, 2 Dec 2013 21:24:32 +0000 (22:24 +0100)]
Record objfile->original_name as an absolute path
gdb/
2013-12-02 Doug Evans <dje@google.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
* objfiles.c (allocate_objfile): Save original_name as an absolute
path.
* objfiles.h (struct objfile): Expand comment on original_name.
* source.c (openp): Call gdb_abspath.
* utils.c (gdb_abspath): New function.
* utils.h (gdb_abspath): Declare.
gdb/testsuite/
2013-12-02 Doug Evans <dje@google.com>
* gdb.dwarf/dwp-symlink.c: Fake out gdb to not load debug info
at start.
* gdb.dwarf/dwp-symlink.exp: Test trying to load dwp when the binary
has been specified with a relative path and we have chdir'd before
accessing the debug info.
Pedro Alves [Mon, 2 Dec 2013 10:12:24 +0000 (10:12 +0000)]
Add new target_read_raw_memory function, and consolidate comments.
Tested on x86_64 Fedora 17.
gdb/
2013-12-02 Pedro Alves <palves@redhat.com>
* dcache.c (dcache_read_line): Use target_read_raw_memory.
* target.c (target_read_raw_memory): New function.
(target_read_stack, target_write_memory, target_write_raw_memory):
Update comment.
(target_read_code): Add comment.
* target.h (target_read_raw_memory): Declare.
Pedro Alves [Mon, 2 Dec 2013 11:09:24 +0000 (11:09 +0000)]
gnulib's sys/stat.h always defines S_IRGRP, S_IXGRP, S_IXOTH.
Confirmed that cross building a mingw gdb still works, and also made
sure it was gnulib's sys/stat.h that was defining the values, by
hacking the header with #errors where the macros are defined.
gdb/
2013-12-02 Pedro Alves <palves@redhat.com>
* ctf.c (ctf_start): Use S_IRGRP, S_IXGRP, S_IXOTH
unconditionally.
Pedro Alves [Sat, 30 Nov 2013 18:22:49 +0000 (18:22 +0000)]
Handle 'k' packet TARGET_CLOSE_ERROR gracefully.
Remote servers may cut the connection abruptly since they are not
required to reply to a 'k' (Kill) packet sent from GDB.
This patch addresses any issues arising from such scenario, which
leads to a GDB internal error due to an attempt to pop the target more
than once. With the patch, this failure is handled gracefully.
Here's the GDB backtrace Maciej got running the testsuite against
QEMU. Full paths edited out for brevity.
#0 0x55573430 in __kernel_vsyscall ()
#1 0x557a2951 in raise () from /lib32/libc.so.6
#2 0x557a5d82 in abort () from /lib32/libc.so.6
#3 0x0826e2e4 in dump_core ()
at .../gdb/utils.c:635
#4 0x0826e5b6 in internal_vproblem (problem=0x85200c0,
file=0x8416be8 ".../gdb/target.c", line=2861,
fmt=0x84174ac "could not find a target to follow mourn inferior",
ap=0xffa4796c "\f")
at .../gdb/utils.c:804
#5 0x0826e5fb in internal_verror (
file=0x8416be8 ".../gdb/target.c", line=2861,
fmt=0x84174ac "could not find a target to follow mourn inferior",
ap=0xffa4796c "\f")
at .../gdb/utils.c:820
#6 0x0826e633 in internal_error (
file=0x8416be8 ".../gdb/target.c", line=2861,
string=0x84174ac "could not find a target to follow mourn inferior")
at .../gdb/utils.c:830
#7 0x081b4ad0 in target_mourn_inferior ()
at .../gdb/target.c:2861
#8 0x08082283 in remote_kill (ops=0x85245e0)
at .../gdb/remote.c:7840
#9 0x081b06d1 in target_kill ()
at .../gdb/target.c:486
#10 0x081b42f6 in dispose_inferior (inf=0xa501c60, args=0x0)
at .../gdb/target.c:2570
#11 0x08290cfc in iterate_over_inferiors (
callback=0x81b42af <dispose_inferior>, data=0x0)
at .../gdb/inferior.c:396
#12 0x081b435a in target_preopen (from_tty=1)
at .../gdb/target.c:2591
#13 0x0807c2c6 in remote_open_1 (name=0xa5538b6 "localhost:1237", from_tty=1,
target=0x85245e0, extended_p=0)
at .../gdb/remote.c:4292
#14 0x0807b7a8 in remote_open (name=0xa5538b6 "localhost:1237", from_tty=1)
at .../gdb/remote.c:3655
#15 0x080a23d4 in do_cfunc (c=0xa464f30, args=0xa5538b6 "localhost:1237",
from_tty=1)
at .../gdb/cli/cli-decode.c:107
#16 0x080a4c3b in cmd_func (cmd=0xa464f30, args=0xa5538b6 "localhost:1237",
from_tty=1)
at .../gdb/cli/cli-decode.c:1882
#17 0x0826bebf in execute_command (p=0xa5538c3 "7", from_tty=1)
at .../gdb/top.c:467
#18 0x08193f2d in command_handler (command=0xa5538a8 "")
at .../gdb/event-top.c:435
#19 0x08194463 in command_line_handler (
rl=0xa778198 "target remote localhost:1237")
at .../gdb/event-top.c:633
#20 0x082ba92b in rl_callback_read_char ()
at .../readline/callback.c:220
#21 0x08193adf in rl_callback_read_char_wrapper (client_data=0x0)
at .../gdb/event-top.c:164
#22 0x08193e57 in stdin_event_handler (error=0, client_data=0x0)
at .../gdb/event-top.c:375
#23 0x08192f29 in handle_file_event (data=...)
at .../gdb/event-loop.c:768
#24 0x0819266a in process_event ()
at .../gdb/event-loop.c:342
#25 0x08192708 in gdb_do_one_event ()
at .../gdb/event-loop.c:394
#26 0x08192781 in start_event_loop ()
at .../gdb/event-loop.c:431
#27 0x08193b08 in cli_command_loop (data=0x0)
at .../gdb/event-top.c:179
#28 0x0818bc26 in current_interp_command_loop ()
at .../gdb/interps.c:327
#29 0x0818c4e5 in captured_command_loop (data=0x0)
at .../gdb/main.c:267
#30 0x0818a37f in catch_errors (func=0x818c4d0 <captured_command_loop>,
func_args=0x0, errstring=0x8402108 "", mask=RETURN_MASK_ALL)
at .../gdb/exceptions.c:524
#31 0x0818d736 in captured_main (data=0xffa47f10)
at .../gdb/main.c:1067
#32 0x0818a37f in catch_errors (func=0x818c723 <captured_main>,
func_args=0xffa47f10, errstring=0x8402108 "", mask=RETURN_MASK_ALL)
at .../gdb/exceptions.c:524
#33 0x0818d76c in gdb_main (args=0xffa47f10)
at .../gdb/main.c:1076
#34 0x0804dd1b in main (argc=5, argv=0xffa47fd4)
at .../gdb/gdb.c:34
The corresponding gdb.log excerpt:
(gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (u9)
cont
Continuing.
Breakpoint 1, break1 () at .../gdb/testsuite/gdb.base/bitfields.c:44
44 }
(gdb) PASS: gdb.base/bitfields.exp: continuing to break1 #9
print flags
$10 = {uc = 0 '\000', s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 1 '\001'}
(gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (sc)
delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break break2
Breakpoint 2 at 0x85f8: file .../gdb/testsuite/gdb.base/bitfields.c, line 48.
(gdb) entering gdb_reload
target remote localhost:1235
A program is being debugged already. Kill it? (y or n) y
Remote connection closed
.../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) ^Ccontinue
Please answer y or n.
.../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) Resyncing due to internal error.
n
.../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) y
Command aborted.
(gdb) print/x flags
$11 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0}
(gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #1
cont
The program is not being run.
(gdb) FAIL: gdb.base/bitfields.exp: continuing to break2 (the program is no longer running)
print/x flags
$12 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0}
(gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #2
delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break break3
Breakpoint 3 at 0x8604: file .../gdb/testsuite/gdb.base/bitfields.c, line 52.
(gdb) entering gdb_reload
target remote localhost:1236
Remote debugging using localhost:1236
Reading symbols from .../lib/ld-linux.so.3...done.
Loaded symbols for .../lib/ld-linux.so.3
0x41001b80 in _start () from .../lib/ld-linux.so.3
(gdb) continue
Continuing.
Breakpoint 3, break3 () at .../gdb/testsuite/gdb.base/bitfields.c:52
52 }
(gdb) print flags
$13 = {uc = 0 '\000', s1 = 0, u1 = 1, s2 = 0, u2 = 3, s3 = 0, u3 = 7, s9 = 0, u9 = 511, sc = 0 '\000'}
(gdb) PASS: gdb.base/bitfields.exp: unsigned bitfield ranges
gdb/
2013-12-02 Pedro Alves <pedro@codesourcery.com>
Maciej W. Rozycki <macro@codesourcery.com>
* remote.c (putpkt_for_catch_errors): Remove function.
(remote_kill): Handle TARGET_CLOSE_ERROR from the kill packet
gracefully.
Yao Qi [Thu, 15 Aug 2013 01:09:08 +0000 (09:09 +0800)]
Fix PR remote/15974
In remote-notif.c:handle_notification, we have a loop,
for (i = 0; i < ARRAY_SIZE (notifs); i++)
{
nc = notifs[i];
if (strncmp (buf, nc->name, strlen (nc->name)) == 0
&& buf[strlen (nc->name)] == ':')
break;
}
/* We ignore notifications we don't recognize, for compatibility
with newer stubs. */
if (nc == NULL)
return;
If the notification is not in the list 'notifs', the last entry is
used, which is wrong. It should be NULL. This patch fixes it.
gdb:
2013-12-02 Pedro Alves <palves@redhat.com>
PR remote/15974
* remote-notif.c (handle_notification): Return early if no
notification is found.
Joel Brobecker [Sun, 17 Nov 2013 03:50:09 +0000 (22:50 -0500)]
Fix filestuff.c build error if RLIMIT_NOFILE not defined.
Not all systems supporting getrlimit also support RLIMIT_NOFILE
(Eg. All LynxOS systems appear to be lacking support for this).
So check its existance before using it.
gdb/ChangeLog:
* common/filestuff.c (fdwalk): Add "defined(RLIMIT_NOFILE)"
preprocessor check.
Joel Brobecker [Mon, 2 Dec 2013 03:10:29 +0000 (07:10 +0400)]
Makefile.in (HFILES_NO_SRCDIR): Remove "common/gdb_dirent.h".
This file no longer exists.
gdb/ChangeLog:
* Makefile.in (HFILES_NO_SRCDIR): Remove "common/gdb_dirent.h".
Joel Brobecker [Mon, 2 Dec 2013 03:05:10 +0000 (07:05 +0400)]
Remove last traces of gdb_stat.h.
This file no longer exists.
gdb/ChangeLog:
* Makefile.in (HFILES_NO_SRCDIR): Remove "common/gdb_stat.h".
* ctf.c (ctf_start): Remove obsolete comment.
Joel Brobecker [Mon, 2 Dec 2013 02:57:38 +0000 (06:57 +0400)]
Makefile.in (HFILES_NO_SRCDIR): Remove "common/gdb_string.h".
This file no longer exists...
gdb/ChangeLog:
* Makefile.in (HFILES_NO_SRCDIR): Remove "common/gdb_string.h".
Alan Modra [Sun, 1 Dec 2013 23:00:01 +0000 (09:30 +1030)]
daily update
Alan Modra [Sat, 30 Nov 2013 23:00:01 +0000 (09:30 +1030)]
daily update
Doug Evans [Sat, 30 Nov 2013 05:29:26 +0000 (21:29 -0800)]
Move .debug_gdb_script processing to auto-load.c.
Simplify handling of auto-loaded objfile scripts.
.debug_gdb_scripts was always intended to handle more than just python,
thus the rightful home for the code that processes it is not in py-foo.c.
This is just a cleanup to move the code to a better place.
This also simplifies the handling of the ${objfile}-${suffix} auto-loaded
scripts. There's no need for each of the the handlers to do is-safe-to-load
checking, or call maybe_add_script. Doing it in the caller removes the
duplication.
* auto-load.h (script_language): New members name, auto_load_enabled.
Add missing comments on struct members.
(auto_load_objfile_script): Delete.
* auto-load.c: #include "cli/cli-cmds.h".
(auto_load_gdb_scripts_enabled): New function.
(script_language_gdb): Update, add new members.
(source_gdb_script_for_objfile): Simplify, auto-load safe-checking
and call to maybe_add_script moved to caller.
(auto_load_objfile_script_1): Auto-load safe-checking and
call to maybe_add_script moved here.
(auto_load_objfile_script): Make static. Early exit if support for
scripting language hasn't been compiled in, or auto-loading has been
disabled.
(source_section_scripts): Argument "source_name" renamed to
"section_name". All uses updated. Replace uses of AUTO_SECTION_NAME
with section_name. Skip loading script if support for scripting
language hasn't been compiled in, or auto-loading has been disabled.
Call language->source_script_for_objfile instead of calling
source_python_script_for_objfile directly.
(load_auto_scripts_for_objfile): Update.
* python/py-auto-load.c: Delete #include "cli/cli-cmds.h".
(gdbpy_load_auto_script_for_objfile): Delete.
(auto_load_python_scripts_enabled): New function.
(script_language_python): Update, add new members.
(gdbpy_script_language_defn): New function.
* python/python.h (gdbpy_load_auto_scripts_for_objfile): Delete.
(gdbpy_script_language_defn): Declare.
* auto-load.c (AUTO_SECTION_NAME): Moved here and renamed from
py-auto-load.c, GDBPY_AUTO_SECTION_NAME.
(source_section_scripts): Moved here from py-auto-load.c.
(auto_load_section_scripts): Ditto.
* python/py-auto-load.c (GDBPY_AUTO_SECTION_NAME): Moved to
auto-load.c, renamed AUTO_SECTION_NAME.
(source_section_scripts, auto_load_section_scripts): Moved to
auto-load.c.
Yao Qi [Tue, 27 Nov 2012 09:59:49 +0000 (17:59 +0800)]
Fix typo "checksm"
Fix typo "checksm".
gdb:
2013-11-30 Yao Qi <yao@codesourcery.com>
* remote.c (getpkt_or_notif_sane_1): Fix typo "checksm".
Alan Modra [Fri, 29 Nov 2013 23:00:01 +0000 (09:30 +1030)]
daily update
Sergio Durigan Junior [Fri, 29 Nov 2013 22:25:18 +0000 (20:25 -0200)]
Remove gdb_string.h from gdbarch.sh
This commit removes the "#include gdb_string.h" from gdbarch.sh, fixing
a small nit caused by Tom's commit
0e9f083f4cb94a9dc861f38ba151aac06efce2b8.
Checked-in as obvious.
2013-11-29 Sergio Durigan Junior <sergiodj@redhat.com>
* gdbarch.sh: Remove include of "gdb_string.h", replace by
<string.h>.
H.J. Lu [Fri, 29 Nov 2013 21:33:42 +0000 (13:33 -0800)]
Remove -lpthread -ldl and add -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/
2013-11-29 Marek Polacek <polacek@redhat.com>
* bootstrap-ubsan.mk (POSTSTAGE1_LDFLAGS): Remove -lpthread -ldl.
Add -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/.
Doug Evans [Fri, 29 Nov 2013 20:34:32 +0000 (12:34 -0800)]
* python/py-auto-load.c (source_section_scripts): Move comment to
more relevant location.
Doug Evans [Fri, 29 Nov 2013 20:00:47 +0000 (12:00 -0800)]
Remove trailing whitespace.
Whitespace cleanup.
* python/py-breakpoint.c: Remove trailing whitespace.
* python/py-cmd.c: Ditto.
* python/py-evts.c: Ditto.
* python/py-finishbreakpoint.c: Ditto.
* python/py-frame.c: Ditto.
* python/py-function.c: Ditto.
* python/py-inferior.c: Ditto.
* python/py-infthread.c: Ditto.
* python/py-param.c: Ditto.
* python/py-prettyprint.c: Ditto.
* python/py-symbol.c: Ditto.
* python/py-type.c: Ditto.
* python/py-utils.c: Ditto.
* python/py-value.c: Ditto.
* python/python-internal.h: Ditto.
* python/python.c: Ditto.
H.J. Lu [Fri, 29 Nov 2013 19:07:49 +0000 (11:07 -0800)]
Add -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/
* bootstrap-asan.mk (POSTSTAGE1_LDFLAGS): Add
-B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/.
H.J. Lu [Fri, 29 Nov 2013 19:06:55 +0000 (11:06 -0800)]
Add -ldl to POSTSTAGE1_LDFLAGS
2013-11-19 Marek Polacek <polacek@redhat.com>
* bootstrap-ubsan.mk (POSTSTAGE1_LDFLAGS): Add -ldl.
H.J. Lu [Fri, 29 Nov 2013 19:05:23 +0000 (11:05 -0800)]
Add -ffat-lto-objects to STAGE[23]_CFLAGS
2013-11-18 Jan Hubicka <jh@suse.cz>
* bootstrap-lto.mk: Use -ffat-lto-objects.
H.J. Lu [Fri, 29 Nov 2013 19:03:20 +0000 (11:03 -0800)]
Add the missing ChangeLog entry
Pedro Alves [Fri, 29 Nov 2013 15:25:46 +0000 (15:25 +0000)]
UNWIND_NULL_ID is no longer used anywhere. Update comments.
Unfortunately, UNWIND_NULL_ID is exported to Python as
gdb.FRAME_UNWIND_NULL_ID so we can't really eliminate it.
(I'd assume scripts just check the result of Frame.unwind_stop_reason,
and compare it to gdb.FRAME_UNWIND_NO_REASON. That at most, they'll
pass the result of Frame.unwind_stop_reason to
gdb.frame_stop_reason_string. I'd prefer to just get rid of it, but
because we make an API promise, we get to keep this around for
compatibility, in case a script does refer to gdb.FRAME_UNWIND_NULL_ID
directly.)
gdb/
2013-11-29 Pedro Alves <palves@redhat.com>
* unwind_stop_reasons.def (UNWIND_NULL_ID): Update comment.
gdb/doc/
2013-11-29 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Frames In Python) <gdb.FRAME_UNWIND_NULL_ID>:
Update comment.
Pedro Alves [Fri, 29 Nov 2013 14:50:26 +0000 (14:50 +0000)]
Plug target side conditions and commands leaks.
The memory management of bp_location->target_info.conditions|tcommands
is currently a little fragile. If the target reports support for
target conditions or commands, and then target side breakpoint support
is disabled, or some error is thrown before remote_add_target_side_XXX
is called, we'll leak these lists. This patch makes us free these
lists when the locations are deleted, and also, just before recreating
the commands|conditions lists.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/
2013-11-29 Pedro Alves <palves@redhat.com>
* breakpoint.c (build_target_condition_list): Release previous
conditions.
(build_target_command_list): Release previous commands.
(bp_location_dtor): Release target conditions and commands.
* remote.c (remote_add_target_side_condition): Don't release
conditions.
(remote_add_target_side_commands): Don't release commands.
Yao Qi [Wed, 27 Nov 2013 10:01:05 +0000 (18:01 +0800)]
Delegate to target_ops->beneath for TARGET_OBJECT_RAW_MEMORY
GDB on x86_64-linux is unable to disassemble on core-file target.
$ ./gdb ./testsuite/gdb.base/corefile
(gdb) core-file ./testsuite/gdb.base/corefile.core
(gdb) disassemble main
Dump of assembler code for function main:
0x0000000000400976 <+0>: Cannot access memory at address 0x400976
However, it works if we turn code-cache off.
(gdb) set code-cache off
(gdb) disassemble main,+4
Dump of assembler code from 0x400976 to 0x40097a:
0x0000000000400976 <main+0>: push %rbp
0x0000000000400977 <main+1>: mov %rsp,%rbp
End of assembler dump.
When code-cache is off, GDB will iterate target_ops from top to bottom
and call to_xfer_partial. When current_target is "core", it will call
to_xfer_partial of target "exec", which reads the contents for
disassemble. However, dcache uses TARGET_OBJECT_RAW_MEMORY to read,
but target_xfer_partial doesn't delegate requests to beneath for
TARGET_OBJECT_RAW_MEMORY.
This patch factors out the iteration from top to bottom to a new
function, raw_memory_xfer_partial, and use it for
TARGET_OBJECT_RAW_MEMORY.
Regression tested on x86_64-linux.
gdb:
2013-11-29 Yao Qi <yao@codesourcery.com>
Pedro Alves <palves@redhat.com>
* dcache.c (dcache_read_line): Use current_target.beneath
instead of ¤t_target.
* target.c (memory_xfer_partial_1): Factor code out to ...
(raw_memory_xfer_partial): ... it. New function.
(target_xfer_partial): Call raw_memory_xfer_partial if OBJECT
is TARGET_OBJECT_RAW_MEMORY.
Alan Modra [Thu, 28 Nov 2013 23:00:01 +0000 (09:30 +1030)]
daily update
Doug Evans [Thu, 28 Nov 2013 22:54:32 +0000 (14:54 -0800)]
Rename breakpoint_object to gdbpy_breakpoint_object.
* breakpoint.h (gdbpy_breakpoint_object): Renamed from
breakpoint_object. All uses updated.
* python/python-internal.h (gdbpy_breakpoint_object): Renamed from
breakpoint_object. All uses updated.
* python.c (*): All uses of breakpoint_object updated.
* python.h (*): All uses of breakpoint_object updated.
* python/py-breakpoint.c (*): All uses of breakpoint_object updated.
* python/py-finishbreakpoint.c (*): Ditto.
Doug Evans [Thu, 28 Nov 2013 22:31:55 +0000 (14:31 -0800)]
fix spelling in previous entry
Doug Evans [Thu, 28 Nov 2013 22:30:59 +0000 (14:30 -0800)]
* configure.ac: Add comments delineating libpython and libmcheck.
* configure: Regenerate.
Andrew Burgess [Thu, 28 Nov 2013 18:54:20 +0000 (18:54 +0000)]
Print entirely unavailable struct/union values as a single <unavailable>.
When printing an entirely optimized out structure/class/union, we
print a single <optimized out> instead of printing <optimized out> for
each field.
This patch makes an entirely unavailable structure/class/union be
likewise displayed with a single "<unavailable>" rather than the whole
object with all fields <unavailable>.
This seems good because this way the user can quickly tell whether the
whole value is unavailable, rather than having to skim all fields.
Consistency with optimized out values also seems to be a good thing to
have.
A few updates to gdb.trace/unavailable.exp where required.
Tested on x86_64 Fedora 17, native gdbserver.
gdb/
2013-11-28 Andrew Burgess <aburgess@broadcom.com>
Pedro Alves <palves@redhat.com>
* valprint.c (value_check_printable): If the value is entirely
unavailable, print a single "<unavailable>" instead of printing
all subfields.
gdb/testsuite/
2013-11-28 Andrew Burgess <aburgess@broadcom.com>
* gdb.trace/unavailable.exp (gdb_collect_args_test): Update
expected results.
(gdb_collect_locals_test): Likewise.
(gdb_collect_globals_test): Likewise.
Pedro Alves [Thu, 28 Nov 2013 18:09:41 +0000 (18:09 +0000)]
get_prev_frame, stop_reason != UNWIND_NO_REASON, add frame debug output.
The stop_reason != UNWIND_NO_REASON doesn't currently have "set debug
frame" output. This patch makes it print the stop_reason enum value
as a string.
gdb/
2013-11-28 Pedro Alves <palves@redhat.com>
* frame.c (get_prev_frame_1) <stop_reason != UNWIND_NO_REASON>:
Add "set debug frame" output.
(frame_stop_reason_symbol_string): New function.
Pedro Alves [Thu, 28 Nov 2013 15:48:51 +0000 (15:48 +0000)]
get_prev_frame, outer_frame_id and unwind->stop_reason checks are redundant.
After the previous patch, it should be clear that the
this_frame->unwind->stop_reason check is redundant with the
outer_frame_id check just below. We can now move the frame_id_eq
comparison to the default this_frame->unwind->stop_reason callback.
Tested on x86_64 Fedora 17.
gdb/
2013-11-28 Pedro Alves <palves@redhat.com>
* frame-unwind.c (default_frame_unwind_stop_reason): Return
UNWIND_OUTERMOST if the frame's ID is outer_frame_id.
* frame.c (get_prev_frame_1): Remove outer_frame_id check.
Pedro Alves [Thu, 28 Nov 2013 15:44:58 +0000 (15:44 +0000)]
get_prev_frame, UNWIND_NULL_ID -> UNWIND_OUTERMOST
- The UNWIND_NULL_ID check in get_prev_frame_1 used to really be
against null_frame_id, back before we had outer_frame_id. We didn't
have UNWIND_OUTERMOST when outer_frame_id was added, but we do now,
and it's more accurate.
- It used to be necessary to check for the sentinel frame explicitly
because that uses null_frame_id for frame id. Since no other frame
can have that id nowadays (it's asserted by compute_frame_id), we
don't need that explicit check.
Tested on x86_64 Fedora 17.
gdb/
2013-11-28 Pedro Alves <palves@redhat.com>
* frame.c (get_prev_frame_1): If the frame id is outer_frame_id,
set the unwind stop reason to UNWIND_OUTERMOST, not
UNWIND_NULL_ID. Remove explicit check for sentinel frame.
Pedro Alves [Thu, 28 Nov 2013 17:26:55 +0000 (17:26 +0000)]
register: "optimized out" -> "not saved".
Another spot that missed the previous related text adjustments.
Tested on x86_64 Fedora 17.
gdb/
2013-11-28 Pedro Alves <palves@redhat.com>
* frame.c (frame_unwind_register): Say the register was "not
saved" instead of "optimized out".
Pedro Alves [Thu, 28 Nov 2013 17:27:36 +0000 (17:27 +0000)]
Fix PR 16152's ChangeLog entry.
Mention PR 16152. Fix formatting. Make wording match commit log.
Yao Qi [Mon, 26 Aug 2013 14:09:12 +0000 (22:09 +0800)]
GDB perf test on disassemble
This patch adds a test case to test the performance of GDB doing
disassembly.
gdb/testsuite/
2013-11-28 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (with_gdb_prompt): New proc.
* gdb.perf/disassemble.exp: New.
* gdb.perf/disassemble.py: New.
Alan Modra [Wed, 27 Nov 2013 23:00:02 +0000 (09:30 +1030)]
daily update
Steffen Sledz [Wed, 27 Nov 2013 18:51:49 +0000 (18:51 +0000)]
gdb: fix cygwin check in configure script
Avoid false positives if the search pattern "lose" is found in path
descriptions in comments generated by the preprocessor.
See <https://sourceware.org/bugzilla/show_bug.cgi?id=16152>.
gdb/
2013-11-27 Steffen Sledz <sledz@dresearch-fe.de>
* configure.ac: Tighten Cygwin detection check.
* configure: Rebuild.
Pedro Alves [Wed, 27 Nov 2013 17:55:38 +0000 (17:55 +0000)]
Fix type of not saved registers.
value_of_register_lazy uses the type of REGNUM in FRAME, but given
multi-arch, the arch of FRAME might be different from the previous
frame's arch, and therefore the type of register REGNUM should be
retrieved from the unwound arch. This used to be correct before the
previous change.
Tested on x86_64 Fedora 17.
gdb/
2013-11-27 Pedro Alves <palves@redhat.com>
* frame-unwind.c (frame_unwind_got_optimized): Use the type of the
register in the previous frame's arch.
Pedro Alves [Wed, 27 Nov 2013 17:49:59 +0000 (17:49 +0000)]
Make "set debug frame 1" output print <not saved> instead of <optimized out>.
"set debug frame 1" is printing "<optimized out>" for not saved
registers. That's because the unwinders are returning optimized out
not_lval values instead of optimized out lval_register values. "<not
saved>" is how val_print_optimized_out prints lval_register values.
...
- { frame_unwind_register_value (frame=0,regnum=7(rsp),...) -> <optimized out> }
+ { frame_unwind_register_value (frame=0,regnum=7(rsp),...) -> <not saved> }
...
Tested on x86_64 Fedora 17.
2013-11-27 Pedro Alves <palves@redhat.com>
* frame-unwind.c (frame_unwind_got_optimized): Return
an lval_register value instead of a not_lval value.
Andrew Burgess [Wed, 27 Nov 2013 17:49:59 +0000 (17:49 +0000)]
Make "set debug frame 1" use the standard print routine for optimized out values.
...
- { frame_unwind_register_value (frame=0,regnum=7(rsp),...) -> optimized out }
+ { frame_unwind_register_value (frame=0,regnum=7(rsp),...) -> <optimized out> }
...
Tested on x86_64 Fedora 17.
2013-11-27 Andrew Burgess <aburgess@broadcom.com>
* frame.c: Include "valprint.h".
(frame_unwind_register_value): Use value_optimized_out.
* value.c (value_fetch_lazy): Likewise.
Kyrylo Tkachov [Wed, 27 Nov 2013 13:43:39 +0000 (13:43 +0000)]
[ld/testsuite/]
2013-11-27 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* ld-plugin/lto.exp: Add -ffat-lto-objects.
* lib/ld-lib.exp (check_lto_available): Likewise.
Luis Machado [Wed, 27 Nov 2013 12:39:26 +0000 (10:39 -0200)]
* gdb.base/callfuncs.c (main): Assign malloc's return value
and free it afterwards.
* gdb.base/charset-malloc.c (malloc_stub): Likewise.
* gdb.base/printcmds.c (main): Likewise.
* gdb.base/randomize.c (main): Free "p" and change breakpoint
marker position.
* gdb.base/setvar.c (dummy): Assign malloc's return value
and free it afterwards.
Tristan Gingold [Thu, 21 Nov 2013 11:00:48 +0000 (12:00 +0100)]
Improve dump of xdata/pdata on x86_64.
bfd/
2013-11-27 Tristan Gingold <gingold@adacore.com>
* pei-x86_64.c (pex_regs): Make it const. Add comments.
(pex64_get_runtime_function): Do not split UnwindData.
(pex64_get_unwind_info): Extract the chain and the handler.
(pex64_xdata_print_uwd_codes): Rewritten: do not reverse print
the opcode, handle version 2, add consistency check, make the
code host neutral.
(pex64_dump_xdata): Change arguments to pass the section and its
content. Handle version 2, change output.
(pex64_bfd_print_pdata): Add comments, load section for xdata.
Avoid duplicate outputs.
include/coff
2013-11-27 Tristan Gingold <gingold@adacore.com>
* pe.h (struct pex64_runtime_function): Remove isChained.
(UWOP_SAVE_XMM): Add comment.
(struct pex64_unwind_info): Remove extra fields.
Richard Sandiford [Wed, 27 Nov 2013 09:11:06 +0000 (09:11 +0000)]
binutils/testsuite/
2013-11-27 Matthew Fortune <matthew.fortune@imgtec.com>
* binutils-all/objcopy.exp: Consider mips-mti-elf the same as
mips-sde-elf
* binutils-all/readelf.exp: Likewise
gas/testsuite/
2013-11-27 Matthew Fortune <matthew.fortune@imgtec.com>
* gas/mips/mips.exp: Consider mips-mti-elf the same as mips-sde-elf
ld/testsuite/
2013-11-27 Matthew Fortune <matthew.fortune@imgtec.com>
* ld-mips-elf/mips-elf.exp: Consider mips-mti-elf the same as
mips-sde-elf
Alan Modra [Tue, 26 Nov 2013 23:00:01 +0000 (09:30 +1030)]
daily update
H.J. Lu [Tue, 26 Nov 2013 19:25:25 +0000 (11:25 -0800)]
Fix a typo
H.J. Lu [Tue, 26 Nov 2013 19:17:08 +0000 (11:17 -0800)]
Add HOSTING_SLIBS and use it for -pie
ld/
PR ld/16259
* Makefile.am (HOSTING_SLIBS): New.
* configure.host (HOSTING_SLIBS): New. Used for PIE.
* configure.in (HOSTING_SLIBS): New AC_SUBST.
* Makefile.in: Regenerated.
* configure: Likewise.
ld/testsuite/
PR ld/16259
* config/default.exp (get_target_emul): Also set HOSTING_SLIBS.
* lib/ld-lib.exp (default_ld_link): Use HOSTING_SLIBS for -pie.
Andrew Burgess [Tue, 26 Nov 2013 16:28:33 +0000 (16:28 +0000)]
Tighten regexp in gdb.base/setshow.exp
https://sourceware.org/ml/gdb-patches/2013-11/msg00817.html
gdb/testsuite/ChangeLog
* gdb.base/setshow.exp: Add $gdb_prompt to the patterns in
gdb_test_multiple.
ccoutant [Fri, 22 Nov 2013 22:25:49 +0000 (22:25 +0000)]
Fix demangler to handle conversion operators correctly.
libiberty/
PR other/59195
* cp-demangle.c (struct d_info_checkpoint): New struct.
(struct d_print_info): Add current_template field.
(d_operator_name): Set flag when processing a conversion
operator.
(cplus_demangle_type): When processing <template-args> for
a conversion operator, backtrack if necessary.
(d_expression_1): Renamed from d_expression.
(d_expression): New wrapper around d_expression_1.
(d_checkpoint): New function.
(d_backtrack): New function.
(d_print_init): Initialize current_template.
(d_print_comp): Set current_template.
(d_print_cast): Put current_template in scope for
printing conversion operator name.
(cplus_demangle_init_info): Initialize is_expression and
is_conversion.
* cp-demangle.h (struct d_info): Add is_expression and
is_conversion fields.
* testsuite/demangle-expected: New test cases.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205292
138bc75d-0d04-0410-961f-
82ee72b054a4
Andrew Burgess [Tue, 26 Nov 2013 16:21:53 +0000 (16:21 +0000)]
Mark entirely optimized out value as non-lazy.
If a value is entirely optimized out, then there's nothing for
value_fetch_lazy to fetch. Sequences like:
if (value_lazy (retval))
value_fetch_lazy (retval);
End up allocating the value contents buffer, wasting memory, for no
use.
gdb/ChangeLog
2013-11-26 Andrew Burgess <aburgess@broadcom.com>
* value.c (allocate_optimized_out_value): Mark value as non-lazy.
Will Newton [Mon, 25 Nov 2013 14:44:59 +0000 (14:44 +0000)]
bfd/elfnn-aarch64.c: Handle static links with ifunc correctly.
The code for handling GOT references to ifunc symbols in static links
was missing.
bfd/ChangeLog:
2013-11-26 Will Newton <will.newton@linaro.org>
* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol):
Handle STT_GNU_IFUNC symbols correctly in static links.
ld/testsuite/ChangeLog:
2013-11-26 Will Newton <will.newton@linaro.org>
* ld-aarch64/aarch64-elf.exp: Add ifunc-22.
* ld-aarch64/ifunc-22.d: New file.
* ld-aarch64/ifunc-22.s: Likewise.
Will Newton [Mon, 25 Nov 2013 11:07:07 +0000 (11:07 +0000)]
bfd/elfnn-aarch64.c: Fix miscalculation of GOTPLT offset for ifunc syms.
The .got.plt header size was not being correctly taken into account
when calculating the offset for relocations against ifunc symbols.
bfd/ChangeLog:
2013-11-26 Will Newton <will.newton@linaro.org>
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Ensure
PLT_INDEX is calculated using correct header size.
ld/testsuite/ChangeLog:
2013-11-26 Will Newton <will.newton@linaro.org>
* ld-aarch64/aarch64-elf.exp: Add ifunc-21 test.
* ld-aarch64/ifunc-21.d: New file.
* ld-aarch64/ifunc-21.s: Likewise.
Tom Tromey [Tue, 26 Nov 2013 14:47:56 +0000 (07:47 -0700)]
revert patch from 2013-11-22
This reverts
da2b2fdf57a96f7a5b6b153e94afb747e212b17f and some
follow-up patches. They were incorrect.
2013-11-26 Tom Tromey <tromey@redhat.com>
* dwarf2-frame.c (dwarf2_frame_cache): Revert patch from
2013-11-22.
2013-11-26 Tom Tromey <tromey@redhat.com>
* gdb.dwarf2/dw2-unspecified-ret-addr.S: Remove.
* gdb.dwarf2/dw2-unspecified-ret-addr.c: Remove.
* gdb.dwarf2/dw2-unspecified-ret-addr.exp: Remove.
Walfred Tedeschi [Tue, 26 Nov 2013 08:32:16 +0000 (08:32 +0000)]
Fix PR16193 - gdbserver aborts.
The MPX patch has broken the I386_XSTATE_SIZE macro. For AVX machines,
it ends up returning I386_XSTATE_SSE_SIZE. Where it first reads
I386_XSTATE_AVX_SIZE, it should have read I386_XSTATE_AVX:
#define I386_XSTATE_SIZE(XCR0) \
(((XCR0) & I386_XSTATE_BNDCFG) != 0 ? I386_XSTATE_BNDCFG_SIZE \
: (((XCR0) & I386_XSTATE_BNDREGS) != 0 ? I386_XSTATE_BNDCFG_SIZE \
- : (((XCR0) & I386_XSTATE_AVX_SIZE) != 0 ? I386_XSTATE_AVX_SIZE \
+ : (((XCR0) & I386_XSTATE_AVX) != 0 ? I386_XSTATE_AVX_SIZE \
: I386_XSTATE_SSE_SIZE)))
The patch goes a step further and improves readability of the macro,
by adding a couple other auxiliary macros.
2013-11-26 Walfred Tedeschi <walfred.tedeschi@intel.com>
* i386-xstate.h (I386_XSTATE_MPX): New Macro.
(I386_XSTATE_MPX_MASK): Makes use of I386_XSTATE_MPX.
(HAS_MPX): New macro.
(HAS_AVX): New macro.
(I386_XSTATE_SIZE): Uses HAS_MPX and HAS_AVX.
Alan Modra [Mon, 25 Nov 2013 23:00:01 +0000 (09:30 +1030)]
daily update
Keith Seitz [Mon, 25 Nov 2013 21:37:08 +0000 (13:37 -0800)]
PR c++/14819: Explicit class:: inside class scope does not work
https://sourceware.org/ml/gdb-patches/2013-11/msg00102.html
Steve Ellcey [Mon, 25 Nov 2013 21:31:43 +0000 (13:31 -0800)]
2013-11-25 Steve Ellcey <sellcey@mips.com>
* igen/Makefile.in (igen): Use BUILD_CFLAGS in link.
Yao Qi [Fri, 25 Oct 2013 08:12:20 +0000 (16:12 +0800)]
GDB perf test on backtrace
gdb/testsuite/
2013-11-25 Yao Qi <yao@codesourcery.com>
* gdb.perf/backtrace.c: New.
* gdb.perf/backtrace.exp: New.
* gdb.perf/backtrace.py: New.
Alan Modra [Sun, 24 Nov 2013 23:00:01 +0000 (09:30 +1030)]
daily update
Yao Qi [Fri, 1 Nov 2013 04:28:54 +0000 (12:28 +0800)]
Use target_read_code in disassemble.
This patch teaches "disassembly" use code cache mechanism to read
target code.
gdb:
2013-11-24 Yao Qi <yao@codesourcery.com>
* disasm.c (dis_asm_read_memory): Call target_read_code
instead of target_read_memory.
Yao Qi [Fri, 1 Nov 2013 04:26:10 +0000 (12:26 +0800)]
set/show code-cache
Similar to stack cache, in this patch, we add
TARGET_OBJECT_CODE_MEMORY to read code from target and add a new
option "set code-cache on|off" to optimize code accesses by
using the target memory cache.
In V4:
- Remove "without affecting correctness" from NEWS and doc.
- Replace "ON" with "on" in doc.
- "access" -> "accesses".
In V3:
- Rename functions and variables.
- Update command help, doc and NEWS entry.
- Invalidate cache on option transitions, to align with
the behaviour of "stack-cache". Since cache invalidation is
transparent to users, users don't know option "stack-cache"
transitions cause code cache invalidation.
V2 was reviewed by Doug. There are some changes in V3, so I post it
here.
gdb:
2013-11-24 Yao Qi <yao@codesourcery.com>
* NEWS: Add note on new "set code-cache" option.
* target-dcache.c (code_cache_enabled_1): New variable.
(code_cache_enabled): New variable.
(show_code_cache, set_code_cache): New function.
(code_cache_enabled_p): New function.
(_initialize_target_dcache): Register command.
* target-dcache.h (code_cache_enabled_p): Declare.
* target.c (memory_xfer_partial_1):Handle
TARGET_OBJECT_CODE_MEMORY and code_cache_enabled.
(target_read_code): New function.
* target.h (enum target_object) <TARGET_OBJECT_CODE_MEMORY>:
New.
(target_read_code): Declare.
gdb/doc:
2013-11-24 Yao Qi <yao@codesourcery.com>
* gdb.texinfo (Caching Remote Data): Document new
"set/show stack-cache" option.
Yao Qi [Wed, 20 Nov 2013 08:21:47 +0000 (16:21 +0800)]
Renaming in target-dcache.c
Hi,
This patch does some renamings on "stack-cache" related functions and
variables.
In the review to "code cache" series v2, we have some discussions on the
name of predicate function 'stack_cache_enabled', and have some options,
1 keep it unchanged, as it is already a predicate clearly,
2 rename it to stack_cache_enabled_p,
3 rename it to enable_stack_cache_p,
I choose #2, because 'stack_cache_enabled' is a predicate, but
it's better to add "_p" suffix to stress this. There are some other
similar patterns used in GDB source, such as unop_user_defined_p
and agent_loaded_p.
Then, I have to rename variable stack_cache_enabled_p to something
else. The option is "stack-cache", so I'd like to name the variable
associated with this command as "stack_cache". Similarly, the commands
associated with this command should be renamed to "set_stack_cache"
and "show_stack_cache" respectively.
gdb:
2013-11-24 Yao Qi <yao@codesourcery.com>
* target-dcache.c (stack_cache_enabled_p_1): Rename to ...
(stack_cache_enabled_1): ... this. New variable.
(stack_cache_enabled_p): Rename to ...
(stack_cache_enabled): ... this. New variable.
(set_stack_cache_enabled_p): Rename to ...
(set_stack_cache): ... this. Update caller.
(show_stack_cache_enabled_p): Rename to ...
(show_stack_cache): ... this. Update caller.
(stack_cache_enabled): Rename to ...
(stack_cache_enabled_p): ... this. Update caller.
(_initialize_target_dcache): Replace "data cache" with
"target memory cache".
* target-dcache.h (stack_cache_enabled): Remove declaration.
(stack_cache_enabled_p): Add declaration.
Yao Qi [Fri, 25 Oct 2013 08:09:31 +0000 (16:09 +0800)]
GDB perf test on single step
gdb/testsuite:
2013-11-24 Yao Qi <yao@codesourcery.com>
* gdb.perf/single-step.c: New.
* gdb.perf/single-step.exp: New.
* gdb.perf/single-step.py: New.
Yao Qi [Fri, 22 Nov 2013 01:28:42 +0000 (09:28 +0800)]
Write "ON" and "OFF" in lower case in GDB doc.
gdb/doc:
2013-11-24 Yao Qi <yao@codesourcery.com>
* gdb.texinfo (Caching Target Data): Replace "ON" with "on".
(Maintenance Commands): Replace "ON" and "OFF" with "on" and
"off" respectively.
Doug Evans [Sun, 24 Nov 2013 00:43:29 +0000 (16:43 -0800)]
* gdb.base/ena-dis-br.exp: Add missing quote to "step after continue
with ignore count".
Doug Evans [Sun, 24 Nov 2013 00:03:47 +0000 (16:03 -0800)]
Test name tweaks for py-value.exp.
* gdb.python/py-value.exp (test_lazy_strings): Tweak test names.
(test_subscript_regression): Ditto.
(top level): Run test_subscript_regression for c++ with "c++" prefix.
Doug Evans [Sat, 23 Nov 2013 23:54:05 +0000 (15:54 -0800)]
* gdb.python/py-type.exp (test_enums): Fix typo.
Doug Evans [Sat, 23 Nov 2013 23:45:43 +0000 (15:45 -0800)]
* gdb.python/py-symbol.exp: Add some comments. Make all test names unique.
Doug Evans [Sat, 23 Nov 2013 23:20:42 +0000 (15:20 -0800)]
* gdb.python/py-symbol.exp: Fix whitespace.
Doug Evans [Sat, 23 Nov 2013 23:15:17 +0000 (15:15 -0800)]
Fix long line in earlier entry.
Doug Evans [Sat, 23 Nov 2013 23:08:28 +0000 (15:08 -0800)]
* gdb.python/python.exp: Don't call skip_python_tests, we still want
to test some things in the case where python is not configured in.
Alan Modra [Sat, 23 Nov 2013 23:00:01 +0000 (09:30 +1030)]
daily update
Doug Evans [Sat, 23 Nov 2013 22:46:43 +0000 (14:46 -0800)]
* python/py-frame.c (gdbpy_initialize_frames): Remove FIRST_ERROR,
superfluous.
Doug Evans [Sat, 23 Nov 2013 22:36:57 +0000 (14:36 -0800)]
* python/py-frame.c (frapy_block): Fix error message text.
Doug Evans [Sat, 23 Nov 2013 19:47:24 +0000 (11:47 -0800)]
cli/cli-script.c (multi_line_command_p): New function.
* cli/cli-script.c (multi_line_command_p): New function.
(recurse_read_control_structure, read_command_lines_1): Call it.
(execute_control_command): Consistently have a blank line between
each case.
Yao Qi [Tue, 19 Nov 2013 11:00:38 +0000 (19:00 +0800)]
Update doc on displayhint in command -var-list-children
Hi,
When using command -var-list-children, "displayhint" appears in the result of
each child, shown as the following output.
-var-list-children ss1 ^M
^done,numchild="2",displayhint="pp_ss",children=[child={name="ss1.a",exp="a",numchild="0",type="struct s",thread-id="1",displayhint="pp_s",dynamic="1"},child={name="ss1.b",exp="b",numchild="0",type="struct s",thread-id="1",displayhint="pp_s",dynamic="1"}],has_more="0"
Current doc on command -var-list-children doesn't reflect this. This
patch is to fix it.
gdb/doc:
2013-11-23 Yao Qi <yao@codesourcery.com>
* gdb.texinfo (GDB/MI Variable Objects): Add the description
of "displayhint" to the table about child results.
Cary Coutant [Fri, 22 Nov 2013 23:46:51 +0000 (15:46 -0800)]
Add check for which library is needed for dlopen.
gold/
PR gold/16203
* configure.ac: Add check for which library is needed for
dlopen.
* configure: Regenerate.
Cary Coutant [Fri, 22 Nov 2013 23:38:24 +0000 (15:38 -0800)]
Use in-tree assembler for exception_x86_64_bnd_test.
gold/
* testsuite/Makefile.am (exception_x86_64_bnd_test): Use in-tree
assembler.
* testsuite/Makefile.in: Regenerate.
Alan Modra [Fri, 22 Nov 2013 23:00:01 +0000 (09:30 +1030)]
daily update
Alan Modra [Fri, 22 Nov 2013 22:25:31 +0000 (08:55 +1030)]
Import config.sub and config.guess from upstream.
Sterling Augustine [Fri, 22 Nov 2013 21:55:32 +0000 (13:55 -0800)]
2013-11-22 Sterling Augustine <saugustine@google.com>
PR gdb/16196:
* valprint.c (read_string): Set new variable fetchlen based on
fetchlimit and size. Use it in call to partial_memory_read.
Update comment.
Sterling Augustine [Fri, 22 Nov 2013 21:55:32 +0000 (13:55 -0800)]
2013-11-22 Sterling Augustine <saugustine@google.com>
PR gdb/16196:
* valprint.c (read_string): Set new variable fetchlen based on
fetchlimit and size. Use it in call to partial_memory_read.
Update comment.
Pedro Alves [Fri, 22 Nov 2013 19:18:28 +0000 (19:18 +0000)]
Rename gdb.dwarf2/dw2-bad-cfi.* to gdb.dwarf2/dw2-unspecified-ret-addr.*.
gdb/testsuite/
2013-11-22 Pedro Alves <palves@redhat.com>
* gdb.dwarf2/dw2-bad-cfi.S: Rename to ...
* gdb.dwarf2/dw2-unspecified-ret-addr.S: ... this. Adjust.
* gdb.dwarf2/dw2-bad-cfi.c: Rename to ...
* gdb.dwarf2/dw2-unspecified-ret-addr.c: ... this.
* gdb.dwarf2/dw2-bad-cfi.exp: Rename to ...
* gdb.dwarf2/dw2-unspecified-ret-addr.exp: ... this.
Tom Tromey [Fri, 22 Nov 2013 19:08:15 +0000 (12:08 -0700)]
update comment in dw2-bad-cfi.S.
Pedro asked me to add a comment to dw2-bad-cfi.S explaining the nature
of the badness.
I'm checking this in.
2013-11-22 Tom Tromey <tromey@redhat.com>
* gdb.dwarf2/dw2-bad-cfi.S: Update comment.
Tom Tromey [Wed, 13 Nov 2013 18:10:55 +0000 (11:10 -0700)]
handle an unspecified return address column
Debugging PR 16155 further, I found that the DWARF unwinder found the
function in question, but thought it had no registers saved
(fs->regs.num_regs == 0).
It seems to me that if a frame does not specify the return address
column, or if the return address column is explicitly marked as
DWARF2_FRAME_REG_UNSPECIFIED, then we should set the
"undefined_retaddr" flag and let the DWARF unwinder gracefully stop.
This patch implements that idea.
With this patch the backtrace works properly:
(gdb) bt
#0 0x0000007fb7ed485c in nanosleep () from /lib64/libc.so.6
#1 0x0000007fb7ed4508 in sleep () from /lib64/libc.so.6
#2 0x00000000004008bc in thread_function (arg=0x4) at threadapply.c:73
#3 0x0000007fb7fad950 in start_thread () from /lib64/libpthread.so.0
#4 0x0000007fb7f0956c in clone () from /lib64/libc.so.6
2013-11-22 Tom Tromey <tromey@redhat.com>
PR backtrace/16155:
* dwarf2-frame.c (dwarf2_frame_cache): Set undefined_retaddr if
the return address column is unspecified.
2013-11-22 Tom Tromey <tromey@redhat.com>
* gdb.dwarf2/dw2-bad-cfi.c: New file.
* gdb.dwarf2/dw2-bad-cfi.exp: New file.
* gdb.dwarf2/dw2-bad-cfi.S: New file.
Tom Tromey [Fri, 22 Nov 2013 17:38:44 +0000 (17:38 +0000)]
Detect infinite loop in value_fetch_lazy's lval_register handling.
If value_fetch_lazy loops infinitely while unwrapping lval_register
values, it means we either somehow ended up with two frames with the
same ID in the frame chain, or some code is trying to unwind behind
get_prev_frame's back (e.g., a frame unwind sniffer trying to unwind).
In any case, it should always be an internal error to end up in this
situation.
This patch adds a check and throws an internal error if the same frame
is returned.
2013-11-22 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
PR backtrace/16155
* value.c (value_fetch_lazy): Internal error if
get_frame_register_value returns the same register.
Cory Fields [Fri, 22 Nov 2013 14:54:33 +0000 (14:54 +0000)]
* windres.c (define_resource): Use zero for timestamp, making
output deterministic. time.h include is no longer needed.
* resres.c (res_append_resource): Likewise.
* pe-dll.c (fill_edata): Only use a real timestamp if
--insert-timestamp was used.
* emultempl/pe.em: Add the --insert-timestamp option.
* emultempl/pep.em: Likewise for 64bit.
* ld.texinfo: Document the --insert-timestamp option.
* libcoff-in.h: Add insert_timestamp flag to the pe_data struct.
* libcoff.h: Regenerate.
* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Only use a real
timestamp if --insert-timestamp was used.
Pedro Alves [Thu, 21 Nov 2013 15:20:09 +0000 (15:20 +0000)]
Make use of the frame stash to detect wider stack cycles.
Given we already have the frame id stash, which holds the ids of all
frames in the chain, detecting corrupted stacks with wide stack cycles
with non-consecutive dup frame ids is just as cheap as just detecting
cycles in consecutive frames:
#0 frame_id1
#1 frame_id2
#2 frame_id3
#3 frame_id1
#4 frame_id2
#5 frame_id3
#6 frame_id1
... forever ...
We just need to check whether the stash already knows about a given
frame id instead of comparing the ids of the previous/this frames.
Tested on x86_64 Fedora 17.
gdb/
2013-11-22 Pedro Alves <palves@redhat.com>
Tom Tromey <tromey@redhat.com>
* frame.c (frame_stash_add): Now returns whether a frame with the
same ID was already known.
(compute_frame_id): New function, factored out from get_frame_id.
(get_frame_id): No longer lazilly compute the frame id here.
(get_prev_frame_if_no_cycle): New function. Detects wider stack
cycles.
(get_prev_frame_1): Use it instead of get_prev_frame_raw directly,
and checking for stack cycles here.
Pedro Alves [Fri, 22 Nov 2013 11:51:59 +0000 (11:51 +0000)]
Don't let two frames with the same id end up in the frame chain.
The UNWIND_SAME_ID check is done between THIS_FRAME and the next frame
when we go try to unwind the previous frame. But at this point, it's
already too late -- we ended up with two frames with the same ID in
the frame chain. Each frame having its own ID is an invariant assumed
throughout GDB. This patch applies the UNWIND_SAME_ID detection
earlier, right after the previous frame is unwound, discarding the dup
frame if a cycle is detected.
The patch includes a new test that fails before the change. Before
the patch, the test causes an infinite loop in GDB, after the patch,
the UNWIND_SAME_ID logic kicks in and makes the backtrace stop with:
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
The test uses dwarf CFI to emulate a corrupted stack with a cycle. It
has a function with registers marked DW_CFA_same_value (most
importantly RSP/RIP), so that GDB computes the same ID for that frame
and its caller. IOW, something like this:
#0 - frame_id_1
#1 - frame_id_2
#2 - frame_id_3
#3 - frame_id_4
#4 - frame_id_4 <<<< outermost (UNWIND_SAME_ID).
(The test's code is just a copy of dw2-reg-undefined.S /
dw2-reg-undefined.c, adjusted to use DW_CFA_same_value instead of
DW_CFA_undefined, and to mark a different set of registers.)
The infinite loop is here, in value_fetch_lazy:
while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
{
frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
...
new_val = get_frame_register_value (frame, regnum);
}
get_frame_register_value can return a lazy register value pointing to
the next frame. This means that the register wasn't clobbered by
FRAME; the debugger should therefore retrieve its value from the next
frame.
To be clear, get_frame_register_value unwinds the value in question
from the next frame:
struct value *
get_frame_register_value (struct frame_info *frame, int regnum)
{
return frame_unwind_register_value (frame->next, regnum);
^^^^^^^^^^^
}
In other words, if we get a lazy lval_register, it should have the
frame ID of the _next_ frame, never of FRAME.
At this point in value_fetch_lazy, the whole relevant chunk of the
stack up to frame #4 has already been unwound. The loop always
"unlazies" lval_registers in the "next/innermost" direction, not in
the "prev/unwind further/outermost" direction.
So say we're looking at frame #4. get_frame_register_value in frame
#4 can return a lazy register value of frame #3. So the next
iteration, frame_find_by_id tries to read the register from frame #3.
But, since frame #4 happens to have same id as frame #3,
frame_find_by_id returns frame #4 instead. Rinse, repeat, and we have
an infinite loop.
This is an old latent problem, exposed by the recent addition of the
frame stash. Before we had a stash, frame_find_by_id(frame_id_4)
would walk over all frames starting at the current frame, and would
always find #3 first. The stash happens to return #4 instead:
struct frame_info *
frame_find_by_id (struct frame_id id)
{
struct frame_info *frame, *prev_frame;
...
/* Try using the frame stash first. Finding it there removes the need
to perform the search by looping over all frames, which can be very
CPU-intensive if the number of frames is very high (the loop is O(n)
and get_prev_frame performs a series of checks that are relatively
expensive). This optimization is particularly useful when this function
is called from another function (such as value_fetch_lazy, case
VALUE_LVAL (val) == lval_register) which already loops over all frames,
making the overall behavior O(n^2). */
frame = frame_stash_find (id);
if (frame)
return frame;
for (frame = get_current_frame (); ; frame = prev_frame)
{
gdb/
2013-11-22 Pedro Alves <palves@redhat.com>
PR 16155
* frame.c (get_prev_frame_1): Do the UNWIND_SAME_ID check between
this frame and the new previous frame, not between this frame and
the next frame.
gdb/testsuite/
2013-11-22 Pedro Alves <palves@redhat.com>
PR 16155
* gdb.dwarf2/dw2-dup-frame.S: New file.
* gdb.dwarf2/dw2-dup-frame.c: New file.
* gdb.dwarf2/dw2-dup-frame.exp: New file.
Pedro Alves [Fri, 22 Nov 2013 13:17:46 +0000 (13:17 +0000)]
Eliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer (move dwarf2_tailcall_sniffer_first elsewhere).
Two rationales, same patch.
TL;DR 1:
dwarf2_frame_cache recursion is evil. dwarf2_frame_cache calls
dwarf2_tailcall_sniffer_first which then recurses into
dwarf2_frame_cache.
TL;DR 2:
An unwinder trying to unwind is evil. dwarf2_frame_sniffer calls
dwarf2_frame_cache which calls dwarf2_tailcall_sniffer_first which
then tries to unwind the PC of the previous frame.
Avoid all that by deferring dwarf2_tailcall_sniffer_first until it's
really necessary.
Rationale 1
===========
A frame sniffer should not try to unwind, because that bypasses all
the validation checks done by get_prev_frame. The UNWIND_SAME_ID
scenario is one such case where GDB is currently broken because (in
part) of this (the next patch adds a test that would fail without
this).
GDB goes into an infinite loop in value_fetch_lazy, here:
while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
{
frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
...
new_val = get_frame_register_value (frame, regnum);
}
(top-gdb) bt
#0 value_fetch_lazy (val=0x11516d0) at ../../src/gdb/value.c:3510
#1 0x0000000000584bd8 in value_optimized_out (value=0x11516d0) at ../../src/gdb/value.c:1096
#2 0x00000000006fe7a1 in frame_register_unwind (frame=0x1492600, regnum=16, optimizedp=0x7fffffffcdec, unavailablep=0x7fffffffcde8, lvalp=0x7fffffffcdd8, addrp=
0x7fffffffcde0, realnump=0x7fffffffcddc, bufferp=0x7fffffffce10 "@\316\377\377\377\177") at ../../src/gdb/frame.c:940
#3 0x00000000006fea3a in frame_unwind_register (frame=0x1492600, regnum=16, buf=0x7fffffffce10 "@\316\377\377\377\177") at ../../src/gdb/frame.c:990
#4 0x0000000000473b9b in i386_unwind_pc (gdbarch=0xf54660, next_frame=0x1492600) at ../../src/gdb/i386-tdep.c:1771
#5 0x0000000000601dfa in gdbarch_unwind_pc (gdbarch=0xf54660, next_frame=0x1492600) at ../../src/gdb/gdbarch.c:2870
#6 0x0000000000693db5 in dwarf2_tailcall_sniffer_first (this_frame=0x1492600, tailcall_cachep=0x14926f0, entry_cfa_sp_offsetp=0x7fffffffcf00)
at ../../src/gdb/dwarf2-frame-tailcall.c:389
#7 0x0000000000690928 in dwarf2_frame_cache (this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/dwarf2-frame.c:1245
#8 0x0000000000690f46 in dwarf2_frame_sniffer (self=0x8e4980, this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/dwarf2-frame.c:1423
#9 0x000000000070203b in frame_unwind_find_by_frame (this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/frame-unwind.c:112
#10 0x00000000006fd681 in get_frame_id (fi=0x1492600) at ../../src/gdb/frame.c:408
#11 0x00000000007006c2 in get_prev_frame_1 (this_frame=0xdc1860) at ../../src/gdb/frame.c:1826
#12 0x0000000000700b7a in get_prev_frame (this_frame=0xdc1860) at ../../src/gdb/frame.c:2056
#13 0x0000000000514588 in frame_info_to_frame_object (frame=0xdc1860) at ../../src/gdb/python/py-frame.c:322
#14 0x000000000051784c in bootstrap_python_frame_filters (frame=0xdc1860, frame_low=0, frame_high=-1) at ../../src/gdb/python/py-framefilter.c:1396
#15 0x0000000000517a6f in apply_frame_filter (frame=0xdc1860, flags=7, args_type=CLI_SCALAR_VALUES, out=0xed7a90, frame_low=0, frame_high=-1)
at ../../src/gdb/python/py-framefilter.c:1492
#16 0x00000000005e77b0 in backtrace_command_1 (count_exp=0x0, show_locals=0, no_filters=0, from_tty=1) at ../../src/gdb/stack.c:1777
#17 0x00000000005e7c0f in backtrace_command (arg=0x0, from_tty=1) at ../../src/gdb/stack.c:1891
#18 0x00000000004e37a7 in do_cfunc (c=0xda4fa0, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:107
#19 0x00000000004e683c in cmd_func (cmd=0xda4fa0, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:1882
#20 0x00000000006f35ed in execute_command (p=0xcc66c2 "", from_tty=1) at ../../src/gdb/top.c:468
#21 0x00000000005f8853 in command_handler (command=0xcc66c0 "bt") at ../../src/gdb/event-top.c:435
#22 0x00000000005f8e12 in command_line_handler (rl=0xfe05f0 "@") at ../../src/gdb/event-top.c:632
#23 0x000000000074d2c6 in rl_callback_read_char () at ../../src/readline/callback.c:220
#24 0x00000000005f8375 in rl_callback_read_char_wrapper (client_data=0x0) at ../../src/gdb/event-top.c:164
#25 0x00000000005f876a in stdin_event_handler (error=0, client_data=0x0) at ../../src/gdb/event-top.c:375
#26 0x00000000005f72fa in handle_file_event (data=...) at ../../src/gdb/event-loop.c:768
#27 0x00000000005f67a3 in process_event () at ../../src/gdb/event-loop.c:342
#28 0x00000000005f686a in gdb_do_one_event () at ../../src/gdb/event-loop.c:406
#29 0x00000000005f68bb in start_event_loop () at ../../src/gdb/event-loop.c:431
#30 0x00000000005f83a7 in cli_command_loop (data=0x0) at ../../src/gdb/event-top.c:179
#31 0x00000000005eeed3 in current_interp_command_loop () at ../../src/gdb/interps.c:327
#32 0x00000000005ef8ff in captured_command_loop (data=0x0) at ../../src/gdb/main.c:267
#33 0x00000000005ed2f6 in catch_errors (func=0x5ef8e4 <captured_command_loop>, func_args=0x0, errstring=0x8b6554 "", mask=RETURN_MASK_ALL)
at ../../src/gdb/exceptions.c:524
#34 0x00000000005f0d21 in captured_main (data=0x7fffffffd9e0) at ../../src/gdb/main.c:1067
#35 0x00000000005ed2f6 in catch_errors (func=0x5efb9b <captured_main>, func_args=0x7fffffffd9e0, errstring=0x8b6554 "", mask=RETURN_MASK_ALL)
at ../../src/gdb/exceptions.c:524
#36 0x00000000005f0d57 in gdb_main (args=0x7fffffffd9e0) at ../../src/gdb/main.c:1076
#37 0x000000000045bb6a in main (argc=4, argv=0x7fffffffdae8) at ../../src/gdb/gdb.c:34
(top-gdb)
GDB is trying to unwind the PC register of the previous frame (frame
#5 above), starting from the frame being sniffed (the THIS frame).
But the THIS frame's unwinder says the PC of the previous frame is
actually the same as the previous's frame's next frame (which is the
same frame we started with, the THIS frame), therefore it returns an
lval_register lazy value with frame set to THIS frame. And so the
value_fetch_lazy loop never ends.
Rationale 2
===========
As an experiment, I tried making dwarf2-frame.c:read_addr_from_reg use
address_from_register. That caused a bunch of regressions, but it
actually took me a long while to figure out what was going on. Turns
out dwarf2-frame.c:read_addr_from_reg is called while computing the
frame's CFA, from within dwarf2_frame_cache. address_from_register
wants to create a register with frame_id set to the frame being
constructed. To create the frame id, we again call dwarf2_frame_cache,
which given:
static struct dwarf2_frame_cache *
dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
{
...
if (*this_cache)
return *this_cache;
returns an incomplete object to the caller:
static void
dwarf2_frame_this_id (struct frame_info *this_frame, void **this_cache,
struct frame_id *this_id)
{
struct dwarf2_frame_cache *cache =
dwarf2_frame_cache (this_frame, this_cache);
...
(*this_id) = frame_id_build (cache->cfa, get_frame_func (this_frame));
}
As cache->cfa is still 0 (we were trying to compute it!), and
get_frame_id recalls this id from here on, we end up with a broken
frame id in recorded for this frame. Later, when inspecting locals,
the dwarf machinery needs to know the selected frame's base, which
calls get_frame_base:
CORE_ADDR
get_frame_base (struct frame_info *fi)
{
return get_frame_id (fi).stack_addr;
}
which as seen above then returns 0 ...
So I gave up using address_from_register.
But, the pain of investigating this made me want to have GDB itself
assert that recursion never happens here. So I wrote a patch to do
that. But, it triggers on current mainline, because
dwarf2_tailcall_sniffer_first, called from dwarf2_frame_cache, unwinds
the this_frame.
A sniffer shouldn't be trying to unwind, exactly because of this sort
of tricky issue. The patch defers calling
dwarf2_tailcall_sniffer_first until it's really necessary, in
dwarf2_frame_prev_register (thus actually outside the sniffer path).
As this makes the call to dwarf2_frame_sniffer in dwarf2_frame_cache
unnecessary again, the patch removes that too.
Tested on x86_64 Fedora 17.
gdb/
2013-11-22 Pedro Alves <palves@redhat.com>
PR 16155
* dwarf2-frame.c (struct dwarf2_frame_cache)
<checked_tailcall_bottom, entry_cfa_sp_offset,
entry_cfa_sp_offset_p>: New fields.
(dwarf2_frame_cache): Adjust to use the new cache fields instead
of locals. Don't call dwarf2_tailcall_sniffer_first here.
(dwarf2_frame_prev_register): Call it here, but only once.
Pedro Alves [Fri, 22 Nov 2013 13:46:51 +0000 (13:46 +0000)]
Revert "Don't let two frames with the same id end up in the frame chain."
This reverts commit
be2c48b4d50b992ba83bc51f086e316621a03a14.
Pedro Alves [Fri, 22 Nov 2013 13:46:43 +0000 (13:46 +0000)]
Revert "Make use of the frame stash to detect wider stack cycles."
This reverts commit
f5b0ed3c8ce42b0dd6b6caa0b3d7b7e734311afe.
Pedro Alves [Fri, 22 Nov 2013 13:46:35 +0000 (13:46 +0000)]
Revert "Eliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer (move dwarf2_tailcall_sniffer_first elsewhere)."
This reverts commit
1dc8686c48e72fc02723d44ee0fecde0d233c74e.
Pedro Alves [Fri, 22 Nov 2013 13:17:46 +0000 (13:17 +0000)]
Eliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer (move dwarf2_tailcall_sniffer_first elsewhere).
Two rationales, same patch.
TL;DR 1:
dwarf2_frame_cache recursion is evil. dwarf2_frame_cache calls
dwarf2_tailcall_sniffer_first which then recurses into
dwarf2_frame_cache.
TL;DR 2:
An unwinder trying to unwind is evil. dwarf2_frame_sniffer calls
dwarf2_frame_cache which calls dwarf2_tailcall_sniffer_first which
then tries to unwind the PC of the previous frame.
Avoid all that by deferring dwarf2_tailcall_sniffer_first until it's
really necessary.
Rationale 1
===========
A frame sniffer should not try to unwind, because that bypasses all
the validation checks done by get_prev_frame. The UNWIND_SAME_ID
scenario is one such case where GDB is currently broken because (in
part) of this (the next patch adds a test that would fail without
this).
GDB goes into an infinite loop in value_fetch_lazy, here:
while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
{
frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
...
new_val = get_frame_register_value (frame, regnum);
}
(top-gdb) bt
#0 value_fetch_lazy (val=0x11516d0) at ../../src/gdb/value.c:3510
#1 0x0000000000584bd8 in value_optimized_out (value=0x11516d0) at ../../src/gdb/value.c:1096
#2 0x00000000006fe7a1 in frame_register_unwind (frame=0x1492600, regnum=16, optimizedp=0x7fffffffcdec, unavailablep=0x7fffffffcde8, lvalp=0x7fffffffcdd8, addrp=
0x7fffffffcde0, realnump=0x7fffffffcddc, bufferp=0x7fffffffce10 "@\316\377\377\377\177") at ../../src/gdb/frame.c:940
#3 0x00000000006fea3a in frame_unwind_register (frame=0x1492600, regnum=16, buf=0x7fffffffce10 "@\316\377\377\377\177") at ../../src/gdb/frame.c:990
#4 0x0000000000473b9b in i386_unwind_pc (gdbarch=0xf54660, next_frame=0x1492600) at ../../src/gdb/i386-tdep.c:1771
#5 0x0000000000601dfa in gdbarch_unwind_pc (gdbarch=0xf54660, next_frame=0x1492600) at ../../src/gdb/gdbarch.c:2870
#6 0x0000000000693db5 in dwarf2_tailcall_sniffer_first (this_frame=0x1492600, tailcall_cachep=0x14926f0, entry_cfa_sp_offsetp=0x7fffffffcf00)
at ../../src/gdb/dwarf2-frame-tailcall.c:389
#7 0x0000000000690928 in dwarf2_frame_cache (this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/dwarf2-frame.c:1245
#8 0x0000000000690f46 in dwarf2_frame_sniffer (self=0x8e4980, this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/dwarf2-frame.c:1423
#9 0x000000000070203b in frame_unwind_find_by_frame (this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/frame-unwind.c:112
#10 0x00000000006fd681 in get_frame_id (fi=0x1492600) at ../../src/gdb/frame.c:408
#11 0x00000000007006c2 in get_prev_frame_1 (this_frame=0xdc1860) at ../../src/gdb/frame.c:1826
#12 0x0000000000700b7a in get_prev_frame (this_frame=0xdc1860) at ../../src/gdb/frame.c:2056
#13 0x0000000000514588 in frame_info_to_frame_object (frame=0xdc1860) at ../../src/gdb/python/py-frame.c:322
#14 0x000000000051784c in bootstrap_python_frame_filters (frame=0xdc1860, frame_low=0, frame_high=-1) at ../../src/gdb/python/py-framefilter.c:1396
#15 0x0000000000517a6f in apply_frame_filter (frame=0xdc1860, flags=7, args_type=CLI_SCALAR_VALUES, out=0xed7a90, frame_low=0, frame_high=-1)
at ../../src/gdb/python/py-framefilter.c:1492
#16 0x00000000005e77b0 in backtrace_command_1 (count_exp=0x0, show_locals=0, no_filters=0, from_tty=1) at ../../src/gdb/stack.c:1777
#17 0x00000000005e7c0f in backtrace_command (arg=0x0, from_tty=1) at ../../src/gdb/stack.c:1891
#18 0x00000000004e37a7 in do_cfunc (c=0xda4fa0, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:107
#19 0x00000000004e683c in cmd_func (cmd=0xda4fa0, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:1882
#20 0x00000000006f35ed in execute_command (p=0xcc66c2 "", from_tty=1) at ../../src/gdb/top.c:468
#21 0x00000000005f8853 in command_handler (command=0xcc66c0 "bt") at ../../src/gdb/event-top.c:435
#22 0x00000000005f8e12 in command_line_handler (rl=0xfe05f0 "@") at ../../src/gdb/event-top.c:632
#23 0x000000000074d2c6 in rl_callback_read_char () at ../../src/readline/callback.c:220
#24 0x00000000005f8375 in rl_callback_read_char_wrapper (client_data=0x0) at ../../src/gdb/event-top.c:164
#25 0x00000000005f876a in stdin_event_handler (error=0, client_data=0x0) at ../../src/gdb/event-top.c:375
#26 0x00000000005f72fa in handle_file_event (data=...) at ../../src/gdb/event-loop.c:768
#27 0x00000000005f67a3 in process_event () at ../../src/gdb/event-loop.c:342
#28 0x00000000005f686a in gdb_do_one_event () at ../../src/gdb/event-loop.c:406
#29 0x00000000005f68bb in start_event_loop () at ../../src/gdb/event-loop.c:431
#30 0x00000000005f83a7 in cli_command_loop (data=0x0) at ../../src/gdb/event-top.c:179
#31 0x00000000005eeed3 in current_interp_command_loop () at ../../src/gdb/interps.c:327
#32 0x00000000005ef8ff in captured_command_loop (data=0x0) at ../../src/gdb/main.c:267
#33 0x00000000005ed2f6 in catch_errors (func=0x5ef8e4 <captured_command_loop>, func_args=0x0, errstring=0x8b6554 "", mask=RETURN_MASK_ALL)
at ../../src/gdb/exceptions.c:524
#34 0x00000000005f0d21 in captured_main (data=0x7fffffffd9e0) at ../../src/gdb/main.c:1067
#35 0x00000000005ed2f6 in catch_errors (func=0x5efb9b <captured_main>, func_args=0x7fffffffd9e0, errstring=0x8b6554 "", mask=RETURN_MASK_ALL)
at ../../src/gdb/exceptions.c:524
#36 0x00000000005f0d57 in gdb_main (args=0x7fffffffd9e0) at ../../src/gdb/main.c:1076
#37 0x000000000045bb6a in main (argc=4, argv=0x7fffffffdae8) at ../../src/gdb/gdb.c:34
(top-gdb)
GDB is trying to unwind the PC register of the previous frame (frame
#5 above), starting from the frame being sniffed (the THIS frame).
But the THIS frame's unwinder says the PC of the previous frame is
actually the same as the previous's frame's next frame (which is the
same frame we started with, the THIS frame), therefore it returns an
lval_register lazy value with frame set to THIS frame. And so the
value_fetch_lazy loop never ends.
Rationale 2
===========
As an experiment, I tried making dwarf2-frame.c:read_addr_from_reg use
address_from_register. That caused a bunch of regressions, but it
actually took me a long while to figure out what was going on. Turns
out dwarf2-frame.c:read_addr_from_reg is called while computing the
frame's CFA, from within dwarf2_frame_cache. address_from_register
wants to create a register with frame_id set to the frame being
constructed. To create the frame id, we again call dwarf2_frame_cache,
which given:
static struct dwarf2_frame_cache *
dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
{
...
if (*this_cache)
return *this_cache;
returns an incomplete object to the caller:
static void
dwarf2_frame_this_id (struct frame_info *this_frame, void **this_cache,
struct frame_id *this_id)
{
struct dwarf2_frame_cache *cache =
dwarf2_frame_cache (this_frame, this_cache);
...
(*this_id) = frame_id_build (cache->cfa, get_frame_func (this_frame));
}
As cache->cfa is still 0 (we were trying to compute it!), and
get_frame_id recalls this id from here on, we end up with a broken
frame id in recorded for this frame. Later, when inspecting locals,
the dwarf machinery needs to know the selected frame's base, which
calls get_frame_base:
CORE_ADDR
get_frame_base (struct frame_info *fi)
{
return get_frame_id (fi).stack_addr;
}
which as seen above then returns 0 ...
So I gave up using address_from_register.
But, the pain of investigating this made me want to have GDB itself
assert that recursion never happens here. So I wrote a patch to do
that. But, it triggers on current mainline, because
dwarf2_tailcall_sniffer_first, called from dwarf2_frame_cache, unwinds
the this_frame.
A sniffer shouldn't be trying to unwind, exactly because of this sort
of tricky issue. The patch defers calling
dwarf2_tailcall_sniffer_first until it's really necessary, in
dwarf2_frame_prev_register (thus actually outside the sniffer path).
As this makes the call to dwarf2_frame_sniffer in dwarf2_frame_cache
unnecessary again, the patch removes that too.
Tested on x86_64 Fedora 17.
gdb/
2013-11-22 Pedro Alves <palves@redhat.com>
PR 16155
* dwarf2-frame.c (struct dwarf2_frame_cache)
<checked_tailcall_bottom, entry_cfa_sp_offset,
entry_cfa_sp_offset_p>: New fields.
(dwarf2_frame_cache): Adjust to use the new cache fields instead
of locals. Don't call dwarf2_tailcall_sniffer_first here.
(dwarf2_frame_prev_register): Call it here, but only once.
Pedro Alves [Thu, 21 Nov 2013 15:20:09 +0000 (15:20 +0000)]
Make use of the frame stash to detect wider stack cycles.
Tested on x86_64 Fedora 17.
gdb/
2013-11-22 Pedro Alves <palves@redhat.com>
Tom Tromey <tromey@redhat.com>
* frame.c (frame_stash_add): Now returns whether a frame with the
same ID was already known.
(compute_frame_id): New function, factored out from get_frame_id.
(get_frame_id): No longer lazilly compute the frame id here.
(get_prev_frame_if_no_cycle): New function. Detects wider stack
cycles.
(get_prev_frame_1): Use it instead of get_prev_frame_raw directly,
and checking for stack cycles here.
Pedro Alves [Fri, 22 Nov 2013 11:51:59 +0000 (11:51 +0000)]
Don't let two frames with the same id end up in the frame chain.
The UNWIND_SAME_ID check is done between THIS_FRAME and the next frame
when we go try to unwind the previous frame. But at this point, it's
already too late -- we ended up with two frames with the same ID in
the frame chain. Each frame having its own ID is an invariant assumed
throughout GDB. This patch applies the UNWIND_SAME_ID detection
earlier, right after the previous frame is unwound, discarding the dup
frame if a cycle is detected.
The patch includes a new test that fails before the change. Before
the patch, the test causes an infinite loop in GDB, after the patch,
the UNWIND_SAME_ID logic kicks in and makes the backtrace stop with:
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
The test uses dwarf CFI to emulate a corrupted stack with a cycle. It
has a function with registers marked DW_CFA_same_value (most
importantly RSP/RIP), so that GDB computes the same ID for that frame
and its caller. IOW, something like this:
#0 - frame_id_1
#1 - frame_id_2
#2 - frame_id_3
#3 - frame_id_4
#4 - frame_id_4 <<<< outermost (UNWIND_SAME_ID).
(The test's code is just a copy of dw2-reg-undefined.S /
dw2-reg-undefined.c, adjusted to use DW_CFA_same_value instead of
DW_CFA_undefined, and to mark a different set of registers.)
The infinite loop is here, in value_fetch_lazy:
while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
{
frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
...
new_val = get_frame_register_value (frame, regnum);
}
get_frame_register_value can return a lazy register value pointing to
the next frame. This means that the register wasn't clobbered by
FRAME; the debugger should therefore retrieve its value from the next
frame.
To be clear, get_frame_register_value unwinds the value in question
from the next frame:
struct value *
get_frame_register_value (struct frame_info *frame, int regnum)
{
return frame_unwind_register_value (frame->next, regnum);
^^^^^^^^^^^
}
In other words, if we get a lazy lval_register, it should have the
frame ID of the _next_ frame, never of FRAME.
At this point in value_fetch_lazy, the whole relevant chunk of the
stack up to frame #4 has already been unwound. The loop always
"unlazies" lval_registers in the "next/innermost" direction, not in
the "prev/unwind further/outermost" direction.
So say we're looking at frame #4. get_frame_register_value in frame
#4 can return a lazy register value of frame #3. So the next
iteration, frame_find_by_id tries to read the register from frame #3.
But, since frame #4 happens to have same id as frame #3,
frame_find_by_id returns frame #4 instead. Rinse, repeat, and we have
an infinite loop.
This is an old latent problem, exposed by the recent addition of the
frame stash. Before we had a stash, frame_find_by_id(frame_id_4)
would walk over all frames starting at the current frame, and would
always find #3 first. The stash happens to return #4 instead:
struct frame_info *
frame_find_by_id (struct frame_id id)
{
struct frame_info *frame, *prev_frame;
...
/* Try using the frame stash first. Finding it there removes the need
to perform the search by looping over all frames, which can be very
CPU-intensive if the number of frames is very high (the loop is O(n)
and get_prev_frame performs a series of checks that are relatively
expensive). This optimization is particularly useful when this function
is called from another function (such as value_fetch_lazy, case
VALUE_LVAL (val) == lval_register) which already loops over all frames,
making the overall behavior O(n^2). */
frame = frame_stash_find (id);
if (frame)
return frame;
for (frame = get_current_frame (); ; frame = prev_frame)
{
gdb/
2013-11-22 Pedro Alves <palves@redhat.com>
PR 16155
* frame.c (get_prev_frame_1): Do the UNWIND_SAME_ID check between
this frame and the new previous frame, not between this frame and
the next frame.
gdb/testsuite/
2013-11-22 Pedro Alves <palves@redhat.com>
PR 16155
* gdb.dwarf2/dw2-dup-frame.S: New file.
* gdb.dwarf2/dw2-dup-frame.c: New file.
* gdb.dwarf2/dw2-dup-frame.exp: New file.
Senthil Kumar Selvaraj [Fri, 22 Nov 2013 12:00:55 +0000 (12:00 +0000)]
* scripttempl/avr.sc: Set .data section's LMA to next available
address in text region.
Doug Evans [Fri, 22 Nov 2013 04:28:35 +0000 (20:28 -0800)]
Move types_deeply_equal from py-type.c to gdbtypes.c.
* gdbtypes.c: #include bcache.h, dwarf2loc.h.
(type_equality_entry): Move here from python/py-type.c.
(type_equality_entry_d): Ditto.
(compare_maybe_null_strings, check_types_equal): Ditto.
(check_types_worklist, types_deeply_equal): Ditto.
* gdbtypes.h (types_deeply_equal): Declare.
* python/py-type.c: Remove inclusion of bcache.h, dwarf2loc.h.
(typy_richcompare): Update.