Commit Graph

34065 Commits

Author SHA1 Message Date
Joel Brobecker ae56bfb8e7 Delete ada-lang.h::clear_ada_sym_cache (nonexistant function).
I happen to notice this extern function declaration in ada-lang.h
which does not actually exist...

gdb/ChangeLog:

        * ada-lang.h (clear_ada_sym_cache): Delete.
2014-01-31 15:32:00 +04:00
Ulrich Weigand 718ee4dc9b Add support for AT_HWCAP2 auxv entry
Recent ppc64 Linux kernels provide a new auxv entry AT_HWCAP2,
which is currently not recognized by GDB, causing every use of
"info auxv" to show an error.

This commit adds the AT_HWCAP2 define to include/elf/common.h
and handles it in GDB.

include/elf/ChangeLog:

	* common.h (AT_HWCAP2): Define.

gdb/ChangeLog:

	* auxv.c (fprint_target_auxv): Handle AT_HWCAP2.
2014-01-30 19:12:35 +01:00
Jose E. Marchesi 401e27fd71 This changeset makes sparc64_linux_step_trap to return 0 when a
breakpoint is set in a `ta 0x6d´ which is not a sigreturn syscall.  In
these cases no rt_frame exists in the stack and thus the read PC is
wrong.

ChangeLog
2014-01-29  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* sparc64-linux-tdep.c (sparc64_linux_step_trap): Get PC from
          the sigreturn register save area only if the syscall is
          sigreturn.

testsuite/ChangeLog
2014-01-29  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* gdb.arch/sparc-sysstep.exp: New file.
	* gdb.arch/sparc-sysstep.c: Likewise.

	* gdb.arch/Makefile.in (EXECUTABLES): Add sparc-sysstep.
2014-01-29 07:15:05 -08:00
Joel Brobecker a7c88acd1e Minor reformatting in valops.c::value_slice
I noticed that a small lexical block was over indented by 2 characters.
So this patch starts by reducing the indentation.

While looking at this area of the code, I also noticed a couple of lines
that had trailing spaces, so this patch also removes them.

And finally, it fixes one tiny to put the assignment operator at
the start of the next line, rather than at the end of the first line.

gdb/ChangeLog:

        * valops.c (value_slice): Minor reformatting.
2014-01-29 14:41:04 +04:00
Edjunior Barbosa Machado 8b92472967 Fix info-shared.exp testcase to expect the leading `.' found on ppc64's symbols.
gdb/testsuite/
2014-01-28  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

	* gdb.base/info-shared.exp: Expect leading `.' on ppc64's symbols.
2014-01-28 15:31:23 -02:00
Ulrich Weigand fa0079ea72 Fix typo in ppc64_standard_linkage7
The ppc64_standard_linkage7 pattern added by Alan's recent patch:
https://sourceware.org/ml/gdb-patches/2013-11/msg00274.html
contains a typo: the ELFv2 TOC slot offset is 24, not 40.
This was correct in the comment, but not the actual code.

ChangeLog:

	* ppc64-tdep.c (ppc64_standard_linkage7): Fix typo.
2014-01-28 17:49:13 +01:00
Joel Brobecker c6044dd124 New Ada maintenance command to ignore descriptive types (DWARF).
Currently, Ada debugging requires the use of certain GNAT-specific
encodings, which are generated by the compiler. These encodings
were created a long time ago to work around the fairly limited
capabilities of the stabs debugging format. With DWARF, the vast
majority of the encodings could be abandoned in favor of a pure
DWARF approach.

In order to make it easier to evaluate the quality of the DWARF
debugging information generated by the compiler, and how the debugger
handles it, we are introducing a small Ada-specific maintenance
setting which changes the debugger's behavior to ignore descriptive
types. Descriptive types are artificial types generated by the
compiler purely to give the debugger hints as to how to properly
decode certain properties of a type.  For instance, for array
types, it generates a parallel type whose name is the name of
the array suffixed with ___XA, whose contents tells us what
the array's index type is, and possibly its bounds. See GCC's
gcc/ada/exp_dbug.ads for the full description of all encodings.

This is only a first step, as this setting does not deactivate
all encodings; More settings dedicated to each type of encoding
will likely be implemented in the future, as we make progress.

gdb/ChangeLog:

        * ada-lang.c (maint_set_ada_cmdlist, maint_show_ada_cmdlist):
        New static globals.
        (maint_set_ada_cmd, maint_show_ada_cmd): New functions.
        (ada_ignore_descriptive_types_p): New static global.
        (find_parallel_type_by_descriptive_type): Return immediately
        if ada_ignore_descriptive_types_p is set.
        (_initialize_ada_language): Register new commands "maintenance
        set ada", "maintenance show ada", "maintenance set ada
        ignore-descriptive-types" and "maintenance show ada
        ignore-descriptive-types".
        * NEWS: Add entry for new "maint ada set/show
        ignore-descriptive-types" commands.

gdb/doc/ChangeLog:

        * gdb.texinfo (Ada Glitches): Document the new "maint ada set/show
        ignore-descriptive-types". commands.
2014-01-28 07:01:48 +04:00
Markus Metzger 568e808b7d btrace: initiate teardown when closing record btrace target
The to_teardown_btrace target method is used to free btrace resources
during shutdown when target record has already been unpushed and we
can't reliably talk to a remote target to disable branch tracing.

Tracing resources are freed for each thread when the thread is removed;
both on the GDB side and on the gdbserver side.

In the remote case, the remote target that provides to_teardown_btrace
to free the GDB side resources has already been unpushed when threads
are destroyed.  This results in a complaint "You can't do this ..." and
in a few bytes of memory leaked for each thread.

Initiate btrace teardown in record_btrace_close, so the remote target is
still in place.

2014-01-27  Markus Metzger  <markus.t.metzger@intel.com>

	* record-btrace.c (record_btrace_close): Call btrace_teardown
	for all threads.
2014-01-27 08:56:16 +01:00
Joel Brobecker 467d141bf5 ada-lang.c: Really include "ui-out.h".
Currently, ada-lang.c pretends to include "ui-out.h" as follow:

    #ifdef UI_OUT
    #include "ui-out.h"
    #endif

However, UI_OUT is never defined as far as I can tell. This is confirmed
by rebuilding with a #error pragma inside the #ifdef UI_OUT block,
which never triggers.

Since this unit makes references to declarations from ui-out.h,
this patch simply removes the #ifdef/#endif condition.  This has not
been an error so far because "ui-out.h" indirectly gets included,
via one of the other .h files being included.

gdb/ChangeLog:

        * ada-lang.c: Remove "#ifdef UI_OUT" condition for including
        "ui-out.h".
2014-01-27 08:29:47 +04:00
Joel Brobecker fb15121096 Try printing array range using the name of its index type
type Char_Table is array (Character range Character'First .. Character'Last)
     of Natural;

Trying to print the type description of this type currently yields:

   (gdb) ptype char_table
   type = array ('["00"]' .. '["ff"]') of natural

Although technically correct, it seemed more useful to print the array
range as:

   (gdb) ptype char_table
   type = array (character) of natural

This patch implements this suggestion.

gdb/ChangeLog:

        * ada-typeprint (type_is_full_subrange_of_target_type):
        New function.
        (print_range): Add parameter bounds_prefered_p.  If not set,
        try printing range types using the name of their base type.
        (print_range_type): Add parameter bounds_prefered_p.
        Use it in call to print_range.
        (print_array_type, ada_print_type): Update calls to print_range
        and print_range_type.

gdb/testsuite/ChangeLog:

        * gdb.ada/array_char_idx: New testcase.
2014-01-27 08:27:21 +04:00
Joel Brobecker aba0210970 Remove unncessary function declarations in ada-typeprint.c.
These declarations are unncessary, and make it extra work when trying
to change the profile of one of these functions. This patch just
removes them.

Note that one of them (print_dynamic_range_bound), was improperly
indented.

gdb/ChangeLog:

        * ada-typeprint.c (print_array_type, print_choices, print_range)
        (print_range_bound, print_dynamic_range_bound, print_range_type):
        Remove declaration.
2014-01-27 08:21:36 +04:00
Joel Brobecker e62e21fd47 Add missing empty line after declaration in ada-typeprint.c:print_range.
gdb/ChangeLog:

        * ada-typeprint.c (print_range): Add missing empty line
        after local declaration.
2014-01-27 08:19:54 +04:00
Joel Brobecker 859cf5d1de [Ada] Array bound incorrectly printed for array indexed by enum subrange
Consider the following declarations:

   type Range_Type is (One, Two, Three);
   type Array_Type is array (Range_Type range One .. Two) of Integer;
   A : Array_Type := (1, 2);

Trying to print A can yield:

   (gdb) print a
   $1 = (one => 1, 2)

The bound of the first element should not have been printed, since
"one" is the first enumerate of type Range_Type. Similarly, with
the following declarations:

   type Array2_Type is array (Range_Type range Two .. Three) of Integer;
   A2 : Array2_Type := (2, 3);

GDB is failing to print the bound of the first element of "A2":

   (gdb) print a2
   $2 = (2, 3)

This is because the index type for both types Array_Type and Array2_Type
are subranges (by DWARF definition for arrays), of an anonymous subrange
type. When deciding whether to print the bound of the first element,
we handle subranges, but only up to one level. This patch enhanced
the code to handle any number of subrange levels.

gdb/ChangeLog:

        * ada-valprint.c (print_optional_low_bound): Get index_type's
        target type for as long as it is a TYPE_CODE_RANGE.

No testcase with this patch, but this will be tested via the testcase
of another patch, which uses the DWARF assembler to generate debugging
info for an array indexed by an enum.
2014-01-27 08:13:49 +04:00
Joel Brobecker 25790f6fc1 Remove assert in procfs.c::procfs_make_note_section (x86-solaris)
On x86-solaris, the gcore command sometimes triggers the following
internal error:

    (gdb) gcore
    /[...]/procfs.c:5523: internal-error: procfs_make_note_section: Assertion `thread_args.note_data != note_data' failed.

The problem is extremely elusive, for reasons that will become clearer
as I explain what is going on.

The program used to produce this issue was really simple:

    | void break_me (void) { }
    |
    | int
    | main (void)
    | {
    |   break_me ();
    |   return 0;
    | }

The procfs_make_note_section builds a buffer incrementally with
the contents of the core's notes section.  The interesting bits are:

  char *note_data = NULL;
  [...]
  note_data = (char *) elfcore_write_prpsinfo (obfd,
                                               note_data,
                                               note_size,
                                               fname,
                                               psargs);

This is the first call to bfd's elfcore which initializes note_data.
After that, we have a few more calls, which keep updating notes_data
and note_size, but our interest lies in the following part of
the function:

  thread_args.note_data = note_data;
  [...]
  proc_iterate_over_threads (pi, procfs_corefile_thread_callback,
                             &thread_args);
  /* There should be always at least one thread.  */
  gdb_assert (thread_args.note_data != note_data);

The comment implies that the assert is to verify that our loop
iterated over at least one thread. The check is relying on the
fact that the notes_data returned by the elfcore module changes
at each iteration, via (in procfs_corefile_thread_callback):

      args->note_data = procfs_do_thread_registers (args->obfd, ptid,
                                                    args->note_data,
                                                    args->note_size,
                                                    args->stop_signal);

(which calls elfcore_write_lwpstatus).

But, while it happens most of the time, thanks to a call to realloc
in elfcore_write_note (the function that actually appends the data
at the end of the notes buffer),...

       buf = (char *) realloc (buf, *bufsiz + newspace);

... this is by no means guarantied. In fact, under the right
circumstances, the buffer was grown twice without changing
addresses. Unfortunately, the circumstances are very sensitive,
thus making this bug very elusive.

This patch fixes the problem by simply removing the assert.
This means we're losing the assertion that there is at least one
thread, but I think that's OK. If we still want to keep the
assertion, we have the option of either checking the buffer
size, or else adding a boolean flag in the context structure
that we'd set to true as soon as we have a thread.

gdb/ChangeLog:

        * procfs.c (procfs_make_note_section): Remove assertion and
        associated comment.
2014-01-27 07:01:09 +04:00
Yao Qi 6b6aa82881 Change len's type to ULONGEST: remote_read_bytes and get_core_siginfo
Functions remote_read_bytes and get_core_siginfo are the callees of
target to_xfer_partial interface, so argument 'len' should be changed
to type ULONGEST.

gdb:

2014-01-24  Yao Qi  <yao@codesourcery.com>

	* remote.c (remote_read_bytes): Change type of len to ULONGEST.
	* corelow.c (get_core_siginfo): Likewise.
2014-01-24 21:31:30 +08:00
Yao Qi 5d6df42390 Change len's type to ULONGEST: remote_write_bytes_aux
Hi,
This patch changes the type of 'len' from ssize_t to ULONGEST.

At the beginning Siddhesh Poyarekar proposed this patch

  [PATCH] Memory reads and writes should have size_t length
  https://sourceware.org/ml/gdb-patches/2012-05/msg01073.html

to change type of 'len' to size_t.  However, after Jan's review, we
decide to change it to ssize_t, because callers of these functions
may pass signed type to them.

AFAICS, the target layer is a boundary.  In one side, we pass size_t
or ssize_t to target related APIs, and in the other side, the
implementation side, we used LONGEST (ULONGEST in latest code) because
of to_xfer_partial.

Since remote_write_bytes_aux and remote_write_bytes belong to the
implementation of remote target, we should use ULONGEST for len, IMO.

Regression tested on x86_64-linux.  Is it OK?

gdb:

2014-01-24  Yao Qi  <yao@codesourcery.com>

	* remote.c (remote_write_bytes_aux): Change type of 'len' to
	ULONGEST.  Don't check 'len' is negative.
	(remote_write_bytes):  Change type of 'len' to ULONGEST.
2014-01-24 21:31:26 +08:00
Tom Tromey 83b645b833 avoid python exception in FrameDecorator.py
This fixes a bug in FrameDecorator.py.

FrameVars seems to assume that Frame.block can return None if there is
no block.  However, it actually throws an exception.

I saw this bug while developing a frame filter, but unfortunately I
don't know how to reproduce it.  It seems to me that the SAL tests in
_is_limited_frame should exclude the bad cases; and in my attempts to
write a test they do.

Nevertheless I think the fix is reasonably obvious and ought to go in.

2014-01-23  Tom Tromey  <tromey@redhat.com>

	PR python/16485:
	* python/lib/gdb/FrameDecorator.py: (FrameVars.fetch_frame_args):
	Handle exception from frame.block.
	(FrameVars.fetch_frame_locals): Likewise.
2014-01-23 08:03:52 -07:00
Tom Tromey 0740f8d82d fix erroneous error-handling in frame filter code
This fixes PR python/16487.

The bug here is that the function-name-handling code in py_print_frame
had a small logic error (really a misplaced closing brace).  This
error could lead to a Py_DECREF(NULL), which crashes.

This patch fixes the bug in the obvious way.

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

2014-01-23  Tom Tromey  <tromey@redhat.com>

	PR python/16487:
	* python/py-framefilter.c (py_print_frame): Don't call Py_DECREF
	on a NULL pointer.  Move "goto error" to correct place.

2014-01-23  Tom Tromey  <tromey@redhat.com>

	PR python/16487:
	* gdb.python/py-framefilter.exp: Add test using "Error" filter.
	* gdb.python/py-framefilter.py (ErrorInName, ErrorFilter): New
	classes.
2014-01-23 08:03:51 -07:00
Tom Tromey 21909fa1c6 fix crash in frame filters
apply_frame_filter calls ensure_python_env before computing the
gdbarch to use.  This means that python_gdbarch can be NULL while in
Python code, and if a frame filter depends on this somehow (easy to
do), gdb will crash.

The fix is to compute the gdbarch first.

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

2014-01-23  Tom Tromey  <tromey@redhat.com>

	PR python/16491:
	* python/py-framefilter.c (apply_frame_filter): Call
	ensure_python_env after computing gdbarch.

2014-01-23  Tom Tromey  <tromey@redhat.com>

	PR python/16491:
	* gdb.python/py-framefilter.py (Reverse_Function.function): Read a
	string from an inferior frame.
	* gdb.python/py-framefilter-mi.exp: Update.
2014-01-23 08:03:50 -07:00
Yao Qi 17fde6d091 Use gdb_byte * instead of void *
This patch changes the argument type to gdb_byte * in order to align
with the to_xfer_partial interface.

gdb:

2014-01-23  Yao Qi  <yao@codesourcery.com>

	* target.c (raw_memory_xfer_partial): Change argument type
	from void * to gdb_byte *.
	(memory_xfer_partial_1, memory_xfer_partial): Likewise.
