Commit Graph

33894 Commits

Author SHA1 Message Date
Doug Evans 5072219825 * nat/linux-waitpid.c (linux_debug): Remove extraneous \n from output. 2014-01-03 14:34:45 -08:00
Joel Brobecker 2fa4b86204 Add gdb/ChangeLog entry for previous change.
I forgot to add that entry when I checked in the "copyright year range"
update for GDB files.
2014-01-01 07:57:03 +04:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Joel Brobecker 28498c4207 Update copyright year in gdb/gdbserver/gdbreplay version output.
gdb/ChangeLog:

        * top.c (print_gdb_version): Set copyright year to 2014.

gdb/gdbserver/ChangeLog:

        * gdbserver.c (gdbserver_version): Set copyright year to 2014.
        * gdbreplay.c (gdbreplay_version): Likewise.
2014-01-01 07:43:51 +04:00
Joel Brobecker 7b6e104658 Add gdb/ChangeLog-2013 entry in fnchange.lst. 2014-01-01 07:34:22 +04:00
Joel Brobecker df96af5539 New Year - GDB ChangeLog rotation. 2014-01-01 07:31:51 +04:00
Joel Brobecker 5fba4c0ff5 Clarify documentation of the gdb.Field.bitpos attribute
gdb/doc/ChangeLog:

        * gdb.texinfo (Types In Python): Clarify the documentation
        of attribute gdb.Field.bitpos.
2013-12-30 06:52:43 +04:00
Sergio Durigan Junior c248fc1d26 Add comment describing arm_stap_is_single_operand
2013-12-29  Sergio Durigan Junior  <sergiodj@redhat.com>

	* arm-linux-tdep.c (arm_stap_is_single_operand): Add comment
	describing function.
2013-12-29 18:55:11 -02:00
Sergio Durigan Junior 8d85bacb91 Extend handling of immediates on ARM's SystemTap SDT probe support
Continuing my series of fixes on the SystemTap SDT support for the
ARM/AArch64 architectures, this patch now extends how ARM's SDT specific
parser handles literal numbers (immediates).

Currently, it only accepts "#" as the prefix.  However, according to
"info '(as) ARM-Chars'", expressions can also have "$" and nothing as a
prefix.  This patch extends the parser to accept those options.

2013-12-28  Sergio Durigan Junior  <sergiodj@redhat.com>

	* arm-linux-tdep.c (arm_stap_is_single_operand): Accept "$" as a
	literal prefix.  Also accept no prefix at all.
	(arm_stap_parse_special_token): Likewise.
	(arm_linux_init_abi): Likewise.
2013-12-28 19:20:58 -02:00
Sergio Durigan Junior 08248ca9fe Implement SystemTap SDT probe support for AArch64
This commit implements the needed bits for SystemTap SDT probe support
on AArch64 architectures.

First, I started by looking at AArch64 assembly specification and
filling the necessary options on gdbarch's stap machinery in order to
make the generic asm parser (implemented in stap-probe.c) recognize
AArch64's asm.

After my last patch for the SystemTap SDT API, which extends it in order
to accept multiple prefixes and suffixes, this patch became simpler.  I
also followed Marcus suggestion and did not shared code between 32- and
64-bit ARM.

Tom asked me in a previous message how I did my tests.  I believe I
replied that, but just in case: I ran the tests on
gdb.base/stap-probe.exp by hand.  I also managed to run the tests on
real hardware, and they pass without regressions.

2013-12-28  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR tdep/15653
	* NEWS: Mention SystemTap SDT probe support for AArch64 GNU/Linux.
	* aarch64-linux-tdep.c: Include necessary headers for parsing of
	SystemTap SDT probes.
	(aarch64_stap_is_single_operand): New function.
	(aarch64_stap_parse_special_token): Likewise.
	(aarch64_linux_init_abi): Declare SystemTap SDT probe argument
	prefixes and suffixes.  Initialize gdbarch with them.
2013-12-28 14:14:11 -02:00
Joel Brobecker 0809504b5e Fix gdb.Field attributes documentation for enum types.
The following patch ...

    | commit 14e75d8ea4
    | Date:   Wed Apr 18 06:46:47 2012 +0000
    |
    |     gdb/
    |         PR symtab/7259:
    | [...]

... discussed under ...

    [PATCH] Allow 64-bit enum values
    http://www.sourceware.org/ml/gdb-patches/2012-03/msg00772.html

... introduced a change in the gdb.Fields API without documenting it:

    | I took a separate approach from the one I took in:
    |
    | http://sourceware.org/ml/gdb-patches/2012-02/msg00403.html
    |
    | and removed the overloaded meaning of the bitpos location variable to
    | fix PR symtab/7259. In the following patch, I introduce a separate
    | field_location union member 'enumval' which can accept LONGEST and
    | hence expand enum values to 64-bit signed values. With this change,
    | bitpos now only is used for (non-negative) offsets into structures,
    | since the other overload of bitpos (range bounds) were already
    | separated into struct range_bound.

This patch updates the documentation to reflect that change.

gdb/doc/ChangeLog:

        * gdb.texinfo (Types In Python): Fix the documentation of
        attribute "bitpos" in class gdb.Field for enum types.  Add
        documentation for attribute "enumval" in that same class.
2013-12-28 07:19:07 +04:00
Joel Brobecker edef60002f Turn -list-feature @table into @ftable.
This is to make it easier to discover the various options displayed
by the -list-features command.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Support Commands): Change @table into
        @ftable.
2013-12-28 07:08:30 +04:00
Doug Evans 71b8c8455f Reorganize extension language auto-loading docs.
* gdb.texinfo (Auto-loading): Move menu up.  Move discussion of
	auto-loaded objfile scripts and .debug_gdb_scripts section to their
	corresponding section in Extending GDB.
	(Extending GDB): Move menu up.  New menu item "Auto-loading
	extensions".
	(Sequences): New menu item "Auto-loading sequences".
	(Auto-loading sequences): New node.
	(Python): Rename section from Scripting GDB to Extending GDB.
	(Python Auto-loading): Update xref, refer to "Auto-loading extensions".
	Move docs on ways to auto-load extensions to ...
	(Auto-loading extensions): ... here.  New node.
2013-12-23 21:01:17 -08:00
Sterling Augustine e617b0692b 2013-12-17 Sterling Augustine <saugustine@google.com>
* linespec.c (add_sal_to_sals): Use "<unknown>" when a symbol
	isn't found.
2013-12-23 15:14:39 -08:00
Sergio Durigan Junior 97c2dca091 Some cleanups on stap-probe.c
This patch does some basic cleanups on the SystemTap SDT probes API.  It
removes spurious newlines, brackets, reindents some code, and do
explicit checks for NULL, NUL, and 0 where applicable.

2013-12-23  Sergio Durigan JUnior  <sergiodj@redhat.com>

	* stap-probe.c (struct stap_probe) <args_parsed>: Add comment.
	(stap_is_generic_prefix): Delete extra brackets.  Reindent.
	(stap_parse_register_operand): Remove spurious newlines.  Simplify
	code to parse special token.
	(stap_parse_argument_conditionally): Add gdb_assert.
	(stap_parse_argument_1): Likewise.  Explicitly check for NULL and
	NUL.
	(stap_parse_probe_arguments): Likewise.
	(handle_stap_probe): Likewise.  Reindent code.
	(get_stap_base_address): Explicitly check for NULL.
	(stap_get_probes): Likewise.  Reindent code.
	(stap_relocate): Explicitly check for 0.
	(stap_gen_info_probes_table_values): Likewise.
2013-12-23 20:48:08 -02:00
Joel Brobecker d192b37306 Move GDB/MI commands related to support-query to their own @node.
A number of commands provide the capability to query the debugger
about support for various features, and one of them in particular
(-list-features), is expected to grow as new features get added.
-list-target-features should also grow a bit over time, but probably
slower.

These commands deserve their own section and @node.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI): Add "GDB/MI Support Commands" entry
        in menu.
        (GDB/MI Variable Objects): Adjust reference to "-list-features"
        command, now in a new node.
        (GDB/MI Support Commands): New node, with its contents being
        extracted from the "GDB/MI Miscellaneous Commands" node.
        A small paragraph introducing the section is also added at
        the start.
        (GDB/MI Miscellaneous Commands): Delete the description of the
        -info-gdb-mi-command, -list-features and -list-target-features
        commands, now hosted in the "GDB/MI Support Commands" node.
2013-12-23 04:58:02 +04:00
Chung-Lin Tang 21986715b1 2013-12-20 Chung-Lin Tang <cltang@codesourcery.com>
* nios2-linux-tdep.c (nios2_linux_sigreturn_init): Remove.
	(nios2_linux_sigreturn_tramp_frame): Remove.
	(nios2_linux_rt_sigreturn_tramp_frame): Update rt_sigreturn syscall
	number.
	(nios2_linux_syscall_next_pc): Likewise. Remove sigreturn case.
	(nios2_linux_init_abi): Remove registration of
	nios2_linux_sigreturn_tramp_frame.
2013-12-20 20:53:53 +08:00
H.J. Lu f9fda3f571 Mask out PREFIX_ADDR when adding prefix to opcode
PREFIX_ADDR isn't a prefix to opcode.  This patch masks out PREFIX_ADDR
when adding prefix to opcode.

	PR gdb/16305
	* i386-tdep.c (i386_process_record): Mask out PREFIX_ADDR when
	adding prefix to opcode.
2013-12-19 14:28:18 -08:00
H.J. Lu 1e87984a63 Properly decode MODRM byte for 64-bit
64-bit mode doesn't use 16-bit address.  We should always check SIB byte
for address in 64-bit mode.

	PR gdb/16304
	* i386-tdep.c (i386_record_lea_modrm_addr): Don't use 16-bit
	address in 64-bit mode.
2013-12-19 14:24:34 -08:00
H.J. Lu e85596e021 Zero-extend address from 32-bit to 64-bit for ADDR32 prefix
When there is ADDR32 prefix in 64-bit mode, we should zero-extend
address from 32-bit to 64-bit.

	PR gdb/16304
	* i386-tdep.c (i386_record_lea_modrm_addr): Zero-extend 32-bit
	address to 64-bit in 64-bit mode.
2013-12-19 14:22:30 -08:00
H.J. Lu 8ee5199a42 Add amd64_x32_linux_record_tdep and amd64_x32_sys
X32 Linux system calls are diffferent from amd64 Linux system calls in
system call numbers as well as parameter types/values.  This patch adds
amd64_x32_linux_record_tdep and amd64_x32_syscall for x32.

	PR gdb/16304
	* amd64-linux-tdep.c (amd64_canonicalize_syscall): Handle x32
	system calls.
	(amd64_x32_linux_record_tdep): New.
	(amd64_linux_syscall_record_common): New function.
	(amd64_linux_syscall_record): Call
	amd64_linux_syscall_record_common with amd64_linux_record_tdep.
	(amd64_x32_linux_syscall_record): Call
	amd64_linux_syscall_record_common with
	amd64_x32_linux_record_tdep.
	(amd64_linux_init_abi_common): Move amd64_linux_record_tdep
	initialization and tdep->i386_syscall_record setup to ...
	(amd64_linux_init_abi): Here.
	(amd64_x32_linux_init_abi): Initialize
	amd64_x32_linux_record_tdep.  Set tdep->i386_syscall_record to
	amd64_x32_linux_syscall_record.
	* amd64-linux-tdep.h (amd64_x32_syscall): New enum.
2013-12-19 14:17:48 -08:00
Sergio Durigan Junior 05c0465e16 Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments.  It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).

I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.

This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec).  And AArch64 will also need this, for the same
reason.

This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64).  No regressions were found.

2013-12-19  Sergio Durigan Junior  <sergiodj@redhat.com>

	* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
	argument prefixes and suffixes.  Initialize gdbarch with them.
	* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
	(stap_register_prefix, stap_register_suffix)
	(stap_register_indirection_prefix)
	(stap_register_indirection_suffix): Declare as "const char *const
	*" instead of "const char *".  Adjust printing function.  Rename
	all of the variables to the plural.
	(pstring_list): New function.
	* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
	argument prefixes and suffixes.  Initialize gdbarch with them.
	* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
	* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
	* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
	* stap-probe.c (stap_is_generic_prefix): New function.
	(stap_is_register_prefix): Likewise.
	(stap_is_register_indirection_prefix): Likewise.
	(stap_is_integer_prefix): Likewise.
	(stap_generic_check_suffix): Likewise.
	(stap_check_integer_suffix): Likewise.
	(stap_check_register_suffix): Likewise.
	(stap_check_register_indirection_suffix): Likewise.
	(stap_parse_register_operand): Remove unecessary declarations for
	variables holding prefix and suffix information.  Use the new
	functions listed above for checking for prefixes and suffixes.
	(stap_parse_single_operand): Likewise.
2013-12-19 18:53:40 -02:00
Gabriel Krisman Bertazi 4924df7977 Fix PR breakpoints/16297: catch syscall with syscall 0
Code rationale
==============
by: Gabriel Krisman Bertazi

This is a fix for bug 16297. The problem occurs when the user attempts
to catch any syscall 0 (such as syscall read on Linux/x86_64). GDB was
not able to catch the syscall and was missing the breakpoint.

Now, breakpoint_hit_catch_syscall returns immediately when it finds the
correct syscall number, avoiding a following check for the end of the
search vector, that returns a no hit if the syscall number was zero.

Testcase rationale
==================
by: Sergio Durigan Junior

This testcase is a little difficult to write.  By doing a quick
inspection at the Linux source, one can see that, in many targets, the
syscall number 0 is restart_syscall, which is forbidden to be called
from userspace.  Therefore, on many targets, there's just no way to test
this safely.

My decision was to take the simpler route and just adds the "read"
syscall on the default test.  Its number on x86_64 is zero, which is
"good enough" since many people here do their tests on x86_64 anyway and
it is a popular architecture.

However, there was another little gotcha.  When using "read" passing 0
as the third parameter (i.e., asking it to read 0 bytes), current libc
implementations could choose not to effectively call the syscall.
Therefore, the best solution was to create a temporary pipe, write 1
byte into it, and then read this byte from it.

gdb/ChangeLog
2013-12-19  Gabriel Krisman Bertazi  <gabriel@krisman.be>

	PR breakpoints/16297
	* breakpoint.c (breakpoint_hit_catch_syscall): Return immediately
	when expected syscall is hit.

gdb/testsuite/ChangeLog
2013-12-19  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR breakpoints/16297
	* gdb.base/catch-syscall.c (read_syscall, pipe_syscall)
	(write_syscall): New variables.
	(main): Create a pipe, write 1 byte in it, and read 1 byte from
	it.
	* gdb.base/catch-syscall.exp (all_syscalls): Include "pipe,
	"write" and "read" syscalls.
	(fill_all_syscalls_numbers): Improve the way to obtain syscalls
	numbers.
2013-12-19 17:01:49 -02:00
Tom Tromey 12e8c7d7c2 don't allocate serial_ops
Now that struct serial_ops is const everywhere, we can easily turn the
instances into globals.  This patch implements this idea.

On the one hand I think this is nicer since it makes a bit more data
readonly and slightly reduces allocations.  On the other hand it
reduces readability somewhat.

If the readability is a concern to anyone I was thinking I could write
a macro that conditionally uses GCC's designated initializer
extension.

Tested by rebuilding on x86-64 Fedora 18, both natively and using the
mingw cross tools.

2013-12-19  Tom Tromey  <tromey@redhat.com>

	* ser-unix.c (hardwire_ops): New global.
	(_initialize_ser_hardwire): Use it.
	* ser-tcp.c (tcp_ops): New global.
	(_initialize_ser_tcp): Use it.
	* ser-pipe.c (pipe_ops): New global.
	(_initialize_ser_pipe): Use it.
	* ser-mingw.c (hardwire_ops, tty_ops, pipe_ops, tcp_ops): New
	globals.
	(_initialize_ser_windows): Use them.
2013-12-19 08:50:48 -07:00
Tom Tromey fcd488ca4e make serial_ops const
I noticed that the serial_ops vtable is not const, but really it ought
to be.

This patch constifies it, removing the only mutable field in the
process.

Tested by rebuilding on x86-64 Fedora 18, both natively and using the
mingw cross tools.

2013-12-19  Tom Tromey  <tromey@redhat.com>

	* serial.c (serial_ops_p): New typedef.
	(serial_ops_list): Now a VEC.
	(serial_interface_lookup): Return const.  Use VEC_iterate.
	(serial_add_interface): Make parameter const.
	(serial_open): Update.
	(serial_fdopen_ops): Make 'ops' const.
	(serial_pipe): Update.
	* ser-tcp.c (_initialize_ser_tcp): Update.
	* ser-pipe.c (_initialize_ser_pipe): Update.
	* ser-unix.c (_initialize_ser_hardwire): Update.
	* ser-mingw.c (_initialize_ser_windows): Update.
	* ser-go32.c (dos_ops): Now const.  Update.
	* serial.h (struct serial) <ops>: Now const.
	(struct serial_ops) <next>: Remove.
	(serial_add_interface): Make parameter const.
2013-12-19 08:50:46 -07:00
Keven Boell 530e8392d7 fortran: enable ptype/whatis for modules.
Added new domain MODULE_DOMAIN for fortran modules to avoid
issues with sharing namespaces (e.g. when a variable currently
in scope has the same name as a module).

	(gdb) ptype modname
	old> No symbol "modname" in current context.
	new> type = module modname

This fixes PR 15209 and also addresses the issue
with sharing namespaces:
https://sourceware.org/ml/gdb-patches/2013-02/msg00643.html

2013-11-19  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

	* cp-namespace.c (cp_lookup_nested_symbol): Enable
	nested lookups for fortran modules.
	* dwarf2read.c (read_module): Add fortran module to
	the symbol table.
	(add_partial_symbol, add_partial_module): Add fortran
	module to the partial symbol table.
	(new_symbol_full): Create full symbol for fortran module.
	* f-exp.y (yylex): Add new module domain to be parsed.
	* symtab.h: New domain for fortran modules.

testsuite/

	* gdb.fortran/module.exp: Completion matches fortran module
	names as well. ptype/whatis on modules return a proper type.
	Add new check for having the correct scope.
2013-12-19 13:18:21 +01:00
Keven Boell 7f9b20bb35 fortran: enable ptype/whatis for user defined types.
(gdb) ptype type
	old> No symbol "type" in current context.
	new> type = Type type
	     integer(kind=4) :: t_i
	     End Type type

2013-11-19  Sanimir Agovic  <sanimir.agovic@intel.com>
            Keven Boell  <keven.boell@intel.com>

	* f-exp.y (yylex): Add domain array to enable lookup
	in multiple domains. Loop over lookup domains and try
	to find requested symbol. Add STRUCT_DOMAIN to lookup
	domains to be able to query for user defined types.

testsuite/
	* gdb.fortran/type.f90: New file.
	* gdb.fortran/whatis_type.f90: New file.
2013-12-19 13:18:11 +01:00
Sergio Durigan Junior 2e0d821f2d Improve and fix catch-syscall.exp
While fixing another bug, I found that the current
gdb.base/catch-syscall.exp is kind of messy, could use some
improvements, and is not correctly testing some things.

I've made the following patch to address all the issues I found.  On the
organization side, it does a cleanup and removes unecessary imports of
gdb_prompt, uses prepare_for_testing and clean_restart where needed, and
fixes some comments.  The testcase was also not correctly testing
catching syscalls using only numbers, or catching many syscalls at
once.  I fixed that.

The patch also uses a new method for obtaining the syscalls numbers: it
relies on the C source file to get them, via <sys/syscall.h> and SYS_*
macros.  This makes the .exp file simpler because there is no need to
include target conditionals there.

I tested this on x86_64 Fedora 18.

