Commit Graph

36661 Commits

Author SHA1 Message Date
Pedro Alves bde40b8f56 Fix gdb.server/server-exec-info.exp with the extended-remote board
This test fails with --target_board=native-extended-gdbserver because
it misses the usual "disconnect":

 (gdb) spawn ../gdbserver/gdbserver --once :2347 /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.server/server-exec-info
 Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.server/server-exec-info created; pid = 4736
 Listening on port 2347
 target extended-remote localhost:2347
 Already connected to a remote target.  Disconnect? (y or n) ^CsQuit
 (gdb) et sysroot remote:
 Undefined command: "et".  Try "help".
 (gdb) n
 The program is not being run.
 (gdb) FAIL: gdb.server/server-exec-info.exp: set sysroot remote: (got interactive prompt)
 info files
 (gdb) FAIL: gdb.server/server-exec-info.exp: info files

gdb/testsuite/ChangeLog:
2015-07-28  Pedro Alves  <palves@redhat.com>

	* gdb.server/server-exec-info.exp: Issue a "disconnect".
2015-07-28 18:04:07 +01:00
Simon Marchi 3ae385afe1 Consider addressable memory unit size in various value functions
This patch updates various value handling functions to make them
consider the addressable memory unit size of the current architecture.
This allows to correctly extract and print values on architectures whose
addressable memory unit is not 8 bits.

The patch doesn't cover all the code that would ideally need to be
adjusted, only the code paths that we happen to use, plus a few obvious
ones.  Specifically, those areas are not covered by this patch:

 - Management of unavailable bits
 - Bitfields
 - C++ stuff

Regression-tested on x86-64 Ubuntu 14.04.  I saw no related test result
change.

gdb/ChangeLog:

	* c-valprint.c (c_val_print_array): Consider addressable memory
	unit size.
	(c_val_print_ptr): Likewise.
	(c_val_print_int): Likewise.
	* findvar.c (read_frame_register_value): Likewise.
	* valarith.c (find_size_for_pointer_math): Likewise.
	(value_ptrdiff): Likewise.
	(value_subscripted_rvalue): Likewise.
	* valops.c (read_value_memory): Likewise (and rename variables).
	(value_assign): Likewise.
	(value_repeat): Likewise.
	(value_array): Likewise.
	(value_slice): Likewise.
	* valprint.c (generic_val_print_ptr): Likewise.
	(generic_val_print_enum): Likewise.
	(generic_val_print_bool): Likewise.
	(generic_val_print_int): Likewise.
	(generic_val_print_char): Likewise.
	(generic_val_print_float): Likewise.
	(generic_val_print_decfloat): Likewise.
	(generic_val_print_complex): Likewise.
	(val_print_scalar_formatted): Likewise.
	(val_print_array_elements): Likewise.
	* value.c (set_value_parent): Likewise.
	(value_contents_copy_raw): Likewise.
	(set_internalvar_component): Likewise.
	(value_primitive_field): Likewise.
	(value_fetch_lazy): Likewise.
	* value.h (read_value_memory): Update comment.
2015-07-28 11:01:50 -04:00
Simon Marchi e512cdbdff Introduce get_value_arch
Similar to get_type_arch, used to get the gdbarch associated to a
struct value.

gdb/ChangeLog:

	* value.c (get_value_arch): New function.
	* value.h (get_value_arch): New declaration.
2015-07-28 11:01:50 -04:00
Simon Marchi 3723fda829 Update comments in struct value for non-8-bits architectures
gdb/ChangeLog:

	* value.c (struct value): Update comments.
2015-07-28 11:01:49 -04:00
Simon Marchi 2e0569314c Update comment for struct type's length field, introduce type_length_units
This patch tries to clean up a bit the blur around the length field in
struct type, regarding its use with architectures with non-8-bits
addressable memory.  It clarifies that the field is expressed in host
bytes, which is what is the closest to the current reality.

It also introduces a new function to get the length of the type in
target addressable memory units.

gdb/ChangeLog:

	* gdbtypes.c (type_length_units): New function.
	* gdbtypes.h (type_length_units): New declaration.
	(struct type) <length>: Update comment.
2015-07-28 11:01:49 -04:00
Simon Marchi 13e1dec896 gdb.mi/mi-pending.c: Return NULL instead of nothing in thread function
Using gcc 5.2 (maybe other versions as well), building mi-pending.c gives
these warnings:

	./gdb.mi/mi-pending.c: In function ‘thread_func’:
	./gdb.mi/mi-pending.c:34:5: warning: ‘return’ with no value, in function returning non-void
	     return;
	     ^
	./gdb.mi/mi-pending.c:38:5: warning: ‘return’ with no value, in function returning non-void
	     return;
	     ^
gdb_compile_pthreads assumes that the build was successful only if there
is no output. These warnings therefore make gdb_compile_pthreads think
that the build failed, and the test doesn't run.

The easy fix is to replace the "return" with "return NULL".  I am
pushing this as obvious.

gdb/testsuite/ChangeLog:

	* gdb.mi/mi-pending.c (thread_func): Replace return with return
	NULL.
2015-07-27 15:49:24 -04:00
Simon Marchi da33c9a7bf Remove xfail in gdb.mi/mi-watch.exp
I noticed there was an unexpected pass in mi-watch.exp when running on
x86_64.  Doing a bit of archeology shows that the xfail was added by
4a543da.  This particular test failed on the MIPS architecture, which
the original contributor was working with.  Here is the thread:

https://www.sourceware.org/ml/gdb-patches/2007-09/msg00151.html

Looking at the latest buildbot results for MIPS, it seems that it's also
an unexpected pass on that architecture.  Therefore, I see no reason to
leave the xfail in place.

gdb/testsuite/ChangeLog:

	* gdb.mi/mi-watch.exp (test_watchpoint_triggering): Remove xfail.
2015-07-27 15:02:37 -04:00
Simon Marchi 0c87c0bfdf Factor out complex printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out complex
	printing code to ...
	(generic_val_print_complex): ... this new function.
2015-07-27 14:11:26 -04:00
Simon Marchi 9550ae5e54 Factor out decfloat printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out decfloat
	printing code to ...
	(generic_val_print_decfloat): ... this new function.
2015-07-27 14:11:25 -04:00
Simon Marchi 7784724bb1 Factor out float printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out float
	printing code to ...
	(generic_val_print_float): ... this new function.
2015-07-27 14:11:24 -04:00
Simon Marchi 385f5affc0 Factor out char printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out char
	printing code to ...
	(generic_val_print_char): ... this new function.
2015-07-27 14:11:24 -04:00
Simon Marchi b21b63420b Factor out int printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out integer
	printing code to ...
	(generic_val_print_int): ... this new function.
2015-07-27 14:11:23 -04:00
Simon Marchi e5bead4b23 Factor out bool printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out bool
	printing code to ...
	(generic_val_print_bool): ... this new function.
2015-07-27 14:11:23 -04:00
Simon Marchi 4a8c372f1f Factor out function/method printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out function/method
	printing code to ...
	(generic_val_print_func): ... this new function.
2015-07-27 14:11:22 -04:00
Simon Marchi d93880bd1c Factor out flags printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out flags
	printing code to ...
	(generic_val_print_flags): ... this new function.
2015-07-27 14:11:22 -04:00
Simon Marchi ef0bc0dd96 Factor out enum printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out enum
	printing code to ...
	(generic_val_print_enum): ... this new function.
2015-07-27 14:11:21 -04:00
Simon Marchi fe43fede47 Factor out reference printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out reference
	printing code to ...
	(generic_val_print_ref): ... this new function.
2015-07-27 14:11:21 -04:00
Simon Marchi 45000ea2f3 Factor out memberptr printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out memberptr
	printing code to ...
	(generic_val_print_memberptr): ... this new function.
2015-07-27 14:11:20 -04:00
Simon Marchi 81eb921ae1 Factor out pointer printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out pointer
	printing code to ...
	(generic_val_print_ptr): ... this new function.
2015-07-27 14:11:19 -04:00
Simon Marchi 557dbe8a5e Factor out array printing code from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out array
	printing code to ...
	(generic_val_print_array): ... this new function.
2015-07-27 14:11:19 -04:00
Simon Marchi 9f436164d5 Factor out print_unpacked_pointer from generic_val_print
gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out
	print_unpacked_pointer code to ...
	(print_unpacked_pointer): ... this new function.
2015-07-27 14:11:18 -04:00
Patrick Palka 077836f7cf Have SIGTERM promptly quit GDB even when the dummy target is active
GDB currently does not promptly quit after receiving a SIGTERM while no
proper target is active.  This is because in handle_sigterm we currently
look at target_can_async_p to determine whether to asynchronously quit
GDB using an async signal handler or to asynchronously quit using the
quit flag.  However, target_can_async_p is always false under the dummy
target, so under this target we always use the quit flag and not the
async signal handler to signal that GDB should quit.  So GDB won't quit
until a code path that checks the quit flag is executed.

To fix this issue, this patch makes the SIGTERM handler no longer
inspect target_can_async_p, and instead makes the handler
unconditionally set the quit flag _and_ mark the corresponding async
signal handler, so that if the target is async (or if it's the dummy
target) then we will likely quit through the async signal handler, and
if it's not async then we will likely quit through the quit flag.  This
redundant approach is similar to how we handle SIGINT.

gdb/ChangeLog:

	* event-top.c (handle_sigterm): Don't inspect
	target_can_async_p.  Always set the quit flag and always mark
	the async signal handler.

gdb/testsuite/ChangeLog:

	* gdb.base/gdb-sigterm-2.exp: New test.
2015-07-27 12:44:12 -04:00
Yao Qi 50904b25ec [gdbserver] Don't set srv_linux_usrregs for aarch64*-*-linux*
We don't use PTRACE_PEEKUSR/PTRACE_POKEUSR on aarch64-linux, so don't
need to set srv_linux_usrregs.  This patch removes that line.

gdb/gdbserver:

2015-07-27  Yao Qi  <yao.qi@linaro.org>

	* configure.srv (case aarch64*-*-linux*): Don't set
	srv_linux_usrregs.
2015-07-27 16:15:48 +01:00
Yao Qi 3a60804fbc Fix ChangeLog entry 2015-07-27 16:12:48 +01:00
Yao Qi 206350da0f Remove REMOTE_EXAMPLES from gdb/Makefile.in
I happen to see REMOTE_EXAMPLES isn't used anywhere, so this patch
removes it.

REMOTE_EXAMPLES was added in the following commit in 1991,

commit 86bbb439c8
Author: John Gilmore <gnu@cygnus>
Date:   Fri May 3 19:57:13 1991 +0000

    There should be a Makefile in the cvs main directory, configured
    for "./config.gdb none", so that things like "make tags" and "make tar"
    will work.

and it was used like:

TARFILES = ${TAGFILES_MAINDIR} ${OTHERS} ${REMOTE_EXAMPLES}

However TARFILES was removed by the change latter in 1994,

Tue Aug 16 15:24:03 1994  Jim Kingdon  (kingdon@lioth.cygnus.com)

	* symtab.c (decode_line_1): If funfirstline and we get a
	non-LOC_BLOCK symbol (e.g. variable or type), then error().

	* Makefile.in (TARFILES, NONSRC, SFILES_STAND, SFILES_KGDB):
	Remove; unused.

Since then, REMOTE_EXAMPLES is not used any more.

gdb:

2015-07-27  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (REMOTE_EXAMPLES): Remove it.
2015-07-27 16:06:31 +01:00
Kevin Buettner c9f35b348e remote.c: Make read_ptid return a null value when no thread id is found.
When using GDB to debug an RX target using the GDB remote protocol,
using a Renesas supplied debug agent, I encountered the following
assertion error:

thread.c:85: internal-error: inferior_thread: Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n
Command aborted.

This assertion error occurs due to the fact that the value associated
with inferior_ptid is not on the thread list.

The remote debug output (obtained with "set debug remote 1") is fairly
short, so I will include it up to the point where things go wrong -
which is somewhat before the assertion failure:

    (gdb) target remote coyote.lan:61234
    Remote debugging using coyote.lan:61234
    Sending packet: $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+#c9...Ack
    Packet received: PacketSize=c00;qXfer:memory-map:read-;qXfer:features:read-;QStartNoAckMode+;multiprocess+;QNonStop+
    Packet qSupported (supported-packets) is supported
    Sending packet: $QStartNoAckMode#b0...Ack
    Packet received: OK
    Sending packet: $Hgp0.0#ad...Packet received: OK
    Sending packet: $QNonStop:0#8c...Packet received: OK
    Sending packet: $qTStatus#49...Packet received:
    Packet qTStatus (trace-status) is NOT supported
    Sending packet: $?#3f...Packet received: S02
    Sending packet: $qfThreadInfo#bb...Packet received: m1
    Sending packet: $qsThreadInfo#c8...Packet received: l
    Sending packet: $qAttached:a410#bf...Packet received: 0
    Packet qAttached (query-attached) is supported
    Sending packet: $Hc-1#09...Packet received: OK
    Sending packet: $qC#b4...Packet received: QC not supported