2014-01-23 11:50:29 +08:00
Doug Evans f5a0277332 * gdbthread.h (gdb_id_to_thread): Delete, unused. 2014-01-22 16:42:07 -08:00
Doug Evans 87ce2a04c5 New gdbserver option --debug-format=timestamp.
* NEWS: Mention it.

	gdbserver/
	* configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday.
	* configure: Regenerate.
	* config.in: Regenerate.
	* Makefile.in (SFILES): Add debug.c.
	(OBS): Add debug.o.
	* debug.c: New file.
	* debug.h: New file.
	* linux-aarch64-low.c (*): Update all debugging printfs to use
	debug_printf instead of fprintf.
	* linux-arm-low.c (*): Ditto.
	* linux-cris-low.c (*): Ditto.
	* linux-crisv32-low.c (*): Ditto.
	* linux-m32r-low.c (*): Ditto.
	* linux-sparc-low.c (*): Ditto.
	* linux-x86.c (*): Ditto.
	* linux-low.c (*): Ditto.
	(linux_wait_1): Add calls to debug_enter, debug_exit.
	(linux_wait): Remove redundant debugging printf.
	(stop_all_lwps): Add calls to debug_enter, debug_exit.
	(linux_resume, unstop_all_lwps): Ditto.
	* mem-break.c (*): Update all debugging printfs to use
	debug_printf instead of fprintf.
	* remote-utils.c (*): Ditto.
	* thread-db.c (*): Ditto.
	* server.c #include <ctype.h>, "gdb_vecs.h".
	(debug_threads): Moved to debug.c.
	(*): Update all debugging printfs to use debug_printf instead of
	fprintf.
	(start_inferior): Replace call to fflush with call to debug_flush.
	(monitor_show_help): Mention set debug-format.
	(parse_debug_format_options): New function.
	(handle_monitor_command): Handle "monitor set debug-format".
	(gdbserver_usage): Mention --debug-format.
	(main): Parse --debug-format.
	* server.h (debug_threads): Declaration moved to debug.h.
	#include "debug.h".
	* tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of
	trace_debug_1 that uses debug_printf.
	(tracepoint_look_up_symbols): Update all debugging printfs to use
	debug_printf instead of fprintf.

	doc/
	* gdb.texinfo (Server): Mention --debug-format=all|none|timestamp.
	(gdbserver man): Ditto.

	testsuite/
	* gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 14:17:39 -08:00
Andreas Arnez 237b092b9f gdb/ChangeLog:
* syscalls/s390x-linux.xml: New file.
	* syscalls/s390-linux.xml: New file.
	* s390-linux-tdep.c (XML_SYSCALL_FILENAME_S390): New macro.
	(XML_SYSCALL_FILENAME_S390X): Likewise.
	(op_svc): New enum value for SVC opcode.
	(s390_sigtramp_frame_sniffer): Replace literal by 'op_svc'.
	(s390_linux_get_syscall_number): New function.
	(s390_gdbarch_init): Register '*get_syscall_number' and the
	syscall xml file name.
	* data-directory/Makefile.in (SYSCALLS_FILES): Add
	"s390-linux.xml" and "s390x-linux.xml".
	* NEWS: Announce new feature.

gdb/testsuite/ChangeLog:
	* gdb.base/catch-syscall.exp: Activate test on s390*-linux.
2014-01-22 18:54:43 +01:00
Andreas Arnez d674a7090f Fix regression on s390x with entry-values.exp.
The trace-specific test case 'entry-values' concludes fairly late in
the process that this platform doesn't support trace.  Before that,
there are some platform specifics that don't work on s390x.  The fix
addresses two aspects:

(1) Removal of an excess space character in the regex for the
    disassembly.  This is needed when there is a function alignment
    gap, because then the hex address is immediately followed by a
    colon, like in the first 'nopr' line below:

    (gdb) disassemble foo+50,+10
    Dump of assembler code from 0x32 to 0x3c:
       0x0000000000000032 <foo+50>: br      %r4
       0x0000000000000034:  nopr    %r7
       0x0000000000000036:  nopr    %r7
       0x0000000000000038 <bar+0>:  stmg    %r11,%r15,88(%r15)
    End of assembler dump.

(2) Handling for the s390-specific call instruction.

gdb/testsuite/ChangeLog:
	* gdb.trace/entry-values.exp: Remove excess space character from
	regex patterns.  Handle s390 call instruction.
2014-01-22 17:02:13 +01:00
Andreas Arnez 20fa339009 Re-introduce '_start' labels and add alignment in dw2-dir-file-name test case.
On ppc64-linux a function symbol does not point to code, but to the
function descriptor.  Thus the previous change for this test case
broke it:

      https://sourceware.org/ml/gdb-patches/2014-01/msg00275.html

This patch reverts to the original method, re-introducing '_start'
symbols.  In addition, it adds sufficient alignment before the label,
such that the label never points into an alignment gap.

gdb/testsuite/ChangeLog:
	* gdb.dwarf2/dw2-dir-file-name.c (FUNC): Insert alignment and
	define "*_start" label.  Make "name" static.
	* gdb.dwarf2/dw2-dir-file-name.exp: Replace references to
	${name} by references to ${name}_start.
2014-01-22 17:02:13 +01:00
Andreas Arnez 7846671423 Prevent appending "-g" after "-g3" to compile options in info-macros.exp.
When upstream gcc is given a command line with the "-g" option after
"-g3", it doesn't generate a ".debug_macro" section.  This is because
the last option wins, thus downgrading the debug level again.  Without
any macro debug information in the executable, info-macros.exp
obviously produces many failures.

Since the "-g" option is appended by DejaGnu's target_compile whenever
the "debug" option is set, the fix just removes that option.

gdb/testsuite/ChangeLog:
	* gdb.base/info-macros.exp: Remove "debug" from the compile
	options.
2014-01-22 17:02:13 +01:00
Baruch Siach 54bff65084 gdb: xtensa: fix on 64-bit hosts
On 64-bit hosts unsigned long is 64 bit.  Use uint32_t instead.

gdb/
2014-01-22  Baruch Siach  <baruch@tkos.co.il>

	* xtensa-tdep.h (xtensa_elf_greg_t): Change type to uint32_t.
2014-01-22 12:12:24 +00:00
Pedro Alves 14e361d7aa xtensa-config.c: missing defs.h include.
All .c files must start by including defs.h.

2014-01-22  Pedro Alves  <palves@redhat.com>

	* xtensa-config.c: Include defs.h.
2014-01-22 12:03:29 +00:00
Joel Brobecker 46bbb3edac Add ARI (ok) marker for __func__ reference in common-utils.h
The ARI script flagged the use of the __func__ variable, which
is normally not allowed (not defined in C90). However, this particular
use is OK, as the reference is only made when __STDC_VERSION__ >=
199901L.  So, add an "ARI:" comment to explicitly OK this use.

gdb/ChangeLog:

        * common/common-utils.h: Add "ARI:" comment beside __func__
        reference.
2014-01-22 09:03:31 +04:00
Joel Brobecker 3a80edfc74 Expand documentation of common-utils.h::FUNCTION_NAME
While looking at this macro, I noticed that it wasn't always necessarily
defined. That prompted me to search the current sources to make sure
that all uses were adequately protected, which they were. But to help
prevent future uses to be made unprotected, this patch expands the
current macro documentation a bit.

gdb/ChangeLog:

        * common/common-utils.h (FUNCTION_NAME): Expand the macro's
        documentation a bit.
2014-01-22 09:02:45 +04:00
Roland McGrath 4869db5e97 gdb: Support install-strip target
gdb/
	* configure.ac: Call AM_PROG_INSTALL_STRIP.
	* configure: Regenerate.
	* aclocal.m4: Regenerate.
	* Makefile.in (install_sh, INSTALL_STRIP_PROGRAM, STRIP):
	New substituted	variables.
	(install-strip): New target.
	(INSTALL_SCRIPT): New substituted variable.
	(FLAGS_TO_PASS): Add it.
	(install-only): Use $(INSTALL_SCRIPT) rather than
	$(INSTALL_PROGRAM) for gcore.
2014-01-21 11:01:04 -08:00
Tom Tromey 9ea4267d62 better packing for command struct
This moves all the bitfields in struct cmd_list_element to be closer
together.  This packs the structure somewhat better.  On a 64 bit
machine, this simple rearrangement saves around 50k at startup.

2014-01-20  Tom Tromey  <tromey@redhat.com>

	* cli/cli-decode.h (struct cmd_list_element): Move all bitfields
	together.
2014-01-20 09:10:52 -07:00
Tom Tromey 1f2bdf09c6 convert flags to bitfields
This changes various flags struct cmd_list_element into bitfields.  In
general I think bitfields are cleaner than flag words, at least in a
case like this where there is no need to pass the flags around
independently of the enclosing struct.

2014-01-20  Tom Tromey  <tromey@redhat.com>

	* cli/cli-decode.c (add_cmd, deprecate_cmd, add_alias_cmd)
	(add_setshow_cmd_full, delete_cmd, lookup_cmd_1)
	(deprecated_cmd_warning, complete_on_cmdlist): Update.
	* cli/cli-decode.h (CMD_DEPRECATED, DEPRECATED_WARN_USER)
	(MALLOCED_REPLACEMENT, DOC_ALLOCATED): Remove.
	(struct cmd_list_element) <flags>: Remove.
	<cmd_deprecated, deprecated_warn_user, malloced_replacement,
	doc_allocated>: New fields.
	<hook_in, allow_unknown, abbrev_flag, type, var_type>: Now
	bitfields.
	* maint.c (maintenance_do_deprecate): Update.
	* top.c (execute_command): Update.
2014-01-20 09:10:51 -07:00
Baruch Siach e671835b7a gdb: xtensa: fix linux ptrace includes
Currently, xtensa code using the Linux ptrace interface only include
sys/ptrace.h.  This file comes from the C library (glibc and uClibc,
at least), and includes a declaration of the ptrace() functions, along
with some cross architecture constants that are mostly copied from the
file located at include/uapi/linux/ptrace.h in recent Linux kernels.

For xtensa specific constants like PTRACE_GETXTREGS and
PTRACE_SETXTREGS the asm/ptrace.h include from the Linux kernel UAPI
is needed.  The code in gdbserver xtensa specific part doesn't call
ptrace() directly, so we can remove the unneeded sys/ptrace.h include.
The gdb xtensa specific code needs both headers, since it calls
ptrace().

gdb/
	* xtensa-linux-nat.c: Include asm/ptrace.h.

gdb/gdbserver/
	* linux-xtensa-low.c: Include asm/ptrace.h instead of
	sys/ptrace.h.
2014-01-20 11:43:44 +00:00
Iain Buclaw 50367cd2ad Move D demangling routines out of d-lang.c and into d-support.c, which
is intended to house other D language support functions.

gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * Makefile.in (SFILES): Add d-support.c.
    (COMMON_OBS): Add d-support.o.
    * d-lang.h (d_parse_symbol): Add comment, now defined in
    d-support.c.
    * d-lang.c (parse_call_convention)
    (parse_attributes, parse_function_types)
    (parse_function_args, parse_type, parse_identifier)
    (call_convention_p, d_parse_symbol): Move functions to ...
    * d-support.c: ... New file.
2014-01-18 18:11:24 +00:00
Iain Buclaw ec9f644ac9 Fix and update D demangling support in gdb to the current mangling ABI.
gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * d-lang.h (d_parse_symbol): Add declaration.
    * d-lang.c (extract_identifiers)
    (extract_type_info): Remove functions.
    (parse_call_convention, parse_attributes)
    (parse_function_types, parse_function_args)
    (parse_type, parse_identifier, call_convention_p)
    (d_parse_symbol): New functions.
    (d_demangle): Use d_parse_symbol to demangle D symbols.

gdb/testsuite/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

* gdb.dlang/demangle.exp: New file.
2014-01-18 18:11:06 +00:00
Iain Buclaw 94b1b47ee1 Define all basic data types of D and add them to the primitive type
language vector.

gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * d-lang.h (struct builtin_d_type): New data type.
    (builtin_d_type): Add declaration.
    * d-lang.c (d_language_arch_info, build_d_types)
    (builtin_d_type): New functions.
    (enum d_primitive_types): New data type.
    (d_language_defn): Change c_language_arch_info to
    d_language_arch_info.
    (d_type_data): New static variable.
    (_initialize_d_language): Initialize d_type_data.

gdb/testsuite/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * gdb.dlang/primitive-types.exp: New file.
2014-01-18 18:10:47 +00:00
Iain Buclaw 6377854769 Add d_main_name to set the logical entry point for D programs.
gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * d-lang.h (d_main_name): Add declaration.
    * d-lang.c (d_main_name): New function.
    * symtab.c (find_main_name): Add call to d_main_name.
2014-01-18 18:10:32 +00:00
Iain Buclaw 3271ba660a Update d_language_defn to reflect that D does not have any style of
macro expansion in its language.

gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * d-lang.c (d_language_defn): Change macro_expansion_c to
    macro_expansion_no.
2014-01-18 18:09:48 +00:00
Iain Buclaw 7f420862a7 Add gdb.dlang to the gdb testsuite for the purpose of creating D
specific tests.

gdb/testsuite/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * configure.ac: Create gdb.dlang/Makefile.
    * configure: Regenerate.
    * Makefile.in (ALL_SUBDIRS): Add gdb.dlang.
    * gdb.dlang/Makefile.in: New file.
    * lib/d-support.exp: New file.
    * lib/gdb.exp (skip_d_tests): New proc.
2014-01-18 18:09:28 +00:00
Iain Buclaw d36b301294 Add myself as a write-after-approval gdb maintainer.
gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * MAINTAINERS: Add myself as a write-after-approval maintainer.
2014-01-18 18:09:12 +00:00
Sergio Durigan Junior c90a6fb765 Add "volatile" keyword to "struct gdb_exception" declaration
While doing something else, I found that those 2 places were incorrectly
declaring a "struct gdb_exception" without using the "volatile" keyword.
This commit fixes that.

2014-01-17  Sergio Durigan Junior  <sergiodj@redhat.com>

	* breakpoint.c (insert_bp_location): Add "volatile" keyword to "struct
	gdb_exception" declaration.
	* remote.c (getpkt_or_notif_sane): Likewise.
2014-01-17 19:39:57 -02:00
Doug Evans 749234e540 Add delim_string_to_char_ptr_vec.
* common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): New
	function, contents of dirnames_to_char_ptr_vec_append moved here.
	(delim_string_to_char_ptr_vec): New function.
	(dirnames_to_char_ptr_vec_append): Rewrite.
	* common/gdb_vecs.h (delim_string_to_char_ptr_vec): Declare.
2014-01-17 10:23:29 -08:00
Doug Evans df049a5831 Move ASSERT_FUNCTION to FUNCTION_NAME.
* common/common-utils.h (FUNCTION_NAME): Renamed from ASSERT_FUNCTION,
	and moved here ...
	* common/gdb_assert.h (ASSERT_FUNCTION): ... from here.
	#include "common-utils.h".
	(gdb_assert, gdb_assert_fail, gdb_assert_not_reached): Update.
	* common/vec.h (VEC_ASSERT_PASS): Update.
	* darwin-nat.h: Replace #include of gdb_assert.h with common-utils.h.
	(MACH_CHECK_ERROR): Update.
2014-01-17 10:00:07 -08:00
Pedro Alves ea38d2a92e Fix PR mention in gdb/gdbserver/ChangeLog's previous change. 2014-01-17 16:28:38 +00:00
Pedro Alves c7faa97a85 Fix silly ChangeLog entry in previous change. 2014-01-17 15:27:43 +00:00
Pedro Alves b5737fa98a Fix PR PR16445 - gdbserver build failure on x86.
If gdb_proc_service.h ends up including linux/elf.h, we'll trip on
duplicate definitions:

 In file included from ../../../gdb/gdbserver/linux-x86-low.c:29:0:
 ../../../gdb/gdbserver/../../include/elf/common.h:36:0: error: "ELFMAG0"
                 redefined [-Werror]
 ... etc ...

Handle this the same way linux-low.c and linux-arm-low.c handle this.

gdb/gdbserver/
2014-01-17  Pedro Alves  <palves@redhat.com>

	PR PR16445
	* linux-x86-low.c (linux-x86-low.c): Don't include elf/common.h if
	ELFMAG0 is defined after including gdb_proc_service.h.
2014-01-17 13:33:30 +00:00
Simon Marchi 69f9764846 Add comments to gdbarch_address_class_name_to_type_flags.
gdb/ChangeLog
2014-01-17  Simon Marchi  <simon.marchi@ericsson.com>

	* gdbarch.sh (gdbarch_address_class_name_to_type_flags): Add
	comments.
	* gdbarch.h: Regenerate.
2014-01-17 09:54:56 +00:00
Doug Evans 40ed484e74 * dll.c (UNSPECIFIED_CORE_ADDR): New macro.
(match_dll): Use it.
2014-01-16 15:47:43 -08:00
Tom Tromey 98b1cfdcc8 rearrange struct value to save memory
This patch rearranges struct value a tiny bit, moving the "regnum"
field into a hole.  This saves 8 bytes per value on a 64-bit machine,
and 4 bytes per value on a 32 bit machine.  I think it does not
negatively affect readability or performance.

Built and regtested on x86-64 Fedora 18.

2014-01-16  Tom Tromey  <tromey@redhat.com>

	* value.c (struct value) <regnum>: Move earlier.
2014-01-16 14:56:31 -07:00
Tom Tromey 77a1944595 remove extended_remote_create_inferior_1
I noticed that extended_remote_create_inferior_1 is called from a
single spot.  This patch unifies the callee and caller.  It's just a
simple cleanup that made the coming refactoring simpler.

2014-01-16  Tom Tromey  <tromey@redhat.com>

	* remote.c (extended_remote_create_inferior): Rename from
	extended_remote_create_inferior_1.  Add "ops" argument.  Remove
	old implementation.
2014-01-16 12:12:32 -07:00
Pedro Alves 62261490a3 Fix gdb.trace/mi-traceframe-changed.exp on s390.
The test fails on s390 with:

  -trace-find frame-number 0^M
  &"PC not available\n"^M
  ^done,found="1",tracepoint="1",traceframe="0",frame={level="-1",addr="<unavailable>",func="??",args=[]}^M
  (gdb) ^M
  FAIL: gdb.trace/mi-traceframe-changed.exp: tfile: -trace-find frame-number 0

tfile knows to infer the PC from the tracepoint's address if the PC
wasn't collected (tfile_fetch_registers) but, that only works on
targets whose PC register is a raw register, and on s390, the PC
register is a pseudo register.

But even if GDB doesn't know how to infer the value of PC, saying the
current frame is level -1 is a bug:

  ^done,found="1",tracepoint="1",traceframe="0",frame={level="-1",addr="<unavailable>",func="??",args=[]}^M
                                                       ^^^^^^^^^