gdb/testsuite/ChangeLog:
2013-12-18  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.base/catch-syscall.c: Include <sys/syscall.h>.
	(close_syscall, chroot_syscall, exit_group_syscall): New
	variables.
	* gdb.base/catch-syscall.exp: Replace gdb_compile by
	prepare_for_testing.  Call fill_all_syscalls_numbers before
	starting.  Replace gdb_exit, gdb_start, gdb_reinitialize_dir and
	gdb_load by clean_restart.
	(check_info_bp_any_syscall, check_info_bp_specific_syscall)
	(check_info_bp_many_syscalls): Remove global gdb_prompt.
	(check_call_to_syscall): Likewise.  Add global decimal.  Improve
	testing regex.
	(check_return_from_syscall): Likewise.
	(check_continue, insert_catch_syscall_with_arg): Remove global
	gdb_prompt.
	(insert_catch_syscall_with_many_args): Likewise.  Add global
	decimal.  Fix $filter_str.  Improve testing regex.
	(check_for_program_end): Remove global gdb_prompt.
	(test_catch_syscall_without_args): Likewise.  Add global decimal.
	Improve testing regex.
	(test_catch_syscall_with_args, test_catch_syscall_with_many_args)
	(test_catch_syscall_with_wrong_args)
	(test_catch_syscall_restarting_inferior)
	(test_catch_syscall_fail_nodatadir): Remove global gdb_prompt.
	(do_syscall_tests): Likewise.  Remove global srcdir.
	(test_catch_syscall_without_args_noxml): Remove global gdb_prompt.
	Add global last_syscall_number.  Test for the exact syscall number
	to be caught.
	(test_catch_syscall_with_args_noxml): Remove global gdb_prompt.
	Add global all_syscalls_numbers.  Test each syscall number to be
	caught, instead of only testing "close".
	(test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt.
	(do_syscall_tests_without_xml): Likewise.  Remove global srcdir.
	Remove stale comment.
	(fill_all_syscalls_numbers): Add global last_syscall_number.  Fill
	the correct syscall numbers using information from the inferior.
2013-12-18 20:19:01 -02:00
Yufeng Zhang f45c82da38 gdb/
* aarch64-linux-nat.c (aarch64_linux_set_debug_regs): Set
	iov.iov_len with the real length in use.

gdb/gdbserver/

	* linux-aarch64-low.c (aarch64_linux_set_debug_regs): Set
	iov.iov_len with the real length in use.
2013-12-18 16:47:33 +00:00
Yao Qi 4ac248ca0b Add target_xfer_partial_ftype
This patch adds a typedef target_xfer_partial_ftype.  When we change
the signature of xfer_partial functions (for example, adding a new
parameter), we don't have to modify all of their declarations.

This patch also updates the type of parameters of target_xfer_partial
from "void *" to "gdb_byte *".

gdb:

2013-12-18  Yao Qi  <yao@codesourcery.com>

	* target.h (target_xfer_partial_ftype): New typedef.
	(target_xfer_partial): Update declaration.
	* auxv.h (memory_xfer_auxv): Likewise.
	* ia64-hpux-nat.c (super_xfer_partial): Likewise.
	* ia64-linux-nat.c (super_xfer_partial): Likewise.
	* linux-nat.c (super_xfer_partial): Likewise.
	* procfs.c (procfs_xfer_partial): Likewise.
	* record-full.c (record_full_beneath_to_xfer_partial):
	(tmp_to_xfer_partial): Likewise.
	* sparc-nat.c (inf_ptrace_xfer_partial): Likewise.
	* target.c (default_xfer_partial): Likewise.
	(current_xfer_partial): Likewise.
	(target_xfer_partial): Change parameter type to 'gdb_byte *'.
2013-12-18 11:47:03 +08:00
Yao Qi cde33bf103 Replace sprintf with xsnprintf
gdb:

2013-12-18  Yao Qi  <yao@codesourcery.com>

	* linux-nat.c (linux_proc_xfer_partial): Call xsnprintf instead
	of sprintf.
	(linux_nat_detach, linux_child_pid_to_exec_file): Likewise.
	(linux_proc_pending_signals): Likewise.
2013-12-18 11:46:56 +08:00
Yao Qi 230de03ab4 Fix the format of one ChangeLog entry
I notice that two lines of a recent changelog entry are not prefixed
with tab.  They are prefixed with a space and a tab.  This patch
is to remove the space.

gdb:

2013-12-18  Yao Qi  <yao@codesourcery.com>

	* ChangeLog: Fix the format of one entry.
2013-12-18 11:30:54 +08:00
Joel Brobecker 64c46ce4ac ARI fix in value.c::value_entirely_unavailable
gdb/ChangeLog:

        * value.c (value_entirely_unavailable): ARI fix: Move trailing
        binary operator to the next line.  No actual code change.
2013-12-18 06:45:49 +04:00
Pedro Alves 5ce0145de7 "tfind" across unavailable-stack frames.
Like when stepping, the current stack frame location is expected to be
printed as result of tfind command, if that results in moving to a
different function.  In tfind_1 we see:

  if (from_tty
      && (has_stack_frames () || traceframe_number >= 0))
    {
      enum print_what print_what;

      /* NOTE: in imitation of the step command, try to determine
         whether we have made a transition from one function to
         another.  If so, we'll print the "stack frame" (ie. the new
         function and it's arguments) -- otherwise we'll just show the
         new source line.  */

      if (frame_id_eq (old_frame_id,
                       get_frame_id (get_current_frame ())))
        print_what = SRC_LINE;
      else
        print_what = SRC_AND_LOC;

      print_stack_frame (get_selected_frame (NULL), 1, print_what, 1);
      do_displays ();
    }

However, when we haven't collected any registers in the tracepoint
(collect $regs), that doesn't actually work:

 (gdb) tstart
 (gdb) info tracepoints
 Num     Type           Disp Enb Address    What
 1       tracepoint     keep y   0x080483b7 in func0
                                            at ../.././../git/gdb/testsuite/gdb.trace/circ.c:28
         collect testload
     installed on target
 2       tracepoint     keep y   0x080483bc in func1
                                            at ../.././../git/gdb/testsuite/gdb.trace/circ.c:32
         collect testload
     installed on target
 (gdb) c
 Continuing.

 Breakpoint 3, end () at ../.././../git/gdb/testsuite/gdb.trace/circ.c:72
 72    }
 (gdb) tstop
 (gdb) tfind start
 Found trace frame 0, tracepoint 1
 #0  func0 () at ../.././../git/gdb/testsuite/gdb.trace/circ.c:28
 28    }
 (gdb) tfind
 Found trace frame 1, tracepoint 2
 32    }
 (gdb)

When we don't have info about the stack available
(UNWIND_UNAVAILABLE), frames end up with outer_frame_id as frame ID.
And in the scenario above, the issue is that both frames before and
after the second tfind (the frames for func0 an func1) have the same
id (outer_frame_id), so the frame_id_eq check returns false, even
though the frames were of different functions.  GDB knows that,
because the PC is inferred from the tracepoint's address, even if no
registers were collected.

To fix this, this patch adds support for frame ids with a valid code
address, but <unavailable> stack address, and then makes the unwinders
use that instead of the catch-all outer_frame_id for such frames.  The
frame_id_eq check in tfind_1 then automatically does the right thing
as expected.

I tested with --directory=gdb.trace/ , before/after the patch, and
compared the resulting gdb.logs, then adjusted the tests to expect the
extra output that came out.  Turns out that was only circ.exp, the
original test that actually brought this issue to light.

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/
2013-12-17  Pedro Alves  <palves@redhat.com>

	* frame.h (enum frame_id_stack_status): New enum.
	(struct frame_id) <stack_addr>: Adjust comment.
	<stack_addr_p>: Delete field, replaced with ...
	<stack_status>: ... this new field.
	(frame_id_build_unavailable_stack): Declare.
	* frame.c (frame_addr_hash, fprint_field, outer_frame_id)
	(frame_id_build_special): Adjust.
	(frame_id_build_unavailable_stack): New function.
	(frame_id_build, frame_id_build_wild): Adjust.
	(frame_id_p, frame_id_eq, frame_id_inner): Adjust to take into
	account frames with unavailable stack.

	* amd64-tdep.c (amd64_frame_this_id)
	(amd64_sigtramp_frame_this_id, amd64_epilogue_frame_this_id): Use
	frame_id_build_unavailable_stack.
	* dwarf2-frame.c (dwarf2_frame_this_id): Likewise.
	* i386-tdep.c (i386_frame_this_id, i386_epilogue_frame_this_id)
	(i386_sigtramp_frame_this_id):  Likewise.

gdb/testsuite/
2013-12-17  Pedro Alves  <palves@redhat.com>

	* gdb.trace/circ.exp: Expect frame info to be printed when
	switching between frames with unavailable stack, but different
	functions.
2013-12-17 20:47:36 +00:00
Andrew Burgess bdf2220615 Convert the unavailable vector to be bit, not byte, based.
https://sourceware.org/ml/gdb-patches/2013-12/msg00144.html

The vector of unavailable parts of a value is currently byte based.  Given
that we can model a value down to the bit level, we can potentially loose
information with the current implementation.  After this patch we model the
unavailable information in bits.

gdb/ChangeLog

	* dwarf2loc.c (read_pieced_value): Mark bits, not bytes
	unavailable, use correct bit length.
	* value.c (struct value): Extend comment on unavailable to
	indicate that it is bit based.
	(value_bits_available): New function.
	(value_bytes_available): Call value_bits_available.
	(value_entirely_available): Check against the bit length, not byte
	length.
	(mark_value_bits_unavailable): New function.
	(mark_value_bytes_unavailable): Move contents to
	mark_value_bits_unavailable, call to same.
	(memcmp_with_bit_offsets): New function.
	(value_available_contents_bits_eq): New function, takes the
	functionality from value_available_contents_eq but uses
	memcmp_with_bit_offsets now, and is bit not byte based.
	(value_available_contents_eq): Move implementation into
	value_available_contents_bits_eq, call to same.
	(value_contents_copy_raw): Work on bits, not bytes.
	(unpack_value_bits_as_long_1): Check availability in bits, not
	bytes.
	* value.h (value_bits_available): Declare new function.
	(mark_value_bits_unavailable): Declare new function.

gdb/testsuite/ChangeLog

	* gdb.trace/unavailable-dwarf-piece.c: New file.
	* gdb.trace/unavailable-dwarf-piece.exp: New file.
2013-12-17 17:24:15 +00:00
Pierre Muller 774f74c220 Fix compilation error for cygwin native build.
* windows-nat.c (windows_ensure_ntdll_loaded) [__USEWIDE]:
        Call wcstombs.
2013-12-16 23:44:43 +01:00
Pedro Alves 9a362b9a32 PR 16329: remote debugging broken on Solaris.
Like on GNU/Linux (linux-thread-db.c), the Solaris solaris-threads
target (handles libthread_db.so) shouldn't be pushed when remote
debugging.

This uses the same predicate used by linux-thread-db.c.

gdb/
2013-12-16  Pedro Alves  <palves@redhat.com>

	PR 16329
	* sol-thread.c (check_for_thread_db): If the target can't run or
	isn't a core, return without pushing.
2013-12-16 14:04:52 +00:00
Joel Brobecker b030cf11d6 Revert "Do not overwrite so_list's so_name in solib_map_sections"
This reverts commit 07293be448, as it
causes an unintended change of behavior with GDB/MI's =library-loaded
events: The host-name="<path>" part of the event is now showing the
target-side path instead of the host-side path.

This revert affects Darwin and AIX systems, however, where the BFD
is either artificial or icomplete, leading to the outputt of
"info shared" not containing the information we'd like. For instance,
on Darwin, we would see:

    (top-gdb) info shared
    From                To                  Syms Read   Shared Object Library
    0x00007fff8d060de4  0x00007fff8d09ce1f  Yes (*)     i386:x86-64
    0x00007fff8af08b10  0x00007fff8b1c6f73  Yes (*)     i386:x86-64

To compensate for that, we overwrite the filename of the associated bfd.

gdb/ChangeLog:

	Revert the following commit:
	* solib.c (solib_map_sections): Remove code overwriting
	SO->SO_NAME with the bfd's filename.

	Make the following changes required after the revert above:
	* solib-aix.c (solib_aix_bfd_open): Set the filename of the
	returned bfd to a copy of the synthetic pathname.
	* solib-darwin.c (darwin_bfd_open): Set the filename of the
	returned bfd to a copy of PATHNAME.
2013-12-15 10:59:18 +01:00
Yao Qi 07d100d43e Perf test case: skip-prologue
This patch add a perf test case on skip-prologue by inserting
breakpoints on two functions many times, in order to exercise
skip-prologue.

gdb/testsuite:

2013-12-15  Yao Qi  <yao@codesourcery.com>

	* gdb.perf/skip-prologue.c: New.
	* gdb.perf/skip-prologue.exp: New.
	* gdb.perf/skip-prologue.py: New.
2013-12-15 16:16:10 +08:00
Joel Brobecker 379a5e2d36 nameless LOAD_DLL_DEBUG_EVENT causes ntdll.dll to be missing
This is the gdbserver-equivalent of the change made in GDB to handle
the case, in x64 windows version 2012, where the kernel produces
a LOAD_DLL_DEBUG_EVENT where the name of the associated DLL cannot
be determined at that time, and thus has to be processed later.

The visible symptom is that ntdll.dll is missing from the list of
shared libraries known to be mapped by the inferior, with other
side-effects such as failure to unwind through code provided by
that DLL (such as exception handling routines).

gdb/gdbserver/ChangeLog:

	* Makefile.in (safe-ctype.o, lbasename.o): New rules.
	* configure.srv: Add safe-ctype.o and lbasename.o to srv_tgtobj
	for all targets that use win32-low.c.
	* win32-low.c (win32_ensure_ntdll_loaded): New function.
	(do_initial_child_stuff): Add call to win32_ensure_ntdll_loaded.
2013-12-13 16:42:54 +01:00
Pedro Alves 4210d83ee6 Do the target-waiting within do_initial_child_stuff on Windows.
This is a preparatory patch that achieves two goals:

  . Makes the initial event handling more similar to GDB's;
  . Opens the door for implementing post-inititial-handling
    operations.

At the moment, this is only done on Windows, where the
post-initial-handling is going to be needed (in the context of
Windows 2012). And because we're close to creating the gdb 7.7
branch, making that change for all platforms is a little more
risk that we'd like. So the change is currently implemented
on Windows.

gdb/gdbserver/ChangeLog:

        * target.c (mywait): Set OURSTATUS->KIND to TARGET_WAITKIND_STOPPED
        if equal to TARGET_WAITKIND_LOADED.
        * win32-low.c (cached_status): New static global.
        (win32_wait): Add declaration.
        (do_initial_child_stuff): Flush all initial pending debug events
        up to the initial breakpoint.
        (win32_wait): If CACHED_STATUS was set, return that instead
        of doing a real wait.  Remove the code resuming the execution
        of the inferior after receiving a TARGET_WAITKIND_LOADED event
        during the initial phase.  Also remove the code changing
        OURSTATUS->KIND from TARGET_WAITKIND_LOADED to
        TARGET_WAITKIND_STOPPED.
2013-12-13 16:42:08 +01:00
Joel Brobecker 8a48ac9579 wrong dimension found in ada-lang.c:ada_array_bound_from_type
This function has the following code:

  elt_type = type;
  for (i = n; i > 1; i--)
    elt_type = TYPE_TARGET_TYPE (type);

For multi-dimension arrays, the code above tries to find the array
type corresponding to the dimension we're trying to inspect.
The problem is that, past the second dimension, the loop does
nothing other than repeat the first iteration. There is a little
thinko where it got the TYPE_TARGET_TYPE of TYPE instead of ELT_TYPE!

To my surprise, I was unable to produce an Ada exemple that demonstrated
the problem.  That's because the examples I created all trigger a parallel
___XA type which we then use in place of the ELT_TYPE in order to
determine the bounds - see the code that immediately follows our
loop above:

    index_type_desc = ada_find_parallel_type (type, "___XA");
    ada_fixup_array_indexes_type (index_type_desc);
    if (index_type_desc != NULL)
    [...]

So, in order to avoid depending on an Ada example where the compiler
can potentially decide one way or the other, I decided to use an
artificial example, written in C. With ...

  int multi[1][2][3];

... forcing the language to Ada, and trying to print the 'last,
we get:

    (gdb) p multi'last(1)
    $1 = 0
    (gdb) p multi'last(2)
    $2 = 1
    (gdb) p multi'last(3)
    $3 = 1   <<<---  This should be 2!

Additionally, I noticed that a couple of check_typedef's were missing.
This patch adds them. And since the variable in question only gets
used within an "else" block, I moved the variable declaration and
use inside that block - making it clear what the scope of the variable
is.

gdb/ChangeLog:

        * ada-lang.c (ada_array_bound_from_type): Move the declaration
        and assignment of variable "elt_type" inside the else block
        where it is used.  Add two missing check_typedef calls.
        Fix bug where we got TYPE's TYPE_TARGET_TYPE, where in fact
        we really wanted to get ELT_TYPE's TYPE_TARGET_TYPE.

gdb/testsuite/ChangeLog:

        * gdb.ada/arraydim: New testcase.
2013-12-13 09:55:24 +01:00
Joel Brobecker fb5e3d5c69 Small style violation fix in ada_array_bound_from_type
gdb/ChangeLog:

        * ada-lang.c (ada_array_bound_from_type): Remove unwanted space
        between 'struct type *' and 'arr_type'.
2013-12-13 09:48:35 +01:00
Siva Chandra a16b0e220d 2013-12-12 Siva Chandra Reddy <sivachandra@google.com>
PR python/16113
	* NEWS (Python Scripting): Add entry for the new feature and the
	new attribute of gdb.Field objects.
	* python/py-type.c (gdbpy_is_field): New function
	(convert_field): Add 'parent_type' attribute to gdb.Field
	objects.
	* python/py-value.c (valpy_getitem): Allow subscript value to be
	a gdb.Field object.
	(value_has_field): New function
	(get_field_flag): New function
	* python/python-internal.h (gdbpy_is_field): Add declaration.

	testsuite/
	* gdb.python/py-value-cc.cc: Improve test case.
	* gdb.python/py-value-cc.exp: Add new tests to test usage of
	gdb.Field objects as subscripts on gdb.Value objects.

	doc/
	* gdb.texinfo (Values From Inferior): Add a note about using
	gdb.Field objects as subscripts on gdb.Value objects.
	(Types In Python): Add description about the new attribute
	"parent_type" of gdb.Field objects.
2013-12-12 15:21:53 -08:00
Joel Brobecker 9b26f0fbe4 Add @cindex for section documenting the -list-features GDB/MI command.
gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Miscellaneous Commands): Add @cindex
        entry for section docuumenting the -list-features GDB/MI command.
2013-12-12 16:54:48 +01:00
Pedro Alves b15e5c540f breakpoint.c:insert_bp_location: Constify local.
gdb/
2013-12-12  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (insert_bp_location): Make 'hw_bp_err_string' local
	const, and remove casts.
2013-12-12 10:44:42 +00:00
Pedro Alves f23981e991 Eliminate UNSUPPORTED_ERROR.
I have a case that could use an exception for "unsupported feature".
I found UNSUPPORTED_ERROR, but looking deeper, I think as is, reusing
it for other things would be fragile.  E.g., if the Python script
sourced by source_script_from_stream triggers any other missing
functionality that would result in UNSUPPORTED_ERROR being propagated
out to source_script_from_stream, that would confuse the error for
Python not being built into GDB.

This patch thus redoes things a little.  Instead of using an exception
for the "No Python" scenario, check whether Python is configured in
before actually trying to source the file.  It adds a new function
instead of using #ifdef HAVE_PYTHON directly, as that is better at
avoiding bitrot, as both Python and !Python paths are visible to the
compiler this way.

Tested on Fedora 17, with and without Python.

gdb/
2013-12-12  Pedro Alves  <palves@redhat.com>

	* cli/cli-cmds.c (source_script_from_stream) Use have_python
	instead of catching UNSUPPORTED_ERROR.
	* exceptions.h (UNSUPPORTED_ERROR): Delete.
	* python/python.c (source_python_script) [!HAVE_PYTHON]: Internal
	error if called.
	* python/python.h (have_python): New static inline function.
2013-12-12 10:15:48 +00:00
Doug Evans 43942612f4 * dwarf2read.c (lookup_dwo_cutu): Include name of dwp file in
"can't find DWO" warning.
2013-12-11 15:52:12 -08:00
Sergio Durigan Junior 08a6411c71 Sanitize access to gdbarch on the SDT probe API (and fix ARM bug)
This patch sanitizes the access to gdbarch made by various functions of
the SDT probe API.  Before this patch, gdbarch was being accessed via
the probe's objfile; however, this proved to cause a bug on 32-bit ARM
targets because during the parsing of the probe's arguments the code
needed to access some pseudo-registers of the architecture, and this
information is not fully correct on the objfile's gdbarch.

Basically, the approach taken was to instead pass the current/selected
frame to the parsing and evaluation functions, so that they can extract
the gdbarch directly from the frame.  It solved the ARM bug reported
above, and also contributed to make the API cleaner.

Tested on x86_64 and 32-bit ARM.

2013-12-11  Sergio Durigan Junior  <sergiodj@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Pass selected frame
	to get_probe_argument_count and evaluate_probe_argument.
	* probe.c (get_probe_argument_count): Adjust declaration to accept
	frame.  Pass frame to probe_ops's get_probe_argument_count.
	(evaluate_probe_argument): Likewise, for evaluate_probe_argument.
	(probe_safe_evaluate_at_pc): Pass frame to
	get_probe_argument_count and evaluate_probe_argument.
	* probe.h (struct probe_ops) <get_probe_argument_count,
	evaluate_probe_argument>: Adjust declarations to accept frame.
	(get_probe_argument_count, evaluate_probe_argument): Likewise.
	* solib-svr4.c (solib_event_probe_action): Get current frame.
	Pass it to get_probe_argument_count.
	(svr4_handle_solib_event): Get current frame.  Pass it to
	get_probe_argument_count and evaluate_probe_argument.
	* stap-probe.c (stap_parse_probe_arguments): Adjust declaration to
	accept gdbarch.  Do not obtain it from the probe's objfile.
	(stap_get_probe_argument_count): Adjust declaration to accept
	frame.  Obtain gdbarch from the frame.  Call generic
	can_evaluate_probe_arguments.  Pass gdbarch to
	stap_parse_probe_arguments.
	(stap_get_arg): Adjust declaration to accept gdbarch.  Pass it to
	stap_parse_probe_arguments.
	(stap_evaluate_probe_argument): Adjust declaration to accept
	frame.  Obtain gdbarch from the frame.  Pass gdbarch to
	stap_get_arg.
	(stap_compile_to_ax): Pass agent_expr's gdbarch to stap_get_arg.
	(compute_probe_arg): Obtain gdbarch from frame.  Pass frame to
	get_probe_argument_count and evaluate_probe_argument.