Above is the trace starting from the invocation of "target remote"
through the call of get_current_thread() in remote_start_remote().
Below, I've pasted this line of code along with additional lines of
context.  The test following the call is especially important to
understanding both the problem and my patch.

          /* We have thread information; select the thread the target
             says should be current.  If we're reconnecting to a
             multi-threaded program, this will ideally be the thread
             that last reported an event before GDB disconnected.  */
          inferior_ptid = get_current_thread (wait_status);
          if (ptid_equal (inferior_ptid, null_ptid))
            {
              /* Odd... The target was able to list threads, but not
                 tell us which thread was current (no "thread"
                 register in T stop reply?).  Just pick the first
                 thread in the thread list then.  */
              inferior_ptid = thread_list->ptid;
            }
        }

Prior to getting to the code pasted above, remote_start_remote()
made a call to target_update_thread_list().  This corresponds to the
following lines from the above trace:

    Sending packet: $qfThreadInfo#bb...Packet received: m1
    Sending packet: $qsThreadInfo#c8...Packet received: l
    Sending packet: $qAttached:a410#bf...Packet received: 0
    Packet qAttached (query-attached) is supported

Once target_update_thread_list has completed, the thread list
contains a single entry: {pid = 42000, lwp = 1, tid = 0}.

remote_start_remote() then makes a call to set_continue_thread(),
accounting for this line of the trace:

    Sending packet: $Hc-1#09...Packet received: OK

Finally, the call to get_current_thread() is responsible for the last
line of the trace that I provided above:

    Sending packet: $qC#b4...Packet received: QC not supported

get_current_thread() calls stop_reply_extract_thread() with the wait
status. This returns null_ptid.

get_current_thread() then calls remote_current_thread with a null
inferior_ptid.  After the calls to putpkt() and getpkt(), rs->buf[0]
is 'Q', so read_ptid() is called and its result is returned.

The buffer passed to read_ptid() is " not supported".  read_ptid ultimately
returns a ptid of {pid = 4200, lwp = 0, tid = 0}.

However, this thread is not on the thread list.  As noted earlier, the
call to target_update_thread_list() had placed {pid = 42000, lwp = 1,
tid = 0} on the list.  This is the only thread in the list.

When these calls ultimately return to remote_start_remote(),
inferior_ptid gets set to {pid = 4200, lwp = 0, tid = 0}, which
(again) is not on the thread list.

It appears to me that the string " not supported" is coming from the
debug agent.  If so, it should be fixed, but I don't see a reason to
not consult the thread list in order to place a valid thread id in
inferior_ptid.

This (consultation of the thread list) is what is done when
inferior_ptid is null_ptid:

	  if (ptid_equal (inferior_ptid, null_ptid))
	    {
	      /* Odd... The target was able to list threads, but not
		 tell us which thread was current (no "thread"
		 register in T stop reply?).  Just pick the first
		 thread in the thread list then.  */
	      inferior_ptid = thread_list->ptid;
	    }

My patch causes a null inferior_ptid to be returned by read_ptid when
no thread id is found in the response from the debug agent.  This
return value ends up being returned by remote_current_thread() and
then by get_current_thread.  The assignment then places this null
value into inferior_ptid.  That, in turn, allows the ptid_equal test
(noted above) to fetch a valid thread from the thread list.  I no
longer see the assertion failure due a good value (which is on the
thread list) being placed in inferior_ptid.

This patch also adds two log warnings that may be output when "set
debug remote 1" is used.  When running against the Renesas debug agent
mentioned earlier, this is the relevant portion of the log output:

Sending packet: $qC#b4...Packet received: QC not supported
warning: garbage in qC reply
warning: couldn't determine remote current thread; picking first in list.

gdb/ChangeLog:

	* remote.c (read_ptid): Return null_ptid when no thread id
	is found.
	(remote_current_thread): Add log warning for malformed
	qC reply.
	(remote_start_remote): Add log warning when current thread
	not found.
2015-07-25 22:02:27 -07:00
Patrick Palka 5836a818ec Revert "Sync readline/ to version 7.0 alpha"
This reverts commit b558ff043d.
This reverts commit 4a11f20659.

The initial import commit failed to retain local changes made to
readline's configure.in (and the commit message erroneously stated that
there were no local changes that needed to be reapplied).  Also the
import caused a couple of build errors and a scattering of testsuite
regressions throughout many arches.  It's probably better to start over
with this import, hopefully more carefully next time.
2015-07-25 15:57:00 -04:00
Doug Evans b8cc7b2e9a Revert: * Makefile.in (check/%.exp): Pass directory for GDB_PARALLEL.
Regressions, e.g.,
http://gdb-build.sergiodj.net/builders/Fedora-x86_64-m32/builds/1501

gdb/testsuite/ChangeLog:

	Revert:
	* Makefile.in (check/%.exp): Pass directory for GDB_PARALLEL.
	(workers/%.worker, build-perf): New rule.
	(GDB_PERFTEST_MODE): New variable.
	(check-perf): Use it.
	(clean): Clean up gdb.perf parallel build subdirs.
	* lib/build-piece.exp: New file.
	* lib/cache.exp (gdb_do_cache): Include $GDB_PARALLEL in path name.
	* lib/gdb.exp (standard_output_file): Include $GDB_PARALLEL in path
	name.
	(standard_temp_file): Ditto.
	(GDB_PARALLEL handling): Make outputs,temp,cache directories as subdirs
	of $GDB_PARALLEL.
2015-07-25 12:07:28 -07:00
Patrick Palka 4a11f20659 Sync readline/ to version 7.0 alpha
This patch syncs our upstream copy of readline from version 6.2 to the
latest version, 7.0 alpha (released July 10 2015).

I essentially copied what was done the last time readline was synced,
when Jan updated to readline 6.2 in 2011:
http://sourceware.org/ml/gdb-patches/2011-05/msg00003.html

Procedure:

1. I extracted the readline-7.0-alpha tarball on top of readline/.
2. I deleted all the new files under doc/ that were deliberately omitted
   before.
3. I regenerated readline/configure and readline/examples/rlfe/configure
   using autoconf 2.64.  No other configure files need regenerating.
4. I updated the function gdb_printable_part in completer.c with a
   trivial change made to the readline function it is based off of,
   printable_part in readline/complete.c.  There is more work to be done in
   completer.c to sync it with readline/complete.c, but it is non-trivial
   and should probably be done separately anyway.

Local patches that had to be reapplied:

    None.  readline 7.0 alpha contains all of our local readline
    patches.

New files in readline/:

    colors.{c,h}
    examples/{hist_erasedups,hist_purgecmd,rl-callbacktest,rlbasic}.c
    parse-colors.{c,h}
    readline.pc.in
    configure.ac

Deleted files in readline/:

    configure.in

Regressions:

After the sync there is one testsuite regression, the test
"signal SIGINT" in gdb.gdb/selftest.exp which now FAILs.  Previously,
the readline 6.2 SIGINT handler would temporarily reinstall the
underlying application's SIGINT handler and immediately re-raise SIGINT
so that the orginal handler gets invoked.  But now (since readline 6.3)
its SIGINT handler does not re-raise SIGINT or directly invoke the
original handler; it now sets a flag marking that SIGINT was raised, and
waits until readline explicitly has control to call the application's
SIGINT handler.  Anyway, because SIGINT is no longer re-raised from
within readline's SIGINT handler, doing "signal SIGINT" with a stopped
inferior gdb process will no longer resume and then immediately stop the
process (since there is no 2nd SIGINT to immediately catch).  Instead,
the inferior gdb process will now just print "Quit" and continue to run.
So with this commit, this particular test case is adjusted to reflect
this change in behavior (we now have to send a 2nd SIGINT manually to
stop it).

Aside from this one testsuite regression, I personally noticed no
regression in user-visible behavior.  Though I only tested on x86_64
and on i686 Debian Stretch.

Getting this kind of change in at the start of the GDB 7.11 development
cycle will allow us to get a lot of passive testing from developers and
from bleeding-edge users.

readline/ChangeLog.gdb:

	Import readline 7.0 alpha
	* configure: Regenerate.
	* examples/rlfe/configure: Regenerate.

gdb/ChangeLog:

	* completer.c (gdb_printable_part): Sync with readline function
	it is based off of.

gdb/testsuite/ChangeLog:

	* gdb.gdb/selftest.exp (test_with_self): Update test to now
	expect the GDB inferior to no longer immediately stop after
	being resumed with "signal SIGINT".
2015-07-25 09:53:01 -04:00
Doug Evans ca3084f54b Revert 4fd4095a5f, log individual measurements.
I think I lost a patch along the way, because I remember needing
something like this, but the reverted patch isn't the right way to
do this.  Removing ...

gdb/testsuite/ChangeLog:

	* gdb.perf/lib/perftest/measure.py (MeasurementCpuTime::stop): Print
	result.
	(MeasurementWallTime::stop): Ditto.
	(MeasurementVmSizeTime::stop): Ditto.
2015-07-24 17:42:18 -07:00
Doug Evans 7fecd1b400 Add gmonster-{1,2} perf testcases.
These testcases are mocks of real programs.
GDB doesn't care what the programs do, they just have to look
and/or behave like the real program.
These testcases exercise gdb when debugging really large programs.
E.g., gmonster-1 has 10,000 CUs, and gmonster-2 has 1000 shared libs
(which is actually a little small, 5000 would be more accurate).

gdb/testsuite/ChangeLog:

	* gdb.perf/lib/perftest/utils.py: New file.
	* gdb.perf/gm-hello.cc: New file.
	* gdb.perf/gm-pervasive-typedef.cc: New file.
	* gdb.perf/gm-pervasive-typedef.h: New file.
	* gdb.perf/gm-std.cc: New file.
	* gdb.perf/gm-std.h: New file.
	* gdb.perf/gm-use-cerr.cc: New file.
	* gdb.perf/gm-utils.h: New file.
	* gdb.perf/gmonster-null-lookup.py: New file.
	* gdb.perf/gmonster-pervasive-typedef.py: New file.
	* gdb.perf/gmonster-print-cerr.py: New file.
	* gdb.perf/gmonster-ptype-string.py: New file.
	* gdb.perf/gmonster-runto-main.py: New file.
	* gdb.perf/gmonster-select-file.py: New file.
	* gdb.perf/gmonster1-null-lookup.exp: New file.
	* gdb.perf/gmonster1-pervasive-typedef.exp: New file.
	* gdb.perf/gmonster1-print-cerr.exp: New file.
	* gdb.perf/gmonster1-ptype-string.exp: New file.
	* gdb.perf/gmonster1-runto-main.exp: New file.
	* gdb.perf/gmonster1-select-file.exp: New file.
	* gdb.perf/gmonster1.cc: New file.
	* gdb.perf/gmonster1.exp: New file.
	* gdb.perf/gmonster2-null-lookup.exp: New file.
	* gdb.perf/gmonster2-pervasive-typedef.exp: New file.
	* gdb.perf/gmonster2-print-cerr.exp: New file.
	* gdb.perf/gmonster2-ptype-string.exp: New file.
	* gdb.perf/gmonster2-runto-main.exp: New file.
	* gdb.perf/gmonster2-select-file.exp: New file.
	* gdb.perf/gmonster2.cc: New file.
	* gdb.perf/gmonster2.exp: New file.
2015-07-24 15:46:31 -07:00
Doug Evans 6eab34f3dc Add perf testcase generator.
gdb/testsuite/ChangeLog:

	* gdb.perf/README: New file.
	* lib/perftest.exp (tcl_string_list_to_python_list): New function.
	* lib/gen-perf-test.exp: New file.
2015-07-24 15:43:15 -07:00
Doug Evans 63738bfdb9 PerfTest::assemble functions return results.
gdb/testsuite/ChangeLog:

	* lib/perftest.exp (PerfTest::compile): Unconditionally call body.
	(PerfTest::startup): New function.
	(PerfTest::run): Return result of calling body.
	(PerfTest::assemble): Rewrite.
	* gdb.perf/backtrace.exp (PerfTest::assemble): Update function result.
	* gdb.perf/disassemble.exp (PerfTest::assemble): Ditto.
	* gdb.perf/single-step.exp (PerfTest::assemble): Ditto.
	* gdb.perf/skip-prologue.exp (PerfTest::assemble): Ditto.
	* gdb.perf/solib.exp (PerfTest::assemble): Ditto.