'-1' is the level of the sentinel frame, which should never be visible.

This is caused by the s390's heuristic unwinder accepting the frame
(the fallback heuristic unwinders _always_ accept the frame), but then
the unwind->this_id method throws that "PC not available\n" error.

IOW, the s390's heuristic unwinder was never adjusted to handle
unavailable register values gracefully, which can happen with e.g., a
trimmed core file too.

This is just the minimal necessary for
<unavailable> frames, which at least gets us:

  (gdb) tfind
  Found trace frame 0, tracepoint 1
  #0  <unavailable> in ?? ()

That is, frame #0 instead of -1.

We could get better info out of "info frame" (this patch makes us show
"outermost"), but this change would still be necessary.

gdb/
2014-01-16  Pedro Alves  <palves@redhat.com>

	* s390-linux-tdep.c (s390_frame_unwind_cache): Swallow
	NOT_AVAILABLE_ERROR errors while parsing the prologue or reading
	the backchain.
2014-01-16 17:43:46 +00:00
Doug Evans 4d65956b03 dwarf2read.c (open_and_init_dwp_file): Fix typo in comment. 2014-01-16 09:29:10 -08:00
Markus Metzger 52834460bc record-btrace: add (reverse-)stepping support
Provide to_resume and to_wait target methods for the btrace record target
to allow reverse stepping and replay support.

Replay is limited in the sense that only stepping and source correlation
are supported.  We do not record data and thus can not show variables.

Non-stop mode is not working.  Do not allow record-btrace in non-stop mode.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.h (btrace_thread_flag): New.
	(struct btrace_thread_info) <flags>: New.
	* record-btrace.c (record_btrace_resume_thread)
	(record_btrace_find_thread_to_move, btrace_step_no_history)
	(btrace_step_stopped, record_btrace_start_replaying)
	(record_btrace_step_thread, record_btrace_decr_pc_after_break)
	(record_btrace_find_resume_thread): New.
	(record_btrace_resume, record_btrace_wait): Extend.
	(record_btrace_can_execute_reverse): New.
	(record_btrace_open): Fail in non-stop mode.
	(record_btrace_set_replay): Split into this, ...
	(record_btrace_stop_replaying): ... this, ...
	(record_btrace_clear_histories): ... and this.
	(init_record_btrace_ops): Init to_can_execute_reverse.
	* NEWS: Announce it.

testsuite/
	* gdb.btrace/delta.exp: Check reverse stepi.
	* gdb.btrace/tailcall.exp: Update.  Add stepping tests.
	* gdb.btrace/finish.exp: New.
	* gdb.btrace/next.exp: New.
	* gdb.btrace/nexti.exp: New.
	* gdb.btrace/record_goto.c: Add comments.
	* gdb.btrace/step.exp: New.
	* gdb.btrace/stepi.exp: New.
	* gdb.btrace/multi-thread-step.c: New.
	* gdb.btrace/multi-thread-step.exp: New.
	* gdb.btrace/rn-dl-bind.c: New.
	* gdb.btrace/rn-dl-bind.exp: New.
	* gdb.btrace/data.c: New.
	* gdb.btrace/data.exp: New.
	* gdb.btrace/Makefile.in (EXECUTABLES): Add new.

doc/
	* gdb.texinfo: Document limited reverse/replay support
	for target record-btrace.
2014-01-16 13:14:12 +01:00
Markus Metzger 118e6252ca target: allow decr_pc_after_break to be defined by the target
Allow the target to define which value to use in decr_pc_after_break.
It defaults to gdbarch_decr_pc_after_break (GDBARCH).

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* target.h (struct target_ops) <to_decr_pc_after_break>: New.
	(forward_target_decr_pc_after_break)
	(target_decr_pc_after_break): New.
	* target.c (forward_target_decr_pc_after_break)
	(target_decr_pc_after_break): New.
	* aix-thread.c (aix_thread_wait): Call target_decr_pc_after_break
	instead of gdbarch_decr_pc_after_break.
	* darwin-nat.c (cancel_breakpoint): Call target_decr_pc_after_break
	instead of gdbarch_decr_pc_after_break.
	* infrun.c (adjust_pc_after_break): Call target_decr_pc_after_break
	instead of gdbarch_decr_pc_after_break.
	* linux-nat.c (cancel_breakpoint): Call target_decr_pc_after_break
	instead of gdbarch_decr_pc_after_break.
	* linux-thread-db.c (check_event): Call target_decr_pc_after_break
	instead of gdbarch_decr_pc_after_break.
	* record-full.c (record_full_wait_1): Call target_decr_pc_after_break
	instead of gdbarch_decr_pc_after_break.
2014-01-16 13:12:00 +01:00
Markus Metzger 6e07b1d27e record-btrace: show trace from enable location
The btrace record target shows the branch trace from the location of the first
branch destination.  This is the first BTS records.

After adding incremental updates, we can now add a dummy record for the current
PC when we enable tracing so we show the trace from the location where branch
tracing has been enabled.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.c: Include regcache.h.
	(btrace_add_pc): New.
	(btrace_enable): Call btrace_add_pc.
	(btrace_is_empty): New.
	* btrace.h (btrace_is_empty): New.
	* record-btrace.c (require_btrace, record_btrace_info): Call
	btrace_is_empty.

testsuite/
	* gdb.btrace/Makefile.in (EXECUTABLES): Add delta.
	* gdb.btrace/exception.exp: Update.
	* gdb.btrace/instruction_history.exp: Update.
	* gdb.btrace/record_goto.exp: Update.
	* gdb.btrace/tailcall.exp: Update.
	* gdb.btrace/unknown_functions.exp: Update.
	* gdb.btrace/delta.exp: New.
2014-01-16 13:12:00 +01:00
Markus Metzger 969c39fbcd btrace, gdbserver: read branch trace incrementally
Read branch trace data incrementally and extend the current trace rather than
discarding it and reading the entire trace buffer each time.

If the branch trace buffer overflowed, we can't extend the current trace so we
discard it and start anew by reading the entire branch trace buffer.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* common/linux-btrace.c (perf_event_read_bts, linux_read_btrace):
	Support delta reads.
	(linux_disable_btrace): Change return type.
	* common/linux-btrace.h (linux_read_btrace): Change parameters
	and return type to allow error reporting.  Update users.
	(linux_disable_btrace): Change return type.  Update users.
	* common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>:
	New.
	(btrace_error): New.
	(btrace_block) <begin>: Comment on BEGIN == 0.
	* btrace.c (btrace_compute_ftrace): Start from the end of
	the current trace.
	(btrace_stitch_trace, btrace_clear_history): New.
	(btrace_fetch): Read delta trace, return if replaying.
	(btrace_clear): Move clear history code to btrace_clear_history.
	(parse_xml_btrace): Throw an error if parsing failed.
	* target.h (struct target_ops) <to_read_btrace>: Change parameters
	and return type to allow error reporting.
	(target_read_btrace): Change parameters and return type to allow
	error reporting.
	* target.c (target_read_btrace): Update.
	* remote.c (remote_read_btrace): Support delta reads.  Pass
	errors on.
	* NEWS: Announce it.

gdbserver/
	* target.h (target_ops) <read_btrace>: Change parameters and
	return type to allow error reporting.
	* server.c (handle_qxfer_btrace): Support delta reads.  Pass
	trace reading errors on.
	* linux-low.c (linux_low_read_btrace): Pass trace reading
	errors on.
	(linux_low_disable_btrace): New.
2014-01-16 13:11:42 +01:00
Markus Metzger 0b722aec57 record-btrace: extend unwinder
Extend the always failing unwinder to provide the PC based on the call
structure detected in the branch trace.

The unwinder supports normal frames and tailcall frames.
Inline frames are not supported.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* record.h (record_btrace_frame_unwind)
	(record_btrace_tailcall_frame_unwind): New declarations.
	* dwarf2-frame: Include record.h
	(dwarf2_frame_cfa): Throw an error for btrace frames.
	* record-btrace.c: Include hashtab.h.
	(btrace_get_bfun_name): New.
	(btrace_call_history): Call btrace_get_bfun_name.
	(struct btrace_frame_cache): New.
	(bfcache): New.
	(bfcache_hash, bfcache_eq, bfcache_new): New.
	(btrace_get_frame_function): New.
	(record_btrace_frame_unwind_stop_reason): Allow unwinding.
	(record_btrace_frame_this_id): Compute own id.
	(record_btrace_frame_prev_register): Provide PC, throw_error
	for all other registers.
	(record_btrace_frame_sniffer): Detect btrace frames.
	(record_btrace_tailcall_frame_sniffer): New.
	(record_btrace_frame_dealloc_cache): New.
	(record_btrace_frame_unwind): Add new functions.
	(record_btrace_tailcall_frame_unwind): New.
	(_initialize_record_btrace): Allocate cache.
	* btrace.c (btrace_clear): Call reinit_frame_cache.
	* NEWS: Announce it.

testsuite/
	* gdb.btrace/record_goto.exp: Add backtrace test.
	* gdb.btrace/tailcall.exp: Add backtrace test.
2014-01-16 13:09:42 +01:00
Markus Metzger 066ce621f4 record-btrace: add record goto target methods
2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* record-btrace.c (record_btrace_set_replay)
	(record_btrace_goto_begin, record_btrace_goto_end)
	(record_btrace_goto): New.
	(init_record_btrace_ops): Initialize them.
	* NEWS: Announce it.

testsuite/
	* gdb.btrace/Makefile.in (EXECUTABLES): Add record_goto.
	* gdb.btrace/record_goto.c: New.
	* gdb.btrace/record_goto.exp: New.
	* gdb.btrace/x86-record_goto.S: New.
2014-01-16 13:08:05 +01:00
Markus Metzger e2887aa34f record-btrace: provide target_find_new_threads method
The "info threads" command tries to read memory, which is not possible during
replay.  This results in an error message and aborts the command without showing
the existing threads.

Provide a to_find_new_threads target method to skip the search while replaying.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* record-btrace.c (record_btrace_find_new_threads)
	(record_btrace_thread_alive): New.
	(init_record_btrace_ops): Initialize to_find_new_threads and
	to_thread_alive.
2014-01-16 13:06:15 +01:00
Markus Metzger b2f4cfdebc record-btrace: add to_wait and to_resume target methods.
Add simple to_wait and to_resume target methods that prevent stepping when the
current replay position is not at the end of the execution log.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* record-btrace.c (record_btrace_resume): New.
	(record_btrace_wait): New.
	(init_record_btrace_ops): Initialize to_wait and to_resume.
2014-01-16 13:06:14 +01:00
Markus Metzger 633785ff28 record-btrace: provide xfer_partial target method
Provide the xfer_partial target method for the btrace record target.

Only allow memory read accesses to readonly memory while we're replaying,
except for inserting and removing breakpoints.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* record-btrace.c (record_btrace_xfer_partial)
	(record_btrace_insert_breakpoint, record_btrace_remove_breakpoint)
	(record_btrace_allow_memory_access): New.
	(init_record_btrace_ops): Initialize new methods.
	* target.c (raw_memory_xfer_partial): Bail out if target reports
	that this memory is not available.
2014-01-16 13:06:14 +01:00
Markus Metzger 3db08215d4 target, breakpoint: allow insert/remove breakpoint to be forwarded
2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* target.h (target_ops) <to_insert_breakpoint>
	<to_remove_breakpoint>: Add target_ops parameter.
	(forward_target_insert_breakpoint): New.
	(forward_target_remove_breakpoint): New.
	(memory_remove_breakpoint, memory_insert_breakpoint):
	Add target_ops parameter.
	* target.c (target_insert_breakpoint): Split into this and ...
	(forward_target_insert_breakpoint): ... this.
	(target_remove_breakpoint): Split into this and ...
	(forward_target_remove_breakpoint): ... this.
	(debug_to_insert_breakpoint): Add target_ops parameter.
	Call forward_target_insert_breakpoint.
	(debug_to_remove_breakpoint): Add target_ops parameter.
	Call forward_target_remove_breakpoint.
	(update_current_target): Do not inherit or default to_insert_breakpoint
	and to_remove_breakpoint.
	* corelow.c (ignore): Add target_ops parameter.
	* exec.c (ignore): Add target_ops parameter.
	* mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint):
	Add target_ops parameter.
	* monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint):
	Add target_ops parameter.
	* nto-procfs.c (procfs_insert_breakpoint, procfs_remove_breakpoint):
	Add target_ops parameter.
	* record-full.c (record_full_beneath_to_insert_breakpoint)
	(record_full_beneath_to_remove_breakpoint, tmp_to_insert_breakpoint)
	(tmp_to_remove_breakpoint, record_full_insert_breakpoint)
	(record_full_remove_breakpoint, record_full_core_insert_breakpoint)
	(record_full_core_remove_breakpoint): Add target_ops parameter.
	Update users.
	(record_full_beneath_to_insert_breakpoint_ops)
	(record_full_beneath_to_remove_breakpoint_ops)
	(tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops): New.
	(record_full_open): Initialize tmp_to_insert_breakpoint_ops,
	tmp_to_remove_breakpoint_ops,
	record_full_beneath_to_insert_breakpoint_ops, and
	record_full_beneath_to_remove_breakpoint_ops.
	* remote-m32r-sdi.c (m32r_insert_breakpoint)
	(m32r_remove_breakpoint): Add target_ops parameter.
	* remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint):
	Add target_ops parameter.
	* remote.c (remote_insert_breakpoint, remote_remove_breakpoint):
	Add target_ops parameter.
2014-01-16 13:06:13 +01:00
Markus Metzger cecac1aba0 record-btrace, frame: supply target-specific unwinder
Supply a target-specific frame unwinder for the record-btrace target that does
not allow unwinding while replaying.

2013-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
            Markus Metzger  <markus.t.metzger@intel.com>

gdb/
	* record-btrace.c: Include frame-unwind.h.
	(record_btrace_frame_unwind_stop_reason)
	(record_btrace_frame_this_id, record_btrace_frame_prev_register)
	(record_btrace_frame_sniffer, record_btrace_frame_unwind):
	New.
	(init_record_btrace_ops): Install it.
2014-01-16 13:06:12 +01:00
Markus Metzger 824344ca4f frame: do not assume unwinding will succeed
In get_frame_unwind_stop_reason, remove the assumption that further frame
unwinding will succeed.

gdb/
2013-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* frame.c (get_frame_unwind_stop_reason): Unconditionally call
	get_prev_frame_1.
2014-01-16 13:06:12 +01:00
Markus Metzger 32261e5234 frame, cfa: check unwind stop reason first
Swap the unwind stop reason check and the unwinder check to allow
non-dwarf2 frame types to fail with a recoverable error.

gdb/
2013-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2-frame.c (dwarf2_frame_cfa): Move UNWIND_UNAVAILABLE check
	earlier.
2014-01-16 13:06:11 +01:00
Markus Metzger ea001bdce2 frame, backtrace: allow targets to supply a frame unwinder
Allow targets to supply their own target-specific frame unwinders; one for
normal frames and one for tailcall frames.  If a target-specific unwinder
is supplied, it will be chosen before any other unwinder.

The original patch has been split into this and the next two patches.