2013-12-10 23:59:00 -02:00
Yao Qi e7f0d979dd Fix a bug in matching notifications.
Due to copy-n-paste, the problem caused PR remote/15974 also exists
in gdbserver.  This patch fixes it in the same way.  Patch to fix
remote/15974 can be found:

  https://sourceware.org/ml/gdb-patches/2013-12/msg00014.html

gdb/gdbserver:

2013-12-11  Yao Qi  <yao@codesourcery.com>

	* notif.c (handle_notif_ack): Return 0 if no notification
	matches.
2013-12-11 09:38:58 +08:00
Doug Evans 7b3fd68b73 add missing PR# to previous entry 2013-12-10 16:21:41 -08:00
Doug Evans 0987cf3512 PR 16286
* c-lang.c (c_get_string): Ignore the declared size of the object
	if a specific length is requested.

	testsuite/
	* gdb.python/py-value.c: #include stdlib.h, string.h.
	(str): New struct.
	(main): New local xstr.
	* gdb.python/py-value.exp (test_value_in_inferior): Add test to
	fetch a value as a string with a length beyond the declared length
	of the array.
2013-12-10 16:20:08 -08:00
Doug Evans 34dc884e17 Delete interp_exec_p.
* interps.h (interp_exec_p): Delete.
    	* interps.c (interp_exec_p): Delete.
    	(interp_exec): Update.  Assert interp->procs->exec_proc != NULL.
    	* mi/mi-interp.c (mi_cmd_interpreter_exec): Update.
2013-12-10 16:06:53 -08:00
Andrew Burgess 409d8f4815 Add call to get_compiler_info to gdb_compile_shlib.
https://sourceware.org/ml/gdb-patches/2013-12/msg00374.html

gdb/testsuite/ChangeLog

	* lib/gdb.exp (gdb_compile_shlib): Add call to get_compiler_info,
	update comment.
2013-12-10 17:04:17 +00:00
Yao Qi bae8a07ab1 Use target_read_code in skip_prologue (amd64)
gdb:

2013-12-10  Yao Qi  <yao@codesourcery.com>

	* amd64-tdep.c (amd64_analyze_stack_align): Call
	target_read_code instead of target_read_memory.
	(amd64_analyze_prologue): Call read_code_unsigned_integer
	instead of read_memory_unsigned_integer.  Call read_code
	instead of read_memory.
	(amd64_skip_xmm_prologue): Likewise.
2013-12-10 20:27:56 +08:00
Yao Qi 0865b04a4d Use target_read_code in skip_prologue (i386)
GDB is able to cache memory accesses requested in target_read_code,
so target_read_code is more efficient than general target_read_memory.

This patch uses target_read_code and its variants to read target
memory in the functions related to i386_skip_prologue.  It improves
the performance when doing 'b foo' (foo is a function) in remote
debugging.

Nowadays, when we set a breakpoint on function f1, GDB will fetch the
code in f1 to determine the start of the function body (say skip the
prologue), it requests read from target many times.  With this patch
applied, the number of RSP 'm' packets are reduced.

gdb:

2013-12-10  Yao Qi  <yao@codesourcery.com>

	* corefile.c (read_code): New function.
	(read_code_integer): New function.
	(read_code_unsigned_integer): New function.
	* gdbcore.h (read_code): Declare.
	(read_code_integer): Declare.
	(read_code_unsigned_integer): Declare.
	* i386-tdep.c (i386_follow_jump): Call target_read_code instead
	of target_read_memory.  Call read_code_unsigned_integer instead
	of read_memory_unsigned_integer.
	(i386_analyze_struct_return): Likewise.
	(i386_skip_probe): Likewise.
	(i386_analyze_stack_align): Likewise.
	(i386_match_pattern): Likewise.
	(i386_skip_noop): Likewise.
	(i386_analyze_frame_setup): Likewise.
	(i386_analyze_register_saves): Likewise.
	(i386_skip_prologue): Likewise.
	(i386_skip_main_prologue): Likewise.
	(i386_frame_cache_1): Likewise.
2013-12-10 20:27:49 +08:00
Yao Qi f15cb84a84 Invalidate target cache before starting to handle event.
gdb:

2013-12-10  Yao Qi  <yao@codesourcery.com>

	* infrun.c: Include "target-dcache.h".
	(prepare_for_detach): Call target_dcache_invalidate.
	(wait_for_inferior): Likewise.
	(fetch_inferior_event): Likewise.
	(infrun_thread_stop_requested_callback): Likewise.  Set
	overlay_cache_invalid to 1.
2013-12-10 19:57:20 +08:00
Joel Brobecker 036e93dfda Set language for Ada minimal symbols.
This helps with the following issue: Given an Ada program defining
a global variable:

    package Pck is
       Watch : Integer := 1974;
    end Pck;

When printing the address of this variable, GDB also tries to print
the associated symbol name:

    (gdb) p watch'address
    $1 = (access integer) 0x6139d8 <pck__watch>
                                       ^^
                                       ||

The problem is that GDB prints the variable's linkage name, instead
of its natural name. This is because the language of the associated
minimal symbol never really gets set.

This patch adds handling for Ada symbols in symbol_find_demangled_name.
After this patch, we now get:

    (gdb) p watch'address
    $1 = (access integer) 0x6139d8 <pck.watch>
                                       ^
                                       |

gdb/ChangeLog:

        * symtab.c (symbol_find_demangled_name): Add handling of
        Ada symbols.

gdb/testsuite/ChangeLog:

        * gdb.ada/int_deref.exp: Add test verifying that we print
        the decoded symbol name when printing the address of Ada
        symbols.
2013-12-10 12:16:47 +01:00
Joel Brobecker 72bfa06c56 GDB/MI: Document support for -exec-run --start in -list-features
This adds "exec-run-start-option" in the output of the -list-features
commands, allowing front-ends to easily determine whether -exec-run
supports the --start option.

gdb/ChangeLog:

        * mi/mi-main.c (mi_cmd_list_features): add "exec-run-start-option".
        * NEWS: Expand the entry documenting the new -exec-run --start
        option to mention the corresponding new entry in the output of
        "-list-features".

gdb/doc/ChangeLog:

	* gdb.texinfo (GDB/MI Miscellaneous Commands): Document the new
	"exec-run-start-option" entry in the output of the "-list-features"
	command.

gdb/testsuite/ChangeLog:

        * gdb.mi/mi-start.exp: Add test verifying that -list-features
        contains "exec-run-start-option".
2013-12-10 12:12:14 +01:00
Joel Brobecker 94481b8c8f nameless LOAD_DLL_DEBUG_EVENT causes ntdll.dll to be missing
We observed on Windows 2012 that we were unable to unwind past
exception handlers. For instance, with any Ada program raising
an exception that does not get handled:

    % gnatmake -g a -bargs -shared
    % gdb a
    (gdb) start
    (gdb) catch exception unhandled
    Catchpoint 2: unhandled Ada exceptions
    (gdb) c
    Catchpoint 2, unhandled CONSTRAINT_ERROR at <__gnat_unhandled_exception> (
        e=0x645ff820 <constraint_error>) at s-excdeb.adb:53
    53      s-excdeb.adb: No such file or directory.

At this point, we can already see that something went wrong, since
the frame selected by the debugger corresponds to a runtime function
rather than the function in the user code that caused the exception
to be raised (in our case procedure A).

This is further confirmed by the fact that we are unable to unwind
all the way to procedure A:

    (gdb) bt
    #0  <__gnat_unhandled_exception> (e=0x645ff820 <constraint_error>)
        at s-excdeb.adb:53
    #1  0x000000006444e9a3 in <__gnat_notify_unhandled_exception> (excep=0x284d2
+0)
        at a-exextr.adb:144
    #2  0x00000000645f106a in __gnat_personality_imp ()
       from C:\[...]\libgnat-7.3.dll
    #3  0x000000006144d1b7 in _GCC_specific_handler (ms_exc=0x242fab0,
        this_frame=0x242fe60, ms_orig_context=0x242f5c0, ms_disp=0x242ef70,
        gcc_per=0x645f0960 <__gnat_personality_imp>)
        at ../../../src/libgcc/unwind-seh.c:289
    #4  0x00000000645f1211 in __gnat_personality_seh0 ()
       from C:\[...]\libgnat-7.3.dll
    #5  0x000007fad3879f4d in ?? ()
    Backtrace stopped: previous frame inner to this frame (corrupt stack?)

It turns out that the unwinder has been doing its job flawlessly
up until frame #5. The address in frame #5 is correct, but GDB
is not able to associate it with any symbol or unwind record.

And this is because this address is inside ntdll.dll, and when
we received the LOAD_DLL_DEBUG_EVENT for that DLL, the system
was not able to tell us the name of the library, thus causing us
to silently ignoring the event. Because GDB does not know about
ntdll.dll, it is unable to access the unwind information from it.
And because the function at that address does not use a frame
pointer, the unwinding becomes impossible.

This patch helps recovering ntdll.dll at the end of the "run/attach"
phase, simply by trying to locate that specific DLL again.

In terms of our medium to long term planning, it seems to me that
we should be able to simplify the code by ignoring LOAD_DLL_DEBUG_EVENT
during the startup phase, and modify windows_ensure_ntdll_loaded
to then detect and report all shared libraries after we've finished
inferior creation.  But for a change just before 7.7 branch creation,
I thought it was safest to just handle ntdll.dll specifically. This
is less intrusive, and ntdll is the only DLL affected by the problem
I know so far.

gdb/ChangeLog:

	* windows-nat.c (handle_load_dll): Add comments.
        (windows_ensure_ntdll_loaded): New function.
	(do_initial_windows_stuff): Use windows_ensure_ntdll_loaded.
        Add FIXME comment.
2013-12-10 11:02:56 +01:00
Joel Brobecker ebeec1e942 Fix gdb/ChangeLog date in last entry. 2013-12-08 12:28:10 +04:00
Yao Qi 11ec596510 Use gdb_produce_source
We added a new proc gdb_produce_source recently, and it can be used
more widely in lib/gdb.exp to generate source file.

gdb/testsuite:

2013-12-08  Yao Qi  <yao@codesourcery.com>

	* lib/gdb.exp (support_complex_tests): Use gdb_produce_source.
	(is_elf_target, is_ilp32_target, is_ilp64_target): Likewise.
	(is_64_target, is_amd64_regs_target): Likewise.
	(skip_altivec_tests, skip_vsx_tests, skip_btrace_tests): Likewise.
2013-12-08 15:20:18 +08:00
Joel Brobecker 0c2242c192 Document the GDB 7.6.2 release in gdb/ChangeLog
gdb/ChangeLog:

	GDB 7.6.2 released.
2013-12-08 08:40:37 +04:00
Yao Qi e5e6f788e4 Avoid "may be used uninitialized" warning
Hi,
I see such warning below on one compiler I am using.

cc1: warnings being treated as errors
../../workspace/gdb/stack.c: In function 'frame_info':
../../workspace/gdb/stack.c:1519:20: error: 'caller_pc' may be used uninitialized in this function

Go through the gdb-patches archives and find the "canonical" way to
fix this warning is to initialize the variable.

gdb:

2013-12-08  Yao Qi  <yao@codesourcery.com>

	* stack.c (frame_info): Initialize variable caller_pc.
2013-12-08 10:34:34 +08:00
Mike Frysinger 594d8fa8e9 strip off +x bits on non-executable/script files
These files are source files and have no business being +x.  We couldn't
easily fix it in CVS (you need login+write access to the raw rcs files),
but we can fix this w/git.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-12-07 02:03:03 -05:00
Mike Frysinger d9a196da2e gdb: testsuite: fix ksh shebang to use sh
These scripts use /bin/ksh, but they're dirt simple and can be used with
/bin/sh, so just change the shebang.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-12-07 01:59:26 -05:00
Pedro Alves 782d47dfbd Fix "info frame" in the outermost frame.
Doing "info frame" in the outermost frame, when that was indicated by
the next frame saying the unwound PC is undefined/not saved, results
in error and incomplete output:

 (gdb) bt
 #0  thread_function0 (arg=0x0) at threads.c:63
 #1  0x00000034cf407d14 in start_thread (arg=0x7ffff7fcb700) at pthread_create.c:309
 #2  0x000000323d4f168d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

 (gdb) frame 2
 #2  0x000000323d4f168d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115
 115             call    *%rax

 (gdb) info frame
 Stack level 2, frame at 0x0:
  rip = 0x323d4f168d in clone (../sysdeps/unix/sysv/linux/x86_64/clone.S:115); saved rip Register 16 was not saved
 (gdb)

Not saved register values are treated as optimized out values
internally throughout.  stack.c:frame_info is handing unvailable
values, but not optimized out ones.  The patch deletes the
frame_unwind_caller_pc_if_available wrapper function and instead lets
errors propagate to frame_info (it's only user).

As frame_unwind_pc now needs to be able to handle and cache two
different error scenarios, the prev_pc.p variable is replaced with an
enumeration.

(FWIW, I looked into making gdbarch_unwind_pc or a variant return
struct value's instead, but it results in lots of boxing and unboxing
for no real gain -- e.g., the mips and arm implementations need to do
computation on the unboxed PC value.  Might as well throw an error on
first attempt to get at invalid contents.)

After the patch, we get:

 (gdb) info frame
 Stack level 2, frame at 0x0:
  rip = 0x323d4f168d in clone (../sysdeps/unix/sysv/linux/x86_64/clone.S:115); saved rip = <not saved>
  Outermost frame: outermost
  caller of frame at 0x7ffff7fcafc0
  source language asm.
  Arglist at 0x7ffff7fcafb8, args:
  Locals at 0x7ffff7fcafb8, Previous frame's sp is 0x7ffff7fcafc8
 (gdb)

A new test is added.  It's based off dw2-reg-undefined.exp, and tweaked to
mark the return address (rip) of "stop_frame" as undefined.

Tested on x86_64 Fedora 17.

gdb/
2013-12-06  Pedro Alves  <palves@redhat.com>

	* frame.c (enum cached_copy_status): New enum.
	(struct frame_info) <prev_pc.p>: Change type to enum
	cached_copy_status.
	(fprint_frame): Handle not saved and unavailable prev_pc values.
	(frame_unwind_pc_if_available): Delete and merge contents into ...
	(frame_unwind_pc): ... here.  Handle OPTIMIZED_OUT_ERROR.  Adjust
	to use enum cached_copy_status.
	(frame_unwind_caller_pc_if_available): Delete.
	(create_new_frame): Adjust.
	* frame.h (frame_unwind_caller_pc_if_available): Delete
	declaration.
	* stack.c (frame_info): Use frame_unwind_caller_pc instead of
	frame_unwind_caller_pc_if_available, and handle
	NOT_AVAILABLE_ERROR and OPTIMIZED_OUT_ERROR errors.
	* valprint.c (val_print_optimized_out): Use val_print_not_saved.
	(val_print_not_saved): New function.
	* valprint.h (val_print_not_saved): Declare.

gdb/testsuite/
2013-12-06  Pedro Alves  <palves@redhat.com>

	* gdb.dwarf2/dw2-undefined-ret-addr.S: New file.
	* gdb.dwarf2/dw2-undefined-ret-addr.c: New file.
	* gdb.dwarf2/dw2-undefined-ret-addr.exp: New file.
2013-12-06 19:50:10 +00:00
Pedro Alves 710409a221 New OPTIMIZED_OUT_ERROR error code.
In order to catch <optimized out> errors like we catch <unavailable>
errors, this adds a new OPTIMIZED_OUT_ERROR error code, and throws it
in various places.

gdb/ChangeLog
2013-12-06  Andrew Burgess  <aburgess@broadcom.com>
	    Pedro Alves  <palves@redhat.com>

	* exceptions.h (errors): Add OPTIMIZED_OUT_ERROR.
	* dwarf2loc.c (write_pieced_value): Throw OPTIMIZED_OUT_ERROR.
	* frame.c (frame_unwind_register): Throw OPTIMIZED_OUT_ERROR.
	* spu-tdep.c (spu_software_single_step): Throw
	OPTIMIZED_OUT_ERROR.
	* valops.c (value_assign): Throw OPTIMIZED_OUT_ERROR.
2013-12-06 19:48:54 +00:00
Tom Tromey 7580e91767 update free_objfile comment
The introductory comment to free_objfile is obsolete.
This patch fixes it by removing all the obsolete bits.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* objfiles.c (free_objfile): Update comment.
2013-12-06 12:14:03 -07:00
Tom Tromey 53e0e56d64 remove objfile_to_front
I happened to notice that nothing uses objfile_to_front.
This patch removes it.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* objfiles.h (objfile_to_front): Remove.
	* objfiles.c (objfile_to_front): Remove.
2013-12-06 12:13:59 -07:00
Tom Tromey 830f7a41e3 remove unnecessary declaration
This removes an unnecessary declaration from minsyms.c.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* minsyms.c (get_symbol_leading_char): Remove unnecessary
	declaration.
2013-12-06 12:13:55 -07:00
Tom Tromey e1b06ae220 pack partial_symtab for space
This improves the packing of struct partial_symtab.  I noticed with
pahole that were were a couple of holes.  This consolidates the holes
without, I think, affecting readability -- it just moves the "user"
field a bit earlier in the struct.  This change saves a small amount
of memory.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* psympriv.h (struct partial_symtab) <user>: Move earlier.
2013-12-06 12:13:51 -07:00
Tom Tromey 2b69941d0d fix a couple of FIXMEs
This fixes a couple of old "32x64" FIXME comments by using paddress
with current_gdbarch rather than hex_string and a cast to long.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* cli/cli-cmds.c (edit_command): Use paddress, not hex_string.
	(list_command): Likewise.
2013-12-06 12:13:47 -07:00
Tom Tromey bf121224c7 put the psymtab filename in the filename bcache
This puts the psymtab filename in the filename bcache.
This saves a small amount of memory.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* psymtab.c (allocate_psymtab): Put the filename in the filename
	bcache.
2013-12-06 12:13:42 -07:00
Tom Tromey 8e96694e31 make symtab::dirname const
This makes symtab::dirname const and updates one spot to avoid an
intermediate constless result.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* buildsym.c (end_symtab_from_static_block): Use obstack_copy0.
	* symtab.h (struct symtab) <dirname>: Now const.
2013-12-06 12:13:37 -07:00
Tom Tromey 21ea9eece7 make symtab::filename const
This makes symtab::filename const and removes a newly unnecessary
cast.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* symfile.c (allocate_symtab): Remove cast.
	* symtab.h (struct symtab) <filename>: Now const.
2013-12-06 12:13:31 -07:00
Doug Evans 399d6e3089 * gdb.base/break.exp: Fix setting of $baz. 2013-12-06 10:19:01 -08:00
Tom Tromey 37fbcad0be remove some sym_probe_fns methods
While looking into the probe API, it seemed to me that there were a
number of methods in sym_probe_fns that were not needed.  This patch
removes them.

Specifically, it seems to me that sym_probe_fns ought to be concerned
with the API for constructing the probes.  Any method relating to some
aspect of an individual probe can be handled via the probe's own
vtable.  That is, the double indirection here doesn't seem useful --
it certainly isn't in fact used, but also I couldn't think of a
potential use.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Use
	get_probe_argument_count and evaluate_probe_argument.
	* elfread.c (elf_get_probe_argument_count)
	(elf_can_evaluate_probe_arguments, elf_evaluate_probe_argument)
	(elf_compile_to_ax): Remove.
	(elf_probe_fns): Update.
	* probe.c (get_probe_argument_count, can_evaluate_probe_arguments)
	(evaluate_probe_argument): Call method on probe, not via sym
	functions.
	* stap-probe.c (compute_probe_arg): Use get_probe_argument_count,
	evaluate_probe_argument.
	(compile_probe_arg): Use get_probe_argument_count.  Call method on
	probe, not via sym functions.
	* symfile-debug.c (debug_sym_get_probe_argument_count)
	(debug_can_evaluate_probe_arguments)
	(debug_sym_evaluate_probe_argument, debug_sym_compile_to_ax):
	Remove.
	(debug_sym_probe_fns): Remove.
	* symfile.h (struct sym_probe_fns) <sym_get_probe_argument_count,
	can_evaluate_probe_arguments, sym_evaluate_probe_argument,
	sym_compile_to_ax>: Remove fields.
2013-12-06 08:57:55 -07:00
Andrew Burgess 16b5a7cbae Add support for DW_OP_bit_piece and DW_OP_plus_uconst to DWARF assembler.
https://sourceware.org/ml/gdb-patches/2013-12/msg00143.html

gdb/testsuite/ChangeLog

	* lib/dwarf.exp: (Dwarf::_location): Handle DW_OP_bit_piece and
	DW_OP_plus_uconst.
2013-12-06 13:27:24 +00:00
Keven Boell f84bc21877 testsuite: introduce index in varobj child eval.
In some languages, e.g. fortran, arrays start with index 1
instead 0. This patch changes the MI library to support testing
varobj children of fortran arrays.

2013-11-21  Keven Boell  <keven.boell@intel.com>

testsuite/

	* lib/mi-support.exp (mi_list_varobj_children_range): Add
	call to mi_list_array_varobj_children_with_index.
	(mi_list_array_varobj_children_with_index): New function.
	Add parameter to specify array start.
2013-12-06 10:02:16 +01:00
Pierre Muller 8662d51346 Fix completion for pascal language.
* p-exp.y (exp : field_exp name): Do not call mark_struct_expression.
       (exp : field_exp name COMPLETE): New rule.
       (exp : SIZEOF): Set correct current_type.
       (last_was_structop): Remove static variable.
       (yylex): Remove saw_structop local variable.
       Adapt code to removal of variables above.
2013-12-06 09:37:35 +01:00
Joel Brobecker da361ebd2d Uninitialized variable "this_id" in frame.c:get_prev_frame_1.
With a simple Ada program where I have 3 functions, one just calling
the next, the backtrace is currently broken when GDB is compiled
at -O2:

   #0  hello.first () at hello.adb:5
   #1  0x0000000100001475 in hello.second () at hello.adb:10
   Backtrace stopped: previous frame inner to this frame (corrupt stack?)

It turns out that a recent patch deleted the assignment of variable
this_id, making it an unitialized variable:

        * 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.

The hunk in question starts with:

-  /* Check that this frame is not the outermost.  If it is, don't try
-     to unwind to the prev frame.  */
-  this_id = get_frame_id (this_frame);
-  if (frame_id_eq (this_id, outer_frame_id))

(the code was removed as redundant - but removing the assignment
was in fact not intentional).

There is no other code in this function that sets the variable.
Instead of re-adding the statement in the lone section where it is
actually used, I inlined it, and then got rid of the variable
altogether.  This way, and until we start needing this frame ID
in another location within that function, we dont' have to worry
about the variable's validity/lifetime.

gdb/ChangeLog:

        * frame.c (get_prev_frame_1): Delete variable "this_id".
        Replace its use by a call to get_frame_id.
2013-12-06 08:51:15 +04:00
Anthony Green 6ed1ff02f3 Add software single step support to moxie port 2013-12-05 10:25:03 -05:00
Doug Evans 39d7494aad fix date in previous entry 2013-12-04 22:12:54 -08:00
Doug Evans c47cf54742 * auto-load.c (load_auto_scripts_for_objfile): Add some comments. 2013-12-04 22:08:38 -08:00
Joel Brobecker 170d82c951 Allow Windows UNWIND_INFO version 2.
We've observed in Windows 2012 that ntdll.dll contains some unwind
records with the version field set to 2.  This patch adjusts the
decoder to accept records flagged with this version as well.

Version 2 appears to still be largely undocumented at this stage.
However, apart from a mysterious opcode 6, everything else still
seems to remain the same. So this patch also changes the decoder
to ignore those opcodes; before this change, the debugger would
silently stop the decoding, and let the frame unwinder make do
with what it the decoder managed to decode up to that point.

It's unclear at this point what we're losing by not being able to
decode that opcode. But the information does not appear to be critical,
at least as far as call unwinding is concerned.

gdb/ChangeLog:

	(from Tristan Gingold  <gingold@adacore.com>)
	(from Joel Brobecker  <brobecker@adacore.com>)
	* amd64-windows-tdep.c (amd64_windows_frame_decode_insns):
	Accept version 2.  Ignore operations using opcode 6.
2013-12-05 07:41:31 +04:00
Joel Brobecker a5e619ec1f Minor coding-style fixes in ada-lex.l:find_dot_all.
gdb/ChangeLog:

        * ada-lex.l (find_dot_all): Fix coding style violations.
2013-12-05 07:38:49 +04:00
Eli Zaretskii 22f25c9dd6 Fix the manual more thoroughly. 2013-12-04 19:44:30 +02:00
Eli Zaretskii 3ea8680f84 doc/gdb.texinfo (i386): Fix yesterday's commit. 2013-12-04 18:12:16 +02:00
Tom Tromey 1a4f73eb8a add @kindex for catchpoints
I wanted to find the docs for "catch load" the other day, and I found
out that this isn't in the index.  It seems to me that each command
ought to be in the index for quick reference like this, so this patch
adds an @kindex (chosen because it seems to be what the rest of the
manual does) for each "catch" subcommand.

2013-12-03  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Set Catchpoints): Add @kindex for each command
	documented here.