2015-07-24 15:38:21 -07:00
Doug Evans 7b606f95c9 lib/gdb.exp (clean_restart): Make executable optional.
gdb/testsuite/ChangeLog:

	* lib/gdb.exp (clean_restart): Make executable optional.
2015-07-24 15:35:12 -07:00
Doug Evans a97b16b8fc Clean up testsuite compiler_info support.
gdb/testsuite/ChangeLog:

	* gdb.base/watchpoint.exp (test_complex_watchpoint): Remove
	compiler_info references.
	* gdb.cp/temargs.exp: Ditto.
	* lib/gdb.exp: Unset compiler_info instead of setting to "unknown".
	(get_compiler_info): Early exit if already computed.  Set compiler_info
	to "unknown" if there was a problem.
	(test_compiler_info): Add function comment.  Call get_compiler_info.
2015-07-24 15:32:45 -07:00
Doug Evans 35baa57fcf Add parallel build support for perf tests.
gdb/testsuite/ChangeLog:

	* Makefile.in (check/%.exp): Pass directory for GDB_PARALLEL.
	(workers/%.worker, build-perf): New rule.
	(GDB_PERFTEST_MODE): New variable.
	(check-perf): Use it.
	(clean): Clean up gdb.perf parallel build subdirs.
	* lib/build-piece.exp: New file.
	* lib/cache.exp (gdb_do_cache): Include $GDB_PARALLEL in path name.
	* lib/gdb.exp (standard_output_file): Include $GDB_PARALLEL in path
	name.
	(standard_temp_file): Ditto.
	(GDB_PARALLEL handling): Make outputs,temp,cache directories as subdirs
	of $GDB_PARALLEL.
2015-07-24 15:28:46 -07:00
Doug Evans 6ebea266fd Workaround debian change to default value of --as-needed.
gdb/testsuite/ChangeLog:

	* lib/future.exp (gdb_default_target_compile): New option
	"early_flags".
	* lib/gdb.exp (gdb_compile): Undo debian's change in default of
	--as-needed.
2015-07-24 15:24:37 -07:00
Doug Evans 4fd4095a5f Print data from individual perf runs.
gdb/testsuite/ChangeLog:

	* gdb.perf/lib/perftest/measure.py (MeasurementCpuTime::stop): Print
	result.
	(MeasurementWallTime::stop): Ditto.
	(MeasurementVmSizeTime::stop): Ditto.
2015-07-24 15:11:07 -07:00
Sergio Durigan Junior 1e76a7e9b1 Call gdb_exit before gdb_skip_xml_test on gdb.base/catch-syscall.exp
The gdb_skip_xml_test procedure explicitly says that it cannot be
invoked when GDB is running.  However, the testcase for "catch
syscall" is wrongly doing that, which is causing a failure on
native-extended-gdbserver tests:

  new FAIL: gdb.base/catch-syscall.exp: set tdesc filename /home/gdb-buildbot/fedora-x86-64-3/fedora-x86-64-native-extended-gdbserver-m32/build/gdb/testsuite/outputs/gdb.base/catch-syscall/trivial.xml (got interactive prompt)

This obvious commit fixes this, by calling gdb_exit before gdb_skip_xml_test.

Checked in as obvious.

gdb/testsuite/ChangeLog
2015-07-24  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.base/catch-syscall.exp: Call gdb_exit before
	gdb_skip_xml_test.
2015-07-24 16:46:49 -04:00
Pedro Alves 2b4cab8654 Fix s390 GNU/Linux build after enum __ptrace_request changes
The buildbot noticed that the enum __ptrace_request series broke the
s390 GNU/Linux build:

../../binutils-gdb/gdb/s390-linux-nat.c: In function 'fetch_regs':
../../binutils-gdb/gdb/s390-linux-nat.c:226:54: error: macro "ptrace" requires 4 arguments, but only 3 given
   if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea) < 0)
                                                      ^
../../binutils-gdb/gdb/s390-linux-nat.c: In function 'store_regs':
../../binutils-gdb/gdb/s390-linux-nat.c:243:54: error: macro "ptrace" requires 4 arguments, but only 3 given
   if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea) < 0)
                                                      ^

Fix this the same way it's handled everywhere else -- just pass 0 as
forth argument, which also handles non-varargs ptrace prototypes in
non-glibc libcs, e.g., Bionic (if it ever gets a s390 port...).

gdb/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* s390-linux-nat.c (fetch_regs, store_regs, fetch_fpregs)
	(s390_stopped_by_watchpoint, s390_prepare_to_resume): Pass 0 as
	forth argument to ptrace PTRACE_PEEKUSR_AREA/PTRACE_POKEUSR_AREA.
2015-07-24 20:29:53 +01:00
Pedro Alves 5068630ad3 gdb.python/py-events.exp and normal_stop observers ordering
I have patches that:

 1 - make the CLI print stop info from a normal_stop observer, like MI
     does.

 2 - happen to change the order in which the Python and CLI/TUI
     normal_stop observers are installed.

With those in place, py-events.exp regresses like shown below [1],
because the Python stop events are output before CLI prints stop info,
instead of after, and the test doesn't expect that.

With the same Python hooks, the order in which MI and Python events is
emited today is already undefined, because MI also uses the
normal_stop observer for output.  I see no reason that we should in
general define the order observers, interpreters and scripting
languages get their turn at being notified of these events.  So this
patch makes the test cope with Python->CLI output order too.

Tested on x86_64 Fedora 20.

gdb/testsuite/
2015-07-24  Pedro Alves  <palves@redhat.com>

	* gdb.python/py-events.exp: Accept output between the stop event
	and the prompt.
	* gdb.python/py-evsignal.exp: Likewise.
	* gdb.python/py-evthreads.exp: Likewise.

[1] - The regressions in question look like:

Before said patches:
  (gdb) continue
  Continuing.
  event type: continue

  Breakpoint 2, first () at /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.python/py-events.c:30
  30	  for (i = 0; i < 2; i++)
  event type: stop
  event type: stop
  stop reason: breakpoint
  first breakpoint number: 2
  breakpoint number: 2
  breakpoint number: 3
  all threads stopped
  (gdb) PASS: gdb.python/py-events.exp: continue

After said patches:
  (gdb) continue
  Continuing.
  event type: continue
  event type: stop
  event type: stop
  stop reason: breakpoint
  first breakpoint number: 2
  breakpoint number: 2
  breakpoint number: 3
  all threads stopped

  Breakpoint 2, first () at /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.python/py-events.c:30
  30	  for (i = 0; i < 2; i++)
  (gdb) FAIL: gdb.python/py-events.exp: continue