gdb/
2013-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* frame-unwind.c: Include target.h.
	(frame_unwind_try_unwinder): New function with code from ...
	(frame_unwind_find_by_frame): ... here.  New variable
	unwinder_from_target, call also target_get_unwinder)
	(target_get_tailcall_unwinder, and frame_unwind_try_unwinder for it.
	* target.c (target_get_unwinder, target_get_tailcall_unwinder): New.
	* target.h (struct target_ops): New fields to_get_unwinder and
	to_get_tailcall_unwinder.
	(target_get_unwinder, target_get_tailcall_unwinder): New declarations.
2014-01-16 13:06:11 +01:00
Markus Metzger 1f3ef5810c record-btrace: supply register target methods
Supply target methods to allow reading the PC.  Forbid anything else.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* record-btrace.c (record_btrace_fetch_registers)
	(record_btrace_store_registers)
	(record_btrace_to_prepare_to_store): New.
	(init_record_btrace_ops): Add the above.
2014-01-16 13:06:10 +01:00
Markus Metzger f32dbf8c79 Add target_ops argument to to_prepare_to_store
2013-12-17  Tom Tromey  <tromey@redhat.com>

	* windows-nat.c (windows_prepare_to_store): Add 'self' argument.
	* target.h (struct target_ops) <to_prepare_to_store>: Add
	argument.
	(target_prepare_to_store): Add argument.
	* target.c (debug_to_prepare_to_store): Add argument.
	(update_current_target): Update.
	* remote.c (remote_prepare_to_store): Add 'self' argument.
	* remote-sim.c (gdbsim_prepare_to_store): Add 'self' argument.
	* remote-mips.c (mips_prepare_to_store): Add 'self' argument.
	* remote-m32r-sdi.c (m32r_prepare_to_store): Add 'self' argument.
	* record-full.c (record_full_core_prepare_to_store): Add 'self'
	argument.
	* ravenscar-thread.c (ravenscar_prepare_to_store): Add argument.
	* nto-procfs.c (procfs_prepare_to_store): Add 'self' argument.
	* monitor.c (monitor_prepare_to_store): Add 'self' argument.
	* inf-child.c (inf_child_prepare_to_store): Add 'self' argument.
	* go32-nat.c (go32_prepare_to_store): Add 'self' argument.
2014-01-16 13:06:10 +01:00
Markus Metzger 07bbe694e7 btrace: add replay position to btrace thread info
Add a branch trace instruction iterator pointing to the current replay position
to the branch trace thread info struct.

Free the iterator when btrace is cleared.

Start at the replay position for the instruction and function-call histories.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.h (replay) <replay>: New.
	(btrace_is_replaying): New.
	* btrace.c (btrace_clear): Free replay iterator.
	(btrace_is_replaying): New.
	* record-btrace.c (record_btrace_is_replaying): New.
	(record_btrace_info): Print insn number if replaying.
	(record_btrace_insn_history): Start at replay position.
	(record_btrace_call_history): Start at replay position.
	(init_record_btrace_ops): Init to_record_is_replaying.
2014-01-16 13:06:09 +01:00
Markus Metzger 0688d04e19 record-btrace: make ranges include begin and end
The "record function-call-history" and "record instruction-history" commands
accept a range "begin, end".  End is not included in both cases.  Include it.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* record-btrace.c (record_btrace_insn_history_range): Include
	end.
	(record_btrace_insn_history_from): Adjust range.
	(record_btrace_call_history_range): Include
	end.
	(record_btrace_call_history_from): Adjust range.
	* NEWS: Announce changes.

testsuite/
	* gdb.btrace/function_call_history.exp: Update tests.
	* gdb.btrace/instruction_history.exp: Update tests.

doc/
	* gdb.texinfo (Process Record and Replay): Update documentation.
2014-01-16 13:05:38 +01:00
Markus Metzger 8710b7097e record-btrace: optionally indent function call history
Add a new modifier /c to the "record function-call-history" command to
indent the function name based on its depth in the call stack.

Also reorder the optional fields to have the indentation at the very beginning.
Prefix the insn range (/i modifier) with "inst ".
Prefix the source line (/l modifier) with "at ".
Change the range syntax from "begin-end" to "begin,end" to allow copy&paste to
the "record instruction-history" and "list" commands.

Adjust the respective tests and add new tests for the /c modifier.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* record.h (enum record_print_flag)
	<record_print_indent_calls>: New.
	* record.c (get_call_history_modifiers): Recognize /c modifier.
	(_initialize_record): Document /c modifier.
	* record-btrace.c (btrace_call_history): Add btinfo parameter.
	Reorder fields.  Optionally indent the function name.  Update
	all users.
	* NEWS: Announce changes.

testsuite/
	* gdb.btrace/function_call_history.exp: Fix expected field
	order for "record function-call-history".
	Add new tests for "record function-call-history /c".
	* gdb.btrace/exception.cc: New.
	* gdb.btrace/exception.exp: New.
	* gdb.btrace/tailcall.exp: New.
	* gdb.btrace/x86-tailcall.S: New.
	* gdb.btrace/x86-tailcall.c: New.
	* gdb.btrace/unknown_functions.c: New.
	* gdb.btrace/unknown_functions.exp: New.
	* gdb.btrace/Makefile.in (EXECUTABLES): Add new.

doc/
	* gdb.texinfo (Process Record and Replay): Document new /c
	modifier accepted by "record function-call-history".
	Add /i modifier to "record function-call-history" example.
2014-01-16 13:03:41 +01:00
Markus Metzger d0fa75352b btrace: increase buffer size
Try to allocate as much buffer as we can for each thread with a maximum
of 64KB.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* common/linux-btrace.c (linux_enable_btrace): Enlarge buffer.
2014-01-16 12:58:53 +01:00
Markus Metzger 5de9129b06 record-btrace: start counting at one
The record instruction-history and record-function-call-history commands start
counting instructions at zero.  This is somewhat unintuitive when we start
navigating in the recorded instruction history.  Start at one, instead.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.c (ftrace_new_function): Start counting at one.
	* record-btrace.c (record_btrace_info): Adjust number of calls
	and insns.
	* NEWS: Announce it.

testsuite/
    * gdb.btrace/instruction_history.exp: Update.
    * gdb.btrace/function_call_history.exp: Update.
2014-01-16 12:58:25 +01:00
Markus Metzger 7acbe13307 record-btrace: fix insn range in function call history
With the "/i" modifier, we print the instruction number range in the
"record function-call-history" command as [begin, end).

It would be more intuitive if we printed the range as [begin, end].

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* record-btrace.c (btrace_call_history_insn_range): Print
	insn range as [begin, end].
2014-01-16 12:45:12 +01:00
Markus Metzger 23a7fe7580 btrace: change branch trace data structure
The branch trace is represented as 3 vectors:
  - a block vector
  - a instruction vector
  - a function vector

Each vector (except for the first) is computed from the one above.

Change this into a graph where a node represents a sequence of instructions
belonging to the same function and where we have three types of edges to connect
the function segments:
  - control flow
  - same function (instance)
  - call stack

This allows us to navigate in the branch trace.  We will need this for "record
goto" and reverse execution.

This patch introduces the data structure and computes the control flow edges.
It also introduces iterator structs to simplify iterating over the branch trace
in control-flow order.

It also fixes PR gdb/15240 since now recursive calls are handled correctly.
Fix the test that got the number of expected fib instances and also the
function numbers wrong.

The current instruction had been part of the branch trace.  This will look odd
once we start support for reverse execution.  Remove it.  We still keep it in
the trace itself to allow extending the branch trace more easily in the future.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.h (struct btrace_func_link): New.
	(enum btrace_function_flag): New.
	(struct btrace_inst): Rename to ...
	(struct btrace_insn): ...this. Update all users.
	(struct btrace_func) <ibegin, iend>: Remove.
	(struct btrace_func_link): New.
	(struct btrace_func): Rename to ...
	(struct btrace_function): ...this. Update all users.
	(struct btrace_function) <segment, flow, up, insn, insn_offset)
	(number, level, flags>: New.
	(struct btrace_insn_iterator): Rename to ...
	(struct btrace_insn_history): ...this.
	Update all users.
	(struct btrace_insn_iterator, btrace_call_iterator): New.
	(struct btrace_target_info) <btrace, itrace, ftrace>: Remove.
	(struct btrace_target_info) <begin, end, level>
	<insn_history, call_history>: New.
	(btrace_insn_get, btrace_insn_number, btrace_insn_begin)
	(btrace_insn_end, btrace_insn_prev, btrace_insn_next)
	(btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get)
	(btrace_call_number, btrace_call_begin, btrace_call_end)
	(btrace_call_prev, btrace_call_next, btrace_call_cmp)
	(btrace_find_function_by_number, btrace_set_insn_history)
	(btrace_set_call_history): New.
	* btrace.c (btrace_init_insn_iterator)
	(btrace_init_func_iterator, compute_itrace): Remove.
	(ftrace_print_function_name, ftrace_print_filename)
	(ftrace_skip_file): Change
	parameter to const.
	(ftrace_init_func): Remove.
	(ftrace_debug): Use new btrace_function fields.
	(ftrace_function_switched): Also consider gaining and
	losing symbol information).
	(ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return)
	(ftrace_new_switch, ftrace_find_caller, ftrace_new_function)
	(ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall):
	New.
	(ftrace_new_function): Move. Remove debug print.
	(ftrace_update_lines, ftrace_update_insns): New.
	(ftrace_update_function): Check for call, ret, and jump.
	(compute_ftrace): Renamed to ...
	(btrace_compute_ftrace): ...this. Rewritten to compute call
	stack.
	(btrace_fetch, btrace_clear): Updated.
	(btrace_insn_get, btrace_insn_number, btrace_insn_begin)
	(btrace_insn_end, btrace_insn_prev, btrace_insn_next)
	(btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get)
	(btrace_call_number, btrace_call_begin, btrace_call_end)
	(btrace_call_prev, btrace_call_next, btrace_call_cmp)
	(btrace_find_function_by_number, btrace_set_insn_history)
	(btrace_set_call_history): New.
	* record-btrace.c (require_btrace): Use new btrace thread
	info fields.
	(record_btrace_info, btrace_insn_history)
	(record_btrace_insn_history, record_btrace_insn_history_range):
	Use new btrace thread info fields and new iterator.
	(btrace_func_history_src_line): Rename to ...
	(btrace_call_history_src_line): ...this. Use new btrace
	thread info fields.
	(btrace_func_history): Rename to ...
	(btrace_call_history): ...this. Use new btrace thread info
	fields and new iterator.
	(record_btrace_call_history, record_btrace_call_history_range):
	Use new btrace thread info fields and new iterator.

testsuite/
	* gdb.btrace/function_call_history.exp: Fix expected function
	trace.
	* gdb.btrace/instruction_history.exp: Initialize traced.
	Remove traced_functions.
2014-01-16 12:45:11 +01:00
Markus Metzger 8372a7cb96 frame: add frame_id_build_unavailable_stack_special
Add a function to build a frame_id for a frame with unavailable stack
and with a special identifier address.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* frame.h (frame_id_build_unavailable_stack_special): New.
	* frame.c (frame_id_build_unavailable_stack_special): New.
2014-01-16 12:45:11 +01:00
Markus Metzger c2170eeffa gdbarch: add instruction predicate methods
Add new methods to gdbarch for analyzing the instruction at a given address.
Implement those methods for i386 and amd64 architectures.

This is needed by "record btrace" to detect function calls in the
execution trace.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* amd64-tdep.c (amd64_classify_insn_at, amd64_insn_is_call)
	(amd64_insn_is_ret, amd64_insn_is_jump, amd64_jmp_p): New.
	(amd64_init_abi): Add insn_is_call, insn_is_ret, and insn_is_jump
	to gdbarch.
	* i386-tdep.c (i386_insn_is_call, i386_insn_is_ret)
	(i386_insn_is_jump, i386_jmp_p): New.
	(i386_gdbarch_init): Add insn_is_call, insn_is_ret, and
	insn_is_jump to gdbarch.
	* gdbarch.sh (insn_is_call, insn_is_ret, insn_is_jump): New.
	* gdbarch.h: Regenerated.
	* gdbarch.c: Regenerated.
	* arch-utils.h (default_insn_is_call, default_insn_is_ret)
	(default_insn_is_jump): New.
	* arch-utils.c (default_insn_is_call, default_insn_is_ret)
	(default_insn_is_jump): New.
2014-01-16 12:45:11 +01:00
Markus Metzger 864089d2f6 btrace: uppercase btrace_read_type
2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* common/btrace-common.h (btrace_read_type) <btrace_read_all>:
	Change to ...
	(btrace_read_type) <BTRACE_READ_ALL>: ... this.  Update users.
	(btrace_read_type) <btrace_read_new>: Change to ...
	(btrace_read_type) <BTRACE_READ_NEW>: ... this.  Update users.
2014-01-16 12:45:10 +01:00
Markus Metzger ed9edfb5d5 btrace, linux: fix memory leak when reading branch trace
When it takes more than one iteration to read the BTS trace, the trace from the
previous iteration is leaked.  Fix it.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* common/linux-btrace.c (linux_read_btrace): Free trace from
	previous iteration.
2014-01-16 12:45:10 +01:00
Markus Metzger 724c7dd8a4 btrace, test: fix multi-line btrace tests
For testing multi-line test output, gdb.btrace tests used the following
pattern:

  gdb_test "..." "
  ...\r
  ..."

Change this to:

  gdb_test "..." [join [list \
    "..." \
    "..."] "\r\n"]

Also extract repeated tests into a test function and shorten or remove
test messages.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

testsuite/
	* gdb.btrace/function_call_history.exp: Update
	* gdb.btrace/instruction_history.exp: Update.
2014-01-16 12:45:09 +01:00
Markus Metzger 6d78d93b8d test, btrace: update expected text
The error message for starting recording twice changed.
Update the expected text to fix resulting regressions.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* gdb.btrace/enable.exp: Update expected text.
2014-01-16 12:45:08 +01:00
Omair Javaid 93a360cc5d Fix testsuite/gdb.dwarf2/dw2-dos-drive.exp on ARM.
This test currently fails on ARM:

  (gdb) PASS: gdb.dwarf2/dw2-dos-drive.exp: set breakpoint pending off
  break 'z:file.c':func
  Cannot access memory at address 0x0