2013-12-03 13:04:16 -07:00
Tom Tromey 6cb999f8df add "dir" menu item for gdbserver
I happened to notice that the gdbserver program doesn't appear in the
top-level "dir" file.  This adds an entry for it to the gdb manual.

2013-12-03  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (@direntry): Add menu item for gdbserver.
2013-12-03 13:02:48 -07:00
Walfred Tedeschi ca8941bbd0 Documentation for MPX.
2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* NEWS:  Add section for Intel(R) Architecture Instructions
	Extesions mentioning MPX.
doc/
	* gdb.texinfo (i386 Features): Add MPX feature registers.
	(x86 Specific featuresx86 Architecture-specific Issues): Adds
	a subsubsection for MPX and describes the display of the
	boundary registers.


Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
2013-12-03 13:31:03 +00:00
Jose E. Marchesi 489e41ddf4 Fixed typo in date in testsuite/ChangeLog entry 2013-12-03 04:41:30 -08:00
Jose E. Marchesi f130030056 testsuite: handle SIGLOST/SIGPWR conflict in sparc64-*-linux-gnu targets.
2013-10-03  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* gdb.base/sigall.exp (test_one_sig): gdb identifies SIGLOST as a
	SIGPWR in sparc64.

	* gdb.base/sigall.c (main): In some targets SIGLOST and SIGPWR
	have the same signal number.  Handle this situation.
2013-12-03 04:34:48 -08:00
Joel Brobecker 7fb1b8b13f Ada: Reserved word "all" should not need to be spelled in lowercase.
Consider the following code:

   type Ptr is access all Integer;
   IP : Ptr := new Integer'(123);

IP is the Ada exception of a pointer to an integer. To dereference
the pointer and get its value, the user uses the reserved word "all"
as follow:

    (gdb) p ip.all
    $1 = 123

Ada being a case-insensitive language, the casing should not matter.
Unfortunately, for the reserved word "all", things don't work. For
instance:

    (gdb) p ip.ALL
    Type integer is not a structure or union type

This patch fixes the problem.

gdb/ChangeLog:

	* ada-lex.l (find_dot_all): Use strncasecmp instead of strncmp.

gdb/testsuite/ChangeLog:

        * gdb.ada/dot_all: New testcase.
2013-12-03 16:04:26 +04:00
Joel Brobecker 849f2b52ec crash evaluating bogus exception condition expression (sparc-solaris)
With a program raising an exception, trying to debug that program
in GDB/MI mode can yield a crash:

    % gdb -i=mi foo
    (gdb)
    -catch-exception -e "Program_Error"
    ^done,bkptno="2",bkpt={number="2",type="breakpoint",[...]
    (gdb)
    -exec-continue
    ^running
    *running,thread-id="all"
    (gdb)
    =library-loaded,id=[...]
    &"warning: failed to reevaluate internal exception condition for catchpoint 2: Error in expression, near `'.\n"
    zsh: 22956 bus error (core dumped)  gdb -q -i=mi foo

The problem is triggered by a problem in the compiler which causes
EXP in the following TRY_CATCH block to change unexpectedly when
parse_exp_1 throws an error :

   |      TRY_CATCH (e, RETURN_MASK_ERROR)
   |        {
   |          exp = parse_exp_1 (&s, bl->address,
   |                             block_for_pc (bl->address), 0);
   |        }

In ada-lang.c:create_excep_cond_exprs, EXP is initialized to NULL,
and is expected to remain NULL if parse_exp_1 throws.  Instead,
its value gets changed to something invalid.  This later crashes
the debugger, when trying to evaluate the bogus expression.

This patch works around the issue by simply forcing EXP back to NULL
when an exception was thrown. A comment explaining why, and the sort
of timeline we're looking at for a fix, is also added.

gdb/ChangeLog:

        * ada-lang.c (create_excep_cond_exprs): Force EXP to NULL
        when parse_exp_1 threw an error.  Add comment.
2013-12-03 15:42:48 +04:00
Joel Brobecker 4e35e8085e NEWS: Extend documentation of the new GDB/MI --language option.
This patch extends a bit the news entry we added which documents
general support of the --language option, to add a small reference
to the associated entry which was also added to the "-list-features"
command output.

gdb/ChangeLog:

        * NEWS: Mention "-list-features" in the entry documenting
        the support for the "--language" option.
2013-12-03 14:20:18 +04:00
Samuel Bronson caf26be91a Resurrect gdb-add-index as a contrib script
This includes changes made in Fedora's gdb packaging[1], Doug's
robustness patch[2] from before gdb-add-index was dropped, some
corrections, and some more changes Doug accumulated in the
meantime[3].

[1]: http://pkgs.fedoraproject.org/cgit/gdb.git/log/gdb-gdb-add-index-script.patch?id=fe74423b0812bae6d7bb027584e401a2ac37d24d
[2]: https://sourceware.org/ml/gdb-patches/2010-09/msg00130.html
[3]: https://sourceware.org/ml/gdb-patches/2013-11/msg00297.html

It would be a good idea to mention the existance of this script
in (info "(gdb) Index Files"), but I'm boycotting invariant
sections/cover texts because non-free docs are a PITA, so somebody
else would need to do that.

Summary of previous activity:

97924a9 Actual removal
c29c521 Attempted removal (accidentally left gdb-add-index.sh in place)
c2bbed2 Addition
2013-12-03 00:17:59 -05:00
Samuel Bronson 34a4fb3a70 MAINTAINERS (Write After Approval): Add myself to the list. 2013-12-03 00:17:57 -05:00
Joel Brobecker 688981c916 Remove "ada-exceptions" from -list-features output.
Now that the -info-gdb-mi-command is available, there is no need for
this entry. The entry and associated new commands were added recently
enough that no front-end out there should be depending on it yet.

gdb/ChangeLog:

        * mi/mi-main.c (mi_cmd_list_features): Remove "ada-exceptions".

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Miscellaneous Commands): Remove the
        documentation of the "ada-exceptions" entry.
2013-12-03 08:53:11 +04:00
Joel Brobecker c1244769eb Remove all trailing spaces in mi/mi-main.c.
No code change, just a mechanical cleanup.

gdb/ChangeLog:

        * mi/mi-main.c: Remove trailing spaces throughout.
2013-12-03 08:53:11 +04:00
Joel Brobecker 2ea126fa78 Add "undefined-command" error code at end of ^error result...
... when trying to execute an undefined GDB/MI command. When trying
to execute a GDB/MI command which does not exist, the current error
result record looks like this:

    -unsupported
    ^error,msg="Undefined MI command: unsupported"

The only indication that the command does not exist is the error
message. It would be a little fragile for a consumer to rely solely
on the contents of the error message in order to determine whether
a command exists or not.

This patch improves the situation by adding concept of error
code, starting with one well-defined error code ("undefined-command")
identifying errors due to a non-existant command. Here is the new
output:

    -unsupported
    ^error,msg="Undefined MI command: unsupported",code="undefined-command"

This error code is only displayed when the corresponding error
condition is met. Otherwise, the error record remains unchanged.
For instance:

    -symbol-list-lines foo.adb
    ^error,msg="-symbol-list-lines: Unknown source file name."

For frontends to be able to know whether they can rely on this
variable, a new entry "undefined-command-error-code" has been
added to the "-list-features" command.  Another option would be
to always generate an error="..." variable (for the default case,
we could decide for instance that the error code is the empty string).
But it seems more efficient to provide that info in "-list-features"
and then only add the error code when meaningful.

gdb/ChangeLog:

        (from Pedro Alves  <palves@redhat.com>)
        (from Joel Brobecker  <brobecker@adacore.com>)
        * exceptions.h (enum_errors) <UNDEFINED_COMMAND_ERROR>: New enum.
        * mi/mi-parse.c (mi_parse): Throw UNDEFINED_COMMAND_ERROR instead
        of a regular error when the GDB/MI command does not exist.
        * mi/mi-main.c (mi_cmd_list_features): Add
        "undefined-command-error-code".
        (mi_print_exception): Print an "undefined-command"
        error code if EXCEPTION.ERROR is UNDEFINED_COMMAND_ERROR.
        * NEWS: Add entry documenting the new "code" variable in
        "^error" result records.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Result Records): Fix the syntax of the
        "^error" result record concerning the error message.  Document
        the error code that may also be part of that result record.
        (GDB/MI Miscellaneous Commands): Document the
        "undefined-command-error-code" element in the output of
        the "-list-features" GDB/MI command.

gdb/testsuite/ChangeLog:

        * gdb.mi/mi-undefined-cmd.exp: New testcase.
2013-12-03 08:01:01 +04:00
Joel Brobecker 6b7cbff192 New GDB/MI command "-info-gdb-mi-command"
This patch adds a new GDB/MI command meant for graphical frontends
trying to determine whether a given GDB/MI command exists or not.

Examples:

    -info-gdb-mi-command unsupported-command
    ^done,command={exists="false"}
    (gdb)
    -info-gdb-mi-command symbol-list-lines
    ^done,command={exists="true"}
    (gdb)

At the moment, this is the only piece of information that this
command returns.

Eventually, and if needed, we can extend it to provide
command-specific pieces of information, such as updates to
the command's syntax since inception.  This could become,
for instance:

    -info-gdb-mi-command symbol-list-lines
    ^done,command={exists="true",features=[]}
    (gdb)
    -info-gdb-mi-command catch-assert
    ^done,command={exists="true",features=["conditions"]}

In the first case, it would mean that no extra features,
while in the second, it announces that the -catch-assert
command in this version of the debugger supports a feature
called "condition" - exact semantics to be documented with
combined with the rest of the queried command's documentation.

But for now, we start small, and only worry about existance.
And to bootstrap the process, I have added an entry in the
output of the -list-features command as well ("info-gdb-mi-command"),
allowing the graphical frontends to go through the following process:

  1. Send -list-features, collect info from there as before;
  2. Check if the output contains "info-gdb-mi-command".
     If it does, then support for various commands can be
     queried though -info-gdb-mi-command. Newer commands
     will be expected to always be checked via this new
     -info-gdb-mi-command.

gdb/ChangeLog:

        * mi/mi-cmds.h (mi_cmd_info_gdb_mi_command): Declare.
        * mi/mi-cmd-info.c (mi_cmd_info_gdb_mi_command): New function.
        * mi/mi-cmds.c (mi_cmds): Add -info-gdb-mi-command command.
        * mi/mi-main.c (mi_cmd_list_features): Add "info-gdb-mi-command"
        field to output of "-list-features".

        * NEWS: Add entry for new -info-gdb-mi-command.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Miscellaneous Commands): Document
        the new -info-gdb-mi-command GDB/MI command.  Document
        the meaning of "-info-gdb-mi-command" in the output of
        -list-features.

gdb/testsuite/ChangeLog:

        * gdb.mi/mi-i-cmd.exp: New file.
2013-12-03 07:57:24 +04:00
Jan Kratochvil 04affae3ef 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.
2013-12-02 22:24:32 +01:00
Pedro Alves aee4bf8505 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.
2013-12-02 11:10:20 +00:00
Pedro Alves 840207d8ee 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.
2013-12-02 11:09:24 +00:00
Pedro Alves 0fdf84ca4b 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.
2013-12-02 10:42:02 +00:00
Yao Qi 62972e0b66 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.
2013-12-02 14:44:14 +08:00
Joel Brobecker f9b0da3d58 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.
2013-12-02 07:14:10 +04:00
Joel Brobecker 2dd4d4224a 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".
2013-12-02 07:10:29 +04:00
Joel Brobecker e72eff80bf 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.
2013-12-02 07:05:10 +04:00
Joel Brobecker 844ad0054a 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".
2013-12-02 06:57:38 +04:00
Doug Evans 5b2bf9471f 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.
2013-11-29 21:29:26 -08:00
Yao Qi d9c4392818 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".
2013-11-30 11:17:16 +08:00
Sergio Durigan Junior e7b1239280 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
0e9f083f4c.

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>.
2013-11-29 20:28:16 -02:00
Doug Evans 7b2d3abff9 * python/py-auto-load.c (source_section_scripts): Move comment to
more relevant location.
2013-11-29 12:34:32 -08:00
Doug Evans 256458bc0e 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.
2013-11-29 12:00:47 -08:00
Pedro Alves 20e1ca3bc1 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.
2013-11-29 15:25:46 +00:00
Pedro Alves 8b4f3082d8 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.
2013-11-29 14:50:26 +00:00
Yao Qi 9f7132948d 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 &current_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.
2013-11-29 21:32:03 +08:00
Doug Evans 4cb0213de5 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.
2013-11-28 14:54:32 -08:00
Doug Evans d729aae0fd fix spelling in previous entry 2013-11-28 14:31:55 -08:00
Doug Evans d344e670e7 * configure.ac: Add comments delineating libpython and libmcheck.
* configure: Regenerate.
2013-11-28 14:30:59 -08:00
Andrew Burgess eebc056c8e 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.
2013-11-28 18:54:20 +00:00
Pedro Alves a730086980 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.
2013-11-28 18:09:41 +00:00
Pedro Alves 50fd528a13 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.
2013-11-28 17:37:47 +00:00
Pedro Alves 5de5158168 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.
2013-11-28 17:35:28 +00:00
Pedro Alves 739cb10c0e 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".
2013-11-28 17:32:26 +00:00
Pedro Alves 514c0aa6a3 Fix PR 16152's ChangeLog entry.
Mention PR 16152.  Fix formatting.  Make wording match commit log.
2013-11-28 17:27:36 +00:00
Yao Qi 8b5e6dc217 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.
2013-11-28 12:53:26 +08:00
Steffen Sledz 92a021debf 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.
2013-11-27 18:51:49 +00:00
Pedro Alves 908fa2aaed 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.
2013-11-27 17:55:38 +00:00
Pedro Alves 6bd273ae45 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.
2013-11-27 17:49:59 +00:00
Andrew Burgess f6c01fc515 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.
2013-11-27 17:49:59 +00:00
Luis Machado 0db4ca1856 * 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.
2013-11-27 10:39:26 -02:00
Andrew Burgess d24a9f159c 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.
2013-11-26 16:36:21 +00:00
Andrew Burgess 4f14910fa1 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.
2013-11-26 16:21:53 +00:00
Tom Tromey 158599681f revert patch from 2013-11-22
This reverts da2b2fdf57 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.
2013-11-26 07:47:56 -07:00
Walfred Tedeschi 244ec0da38 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.
2013-11-26 08:32:16 +00:00
Keith Seitz f7e3ecae9f PR c++/14819: Explicit class:: inside class scope does not work
https://sourceware.org/ml/gdb-patches/2013-11/msg00102.html
2013-11-25 13:37:08 -08:00
Yao Qi 23e9d3b9ce 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.
2013-11-25 09:12:38 +08:00
Yao Qi 283f7163ec 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.
2013-11-24 14:56:51 +08:00
Yao Qi 29453a1455 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.
2013-11-24 14:56:49 +08:00
Yao Qi 0fb14d8ffd 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.
2013-11-24 14:56:48 +08:00
Yao Qi 22825df749 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.
2013-11-24 14:33:31 +08:00
Yao Qi 6dd315bae3 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.
2013-11-24 11:11:39 +08:00
Doug Evans c1ea7c017e * gdb.base/ena-dis-br.exp: Add missing quote to "step after continue
with ignore count".
2013-11-23 16:43:29 -08:00
Doug Evans 35720eaabd 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.
2013-11-23 16:03:47 -08:00
Doug Evans 3cd14e4575 * gdb.python/py-type.exp (test_enums): Fix typo. 2013-11-23 15:54:05 -08:00
Doug Evans 985c818c2d * gdb.python/py-symbol.exp: Add some comments. Make all test names unique. 2013-11-23 15:45:43 -08:00
Doug Evans f873dd7ade * gdb.python/py-symbol.exp: Fix whitespace. 2013-11-23 15:20:42 -08:00
Doug Evans 995c1ad93a Fix long line in earlier entry. 2013-11-23 15:15:17 -08:00
Doug Evans 38a502a410 * 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.
2013-11-23 15:08:28 -08:00
Doug Evans a12361b95c * python/py-frame.c (gdbpy_initialize_frames): Remove FIRST_ERROR,
superfluous.
2013-11-23 14:46:43 -08:00
Doug Evans 1e1d69201b * python/py-frame.c (frapy_block): Fix error message text. 2013-11-23 14:36:57 -08:00
Doug Evans 1e9c71b81b 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.
2013-11-23 11:47:24 -08:00
Yao Qi 9df9dbe031 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.
2013-11-23 20:33:11 +08:00
Sterling Augustine 38e1f2a7d5 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.
2013-11-22 14:25:14 -08:00
Sterling Augustine f380848e84 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.
2013-11-22 13:58:55 -08:00
Pedro Alves c0621699ff 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.
2013-11-22 19:19:13 +00:00
Tom Tromey f57e61cdf6 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.
2013-11-22 12:08:15 -07:00
Tom Tromey da2b2fdf57 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.
2013-11-22 11:02:01 -07:00
Tom Tromey 6eeee81c8e 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.
2013-11-22 17:38:44 +00:00
Pedro Alves 194cca4119 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.
2013-11-22 13:53:39 +00:00
Pedro Alves 33f8fe58b9 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.
2013-11-22 13:50:48 +00:00
Pedro Alves 1ec56e88aa 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.
2013-11-22 13:50:11 +00:00
Pedro Alves 8ad6489081 Revert "Don't let two frames with the same id end up in the frame chain."
This reverts commit be2c48b4d5.
2013-11-22 13:46:51 +00:00
Pedro Alves c8381c86b4 Revert "Make use of the frame stash to detect wider stack cycles."
This reverts commit f5b0ed3c8c.
2013-11-22 13:46:43 +00:00
Pedro Alves 1bd122facc Revert "Eliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer (move dwarf2_tailcall_sniffer_first elsewhere)."
This reverts commit 1dc8686c48.
2013-11-22 13:46:35 +00:00
Pedro Alves 1dc8686c48 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.
2013-11-22 13:41:59 +00:00
Pedro Alves f5b0ed3c8c 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.
2013-11-22 13:41:43 +00:00
Pedro Alves be2c48b4d5 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.
2013-11-22 13:41:43 +00:00
Doug Evans ca092b61dc 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.
2013-11-21 20:28:35 -08:00
Yao Qi 0a1e61210c Check has_more in mi_create_dynamic_varobj
Hi,
I find "has_more" is not checked when a dynamic varobj is created in
proc mi_create_dynamic_varobj.  This patch adds the check to
"has_more".