2015-07-24 19:34:17 +01:00
Pedro Alves 7759842763 PR gdb/18717: internal error if non-leader thread exits process
If a non-leader thread exits the process while all other threads are
ptrace-stopped, native gdb fails an assertion.  The test added by this
commit catches it:

 /home/pedro/gdb/mygit/build/../src/gdb/linux-nat.c:3198: internal-error: linux_nat_filter_event: Assertion `lp->resumed' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n)
 FAIL: gdb.threads/non-leader-exit-process.exp: program exits normally (GDB internal error)

The fix is just to remove the assertion.

With that out of the way, neither GDB not GDBserver handle this
perfectly though, so I'm adding a KFAIL:

 (gdb) continue
 Continuing.
 [Thread 0x7ffff7fc0700 (LWP 15350) exited]
 No unwaited-for children left.
 Couldn't get registers: No such process.
 (gdb) KFAIL: gdb.threads/non-ldr-exit.exp: program exits normally (PRMS: gdb/18717)

gdb/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	PR gdb/18717
	* linux-nat.c (linux_nat_filter_event): Don't assert that the lwp
	is resumed, and extend the debug log.

gdb/testsuite/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	PR gdb/18717
	* gdb.threads/non-ldr-exit.c: New file.
	* gdb.threads/non-ldr-exit.exp: New file.
2015-07-24 17:49:17 +01:00
Pedro Alves fe23c31f26 Fix failed exec error message
Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00629.html

This fixes the bogus command line in the error message shown when the
SHELL environment variable points somewhere that's not something that
resembles a shell:

  $ SHELL=/nonexisting gdb /home/pedro/a.out
  (gdb) r
  Starting program: /home/pedro/a.out
 - Cannot exec /home/pedro/a.out -c exec /home/pedro/a.out .
 + Cannot exec /nonexisting -c exec /home/pedro/a.out .
  Error: No such file or directory
  During startup program exited with code 127.
  (gdb)

gdb/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* fork-child.c (fork_inferior): Print argv[0] instead of exec_file.
2015-07-24 17:27:58 +01:00
Pedro Alves 5826e15986 Linux: sys/ptrace.h -> nat/gdb_ptrace.h everywhere
So that we pick the enum __ptrace_request fix everywhere.

gdb/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* aarch64-linux-nat.c: Include nat/gdb_ptrace.h instead of
	sys/ptrace.h.
	* alpha-linux-nat.c: Likewise.
	* amd64-linux-nat.c: Likewise.
	* arm-linux-nat.c: Likewise.
	* hppa-linux-nat.c: Likewise.
	* i386-linux-nat.c: Likewise.
	* ia64-linux-nat.c: Likewise.
	* linux-fork.c: Likewise.
	* linux-nat.c: Likewise.
	* m32r-linux-nat.c: Likewise.
	* m68klinux-nat.c: Likewise.
	* mips-linux-nat.c: Likewise.
	* nat/linux-btrace.c: Likewise.
	* nat/linux-ptrace.c: Likewise.
	* nat/linux-ptrace.h
	* nat/mips-linux-watch.c: Likewise.
	* nat/x86-linux-dregs.c: Likewise.
	* ppc-linux-nat.c: Likewise.
	* s390-linux-nat.c: Likewise.
	* spu-linux-nat.c: Likewise.
	* tilegx-linux-nat.c: Likewise.
	* x86-linux-nat.c: Likewise.
	* xtensa-linux-nat.c: Likewise.

gdb/gdbserver/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.c: Likewise.om>

	* linux-aarch64-low.c: Include nat/gdb_ptrace.h instead of
	sys/ptrace.h.
	* linux-arm-low.c: Likewise.
	* linux-cris-low.c: Likewise.
	* linux-crisv32-low.c: Likewise.
	* linux-low.c: Likewise.
	* linux-m68k-low.c: Likewise.
	* linux-mips-low.c: Likewise.
	* linux-nios2-low.c: Likewise.
	* linux-s390-low.c: Likewise.
	* linux-sparc-low.c: Likewise.
	* linux-tic6x-low.c: Likewise.
	* linux-tile-low.c: Likewise.
	* linux-x86-low.c: Likewise.
2015-07-24 15:14:47 +01:00
Pedro Alves 5401971915 C++: handle glibc's ptrace(enum __ptrace_request, ...)
Building in C++ mode issues ~40 warnings like this:

 ../../src/gdb/linux-nat.c: In function ‘int linux_handle_extended_wait(lwp_info*, int, int)’:
 ../../src/gdb/linux-nat.c:2016:51: warning: invalid conversion from ‘int’ to ‘__ptrace_request’ [-fpermissive]
	ptrace (PTRACE_GETEVENTMSG, pid, 0, &new_pid);

The issue is that in glibc, ptrace's first parameter is an enum.
That's not a problem if we pick the PTRACE_XXX requests from
sys/ptrace.h, as those will be values of the corresponding enum.
However, we have fallback definitions for PTRACE_XXX symbols when the
system headers miss them (such as PTRACE_GETEVENTMSG above), and those
are plain integer constants.  E.g., nat/linux-ptrace.h:

 #define PTRACE_GETEVENTMSG	0x4201

One idea would be to fix this by defining those fallbacks like:

 -#define PTRACE_GETEVENTMSG	0x4201
 +#define PTRACE_GETEVENTMSG	((enum __ptrace_request) 0x4201)

However, while glibc's ptrace uses enum __ptrace_request for first
parameter:

  extern long int ptrace (enum __ptrace_request __request, ...) __THROW;

other libc's, like e.g., Android's bionic do not -- in that case, the
first parameter is int:

  long ptrace(int request, pid_t pid, void * addr, void * data);

So the fix I came up is to make configure/ptrace.m4 also detect the
type of the ptrace's first parameter and defin PTRACE_TYPE_ARG1, as
already does the for parameters 3-4, and then simply wrap ptrace with
a macro that casts the first argument to the detected type.  (I'm
leaving adding a nicer wrapper for when we drop building in C).

While this adds the wrapper, GNU/Linux files won't use it until the
next patch, which makes all native GNU/Linux files include
gdb_ptrace.h.

gdb/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* ptrace.m4 (ptrace tests): Test in C++ mode.  Try with 'enum
	__ptrace_request as first parameter type instead of int.
	(PTRACE_TYPE_ARG1): Define.
	* nat/gdb_ptrace.h [!PTRACE_TYPE_ARG5] (ptrace): Define as wrapper
	that casts first argument to PTRACE_TYPE_ARG1.
	* config.in: Regenerate.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* config.in: Regenerate.
	* configure: Regenerate.
2015-07-24 15:12:15 +01:00
Pedro Alves e379037592 Move gdb_ptrace.h to nat/
Now that gdbserver's configure defines PTRACE_TYPE_ARGx etc., we'll be
able to make gdbserver use gdb_ptrace.h too.  Move it to the native
target files directory.

gdb/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* gdb_ptrace.h: Move ...
	* nat/gdb_ptrace.h: ... here.
	* inf-ptrace.c: Adjust.
2015-07-24 15:11:18 +01:00
Pedro Alves eb7aa56163 make gdbserver use the same ptrace autoconf checks as gdb
This factors the ptrace checks out of gdb's configure.ac to a new
ptrace.m4 file, and then makes gdbserver's configure.ac source it too.

gdb/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include ptrace.m4.
	* configure.ac: Call GDB_AC_PTRACE and move ptrace checks ...
	* ptrace.m4: ... to this new file.

gdb/gdbserver/ChangeLog:
2015-07-24  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include ../ptrace.m4.
	* configure.ac: Call GDB_AC_PTRACE.
	* config.in, configure: Regenerate.
2015-07-24 14:57:19 +01:00
Yao Qi 55d7b84196 Remove proc->priv->new_inferior
As the result of the previous patch, new_inferior is no longer used.
This patch is to remove it.

gdb/gdbserver:

2015-07-24  Yao Qi  <yao.qi@linaro.org>

	* linux-low.c (linux_create_inferior): Remove setting to
	proc->priv->new_inferior.
	(linux_attach): Likewise.
	(linux_low_filter_event): Likewise.
	* linux-low.h (struct process_info_private) <new_inferior>: Remove.
2015-07-24 14:40:34 +01:00
Yao Qi c06cbd92be Initialise target descrption after skipping extra traps for --wrapper
Nowadays, when --wrapper is used, GDBserver skips extra traps/stops
in the wrapper program, and stops at the first instruction of the
program to be debugged.  However, GDBserver created target description
in the first stop of inferior, and the executable of the inferior
is the wrapper program rather than the program to be debugged.  In
this way, the target description can be wrong if the architectures
of wrapper program and program to be debugged are different.  This
is shown by some fails in gdb.server/wrapper.exp on buildbot.

We are testing i686-linux GDB (Fedora-i686) on an x86_64-linux box
(fedora-x86-64-4) in buildbot, such configuration causes fails in
gdb.server/wrapper.exp like this:

spawn /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/../../gdb/gdbserver/gdbserver --once --wrapper env TEST=1 -- :2346 /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper
Process /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper created; pid = 8795
Can't debug 64-bit process with 32-bit GDBserver
Exiting
target remote localhost:2346
localhost:2346: Connection timed out.
(gdb) FAIL: gdb.server/wrapper.exp: setting breakpoint at marker

See https://sourceware.org/ml/gdb-testers/2015-q3/msg01541.html

In this case, program to be debugged ("wrapper") is 32-bit but wrapper
program ("/usr/bin/env") is 64-bit, so GDBserver gets the 64-bit
target description instead of 32-bit.

The root cause of this problem is that GDBserver creates target
description too early, and the rationale of fix could be creating
target description once the GDBserver skips extra traps and inferior
stops at the first instruction of the program we want to debug.  IOW,
when GDBserver skips extra traps, the inferior's tdesc is NULL, and
mywait and its callees shouldn't use inferior's tdesc, so in this
patch, we skip code that requires register access, see changes in
linux_resume_one_lwp_throw and need_step_over_p.

In linux_low_filter_event, if target description isn't initialised and
GDBserver attached the process, we create target description immediately,
because GDBserver don't have to skip extra traps for attach, IOW, it
makes no sense to use --attach and --wrapper together.  Otherwise, the
process is launched by GDBserver, we keep the status pending, and return.

After GDBserver skipped extra traps in start_inferior, we call a
target_ops hook arch_setup to initialise target description there.

gdb/gdbserver:

2015-07-24  Yao Qi  <yao.qi@linaro.org>

	* linux-low.c (linux_arch_setup): New function.
	(linux_low_filter_event): If proc->tdesc is NULL and
	proc->attached is true, call the_low_target.arch_setup.
	Otherwise, keep status pending, and return.
	(linux_resume_one_lwp_throw): Don't call get_pc if
	thread->while_stepping isn't NULL.  Don't call
	get_thread_regcache if proc->tdesc is NULL.
	(need_step_over_p): Return 0 if proc->tdesc is NULL.
	(linux_target_ops): Install arch_setup.
	* server.c (start_inferior): Call the_target->arch_setup.
	* target.h (struct target_ops) <arch_setup>: New field.
	(target_arch_setup): New marco.
	* lynx-low.c (lynx_target_ops): Update.
	* nto-low.c (nto_target_ops): Update.
	* spu-low.c (spu_target_ops): Update.
	* win32-low.c (win32_target_ops): Update.
2015-07-24 14:40:34 +01:00
Yao Qi 5ae3ebbae5 Set proc->priv->new_inferior out of linux_add_process
Nowadays, we set proc->priv->new_inferior to 1 inside linux_add_process,
and new_inferior is used as a flag to initialise target description later.
linux_add_process is used for the three cases, fork/vfork event
(handle_extended_wait), run the program (linux_create_inferior), and
attach to the process (linux_attach).  In the first case, the child's
target description is copied from parent's, so we don't need to initialise
target description again later, which means we don't need to set
proc->priv->new_inferior to 1 in this case.  For the rest of two cases,
we need this flag.

This patch move the code setting proc->priv->new_inferior to 1 inside
linux_add_process to linux_create_inferior and linux_attach.  No
functionality is changed.

gdb/gdbserver:

2015-07-24  Yao Qi  <yao.qi@linaro.org>

	* linux-low.c (linux_add_process): Don't set
	proc->priv->new_inferior.
	(linux_create_inferior): Set proc->priv->new_inferior to 1.
	(linux_attach): Likewise.
2015-07-24 14:40:34 +01:00
Yao Qi eb97750bce Refactor start_inferior
This patch is to refactor function start_inferior that signal_pid
is return in one place.

gdb/gdbserver:

2015-07-24  Yao Qi  <yao.qi@linaro.org>

	* server.c (start_inferior): Code refactor.
2015-07-24 14:40:34 +01:00
Yao Qi 11e6c98f1b Test --wrapper when restarting process.
My patch series will affect the code starting inferior in GDBserver
(callees of start_inferior), so we need tests to cover how
start_inferior is used in different cases.

In server.c:process_serial_event, start_inferior is used when
GBDserver receives 'R' packet, and this patch is to add a test
for this path, and see how --wrapper option works when the process
is restarted.

gdb/testsuite:

2015-07-24  Yao Qi  <yao.qi@linaro.org>

	* gdb.server/ext-wrapper.exp: Test --wrapper option when
	restarting process.
2015-07-24 14:40:34 +01:00
Yao Qi 51aee833ed Set general_thread after restart
When I run gdb.server/ext-restart.exp, I get the following GDB internal
error,

run^M
The program being debugged has been started already.^M
Start it from the beginning? (y or n) y^M
Sending packet: $vKill;53c5#3d...Packet received: OK^M
Packet vKill (kill) is supported^M
Sending packet: $vFile:close:6#b6...Packet received: F0^M
Sending packet: $vFile:close:3#b3...Packet received: F0^M
Starting program: /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.server/ext-restart ^M
Sending packet: $QDisableRandomization:1#cf...Packet received: OK^M
Sending packet: $R0#82...Sending packet: $qC#b4...Packet received: QCp53c5.53c5^M  <-- [1]
Sending packet: $qAttached:53c5#c9...Packet received: E01^M
warning: Remote failure reply: E01^M
....
0x00002aaaaaaac2d0 in ?? () from target:/lib64/ld-linux-x86-64.so.2^M
/home/yao/SourceCode/gnu/gdb/git/gdb/thread.c:88: internal-error: inferior_thread: Assertion `tp' failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
Quit this debugging session? (y or n) FAIL: gdb.server/ext-restart.exp: run to main (GDB internal error)
Resyncing due to internal error.

the test is to restart the program, to make sure GDBserver handles
packet 'R' correctly.  From the GDBserver output, we can see,

 Remote debugging from host 127.0.0.1^M
 Process /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.server/ext-restart created; pid = 21445^M
 GDBserver restarting^M
 Process /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.server/ext-restart created; pid = 21446^M
 Killing process(es): 21446

we first start process 21445(0x53c5), kill it and restart a new process
21446.  However, in the gdb output above [1], we can see that the reply
of qC is still the old process id rather than the new one.  Looks
general_thread isn't up to date after GDBserver receives R packet.
This patch is to update general_thread after call start_inferior.

gdb/gdbserver:

2015-07-24  Yao Qi  <yao.qi@linaro.org>

	* server.c (process_serial_event): Set general_thread.

gdb/testsuite:

2015-07-24  Yao Qi  <yao.qi@linaro.org>

	* gdb.server/ext-restart.exp: New file.
2015-07-24 14:40:34 +01:00
Yao Qi 8cfe207c9f Test --wrapper in extended-remote
We didn't test --wrapper option in extended-remote before, this patch
is to add a test case for it.  In order to pass option --wrapper to
gdbserver in extended-remote, I add arg in gdbserver_start_extended,
and its default value is "", so that other places use
gdbserver_start_extended don't have to be updated.

gdb/testsuite:

2015-07-24  Yao Qi  <yao.qi@linaro.org>

	* lib/gdbserver-support.exp (gdbserver_start_extended): Add
	argument options.
	* gdb.server/ext-wrapper.exp: New file.
2015-07-24 14:40:34 +01:00
H.J. Lu 72f4393d8c Remove leading/trailing white spaces in ChangeLog 2015-07-24 04:16:47 -07:00
Doug Evans cc12ce380e Fix crash when reading dummy CUs.
Dummy CUs are used by the incremental linker to pre-allocate space
in the output file. They have a DWARF header but no contents.

gdb/ChangeLog:

	* dwarf2read.c (dwarf2_per_cu_data): Add comment.
	(load_cu): Handle dummy CUs.
	(dw2_do_instantiate_symtab, process_queuef): Ditto.
	(dwarf2_fetch_die_loc_sect_off, dwarf2_fetch_constant_bytes): Ditto.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-dummy-cu.S: New file.
	* gdb.dwarf2/dw2-dummy-cu.exp: New file.
2015-07-23 09:25:49 -07:00
Ciro Santilli 7b849db4f2 py-linetable.c: Fix doc of LineTable.source_lines' return type
The ltpy_get_all_source_lines function, use to implement
the gdb.LineTable.source_lines method, returns a list:

    source_list = PyDict_Keys (source_dict);
    return source_list;

This patch fixes the function's documentation as well as its docstring
to say that it returns a list rather than a FrozenSet.

gdb/ChangeLog:

        * py-linetable.c (ltpy_get_all_source_lines): Adjust function
        documentation to say that it returns a list rather than
        a FrozenSet.
        (linetable_object_methods): Update the docstring of the
        "source_line" entry.

Tested on x86_64-linux.
2015-07-23 06:51:07 -07:00
Pierre-Marie de Rodat d0d8478068 gdb/gdbtypes: fix handling of typedef layers between array types
When a dynamic array type contains a typedef-wrapped array, an assertion
failure occurs during type resolution.  This is what happens in the
following Ada case:

    type Rec_Type is record
       I : Integer;
       B : Boolean;
    end record;

    type Vec_Type is array (1 .. 4) of Rec_Type;

    type Array_Type is array (Positive range <>) of Vec_Type;