The error is GDB trying to read the prologue at the breakpoint's
address, and failing:

  38 throw_error() exceptions.c:444 0x0016728c
  37 memory_error() corefile.c:204 0x001d1fcc
  36 read_memory() corefile.c:223 0x001d201a
  35 read_memory_unsigned_integer() corefile.c:312 0x001d2166
  34 arm_skip_prologue() arm-tdep.c:1452 0x00054270

  static CORE_ADDR
  arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
  {
  ...
    for (skip_pc = pc; skip_pc < limit_pc; skip_pc += 4)
      {
        inst = read_memory_unsigned_integer (skip_pc, 4, byte_order_for_code);


The test doesn't execute the compiled object's code, so GDB will try
to read memory from the binary's sections.  Instructions on ARM are
4-byte wide, and thus ARM's prologue scanner reads in 4-byte chunks.
As the section 'func' is put at is only 1 byte long, and no other
section is allocated contiguously:

  ...
  Sections:
  Idx Name          Size      VMA       LMA       File off  Algn
    0 .text         00000001  00000000  00000000  00000034  2**0
                    CONTENTS, ALLOC, LOAD, READONLY, CODE
  ...

... the exec target fails the read the 4 bytes.

Fix this by increasing the function's size.

gdb/testsuite/ChangeLog:
2014-01-16  Omair Javaid  <Omair.Javaid@linaro.org>

	* gdb.dwarf2/dw2-dos-drive.S: Increase text section size to 4
	bytes.
2014-01-16 10:09:34 +00:00
Doug Evans ab7f45ba10 delete thread_id_to_gdb_id, unused
* inferiors.c (thread_id_to_gdb_id): Delete.
	* inferiors.h (thread_id_to_gdb_id): Delete.
2014-01-15 16:35:37 -08:00
Maciej W. Rozycki 3772b53f14 AArch64: gdb.base/float.exp: Fix `info float' test
* gdb.base/float.exp: Handle "aarch64*-*-*" targets.
2014-01-15 22:17:53 +00:00
Doug Evans fbcbc3fda4 * dwarf2read.c (open_and_init_dwp_file): Use pulongest to print uint32_t. 2014-01-15 13:14:06 -08:00
Tom Tromey 3d548a532d move the "main" data into the per-BFD object
This adds the "main"-related data into the per-BFD.  This is needed
because once symbol sharing across objfiles is complete, computing the
main name as a side effect of symbol reading will no longer work --
the symbols simply won't be re-read.

After this change, set_main_name is only used by the main_name
machinery itself, so this patch makes it static.

2014-01-15  Tom Tromey  <tromey@redhat.com>

	* dbxread.c (process_one_symbol): Use set_objfile_main_name.
	* dwarf2read.c (read_partial_die): Use set_objfile_main_name.
	* objfiles.c (get_objfile_bfd_data): Initialize language_of_main.
	(set_objfile_main_name): New function.
	* objfiles.h (struct objfile_per_bfd_storage) <name_of_main,
	language_of_main>: New fields.
	(set_objfile_main_name): Declare.
	* symtab.c (find_main_name): Loop over objfiles to find the main
	name and language.
	(set_main_name): Now static.
	(get_main_info): Add comment.
	* symtab.h (set_main_name): Don't declare.
2014-01-15 12:06:04 -07:00
Tom Tromey 32ac0d11e6 move main name into the progspace
This moves the "main" name and language into an object attached to the
current progspace.  This prevents problems if there are multiple
inferiors tha have different ideas of "main" -- which matters at least
for unwinding, see frame.c:inside_main_func.

2014-01-15  Tom Tromey  <tromey@redhat.com>

	* symtab.c (main_progspace_key): New global.
	(struct main_info): New.
	(name_of_main, language_of_main): Remove.
	(get_main_info, main_info_cleanup): New function.
	(set_main_name, main_name, main_language): Use get_main_info.
	(_initialize_symtab): Initialize main_progspace_key.
2014-01-15 12:06:04 -07:00
Tom Tromey 9e6c82ad4f make language_of_main static
This makes the global language_of_main static.  Now it can be set only
via a new argument to set_main_name.

2014-01-15  Tom Tromey  <tromey@redhat.com>

	* dbxread.c (process_one_symbol): Update.
	* dwarf2read.c (read_partial_die): Update.
	* symfile.c (set_initial_language): Call main_language.
	* symtab.c (language_of_main): Now static.
	(set_main_name): Add 'lang' parameter.
	(find_main_name): Update.
	(main_language): New function.
	(symtab_observer_executable_changed): Update.
	* symtab.h (set_main_name): Update.
	(language_of_main): Remove.
	(main_language): Declare.
2014-01-15 12:06:04 -07:00
Tom Tromey 6ef55de768 move the entry point info into the per-bfd object
This moves the entry point information into the per-BFD object and
arranges not to recompute it when it has already been computed.

2014-01-15  Tom Tromey  <tromey@redhat.com>

	* symfile.c (init_entry_point_info): Use new "initialized" field.
	Update.
	* objfiles.h (struct entry_point) <initialized>: New field.
	(struct objfile_per_bfd_storage) <ei>: New field, moved from...
	(struct objfile) <ei>: ...here.  Remove.
	* objfiles.c (entry_point_address_query): Update.
2014-01-15 11:02:23 -07:00
Tom Tromey 53eddfa606 relocate the entry point address when used
This changes the entry point to be unrelocated in the objfile, and
instead applies the relocation when it is used.

2014-01-15  Tom Tromey  <tromey@redhat.com>

	* objfiles.c (entry_point_address_query): Relocate entry point
	address.
	(objfile_relocate1): Do not relocate entry point address.
	* objfiles.h (struct entry_info) <entry_point>: Update comment.
	<the_bfd_section_index>: New field.
	* symfile.c (init_entry_point_info): Find the entry point's
	section.
2014-01-15 11:02:23 -07:00
Tom Tromey d56e56aaa7 change solib-frv to use entry_point_address_query
This is just a minor cleanup in advance of some other changes, that
modifies solib-frv.c to use entry_point_address_query.  I don't have a
good way to test this but I think it is obviously correct.

2014-01-15  Tom Tromey  <tromey@redhat.com>

	* solib-frv.c (enable_break): Use entry_point_address_query.
2014-01-15 11:02:23 -07:00
Omair Javaid 33a97bbe01 gdb: Add a NEWS entry for ARM record/replay improvements
This patch adds a news entry about improvements in record-replay and
reverse debugging support for arm*-linux* targets.

gdb/ChangeLog:

2014-01-15  Omair Javaid  <omair.javaid@linaro.org>

	* NEWS: Add note on improved process record-replay on
	arm*-linux* targets.
2014-01-15 16:58:58 +00:00
Omair Javaid 596662fa99 gdb: ARM: Update configure.tgt and enable gdb.reverse testsuite
gdb/testsuite/ChangeLog:

2014-01-15  Omair Javaid  <omair.javaid@linaro.org>

	* lib/gdb.exp (supports_process_record): Return true for
	arm*-linux*.  (supports_reverse): Likewise.
2014-01-15 16:57:38 +00:00
Omair Javaid c6ec2b3055 gdb: ARM: Add support for thumb32 instructions recording
gdb/ChangeLog:

2014-01-15  Omair Javaid  <omair.javaid@linaro.org>

	* arm-tdep.c (enum arm_record_result): New enum.
	(arm_record_unsupported_insn): New function.
	(arm_record_coproc_data_proc): Removed.
	(thumb2_record_ld_st_multiple): New function.
	(thumb2_record_ld_st_dual_ex_tbb): New function.
	(thumb2_record_data_proc_sreg_mimm): New function.
	(thumb2_record_ps_dest_generic): New function.
	(thumb2_record_branch_misc_cntrl): New function.
	(thumb2_record_str_single_data): New function.
	(thumb2_record_ld_mem_hints): New function.
	(thumb2_record_ld_word): New function.
	(thumb2_record_lmul_lmla_div): New function.
	(thumb2_record_decode_insn_handler): New function.
	(decode_insn): Add thumb32 instruction handlers.
2014-01-15 16:53:44 +00:00
Omair Javaid 97dfe20617 gdb: ARM: Adds support for recording system call instructions
gdb/ChangeLog:

2014-01-15  Omair Javaid  <omair.javaid@linaro.org>

	* arm-linux-tdep.c: Include "record-full.h" and "linux-record.h".
	(struct arm_linux_record_tdep): Declare.
	(arm_canonicalize_syscall): New function.
	(arm_all_but_pc_registers_record): New function.
	(arm_linux_syscall_record): New function.
	(arm_linux_init_abi): Add syscall recording constructs.
	* arm-tdep.c (thumb_record_ldm_stm_swi): Update thumb syscall
	decoding.  (arm_record_coproc_data_proc): Update arm syscall
	decoding.
	* arm-tdep.h (struct gdbarch_tdep) <arm_swi_record>: Remove.
	<arm_syscall_record>: New field.
	* configure.tgt (arm*-*-linux*): Add linux-record.o to
	gdb_target_obs.
2014-01-15 16:50:40 +00:00
Omair Javaid 9904a494c1 gdb: ARM: Fix for bug in pop instruction decoding
This patch fixes thumb push instruction recording by replacing base
register from pc to sp.

gdb/ChangeLog:

2014-01-15  Omair Javaid  <omair.javaid@linaro.org>

	* arm-tdep.c (thumb_record_misc): Update to use sp as base
	register for push instruction recording.
2014-01-15 16:47:07 +00:00
Omair Javaid f969241e66 gdb: ARM: Fix for bugs in push and ldm instructions decoding
This patch corrects the register numbers and removes multiple loops in
recording procedure of instructions involving multiple registers.

gdb/ChangeLog:

2014-01-15  Omair Javaid  <omair.javaid@linaro.org>

	* arm-tdep.c (thumb_record_misc): Update to correct logical
	error while recording ldm, ldmia and pop instructions.
2014-01-15 16:43:38 +00:00
Omair Javaid bfbbec0088 gdb: ARM: Fix for memory record corruption due to 64bit addresses
gdb/ChangeLog:

2014-01-15  Omair Javaid  <omair.javaid@linaro.org>

	* arm-tdep.c (struct arm_mem_r) <addr>: Change type to uint32_t.
2014-01-15 16:41:52 +00:00
Pedro Alves e40adcc9f8 Fix go32-nat.c build fallout from to_detach constification.
The recent constification of to_detach missed updating the forward
declaration of go32_detach, breaking the build:

 ../../src/gdb/go32-nat.c:387:1: error: conflicting types for 'go32_detach'
 ../../src/gdb/go32-nat.c:240:13: note: previous declaration of 'go32_detach' was here

go32_detach is actually defined before it's ever used, making the
forward declaration is unnecessary.  So we can just remove it instead
of updating it.  While at it, remove all others in the same situation.
Tested by building a djgpp gdb.

gdb/
2014-01-15  Pedro Alves  <palves@redhat.com>

	* go32-nat.c (go32_open, go32_close, go32_attach, go32_detach)
	(go32_resume, go32_fetch_registers, store_register)
	(go32_store_registers, go32_prepare_to_store)
	(go32_xfer_memory, go32_files_info, go32_kill_inferior)
	(go32_create_inferior, go32_can_run, go32_terminal_init)
	(go32_terminal_inferior, go32_terminal_ours): Delete forward
	declarations.
2014-01-15 16:18:04 +00:00
Tom Tromey b0a16e66b0 introduce async_callback_ftype
This introduces async_callback_ftype.  This is needed for
make-target-delegates to work properly, as it doesn't implement a real
parser.  I think it's also an ok cleanup in its own right.

2014-01-15  Tom Tromey  <tromey@redhat.com>

	* target.h (async_callback_ftype): New typedef.
	(struct target_ops) <to_async>: Use it.
2014-01-15 08:18:57 -07:00
Joel Brobecker bf7105a442 Fix small style violation in py-value.c:get_field_type
gdb/ChangeLog:

        * python/py-value.c (get_field_type): Remove unnecessary curly
        braces for single-statement if block.

Tested on x86_64-linux.
2014-01-15 16:42:16 +04:00
Joel Brobecker a8f35c2ec3 Add missing empty line after declarations in "if" block (py-type.c).
This patch fixes a small coding-style violation...

gdb/ChangeLog:

        * python/py-type.c (convert_field): Add missing empty line
        after declarations.
2014-01-15 16:32:05 +04:00
Joel Brobecker dcf106f37d Small fixes to the GDB/MI Output Syntax grammar.
This patch fixes the grammar, and tries to do it in a way that makes
the logic behind the current implementation a little clearer.

gdb/doc/ChangeLog:

        (from Yuanhui Zhang  <asmwarrior@gmail.com>)
        (from Joel Brobecker  <brobecker@adacore.com>)
        * gdb.texinfo (GDB/MI Output Syntax): Add some missing "nl"
        markers.  Remove one that was misplaced.
2014-01-15 16:19:47 +04:00
Doug Evans bb4142cf49 psymtab cleanup patch 3/3
This last patch removes "partial" from the names of
expand_partial_symbol_names and map_partial_symbol_filenames.
It also renames expand_partial_symbol_names to match the
struct quick_symbol_functions "method" that it wraps:
expand_symtabs_matching.

This patch also adds two parameters to expand_symtabs_matching
so that it can fully wrap the underlying quick_symbol_functions method.
This makes it usable in more places.
I thought of having a cover function that still had the same
signature as the old expand_partial_symbol_names function,
but I couldn't think of a good name, and it wasn't clear it was
worth it anyway.

	* symfile.h (expand_symtabs_matching): Renamed from
	expand_partial_symbol_names.  Update prototype.
	(map_symbol_filenames): Renamed from map_partial_symbol_filenames.
	* symfile.c (expand_symtabs_matching): Renamed from
	expand_partial_symbol_names.  New args file_matcher, kind.
	Rename arg fun to symbol_matcher.
	(map_symbol_filenames): Renamed from map_partial_symbol_filenames.
	* ada-lang.c (ada_complete_symbol_matcher): Renamed from
	ada_expand_partial_symbol_name.
	(ada_make_symbol_completion_list): Update to call
	expand_symtabs_matching.
	(ada_add_global_exceptions): Call expand_symtabs_matching.
	* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update to
	call map_symbol_filenames.
	* symtab.c (sources_info): Update to call map_symbol_filenames.
	(search_symbols): Call expand_symtabs_matching.
	(symbol_completion_matcher): Renamed from expand_partial_symbol_name.
	(default_make_symbol_completion_list_break_on): Update to call
	expand_symtabs_matching.
	(make_source_files_completion_list): Update to call
	map_symbol_filenames.
2014-01-14 18:36:33 -08:00
Doug Evans 206f2a5777 psymtab cleanup patch 2/3
This patch adds two typedefs:
expand_symtabs_file_matcher_ftype
expand_symtabs_symbol_matcher_ftype

It also renames the NAME_MATCHER argument in expand_symtabs_matching.
The function is named expand_symtabs_matching and it takes a name_matcher
argument.  Name of what?  The symtab?  A symbol?
I made it SYMBOL_MATCHER to make it clearer.

	* symfile.h (expand_symtabs_file_matcher_ftype): New typedef.
	(expand_symtabs_symbol_matcher_ftype): New typedef.
	(quick_symbol_functions.expand_symtabs_matching): Update to use.
	expand_symtabs_file_matcher_ftype, expand_symtabs_symbol_matcher_ftype.
	* symfile.c (expand_partial_symbol_names): Update to use
	expand_symtabs_symbol_matcher_ftype.
	* dwarf2read.c (dw2_expand_symtabs_matching): Update to use
	expand_symtabs_file_matcher_ftype, expand_symtabs_symbol_matcher_ftype.
	Arg name_matcher renamed to symbol_matcher.
	* psymtab.c (recursively_search_psymtabs): Update to use
	expand_symtabs_symbol_matcher_ftype.  Arg name_matcher renamed to
	sym_matcher.
	(expand_symtabs_matching_via_partial): Update to use
	expand_symtabs_file_matcher_ftype, expand_symtabs_symbol_matcher_ftype.
	Arg name_matcher renamed to symbol_matcher.
2014-01-14 18:30:31 -08:00
Doug Evans 540c2971fa psymtab cleanup patch 1/3
This is the first of a set of three patches to cleanup psymtab.c a bit.

Basically, these two functions do not belong in psymtab.c:
expand_partial_symbol_names, map_partial_symbol_filenames,
and "partial" does not belong in the function name.

This first patch moves them to a better location.
The second patch adds some typedefs for function parameters to
quick_symbol_functions.expand_symtabs_matching.
The third patch removes "partial" from the function names
and uses them in more places.

	* psymtab.c (expand_partial_symbol_names): Delete, moved to symfile.c.
	(map_partial_symbol_filenames): Ditto.
	* psymtab.h (expand_partial_symbol_names): Delete, moved to symfile.h.
	(map_partial_symbol_filenames): Ditto.
	* symfile.c (expand_partial_symbol_names): Moved here from psymtab.c.
	(map_partial_symbol_filenames): Ditto.
	* symfile.h (expand_partial_symbol_names): Moved here from psymtab.h.
	(map_partial_symbol_filenames): Ditto.
	* symtab.c: Delete #include "psymtab.h".
2014-01-14 18:19:51 -08:00
Pedro Alves 8213266aea Fix "is a record target open" checks.
RECORD_IS_USED and record_full_open look at current_target.to_stratum
to determine whether a record target is in use.  This is wrong because
arch_stratum is greater than record_stratum, so if an arch_stratum
target is pushed, RECORD_IS_USED and record_full_open will miss it.

To fix this, we can use the existing find_record_target instead, which
looks up for a record stratum target across the target stack.  Since
that means exporting find_record_target in record.h, RECORD_IS_USED
ends up redundant, so the patch eliminates it.

That exercise then reveals other issues:

- adjust_pc_after_break is gating record_full_... calls based on
RECORD_IS_USED.  But, record_full_ calls shouldn't be made when
recording with the record-btrace target.  So this adds a new
record_full_is_used predicate to be used in that spot.

- record_full_open says "Process record target already running", even
if the recording target is record-btrace ("process record" is the
original complete name of the record-full target).  record_btrace_open
only says "The process is already being recorded." and does not
suggest "record stop", like record-full does.  The patch factors out
and merges that error to a new record_preopen function that all record
targets call in their open routine.

Tested on x86_64 Fedora 17.

gdb/
2014-01-14  Pedro Alves  <palves@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	* infrun.c (use_displaced_stepping): Use find_record_target
	instead of RECORD_IS_USED.
	(adjust_pc_after_break): Use record_full_is_used instead of
	RECORD_IS_USED.
	* record-btrace.c (record_btrace_open): Call record_preopen
	instead of checking RECORD_IS_USED.
	* record-full.c (record_full_shortname)
	(record_full_core_shortname): New globals.
	(record_full_is_used): New function.
	(find_full_open): Call record_preopen instead of checking
	RECORD_IS_USED.
	(init_record_full_ops): Set the target's shortname to
	record_full_shortname.
	(init_record_full_core_ops): Set the target's shortname to
	record_full_core_shortname.
	* record-full.h (record_full_is_used): Declare.
	* record.c (find_record_target): Make extern.
	(record_preopen): New function.
	* record.h (RECORD_IS_USED): Delete macro.
	(find_record_target, record_preopen): Declare functions.
2014-01-14 16:12:19 +00:00
Yao Qi 7ec1862d1a Change 'len''s type from LONGEST to ULONGEST: gdbarch methods core_xfer_shared_libraries and core_xfer_shared_libraries_aix
This patch changes the type of 'len' from LONGEST to ULONGEST.  'len'
is the argument of gdbarch methods core_xfer_shared_libraries and
core_xfer_shared_libraries_aix.

gdb:

2014-01-14  Yao Qi  <yao@codesourcery.com>

	* gdbarch.sh (core_xfer_shared_libraries): Change its argument
	'len''s type to ULONGEST.
	(core_xfer_shared_libraries_aix): Likewise.
	* gdbarch.c, gdbarch.h: Reenerated.
	* i386-cygwin-tdep.c (windows_core_xfer_shared_libraries):
	Change type of 'len' to ULONGEST.
	* rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise.
	(rs6000_aix_core_xfer_shared_libraries_aix): Likewise.
2014-01-14 22:20:59 +08:00
Yao Qi dea80a2705 Change 'len' of linux_common_xfer_osdata to ULONGEST.
gdb:

2014-01-14  Yao Qi  <yao@codesourcery.com>

	* common/linux-osdata.c (linux_xfer_osdata_processes): Change
	type of 'len' to ULONGEST.
	(linux_xfer_osdata_processgroups): Likewise.
	(linux_xfer_osdata_threads): Likewise.
	(linux_xfer_osdata_fds): Likewise.
	(linux_xfer_osdata_isockets): Likewise.
	(linux_xfer_osdata_shm): Likewise.
	(linux_xfer_osdata_sem): Likewise.
	(linux_xfer_osdata_msg): Likewise.
	(linux_common_xfer_osdata): Likewise.
	(struct osdata_type) <getter>: Likewise.
	* common/linux-osdata.h (linux_common_xfer_osdata): Update
	the declaration.
2014-01-14 22:20:51 +08:00
Yao Qi b55e14c72c Change to_xfer_partial 'len' type to ULONGEST.
This patch changes to_xfer_partial's len's type to ULONGEST, and
adjust its implementations.

gdb:

2014-01-14  Yao Qi  <yao@codesourcery.com>

	* target.h (target_xfer_partial_ftype): Update.
	(struct target_ops) <to_xfer_partial>: Change 'len' type to
	ULONGEST.
	* aix-thread.c (aix_thread_xfer_partial): Change type of
	argument 'len' to ULONGEST.
	* auxv.c (procfs_xfer_auxv): Likewise.
	(ld_so_xfer_auxv): Likewise.
	(memory_xfer_auxv): Likewise.
	* bfd-target.c (target_bfd_xfer_partial): Likewise.
	* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
	* bsd-uthread.c (bsd_uthread_xfer_partial): Likewise.
	* corelow.c (core_xfer_partial): Likewise.
	* ctf.c (ctf_xfer_partial): Likewise.
	* darwin-nat.c (darwin_read_write_inferior): Likewise.  Use
	'%u'.
	(darwin_read_dyld_info): Likewise.
	(darwin_xfer_partial): Likewise.
	* exec.c (section_table_xfer_memory_partial): Likewise.
	(exec_xfer_partial): Likewise.
	* exec.h (section_table_xfer_memory_partial): Update
	declaration.
	* gnu-nat.c (gnu_xfer_memory): Likewise.  Call pulongest
	instead of plongest.
	(gnu_xfer_partial): Likewise.
	* ia64-hpux-nat.c (ia64_hpux_xfer_memory): Likewise.
	(ia64_hpux_xfer_solib_got): Likewise.
	(ia64_hpux_xfer_partial): Likewise.
	* ia64-linux-nat.c (ia64_linux_xfer_partial):
	* inf-ptrace.c (inf_ptrace_xfer_partial):
	* inf-ttrace.c (inf_ttrace_xfer_partial):
	* linux-nat.c (linux_xfer_siginfo): Likewise.
	(linux_nat_xfer_partial): Likewise.
	(spu_enumerate_spu_ids, linux_proc_xfer_spu): Likewise.
	(linux_nat_xfer_osdata, linux_xfer_partial): Likewise.
	* monitor.c (monitor_xfer_memory): Likewise.
	(monitor_xfer_partial): Likewise.
	* procfs.c (procfs_xfer_partial): Likewise.
	* record-full.c (record_full_xfer_partial): Likewise.
	(record_full_core_xfer_partial): Likewise.
	* remote-sim.c (gdbsim_xfer_memory): Likewise.  Call pulongest
	instead of plongest.
	(gdbsim_xfer_partial): Likewise.
	* remote.c (remote_xfer_partial): Likewise.
	* rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise.
	* rs6000-aix-tdep.h (rs6000_aix_ld_info_to_xml): Update
	declaration.
	* rs6000-nat.c (rs6000_xfer_partial): Likewise.
	(rs6000_xfer_shared_libraries): Likewise.
	* sol-thread.c (sol_thread_xfer_partial): Likewise.
	* sparc-nat.c (sparc_xfer_wcookie): Likewise.
	(sparc_xfer_partial): Likewise.
	* spu-linux-nat.c (spu_proc_xfer_spu): Likewise.
	(spu_xfer_partial): Likewise.
	* spu-multiarch.c (spu_xfer_partial): Likewise.
	* target.c (target_read_live_memory): Likewise.
	(memory_xfer_live_readonly_partial): Likewise.
	(memory_xfer_partial, memory_xfer_partial_1): Likewise.
	(target_xfer_partial, default_xfer_partial): Likewise.
	(current_xfer_partial): Likewise.
	* tracepoint.c (tfile_xfer_partial): Likewise.
	* windows-nat.c (windows_xfer_memory): Likewise.  Call
	pulongest instead of plongest.
	(windows_xfer_partial): Likewise.
	(windows_xfer_shared_libraries): Likewise.
2014-01-14 22:20:44 +08:00
Yao Qi 0580464083 Use target_xfer_partial_ftype for rs6000_xfer_shared_libraries
Hi,
We can use target_xfer_partial_ftype here for
rs6000_xfer_shared_libraries declaration.

gdb:

2014-01-14  Yao Qi  <yao@codesourcery.com>

	* rs6000-nat.c (rs6000_xfer_shared_libraries): Use
	target_xfer_partial_ftype.
2014-01-14 22:20:37 +08:00
Siva Chandra b5b08fb4ff Use bitpos and type to lookup a gdb.Field object when its name is 'None'.
PR python/15464
	PR python/16113
	* valops.c (value_struct_elt_bitpos): New function
	* py-type.c (convert_field): Set 'name' attribute of a gdb.Field
	object to 'None' if the field name is an empty string ("").
	* python/py-value.c (valpy_getitem): Use 'bitpos' and 'type'
	attribute to look for a field when 'name' is 'None'.
	(get_field_type): New function

	testsuite/
	* gdb.python/py-type.c: Enhance test case.
	* gdb.python/py-value-cc.cc: Likewise
	* gdb.python/py-type.exp: Add new tests.
	* gdb.python/py-value-cc.exp: Likewise
2014-01-13 17:35:56 -08:00
Doug Evans 13aaf45454 PR symtab/16426
* dwarf2read.c (dwarf2_get_dwz_file): Call gdb_bfd_record_inclusion.
	(try_open_dwop_file): Ditto.
	* gdb_bfd.c: #include "vec.h".
	(bfdp): New typedef.
	(struct gdb_bfd_data): New member included_bfds.
	(gdb_bfd_unref): Unref all included bfds.
	(gdb_bfd_record_inclusion): New function.
	* gdb_bfd.h (gdb_bfd_record_inclusion): Declare.
2014-01-13 17:15:42 -08:00
Tom Tromey c2cec97c24 remove obsolete declaration
deprecated_core_resize_section_table is declared but never defined.
This patch removes the stale declaration.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* gdbcore.h (deprecated_core_resize_section_table): Remove.
2014-01-13 14:25:49 -07:00
Tom Tromey 78e5999d37 remove use_windows
Nothing actually uses use_windows, not even Insight.  So, this patch
removes it.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* defs.h (use_windows): Remove.
	* gdb.c (main): Update.
	* main.c (captured_main, gdb_main): Update.
	* main.h (struct captured_main_args) <use_windows>: Remove.
	* top.c (use_windows): Remove.
2014-01-13 14:25:48 -07:00
Tom Tromey f2052bbe7a remove unused deprecated_flush_hook declaration
deprecated_flush_hook is declared in defs.h but never defined.
This patch removes the stale declaration.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* defs.h (deprecated_flush_hook): Remove.
2014-01-13 14:25:47 -07:00
Jan Kratochvil fde4f8ed8c Fix set auto-load safe-path false warning regression (PR 16216)
gdb/
2014-01-07  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR threads/16216
	* linux-thread-db.c (try_thread_db_load): Add parameter
	check_auto_load_safe.  Move here the file_is_auto_load_safe call.
	(try_thread_db_load_from_pdir_1): Move it there from here.
	(try_thread_db_load_from_sdir): Update caller.
	(try_thread_db_load_from_dir): Move it there from here.
2014-01-13 21:19:18 +01:00
Patrick Palka bdf61915fc Have regdat.sh always rewrite the output register file
The rules for generating the output register files look like:

amd64.c : $(srcdir)/../regformats/i386/amd64.dat $(regdat_sh)
	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/i386/amd64.dat amd64.c

According to this rule, if regdat.sh is newer than amd64.c, then
regdat.sh shall be invoked on amd64.dat.  According to regdat.sh, if the
script determines that the output file amd64.c has not changed, then it
will not overwrite the existing output file.  This means that a
subsequent invocation of make will trigger the above rule again as
regdat.sh will be perpetually newer than amd64.c.

This then shows up in the make output like so:

/bin/bash ./../regformats/regdat.sh ./../regformats/i386/amd64-linux.dat amd64-linux.c
amd64-linux.c unchanged.
/bin/bash ./../regformats/regdat.sh ./../regformats/i386/amd64-avx-linux.dat amd64-avx-linux.c
amd64-avx-linux.c unchanged.
...

To fix this pathological behavior, it suffices to have regdat.sh
unconditionally rewrite the output register file.

On my machine, which has a regdat.sh file that is newer than some of the
input register files, this change speeds up every invocation of make
under gdb/ by about 5 seconds.
2014-01-13 12:53:53 -07:00
Pedro Alves f71e1a8ddb New "make check-headers" rule.
Tries to compile each header in isolation, thus ensuring headers are
self-contained.

Defaults to checking all $HFILES_NO_SRCDIR headers.

Do:

  make check-headers CHECK_HEADERS="header.h list.h"

to check specific headers.

gdb/
2014-01-13  Pedro Alves  <palves@redhat.com>

        * Makefile.in (CHECK_HEADERS): New variable.
        (check-headers:): New rule.
2014-01-13 19:36:38 +00:00
Tom Tromey 42c85435d6 remove deprecated_set_hook
This removes deprecated_set_hook.  Insight was the last user of this
hook, but I recently checked in a patch to have it use the
command_param_changed observer instead.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* cli/cli-setshow.c (do_set_command): Update.
	* defs.h (deprecated_set_hook): Remove.
	* top.c (deprecated_set_hook): Remove.
2014-01-13 12:33:43 -07:00
Eli Zaretskii 66af0f440b Fix MinGW compilation errors in gdbserver/.
gdb/gdbserver/Makefile.in (INCLUDE_CFLAGS): Remove trailing slash from
"-I$(srcdir)/../".  Fixes MinGW compilation errors with old GCC versions.
2014-01-13 20:54:47 +02:00
Pedro Alves f8de512932 tfile: Don't infer the PC from the tracepoint if the PC is a pseudo-register.
This PC guessing can't work when the PC is a pseudo-register.
Pseudo-register values don't end up stored in the regcache, they're
always recomputed.  And, it's actually wrong to try to write a
pseudo-register with regcache_raw_supply.  Skip it and add a comment.

gdb/
2014-01-13  Pedro Alves  <palves@redhat.com>

	* tracepoint.c (tfile_fetch_registers): Don't infer the PC from
	the tracepoint if the PC is a pseudo-register.
2014-01-13 14:56:29 +00:00
Tom Tromey fc270c357a replace XCALLOC with XCNEWVEC or XCNEW
This removes XCALLOC and replaces it either with XCNEWVEC, or, if the
number of elements being requested was 1, with XCNEW.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* defs.h (XCALLOC): Remove.
	* bcache.c (bcache_xmalloc): Use XCNEW, not XCALLOC.
	(print_bcache_statistics): Use XCNEWVEC, not XCALLOC.
	* dwarf2loc.c (allocate_piece_closure): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	(elf_symfile_segments): Likewise.
	* gdbtypes.c (copy_type_recursive): Likewise.
	* i386-tdep.c (i386_gdbarch_init): Use XCNEW, not XCALLOC.
	* jit.c (jit_frame_sniffer): Use XCNEWVEC, not XCALLOC.
	* minsyms.c (prim_record_minimal_symbol_full): Use XCNEW, not
	XCALLOC.
	* mt-tdep.c (mt_gdbarch_init): Likewise.
	* opencl-lang.c (allocate_lval_closure): Use XCNEWVEC, not
	XCALLOC.
	* psymtab.c (psymbol_compare): Use XCNEW, not XCALLOC.
	* regcache.c (regcache_xmalloc_1): Use XCNEWVEC, not XCALLOC.
	* registry.c (registry_alloc_data): Likewise.
	* rs6000-tdep.c (rs6000_gdbarch_init): Use XCNEW, not XCALLOC.
	* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
	* serial.c (serial_fdopen_ops): Likewise.
	* solib-aix.c (solib_aix_get_section_offsets): Use XCNEWVEC, not
	XCALLOC.
	* spu-tdep.c (spu_gdbarch_init): Use XCNEW, not XCALLOC.
	* symfile.c (default_symfile_segments): Use XCNEW and XCNEWVEC,
	not XCALLOC.
2014-01-13 07:31:29 -07:00
Tom Tromey 70ba0933ad replace XMALLOC with XNEW
This replaces XMALLOC with XNEW, and removes XMALLOC.  The only
non-mechanical bit here was remembering to edit gdbarch.sh.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* defs.h (XMALLOC): Remove.
	* avr-tdep.c (avr_gdbarch_init): Use XNEW, not XMALLOC.
	* bfin-tdep.c (bfin_gdbarch_init): Likewise.
	* cli-out.c (struct ui_out *): Likewise.
	* cli/cli-dump.c (add_dump_command): Likewise.
	(add_dump_command): Likewise.
	* complaints.c (get_complaints): Likewise.
	(find_complaint): Likewise.
	* dwarf2-frame.c (execute_cfa_program): Likewise.
	* dwarf2read.c (abbrev_table_read_table): Likewise.
	* gdbarch.sh: Likewise.
	* gdbarch.c: Rebuild.
	* inf-ttrace.c (inf_ttrace_add_page): Likewise.
	* interps.c (interp_new): Likewise.
	* lm32-tdep.c (lm32_gdbarch_init): Likewise.
	* m32r-tdep.c (m32r_gdbarch_init): Likewise.
	* mi/mi-console.c (mi_console_file_new): Likewise.
	* mi/mi-interp.c (mi_interpreter_init): Likewise.
	* mi/mi-out.c (mi_out_new): Likewise.
	* mi/mi-parse.c (mi_parse): Likewise.
	* microblaze-tdep.c (microblaze_gdbarch_init): Likewise.
	* moxie-tdep.c (moxie_gdbarch_init): Likewise.
	* observer.c (xalloc_observer_list_node): Likewise.
	* regcache.c (regcache_xmalloc_1): Likewise.
	* reggroups.c (reggroup_new): Likewise.
	(_initialize_reggroup): Likewise.
	* registry.c (register_data_with_cleanup): Likewise.
	* remote.c (remote_notif_stop_alloc_reply): Likewise.
	* ser-base.c (serial_ttystate): Likewise.
	* ser-mingw.c (make_pipe_state): Likewise.
	* ser-pipe.c (pipe_open): Likewise.
	* serial.c (serial_open): Likewise.
	* sh64-tdep.c (sh64_gdbarch_init): Likewise.
	* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
	(tui_alloc_win_info): Likewise.
	(tui_add_content_elements): Likewise.
	* tui/tui-file.c (tui_file_new): Likewise.
	* tui/tui-out.c (tui_out_new): Likewise.
	* ui-file.c (mem_file_new): Likewise.
	* ui-out.c (push_level): Likewise.
	(make_cleanup_ui_out_end): Likewise.
	(append_header_to_list): Likewise.
	(ui_out_new): Likewise.
	* user-regs.c (user_reg_add_builtin): Likewise.
2014-01-13 07:31:28 -07:00
Tom Tromey 41bf6acad7 replace XZALLOC with XCNEW
This replaces XZALLOC with XCNEW and removes XZALLOC.
This change is purely mechanical.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* defs.h (XZALLOC): Remove.
	* ada-lang.c (get_ada_inferior_data): Use XCNEW, not XZALLOC.
	* ada-tasks.c (get_ada_tasks_pspace_data): Likewise.
	(get_ada_tasks_inferior_data): Likewise.
	* auto-load.c (get_auto_load_pspace_data): Likewise.
	* auxv.c (get_auxv_inferior_data): Likewise.
	* bfd-target.c (target_bfd_reopen): Likewise.
	* breakpoint.c (get_catch_syscall_inferior_data): Likewise.
	(deprecated_insert_raw_breakpoint): Likewise.
	* bsd-uthread.c (bsd_uthread_pid_to_str): Likewise.
	* corelow.c (core_open): Likewise.
	* darwin-nat.c (darwin_check_new_threads): Likewise.
	(darwin_attach_pid): Likewise.
	* dummy-frame.c (dummy_frame_push): Likewise.
	* dwarf2-frame.c (dwarf2_frame_cache): Likewise.
	* dwarf2loc.c (allocate_piece_closure): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	* eval.c (ptrmath_type_p): Likewise.
	* exceptions.c (EXCEPTIONS_SIGJMP_BUF): Likewise.
	* gdbtypes.c (alloc_type_arch): Likewise.
	(alloc_type_instance): Likewise.
	* hppa-tdep.c (hppa_gdbarch_init): Likewise.
	* inf-child.c (inf_child_can_use_agent): Likewise.
	* inflow.c (get_inflow_inferior_data): Likewise.
	* infrun.c (save_infcall_suspend_state): Likewise.
	* jit.c (jit_reader_load): Likewise.
	(get_jit_objfile_data): Likewise.
	(get_jit_program_space_data): Likewise.
	(jit_object_open_impl): Likewise.
	(jit_symtab_open_impl): Likewise.
	(jit_block_open_impl): Likewise.
	(jit_frame_sniffer): Likewise.
	* linux-fork.c (add_fork): Likewise.
	* maint.c (make_command_stats_cleanup): Likewise.
	* objfiles.c (get_objfile_pspace_data): Likewise.
	* opencl-lang.c (struct lval_closure): Likewise.
	* osdata.c (osdata_start_osdata): Likewise.
	* progspace.c (new_address_space): Likewise.
	(add_program_space): Likewise.
	* remote-sim.c (get_sim_inferior_data): Likewise.
	* sh-tdep.c (sh_gdbarch_init): Likewise.
	* skip.c (Ignore): Likewise.
	(skip_delete_command): Likewise.
	* solib-aix.c (get_solib_aix_inferior_data): Likewise.
	(library_list_start_library): Likewise.
	(solib_aix_current_sos): Likewise.
	* solib-darwin.c (get_darwin_info): Likewise.
	(darwin_current_sos): Likewise.
	* solib-dsbt.c (get_dsbt_info): Likewise.
	* solib-ia64-hpux.c (new_so_list): Likewise.
	(ia64_hpux_get_solib_linkage_addr): Likewise.
	* solib-spu.c (append_ocl_sos): Likewise.
	(spu_current_sos): Likewise.
	* solib-svr4.c (get_svr4_info): Likewise.
	(svr4_keep_data_in_core): Likewise.
	(library_list_start_library): Likewise.
	(svr4_default_sos): Likewise.
	(svr4_read_so_list): Likewise.
	* solib-target.c (library_list_start_library): Likewise.
	(solib_target_current_sos): Likewise.
	* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
	* symfile-debug.c (install_symfile_debug_logging): Likewise.
	* symfile.c (default_symfile_segments): Likewise.
	* target-descriptions.c (tdesc_data_init): Likewise.
	(tdesc_create_reg): Likewise.
	(struct tdesc_type *): Likewise.
	(tdesc_create_vector): Likewise.
	(tdesc_set_struct_size): Likewise.
	(struct tdesc_type *): Likewise.
	(tdesc_free_feature): Likewise.
	(tdesc_create_feature): Likewise.
	* windows-nat.c (windows_add_thread): Likewise.
	(windows_make_so): Likewise.
	* xml-support.c (gdb_xml_body_text): Likewise.
	(gdb_xml_create_parser_and_cleanup): Likewise.
	(xml_process_xincludes): Likewise.
	* xml-syscall.c (allocate_syscalls_info): Likewise.
	(syscall_create_syscall_desc): Likewise.
2014-01-13 07:31:27 -07:00
Sergio Durigan Junior 5acfdbae5d Split i386_stap_parse_special_token into smaller functions
This patch reorganizes code on gdb/i386-tdep.c's SystemTap SDT probe
support functions.  Before it, the code to parse special operands on x86
lived in a single, big function.  This patch creates 2 new functions
that makes the code more organized and removes a few indentation levels
(which is always good IMO).

I haven't modified anything logical in the functions, i.e., there's still
one latent bug on i386_stap_parse_special_token_triplet now.  I will soon
post a patch to fix this, and to also improve the readability of the two
new functions.

2014-01-12  Sergio Durigan Junior  <sergiodj@redhat.com>

	* i386-tdep.c (i386_stap_parse_special_token_triplet): New
	function, with code from i386_stap_parse_special_token.
	(i386_stap_parse_special_token_three_arg_disp): Likewise.
	(i386_stap_parse_special_token): Move code to the two functions
	above; simplify it.
2014-01-12 01:32:26 -02:00
Pedro Alves 41ef2965ab [doc] Mention that "set environment" affects the shell too.
gdb/doc/
2014-01-10  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Your Program's Environment) <set environment>:
	Mention the shell, and point at 'set exec-wrapper'.
2014-01-10 15:46:59 +00:00
Andreas Arnez 52d7fb1303 Since upstream gcc has recently increased the function alignment on
S390, the dw2-dir-file-name test case fails in the first
gdb_continue_to_breakpoint.  Indeed, the breakpoint is now placed into
the alignment gap *before* the actual function.

This happens because the test case declares the respective "*_start"
symbol as a "loose" label before the function definition, and the
compiler inserts the alignment between that label and the function
itself.

The "*_start" symbols were only necessary because FUNC made the
function static.  The fix makes the functions extern instead, thus
making the "*_start" labels unnecessary.

testsuite/
2014-01-10  Andreas Arnez  <arnez@linux.vnet.ibm.com>
	    Pedro Alves <palves@redhat.com>

	* gdb.dwarf2/dw2-dir-file-name.c (FUNC): Remove "*_start" symbol.
	Make "name" extern.
	* gdb.dwarf2/dw2-dir-file-name.exp (out_cu, out_line): Replace
	references to ${name}_start by references to ${name}.
2014-01-10 15:37:36 +00:00
Joel Brobecker a2cd8cfed1 Remove path from gdb.ada/pp-rec-component.exp "source" test
gdb/testsuite/ChangeLog:

	* gdb.ada/pp-rec-component.exp: Remove path from "source" test.
2014-01-10 07:57:11 +04:00
Joel Brobecker 4e23fced81 Remove path from gdb.python/py-pp-integral.exp "source" test.
gdb/testsuite/ChangeLog:

	* gdb.python/py-pp-integral.exp: Remove path from "source" test.
2014-01-10 07:57:09 +04:00
Pedro Alves c6a9e42ce4 gdb.mi/mi-info-os.exp: Fix cross-debugger testing
A live target is required for `-info-os' to work in non-native
configurations.

 (gdb)
 Expecting: ^(-info-os[
 ]+)?(.*\^done,OSDataTable=.*[
 ]+[(]gdb[)]
 [ ]*)
 -info-os
 ^error,msg="Don't know how to get OS data.  Try \"help target\"."
 (gdb)
 FAIL: gdb.mi/mi-info-os.exp: -info-os

If GDB does have a native configuration included, but we're testing
remote, it'll be worse, as if we're not connected yet, -info-os will
run against the default run target, and pass, falsely giving the
impression the remote bits were exercised.

gdb/testsuite/
2014-01-09  Maciej W. Rozycki  <macro@codesourcery.com>
	    Pedro Alves  <palves@redhat.com>

	* gdb.mi/mi-info-os.exp: Connect to the target with
        mi_gdb_target_load.
2014-01-09 19:57:13 +00:00
Pedro Alves 0000e5ccd8 Handle the case of a remote target supporting target side commands, but not on software breakpoints.
Although we can tell upfront whether a remote target supports target
side commands, we can only tell whether the target supports that in
combination with a given breakpoint kind (software, hardware,
watchpoints, etc.) when we go and try to insert such a breakpoint kind
the first time.  It's not desirable to make remote_insert_breakpoint
simply return -1 in this case, because if the breakpoint was set in a
shared library, insert_bp_location will assume that the breakpoint
insertion failed because the library wasn't mapped in.

insert_bp_location already handles errors/exceptions thrown from the
target_insert_xxx methods, exactly so the backend can tell the user
the detailed reason the insertion of hw breakpoints failed.  But, in
the case of software breakpoints, it discards the detailed error
message.

So the patch makes insert_bp_location use the error's message for SW
breakpoints too, and, introduces a NOT_SUPPORTED_ERROR error code so
that insert_bp_location doesn't confuse the error for failure due to a
shared library disappearing.

The result is:

(gdb) c
Warning:
Cannot insert breakpoint 2: Target doesn't support breakpoints that have target side commands.

2014-01-09  Pedro Alves  <palves@redhat.com>
	    Hui Zhu  <hui@codesourcery.com>

	PR gdb/16101
	* breakpoint.c (insert_bp_location): Rename hw_bp_err_string to
	bp_err_string.  Don't mark the location shlib_disabled if the
	error thrown wasn't a generic or memory error.  Catch errors
	thrown while inserting breakpoints in overlayed code.  Output
	error message of software breakpoints.
	* remote.c (remote_insert_breakpoint): If this breakpoint has
	target-side commands but this stub doesn't support Z0 packets,
	throw NOT_SUPPORTED_ERROR error.
	* exceptions.h (enum errors) <NOT_SUPPORTED_ERROR>: New error.
	* target.h (target_insert_breakpoint): Extend comment.
	(target_insert_hw_breakpoint): Add comment.
2014-01-09 18:33:45 +00:00
Pedro Alves 9939e1314f GDBserver: Discard previous queued events when GDB disconnects.
... not when a new GDB connection sends the status packet ('?').
Mainly just a cleanup/simplification, as GDB always sends '?' first.

Tested on x86_64 Fedora 17.

2014-01-08  Pedro Alves  <palves@redhat.com>

	* server.c (handle_status): Don't discard previous queued stop
	replies or thread's pending status here.
	(main) <disconnection>: Do it here instead.
2014-01-08 20:34:26 +00:00
Pedro Alves b7ea362b02 [remote/gdbserver] Don't lose signals when reconnecting.
Currently, when GDB connects in all-stop mode, GDBserver always
responds to the status packet with a GDB_SIGNAL_TRAP, even if the
program is actually stopped for some other signal.

 (gdb) tar rem ...
 ...
 (gdb) c
 Program received signal SIGUSR1, User defined signal 1.
 (gdb) disconnect
 (gdb) tar rem ...
 (gdb) c

(Or a GDB crash instead of an explicit disconnect.)

This results in the program losing that signal on that last continue,
because gdb will tell the target to resume with no signal (to suppress
the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will
actually suppress the real signal the program had stopped for
(SIGUSR1).  To fix that, I think we should make GDBserver report the
real signal the thread had stopped for in response to the status
packet:

 @item ?
 @cindex @samp{?} packet
 Indicate the reason the target halted.  The reply is the same as for
 step and continue.

But, that raises the question -- which thread are we reporting the
status for?  Due to how the RSP in all-stop works, we can only report
one status.  The status packet's response is a stop reply packet, so
it includes the thread identifier, so it's not a problem packet-wise.
However, GDBserver is currently always reporting the status for first
thread in the thread list, even though that may well not be the thread
that got the signal that caused the program to stop.  So the next
logical step would be to report the status for the
last_ptid/last_status thread (the last event reported to gdb), if it's
still around; and if not, fallback to some other thread.

There's an issue on the GDB side with that, though...

GDB currently always adds the thread reported in response to the
status query as the first thread in its list.  That means that if we
start with e.g.,

 (gdb) info threads
   3 Thread 1003 ...
 * 2 Thread 1002 ...
   1 Thread 1001 ...

And reconnect:

 (gdb) disconnect
 (gdb) tar rem ...

We end up with:

 (gdb) info threads
   3 Thread 1003 ...
   2 Thread 1001 ...
 * 1 Thread 1002 ...

Not a real big issue, but it's reasonably fixable, by having GDB
fetch/sync the thread list before fetching the status/'?', and then
using the status to select the right thread as current on the GDB
side.  Holes in the thread numbers are squashed before/after
reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved,
which I think is both good, and good enough.

However (yes, there's more...), the previous GDB that was connected
might have had gdbserver running in non-stop mode, or could have left
gdbserver doing disconnected tracing (which also forces non-stop), and
if the new gdb/connection is in all-stop mode, we can end up with more
than one thread with a signal to report back to gdb.  As we can only
report one thread/status (in the all-stop RSP variant; the non-stop
variant doesn't have this issue), we get to do what we do at every
other place we have this situation -- leave events we can't report
right now as pending, so that the next resume picks them up.

Note all this ammounts to a QoI change, within the existing framework.
There's really no RSP change here.

The only user visible change (other than that the signal is program is
stopped at isn't lost / is passed to the program), is in "info
program", that now can show the signal the program stopped for.  Of
course, the next resume will respect the pass/nopass setting for the
signal in question.  It'd be reasonable to have the initial connection
tell the user the program was stopped with a signal, similar to when
we load a core to debug, but I'm leaving that out for a future change.
I think we'll need to either change how handle_inferior_event & co
handle stop_soon, or maybe bypass them completely (like
fork-child.c:startup_inferior) for that.

Tested on x86_64 Fedora 17.

gdb/gdbserver/
2014-01-08  Pedro Alves  <palves@redhat.com>

	* gdbthread.h (struct thread_info) <status_pending_p>: New field.
	* server.c (visit_actioned_threads, handle_pending_status): New
	function.
	(handle_v_cont): Factor out parts to ...
	(resume): ... this new function.  If in all-stop, and a thread
	being resumed has a pending status, report it without actually
	resuming.
	(myresume): Adjust to use the new 'resume' function.
	(clear_pending_status_callback, set_pending_status_callback)
	(find_status_pending_thread_callback): New functions.
	(handle_status): Handle the case of multiple threads having
	interesting statuses to report.  Report threads' real last signal
	instead of always reporting GDB_SIGNAL_TRAP.  Look for a thread
	with an interesting thread to report the status for, instead of
	always reporting the status of the first thread.

gdb/
2014-01-08  Pedro Alves  <palves@redhat.com>

	* remote.c (remote_add_thread): Add threads silently if starting
	up.
	(remote_notice_new_inferior): If in all-stop, and starting up,
	don't call notice_new_inferior.
	(get_current_thread): New function, factored out from ...
	(add_current_inferior_and_thread): ... this.  Adjust.
	(remote_start_remote) <all-stop>: Fetch the thread list.  If we
	found any thread, then select the remote's current thread as GDB's
	current thread too.

gdb/testsuite/
2014-01-08  Pedro Alves  <palves@redhat.com>

	* gdb.threads/reconnect-signal.c: New file.
	* gdb.threads/reconnect-signal.exp: New file.
2014-01-08 18:55:51 +00:00
Joel Brobecker b7bba00155 Update NEWS post GDB 7.7 branch creation.
gdb/ChangeLog:

	* NEWS: Create a new section for the next release branch.
	Rename the section of the current branch, now that it has
	been cut.
2014-01-08 13:41:03 +04:00
Joel Brobecker 16dfbded4c Bump version to 7.7.50.DATE-cvs.
Now that the GDB 7.7 branch has been created, we can
bump the version number.

gdb/ChangeLog:

	GDB 7.7 branch created (79301218fa):
	* version.in: Bump version to 7.7.50.DATE-cvs.
2014-01-08 13:25:28 +04:00
Joel Brobecker 79301218fa Add missing ChangeLog entries. 2014-01-08 13:16:32 +04:00
Yao Qi 22c90ac1cd Fix pointer assignment with different signedness
This patch fixes these errors below:

../../binutils-gdb/gdb/spu-linux-nat.c: In function ‘spu_symbol_file_add_from_memory’:
../../binutils-gdb/gdb/spu-linux-nat.c:368:3: error: pointer targets in passing argument 2 of ‘spu_proc_xfer_spu’ differ in signedness [-Werror=pointer-sign]
../../binutils-gdb/gdb/spu-linux-nat.c:232:1: note: expected ‘gdb_byte *’ but argument is of type ‘char *’
../../binutils-gdb/gdb/spu-linux-nat.c: In function ‘spu_xfer_partial’:
../../binutils-gdb/gdb/spu-linux-nat.c:598:7: error: pointer targets in passing argument 1 of ‘strtoulst’ differ in signedness [-Werror=pointer-sign]
In file included from ../../binutils-gdb/gdb/defs.h:769:0,
                 from ../../binutils-gdb/gdb/spu-linux-nat.c:21:
../../binutils-gdb/gdb/utils.h:43:15: note: expected ‘const char *’ but argument is of type ‘gdb_byte *’

gdb:

2014-01-08  Yao Qi  <yao@codesourcery.com>

	* spu-linux-nat.c (spu_symbol_file_add_from_memory): Change
	type of 'id' to gdb_byte.  Cast 'id' to 'const char *'.
	(spu_xfer_partial): Cast 'buf' to 'const char *'.
2014-01-08 10:44:32 +08:00
Yao Qi d64ad97c6b Pass name to symbol_file_add_from_bfd
This patch fixes the following build error:

../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: passing argument 2 of ‘symbol_file_add_from_bfd’ makes pointer from integer without a cast [-Werror]
In file included from ../../binutils-gdb/gdb/spu-linux-nat.c:29:0:
../../binutils-gdb/gdb/symfile.h:444:24: note: expected ‘const char *’ but argument is of type ‘int’
../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: passing argument 3 of ‘symbol_file_add_from_bfd’ makes integer from pointer without a cast [-Werror]
In file included from ../../binutils-gdb/gdb/spu-linux-nat.c:29:0:
../../binutils-gdb/gdb/symfile.h:444:24: note: expected ‘int’ but argument is of type ‘void *’
../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: passing argument 5 of ‘symbol_file_add_from_bfd’ makes integer from pointer without a cast [-Werror]
In file included from ../../binutils-gdb/gdb/spu-linux-nat.c:29:0:
../../binutils-gdb/gdb/symfile.h:444:24: note: expected ‘int’ but argument is of type ‘void *’
../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: too few arguments to function ‘symbol_file_add_from_bfd’

Argument 'name' was added to function symbol_file_add_from_bfd by this patch

  [patchv4 4/5] Keep objfile original filename
  https://sourceware.org/ml/gdb-patches/2013-09/msg00683.html

but caller of symbol_file_add_from_bfd in spu-linux-nat.c wasn't updated.

This patch fixes the build error.

gdb:

2014-01-08  Yao Qi  <yao@codesourcery.com>

	* spu-linux-nat.c (spu_symbol_file_add_from_memory): Pass
	return value of bfd_get_filename to symbol_file_add_from_bfd.
2014-01-08 10:44:20 +08:00
Pierre Muller f93ba80c98 Fix PR16201.
* coff-pe-read.c (struct read_pe_section_data): Add index field.
	(add_pe_exported_sym): Use SECTION_DATA->INDEX for call
	to prim_record_mininal_symbol_and_info.
	(add_pe_forwarded_sym): Use known section number of forwarded symbol
	in call to prim_record_minimal_symbol_and_info.
	(read_pe_exported_syms): Set index field of section_data.
2014-01-08 00:31:50 +01:00
Andrew Pinski a4d9ba85ec AARCH64: Change cpsr type to be 64bit.
2013-12-18  Andrew Pinski  <apinski@cavium.com>

	* features/aarch64-core.xml (cpsr): Change to be 64bit.
	* features/aarch64.c: Regenerate.
2014-01-07 14:31:55 -08:00
Andreas Schwab 1b67eb0273 Use correct default for target functions that return pointer
* target.c (return_null): Define.
	(update_current_target): Use it instead of return_zero for
	functions that return a pointer.
2014-01-07 22:58:31 +01:00
Edjunior Barbosa Machado 5e3f4fab9a Fix dir command for duplicated paths and add a new testcase.
gdb/ChangeLog:
2014-01-07  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

	* source.c (add_path): Fix check for duplicated paths in the previously
	included paths.

gdb/testsuite/ChangeLog:
2014-01-07  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.base/source-dir.exp: New file.
2014-01-07 17:03:06 -02:00
Honggyu Kim e261678878 Remove duplicated #include's from GDB
This patch simply removes duplicated #include statements in the gdb/
directory.  If there are two duplicated #include statements, this patch
keeps the first #include and removes the second.

Those duplicates have been found by using the checkincludes.pl tool from
the Linux kernel and double checked manually once again if the #include
statements are affected by #ifdef macros.

2014-01-06  Honggyu Kim  <hong.gyu.kim@lge.com>

	* ada-lang.c: Remove duplicated include statements.
	* alphabsd-nat.c: Ditto.
	* amd64-darwin-tdep.c: Ditto.
	* amd64fbsd-nat.c: Ditto.
	* auto-load.c: Ditto.
	* ax-gdb.c: Ditto.
	* breakpoint.c: Ditto.
	* dbxread.c: Ditto.
	* fork-child.c: Ditto.
	* gdb_usleep.c: Ditto.
	* i386-darwin-tdep.c: Ditto.
	* i386fbsd-nat.c: Ditto.
	* infcmd.c: Ditto.
	* inferior.c: Ditto.
	* jv-lang.c: Ditto.
	* linux-nat.c: Ditto.
	* linux-tdep.c: Ditto.
	* m68kbsd-nat.c: Ditto.
	* m68klinux-nat.c: Ditto.
	* microblaze-tdep.c: Ditto.
	* mips-linux-tdep.c: Ditto.
	* mn10300-tdep.c: Ditto.
	* nto-tdep.c: Ditto.
	* opencl-lang.c: Ditto.
	* osdata.c: Ditto.
	* printcmd.c: Ditto.
	* regcache.c: Ditto.
	* remote-m32r-sdi.c: Ditto.
	* remote.c: Ditto.
	* symfile.c: Ditto.
	* symtab.c: Ditto.
	* tilegx-linux-nat.c: Ditto.
	* tilegx-tdep.c: Ditto.
	* tracepoint.c: Ditto.
	* valops.c: Ditto.
	* vaxbsd-nat.c: Ditto.
	* windows-nat.c: Ditto.
	* xtensa-tdep.c: Ditto.
2014-01-07 14:14:30 -02:00
Yao Qi bd1f77885b Fix missing-prototypes error for '_initialize_spu_nat'
This patch fixes this build error below:

../../binutils-gdb/gdb/spu-linux-nat.c:616:1: error: no previous prototype for ‘_initialize_spu_nat’ [-Werror=missing-prototypes]

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* spu-linux-nat.c (_initialize_spu_nat): Declare.
2014-01-07 21:47:14 +08:00
Yao Qi 3b631e3720 Cast to uintptr_t when calling ptrace32 on aix
When I verify my changes to target.h doesn't break build on aix, I get
the following build error on a clean GDB checkout.

../../binutils-gdb/gdb/aix-thread.c: In function 'pdc_read_regs':
../../binutils-gdb/gdb/aix-thread.c:366:4: error: passing argument 3 of 'ptrace32' makes integer from pointer without a cast [-Werror]
    if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
    ^
../../binutils-gdb/gdb/aix-thread.c:263:1: note: expected 'long long int' but argument is of type 'uint32_t *'
 ptrace32 (int req, int id, addr_ptr addr, int data, int *buf)
 ^

../../binutils-gdb/gdb/aix-thread.c:375:42: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
       if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
                                          ^

../../binutils-gdb/gdb/aix-thread.c:392:39: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
    if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))

GCC uses -maix32 in default, so the 'long long' is 64 bit and address
is 32 bit.  Such warnings should go away if -maix64 is used.

In this patch, I cast the parameter to uintptr_t first, and then cast
to addr_ptr.

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>
	    Joel Brobecker  <brobecker@adacore.com>

	* aix-thread.c (pdc_read_regs): Cast parameter to uintptr_t.
	(pdc_write_regs): Likewise.
	(fetch_regs_kernel_thread): Likewise.
	(store_regs_kernel_thread): Likewise.
2014-01-07 14:29:25 +04:00
Joel Brobecker f30b8b38d4 varobj/Ada: Missing children for interface-wide tagged types
Consider the following code:

   type Element is abstract tagged null record;
   type GADataType is interface;
   type Data_Type is new Element and GADataType with record
      I : Integer := 42;
   end record;
   Result1 : Data_Type;
   GGG1    : GADataType'Class := GADataType'Class (Result1);

When trying to create a varobj for variable ggg1, GDB currently
returns an object which has no child:

    -var-create ggg1 * ggg1
    ^done,name="ggg1",numchild="0",[...]

This is incorrect, it should return an object which has one child
(field "i"). This is because tagged-type objects are dynamic, and
we need to apply a small transformation in order to get their actual
type. This is already done on the GDB/CLI side in ada-valprint,
and it needs to be done on the ada-varobj side as well.

gdb/ChangeLog:

        * ada-varobj.c (ada_varobj_adjust_for_child_access): Convert
        tagged type objects to their actual type.

gdb/testsuite/ChangeLog:

        * gdb.ada/mi_interface: New testcase.
2014-01-07 08:29:04 +04:00
Joel Brobecker 8e355c5d24 Ada: Fix missing call to pretty-printer for fields of records.
Consider the following types:

   type Time_T is record
      Secs : Integer;
   end record;
   Before : Time_T := (Secs => 1384395743);

In this example, we assume that type Time_T is the number of seconds
since Epoch, and so added a Python pretty-printer, to print this
type in a more human-friendly way. For instance:

    (gdb) print before
    $1 = Thu Nov 14 02:22:23 2013 (1384395743)

However, we've noticed that things stop working when this type is
embedded inside another record, and we try to print that record.
For instance, with the following declarations:

   type Composite is record
      Id : Integer;
      T : Time_T;
   end record;
   Afternoon : Composite := (Id => 1, T => (Secs => 1384395865));

    (gdb) print afternoon
    $2 = (id => 1, t => (secs => 1384395865))

We expected instead:

    (gdb) print afternoon
    $2 = (id => 1, t => Thu Nov 14 02:24:25 2013 (1384395865))

This patch fixes the problem by making sure that we try to print
each field via a call to val_print, rather than calling ada_val_print
directly. We need to go through val_print, as the val_print
handles all language-independent features such as calling the
pretty-printer, knowing that ada_val_print will get called eventually
if actual Ada-specific printing is required (which should be the
most common scenario).

And because val_print takes the language as parameter, we enhanced
the print_field_values and print_variant_part to also take a language.
As a bonus, this allows us to remove a couple of references to
current_language.

gdb/ChangeLog:

        * ada-valprint.c (print_field_values): Add "language" parameter.
        Update calls to print_field_values and print_variant_part.
        Pass new parameter "language" in call to val_print instead
        of "current_language".  Replace call to ada_val_print by call
        to val_print.
        (print_variant_part): Add "language" parameter.
        (ada_val_print_struct_union): Update call to print_field_values.

gdb/testsuite/ChangeLog:

        * gdb.ada/pp-rec-component.exp, gdb.ada/pp-rec-component.py,
        gdb.ada/pp-rec-component/foo.adb, gdb.ada/pp-rec-component/pck.adb,
        gdb.ada/pp-rec-component/pck.ads: New files.
2014-01-07 08:17:40 +04:00
Joel Brobecker 4fbf5aa5f4 ada_print_floating: Remove use of statically sized buffer.
ada_print_floating declares a char buffer with a size that we're hoping
to always be large enough to hold any string representation of a float
value.  But that's not really necessary, and also forces us to create
a small wrapper (ui_memcpy) to perform the extraction from a temporary
stream into this buffer.  This patches fixes both issues by relying on
ui_file_xstrdup.  This forces us to make a few adjustments that are
minor in nature, as we now need to defer the cleanup to the end of
the function.

gdb/ChangeLog:

        * ada-valprint.c (ui_memcpy): Delete.
        (ada_print_floating): Update documentation.  Add empty line
        between between function documentation and implementation.
        Delete variable "buffer".  Use ui_file_xstrdup in place of
        ui_file_put.  Minor adjustments following this change.
2014-01-07 08:17:40 +04:00
Joel Brobecker 71855601a5 Extract string-printing out of ada_val_print_array
This patch creates a new function called "ada_val_print_string"
whose code is directly extracted out of ada_val_print_array.
The extracted code is then replaced by a call to this new function,
followed by a "return". The return avoids the need for an "else"
branch, with the associated block nesting. The latter is not really
terrible in this case, but it seems more readable this way.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_string): New function,
        extracted from ada_val_print_array.
        (ada_val_print_array): Replace extracted code by call
        to ada_val_print_string followed by a return.  Move
        "else" branch to the function's top block.
2014-01-07 08:17:39 +04:00
Joel Brobecker 4eb27a304c move ada_val_print_array down within other ada_val_print* functions
This patch moves ada_val_print_array to group it with the other
ada_val_print_* function which are being called by ada_val_print_1.
Since this function is in the same situation, it is more logical
to move it within that group.

It also rationalizes the function's prototype to match the prototype
of the other ada_val_print_* routines.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_array): Move implementation
        down.  Rename parameter "offset" and "val" into "offset_aligned"
        and "original_value" respectively.  Add parameter "offset".
2014-01-07 08:17:39 +04:00
Joel Brobecker 34b2795054 rewrite ada_val_print_ref to reduce if/else block nesting depth
The logic as currently implemented in this function was a little
difficult to follow, due to the nested of if/else conditions,
but most of the time, the "else" block was very simple. So this
patch re-organizes the code to use fewer levels of nesting by
using return statements, and writing the code as a sequence of
"if something simple, then handle it and return" blocks.

While touching this code, this patch changes the cryptic "???"
printed when trying to print a reference pointing to an undefined
type. This should only ever happen if the debugging information
was corrupted or improperly read. But in case that happens, we now
print "<ref to undefined type>" instead. This is more in line
with how we print other conditions such as optimized out pieces,
or synthetic pointers.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_ref): Rewrite by mostly
        re-organizing the code. Change the "???" message printed
        when target type is a TYPE_CODE_UNDEF into
        "<ref to undefined type>".
2014-01-07 08:17:39 +04:00
Joel Brobecker 079e459161 ada-valprint.c: Inline print_record inside ada_val_print_struct_union
The function print_record is a fairly small and straightforward
function which is only called from one location. So this patch
inlines the code at the point of call.

One small advantage is that the context of use of this patch has
now become such that we can assume that TYPE is not a typedef,
nor an enum. So thhe call to ada_check_typedef is unnecessary,
and this patch removes it.

gdb/ChangeLog:

        * ada-valprint.c (print_record): Delete, implementation inlined...
        (ada_val_print_struct_union): ... here.  Remove call to
        ada_check_typedef in inlined implementation.
2014-01-07 08:17:39 +04:00
Joel Brobecker 8004dfd1cf Split ada_val_print_1 into smaller functions
The idea of this patch is that it's hard to have a global view of
ada_val_print_1 because its body spans over too many lines. Also,
each individual "case" block within the giant "switch" can be hard
to isolate if spanning over multiple pages as well.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_gnat_array): New function,
        extracted from ada_val_print_1;
        (ada_val_print_ptr, ada_val_print_num, ada_val_print_enum)
        (ada_val_print_flt, ada_val_print_struct_union)
        (ada_val_print_ref): Likewise.
        (ada_val_print_1): Delete variables i and elttype.
        Replace extracted-out code by call to corresponding
        new functions.