gdb/testsuite:

2013-11-22  Yao Qi  <yao@codesourcery.com>

	* lib/mi-support.exp (mi_create_dynamic_varobj): Update
	comment and add one more argument "has_more".
	* gdb.python/py-mi.exp: Callers update.
2013-11-22 08:34:42 +08:00
Yao Qi 0061ea2440 Use mi_create_floating_varobj
In gdb.python/py-mi.exp, two varobjs container and nscont are created
when pretty-printing is still not enabled, so they are not dynamic
varobj, IIUC.  In this patch, we use mi_create_floating_varobj instead
of mi_create_dynamic_varobj.

gdb/testsuite:

2013-11-22  Yao Qi  <yao@codesourcery.com>

	* gdb.python/py-mi.exp: Use mi_create_floating_varobj instead
	of mi_create_dynamic_varobj.
2013-11-22 08:34:22 +08:00
Yao Qi c78feb398f Doc 'dynamic' for command -var-list-children
Hi,
I find "dynamic=1" appear in the result of each child of the output of
-var-list-children,

  -var-list-children  ss1
  ^done,numchild="2",children=[child={name="ss1.a",exp="a",numchild="0",type="struct s",thread-id="1",dynamic="1"},child={name="ss1.b",exp="b",numchild="0",type="struct s",thread-id="1",dynamic="1"}],has_more="0"

but the doc doesn't mention this.  This patch is to copy the description
of "dynamic=1" here.

gdb/doc:

2013-11-21  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (GDB/MI Variable Objects): Add attribute 'dynamic'
	for the output of command -var-list-children.
2013-11-21 11:41:55 +08:00
Yao Qi 27b81af3ea s/see @pxref/@pxref in doc
Looks "see" is unnecessary before @pxref.

gdb/doc:

2013-11-21  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (Caching Target Data): Remove "see" before
	@pxref.
2013-11-21 10:33:39 +08:00
Doug Evans ebcf782c74 * linux-low.c (linux_set_resume_request): Fix comment. 2013-11-20 17:32:33 -08:00
Doug Evans 20ad937816 * linux-low.c (resume_status_pending_p): Tweak comment. 2013-11-20 16:31:48 -08:00
Pedro Alves 069d6a0fbf Add missing ChangeLog entry.
2013-11-20  Pedro Alves  <palves@redhat.com>

	* gdb.base/maint.exp (maint print objfiles): Consume one line at a
	time, and run it through all three milestone regexes.
2013-11-20 17:23:39 +00:00
Joel Brobecker 7c245c246c get rid of py-value.c:is_intlike (use is_integral_type instead)
is_intlike was mostly duplicating is_integral_type, with the exception
of the handling of TYPE_CODE_PTR when parameter PTR_OK is nonzero.
This patches deletes the is_intlike function, using is_integral_type
instead, and adjusting the two locations where this function gets
called.

The code should remain strictly equivalent.

gdb/ChangeLog:

        * python/py-value.c (is_intlike): Delete.
        (valpy_int): Replace use of CHECK_TYPEDEF and is_intlike
        by use of is_integral_type.
        (valpy_long): Replace use of CHECK_TYPEDEF and is_intlike
        by use of is_integral_type and check for TYPE_CODE_PTR.
2013-11-20 21:20:11 +04:00
Pedro Alves e48744a00a Make the maint.exp:'maint print objfiles' test less fragile.
I was "lucky" enough that an unrelated patch changed how many symtabs
GDB expands in a plain run to main, and that triggered a latent issue
in this test:

  PASS: gdb.base/maint.exp: maint print objfiles: header
  PASS: gdb.base/maint.exp: maint print objfiles: psymtabs
  FAIL: gdb.base/maint.exp: maint print objfiles: symtabs

The problem is in my case, expect is managing to alway put in the
buffer chunks like this:


  Psymtabs:
  ../../../src/gdb/testsuite/gdb.base/break1.c at 0x1ed2280, ../../../src/gdb/testsuite/gdb.base/break.c at 0x1ed21d0,

  Symtabs:
  ../../../src/gdb/testsuite/gdb.base/break.c at 0x1f044f0, /usr/include/stdio.h at 0x1ed25a0, /usr/include/libio.h at 0x1ed2510, /usr/include/bits/types.h at 0x1ed2480, /usr/lib/gcc/x86_64-redhat-linux/4.7.2/include/stddef.h at 0x1ed23f0,


  Object file /usr/lib/debug/lib64/ld-2.15.so.debug:  Objfile at 0x1f4bff0, bfd at 0x1f2d940, 0 minsyms

  Psymtabs:
  bsearch.c at 0x1f65340, ../sysdeps/x86_64/multiarch/init-arch.c at
  0x1f65290, ...

Note: Psymtabs:/Symtabs:/Psymtabs:.

So, the loop matches the first Psymtabs in the buffer.  Then we're
left with


  ../../../src/gdb/testsuite/gdb.base/break1.c at 0x1ed2280, ../../../src/gdb/testsuite/gdb.base/break.c at 0x1ed21d0,

  Symtabs:
  ../../../src/gdb/testsuite/gdb.base/break.c at 0x1f044f0, /usr/include/stdio.h at 0x1ed25a0, /usr/include/libio.h at 0x1ed2510, /usr/include/bits/types.h at 0x1ed2480, /usr/lib/gcc/x86_64-redhat-linux/4.7.2/include/stddef.h at 0x1ed23f0,


  Object file /usr/lib/debug/lib64/ld-2.15.so.debug:  Objfile at 0x1f4bff0, bfd at 0x1f2d940, 0 minsyms

  Psymtabs:
  bsearch.c at 0x1f65340, ../sysdeps/x86_64/multiarch/init-arch.c at
  0x1f65290, ...

In the next iteration, because the psymtabs regex comes first, we
match with the Psymtabs: line, then of course, end up with just

  bsearch.c at 0x1f65340, ../sysdeps/x86_64/multiarch/init-arch.c at
  0x1f65290, ...

in the buffer.  The "Symtabs:" line is lost.  expect then reads more
gdb output, and manages to again retrieve the same pattern.  Rinse,
repeat, and the test never matches any "Symtab:" line.

We don't know the order the matches lines will appear, so the fix is
to consume one line at a time, and run it through all three milestone
regexes.

gdb/testsuite/
2013-11-20  Pedro Alves  <palves@redhat.com>

	* gdb.base/maint.exp (maint print objfiles): Consume one line at a
	time, and run it through all three milestone regexes.
2013-11-20 17:12:37 +00:00
Tom Tromey 8986e351a4 remove strerror module
This fixes the mingw build breakage reported by Pierre.

I found that the gnulib strerror module somehow requires us to pull in
the gethostname module.  However, pulling in the gethostname module
makes many things break.

I've sent a bug report to gnulib.

Meanwhile, removing the strerror module should not harm gdb and fixes
the build.

I'm checking this in.

2013-11-20  Tom Tromey  <tromey@redhat.com>

	* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Remove
	strerror module.
	* gnulib/aclocal.m4: Update.
	* gnulib/config.in: Update.
	* gnulib/configure: Update.
	* gnulib/import/Makefile.am: Update.
	* gnulib/import/Makefile.in: Update.
	* gnulib/import/errno.in.h: Remove.
	* gnulib/import/intprops.h: Remove.
	* gnulib/import/m4/errno_h.m4: Remove.
	* gnulib/import/m4/gnulib-cache.m4: Update.
	* gnulib/import/m4/gnulib-comp.m4: Update.
	* gnulib/import/m4/strerror.m4: Remove.
	* gnulib/import/m4/sys_socket_h.m4: Remove.
	* gnulib/import/strerror-override.c: Remove.
	* gnulib/import/strerror-override.h: Remove.
	* gnulib/import/strerror.c: Remove.
	* gnulib/update-gnulib.sh: Update.
2013-11-20 08:49:40 -07:00
Sanimir Agovic 10d8cbd222 test: test eval routines with EVAL_AVOID_SIDE_EFFECTS flag set
Ensure that certain commands (e.g. whatis/ptype) and sizeof intrinsic
have no side effects (variables cannot be altered).

2013-11-20  Sanimir Agovic  <sanimir.agovic@intel.com>

testsuite/
	* gdb.base/eval-avoid-side-effects.exp: New test.
2013-11-20 13:50:14 +00:00
Yao Qi 6b1141e3f3 set_address_space_data if dcache is NULL.
gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

	* target-dcache.c (target_dcache_get_or_init): Call
	set_address_space_data if 'dcache' is NULL.
2013-11-20 21:15:57 +08:00
Walfred Tedeschi 60650f2e2f Add MPX registers tests.
2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* common/i386-gcc-cpuid.h (bit_MPX): Synchronize with gcc file.
testsuite/
	* gdb.arch/i386-mpx.c: New file
	* gdb.arch/i386-mpx.exp: New file.

Change-Id: Ica4c9ee823c8210ca876e31f27dcd8583b660a9f
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
2013-11-20 14:42:53 +01:00
Walfred Tedeschi 09748966c1 Add pretty-printer for MPX bnd registers.
Boundary length is simpler implemented by means of a pretty
printer. This simplifies users life when examining a bound register.

Changelog:
2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* python/lib/gdb/command/bound_register.py: New file.
	* gdb/data-directory/Makefile.in: copy bond_register.py to the right path to
	be initialized at gdb startup.
testsuite/
	* gdb.python/py-pp-maint.exp: Consider new pretty-print added for registers.

Change-Id: Id4f39845e5ece56c370a1fd4343648909f08b731
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>

Conflicts:

	gdb/ChangeLog
2013-11-20 14:42:53 +01:00
Walfred Tedeschi a196ebeb91 Add MPX support to gdbserver.
2013-05-22  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdbserver/
	* Makefile.in: Add i386-mpx.c, i386-mpx-linux.c, amd64-mpx.c,
	amd64-mpx-linux.c, x32-mpx.c and x32-mpx-linux.c generation.

	* configure.srv (srv_i386_regobj): Add i386-mpx.o.
	(srv_i386_linux_regobj): Add i386-mpx-linux.o.
	(srv_amd64_regobj): Add amd64-mpx.o.
	(srv_amd64_linux_regobj): Add amd64-mpx-linux.o.
	(srv_i386_32bit_xmlfiles): Add i386/32bit-mpx.xml.
	(srv_i386_64bit_xmlfiles): Add i386/64bit-mpx.xml.

	* i387-fp.c (num_pl_bnd_register) Added constant.
	(num_pl_bnd_cfg_registers) Added constant.
	(struct i387_xsave) Added reserved area and MPX fields.
	(i387_cache_to_xsave, i387_xsave_to_cache) Add MPX.

	* linux-x86-low.c (init_registers_i386_mpx_linux): Declare new
	function.
	(tdesc_i386_mpx_linux): Add MPX amd64 target.
	(init_registers_amd64_mpx_linux): Declare new function.
	(tdesc_amd64_mpx_linux): Add MPX amd64 target.
	(x86_64_regmap): Add MPX registers.
	(x86_linux_read_description): Add MPX case.
	(initialize_low_arch): Initialize MPX targets.

Change-Id: I394d81afa76d11375ce792cefad0ceb9825fb379
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
2013-11-20 14:42:52 +01:00
Walfred Tedeschi e43e105e0d MPX for amd64
2013-06-24  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* amd64-linux-nat.c (amd64_linux_gregset32_reg_offset):
	Add MPX registers.
	(amd64_linux_read_description): Add initialization for MPX and
	AVX independently.
	* amd64-linux-tdep.c: Includes features/i386/amd64-mpx-linux.c.
	(amd64_linux_gregset_reg_offset): Add MPX registers.
	(amd64_linux_core_read_description): Add initialization for MPX
	registers.
	(_initialize_amd64_linux_tdep): Initialize MPX targets.
	* amd64-linux-tdep.h (AMD64_LINUX_RAX_REGNUM): Set it to the last
	register on the list.
	(tdesc_amd64_mpx_linux) Add new target	for MPX.
	* amd64-tdep.c: Includes features/i386/amd64-mpx.c.
	(amd64_mpx_names): MPX register names.
	(amd64_init_abi): Add MPX register while initializing the ABI.
	(_initialize_amd64_tdep): Initialize MPX targets.
	* amd64-tdep.h (amd64_regnum): Add MPX registers.
	(AMD64_NUM_REGS): Set number of registers taking MPX into account.

Change-Id: I4a785c181e2fb45e4086650b2f87426caeb2f800
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>

Conflicts:

	gdb/ChangeLog
2013-11-20 14:42:51 +01:00
Walfred Tedeschi 1dbcd68cf1 Add MPX support for i386
2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* i386-linux-nat.c (GETXSTATEREGS_SUPPLIES): Add MPX
	registers on the range of registers to be read from
	xsave buffer.
	(i386_linux_read_description): Add case for MPX.
	* i386-linux-tdep.c: Include features/i386/i386-mpx-linux.c.
	(i386_linux_gregset_reg_offset): Add MPX registers.
	(i386_linux_core_read_description): Initialize also MPX.
	(_initialize_i386_linux_tdep): Add mpx initialization.
	* i386-tdep.h (gdbarch_tdep): Add fields bnd0r_regnum, bnd0_regnum,
	mpx_register_names.
	(i386_regnum): Add MPX registers.
	(I386_MPX_NUM_REGS): New macro.
	(i386_bnd_regnum_p): New function.
	* i386-linux-tdep.h (I386_LINUX_NUM_REGS): Set
	number of registers to be the number of BNDSTATUS.
	(tdesc_i386_mpx_linux): Add description for MPX Linux registers.
	* i386-tdep.c: Include features/i386/i386-mpx.c.
	(i386_mpx_names): Add MPX register names array.
	(i386_bnd_names): Add bnd pseudo register names array.
	(i386_bndr_regnum_p): Lookup register numbers for bnd raw
	registers.
	(i386_bndr_regnum_p): Lookup register numbers for bnd raw registers.
	(386_mpx_ctrl_regnum_p): Lookup register numbers for MPX control
	registers.
	(i386_bnd_type): New function.
	(i386_pseudo_register_type): Use i386_bnd_type for bnd pseudo
	register types.
	(i386_pseudo_register_read_into_value): Add bnd case.
	(i386_pseudo_register_write): Add bnd pseudo registers.
	(i386_register_reggroup_p): Add MPX register to the group all.
	(i386_validate_tdesc_p): Add MPX to the target 	description
	validation.
	(i386_pseudo_register_name): Add bnd pseudo registers.
	(i386_gdbarch_init): Add MPX for architecture initialization.
	(_initia_initialize_i386_tdep): Add mpx initialization.
	* i387-tdep.c (xsave_mpx_offset): New vector for MPX offsets on
	XSAVE buffer.
	(XSAVE_MPX_ADDR): New macro.
	(i387_supply_xsave): Add MPX case.
	(i387_collect_xsave): Add MPX case.
	* i387-tdep.h (I387_BND0R_REGNUM): New macro.
	(I387_BNDCFGU_REGNUM): New macro.
	(I387_NUM_MPX_REGS): New macro.
	(I387_NUM_BND_REGS): New macro.
	(I387_NUM_MPX_CTRL_REGS): New macro.
	(I387_MPXEND_REGNUM): New macro.
	* common/i386-xstate.h (I386_XSTATE_BNDREGS): New macro.
	(I386_XSTATE_BNDCFG): Likewise.
	(I386_XSTATE_MPX_MASK): Likewise.
	(I386_XSTATE_ALL_MASK): New macro represents flags for all states.
	(I386_XSTATE_BNDREGS_SIZE): New macro.
	(I386_XSTATE_BNDCFG_SIZE): Likewise.
	(I386_XSTATE_SIZE): Adapt for MPX.
	(I386_XSTATE_MAX_SIZE): Likewise.

Change-Id: I9ddb7d49434d86fa18eb6b99515203d7c567aefd
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>

Conflicts:

	gdb/ChangeLog
2013-11-20 14:42:50 +01:00
Walfred Tedeschi ccc42043f7 Add MPX registers XML files.
2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* features/i386/Makefile: Adapts for using MPX registers.
	* features/i386/32bit-mpx.xml: New file.
	* features/i386/64bit-mpx.xml: Likewise.
	* features/i386/amd64-mpx-linux.c: Likewise.
	* features/i386/amd64-mpx-linux.xml: Likewise.
	* features/i386/amd64-mpx.c: Likewise.
	* features/i386/amd64-mpx.xml: Likewise.
	* features/i386/i386-mpx-linux.c: Likewise.
	* features/i386/i386-mpx-linux.xml: Likewise.
	* features/i386/i386-mpx.c: Likewise.
	* features/i386/i386-mpx.xml: Likewise.
	* regformats/i386/amd64-mpx-linux.dat: New file.
	* regformats/i386/amd64-mpx.dat: Likewise.
	* regformats/i386/i386-mpx-linux.dat: Likewise.
 	* regformats/i386/i386-mpx.dat: Likewise.
2013-11-20 14:42:50 +01:00
Walfred Tedeschi 57803a3c60 Fix conditions in creating a bitfield.
Bitfields are represented by intervals [start, begin]. It means that for an
interval comprised by only one  bit start and end will be equal.
The present condition does not always hold. On the other hand in target-description.c
(tdesc_gdb_type) bitfield is created when "f->type" is null. The routine
maint_print_maint_print_c_tdesc_cmd is modified to follow the same strategy.

2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* target-descriptions.c (maint_print_maint_print_c_tdesc_cmd):
	Modified logic of creating a bitfield to be in sync with
	tdesc_gdb_type.

testsuite/
	* gdb.xml/maint_print_struct.xml (bitfield): Added bitfield having
	start and end equal 0.

Change-Id: I8c62db049995f0c0c30606d9696b86afe237cbb9
2013-11-20 14:42:49 +01:00
Will Newton 2b59118e72 gdb/arm-tdep.c: Remove "Infinite loop detected" error message.
Since as far back as the beginning of the sourceware repository
the ARM port has printed an error "Infinite loop detected" when
the next_pc calculated is the same as the current one, for example
when encountering a branch to the current PC address.

This causes the test gdb.base/random-signal.exp as the error message
is not expected. I have not been able to find a good reason for the
message to be here so remove it and let the test pass.

gdb/ChangeLog:

2013-11-20  Will Newton  <will.newton@linaro.org>

	* arm-tdep.c (arm_get_next_pc): Remove "Infinite loop detected"
	error message.
2013-11-20 10:50:32 +00:00
Yao Qi b26dfc9ab3 Associate target_dcache to address_space.
Hi,
Nowadays, 'target_dcache' is a global variable in GDB, which is not
necessary.  It can be a per-address-space variable.  In this patch, we
associate target_dcache to address_space.

gdb/doc:

2013-11-20  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (Caching Target Data): Update doc for
	per-address-space dcache.

gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

	* progspace.h (struct address_space_data): Declare.
	* target-dcache.c: Include "progspace.h".
	(target_dache): Remove.
	(target_dcache_aspace_key): New.
	(target_dcache_cleanup): New function.
	(target_dcache_init_p): Get data through
	target_dcache_aspace_key.
	(target_dcache_invalidate): Likewise.
	(target_dcache_get): Likewise.
	(target_dcache_get_or_init): Likewise.
	(_initialize_target_dcache): Initialize
	target_dcache_aspace_key.
2013-11-20 12:41:26 +08:00
Yao Qi 3a8356ffac Add REGISTRY for struct address_space.
This patch adds REGISTRY for struct address_space.

gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

	* progspace.c (struct address_space): Update comments.
	<REGISTRY_FIELDS>: New fields.
	DEFINE_REGISTRY for address_space.
	(new_address_space): Call address_space_alloc_data.
	(free_address_space): Call address_space_free_data.
	* progspace.h: Use DECLARE_REGISTRY.