If users try to print or even pass to an inferior call a variable A of
type Array_Type, GDB will raise an error:

    (gdb) print a
    ../../src/gdb/gdbtypes.c:1807: internal-error:
    resolve_dynamic_array: Assertion `TYPE_CODE (type) ==
    TYPE_CODE_ARRAY' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

What happens is that during dynamic array type resolution, we first peel
TYPE_CODE_TYPEDEF layers wrapping the array element type and check if
its type is itself TYPE_CODE_ARRAY.  If it is, we pass the
typedef-wrapped type to a recursive call to resolve_dynamic_array
whereas this function expects only TYPE_CODE_ARRAY types.

This patch makes it pass the peeled type to the recursive call so that
type resolution can continue smoothly.

gdb/ChangeLog:

	* gdbtypes.c (resolve_dynamic_array): Pass the peeled element
	type to the recursive call instead of the original (maybe
	TYPE_CODE_TYPEDEF) type.

gdb/testsuite/ChangeLog:

	* gdb.ada/var_arr_typedef.exp: New testcase.
	* gdb.ada/var_arr_typedef/pack.adb: New file.
	* gdb.ada/var_arr_typedef/pack.ads: New file.
	* gdb.ada/var_arr_typedef/var_arr_typedef.adb: New file.
2015-07-23 14:59:58 +02:00
Yao Qi c2fbdc5901 Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoint
Nowadays aarch64_linux_can_use_hw_breakpoint always return one, but it
can be smarter, say, if GDB knows target doesn't support HW watchpoint
or breakpoint because HW watchpoint/breakpoint is disabled in linux
kernel, for example, it can safely return zero.

gdb:

2015-07-23  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_can_use_hw_breakpoint): If
	TYPE is watchpoint, return zero if aarch64_num_wp_regs is zero.
	If TYPE is breakpoint, return zero if arch64_num_bp_regs is zero.
2015-07-23 11:22:34 +01:00
Yao Qi af1b22f300 Move aarch64_linux_get_debug_reg_capacity to nat/aarch64-linux-hw-point.c
There are also some duplication on getting HW watchpoint/breakpoint
registers info between GDB and GDBserver.  This patch moves them
to nat/aarch64-linux-hw-point.c.

Note that ENABLE_NLS is not defined in GDBserver, so it should be OK
to use _( markup.

gdb:

2015-07-21  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_get_debug_reg_capacity):
	Move it to nat/aarch64-linux-hw-point.c.
	(aarch64_linux_child_post_startup_inferior): Update.
	* nat/aarch64-linux-hw-point.c (aarch64_linux_get_debug_reg_capacity):
	New function.
	* nat/aarch64-linux-hw-point.h (aarch64_linux_get_debug_reg_capacity):
	Declare it.

gdb/gdbserver:

2015-07-21  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_arch_setup): Remove code and call
	aarch64_linux_get_debug_reg_capacity.
2015-07-21 16:33:41 +01:00
Markus Metzger 40e050d242 btrace: fix case label in btrace_data_append
gdb/
	* common/btrace-common.c (btrace_data_append): Change case label.
2015-07-21 13:50:44 +02:00
Joel Brobecker 8b558f797a gdb.ada/info_exc.exp: Adjust expected output in "info exception" test.
Since multi_line was moved to gdb.exp in a slightly stricter form,
The gdb.ada/info_exc.exp:info exceptions test has been failing.
This is because it now expects a new-line sequence at the end of
each argument given to multi_line, including ".*". But the intent
when writing the test was to signify "could-be-nothing-at-all".
As a result, the test fails on x86_64-linux with a runtime built as
recommended, because of that
extra new-line sequence.

gdb/testsuite/ChangeLog:

        * gdb.ada/info_exc.exp: Adjust "info exceptions" expected output.
2015-07-20 15:18:24 -07:00
Doug Evans a3b5281eb9 Makefile.in (STABS_DOC_BUILD_INCLUDES): Add gdb-cfg.texi, GDBvn.texi.
gdb/doc/ChangeLog:

	* Makefile.in (STABS_DOC_BUILD_INCLUDES): Add gdb-cfg.texi, GDBvn.texi.
2015-07-20 09:21:51 -07:00
Yao Qi 3675a06a82 Fix ARI warnings to nat/aarch64-linux-hw-point.{c,h}
This patch is to fix two ARI warnings for nat/aarch64-linux-hw-point.{c,h}.

gdb:

2015-07-20  Yao Qi  <yao.qi@linaro.org>

	* nat/aarch64-linux-hw-point.c (aarch64_handle_unaligned_watchpoint):
	Re-indent the code.
	* nat/aarch64-linux-hw-point.h: Use ULONGEST rather than
	"unsigned long long".
2015-07-20 16:49:22 +01:00
Kevin Buettner b4e1fd615a dwarf2read: Allow SEC_ALLOC sections to be located at address 0.
GDB already allows statically initialized variables, located in
SEC_LOAD sections, to be placed at address 0.  This change allows
uninitialized variables (which are in SEC_ALLOC sections) to be placed
address 0 as well.

gdb/ChangeLog:

	* dwarf2read.c (dwarf2_locate_sections): Allow has_section_at_zero
	to be set for SEC_ALLOC sections too.
2015-07-18 10:10:15 -07:00
Yao Qi 554717a3ed Move common aarch64 HW breakpoint/watchpoint code to nat/
When I look at test fails related to watchpoint on aarch64-linux,
I find there are some code duplicates between GDB and GDBserver.
This patch is to move some of them to a nat/aarch64-linux-hw-point.{h,c}.

The only change I do is about the dr_changed_t typedef, which was
ULONGEST in GDB and 'unsigned long long' in GDBserver.  Each bit
of dr_changed_t represents a status of each HW breakpoint or
watchpoint register, and the max number of HW breakpoint or watchpoint
registers is 16, so the width of 'unsigned long long' is sufficient.

gdb:

2015-07-17  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (HFILES_NO_SRCDIR): Add
	nat/aarch64-linux-hw-point.h.
	(aarch64-linux-hw-point.o): New rule.
	* nat/aarch64-linux-hw-point.h: New file.
	* nat/aarch64-linux-hw-point.c: New file.
	* aarch64-linux-nat.c: Include nat/aarch64-linux-hw-point.h.
	(AARCH64_HBP_MAX_NUM): Move to nat/aarch64-linux-hw-point.h.
	(AARCH64_HWP_MAX_NUM, AARCH64_HBP_ALIGNMENT): Likewise.
	(AARCH64_HWP_ALIGNMENT): Likewise.
	(AARCH64_HWP_MAX_LEN_PER_REG): Likewise.
	(AARCH64_DEBUG_NUM_SLOTS, AARCH64_DEBUG_ARCH): Likewise.
	(AARCH64_DEBUG_ARCH_V8, DR_MARK_ALL_CHANGED): Likewise.
	(DR_MARK_N_CHANGED, DR_CLEAR_CHANGED): Likewise.
	(DR_HAS_CHANGED, DR_N_HAS_CHANGE): Likewise.
	(aarch64_num_bp_regs, aarch64_num_wp_regs): Likewise.
	(struct aarch64_debug_reg_state): Likewise.
	(struct arch_lwp_info):	Likewise.
	(aarch64_linux_set_debug_regs): Likewise.
	(aarch64_notify_debug_reg_change): Remove static.
	(aarch64_align_watchpoint): Likewise.
	(DR_CONTROL_ENABLED, DR_CONTROL_LENGTH): Likewise.
	(aarch64_watchpoint_length): Likewise.
	(aarch64_point_encode_ctrl_reg): Likewise
	(aarch64_point_is_aligned): Likewise.
	(aarch64_dr_state_insert_one_point): Likewise.
	(aarch64_dr_state_remove_one_point): Likewise.
	(aarch64_handle_breakpoint): Likewise.
	(aarch64_handle_aligned_watchpoint): Likewise.
	(aarch64_handle_unaligned_watchpoint): Likewise.
	(aarch64_handle_watchpoint): Likewise.
	* config/aarch64/linux.mh (NAT_FILE): Add
	aarch64-linux-hw-point.o.

gdb/gdbserver:

2015-07-17  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (aarch64-linux-hw-point.o): New rule.
	* configure.srv (srv_tgtobj): Append aarch64-linux-hw-point.o.
	* linux-aarch64-low.c: Include nat/aarch64-linux-hw-point.h.
	(AARCH64_HBP_MAX_NUM): Move to nat/aarch64-linux-hw-point.h.
	(AARCH64_HWP_MAX_NUM, AARCH64_HBP_ALIGNMENT): Likewise.
	(AARCH64_HWP_ALIGNMENT): Likewise.
	(AARCH64_HWP_MAX_LEN_PER_REG): Likewise.
	(AARCH64_DEBUG_NUM_SLOTS, AARCH64_DEBUG_ARCH): Likewise.
	(aarch64_num_bp_regs, aarch64_num_wp_regs): Likewise.
	(AARCH64_DEBUG_ARCH_V8, DR_MARK_ALL_CHANGED): Likewise.
	(DR_MARK_N_CHANGED, DR_CLEAR_CHANGED): Likewise.
	(DR_HAS_CHANGED, DR_N_HAS_CHANGE): Likewise.
	(struct aarch64_debug_reg_state): Likewise.
	(struct arch_lwp_info):	Likewise.
	(aarch64_align_watchpoint): Likewise.
	(DR_CONTROL_ENABLED, DR_CONTROL_LENGTH): Likewise.
	(aarch64_watchpoint_length): Likewise.
	(aarch64_point_encode_ctrl_reg): Likewise
	(aarch64_point_is_aligned): Likewise.
	(aarch64_align_watchpoint): Likewise.
	(aarch64_linux_set_debug_regs):
	(aarch64_dr_state_insert_one_point): Likewise.
	(aarch64_dr_state_remove_one_point): Likewise.
	(aarch64_handle_breakpoint): Likewise.
	(aarch64_handle_aligned_watchpoint): Likewise.
	(aarch64_handle_unaligned_watchpoint): Likewise.
	(aarch64_handle_watchpoint): Likewise.
2015-07-17 14:32:40 +01:00
Yao Qi c67ca4de63 Pass aarch64_debug_reg_state to functions
Some functions on handling HW watchpoint in GDB and GDBserver looks the
same except the code getting debug register state from current inferior.
In GDB, we get debug register state like this:

  state = aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));

while in GDBserver, we get debug register state like this:

  state = aarch64_get_debug_reg_state ();

This patch is to move two lines above out of some functions, and pass
aarch64_debug_reg_state to these functions, in this way, these functions
are the same, and can be moved to a common place.

gdb:

2015-07-17  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_handle_breakpoint): Add argument
	state and don't call aarch64_get_debug_reg_state.  All callers
	update.
	(aarch64_linux_insert_hw_breakpoint): Call
	aarch64_get_debug_reg_state earlier.
	(aarch64_linux_remove_hw_breakpoint): Likewise.
	(aarch64_handle_aligned_watchpoint): Add argument state and
	don't call aarch64_get_debug_reg_state.  All callers update.
	(aarch64_handle_unaligned_watchpoint): Likewise.
	(aarch64_handle_watchpoint): Add argument state.
	(aarch64_linux_insert_watchpoint): Call aarch64_get_debug_reg_state
	earlier.
	(aarch64_linux_remove_watchpoint): Likewise.

gdb/gdbserver:

2015-07-17  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_handle_breakpoint): Add argument state
	and don't aarch64_get_debug_reg_state.  All callers update.
	(aarch64_handle_aligned_watchpoint): Likewise.
	(aarch64_handle_unaligned_watchpoint): Likewise.
	(aarch64_handle_watchpoint): Likewise.
	(aarch64_insert_point): Call aarch64_get_debug_reg_state earlier.
	(aarch64_remove_point): Likewise.
2015-07-17 14:32:40 +01:00
Yao Qi 25abf97969 Use debug_printf to print debug message
Some functions in aarch64-linux-nat.c and linux-aarch64-low.c looks
the same except for the code printing debug message.  In GDB, we use
fprintf_unfiltered (gdb_stdlog, ...) while in GDBserver, we use
fprintf (stderr, ...).  This patch is to change them to use debug_printf
so that these functions are the same, and I can move them to a common
place in the following patch.

gdb:

2015-07-17  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_show_debug_reg_state): Use
	debug_printf.
	(aarch64_handle_unaligned_watchpoint): Likewise.

gdb/gdbserver:

2015-07-17  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_show_debug_reg_state): Use
	debug_printf.
	(aarch64_handle_unaligned_watchpoint): Likewise.
2015-07-17 14:32:40 +01:00
Yao Qi 2ecd81c23c int -> enum target_hw_bp_type in aarch64-linux-nat.c
This patch is to use 'enum target_hw_bp_type' instead of int for
breakpoint type, in order to make some functions in GDB and
GDBserver looks similar.

gdb:

2015-07-17  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_dr_state_insert_one_point): Change
	argument type's type to 'enum target_hw_bp_type'.
	(aarch64_dr_state_remove_one_point): Likewise.
	(aarch64_handle_breakpoint): Likewise.
	(aarch64_linux_insert_hw_breakpoint): Likewise.
	(aarch64_linux_remove_hw_breakpoint): Likewise.
	(aarch64_handle_aligned_watchpoint): Likewise.
2015-07-17 14:32:40 +01:00
Yao Qi e53b69389a Call ptid_get_pid instead of get_thread_id in aarch64_linux_get_debug_reg_capacity
aarch64_linux_get_debug_reg_capacity is called by
aarch64_linux_child_post_startup_inferior, and argument ptid is created in
inf-ptrace.c:inf_ptrace_create_inferior,

  /* On some targets, there must be some explicit actions taken after
     the inferior has been started up.  */
  target_post_startup_inferior (pid_to_ptid (pid));

so in aarch64_linux_get_debug_reg_capacity, we can get pid by ptid_get_pid,
and don't need to use get_thread_id.

gdb:

2015-07-17  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_get_debug_reg_capacity): Call
	ptid_get_pid instead of get_thread_id.
2015-07-17 14:07:18 +01:00
Yao Qi 6a49a997b4 Fix using uninitialised values
We did a code refacotr here
https://sourceware.org/ml/gdb-patches/2013-11/msg00063.html

>	(get_current_thread): New function, factored out from ...
>	(add_current_inferior_and_thread): ... this.  Adjust.
>
>@@ -3332,18 +3371,8 @@ add_current_inferior_and_thread (char *wait_status)
>
>   inferior_ptid = null_ptid;
>
>-  /* Now, if we have thread information, update inferior_ptid.  First
>-     if we have a stop reply handy, maybe it's a T stop reply with a
>-     "thread" register we can extract the current thread from.  If
>-     not, ask the remote which is the current thread, with qC.  The
>-     former method avoids a roundtrip.  Note we don't use
>-     remote_parse_stop_reply as that makes use of the target
>-     architecture, which we haven't yet fully determined at this
>-     point.  */
>-  if (wait_status != NULL)
>-    ptid = stop_reply_extract_thread (wait_status);
>-  if (ptid_equal (ptid, null_ptid))
>-    ptid = remote_current_thread (inferior_ptid);
>+  /* Now, if we have thread information, update inferior_ptid.  */
>+  ptid = get_current_thread (wait_status);

but after the refactor, local variable ptid is used without
initialisation.  However, before this change, ptid is initialised to
null_ptid.  This error can be found by valgrind too...

==3298==    at 0x6B99BA: ptid_equal (ptid.c:80)
==3298==    by 0x4C67FF: get_current_thread (remote.c:3484)
==3298==    by 0x4C6951: add_current_inferior_and_thread (remote.c:3511)
==3298==    by 0x4C762C: extended_remote_create_inferior (remote.c:8506)
==3298==    by 0x5A5312: run_command_1 (infcmd.c:606)
==3298==    by 0x68B4FB: execute_command (top.c:463)
==3298==    by 0x5C7214: command_handler (event-top.c:494)
==3298==    by 0x5C78A3: command_line_handler (event-top.c:692)
==3298==    by 0x6DEB57: rl_callback_read_char (callback.c:220)
==3298==    by 0x5C7278: rl_callback_read_char_wrapper (event-top.c:171)
==3298==    by 0x5C72C2: stdin_event_handler (event-top.c:432)
==3298==    by 0x5C6194: gdb_wait_for_event (event-loop.c:834)

This patch initialises local variable ptid to null in get_current_thread.
We don't need to initialise ptid in add_current_inferior_and_thread,
so this patch also removes the ptid initialisation.

gdb:

2015-07-17  Yao Qi  <yao.qi@linaro.org>

	* remote.c (get_current_thread): Initialise ptid to null_ptid.
	(add_current_inferior_and_thread): Don't initialise ptid.
2015-07-17 12:14:59 +01:00
Doug Evans 6bcb1f97b1 stabs.texinfo: @include gdb-cfg.texi.
gdb/doc/ChangeLog:

	* stabs.texinfo: @include gdb-cfg.texi.
2015-07-16 09:48:03 -07:00
Jan Kratochvil 775a3298dc Fix gdb.arch/i386-biarch-core.exp FAIL on i386.
This new test fails on i686 buildbot slaves,

(gdb) core-file /home/gdb-buildbot-2/fedora-x86-64-2/fedora-i686/build/gdb/testsuite/gdb.arch/i386-biarch-core.core
"/home/gdb-buildbot-2/fedora-x86-64-2/fedora-i686/build/gdb/testsuite/gdb.arch/i386-biarch-core.core"
is not a core dump: File format not recognized
(gdb) FAIL: gdb.arch/i386-biarch-core.exp: core-file

There are two problems:

(1) The testcase did not really test if elf64-i386 is supported by GDB (BFD).
That was OK for a Fedora testcase but I forgot about it when submitting it
upstream.

I haven't really verified if the GNU target is elf64-little but it seems so,
no other one seems suitable from:
	elf32-x86-64
	elf64-big
	elf64-k1om
	elf64-l1om
	elf64-little
	elf64-x86-64
	pei-x86-64

(2) The output of the "core-file" command itself can be arbitrary as the
elf64-i386 file with x86_64 registers is really broken; but that does not
matter much, important is the following test whether core file memory is
readable.
	./configure --enable-64-bit-bfd
	(gdb) core-file /home/jkratoch/redhat/gdb-test-build32-plus64/gdb/testsuite/gdb.arch/i386-biarch-core.core^M
	warning: Couldn't find general-purpose registers in core file.^M
	Failed to read a valid object file image from memory.^M
	warning: Couldn't find general-purpose registers in core file.^M
	#0  <unavailable> in ?? ()^M
	(gdb) FAIL: gdb.arch/i386-biarch-core.exp: core-file
	x/i 0x400078^M
	   0x400078:    hlt    ^M
	(gdb) PASS: gdb.arch/i386-biarch-core.exp: .text is readable

I do not know much dejagnu but I expect 'istarget' tests against the site.exp
'target_triplet' content which is set to the primary GDB target
(--target=...).

GDB is normally never configured for primary target elf64-i386, I think BFD
does not know such explicit target, it gets recognized as elf64-little.

In fact many testfiles of the GDB testsuite are wrong as they require
'istarget' (therefore primary GDB target) even for just loading arch specific
files which would be sufficient with secondary target (--enable-targets=...)
support.

This my new patch removes this 'istarget' check as it is IMO unrelated to what
we need to test.  Although you are right we do 'x/i' and test for 'hlt' so
I think we should test also for available 'set architecture i386'.
We could also test by 'x/bx' instead of 'x/i' to avoid such additional
test/requirement.

This testcase comes from a different bug from 2009:
	https://bugzilla.redhat.com/show_bug.cgi?id=457187
	http://pkgs.fedoraproject.org/cgit/gdb.git/commit/?id=94cd124608bf0dd359cb48a710800d72c21b30c3

That bug has been fixed in the meantime but the same testcase was reproducing
this new different bug - internal error regression - so I submitted it.

We can remove the "x/bx $address" test but it was useful for the previous bug
from 2009 as that time the internal error regression did not happen, just the
core file was not recognized (which would not be detected by the proposed
ignoring of the "core-file" command output) and so the core file was not
available.  That can be tested by the "x/bx $address" test.

gdb/testsuite/ChangeLog
2015-07-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.arch/i386-biarch-core.exp: Replace istarget
	by "complete set gnutarget". Remove expectation for the "core-file"
	command.
2015-07-16 18:01:22 +02:00
Pierre Langlois 4bcddaceb0 [AArch64] Mark single precision pseudo registers unavailable if invalid
I noticed two failure in gdb.trace/mi-trace-frame-collected.exp:

FAIL: gdb.trace/mi-trace-frame-collected.exp: live:
  -trace-frame-collected (register)
FAIL: gdb.trace/mi-trace-frame-collected.exp: tfile:
  -trace-frame-collected (register)

In these cases, we are not collecting registers so the MI command
-trace-frame-collected should only give us the value of the PC.
However, it also gives us all of the single precision pseudo registers,
initialized with 0x0.

We can reproduce this error by simply issuing the
'maint print cooked-register' when no inferior is connected:

~~~
...
(gdb) maint print cooked-register
 Name         Nr  Rel Offset    Size  Type            Cooked value
 x0            0    0      0       8 long            <unavailable>
 x1            1    1      8       8 long            <unavailable>
 ...
 d30         130   62   1540       8 *1              <unavailable>
 d31         131   63   1548       8 *1              <unavailable>
 s0          132   64   1556       4 *1              0x00000000
 s1          133   65   1560       4 *1              0x00000000
 s2          134   66   1564       4 *1              0x00000000
 ...
 s28         160   92   1668       4 *1              0x00000000
 s29         161   93   1672       4 *1              0x00000000
 s30         162   94   1676       4 *1              0x00000000
 s31         163   95   1680       4 *1              0x00000000
 h0          164   96   1684       2 *1              <unavailable>
 h1          165   97   1686       2 *1              <unavailable>
 h2          166   98   1688       2 *1              <unavailable>
 ...
~~~

It turns out GDB does not check if S registers are valid before returning
a value for them.  It should return <unavailable> in this case.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_pseudo_read_value): Mark S register as
	unavailable if invalid.
2015-07-16 10:16:14 +01:00
Jan Kratochvil db1ff28b60 Revert the previous 7 commits of: Validate binary before use
ddc98fbf2f Create empty nat/linux-maps.[ch] and common/target-utils.[ch]
6e5b4429db Move gdb_regex* to common/
f7af1fcd75 Prepare linux_find_memory_regions_full & co. for move
9904185cfd Move linux_find_memory_regions_full & co.
700ca40f6f gdbserver build-id attribute generator
ca5268b6be Validate symbol file using build-id
0a94970d66 Tests for validate symbol file using build-id

gdb/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Revert the previous 6 commits:
	Create empty nat/linux-maps.[ch] and common/target-utils.[ch].
	Move gdb_regex* to common/
	Prepare linux_find_memory_regions_full & co. for move
	Move linux_find_memory_regions_full & co.
	gdbserver build-id attribute generator
	Validate symbol file using build-id

gdb/gdbserver/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Revert the previous 3 commits:
	Move gdb_regex* to common/
	Move linux_find_memory_regions_full & co.
	gdbserver build-id attribute generator

gdb/doc/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Revert the previous 2 commits:
	gdbserver build-id attribute generator
	Validate symbol file using build-id

gdb/testsuite/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Revert the previous commit:
	Tests for validate symbol file using build-id.
2015-07-15 20:27:32 +02:00
Jan Kratochvil 0a94970d66 Tests for validate symbol file using build-id
New testcase.

gdb/testsuite/ChangeLog
2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com

	Tests for validate symbol file using build-id.
	* gdb.base/solib-mismatch-lib.c: New file.
	* gdb.base/solib-mismatch-libmod.c: New file.
	* gdb.base/solib-mismatch.c: New file.
	* gdb.base/solib-mismatch.exp: New file.
2015-07-15 17:42:51 +02:00
Jan Kratochvil ca5268b6be Validate symbol file using build-id
Consumer part of the "build-id" attribute.

gdb/ChangeLog
2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Validate symbol file using build-id.
	* NEWS (Changes since GDB 7.10): Add 'set validate-build-id'
	and 'show validate-build-id'.  Add build-id attribute.
	* solib-darwin.c (_initialize_darwin_solib): Assign validate value.
	* solib-dsbt.c (_initialize_dsbt_solib): Ditto.
	* solib-frv.c (_initialize_frv_solib): Ditto.
	* solib-spu.c (set_spu_solib_ops): Ditto.
	* solib-svr4.c: Include rsp-low.h.
	(NOTE_GNU_BUILD_ID_NAME): New define.
	(svr4_validate): New function.
	(svr4_copy_library_list): Duplicate field build_id.
	(library_list_start_library): Parse 'build-id' attribute.
	(svr4_library_attributes): Add 'build-id' attribute.
	(_initialize_svr4_solib): Assign validate value.
	* solib-target.c (solib.h): Include.
	(_initialize_solib_target): Assign validate value.
	* solib.c (validate_build_id, show_validate_build_id): New.
	(solib_map_sections): Use ops->validate.
	(clear_so): Free build_id.
	(default_solib_validate): New function.
	(_initialize_solib): Add "validate-build-id".
	* solib.h (default_solib_validate): New declaration.
	* solist.h (struct so_list): New fields 'build_idsz' and 'build_id'.
	(target_so_ops): New field 'validate'.

gdb/doc/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.texinfo (Files): Add 'set validate-build-id'
	and 'show validate-build-id'.
2015-07-15 17:42:07 +02:00
Jan Kratochvil 700ca40f6f gdbserver build-id attribute generator
Producer part of the new "build-id" XML attribute.

gdb/ChangeLog
2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	gdbserver build-id attribute generator.
	* features/library-list-svr4.dtd (library-list-svr4): New
	'build-id' attribute.

gdb/doc/ChangeLog
2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	gdbserver build-id attribute generator.
	* gdb.texinfo (Library List Format for SVR4 Targets): Add
	'build-id' in description, example, new attribute in dtd.

gdb/gdbserver/ChangeLog
2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	gdbserver build-id attribute generator.
	* linux-low.c (nat/linux-maps.h, search.h, rsp-low.h): Include.
	(ElfXX_Ehdr, ElfXX_Phdr, ElfXX_Nhdr): New.
	(ELFXX_FLD, ELFXX_SIZEOF, ELFXX_ROUNDUP, BUILD_ID_INVALID): New.
	(find_phdr): New.
	(get_dynamic): Use find_pdhr to traverse program headers.
	(struct mapping_entry, mapping_entry_s, free_mapping_entry_vec)
	(compare_mapping_entry_range, struct find_memory_region_callback_data)
	(read_build_id, find_memory_region_callback, lrfind_mapping_entry)
	(get_hex_build_id): New.
	(linux_qxfer_libraries_svr4): Add optional build-id attribute
	to reply XML document.
2015-07-15 17:41:18 +02:00
Jan Kratochvil 9904185cfd Move linux_find_memory_regions_full & co.
This should be just a move with no changes.

gdb/ChangeLog
2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Move linux_find_memory_regions_full & co.
	* linux-tdep.c (nat/linux-maps.h): Include.
	(gdb_regex.h): Remove the include.
	(enum filterflags, struct smaps_vmflags, read_mapping, decode_vmflags)
	(mapping_is_anonymous_p, dump_mapping_p): Moved to nat/linux-maps.c.
	(linux_find_memory_region_ftype): Moved typedef to nat/linux-maps.h.
	(linux_find_memory_regions_full): Moved definition to nat/linux-maps.c.
	* nat/linux-maps.c: Include ctype.h, target/target-utils.h, gdb_regex.h
	and target/target.h.
	(struct smaps_vmflags, read_mapping, decode_vmflags)
	(mapping_is_anonymous_p, dump_mapping_p): Move from linux-tdep.c.
	(linux_find_memory_regions_full): Move from linux-tdep.c.
	* nat/linux-maps.h (read_mapping): New declaration.
	(linux_find_memory_region_ftype, enum filterflags): Moved from
	linux-tdep.c.
	(linux_find_memory_regions_full): New declaration.
	* target.c (target/target-utils.h): Include.
	(read_alloc_pread_ftype): Moved typedef to target/target-utils.h.
	(read_alloc, read_stralloc_func_ftype, read_stralloc): Moved
	definitions to target/target-utils.c.
	* target.h (target_fileio_read_stralloc): Move it to target/target.h.
	* target/target-utils.c (read_alloc, read_stralloc): Move definitions
	from target.c.
	* target/target-utils.h (read_alloc_pread_ftype): New typedef.
	(read_alloc): New declaration.
	(read_stralloc_func_ftype): New typedef.
	(read_stralloc): New declaration.
	* target/target.h (target_fileio_read_stralloc): Move it from target.h.

gdb/gdbserver/ChangeLog
2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	* target.c: Include target/target-utils.h and fcntl.h.
	(target_fileio_read_stralloc_1_pread, target_fileio_read_stralloc_1)
	(target_fileio_read_stralloc): New functions.
2015-07-15 17:40:38 +02:00
Jan Kratochvil f7af1fcd75 Prepare linux_find_memory_regions_full & co. for move
Prepare code for move into gdb/common/.

gdb/ChangeLog
2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Prepare linux_find_memory_regions_full & co. for move.
	* linux-tdep.c (linux_find_memory_region_ftype): Comment.
	(linux_find_memory_regions_full): Change signature and prepare
	for moving to linux-maps.
	(linux_find_memory_regions_data): Rename field 'obfd' to 'data'.
	(linux_find_memory_regions_thunk): New.
	(linux_find_memory_regions_thunk): Use 'data' field instead of 'obfd'.
	(linux_find_memory_regions_gdb): New.
	(linux_find_memory_regions): Rename argument 'obfd' to 'func_data'.
	(linux_make_mappings_corefile_notes): Use
	linux_find_memory_regions_gdb.
	* target.c (read_alloc_pread_ftype): New typedef.
	(target_fileio_read_alloc_1_pread): New function.
	(read_alloc): Refactor from target_fileio_read_alloc_1.
	(read_stralloc_func_ftype): New typedef.
	(target_fileio_read_alloc_1): New implementation. Use read_alloc.
	(read_stralloc): Refactored from target_fileio_read_stralloc.
	(target_fileio_read_stralloc): New implementation, use read_stralloc.
2015-07-15 17:39:59 +02:00
Jan Kratochvil 6e5b4429db Move gdb_regex* to common/
Later patches need regex support also in gdbserver.

gdb/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (HFILES_NO_SRCDIR): Change gdb_regex.h to
	common/gdb_regex.h.
	(COMMON_OBS): Add gdb_regex.o.
	(gdb_regex.o): New.
	* common/common.m4 (GDB_AC_COMMON): Add gdb_use_included_regex,
	--without-included-regex and USE_INCLUDED_REGEX.
	* common/gdb_regex.c: New file from utils.c functions.
	* common/gdb_regex.h: Move it here from gdb_regex.h, update include
	file wrapping define name.
	* configure: Rebuilt.
	* configure.ac (gdb_use_included_regex, --without-included-regex)
	(USE_INCLUDED_REGEX): Move them to common/common.m4.
	* gdb_regex.h: Move it to common/gdb_regex.h.
	* utils.c: Remove include gdb_regex.h.
	(do_regfree_cleanup, make_regfree_cleanup, get_regcomp_error)
	(compile_rx_or_error): Move them to common/gdb_regex.c.

gdb/gdbserver/ChangeLog
2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (OBS): Add gdb_regex.o.
	(gdb_regex.o): New.
	* config.in: Rebuilt.
	* configure: Rebuilt.
2015-07-15 17:39:17 +02:00
Jan Kratochvil ddc98fbf2f Create empty nat/linux-maps.[ch] and common/target-utils.[ch]
Prepare new files for later move.

gdb/ChangeLog
2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Create empty nat/linux-maps.[ch] and common/target-utils.[ch].
	* Makefile.in (HFILES_NO_SRCDIR); Add nat/linux-maps.h,
	common/target-utils.h.
	(COMMON_OBS): Add target-utils.o.
	(linux-maps.o, target-utils.o): New.
	* target/target-utils.c: New file.
	* target/target-utils.h: New file.
	* config/i386/linux.mh (NATDEPFILES): Add linux-maps.o.
	* config/i386/linux64.mh (NATDEPFILES): Ditto.
	* nat/linux-maps.c: New file.
	* nat/linux-maps.h: New file.

gdb/gdbserver/ChangeLog
2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Create empty nat/linux-maps.[ch] and common/target-utils.[ch].
	* Makefile.in (OBS): Add target-utils.o.
	(linux-maps.o, target-utils.o): New.
	* configure.srv (srv_linux_obj): Add linux-maps.o.
2015-07-15 17:37:27 +02:00
Sandra Loosemore 03346981fe Unbreak nios2-*-linux* GDB testing.
2015-07-15  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.base/sigaltstack.exp (finish_test): Add kfail for
	nios2-*-linux*.
	* gdb.base/sigbpt.exp (stepi_out): Likewise.
	* gdb.base/siginfo.exp: Likewise.
	* gdb.base/sigstep.exp (advance, advancei): Likewise.
2015-07-15 08:34:09 -07:00
Pierre Langlois e57bb7a031 Move ChangeLog entry to gdbserver
gdb/gdbserver/ChangeLog:

	* linux-aarch64-low.c (aarch64_supports_range_stepping): New
	function, return 1.
	(the_low_target): Install it.
2015-07-15 15:03:01 +01:00
Pierre Langlois d1d0aea1ea [GDBserver][AArch64] Enable support for range stepping
gdb/gdbserver/Changelog:

	* linux-aarch64-low.c (aarch64_supports_range_stepping): New
	function, return 1.
	(the_low_target): Install it.
2015-07-15 14:58:32 +01:00
Pierre Langlois 42422cc7d6 [testsuite] Skip gdb.trace/range-stepping.exp test case if not supported
Tracepoints and range stepping are independent features.  This patch
skips the gdb.trace/range-stepping.exp test case if the target does not
support range stepping.

gdb/testsuite/ChangeLog:

	* gdb.base/range-stepping.exp (gdb_range_stepping_enabled):
	Move it to ...
	* lib/range-stepping-support.exp (gdb_range_stepping_enabled):
	... here.
	* gdb.trace/range-stepping.exp: Check that the target supports
	range stepping.
2015-07-15 14:33:32 +01:00
Markus Metzger e7b01ce03d ari, btrace: avoid unsigned long long
Fix the ARI warning about the use of unsigned long long.  We can't use
ULONGEST as this is defined unsigned long on 64-bit systems.  This will
result in a compile error when storing a pointer to an unsigned long long
structure field (declared in perf_event.h as __u64) in a ULONGEST * variable.

Use size_t to hold the buffer size inside GDB and __u64 when interfacing the
Linux kernel.

gdb/
	* nat/linux-btrace.c (perf_event_read): Change the type of DATA_HEAD.
	(perf_event_read_all): Change the type of SIZE and DATA_HEAD.
	(perf_event_read_bts): Change the type of SIZE and READ.
	(linux_enable_bts): Change the type of SIZE, PAGES, DATA_SIZE,
	and DATA_OFFSET.  Move DATA_SIZE declaration.  Restrict the buffer size
	to UINT_MAX.  Check for overflows when using DATA_HEAD from the perf
	mmap page.
	(linux_enable_pt): Change the type of PAGES and SIZE.  Restrict the
	buffer size to UINT_MAX.
	(linux_read_bts): Change the type of BUFFER_SIZE, SIZE, DATA_HEAD, and
	DATA_TAIL.
	* nat/linux-btrace.h (struct perf_event_buffer)<size, data_head>
	<last_head>: Change type.
	* common/btrace-common.h (struct btrace_dat_pt) <size>: Change type.
	* common/btrace-common.c (btrace_data_append): Change the type of
	SIZE.
	* btrace.c (parse_xml_raw): Change the type of SIZE.  Change oddness
	check.
2015-07-15 08:40:57 +02:00
Simon Marchi f168693bc9 Remove CHECK_TYPEDEF, use check_typedef instead
I think that the CHECK_TYPEDEF macro is not necessary, and even a bit
annoying.  It makes unclear the fact that the "type" variables gets
overwritten.  It has actually bitten me a few times.  I think the
following, explicit form, is better.

  type = check_typedef (type);

This patches changes all instances of CHECK_TYPEDEF for an equivalent
call to check_typedef.  The bulk of the change was done with this sed:

  sed -i 's/CHECK_TYPEDEF (\([^)]*\));/\1 = check_typedef (\1);/' <file>.c

The ChangeLog was generated using David Malcom's generate_changelog.py.
I manually fixed those places where it gets the wrong function name,
hopefully all of them.

The patch was built-tested, and I ran a few smoke tests.

gdb/ChangeLog:
	* gdbtypes.h (CHECK_TYPEDEF): Remove.
	* aarch64-tdep.c (aarch64_return_in_memory): Replace CHECK_TYPEDEF
        with check_typedef.
	* ada-lang.c (decode_constrained_packed_array_type): Likewise.
	(ada_array_length): Likewise.
	(find_parallel_type_by_descriptive_type): Likewise.
	(ada_check_typedef): Likewise.
	* arm-tdep.c (arm_return_in_memory): Likewise.
	* ax-gdb.c (gen_trace_static_fields): Likewise.
	(gen_struct_ref_recursive): Likewise.
	* c-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise.
	(variable: block COLONCOLON name): Likewise.
	(qualified_name: TYPENAME COLONCOLON name): Likewise.
	* c-lang.c (classify_type): Likewise.
	* c-typeprint.c (c_print_type): Likewise.
	(c_print_typedef): Likewise.
	(c_type_print_base): Likewise.
	* c-valprint.c (c_val_print): Likewise.
	* compile/compile-c-types.c (convert_type): Likewise.
	* compile/compile-object-load.c (get_out_value_type): Likewise.
	* completer.c (add_struct_fields): Likewise.
	(expression_completer): Likewise.
	* cp-namespace.c (cp_find_type_baseclass_by_name): Likewise.
	(cp_lookup_nested_symbol_1): Likewise.
	(cp_lookup_nested_symbol): Likewise.
	* cp-valprint.c (cp_print_value_fields): Likewise.
	(cp_print_static_field): Likewise.
	* d-valprint.c (d_val_print): Likewise.
	* eval.c (evaluate_subexp_standard): Likewise.
	(evaluate_subexp_for_sizeof): Likewise.
	* f-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise.
	* f-typeprint.c (f_type_print_base): Likewise.
	* f-valprint.c (f_val_print): Likewise.
	* gdbtypes.c (get_discrete_bounds): Likewise.
	(create_array_type_with_stride): Likewise.
	(type_name_no_tag_or_error): Likewise.
	(lookup_struct_elt_type): Likewise.
	(get_unsigned_type_max): Likewise.
	(internal_type_vptr_fieldno): Likewise.
	(set_type_vptr_fieldno): Likewise.
	(internal_type_vptr_basetype): Likewise.
	(set_type_vptr_basetype): Likewise.
        (get_vptr_fieldno): Likewise.
	(is_integral_type): Likewise.
	(is_scalar_type): Likewise.
        (is_scalar_type_recursive): Likewise.
	(distance_to_ancestor): Likewise.
	(is_unique_ancestor_worker): Likewise.
	(check_types_equal): Likewise.
	* gnu-v2-abi.c (gnuv2_value_rtti_type): Likewise.
	* gnu-v3-abi.c (gnuv3_dynamic_class): Likewise.
	(gnuv3_get_vtable): Likewise.
	(gnuv3_pass_by_reference): Likewise.
	* go-exp.y (exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY): Likewise.
	* go-lang.c (gccgo_string_p): Likewise.
	(go_classify_struct_type): Likewise.
	* go-typeprint.c (go_print_type): Likewise.
	* go-valprint.c (go_val_print): Likewise.
	* guile/scm-math.c (vlscm_binop): Likewise.
	* guile/scm-value.c (gdbscm_value_dynamic_type): Likewise.
	(gdbscm_value_to_bytevector): Likewise.
	(gdbscm_value_to_bool): Likewise.
	(gdbscm_value_to_integer): Likewise.
	(gdbscm_value_to_real): Likewise.
	* infcall.c (call_function_by_hand_dummy): Likewise.
	* infcmd.c (get_return_value): Likewise.
	* jv-lang.c (is_object_type): Likewise.
	* jv-typeprint.c (java_type_print_base): Likewise.
	* jv-valprint.c (java_print_value_fields): Likewise.
	(java_val_print): Likewise.
	* linespec.c (find_methods): Likewise.
	(collect_one_symbol): Likewise.
	* m2-typeprint.c (m2_print_type): Likewise.
	(m2_print_typedef): Likewise.
	(m2_get_discrete_bounds): Likewise.
	* m2-valprint.c (m2_print_long_set): Likewise.
	(m2_print_unbounded_array): Likewise.
	(m2_print_array_contents): Likewise.
	(m2_val_print): Likewise.
	* opencl-lang.c (opencl_print_type): Likewise.
	* p-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise.
	* p-typeprint.c (pascal_print_type): Likewise.
	(pascal_print_typedef): Likewise.
	(pascal_type_print_base): Likewise.
	* p-valprint.c (pascal_val_print): Likewise.
	(pascal_object_print_value_fields): Likewise.
	(pascal_object_print_static_field): Likewise.
	* python/py-type.c (typy_fields_items): Likewise.
	(typy_get_composite): Likewise.
	* python/py-value.c (valpy_get_dynamic_type): Likewise.
	(valpy_binop): Likewise.
	(valpy_long): Likewise.
	(valpy_float): Likewise.
	* stack.c (return_command): Likewise.
	* symtab.c (check_field): Likewise.
	(lookup_symbol_aux): Likewise.
	* tic6x-tdep.c (tic6x_return_value): Likewise.
	* typeprint.c (print_type_scalar): Likewise.
	* valarith.c (value_vector_widen): Likewise.
	* valops.c (value_cast): Likewise.
	(value_assign): Likewise.
	(do_search_struct_field): Likewise.
	(search_struct_method): Likewise.
	(find_method_list): Likewise.
	* valprint.c (val_print_scalar_type_p): Likewise.
	(valprint_check_validity): Likewise.
	(generic_val_print): Likewise.
	* value.c (unpack_double): Likewise.
	(value_primitive_field): Likewise.
	(unpack_bits_as_long): Likewise.
2015-07-14 16:42:16 -04:00
Iain Buclaw 452802827f Add support reading D modules from DWARF
Extends existing support for namespaces/modules in C++/Fortran/Java to
include language_d too.  However unlike Fortran/C++, the separator for
qualified names is a single dot.

2015-07-14  Iain Buclaw  <ibuclaw@gdcproject.org>

	* dwarf2read.c (find_slot_in_mapped_hash): Extend language support to
	also test for language_d.
	(dwarf2_compute_name): Likewise.
	(read_func_scope): Likewise.
	(read_structure_type): Likewise.
	(determine_prefix): Likewise.
	(read_import_statement): Use dot as the separator for language_d.
	(typename_concat): Likewise, but don't prefix the D main function.
2015-07-14 20:31:21 +02:00
Jan Kratochvil cfa68bae42 i386-biarch-core.exp: Fix comment typo
gdb/testsuite/ChangeLog
2015-07-14  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.arch/i386-biarch-core.exp: Fix comment typo.
2015-07-14 19:50:20 +02:00
Peter Bergner 99fe86f799 Fix build issue with nat/linux-namespaces.c.
* nat/linux-namespaces.c (setns): Rename from this ...
	(do_setns): ... to this.  Support calling setns if it exists.
	(mnsh_handle_setns): Call do_setns.
2015-07-14 10:46:16 -05:00
Pedro Alves 8ffdba260c Add test that exercises the inferior being killed while stopped under GDB
This exercises the case of the inferior disappearing while GDB is
debugging it, such as something doing "kill -9 PID" while the program
is stopped under GDB or GDBserver.  This triggered a set of internal
errors, fixed by previous patches.

gdb/testsuite/ChangeLog:
2015-07-14  Pedro Alves  <palves@redhat.com>

	* gdb.base/killed-outside.exp: New file.
	* gdb.base/killed-outside.c: New file.
2015-07-14 10:55:05 +01:00
Pedro Alves 586b02a96f gdbserver/Linux: internal error when killing a process that is already gone
If the process disappears (e.g., killed with "kill -9" from the shell)
while it was stopped under GDBserver's control, and the GDBserver
tries to kill it, GDBserver asserts:

 (gdb) shell kill -9 23084
 (gdb) kill
 ...
 Killing process(es): 23084
 /home/pedro/gdb/mygit/src/gdb/gdbserver/linux-low.c:972: A problem internal to GDBserver has been detected.
 kill_wait_lwp: Assertion `res > 0' failed.
 ...