2014-01-07 08:17:38 +04:00
Joel Brobecker 760a2db02f Remove call to gdb_flush at end of ada_val_print_1
I am not sure why this function was called in the first place, but
it disrupts the printing flow when in GDB/MI mode, ending the current
console stream output, and starting a new one. It's not clear whether,
with the code as currently written, the problem is actually visible
or only latent. But, it becomes visible when we replace one of the
"return" statements in the "switch" block just above by a "break"
statement (this is something I'd like to do, and what made me realize
the problem). With the gdb_flush call (after having replaced the
"return" statement as explained above), we get:

        % gdb -q -i=mi ada_prg
        (gdb)
        print 1
        &"print 1\n"
  !! -> ~"$1 = 1"
  !! -> ~"\n"
        ^done

With the gdb_flush call removed, we now get the entire output into
a single stream.

        (gdb)
        print 1
        &"print 1\n"
        ~"$1 = 1"
        ~"\n"
        ^done

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_1): Remove call to gdb_flush.
2014-01-07 08:17:38 +04:00
Joel Brobecker 3a92c861bb ada_val_print_1: Go through val_print instead of recursive call to self.
This is to standardize a little bit how printing is done, and in
particular make sure that everyone goes through val_print when
printing sub-objects.  This helps making sure that standard features
handled by val_print get activated when expected.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_1): Replace calls to
        ada_val_print_1 by calls to val_print.