2013-11-20 12:41:25 +08:00
Yao Qi b12039c637 Don't stress 'remote' in "Data Caching" in doc
When I try to describe the cache and its related commands (in a
cache-per-address-space world), I find hard to add, because
existing doc is focused on remote debugging, while data cache is used
regardless of the target.  More precisely, GDB cache target data,
instead of remote data.

gdb/doc:

2013-11-20  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (Data): Rename menu item.
	(Caching Remote Data): Rename to ...
	(Caching Target Data): ... it.  Update.
2013-11-20 11:40:55 +08:00
Yao Qi 68c765e263 Move target-dcache out of target.c
This patch moves target_dcache related code out of target.c.

gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

	* Makefile.in (SFILES):Add target-dcache.c.
	(HFILES_NO_SRCDIR): Add target-dcache.h.
	(COMMON_OBS): Add target-dcache.o.
	* dcache.c: Remove inclusion to "target.h".  Include
	"target-dcache.h".
	* memattr.c: Include "target-dcache.h".
	* top.c: Likewise.
	* tracepoint.c: Likewise.
	* target.c: (stack_cache_enabled_p_1): Move to
	target-dcache.c.
	(stack_cache_enabled_p): Likewise.
	(set_stack_cache_enabled_p): Likewise.
	(show_stack_cache_enabled_p): Likewise.
	(target_dcache, target_dcache_init_p): Likewise.
	(target_dcache_invalidate): Likewise.
	(target_dcache_get, target_dcache_get_or_init): Likewise.
	(memory_xfer_partial_1): Call function stack_cache_enabled.
	(initialize_target): Move code to target-dcache.c.
	* target.h (target_dcache_invalidate): Move to
	target-dcache.h.
	(target_dcache_get): Likewise.
	* target-dcache.c: New.
	* target-dcache.h: New.
2013-11-20 11:40:51 +08:00
Yao Qi f2de978509 Don't update target_dcache if it is not initialized
After previous patch, 'target_dcache' is initialized lazily.  It is
possible that 'target_dcache' is still NULL when GDB writes to memory.
In this case, update to 'target_dcache' can be skipped.

gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

	* target.c (memory_xfer_partial_1): Update 'target_dcache' if
	it is initialized.
2013-11-20 11:40:48 +08:00
Yao Qi 2a2f9fe400 Remove last_cache
This patch removes global variable 'last_cache', and initialize
'target_dcache' lazily, so that 'target_dcache' can replace
'last_cache'.  No functionalities should be changed after this patch.

gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

	* dcache.c (last_cache): Remove.
	(dcache_free, dcache_init): Update.
	(dcache_update):
	(dcache_print_line): Add parameter 'dcache'.  Replace
	'target_dcache' with 'dcache'.
	(dcache_info): Move code to dcache_info_1. Call
	'dcache_info_1'.
	(dcache_info_1): New function.
	(set_dcache_size): Call target_dcache_invalidate.
	(set_dcache_line_size): Call target_dcache_invalidate.
	* target.c (target_dcache_init_p): New function.
	(target_dcache_invalidate): Check target_dcache_init_p first.
	(target_dcache_get, target_dcache_get_or_init): New function.
	(memory_xfer_partial_1): Adjust.
	(initialize_target): Don't initialize 'target_dcache'.
	* target.h (struct dcache_struct): Declare.
	(target_dcache_get): Declare.