gdb/gdbserver/ChangeLog:
2015-07-14  Pedro Alves  <palves@redhat.com>

	* linux-low.c (kill_wait_lwp): Don't assert if waitpid fails.
	Instead, ignore ECHILD, and throw an error for other errnos.
2015-07-14 10:10:50 +01:00
Yao Qi d5131498a5 Fix attach-pie-noexec.exp fail on native-extended-gdbserver
When I examine the buildbot fails, I see this fail on
native-extended-gdbserver,

 Attaching to process 13529^M
 "target:/scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.base/attach-pie-noexec (deleted)": could not open as an executable file: No such file or directory^M
 (gdb) FAIL: gdb.base/attach-pie-noexec.exp: attach

if I run tests with board file unix, it doesn't exist,

 Attaching to process 13869^M
 /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.base/attach-pie-noexec (deleted): No such file or directory.^M
 (gdb) PASS: gdb.base/attach-pie-noexec.exp: attach

the test expects to see the period at the end of the error message,

  gdb_test "attach $testpid" "Attaching to process $testpid\r\n.*: No such file or directory\\." "attach"

however the period is missing when running with native-extended-gdbserver.

in exec.c:exec_file_attach, GDB has two places may throw errors [1] and [2],

      if (load_via_target)
	{
	  ...
	}
      else
	{
 	  ...
	  if (scratch_chan < 0)
	    perror_with_name (filename);  <--- [1]
	}

	...
      if (!exec_bfd)
	{
	  error (_("\"%s\": could not open as an executable file: %s"), <-- [2]
		 scratch_pathname, bfd_errmsg (bfd_get_error ()));
	}