2014-01-07 08:17:38 +04:00
Joel Brobecker cd1630f983 ada_val_print_1: Add language parameter
This is to help calling val_print.  We would like to be more systematic
in calling val_print when printing, because it allows us to make sure
we take advantage of the standard features such as pretty-printing
which are handled by val_print.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_1): Add parameter "language".
        Update calls to self accordingly.  Replace calls to c_val_print
        by calls to val_print.
2014-01-07 08:17:38 +04:00
Joel Brobecker bdf779a0c5 ada-valprint.c: Reorder functions to reduce advance declarations.
Advance function declarations add to the maintenance cost, since
any update to the function prototype needs to be made twice.
For static functions, this is not necessary, and this patch
reorders the function so as to reduce the use of such advanche
declarations.

gdb/ChangeLog:

        * ada-valprint.c (print_record): Delete declaration.
        (adjust_type_signedness, ada_val_print_1): Likewise.
        (ada_val_print): Move function implementation down.
        (print_variant_part, print_field_values, print_record):
        Move function implementation up.
2014-01-07 08:17:37 +04:00
Joel Brobecker c0d4881122 [python] Add gdb.Type.name attribute.
Consider the following declarations:

    typedef long our_time_t;
    our_time_t current_time = 1384395743;

The purpose of this patch is to allow the use of a pretty-printer
for variables of type our_time_t.  Normally, pretty-printing sniffers
use the tag name in order to determine which, if any, pretty-printer
should be used. But in the case above, the tag name is not set, since
it does not apply to integral types.