2013-11-20 11:40:43 +08:00
Yao Qi 3e9ecad3e8 Move changelog entry to the right ChangeLog 2013-11-20 11:02:17 +08:00
Yao Qi 31b4ab9e37 Remove unnecessary '\'.
Hi,
In proc mi_child_regexp, \(,thread-id=\"\[0-9\]+\") is appended to
children_exp, while the first '\' is not necessary.  This patch
is to remove it.  With this patch applied, Emacs can find the right
left paren.

gdb/testsuite:

2013-11-19  Yao Qi  <yao@codesourcery.com>

	* lib/mi-support.exp (mi_child_regexp): Remove unnecessary '\'.
2013-11-19 21:36:15 +08:00
Yao Qi 4392c53486 Fix format issues in lib/mi-support.exp
There are some format issues in lib/mi-support.exp, such as using
spaces instead of tab and trailing spaces.  This patch is to fix them.

gdb/testsuite:

2013-11-19  Yao Qi  <yao@codesourcery.com>

	* lib/mi-support.exp: Fix format.
2013-11-19 21:35:43 +08:00
Yao Qi 077e2c8848 Remove 'whatever' in lib/mi-support.exp
Variable 'whatever' is not used at all.  This patch is to remove it.

gdb/testsuite:

2013-11-19  Yao Qi  <yao@codesourcery.com>

	* lib/mi-support.exp (mi_child_regexp): Remove 'whatever'.
	(mi_list_varobj_children_range): Likewise.
2013-11-19 15:26:31 +08:00
Yao Qi 8ab91b9600 Fix typo
Hi,
"It's" should be "Its".  This patch is to fix it.  Committed as
obvious.

gdb:

2013-11-19  Yao Qi  <yao@codesourcery.com>

	* varobj.c (varobj_get_type): Fix typo.
2013-11-19 15:14:01 +08:00
Joel Brobecker df7752b044 Fix int() builtin with range type gdb.Value objects.
Consider the following variable:

    type Small is range -128 .. 127;
    SR : Small := 48;

Trying to get its value as an integer within Python code yields:

    (gdb) python sr = gdb.parse_and_eval('sr')
    (gdb) python print int(sr)
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    gdb.error: Cannot convert value to int.
    Error while executing Python code.

This is happening because our variable is a range type, and
py-value's is_intlike does not handle TYPE_CODE_RANGE. This
patch fixes this.

gdb/ChangeLog:

        * python/py-value.c (is_intlike): Add TYPE_CODE_RANGE handling.

gdb/testsuite/ChangeLog:

        * gdb.ada/py_range: New testcase.
2013-11-19 06:44:40 +04:00
Joel Brobecker 4a0a886ab6 gdb_ari.sh: Remove entries for dirent.h and stat.h.
The corresponding gdb_dirent.h and gdb_stat.h no longer exist.
We rely on gnulib for those, now.

gdb/ChangeLog:

        * contrib/ari/gdb_ari.sh: Remove checks for "dirent.h" and
        "stat.h".
2013-11-19 06:38:47 +04:00
Tom Tromey 53ce3c3929 remove gdb_stat.h
This patch is purely mechanical.  It removes gdb_stat.h and changes
the code to use sys/stat.h.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* common/gdb_stat.h: Remove.
	* ada-lang.c: Use sys/stat.h, not gdb_stat.h.
	* common/filestuff.c: Use sys/stat.h, not gdb_stat.h.
	* common/linux-osdata.c: Use sys/stat.h, not gdb_stat.h.
	* corefile.c: Use sys/stat.h, not gdb_stat.h.
	* ctf.c: Use sys/stat.h, not gdb_stat.h.
	* darwin-nat.c: Use sys/stat.h, not gdb_stat.h.
	* dbxread.c: Use sys/stat.h, not gdb_stat.h.
	* dwarf2read.c: Use sys/stat.h, not gdb_stat.h.
	* exec.c: Use sys/stat.h, not gdb_stat.h.
	* gdbserver/linux-low.c: Use sys/stat.h, not gdb_stat.h.
	* gdbserver/remote-utils.c: Use sys/stat.h, not gdb_stat.h.
	* inf-child.c: Use sys/stat.h, not gdb_stat.h.
	* jit.c: Use sys/stat.h, not gdb_stat.h.
	* linux-nat.c: Use sys/stat.h, not gdb_stat.h.
	* m68klinux-nat.c: Use sys/stat.h, not gdb_stat.h.
	* main.c: Use sys/stat.h, not gdb_stat.h.
	* mdebugread.c: Use sys/stat.h, not gdb_stat.h.
	* mi/mi-cmd-env.c: Use sys/stat.h, not gdb_stat.h.
	* nto-tdep.c: Use sys/stat.h, not gdb_stat.h.
	* objfiles.c: Use sys/stat.h, not gdb_stat.h.
	* procfs.c: Use sys/stat.h, not gdb_stat.h.
	* remote-fileio.c: Use sys/stat.h, not gdb_stat.h.
	* remote-mips.c: Use sys/stat.h, not gdb_stat.h.
	* remote.c: Use sys/stat.h, not gdb_stat.h.
	* rs6000-nat.c: Use sys/stat.h, not gdb_stat.h.
	* sol-thread.c: Use sys/stat.h, not gdb_stat.h.
	* solib-spu.c: Use sys/stat.h, not gdb_stat.h.
	* source.c: Use sys/stat.h, not gdb_stat.h.
	* symfile.c: Use sys/stat.h, not gdb_stat.h.
	* symmisc.c: Use sys/stat.h, not gdb_stat.h.
	* symtab.c: Use sys/stat.h, not gdb_stat.h.
	* top.c: Use sys/stat.h, not gdb_stat.h.
	* xcoffread.c: Use sys/stat.h, not gdb_stat.h.
2013-11-18 13:29:02 -07:00
Tom Tromey 09607c9e08 import gnulib sys/stat.h module
This imports the gnulib sys/stat.h module.
It doesn't make any other changes to gdb.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
	sys_stat.
	* gnulib/aclocal.m4: Update.
	* gnulib/config.in: Update.
	* gnulib/configure: Update.
	* gnulib/import/Makefile.am: Update.
	* gnulib/import/Makefile.in: Update.
	* gnulib/import/m4/gnulib-cache.m4: Update.
	* gnulib/import/m4/gnulib-comp.m4: Update.
	* gnulib/import/m4/sys_stat_h.m4: New.
	* gnulib/import/m4/time_h.m4: New.
	* gnulib/import/sys_stat.in.h: New.
	* gnulib/import/time.in.h: New.
2013-11-18 13:29:02 -07:00
Tom Tromey 4ff70b847c sys/types.h cleanup
configure doesn't check for sys/types.h any more, but it still tries
to use the result of the check.  This removes that use as well.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* configure: Rebuild.
	* configure.ac: Remove check of HAVE_SYS_TYPES_H.
2013-11-18 13:29:02 -07:00
Tom Tromey 3447c05797 don't check for unistd.h
We don't use the result of checking for unistd.h, so this removes the
check.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* configure: Rebuild.
	* configure.ac: Don't check for unistd.h.
2013-11-18 13:29:02 -07:00
Tom Tromey 0080a2f671 stdlib.h is universal too
stdlib.h is universal as well, so there is no need to check for it.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* configure: Rebuild.
	* configure.ac: Don't check for stdlib.h
	* defs.h: Include stdlib.h unconditionally.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* configure: Rebuild.
	* configure.ac: Don't check for stdlib.h.
	* gdbreplay.c: Unconditionally include stdlib.h.
2013-11-18 13:29:02 -07:00
Tom Tromey 161d1bec16 don't check for stddef.h
gdb already unconditionally includes stddef.h in many places.
I think there is no reason to check for its existence.

Also, Zack Weinberg's header file survey agrees:

    http://hacks.owlfolio.org/header-survey/

This patch removes the configure check and the inclusion guards.
It also removes a redundant inclusion that I noticed in defs.h.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* config.in: Rebuild.
	* configure: Rebuild.
	* configure.ac: Don't check for stddef.h.
	* defs.h: Unconditionally include stddef.h.  Remove duplicate
	inclusion.
2013-11-18 13:29:01 -07:00
Tom Tromey 2978b11100 remove gdb_dirent.h
This removes gdb_dirent.h and updates the code to use dirent.h
instead.  It also removes the now-useless configure checks.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* common/common.m4 (GDB_AC_COMMON): Don't use AC_HEADER_DIRENT.
	* common/gdb_dirent.h: Remove.
	* common/filestuff.c: Use dirent.h.
	* common/linux-osdata.c: Use dirent.h.
	(NAMELEN): Define.
	* config.in: Rebuild.
	* configure: Rebuild.
	* configure.ac: Don't use AC_HEADER_DIRENT.
	* linux-fork.c: Use dirent.h
	* linux-nat.c: Use dirent.h.
	* nto-procfs.c: Use dirent.h.
	* procfs.c: Use dirent.h.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* config.in: Rebuild.
	* configure: Rebuild.
	* configure.ac: Don't use AC_HEADER_DIRENT.
2013-11-18 13:29:01 -07:00
Tom Tromey e26b6bb047 import gnulib dirent module
This imports the gnulib dirent module.  It doesn't make any other
changes to gdb.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add dirent.
	* gnulib/aclocal.m4: Update.
	* gnulib/config.in: Update.
	* gnulib/configure: Update.
	* gnulib/import/Makefile.am: Update.
	* gnulib/import/Makefile.in: Update.
	* gnulib/import/dirent.in.h: New.
	* gnulib/import/m4/dirent_h.m4: New.
	* gnulib/import/m4/gnulib-cache.m4: Update.
	* gnulib/import/m4/gnulib-comp.m4: Update.
2013-11-18 13:29:01 -07:00
Tom Tromey a3d08894e5 don't check for string.h or strings.h
Now that we are using the gnulib string.h module, we don't need to
check for string.h or strings.h.  This removes the last few checks
from the source and from the configure scripts.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* configure: Rebuild.
	* common/common.m4 (GDB_AC_COMMON): Don't check for string.h or
	strings.h.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* server.h: Don't check HAVE_STRING_H.
	* gdbreplay.c: Don't check HAVE_STRING_H.
	* configure: Rebuild.
2013-11-18 13:29:01 -07:00
Tom Tromey 0e9f083f4c remove gdb_string.h
This removes gdb_string.h.  This patch is purely mechanical.  I
created it by running the two commands:

    git rm common/gdb_string.h
    perl -pi -e's/"gdb_string.h"/<string.h>/;'  *.[chyl] */*.[chyl]

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* common/gdb_string.h: Remove.
	* aarch64-tdep.c: Use string.h, not gdb_string.h.
	* ada-exp.y: Use string.h, not gdb_string.h.
	* ada-lang.c: Use string.h, not gdb_string.h.
	* ada-lex.l: Use string.h, not gdb_string.h.
	* ada-typeprint.c: Use string.h, not gdb_string.h.
	* ada-valprint.c: Use string.h, not gdb_string.h.
	* aix-thread.c: Use string.h, not gdb_string.h.
	* alpha-linux-tdep.c: Use string.h, not gdb_string.h.
	* alpha-mdebug-tdep.c: Use string.h, not gdb_string.h.
	* alpha-nat.c: Use string.h, not gdb_string.h.
	* alpha-osf1-tdep.c: Use string.h, not gdb_string.h.
	* alpha-tdep.c: Use string.h, not gdb_string.h.
	* alphanbsd-tdep.c: Use string.h, not gdb_string.h.
	* amd64-dicos-tdep.c: Use string.h, not gdb_string.h.
	* amd64-linux-nat.c: Use string.h, not gdb_string.h.
	* amd64-linux-tdep.c: Use string.h, not gdb_string.h.
	* amd64-nat.c: Use string.h, not gdb_string.h.
	* amd64-sol2-tdep.c: Use string.h, not gdb_string.h.
	* amd64fbsd-tdep.c: Use string.h, not gdb_string.h.
	* amd64obsd-tdep.c: Use string.h, not gdb_string.h.
	* arch-utils.c: Use string.h, not gdb_string.h.
	* arm-linux-nat.c: Use string.h, not gdb_string.h.
	* arm-linux-tdep.c: Use string.h, not gdb_string.h.
	* arm-tdep.c: Use string.h, not gdb_string.h.
	* arm-wince-tdep.c: Use string.h, not gdb_string.h.
	* armbsd-tdep.c: Use string.h, not gdb_string.h.
	* armnbsd-nat.c: Use string.h, not gdb_string.h.
	* armnbsd-tdep.c: Use string.h, not gdb_string.h.
	* armobsd-tdep.c: Use string.h, not gdb_string.h.
	* avr-tdep.c: Use string.h, not gdb_string.h.
	* ax-gdb.c: Use string.h, not gdb_string.h.
	* ax-general.c: Use string.h, not gdb_string.h.
	* bcache.c: Use string.h, not gdb_string.h.
	* bfin-tdep.c: Use string.h, not gdb_string.h.
	* breakpoint.c: Use string.h, not gdb_string.h.
	* build-id.c: Use string.h, not gdb_string.h.
	* buildsym.c: Use string.h, not gdb_string.h.
	* c-exp.y: Use string.h, not gdb_string.h.
	* c-lang.c: Use string.h, not gdb_string.h.
	* c-typeprint.c: Use string.h, not gdb_string.h.
	* c-valprint.c: Use string.h, not gdb_string.h.
	* charset.c: Use string.h, not gdb_string.h.
	* cli-out.c: Use string.h, not gdb_string.h.
	* cli/cli-cmds.c: Use string.h, not gdb_string.h.
	* cli/cli-decode.c: Use string.h, not gdb_string.h.
	* cli/cli-dump.c: Use string.h, not gdb_string.h.
	* cli/cli-interp.c: Use string.h, not gdb_string.h.
	* cli/cli-logging.c: Use string.h, not gdb_string.h.
	* cli/cli-script.c: Use string.h, not gdb_string.h.
	* cli/cli-setshow.c: Use string.h, not gdb_string.h.
	* cli/cli-utils.c: Use string.h, not gdb_string.h.
	* coffread.c: Use string.h, not gdb_string.h.
	* common/common-utils.c: Use string.h, not gdb_string.h.
	* common/filestuff.c: Use string.h, not gdb_string.h.
	* common/linux-procfs.c: Use string.h, not gdb_string.h.
	* common/linux-ptrace.c: Use string.h, not gdb_string.h.
	* common/signals.c: Use string.h, not gdb_string.h.
	* common/vec.h: Use string.h, not gdb_string.h.
	* core-regset.c: Use string.h, not gdb_string.h.
	* corefile.c: Use string.h, not gdb_string.h.
	* corelow.c: Use string.h, not gdb_string.h.
	* cp-abi.c: Use string.h, not gdb_string.h.
	* cp-support.c: Use string.h, not gdb_string.h.
	* cp-valprint.c: Use string.h, not gdb_string.h.
	* cris-tdep.c: Use string.h, not gdb_string.h.
	* d-lang.c: Use string.h, not gdb_string.h.
	* dbxread.c: Use string.h, not gdb_string.h.
	* dcache.c: Use string.h, not gdb_string.h.
	* demangle.c: Use string.h, not gdb_string.h.
	* dicos-tdep.c: Use string.h, not gdb_string.h.
	* disasm.c: Use string.h, not gdb_string.h.
	* doublest.c: Use string.h, not gdb_string.h.
	* dsrec.c: Use string.h, not gdb_string.h.
	* dummy-frame.c: Use string.h, not gdb_string.h.
	* dwarf2-frame.c: Use string.h, not gdb_string.h.
	* dwarf2loc.c: Use string.h, not gdb_string.h.
	* dwarf2read.c: Use string.h, not gdb_string.h.
	* elfread.c: Use string.h, not gdb_string.h.
	* environ.c: Use string.h, not gdb_string.h.
	* eval.c: Use string.h, not gdb_string.h.
	* event-loop.c: Use string.h, not gdb_string.h.
	* exceptions.c: Use string.h, not gdb_string.h.
	* exec.c: Use string.h, not gdb_string.h.
	* expprint.c: Use string.h, not gdb_string.h.
	* f-exp.y: Use string.h, not gdb_string.h.
	* f-lang.c: Use string.h, not gdb_string.h.
	* f-typeprint.c: Use string.h, not gdb_string.h.
	* f-valprint.c: Use string.h, not gdb_string.h.
	* fbsd-nat.c: Use string.h, not gdb_string.h.
	* findcmd.c: Use string.h, not gdb_string.h.
	* findvar.c: Use string.h, not gdb_string.h.
	* fork-child.c: Use string.h, not gdb_string.h.
	* frame.c: Use string.h, not gdb_string.h.
	* frv-linux-tdep.c: Use string.h, not gdb_string.h.
	* frv-tdep.c: Use string.h, not gdb_string.h.
	* gdb.c: Use string.h, not gdb_string.h.
	* gdb_bfd.c: Use string.h, not gdb_string.h.
	* gdbarch.c: Use string.h, not gdb_string.h.
	* gdbtypes.c: Use string.h, not gdb_string.h.
	* gnu-nat.c: Use string.h, not gdb_string.h.
	* gnu-v2-abi.c: Use string.h, not gdb_string.h.
	* gnu-v3-abi.c: Use string.h, not gdb_string.h.
	* go-exp.y: Use string.h, not gdb_string.h.
	* go-lang.c: Use string.h, not gdb_string.h.
	* go32-nat.c: Use string.h, not gdb_string.h.
	* hppa-hpux-tdep.c: Use string.h, not gdb_string.h.
	* hppa-linux-nat.c: Use string.h, not gdb_string.h.
	* hppanbsd-tdep.c: Use string.h, not gdb_string.h.
	* hppaobsd-tdep.c: Use string.h, not gdb_string.h.
	* i386-cygwin-tdep.c: Use string.h, not gdb_string.h.
	* i386-dicos-tdep.c: Use string.h, not gdb_string.h.
	* i386-linux-nat.c: Use string.h, not gdb_string.h.
	* i386-linux-tdep.c: Use string.h, not gdb_string.h.
	* i386-nto-tdep.c: Use string.h, not gdb_string.h.
	* i386-sol2-tdep.c: Use string.h, not gdb_string.h.
	* i386-tdep.c: Use string.h, not gdb_string.h.
	* i386bsd-tdep.c: Use string.h, not gdb_string.h.
	* i386gnu-nat.c: Use string.h, not gdb_string.h.
	* i386nbsd-tdep.c: Use string.h, not gdb_string.h.
	* i386obsd-tdep.c: Use string.h, not gdb_string.h.
	* i387-tdep.c: Use string.h, not gdb_string.h.
	* ia64-libunwind-tdep.c: Use string.h, not gdb_string.h.
	* ia64-linux-nat.c: Use string.h, not gdb_string.h.
	* inf-child.c: Use string.h, not gdb_string.h.
	* inf-ptrace.c: Use string.h, not gdb_string.h.
	* inf-ttrace.c: Use string.h, not gdb_string.h.
	* infcall.c: Use string.h, not gdb_string.h.
	* infcmd.c: Use string.h, not gdb_string.h.
	* inflow.c: Use string.h, not gdb_string.h.
	* infrun.c: Use string.h, not gdb_string.h.
	* interps.c: Use string.h, not gdb_string.h.
	* iq2000-tdep.c: Use string.h, not gdb_string.h.
	* irix5-nat.c: Use string.h, not gdb_string.h.
	* jv-exp.y: Use string.h, not gdb_string.h.
	* jv-lang.c: Use string.h, not gdb_string.h.
	* jv-typeprint.c: Use string.h, not gdb_string.h.
	* jv-valprint.c: Use string.h, not gdb_string.h.
	* language.c: Use string.h, not gdb_string.h.
	* linux-fork.c: Use string.h, not gdb_string.h.
	* linux-nat.c: Use string.h, not gdb_string.h.
	* lm32-tdep.c: Use string.h, not gdb_string.h.
	* m2-exp.y: Use string.h, not gdb_string.h.
	* m2-typeprint.c: Use string.h, not gdb_string.h.
	* m32c-tdep.c: Use string.h, not gdb_string.h.
	* m32r-linux-nat.c: Use string.h, not gdb_string.h.
	* m32r-linux-tdep.c: Use string.h, not gdb_string.h.
	* m32r-rom.c: Use string.h, not gdb_string.h.
	* m32r-tdep.c: Use string.h, not gdb_string.h.
	* m68hc11-tdep.c: Use string.h, not gdb_string.h.
	* m68k-tdep.c: Use string.h, not gdb_string.h.
	* m68kbsd-tdep.c: Use string.h, not gdb_string.h.
	* m68klinux-nat.c: Use string.h, not gdb_string.h.
	* m68klinux-tdep.c: Use string.h, not gdb_string.h.
	* m88k-tdep.c: Use string.h, not gdb_string.h.
	* macrocmd.c: Use string.h, not gdb_string.h.
	* main.c: Use string.h, not gdb_string.h.
	* mdebugread.c: Use string.h, not gdb_string.h.
	* mem-break.c: Use string.h, not gdb_string.h.
	* memattr.c: Use string.h, not gdb_string.h.
	* memory-map.c: Use string.h, not gdb_string.h.
	* mep-tdep.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-break.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-disas.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-env.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-stack.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-var.c: Use string.h, not gdb_string.h.
	* mi/mi-cmds.c: Use string.h, not gdb_string.h.
	* mi/mi-console.c: Use string.h, not gdb_string.h.
	* mi/mi-getopt.c: Use string.h, not gdb_string.h.
	* mi/mi-interp.c: Use string.h, not gdb_string.h.
	* mi/mi-main.c: Use string.h, not gdb_string.h.
	* mi/mi-parse.c: Use string.h, not gdb_string.h.
	* microblaze-rom.c: Use string.h, not gdb_string.h.
	* microblaze-tdep.c: Use string.h, not gdb_string.h.
	* mingw-hdep.c: Use string.h, not gdb_string.h.
	* minidebug.c: Use string.h, not gdb_string.h.
	* minsyms.c: Use string.h, not gdb_string.h.
	* mips-irix-tdep.c: Use string.h, not gdb_string.h.
	* mips-linux-tdep.c: Use string.h, not gdb_string.h.
	* mips-tdep.c: Use string.h, not gdb_string.h.
	* mips64obsd-tdep.c: Use string.h, not gdb_string.h.
	* mipsnbsd-tdep.c: Use string.h, not gdb_string.h.
	* mipsread.c: Use string.h, not gdb_string.h.
	* mn10300-linux-tdep.c: Use string.h, not gdb_string.h.
	* mn10300-tdep.c: Use string.h, not gdb_string.h.
	* monitor.c: Use string.h, not gdb_string.h.
	* moxie-tdep.c: Use string.h, not gdb_string.h.
	* mt-tdep.c: Use string.h, not gdb_string.h.
	* nbsd-tdep.c: Use string.h, not gdb_string.h.
	* nios2-linux-tdep.c: Use string.h, not gdb_string.h.
	* nto-procfs.c: Use string.h, not gdb_string.h.
	* nto-tdep.c: Use string.h, not gdb_string.h.
	* objc-lang.c: Use string.h, not gdb_string.h.
	* objfiles.c: Use string.h, not gdb_string.h.
	* opencl-lang.c: Use string.h, not gdb_string.h.
	* osabi.c: Use string.h, not gdb_string.h.
	* osdata.c: Use string.h, not gdb_string.h.
	* p-exp.y: Use string.h, not gdb_string.h.
	* p-lang.c: Use string.h, not gdb_string.h.
	* p-typeprint.c: Use string.h, not gdb_string.h.
	* parse.c: Use string.h, not gdb_string.h.
	* posix-hdep.c: Use string.h, not gdb_string.h.
	* ppc-linux-nat.c: Use string.h, not gdb_string.h.
	* ppc-sysv-tdep.c: Use string.h, not gdb_string.h.
	* ppcfbsd-tdep.c: Use string.h, not gdb_string.h.
	* ppcnbsd-tdep.c: Use string.h, not gdb_string.h.
	* ppcobsd-tdep.c: Use string.h, not gdb_string.h.
	* printcmd.c: Use string.h, not gdb_string.h.
	* procfs.c: Use string.h, not gdb_string.h.
	* prologue-value.c: Use string.h, not gdb_string.h.
	* python/py-auto-load.c: Use string.h, not gdb_string.h.
	* python/py-gdb-readline.c: Use string.h, not gdb_string.h.
	* ravenscar-thread.c: Use string.h, not gdb_string.h.
	* regcache.c: Use string.h, not gdb_string.h.
	* registry.c: Use string.h, not gdb_string.h.
	* remote-fileio.c: Use string.h, not gdb_string.h.
	* remote-m32r-sdi.c: Use string.h, not gdb_string.h.
	* remote-mips.c: Use string.h, not gdb_string.h.
	* remote-sim.c: Use string.h, not gdb_string.h.
	* remote.c: Use string.h, not gdb_string.h.
	* reverse.c: Use string.h, not gdb_string.h.
	* rs6000-aix-tdep.c: Use string.h, not gdb_string.h.
	* ser-base.c: Use string.h, not gdb_string.h.
	* ser-go32.c: Use string.h, not gdb_string.h.
	* ser-mingw.c: Use string.h, not gdb_string.h.
	* ser-pipe.c: Use string.h, not gdb_string.h.
	* ser-tcp.c: Use string.h, not gdb_string.h.
	* ser-unix.c: Use string.h, not gdb_string.h.
	* serial.c: Use string.h, not gdb_string.h.
	* sh-tdep.c: Use string.h, not gdb_string.h.
	* sh64-tdep.c: Use string.h, not gdb_string.h.
	* shnbsd-tdep.c: Use string.h, not gdb_string.h.
	* skip.c: Use string.h, not gdb_string.h.
	* sol-thread.c: Use string.h, not gdb_string.h.
	* solib-dsbt.c: Use string.h, not gdb_string.h.
	* solib-frv.c: Use string.h, not gdb_string.h.
	* solib-osf.c: Use string.h, not gdb_string.h.
	* solib-spu.c: Use string.h, not gdb_string.h.
	* solib-target.c: Use string.h, not gdb_string.h.
	* solib.c: Use string.h, not gdb_string.h.
	* somread.c: Use string.h, not gdb_string.h.
	* source.c: Use string.h, not gdb_string.h.
	* sparc-nat.c: Use string.h, not gdb_string.h.
	* sparc-sol2-tdep.c: Use string.h, not gdb_string.h.
	* sparc-tdep.c: Use string.h, not gdb_string.h.
	* sparc64-tdep.c: Use string.h, not gdb_string.h.
	* sparc64fbsd-tdep.c: Use string.h, not gdb_string.h.
	* sparc64nbsd-tdep.c: Use string.h, not gdb_string.h.
	* sparcnbsd-tdep.c: Use string.h, not gdb_string.h.
	* spu-linux-nat.c: Use string.h, not gdb_string.h.
	* spu-multiarch.c: Use string.h, not gdb_string.h.
	* spu-tdep.c: Use string.h, not gdb_string.h.
	* stabsread.c: Use string.h, not gdb_string.h.
	* stack.c: Use string.h, not gdb_string.h.
	* std-regs.c: Use string.h, not gdb_string.h.
	* symfile.c: Use string.h, not gdb_string.h.
	* symmisc.c: Use string.h, not gdb_string.h.
	* symtab.c: Use string.h, not gdb_string.h.
	* target.c: Use string.h, not gdb_string.h.
	* thread.c: Use string.h, not gdb_string.h.
	* tilegx-linux-nat.c: Use string.h, not gdb_string.h.
	* tilegx-tdep.c: Use string.h, not gdb_string.h.
	* top.c: Use string.h, not gdb_string.h.
	* tracepoint.c: Use string.h, not gdb_string.h.
	* tui/tui-command.c: Use string.h, not gdb_string.h.
	* tui/tui-data.c: Use string.h, not gdb_string.h.
	* tui/tui-disasm.c: Use string.h, not gdb_string.h.
	* tui/tui-file.c: Use string.h, not gdb_string.h.
	* tui/tui-layout.c: Use string.h, not gdb_string.h.
	* tui/tui-out.c: Use string.h, not gdb_string.h.
	* tui/tui-regs.c: Use string.h, not gdb_string.h.
	* tui/tui-source.c: Use string.h, not gdb_string.h.
	* tui/tui-stack.c: Use string.h, not gdb_string.h.
	* tui/tui-win.c: Use string.h, not gdb_string.h.
	* tui/tui-windata.c: Use string.h, not gdb_string.h.
	* tui/tui-winsource.c: Use string.h, not gdb_string.h.
	* typeprint.c: Use string.h, not gdb_string.h.
	* ui-file.c: Use string.h, not gdb_string.h.
	* ui-out.c: Use string.h, not gdb_string.h.
	* user-regs.c: Use string.h, not gdb_string.h.
	* utils.c: Use string.h, not gdb_string.h.
	* v850-tdep.c: Use string.h, not gdb_string.h.
	* valarith.c: Use string.h, not gdb_string.h.
	* valops.c: Use string.h, not gdb_string.h.
	* valprint.c: Use string.h, not gdb_string.h.
	* value.c: Use string.h, not gdb_string.h.
	* varobj.c: Use string.h, not gdb_string.h.
	* vax-tdep.c: Use string.h, not gdb_string.h.
	* vaxnbsd-tdep.c: Use string.h, not gdb_string.h.
	* vaxobsd-tdep.c: Use string.h, not gdb_string.h.
	* windows-nat.c: Use string.h, not gdb_string.h.
	* xcoffread.c: Use string.h, not gdb_string.h.
	* xml-support.c: Use string.h, not gdb_string.h.
	* xstormy16-tdep.c: Use string.h, not gdb_string.h.
	* xtensa-linux-nat.c: Use string.h, not gdb_string.h.
2013-11-18 13:29:00 -07:00
Tom Tromey 63ce7108c4 import strstr and strerror modules
This imports the gnulib strstr and strerror modules.  It doesn't make
any other changes to gdb; I found it simpler to work with the branch
if I made the changes more indepdendent than I had previously.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add strerror
	and strstr.
	* gnulib/aclocal.m4: Update.
	* gnulib/config.in: Update.
	* gnulib/configure: Update.
	* gnulib/import/Makefile.am: Update.
	* gnulib/import/Makefile.in: Update.
	* gnulib/import/errno.in.h: New.
	* gnulib/import/intprops.h: New.
	* gnulib/import/m4/errno_h.m4: New.
	* gnulib/import/m4/gnulib-cache.m4: Update.
	* gnulib/import/m4/gnulib-comp.m4: Update.
	* gnulib/import/m4/strerror.m4: New.
	* gnulib/import/m4/strstr.m4: New.
	* gnulib/import/m4/sys_socket_h.m4: New.
	* gnulib/import/strerror-override.c: New.
	* gnulib/import/strerror-override.h: New.
	* gnulib/import/strerror.c: New.
	* gnulib/import/strstr.c: New.
2013-11-18 13:29:00 -07:00
Tom Tromey a7c11ee135 change how list of modules is computed
While adding modules I found that the current approach of listing all
the modules on one line made it harder to experiment -- any conflicts
from git were a pain to resolve.

This patch splits the list of modules so that there is one module per
line.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Split into
	multiple lines.
2013-11-18 13:29:00 -07:00
Tom Tromey 0a5dd17d95 link gdbreplay against gnulib
Later patches in this series will make changes to gdb and gdbserver
configury, necessitating the use of gnulib in gdbreplay.  This patch
introduces the dependency early, so that subsequent patches don't
break the build.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* Makefile.in (gdbreplay$(EXEEXT)): Depend on and link against
	LIBGNU.
2013-11-18 13:29:00 -07:00
Jose E. Marchesi d0b5971ae7 sparc: support single-stepping over longjmp calls.
2013-11-18  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* sparc-tdep.c (sparc_is_annulled_branch_insn): New function.
	* sparc-tdep.h: And its prototype.

	* sparc64-linux-tdep.c (sparc64_linux_get_longjmp_target): New
	function.
	(sparc64_linux_init_abi): Register the get_longjmp_target hook.
2013-11-18 04:37:05 -08:00
Pedro Alves 4b4589ada7 Simplify dwarf2-frame.c:read_addr_from_reg.
Since 'struct dwarf_expr_context_funcs::read_addr_from_reg' is now
only used for addresses, we can make it use unpack_pointer.  And since
we now have 'struct dwarf_expr_context_funcs'::get_reg_value, there's
no need for speculation about using values here.

Tested on x86_64 Fedora 17.

gdb/
2013-11-18  Pedro Alves  <palves@redhat.com>

	* dwarf2-frame.c (read_addr_from_reg): Remove stale comment and
	use unpack_pointer.
2013-11-18 12:05:11 +00:00
Joel Brobecker 176f037c0f mi-language.exp: Check "langauge-option" in -list-features output.
gdb/testsuite/ChangeLog:

        * mi-language.exp: Add "-list-features" test verifying that
        its output contains "language-option".
2013-11-18 15:59:26 +04:00
Joel Brobecker 422ad5c296 Add "language-option" to -list-features
Following the addition of the --language optiton to all GDB/MI
commands,  I realized that there was no easy way for front-ends
to figure out whether this features is available or not. So I added
a "language-option" entry to -list-features.

gdb/ChangeLog:

        * mi/mi-main.c (mi_cmd_list_features): Add "language-options"
        to -list-features output.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Miscellaneous Commands): Document the new
        "language-option" entry in the output of the "-list-features"
        command.
2013-11-18 15:34:53 +04:00
Joel Brobecker b13704181f Rename "read_reg" into "read_addr_from_reg" in struct dwarf_expr_context_funcs
This is to help make it slightly clearer how this method is expected
to extract data from the given register.

gdb/ChangeLog:

        * dwarf2expr.h (struct dwarf_expr_context_funcs)
        <read_addr_from_reg>: Renames "read_reg".
        * dwarf2-frame.c (read_addr_from_reg): Renames "read_reg".
        Adjust comment.
        (dwarf2_frame_ctx_funcs, execute_stack_op, dwarf2_frame_cache):
        Use read_addr_from_reg in place of read_reg.
        * dwarf2expr.c (execute_stack_op): Use read_addr_from_reg
        in place of read_reg.
        * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Renames
        dwarf_expr_read_reg.
        (dwarf_expr_ctx_funcs): Replace dwarf_expr_read_reg
        with dwarf_expr_read_addr_from_reg.
        (needs_frame_read_addr_from_reg): Renames needs_frame_read_reg.
        (needs_frame_ctx_funcs): Replace needs_frame_read_reg with
        needs_frame_read_addr_from_reg.
2013-11-17 06:59:37 +04:00
Joel Brobecker ee4a1c63da gdb.ada/info_exc.exp,mi_exc_info.exp: Use more unique exception name.
In the case where the GNAT runtime was built with full debugging info,
several of the exceptions defined there might have a name contain
the word "global". To make this less likely, this patch renames
the exception name, replacing "Global" by "Global_GDB". It still
keeps the exeption name relatively short, while it is unlikely that
the GNAT runtime has an exception whose name explicitly mentions GDB,
and even less likely that it contains "Global_GDB".

gdb/testsuite/ChangeLog:

        * info_exc/const.ads (Aint_Global_GDB_E): Renames Aint_Global_E.
        * info_exc/foo.adb: Adjust to new exception name.
        * info_exc.exp: Adjust after exception renaming in const.ads.
        Update "info exception global" test to test "info exceptions
        global_gdb" instead.

        * mi_exc_info/const.ads (Aint_Global_GDB_E): Renames Aint_Global_E.
        * mi_exc_info/foo.adb (Adjust to new exception name.
        * mi_exc_info.exp: Adjust after exception renaming in const.ads.
        Update "-info-ada-exceptions global" test to test
        "-info-ada-exceptions global_gdb" instead.
2013-11-16 06:45:57 +04:00
Luis Machado 6ec41e1e1d * lib/mi-support.exp (mi_gdb_test): Expect different formats
of inferior output for remote and native sessions.
	* gdb.mi/mi-console.exp: Remove obsolete comment.
	Check for semihosted inferior output pattern.
	(semihosted_string): New function.
2013-11-15 19:41:07 -02:00
Jan Kratochvil 6ea71545c3 gdb/NEWS: Fix typo
gdb/
2013-11-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* NEWS (Changes in GDB 7.5) (New commands) (explore): Fix typo.
2013-11-15 19:19:57 +01:00
Joel Brobecker 391d340008 gdb.ada/info_exc.exp,mi_exc_info.exp: handle runtimes with full debug info.
If the runtime has full debug info, then the non-standard exceptions
declared in the GNAT runtime will appear in the list of exceptions
printed by GDB ("info exceptions" or "-info-ada-exceptions").
This is valid output, so this patch allows for it.

gdb/testsuite/ChangeLog:

        * gdb.ada/info_exc.exp: Allow other global exceptions to be
        listed in the output of "info exceptions".
        * gdb.ada/mi_exc_info.exp: Allow other global exceptions to be
        listed in the output of "-info-ada-exceptions".
2013-11-15 20:41:06 +04:00
Andreas Arnez 19a1b230f3 Fix GDB crash with upstream GCC due to memcpy(NULL, ...)
Similar to qsort(), the glibc version of memcpy() also declares its
arguments with __attribute__(__nonnull__(...)).  If NULL is passed
anyway, upstream GCC's new pass '-fisolate-erroneous-paths' typically
causes a trap in such cases.  I've encountered this with GDB in
chain_candidate() when trying to execute the break.exp test case.

gdb/
2013-11-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	* dwarf2loc.c (chain_candidate): Prevent invoking memcpy with
	NULL.
2013-11-15 17:25:23 +01:00
Joel Brobecker e092da2903 Start inferior before running test listing Ada exceptions.
This patch fixes some spurious failures when the inferior is linked
against the shared version of libgnat by default, as appears to be
the case on many GNU/Linux distributions.  When that happens, we have
to start the program in order to ensure that the GNAT runtime is
mapped to memory, in order for us to find the standard exceptions
(defined within the runtime).  Otherwise, they will not be shown,
as expected, by the debugger.

gdb/testsuite/ChangeLog:

        * gdb.ada/info_exc.exp: Start inferior before starting
        the "info exceptions" tests.
        * gdb.ada/mi_exc_info.exp: Start inferior before starting
        the "-info-ada-exceptions" tests.
2013-11-15 20:14:25 +04:00
Tom Tromey 805e1f1908 fix PR c++/16117
This patch fixes PR c++/16117.

gdb has an extension so that users can use expressions like FILE::NAME
to choose a variable of the given name from the given file.  The bug
is that this extension takes precedence over ordinary C++ expressions
of the same form.  You might think this is merely hypothetical, but
now that C++ headers commonly do not use an extension, it is more
common.

This patch fixes the bug by making two related changes.  First, it
changes gdb to prefer the ordinary C++ meaning of a symbol over the
extended meaning.  Second, it arranges for single-quoting of the
symbol to indicate a preference for the extension.

Built and regtested on x86-64 Fedora 18.
New test case included.

2013-11-15  Tom Tromey  <tromey@redhat.com>

	PR c++/16117:
	* c-exp.y (lex_one_token): Add "is_quoted_name" argument.
	(classify_name): Likewise.  Prefer a field of "this" over a
	filename.
	(classify_inner_name, yylex): Update.

2013-11-15  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Variables): Note gdb rules for ambiguous cases.
	Add example.

2013-11-15  Tom Tromey  <tromey@redhat.com>

	* gdb.cp/includefile: New file.
	* gdb.cp/filename.exp: New file.
	* gdb.cp/filename.cc: New file.
2013-11-15 08:43:14 -07:00
Doug Evans 9abb1bd666 * gdb.python/py-breakpoint.exp: Make tests have unique names. 2013-11-14 23:07:55 -08:00
Doug Evans 8abea1a1d2 * gdb.python/py-breakpoint.exp: Reformat for 80 columns. 2013-11-14 22:36:19 -08:00
Doug Evans 330a7fce4a * gdb.python/py-breakpoint.exp: Split up into several functions,
each with their own test prefix.
2013-11-14 22:23:16 -08:00
Joel Brobecker 0acf8b658c Fix DW_OP_GNU_regval_type with FP registers
Consider the following code, compiled at -O2 on ppc-linux:

    procedure Increment (Val : in out Float; Msg : String);

The implementation does not really matter in this case). In our example,
this function is being called from a function with Param_1 set to 99.0.
Trying to break inside that function, and running until reaching that
breakpoint yields:

    (gdb) b increment
    Breakpoint 1 at 0x100014b4: file callee.adb, line 6.
    (gdb) run
    Starting program: /[...]/foo

    Breakpoint 1, callee.increment (val=99.0, val@entry=0.0, msg=...)
        at callee.adb:6
    6             if Val > 200.0 then

The @entry value for parameter "val" is incorrect, it should be 99.0.

The associated call-site parameter DIE looks like this:

        .uleb128 0xc     # (DIE (0x115) DW_TAG_GNU_call_site_parameter)
        .byte   0x2      # DW_AT_location
        .byte   0x90     # DW_OP_regx
        .uleb128 0x21
        .byte   0x3      # DW_AT_GNU_call_site_value
        .byte   0xf5     # DW_OP_GNU_regval_type
        .uleb128 0x3f
        .uleb128 0x25

The DW_AT_GNU_call_site_value uses a DW_OP_GNU_regval_type
operation, referencing register 0x3f=63, which is $f31,
an 8-byte floating register. In that register, the value is
stored using the usual 8-byte float format:

    (gdb) info float
    f31            99.0 (raw 0x4058c00000000000)

The current code evaluating DW_OP_GNU_regval_type operations
currently is (dwarf2expr.c:execute_stack_op):

            result = (ctx->funcs->read_reg) (ctx->baton, reg);
            result_val = value_from_ulongest (address_type, result);
            result_val = value_from_contents (type,
                                              value_contents_all (result_val));

What the ctx->funcs->read_reg function does is read the contents
of the register as if it contained an address. The rest of the code
continues that assumption, thinking it's OK to then use that to
create an address/ulongest struct value, which we then re-type
to the type specified by DW_OP_GNU_regval_type.

We're getting 0.0 above because the read_reg implementations
end up treating the contents of the FP register as an integral,
reading only 4 out of the 8 bytes. Being a big-endian target,
we read the high-order ones, which gives us zero.

This patch fixes the problem by introducing a new callback to
read the contents of a register as a given type, and then adjust
the handling of DW_OP_GNU_regval_type to use that new callback.

gdb/ChangeLog:

        * dwarf2expr.h (struct dwarf_expr_context_funcs) <read_reg>:
        Extend the documentation a bit.
        <get_reg_value>: New field.
        * dwarf2loc.c (dwarf_expr_get_reg_value)
        (needs_frame_get_reg_value): New functions.
        (dwarf_expr_ctx_funcs, needs_frame_ctx_funcs): Add "get_reg_value"
        callback.
        * dwarf2-frame.c (get_reg_value): New function.
        (dwarf2_frame_ctx_funcs): Add "get_reg_value" callback.
        * dwarf2expr.c (execute_stack_op) <DW_OP_GNU_regval_type>:
        Use new callback to compute result_val.

gdb/testsuite/ChangeLog:

        * gdb.ada/O2_float_param: New testcase.
2013-11-14 22:38:48 -05:00
Alan Modra ef1bc9e72f PowerPC64 ELFv2 trampoline match
ELFv2 needs different plt call stubs to ELFv1, register usage differs
too.  When I added these to ld I changed register usage in the ELFv1
stubs as well, simplifying the linker code and (perhaps) future
maintenance.  All well and good, but this means gdb needs to cope with
more stub variants.  This patch also handles skipping over addis/addi
setting up r2 in ELFv2 global entry code.  We want breakpoints to be
set past this point to catch calls via the local entry point.

	* ppc64-tdep.c (ppc64_plt_entry_point): Renamed from..
	(ppc64_desc_entry_point): ..this.  Update comments here and at
	call points.
	(ppc64_standard_linkage1, ppc64_standard_linkage2,
	ppc64_standard_linkage3): Update comments.
	(ppc64_standard_linkage4, ppc64_standard_linkage5,
	(ppc64_standard_linkage6, ppc64_standard_linkage7): New insn
	patterns.
	(ppc64_standard_linkage4_target): New function.
	(ppc64_skip_trampoline_code): Skip ELFv2 patterns too.
	* rs6000-tdep.c (skip_prologue): Skip ELFv2 r2 setup.  Correct
	nop match.  Fix comment wrap.
2013-11-15 10:32:06 +10:30
Tom Tromey 496038b324 print summary from "make check"
Pedro pointed out that it is handy for "make check" to print a summary
of the results.  This happens in the check-single case and also if you
invoke runtest by hand.

This patch implements the same thing for check-parallel.

2013-11-14  Tom Tromey  <tromey@redhat.com>

	* Makefile.in (check-parallel): Print summary from gdb.sum.
2013-11-14 14:31:19 -07:00
Tom Tromey 8fe1b65338 fix grammar oddity in the manual
This patch fixes a buglet in the manual.
It's wrong to say that a method is defined "as" a subclass.
Instead it should say that a method is defined "in" a subclass.

I'm checking this in under the obvious rule.

2013-11-14  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Breakpoints In Python): Replace "as" with "in".
2013-11-14 14:03:06 -07:00
Pedro Alves 36fa80421a infrun.c:handle_signal_stop: Move initial connection/attachment handling code earlier.
Before all this stop_soon handling, we have code that can end in
keep_going.  Particularly, the thread_hop_needed code looked
suspicious considering breakpoint always-inserted mode, though on
closer inspection, it'd take connecting to multiple remote targets
that shared the same address space to trigger that.

Still, I think it's clearer if all this remote connection setup /
attach code is placed early, before any keep_going path could be
reached.

gdb/
2013-11-14  Pedro Alves  <palves@redhat.com>

	* infrun.c (handle_signal_stop): Move STOP_QUIETLY,
	STOP_QUIETLY_REMOTE and 'stop_after_trap' handling earlier.
2013-11-14 19:52:21 +00:00
Pedro Alves 4f5d7f635c infrun.c: Split handle_inferior_event further.
After the previous patches, we only ever reach the code after the
initial 'switch (ecs->ws.kind)' switch for TARGET_WAITKIND_STOPPED.
We can now factor out all that to its own function.

Unfortunately, stepped_after_stopped_by_watchpoint needed to move to
the ecs.  I think that indicates a state machine bug -- no event other
than TARGET_WAITKIND_STOPPED indicates a single-step actually
finished.  TARGET_WAITKIND_SYSCALL_XXX, TARGET_WAITKIND_FORK, etc. are
all events that are triggered from the kernel, _within_ a syscall,
IOW, from userspace's perspective, halfway through an instruction
being executed.  This might actually matter for the syscall events, as
syscalls can change memory (and thus trigger watchpoints).

gdb/
2013-11-14  Pedro Alves  <palves@redhat.com>

	* infrun.c (struct execution_control_state)
	<stepped_after_stopped_by_watchpoint>: New field.
	(get_inferior_stop_soon): New function.
	(handle_inferior_event): 'stepped_after_stopped_by_watchpoint' was
	moved to struct execution_control_state -- adjust.  Use
	get_inferior_stop_soon.  Split TARGET_WAITKIND_STOPPED handling to
	new function.
	(handle_signal_stop): New function, factored out from
	handle_inferior_event.
2013-11-14 19:51:50 +00:00
Pedro Alves 47591c29ad Eliminate enum bpstat_signal_value, simplify random signal checks further.
After the previous patch, there's actually no breakpoint type that
returns BPSTAT_SIGNAL_HIDE, so we can go back to having
bpstat_explains_signal return a boolean.  The signal hiding actually
disappears.

gdb/
2013-11-14  Pedro Alves  <palves@redhat.com>

	* break-catch-sig.c (signal_catchpoint_explains_signal): Adjust to
	return a boolean.
	* breakpoint.c (bpstat_explains_signal): Adjust to return a
	boolean.
	(explains_signal_watchpoint, base_breakpoint_explains_signal):
	Adjust to return a boolean.
	* breakpoint.h (enum bpstat_signal_value): Delete.
	(struct breakpoint_ops) <explains_signal>: New returns a boolean.
	(bpstat_explains_signal): Likewise.
	* infrun.c (handle_inferior_event) <random signal checks>:
	bpstat_explains_signal now returns a boolean - adjust.  No longer
	consider hiding signals.
2013-11-14 19:51:15 +00:00
Pedro Alves bac7d97b66 infrun.c:handle_inferior_event: Rework random signal checks.
Looking at the current random signal checks:

  if (ecs->event_thread->suspend.stop_signal == GDB_SIGNAL_TRAP)
    random_signal
      = !((bpstat_explains_signal (ecs->event_thread->control.stop_bpstat,
				   GDB_SIGNAL_TRAP)
	   != BPSTAT_SIGNAL_NO)
	  || stopped_by_watchpoint
	  || ecs->event_thread->control.trap_expected
	  || (ecs->event_thread->control.step_range_end
	      && (ecs->event_thread->control.step_resume_breakpoint
		  == NULL)));
  else
    {
      enum bpstat_signal_value sval;

      sval = bpstat_explains_signal (ecs->event_thread->control.stop_bpstat,
				     ecs->event_thread->suspend.stop_signal);
      random_signal = (sval == BPSTAT_SIGNAL_NO);

      if (sval == BPSTAT_SIGNAL_HIDE)
	ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_0;
    }

We can observe:

  - the stepping checks bit:

          ...
	  || ecs->event_thread->control.trap_expected
	  || (ecs->event_thread->control.step_range_end
	      && (ecs->event_thread->control.step_resume_breakpoint
		  == NULL)));
          ...

    is just like currently_stepping:

     static int
     currently_stepping (struct thread_info *tp)
     {
       return ((tp->control.step_range_end
                && tp->control.step_resume_breakpoint == NULL)
               || tp->control.trap_expected
               || bpstat_should_step ());
     }

    except it misses the bpstat_should_step check (***).

    It's not really necessary to check bpstat_should_step in the
    random signal tests, because software watchpoints always end up in
    the bpstat list anyway, which means bpstat_explains_signal with
    GDB_SIGNAL_TRAP always returns at least BPSSTAT_SIGNAL_HIDE, but I
    think the code is clearer if we reuse currently_stepping.

    *** - bpstat_should_step checks to see if there's any software
    watchpoint in the breakpoint list, because we need to force the
    target to single-step all the way, to evaluate the watchpoint's
    value at each step.

  - we never hide GDB_SIGNAL_TRAP, even if the bpstat returns
    BPSTAT_SIGNAL_HIDE, which is actually the default for all
    breakpoints.  If we make the default be BPSTAT_SIGNAL_PASS, then
    we can merge the two bpstat_explains_signal paths.

gdb/
2013-11-14  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (bpstat_explains_signal) <Moribund locations>:
	Return BPSTAT_SIGNAL_PASS instead of BPSTAT_SIGNAL_HIDE.
	(explains_signal_watchpoint): Return BPSTAT_SIGNAL_PASS instead of
	BPSTAT_SIGNAL_HIDE.
	(base_breakpoint_explains_signal): Return BPSTAT_SIGNAL_PASS
	instead of BPSTAT_SIGNAL_HIDE.
	* infrun.c (handle_inferior_event): Rework random signal checks.
2013-11-14 19:50:51 +00:00
Pedro Alves ce12b0125d infrun.c: Don't set ecs->random_signal for "catchpoint" events (eliminate ecs->random_signal).
This goes a step forward in making only TARGET_WAITKIND_STOPPED talk
about signals.

There's no reason for the "catchpoint" TARGET_WAITKIND_XXXs to consult
bpstat about signals -- unlike breakpoints, all these events are
continuable, so we don't need to do a remove-break/step/reinsert-break
-like dance.  That means we don't actually need to run them through
process_event_stop_test (for the bpstat_what checks), and can just use
bpstat_causes_stop instead.  Note we were already using it in the
TARGET_WAITKIND_(V)FORKED cases.

Then, these "catchpoint" waitkinds don't need to set
ecs->random_signal for anything, because they check it immediately
afterwards (and the value they set is never used again).

gdb/
2013-11-14  Pedro Alves  <palves@redhat.com>

	* infrun.c (struct execution_control_state): Remove
	'random_signal' field.
	(handle_syscall_event): Use bpstat_causes_stop instead of
	bpstat_explains_signal.  Don't set ecs->random_signal.
	(handle_inferior_event): New 'random_signal' local.
	<TARGET_WAITKIND_FORKED, TARGET_WAITKIND_VFORKED,
	TARGET_WAITKIND_EXECD>: Use bpstat_causes_stop instead of
	bpstat_explains_signal.  Don't set ecs->random_signal.
	<TARGET_WAITKIND_STOPPED>: Adjust to use local instead of
	ecs->random_signal.
2013-11-14 19:50:19 +00:00
Pedro Alves 05ba85103b infrun.c:handle_inferior_event: Move comment.
This comment applies to the whole handle_inferior_event flow, top to
bottom.  Best move it to the function's intro.

gdb/
2013-11-14  Pedro Alves  <palves@redhat.com>

	* infrun.c (handle_inferior_event): Move comment from the
	function's body to the function's description, adjusted.
2013-11-14 19:49:50 +00:00
Pedro Alves 5c09a2c53c infrun.c:handle_inferior_event: Don't fall through in TARGET_WAITKIND_LOADED handling.
Of all the TARGET_WAITKIND_XXXs event kinds other than
TARGET_WAITKIND_STOPPED, TARGET_WAITKIND_LOADED is the only kind that
doesn't end in a return, instead falling through to all the
signal/breakpoint/stepping handling code.  But it only falls through
in the STOP_QUIETLY_NO_SIGSTOP and STOP_QUIETLY_REMOTE cases, which
means the

  /* This is originated from start_remote(), start_inferior() and
     shared libraries hook functions.  */
  if (stop_soon == STOP_QUIETLY || stop_soon == STOP_QUIETLY_REMOTE)
    {
      if (debug_infrun)
	fprintf_unfiltered (gdb_stdlog, "infrun: quietly stopped\n");
      stop_stepping (ecs);
      return;
    }

bit is eventually reached.  All tests before that is reached will
always fail.  It's simpler to inline the stop_soon checks close to the
TARGET_WAITKIND_LOADED code, which allows removing the fall through.

Tested on x86_64 Fedora 17, but that doesn't exercise this
TARGET_WAITKIND_LOADED.

Also ran gdb.base/solib-disc.exp on Cygwin/gdbserver, which exercises
reconnection while the inferior is stopped at an solib event, but then
again, gdbserver always replies a regular trap on initial connection,
instead of the last event the program had seen:

 Sending packet: $?#3f...Packet received: T0505:4ca72800;04:f8a62800;08:62fcc877;thread:d28;
 Sending packet: $Hc-1#09...Packet received: E01
 Sending packet: $qAttached#8f...Packet received: 0
 Packet qAttached (query-attached) is supported
 infrun: clear_proceed_status_thread (Thread 3368)
 Sending packet: $qOffsets#4b...Packet received:
 infrun: wait_for_inferior ()
 infrun: target_wait (-1, status) =
 infrun:   42000 [Thread 3368],
 infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
 infrun: infwait_normal_state
 infrun: TARGET_WAITKIND_STOPPED
 infrun: stop_pc = 0x77c8fc62
 infrun: quietly stopped
 infrun: stop_stepping

So the only way to exercise this would be to hack gdbserver.  I didn't
go that far though.  I'm reasonably confident this is correct.

gdb/
2013-11-14  Pedro Alves  <palves@redhat.com>

	* infrun.c (handle_inferior_event) <TARGET_WAITKIND_LOADED>:
	Handle STOP_QUIETLY_NO_SIGSTOP and STOP_QUIETLY_REMOTE here.
	Assert we never fall through out of the TARGET_WAITKIND_LOADED
	case.
2013-11-14 19:43:25 +00:00
Tom Tromey 918229560c off-by-one fix for py-linetable.c
While digging into a different memory corruption error, I happened to
notice one coming from the linetable code.  In a couple of spots, the
wrong termination condition was used in a loop, leading gdb to read
one element past the end of the linetable.

Built and regtested on x86-64 Fedora 18.  Also verified using
valgrind.  I'm checking this in.

2013-11-14  Tom Tromey  <tromey@redhat.com>

	* python/py-linetable.c (ltpy_has_line)
	(ltpy_get_all_source_lines): Fix loop termination condition.
2013-11-14 11:09:14 -07:00
Omair Javaid c7e8af9b3b testsuite/gdb.dwarf2: dw2-case-insensitive.exp: p fuNC_lang fails on arm
dw2-case-insensitive.exp: p fuNC_lang fails on arm. The problem occurs
when thumb mode code is generated. On ARM last bit of function pointer
value indicates whether the target function is an ARM (if 0) or Thumb
(if 1) routine. The PC address should refer to actual address in
either case. This patch adds new compile unit and function labels to
code which act as address ranges of compile unit and functions in
debug information. Therefore address ranges will have correct
addresses and not the ones with an incremented least significant bit.
This patch has been tested on x86_64 and arm machines.

gdb/testsuite/ChangeLog:

2013-11-14  Omair Javaid  <Omair.Javaid@linaro.org>

        * gdb.dwarf2/dw2-case-insensitive-debug.S: Updated compile unit
	and function label names.
        * gdb.dwarf2/dw2-case-insensitive.c: Created function and
	compile unit labels.
2013-11-14 15:18:17 +00:00
Joel Brobecker 403cb6b138 GDB/MI: Add new "--language LANG" command option.
Frontend sometimes need to evaluate expressions that are
language-specific. For instance, Eclipse uses the following
expression to determine the size of an address on the target:

    -data-evaluate-expression "sizeof (void*)"

Unfortunately, if the main of the program being debugged is not C,
this may not work. For instance, if the main is in Ada, you get...

    -data-evaluate-expression "sizeof (void*)"
    ^error,msg="No definition of \"sizeof\" in current context."

... and apparently decides to stop the debugging session as a result.
The  recommendation sent was to specifically set the language to C
before trying to evaluate the expression.  Something such as:

    1. save current language
    2. set language c
    3. -data-evaluate-expression "sizeof (void*)"
    4. Restore language

This has the same disadvantages as the ones outlined in the "Context
Management" section of the GDB/MI documentation regarding setting
the current thread or the current frame, thus recommending the use of
general command-line switches such as --frame, or --thread instead.

This patch follows the same steps for the language, adding a similar
new command option: --language LANG. Example of use:

    -data-evaluate-expression --language c "sizeof (void*)"
    ^done,value="4"

gdb/ChangeLog:

        * mi/mi-parse.h (struct mi_parse) <language>: New field.
        * mi/mi-main.c (mi_cmd_execute): Temporarily set language to
        PARSE->LANGUAGE during command execution, if set.
        * mi/mi-parse.c: Add "language.h" #include.
        (mi_parse): Add parsing of "--language" command option.

        * NEWS: Add entry mentioning the new "--language" command option.

gdb/testsuite/ChangeLog:

        * gdb.mi/mi-language.exp: New file.

gdb/doc/ChangeLog:

        * gdb.texinfo (Show): Add xref anchor for "show language" command.
        (Context management): Place current subsection text into its own
        subsubsection.  Add new subsubsection describing the "--language"
        command option.
2013-11-14 14:36:18 +04:00
Joel Brobecker b5be8ce022 New function cli-utils.c:extract_arg_const
This function provides the exact same functionality as extract_arg,
except that it takes a "const char**" instead of a "char **".
It allows us also to re-implement extract_arg almost as a simple
wrapper around the new function.

gdb/ChangeLog:

        Pedro Alves  <palves@redhat.com>
        Joel Brobecker  <brobecker@adacore.com>

        * cli/cli-utils.h (extract_arg_const): Add declaration.
        * cli/cli-utils.c (extract_arg_const): New function.
        (extract_arg): Reimplement using extract_arg_const.
2013-11-14 14:31:42 +04:00
Joel Brobecker 671afef641 language.h: Add "symtab.h" #include
In addition to the fact that language.h depends on a number of struct
types declared in symtab.h, language.h also depends on an enumerated
type (domain_enum). So language.h should #include "symtab.h".

gdb/ChangeLog:

        * language.h: Add "symtab.h" #include.
2013-11-14 13:56:49 +04:00