perror_with_name [1] append a period at the end of error message,
but error [2] doesn't.  This fix is to add a period at the end of the
error message.  Note that this fail is shown up on 7.9 release as well.

gdb:

2015-07-13  Yao Qi  <yao.qi@linaro.org>

	* exec.c (exec_file_attach): Add period at the end of error
	message.
2015-07-13 17:14:13 +01:00
Andrew Burgess 97605e61a1 gdb/tui: Add command completion to winheight command.
Share the window name completion code from the focus command with the
winheight command, providing window name completion for the winheight
command.

gdb/ChangeLog:

	* tui/tui-win.c (window_name_completer): New function.
	(focus_completer): Call window_name_completer.  All old content
	moved into window_name_completer.
	(winheight_completer): New function.
	(_initialize_tui_win): Rename variable.  Add completer to
	winheight command.  Update doc string on winheight.
2015-07-13 15:47:06 +01:00
Sandra Loosemore 8d6dbeb44c Fix GDB breakage due to addition of new nios2 mach types in BFD.
2015-07-12  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/
	* nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Register
	all nios2 mach variants.
2015-07-12 07:13:12 -07:00
Kevin Buettner a0e28e5467 rx-tdep.c: Use target_read_code instead of target_read_memory.
This change causes the prologue scanner and the frame type scanner in
rx-tdep.c to use target_read_code() instead of target_read_memory().
This change allows these instruction scanners to operate much more
quickly due to the fact that target_read_code() can potentially read
from a cache maintained by GDB.