This patch extends the gdb.Type list of attributes to also include
the name of the type, thus allowing the sniffer to match against
that name. With that change, I was able to write a pretty-printer
which displays our variable as follow:

    (gdb) print current_time
    $1 = Thu Nov 14 02:22:23 2013 (1384395743)

gdb/ChangeLog:

        * python/py-type.c (typy_get_name): New function.
        (type_object_getset): Add entry for attribute "name".
        * NEWS: Add entry mentioning this new attribute.

gdb/doc/ChangeLog:

        * gdb.texinfo (Types In Python): Document new attribute Types.name.

gdb/testsuite:

        * gdb.python/py-pp-integral.c: New file.
        * gdb.python/py-pp-integral.py: New file.
        * gdb.python/py-pp-integral.exp: New file.

Tested on x86_64-linux.
2014-01-07 07:11:17 +04:00
Yao Qi c26e9cbb0c Remove an empty-body 'if' statement
This patch removes the if statement and the comments together.

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (set_exceptions_cmd): Remove an empty body 'if'
	statement.
2014-01-07 11:01:55 +08:00
Yao Qi 0cc6f43dae Add qualifier 'const' to argument args
This patch fixes the following error.

../../../git/gdb/gnu-nat.c: In function 'info_port_rights':
../../../git/gdb/gnu-nat.c:3083:11: error: passing argument 1 of 'parse_to_comma_and_eval' from incompatible pointer type [-Werror]
In file included from ../../../git/gdb/breakpoint.h:23:0,
                 from ../../../git/gdb/inferior.h:37,
                 from ../../../git/gdb/gnu-nat.c:55:
../../../git/gdb/value.h:763:22: note: expected 'const char **' but argument is of type 'char **'

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (info_port_rights): Add qualifier const to
	argument args.
2014-01-07 11:01:48 +08:00
Yao Qi eec03155c2 Use void for empty argument list in trace_me
This patch fixes the following error:

../../../git/gdb/gnu-nat.c: In function 'trace_me':
../../../git/gdb/gnu-nat.c:2106:8: error: old-style function definition [-Werror=old-style-definition]

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (trace_me): Use 'void' for empty argument list.
2014-01-07 11:01:42 +08:00
Yao Qi f04a82ef62 Make functions static.
gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (make_inf) Update declaration.
	(make_inf): Make it static.
	(inf_set_traced): Likewise.
	(inf_port_to_thread, inf_task_died_status): Likewise.
2014-01-07 11:01:37 +08:00
Yao Qi d57dda0ab3 Remove declaration of inf_tid_to_proc
inf_tid_to_proc is not defined at all.  This patch is to remove its
declaration.
gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (inf_tid_to_proc): Remove declaration.
2014-01-07 11:01:33 +08:00
Yao Qi 3aa8c9698a Fix no previous prototype for '_initialize_gnu_nat' [-Werror=missing-prototypes]
This patch fixes this error below by declaring _initialize_gnu_nat.

../../../git/gdb/gnu-nat.c:3447:1: error: no previous prototype for '_initialize_gnu_nat' [-Werror=missing-prototypes]

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (_initialize_gnu_nat): Declare.
2014-01-07 11:01:27 +08:00
Yao Qi 94123b4f91 Use enum bfd_endian in gdbarch.sh
This patch changes the return type of gdbarch_byte_order and
gdbarch_byte_order_for_code, from 'int' to 'enum bfd_endian'.

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gdbarch.sh (byte_order, byte_order_for_code): Change type to
	'enum bfd_endian'.
	(struct gdbarch_info) <byte_order>: Change type to
	'enum bfd_endian'.
	<byte_order_for_code>: Likewise.
	* gdbarch.c, gdbarch.h: Regenerated.
2014-01-07 10:28:06 +08:00
Tom Tromey dc81d70a97 fix JIT reader path creation
2014-01-06  Sasha Smundak  <asmundak@google.com>

	* jit.c: (jit_reader_load_command): Fix JIT reader path creation.
2014-01-06 14:57:59 -07:00
Tom Tromey cc2f3c3582 convert CONST to const
This removes the last uses of the obsolete CONST macro from the tree.
I'm checking this in.  Tested by rebuilding.

2014-01-06  Tom Tromey  <tromey@redhat.com>

	* doublest.c (convert_doublest_to_floatformat): Use const, not
	CONST.
	* somread.c (som_symtab_read): Likewise.
2014-01-06 12:06:40 -07:00
Hui Zhu 78f47043ff Fix a error of my previous commit. 2014-01-07 00:28:55 +08:00
Hui Zhu adcf2eed05 Remove gdb_bfd_stash_filename to fix crash with fix of binutils/11983
https://sourceware.org/ml/gdb-patches/2014-01/msg00029.html
https://sourceware.org/ml/gdb-patches/2014-01/msg00053.html

2014-01-07  Hui Zhu  <hui@codesourcery.com>

	* gdb_bfd.c (gdb_bfd_stash_filename): Removed.
	(gdb_bfd_open): Removed gdb_bfd_stash_filename.
	(gdb_bfd_fopen): Ditto.
	(gdb_bfd_openr): Ditto.
	(gdb_bfd_openw): Ditto.
	(gdb_bfd_openr_iovec): Ditto.
	(gdb_bfd_fdopenr): Ditto.
	* gdb_bfd.h (gdb_bfd_stash_filename): Removed.
	* solib-aix.c (solib_aix_bfd_open): Alloc object_bfd->filename
	with xstrdup.
	* solib-darwin.c (darwin_bfd_open): Alloc res->filename
	with xstrdup.
	* symfile-mem.c (symbol_file_add_from_memory): Removed
	gdb_bfd_stash_filename.
2014-01-07 00:24:41 +08:00
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