gdb/ChangeLog:

	* rx-tdep.c (rx_get_opcode_byte): Use target_read_code instead
	of target_read_memory.
2015-07-10 13:14:32 -07:00
Pedro Alves 58c1b36c67 gdbserver/event-loop.c: type mismatch
Building with C++ catches a buglet here:

../../../src/gdb/gdbserver/event-loop.c:205:19: warning: invalid conversion from ‘gdb_client_data {aka void*}’ to ‘void**’ [-fpermissive]
   event_ptr->data = data;
                   ^

This works in practice because gdb_client_data is a pointer already
(hence in C we get an implicit conversion), and nothing deferences the
pointer.  It's passed from client at event registration/creation time,
only to pass straight back to client callback.

Well, that and nothing in gdbserver uses the event data anyway.

gdb/gdbserver/ChangeLog:
2015-07-10  Pedro Alves  <palves@redhat.com>

	* event-loop.c (struct callback_event) <data>: Change type to
	gdb_client_data instance instead of gdb_client_data pointer.
	(append_callback_event): Adjust.
2015-07-10 19:47:17 +01:00
Jan Kratochvil 218a5a11a0 Fix testsuite regression by: Do not skip prologue for asm (.S) files
I have somehow missed gdb.asm/asm-source.exp PASS->FAIL even on x86_64.

It has no longer valid assumption that "break" breaks after the prologue even
in assembler.  So I have changed this assumption of the testfile.

gdb/testsuite/ChangeLog
2015-07-10  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.asm/asm-source.exp (f at main): Stop at gdbasm_enter.
	(n at main): New.
	* gdb.asm/asmsrc1.s: Add comment "mark: main enter".
2015-07-10 15:04:51 +02:00
Pierre Langlois 421530db90 [GDBserver][AArch64] Cleanup comments for each linux_target_ops method
This patch cleans up the comments for each linux_target_ops methods.  We
should mention which method each function implements but there is no
need to duplicate information already mentionned in the base target_ops
or linux_target_ops definitions.

gdb/gdbserver/ChangeLog:

	* linux-aarch64-low.c: Add comments for each linux_target_ops
	method.  Remove comments already covered in target_ops and
	linux_target_ops definitions.
	(the_low_target): Add comments for each unimplemented method.
2015-07-10 13:53:49 +01:00