Commit Graph

19 Commits

Author SHA1 Message Date
Joel Brobecker 32d0add0a6 Update year range in copyright notice of all files owned by the GDB project.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2015-01-01 13:32:14 +04:00
Gary Benson 0bfdf32fa1 Rename current_inferior as current_thread in gdbserver
GDB has a function named "current_inferior" and gdbserver has a global
variable named "current_inferior", but the two are not equivalent;
indeed, gdbserver does not have any real equivalent of what GDB calls
an inferior.  What gdbserver's "current_inferior" is actually pointing
to is a structure describing the current thread.  This commit renames
current_inferior as current_thread in gdbserver to clarify this.  It
also renames the function "set_desired_inferior" to "set_desired_thread"
and renames various local variables from foo_inferior to foo_thread.

gdb/gdbserver/ChangeLog:

	* inferiors.h (current_inferior): Renamed as...
	(current_thread): New variable.  All uses updated.
	* linux-low.c (get_pc): Renamed saved_inferior as saved_thread.
	(maybe_move_out_of_jump_pad): Likewise.
	(cancel_breakpoint): Likewise.
	(linux_low_filter_event): Likewise.
	(wait_for_sigstop): Likewise.
	(linux_resume_one_lwp): Likewise.
	(need_step_over_p): Likewise.
	(start_step_over): Likewise.
	(linux_stabilize_threads): Renamed save_inferior as saved_thread.
	* linux-x86-low.c (x86_linux_update_xmltarget): Likewise.
	* proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread
	and save_inferior as saved_thread.
	* regcache.c (get_thread_regcache): Renamed saved_inferior as
	saved_thread.
	(regcache_invalidate_thread): Likewise.
	* remote-utils.c (prepare_resume_reply): Likewise.
	* thread-db.c (thread_db_get_tls_address): Likewise.
	(disable_thread_event_reporting): Likewise.
	(remove_thread_event_breakpoints): Likewise.
	* tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior
	as saved_thread.
	* target.h (set_desired_inferior): Renamed as...
	(set_desired_thread): New declaration.  All uses updated.
	* server.c (myresume): Updated comment to reference thread instead
	of inferior.
	(handle_serial_event): Likewise.
	(handle_target_event): Likewise.
2014-09-16 15:57:13 +01:00
Pedro Alves 802e8e6d84 [GDBserver] Make Zx/zx packet handling idempotent.
This patch fixes hardware breakpoint regressions exposed by my fix for
"PR breakpoints/7143 - Watchpoint does not trigger when first set", at
https://sourceware.org/ml/gdb-patches/2014-03/msg00167.html

The testsuite caught them on Linux/x86_64, at least.  gdb.sum:

gdb.sum:

 FAIL: gdb.base/hbreak2.exp: next over recursive call
 FAIL: gdb.base/hbreak2.exp: backtrace from factorial(5.1)
 FAIL: gdb.base/hbreak2.exp: continue until exit at recursive next test

gdb.log:

 (gdb) next

 Program received signal SIGTRAP, Trace/breakpoint trap.
 factorial (value=4) at ../../../src/gdb/testsuite/gdb.base/break.c:113
 113       if (value > 1) {  /* set breakpoint 7 here */
 (gdb) FAIL: gdb.base/hbreak2.exp: next over recursive call

Actually, that patch just exposed a latent issue to "breakpoints
always-inserted off" mode, not really caused it.  After that patch,
GDB no longer removes breakpoints at each internal event, thus making
some scenarios behave like breakpoint always-inserted on.  The bug is
easy to trigger with always-inserted on.

The issue is that since the target-side breakpoint conditions support,
if the stub/server supports evaluating breakpoint conditions on the
target side, then GDB is sending duplicate Zx packets to the target
without removing them before, and GDBserver is not really expecting
that for Z packets other than Z0/z0.  E.g., with "set breakpoint
always-inserted on" and "set debug remote 1":

 (gdb) b main
 Sending packet: $m410943,1#ff...Packet received: 48
 Breakpoint 4 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z0,410943,1#48...Packet received: OK
                 ^^^^^^^^^^^^
 (gdb) b main
 Note: breakpoint 4 also set at pc 0x410943.
 Sending packet: $m410943,1#ff...Packet received: 48
 Breakpoint 5 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z0,410943,1#48...Packet received: OK
                 ^^^^^^^^^^^^
 (gdb) b main
 Note: breakpoints 4 and 5 also set at pc 0x410943.
 Sending packet: $m410943,1#ff...Packet received: 48
 Breakpoint 6 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z0,410943,1#48...Packet received: OK
                 ^^^^^^^^^^^^
 (gdb) del
 Delete all breakpoints? (y or n) y
 Sending packet: $Z0,410943,1#48...Packet received: OK
 Sending packet: $Z0,410943,1#48...Packet received: OK
 Sending packet: $z0,410943,1#68...Packet received: OK

And for Z1, similarly:

 (gdb) hbreak main
 Sending packet: $m410943,1#ff...Packet received: 48
 Hardware assisted breakpoint 4 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z1,410943,1#49...Packet received: OK
                 ^^^^^^^^^^^^
 Packet Z1 (hardware-breakpoint) is supported
 (gdb) hbreak main
 Note: breakpoint 4 also set at pc 0x410943.
 Sending packet: $m410943,1#ff...Packet received: 48
 Hardware assisted breakpoint 5 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z1,410943,1#49...Packet received: OK
                 ^^^^^^^^^^^^
 (gdb) hbreak main
 Note: breakpoints 4 and 5 also set at pc 0x410943.
 Sending packet: $m410943,1#ff...Packet received: 48
 Hardware assisted breakpoint 6 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028.
 Sending packet: $Z1,410943,1#49...Packet received: OK
                 ^^^^^^^^^^^^
 (gdb) del
 Delete all breakpoints? (y or n) y
 Sending packet: $Z1,410943,1#49...Packet received: OK
                 ^^^^^^^^^^^^
 Sending packet: $Z1,410943,1#49...Packet received: OK
                 ^^^^^^^^^^^^
 Sending packet: $z1,410943,1#69...Packet received: OK
                 ^^^^^^^^^^^^

So GDB sent a bunch of Z1 packets, and then when finally removing the
breakpoint, only one z1 packet was sent.  On the GDBserver side (with
monitor set debug-hw-points 1), in the Z1 case, we see:

 $ ./gdbserver :9999 ./gdbserver
 Process ./gdbserver created; pid = 8629
 Listening on port 9999
 Remote debugging from host 127.0.0.1
 insert_watchpoint (addr=410943, len=1, type=instruction-execute):
	 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
	 DR0: addr=0x410943, ref.count=1  DR1: addr=0x0, ref.count=0
	 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0
 insert_watchpoint (addr=410943, len=1, type=instruction-execute):
	 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
	 DR0: addr=0x410943, ref.count=2  DR1: addr=0x0, ref.count=0
	 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0
 insert_watchpoint (addr=410943, len=1, type=instruction-execute):
	 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
	 DR0: addr=0x410943, ref.count=3  DR1: addr=0x0, ref.count=0
	 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0
 insert_watchpoint (addr=410943, len=1, type=instruction-execute):
	 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
	 DR0: addr=0x410943, ref.count=4  DR1: addr=0x0, ref.count=0
	 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0
 insert_watchpoint (addr=410943, len=1, type=instruction-execute):
	 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
	 DR0: addr=0x410943, ref.count=5  DR1: addr=0x0, ref.count=0
	 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0
 remove_watchpoint (addr=410943, len=1, type=instruction-execute):
	 CONTROL (DR7): 00000101          STATUS (DR6): 00000000
	 DR0: addr=0x410943, ref.count=4  DR1: addr=0x0, ref.count=0
	 DR2: addr=0x0, ref.count=0  DR3: addr=0x0, ref.count=0

That's one insert_watchpoint call for each Z1 packet, and then one
remove_watchpoint call for the z1 packet.  Notice how ref.count
increased for each insert_watchpoint call, and then in the end, after
GDB told GDBserver to forget about the hardware breakpoint, GDBserver
ends with the the first debug register still with ref.count=4!  IOW,
the hardware breakpoint is left armed on the target, while on the GDB
end it's gone.  If the program happens to execute 0x410943 afterwards,
then the CPU traps, GDBserver reports the trap to GDB, and GDB not
having a breakpoint set at that address anymore, reports to the user a
spurious SIGTRAP.

This is exactly what is happening in the hbreak2.exp test, though in
that case, it's a shared library event that triggers a
breakpoint_re_set, when breakpoints are still inserted (because
nowadays GDB doesn't remove breakpoints while handling internal
events), and that recreates breakpoint locations, which likewise
forces breakpoint reinsertion and Zx packet resends...

That is a lot of bogus Zx duplication that should possibly be
addressed on the GDB side.  GDB resends Zx packets because the way to
change the target-side condition, is to resend the breakpoint to the
server with the new condition.  (That's an option in the packet: e.g.,
"Z1,410943,1;X3,220027" for "hbreak main if 0".  The packets in the
examples above are shorter because the breakpoints don't have
conditions attached).  GDB doesn't remove the breakpoint first before
reinserting it because that'd be bad for non-stop, as it'd open a
window where the inferior could miss the breakpoint.  The conditions
actually haven't changed between the resends, but GDB isn't smart
enough to realize that.

(TBC, if the target doesn't support target-side conditions, then GDB
doesn't trigger these resends (init_bp_location calls
mark_breakpoint_location_modified, and that does nothing if condition
evaluation is on the host side.  The resends are caused by the
'loc->condition_changed = condition_modified.'  line.)

But, even if GDB was made smarter, GDBserver should really still
handle the resends anyway.  So target-side conditions also aren't
really to blame.  The documentation of the Z/z packets says:

 "To avoid potential problems with duplicate packets, the operations
 should be implemented in an idempotent way."

As such, we may want to fix GDB, but we should definitely fix
GDBserver.  The fix is a prerequisite for target-side conditions on
hardware breakpoints anyway (and while at it, on watchpoints too).

GDBserver indeed already treats duplicate Z0 packets in an idempotent
way.  mem-break.c has the concept of high-level and low-level
breakpoints, somewhat similar to GDB's split of breakpoints vs
breakpoint locations, and keeps track of multiple breakpoints
referencing the same address/location, for the case of an internal
GDBserver breakpoint or a tracepoint being set at the same address as
a GDB breakpoint.  But, it only allows GDB to ever contribute one
reference to a software breakpoint location.  IOW, if gdbserver sees a
Z0 packet for the same address where it already had a GDB breakpoint
set, then GDBserver won't create another high-level GDB breakpoint.

However, mem-break.c only tracks GDB Z0 breakpoints.  The same logic
should apply to all kinds of Zx packets.  Currently, gdbserver passes
down each duplicate Zx (other than Z0) request directly to the
target->insert_point routine.  The x86 watchpoint support itself
refcounts watchpoint / hw breakpoint requests, to handle overlapping
watchpoints, and save debug registers.  But that code doesn't (and
really shouldn't) handle the duplicate requests, assuming that for
each insert there will be a corresponding remove.

So the fix is to generalize mem-break.c to track all kinds of Zx
breakpoints, and filter out duplicates.  As mentioned, this ends up
adding support for target-side conditions on hardware breakpoints and
watchpoints too (though GDB itself doesn't support the latter yet).

Probably the least obvious change in the patch is that it kind of
turns the breakpoint insert/remove APIs inside out.  Before, the
target methods were only called for GDB breakpoints.  The internal
breakpoint set/delete methods inserted memory breakpoints directly
bypassing the insert/remove target methods.  That's not good when the
target should use a debug API to set software breakpoints, instead of
relying on GDBserver patching memory with breakpoint instructions, as
is the case of NTO.

Now removal/insertion of all kinds of breakpoints/watchpoints, either
internal, or from GDB, always go through the target methods.  The
insert_point/remove_point methods no longer get passed a Z packet
type, but an internal/raw breakpoint type.  They're also passed a
pointer to the raw breakpoint itself (note that's still opaque outside
mem-break.c), so that insert_memory_breakpoint /
remove_memory_breakpoint have access to the breakpoint's shadow
buffer.  I first tried passing down a new structure based on GDB's
"struct bp_target_info" (actually with that name exactly), but then
decided against it as unnecessary complication.

As software/memory breakpoints work by poking at memory, when setting
a GDB Z0 breakpoint (but not internal breakpoints, as those can assume
the conditions are already right), we need to tell the target to
prepare to access memory (which on Linux means stop threads).  If that
operation fails, we need to return error to GDB.  Seeing an error, if
this is the first breakpoint of that type that GDB tries to insert,
GDB would then assume the breakpoint type is supported, but it may
actually not be.  So we need to check whether the type is supported at
all before preparing to access memory.  And to solve that, the patch
adds a new target->supports_z_point_type method that is called before
actually trying to insert the breakpoint.

Other than that, hopefully the change is more or less obvious.

New test added that exercises the hbreak2.exp regression in a more
direct way, without relying on a breakpoint re-set happening before
main is reached.

Tested by building GDBserver for:

 aarch64-linux-gnu
 arm-linux-gnueabihf
 i686-pc-linux-gnu
 i686-w64-mingw32
 m68k-linux-gnu
 mips-linux-gnu
 mips-uclinux
 nios2-linux-gnu
 powerpc-linux-gnu
 sh-linux-gnu
 tilegx-unknown-linux-gnu
 x86_64-redhat-linux
 x86_64-w64-mingw32

And also regression tested on x86_64 Fedora 20.

gdb/gdbserver/
2014-05-20  Pedro Alves  <palves@redhat.com>

	* linux-aarch64-low.c (aarch64_insert_point)
	(aarch64_remove_point): No longer check whether the type is
	supported here.  Adjust to new interface.
	(the_low_target): Install aarch64_supports_z_point_type as
	supports_z_point_type method.
	* linux-arm-low.c (raw_bkpt_type_to_arm_hwbp_type): New function.
	(arm_linux_hw_point_initialize): Take an enum raw_bkpt_type
	instead of a Z packet char.  Adjust.
	(arm_supports_z_point_type): New function.
	(arm_insert_point, arm_remove_point): Adjust to new interface.
	(the_low_target): Install arm_supports_z_point_type.
	* linux-crisv32-low.c (cris_supports_z_point_type): New function.
	(cris_insert_point, cris_remove_point): Adjust to new interface.
	Don't check whether the type is supported here.
	(the_low_target): Install cris_supports_z_point_type.
	* linux-low.c (linux_supports_z_point_type): New function.
	(linux_insert_point, linux_remove_point): Adjust to new interface.
	* linux-low.h (struct linux_target_ops) <insert_point,
	remove_point>: Take an enum raw_bkpt_type instead of a char.  Add
	raw_breakpoint pointer parameter.
	<supports_z_point_type>: New method.
	* linux-mips-low.c (mips_supports_z_point_type): New function.
	(mips_insert_point, mips_remove_point): Adjust to new interface.
	Use mips_supports_z_point_type.
	(the_low_target): Install mips_supports_z_point_type.
	* linux-ppc-low.c (the_low_target): Install NULL as
	supports_z_point_type method.
	* linux-s390-low.c (the_low_target): Install NULL as
	supports_z_point_type method.
	* linux-sparc-low.c (the_low_target): Install NULL as
	supports_z_point_type method.
	* linux-x86-low.c (x86_supports_z_point_type): New function.
	(x86_insert_point): Adjust to new insert_point interface.  Use
	insert_memory_breakpoint.  Adjust to new
	i386_low_insert_watchpoint interface.
	(x86_remove_point): Adjust to remove_point interface.  Use
	remove_memory_breakpoint.  Adjust to new
	i386_low_remove_watchpoint interface.
	(the_low_target): Install x86_supports_z_point_type.
	* lynx-low.c (lynx_target_ops): Install NULL as
	supports_z_point_type callback.
	* nto-low.c (nto_supports_z_point_type): New.
	(nto_insert_point, nto_remove_point): Adjust to new interface.
	(nto_target_ops): Install nto_supports_z_point_type.
	* mem-break.c: Adjust intro comment.
	(struct raw_breakpoint) <raw_type, size>: New fields.
	<inserted>: Update comment.
	<shlib_disabled>: Delete field.
	(enum bkpt_type) <gdb_breakpoint>: Delete value.
	<gdb_breakpoint_Z0, gdb_breakpoint_Z1, gdb_breakpoint_Z2,
	gdb_breakpoint_Z3, gdb_breakpoint_Z4>: New values.
	(raw_bkpt_type_to_target_hw_bp_type): New function.
	(find_enabled_raw_code_breakpoint_at): New function.
	(find_raw_breakpoint_at): New type and size parameters.  Use them.
	(insert_memory_breakpoint): New function, based off
	set_raw_breakpoint_at.
	(remove_memory_breakpoint): New function.
	(set_raw_breakpoint_at): Reimplement.
	(set_breakpoint): New, based on set_breakpoint_at.
	(set_breakpoint_at): Reimplement.
	(delete_raw_breakpoint): Go through the_target->remove_point
	instead of assuming memory breakpoints.
	(find_gdb_breakpoint_at): Delete.
	(Z_packet_to_bkpt_type, Z_packet_to_raw_bkpt_type): New functions.
	(find_gdb_breakpoint): New function.
	(set_gdb_breakpoint_at): Delete.
	(z_type_supported): New function.
	(set_gdb_breakpoint_1): New function, loosely based off
	set_gdb_breakpoint_at.
	(check_gdb_bp_preconditions, set_gdb_breakpoint): New functions.
	(delete_gdb_breakpoint_at): Delete.
	(delete_gdb_breakpoint_1): New function, loosely based off
	delete_gdb_breakpoint_at.
	(delete_gdb_breakpoint): New function.
	(clear_gdb_breakpoint_conditions): Rename to ...
	(clear_breakpoint_conditions): ... this.  Don't handle a NULL
	breakpoint.
	(add_condition_to_breakpoint): Make static.
	(add_breakpoint_condition): Take a struct breakpoint pointer
	instead of an address.  Adjust.
	(gdb_condition_true_at_breakpoint): Rename to ...
	(gdb_condition_true_at_breakpoint_z_type): ... this, and add
	z_type parameter.
	(gdb_condition_true_at_breakpoint): Reimplement.
	(add_breakpoint_commands): Take a struct breakpoint pointer
	instead of an address.  Adjust.
	(gdb_no_commands_at_breakpoint): Rename to ...
	(gdb_no_commands_at_breakpoint_z_type): ... this.  Add z_type
	parameter.  Return true if no breakpoint was found.  Change debug
	output.
	(gdb_no_commands_at_breakpoint): Reimplement.
	(run_breakpoint_commands): Rename to ...
	(run_breakpoint_commands_z_type): ... this.  Add z_type parameter,
	and change return type to boolean.
	(run_breakpoint_commands): New function.
	(gdb_breakpoint_here): Also check for Z1 breakpoints.
	(uninsert_raw_breakpoint): Don't try to reinsert a disabled
	breakpoint.  Go through the_target->remove_point instead of
	assuming memory breakpoint.
	(uninsert_breakpoints_at, uninsert_all_breakpoints): Uninsert
	software and hardware breakpoints.
	(reinsert_raw_breakpoint): Go through the_target->insert_point
	instead of assuming memory breakpoint.
	(reinsert_breakpoints_at, reinsert_all_breakpoints): Reinsert
	software and hardware breakpoints.
	(check_breakpoints, breakpoint_here, breakpoint_inserted_here):
	Check both software and hardware breakpoints.
	(validate_inserted_breakpoint): Assert the breakpoint is a
	software breakpoint.  Set the inserted flag to -1 instead of
	setting shlib_disabled.
	(delete_disabled_breakpoints): Adjust.
	(validate_breakpoints): Only validate software breakpoints.
	Adjust to inserted flag change.
	(check_mem_read, check_mem_write): Skip breakpoint types other
	than software breakpoints.  Adjust to inserted flag change.
	* mem-break.h (enum raw_bkpt_type): New enum.
	(raw_breakpoint, struct process_info): Forward declare.
	(Z_packet_to_target_hw_bp_type): Delete declaration.
	(raw_bkpt_type_to_target_hw_bp_type, Z_packet_to_raw_bkpt_type)
	(set_gdb_breakpoint, delete_gdb_breakpoint)
	(clear_breakpoint_conditions): New declarations.
	(set_gdb_breakpoint_at, clear_gdb_breakpoint_conditions): Delete.
	(breakpoint_inserted_here): Update comment.
	(add_breakpoint_condition, add_breakpoint_commands): Replace
	address parameter with a breakpoint pointer parameter.
	(gdb_breakpoint_here): Update comment.
	(delete_gdb_breakpoint_at): Delete.
	(insert_memory_breakpoint, remove_memory_breakpoint): Declare.
	* server.c (process_point_options): Take a struct breakpoint
	pointer instead of an address.  Adjust.
	(process_serial_event) <Z/z packets>: Use set_gdb_breakpoint and
	delete_gdb_breakpoint.
	* spu-low.c (spu_target_ops): Install NULL as
	supports_z_point_type method.
	* target.h: Include mem-break.h.
	(struct target_ops) <prepare_to_access_memory>: Update comment.
	<supports_z_point_type>: New field.
	<insert_point, remove_point>: Take an enum raw_bkpt_type argument
	instead of a char.  Also take a raw breakpoint pointer.
	* win32-arm-low.c (the_low_target): Install NULL as
	supports_z_point_type.
	* win32-i386-low.c (i386_supports_z_point_type): New function.
	(i386_insert_point, i386_remove_point): Adjust to new interface.
	(the_low_target): Install i386_supports_z_point_type.
	* win32-low.c (win32_supports_z_point_type): New function.
	(win32_insert_point, win32_remove_point): Adjust to new interface.
	(win32_target_ops): Install win32_supports_z_point_type.
	* win32-low.h (struct win32_target_ops):
	<supports_z_point_type>: New method.
	<insert_point, remove_point>: Take an enum raw_bkpt_type argument
	instead of a char.  Also take a raw breakpoint pointer.

gdb/testsuite/
2014-05-20  Pedro Alves  <palves@redhat.com>

	* gdb.base/break-idempotent.c: New file.
	* gdb.base/break-idempotent.exp: New file.
2014-05-20 18:42:30 +01:00
Doug Evans 87ce2a04c5 New gdbserver option --debug-format=timestamp.
* NEWS: Mention it.

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

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

	testsuite/
	* gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 14:17:39 -08:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Pedro Alves 3aee891821 [GDBserver] Multi-process + multi-arch
This patch makes GDBserver support multi-process + biarch.

Currently, if you're debugging more than one process at once with a
single gdbserver (in extended-remote mode), then all processes must
have the same architecture (e.g., 64-bit vs 32-bit).  Otherwise, you
see this:

Added inferior 2
[Switching to inferior 2 [<null>] (<noexec>)]
Reading symbols from /home/pedro/gdb/tests/main32...done.
Temporary breakpoint 2 at 0x4004cf: main. (2 locations)
Starting program: /home/pedro/gdb/tests/main32
warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64
warning: Architecture rejected target-supplied description
Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
... etc, etc ...

Even though the process was running a 32-bit program, GDBserver sent
back to GDB a register set in 64-bit layout.

A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a
while ago made GDB track a target_gdbarch per inferior, and as
consequence, fetch a target description per-inferior.  This patch is
the GDBserver counterpart, that makes GDBserver keep track of each
process'es XML target description and register layout.  So in the
example above, GDBserver will send the correct register set in 32-bit
layout to GDB.

A new "struct target_desc" object (tdesc for short) is added, that
holds the target description and register layout information about
each process.  Each `struct process_info' holds a pointer to a target
description.  The regcache also gains a pointer to a target
description, mainly for convenience, and parallel with GDB (and
possible future support for programs that flip processor modes).

The low target's arch_setup routines are responsible for setting the
process'es correct tdesc.  This isn't that much different to how
things were done before, except that instead of detecting the inferior
process'es architecture and calling the corresponding
init_registers_FOO routine, which would change the regcache layout
globals and recreate the threads' regcaches, the regcache.c globals
are gone, and the init_registers_$BAR routines now each initialize a
separate global struct target_desc object (one for each arch variant
GDBserver supports), and so all the init_registers_$BAR routines that
are built into GDBserver are called early at GDBserver startup time
(similarly to how GDB handles its built-in target descriptions), and
then the arch_setup routine is responsible for making
process_info->tdesc point to one of these target description globals.
The regcache module is all parameterized to get the regcache's layout
from the tdesc object instead of the old register_bytes, etc. globals.

The threads' regcaches are now created lazily.  The old scheme where
we created each of them when we added a new thread doesn't work
anymore, because we add the main thread/lwp before we see it stop for
the first time, and it is only when we see the thread stop for the
first time that we have a chance of determining the inferior's
architecture (through the_low_target.arch_setup).  Therefore when we
add the main thread we don't know which architecture/tdesc its
regcache should have.

This patch makes the gdb.multi/multi-arch.exp test now pass against
(extended-remote) GDBserver.  It currently fails, without this patch.

The IPA also uses the regcache, so it gains a new global struct
target_desc pointer, which points at the description of the process it
is loaded in.

Re. the linux-low.c & friends changes.  Since the register map
etc. may differ between processes (64-bit vs 32-bit) etc., the
linux_target_ops num_regs, regmap and regset_bitmap data fields are no
longer sufficient.  A new method is added in their place that returns
a pointer to a new struct that includes all info linux-low.c needs to
access registers of the current inferior.

The patch/discussion that originally introduced
linux-low.c:disabled_regsets mentions that the disabled_regsets set
may be different per mode (in a biarch setup), and indeed that is
cleared whenever we start a new (first) inferior, so that global is
moved as well behind the new `struct regs_info'.

On the x86 side:

I simply replaced the i387-fp.c:num_xmm_registers global with a check
for 64-bit or 32-bit process, which is equivalent to how the global
was set.  This avoided coming up with some more general mechanism that
would work for all targets that use this module (GNU/Linux, Windows,
etc.).

Tested:

  GNU/Linux IA64
  GNU/Linux MIPS64
  GNU/Linux PowerPC (Fedora 16)
  GNU/Linux s390x (Fedora 16)
  GNU/Linux sparc64 (Debian)
  GNU/Linux x86_64, -m64 and -m32 (Fedora 17)

Cross built, and smoke tested:

  i686-w64-mingw32, under Wine.
  GNU/Linux TI C6x, by Yao Qi.

Cross built but otherwise not tested:

  aarch64-linux-gnu
  arm-linux-gnu
  m68k-linux
  nios2-linux-gnu
  sh-linux-gnu
  spu
  tilegx-unknown-linux-gnu

Completely untested:

  GNU/Linux Blackfin
  GNU/Linux CRIS
  GNU/Linux CRISv32
  GNU/Linux TI Xtensa
  GNU/Linux M32R
  LynxOS
  QNX NTO

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

	* Makefile.in (OBS): Add tdesc.o.
	(IPA_OBJS): Add tdesc-ipa.o.
	(tdesc-ipa.o): New rule.
	* ax.c (gdb_eval_agent_expr): Adjust register_size call to new
	interface.
	* linux-low.c (new_inferior): Delete.
	(disabled_regsets, num_regsets): Delete.
	(linux_add_process): Adjust to set the new per-process
	new_inferior flag.
	(linux_detach_one_lwp): Adjust to call regcache_invalidate_thread.
	(linux_wait_for_lwp): Adjust.  Only call arch_setup if the event
	was a stop.  When calling arch_setup, switch the current inferior
	to the thread that got an event.
	(linux_resume_one_lwp): Adjust to call regcache_invalidate_thread.
	(regsets_fetch_inferior_registers)
	(regsets_store_inferior_registers): New regsets_info parameter.
	Adjust to use it.
	(linux_register_in_regsets): New regs_info parameter.  Adjust to
	use it.
	(register_addr, fetch_register, store_register): New usrregs_info
	parameter.  Adjust to use it.
	(usr_fetch_inferior_registers, usr_store_inferior_registers): New
	parameter regs_info.  Adjust to use it.
	(linux_fetch_registers): Get the current inferior's regs_info, and
	adjust to use it.
	(linux_store_registers): Ditto.
	[HAVE_LINUX_REGSETS] (initialize_regsets_info): New.
	(initialize_low): Don't initialize the target_regsets here.  Call
	initialize_low_arch.
	* linux-low.h (target_regsets): Delete declaration.
	(struct regsets_info): New.
	(struct usrregs_info): New.
	(struct regs_info): New.
	(struct process_info_private) <new_inferior>: New field.
	(struct linux_target_ops): Delete the num_regs, regmap, and
	regset_bitmap fields.  New field regs_info.
	[HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare.
	* i387-fp.c (num_xmm_registers): Delete.
	(i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno
	calls to new interface.
	(i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache)
	(i387_xsave_to_cache): Adjust find_regno calls to new interface.
	Infer the number of xmm registers from the regcache's target
	description.
	* i387-fp.h (num_xmm_registers): Delete.
	* inferiors.c (add_thread): Don't install the thread's regcache
	here.
	* proc-service.c (gregset_info): Fetch the current inferior's
	regs_info.  Adjust to use it.
	* regcache.c: Include tdesc.h.
	(register_bytes, reg_defs, num_registers)
	(gdbserver_expedite_regs): Delete.
	(get_thread_regcache): If the thread doesn't have a regcache yet,
	create one, instead of aborting gdbserver.
	(regcache_invalidate_one): Rename to ...
	(regcache_invalidate_thread): ... this.
	(regcache_invalidate_one): New.
	(regcache_invalidate): Only invalidate registers of the current
	process.
	(init_register_cache): Add target_desc parameter, and use it.
	(new_register_cache): Ditto.  Assert the target description has a
	non zero registers_size.
	(regcache_cpy): Add assertions.  Adjust.
	(realloc_register_cache, set_register_cache): Delete.
	(registers_to_string, registers_from_string): Adjust.
	(find_register_by_name, find_regno, find_register_by_number)
	(register_cache_size): Add target_desc parameter, and use it.
	(free_register_cache_thread, free_register_cache_thread_one)
	(regcache_release, register_cache_size): New.
	(register_size): Add target_desc parameter, and use it.
	(register_data, supply_register, supply_register_zeroed)
	(supply_regblock, supply_register_by_name, collect_register)
	(collect_register_as_string, collect_register_by_name): Adjust.
	* regcache.h (struct target_desc): Forward declare.
	(struct regcache) <tdesc>: New field.
	(init_register_cache, new_register_cache): Add target_desc
	parameter.
	(regcache_invalidate_thread): Declare.
	(regcache_invalidate_one): Delete declaration.
	(regcache_release): Declare.
	(find_register_by_number, register_cache_size, register_size)
	(find_regno): Add target_desc parameter.
	(gdbserver_expedite_regs, gdbserver_xmltarget): Delete
	declarations.
	* remote-utils.c: Include tdesc.h.
	(outreg, prepare_resume_reply): Adjust.
	* server.c: Include tdesc.h.
	(gdbserver_xmltarget): Delete declaration.
	(get_features_xml, process_serial_event): Adjust.
	* server.h [IN_PROCESS_AGENT] (struct target_desc): Forward
	declare.
	(struct process_info) <tdesc>: New field.
	(ipa_tdesc): Declare.
	* tdesc.c: New file.
	* tdesc.h: New file.
	* tracepoint.c: Include tdesc.h.
	[IN_PROCESS_AGENT] (ipa_tdesc): Define.
	(get_context_regcache): Adjust to pass ipa_tdesc down.
	(do_action_at_tracepoint): Adjust to get the register cache size
	from the context regcache's description.
	(traceframe_walk_blocks): Adjust to get the register cache size
	from the current trace frame's description.
	(traceframe_get_pc): Adjust to get current trace frame's
	description and pass it down.
	(gdb_collect): Adjust to get the register cache size from the
	IPA's description.
	* linux-amd64-ipa.c (tdesc_amd64_linux): Declare.
	(gdbserver_xmltarget): Delete.
	(initialize_low_tracepoint): Set the ipa's target description.
	* linux-i386-ipa.c (tdesc_i386_linux): Declare.
	(initialize_low_tracepoint): Set the ipa's target description.
	* linux-x86-low.c: Include tdesc.h.
	[__x86_64__] (is_64bit_tdesc): New.
	(ps_get_thread_area, x86_get_thread_area): Use it.
	(i386_cannot_store_register): Rename to ...
	(x86_cannot_store_register): ... this.  Use is_64bit_tdesc.
	(i386_cannot_fetch_register): Rename to ...
	(x86_cannot_fetch_register): ... this.  Use is_64bit_tdesc.
	(x86_fill_gregset, x86_store_gregset): Adjust register_size calls
	to new interface.
	(target_regsets): Rename to ...
	(x86_regsets): ... this.
	(x86_get_pc, x86_set_pc): Adjust register_size calls to new
	interface.
	(x86_siginfo_fixup): Use is_64bit_tdesc.
	[__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux)
	(tdesc_x32_avx_linux, tdesc_x32_linux)
	(tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux):
	Declare.
	(x86_linux_update_xmltarget): Delete.
	(I386_LINUX_XSAVE_XCR0_OFFSET): Define.
	(have_ptrace_getfpxregs, have_ptrace_getregset): New.
	(AMD64_LINUX_USER64_CS): New.
	(x86_linux_read_description): New, based on
	x86_linux_update_xmltarget.
	(same_process_callback): New.
	(x86_arch_setup_process_callback): New.
	(x86_linux_update_xmltarget): New.
	(x86_regsets_info): New.
	(amd64_linux_regs_info): New.
	(i386_linux_usrregs_info): New.
	(i386_linux_regs_info): New.
	(x86_linux_regs_info): New.
	(x86_arch_setup): Reimplement.
	(x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc.
	(x86_emit_ops): Ditto.
	(the_low_target): Adjust.  Install x86_linux_regs_info,
	x86_cannot_fetch_register, and x86_cannot_store_register.
	(initialize_low_arch): New.
	* linux-ia64-low.c (tdesc_ia64): Declare.
	(ia64_fetch_register): Adjust.
	(ia64_usrregs_info, regs_info): New globals.
	(ia64_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-sparc-low.c (tdesc_sparc64): Declare.
	(sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack):
	Adjust.
	(sparc_arch_setup): New function.
	(sparc_regsets_info, sparc_usrregs_info, regs_info): New globals.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l)
	(tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l)
	(tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l)
	(tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l)
	(tdesc_powerpc_64l, tdesc_powerpc_altivec64l)
	(tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l)
	(tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l)
	(tdesc_powerpc_isa205_vsx64l): Declare.
	(ppc_cannot_store_register, ppc_collect_ptrace_register)
	(ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc)
	(ppc_set_pc, ppc_get_hwcap): Adjust.
	(ppc_usrregs_info): Forward declare.
	(!__powerpc64__) ppc_regmap_adjusted: New global.
	(ppc_arch_setup): Adjust to the current process'es target
	description.
	(ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset)
	(ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse)
	(ppc_store_evrregset): Adjust.
	(target_regsets): Rename to ...
	(ppc_regsets): ... this, and make static.
	(ppc_usrregs_info, ppc_regsets_info, regs_info): New globals.
	(ppc_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1)
	(tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1)
	(tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1)
	(tdesc_s390x_linux64v2): Declare.
	(s390_collect_ptrace_register, s390_supply_ptrace_register)
	(s390_fill_gregset, s390_store_last_break): Adjust.
	(target_regsets): Rename to ...
	(s390_regsets): ... this, and make static.
	(s390_get_pc, s390_set_pc): Adjust.
	(s390_get_hwcap): New target_desc parameter, and use it.
	[__s390x__] (have_hwcap_s390_high_gprs): New global.
	(s390_arch_setup): Adjust to set the current process'es target
	description.  Don't adjust the regmap.
	(s390_usrregs_info, s390_regsets_info, regs_info): New globals.
	[__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264)
	(regs_info_3264): New globals.
	(s390_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux)
	(tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare.
	[__mips64] (init_registers_mips_linux)
	(init_registers_mips_dsp_linux): Delete defines.
	[__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines.
	(have_dsp): New global.
	(mips_read_description): New, based on mips_arch_setup.
	(mips_arch_setup): Reimplement.
	(get_usrregs_info): New function.
	(mips_cannot_fetch_register, mips_cannot_store_register)
	(mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset)
	(mips_fill_fpregset, mips_store_fpregset): Adjust.
	(target_regsets): Rename to ...
	(mips_regsets): ... this, and make static.
	(mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info)
	(dsp_regs_info, regs_info): New globals.
	(mips_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt)
	(tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon):
	Declare.
	(arm_fill_vfpregset, arm_store_vfpregset): Adjust.
	(arm_read_description): New, with bits factored from
	arm_arch_setup.
	(arm_arch_setup): Reimplement.
	(target_regsets): Rename to ...
	(arm_regsets): ... this, and make static.
	(arm_regsets_info, arm_usrregs_info, regs_info): New globals.
	(arm_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-m68k-low.c (tdesc_m68k): Declare.
	(target_regsets): Rename to ...
	(m68k_regsets): ... this, and make static.
	(m68k_regsets_info, m68k_usrregs_info, regs_info): New globals.
	(m68k_regs_info): New function.
	(m68k_arch_setup): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-sh-low.c (tdesc_sharch): Declare.
	(target_regsets): Rename to ...
	(sh_regsets): ... this, and make static.
	(sh_regsets_info, sh_usrregs_info, regs_info): New globals.
	(sh_regs_info, sh_arch_setup): New functions.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-bfin-low.c (tdesc_bfin): Declare.
	(bfin_arch_setup): New function.
	(bfin_usrregs_info, regs_info): New globals.
	(bfin_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-cris-low.c (tdesc_cris): Declare.
	(cris_arch_setup): New function.
	(cris_usrregs_info, regs_info): New globals.
	(cris_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-cris-low.c (tdesc_crisv32): Declare.
	(cris_arch_setup): New function.
	(cris_regsets_info, cris_usrregs_info, regs_info): New globals.
	(cris_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-m32r-low.c (tdesc_m32r): Declare.
	(m32r_arch_setup): New function.
	(m32r_usrregs_info, regs_info): New globals.
	(m32r_regs_info): Adjust.
	(initialize_low_arch): New function.
	* linux-tic6x-low.c (tdesc_tic6x_c64xp_linux)
	(tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare.
	(tic6x_usrregs_info): Forward declare.
	(tic6x_read_description): New function, based on ...
	(tic6x_arch_setup): ... this.  Reimplement.
	(target_regsets): Rename to ...
	(tic6x_regsets): ... this, and make static.
	(tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals.
	(tic6x_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-xtensa-low.c (tdesc_xtensa): Declare.
	(xtensa_fill_gregset, xtensa_store_gregset): Adjust.
	(target_regsets): Rename to ...
	(xtensa_regsets): ... this, and make static.
	(xtensa_regsets_info, xtensa_usrregs_info, regs_info): New
	globals.
	(xtensa_arch_setup, xtensa_regs_info): New functions.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-nios2-low.c (tdesc_nios2_linux): Declare.
	(nios2_arch_setup): Set the current process'es tdesc.
	(target_regsets): Rename to ...
	(nios2_regsets): ... this.
	(nios2_regsets_info, nios2_usrregs_info, regs_info): New globals.
	(nios2_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
        * linux-aarch64-low.c (tdesc_aarch64): Declare.
        (aarch64_arch_setup): Set the current process'es tdesc.
        (target_regsets): Rename to ...
        (aarch64_regsets): ... this.
        (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals.
        (aarch64_regs_info): New function.
        (the_low_target): Adjust.
        (initialize_low_arch): New function.
	* linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare
	globals.
	(target_regsets): Rename to ...
	(tile_regsets): ... this.
	(tile_regsets_info, tile_usrregs_info, regs_info): New globals.
	(tile_regs_info): New function.
	(tile_arch_setup): Set the current process'es tdesc.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* spu-low.c (tdesc_spu): Declare.
	(spu_create_inferior, spu_attach): Set the new process'es tdesc.
	* win32-arm-low.c (tdesc_arm): Declare.
	(arm_arch_setup): New function.
	(the_low_target): Install arm_arch_setup instead of
	init_registers_arm.
	* win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare.
	(init_windows_x86): Rename to ...
	(i386_arch_setup): ... this.  Set `win32_tdesc'.
	(the_low_target): Adjust.
	* win32-low.c (win32_tdesc): New global.
	(child_add_thread): Don't create the thread cache here.
	(do_initial_child_stuff): Set the new process'es tdesc.
	* win32-low.h (struct target_desc): Forward declare.
	(win32_tdesc): Declare.
	* lynx-i386-low.c (tdesc_i386): Declare global.
	(lynx_i386_arch_setup): Set `lynx_tdesc'.
	* lynx-low.c (lynx_tdesc): New global.
	(lynx_add_process): Set the new process'es tdesc.
	* lynx-low.h (struct target_desc): Forward declare.
	(lynx_tdesc): Declare global.
	* lynx-ppc-low.c (tdesc_powerpc_32): Declare global.
	(lynx_ppc_arch_setup): Set `lynx_tdesc'.
	* nto-low.c (nto_tdesc): New global.
	(do_attach): Set the new process'es tdesc.
	* nto-low.h (struct target_desc): Forward declare.
	(nto_tdesc): Declare.
	* nto-x86-low.c (tdesc_i386): Declare.
	(nto_x86_arch_setup): Set `nto_tdesc'.

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

	* regformats/regdat.sh: Output #include tdesc.h.  Make globals
	static.  Output a global target description pointer.
	(init_registers_${name}): Adjust to initialize a
	target description structure.
2013-06-07 10:46:59 +00:00
Joel Brobecker 28e7fd6234 Update years in copyright notice for the GDB files.
Two modifications:
  1. The addition of 2013 to the copyright year range for every file;
  2. The use of a single year range, instead of potentially multiple
     year ranges, as approved by the FSF.
2013-01-01 06:33:28 +00:00
Pedro Alves 111217b396 2012-04-04 Pedro Alves <palves@redhat.com>
* linux-sparc-low.c (sparc_fill_gregset_to_stack)
	(sparc_store_gregset_from_stack, sparc_store_gregset)
	(sparc_breakpoint_at): Fix formatting.
2012-04-04 14:42:15 +00:00
Pedro Alves c14dfd3206 2012-03-28 Pedro Alves <palves@redhat.com>
* linux-ia64-low.c (ia64_regmap): Map IA64_EC_REGNUM to PT_AR_EC.
	(IA64_GR0_REGNUM, IA64_FR0_REGNUM)
	(IA64_FR1_REGNUM): New defines.
	(ia64_fetch_register): New.
	(the_low_target): Install it.
	* linux-low.h (struct linux_target_ops) <fetch_register>: New
	field.
	* linux-low.c (linux_fetch_registers): Try the
	the_low_target.fetch_register hook first.

	* linux-arm-low.c (the_low_target): Adjust.
	* linux-bfin-low.c (the_low_target): Adjust.
	* linux-cris-low.c (the_low_target): Adjust.
	* linux-crisv32-low.c (the_low_target): Adjust.
	* linux-m32r-low.c (the_low_target): Adjust.
	* linux-m68k-low.c (the_low_target): Adjust.
	* linux-mips-low.c (the_low_target): Adjust.
	* linux-ppc-low.c (the_low_target): Adjust.
	* linux-s390-low.c (the_low_target): Adjust.
	* linux-sh-low.c (the_low_target): Adjust.
	* linux-sparc-low.c (the_low_target): Adjust.
	* linux-tic6x-low.c (the_low_target): Adjust.
	* linux-x86-low.c (the_low_target): Adjust.
	* linux-xtensa-low.c (the_low_target): Adjust.
2012-03-28 18:30:01 +00:00
Maciej W. Rozycki 1faeff088b gdb/
* features/mips-dsp.xml: New file.
	* features/mips64-dsp.xml: New file.
	* features/mips-dsp-linux.xml: New file.
	* features/mips64-dsp-linux.xml: New file.
	* features/Makefile (WHICH): Add mips-dsp-linux and
	mips64-dsp-linux.
	(mips-dsp-expedite, mips64-dsp-expedite): New variables.
	* features/mips-dsp-linux.c: New file.
	* features/mips64-dsp-linux.c: New file.
	* regformats/mips-dsp-linux.dat: New file.
	* regformats/mips64-dsp-linux.dat: New file.
	* mips-linux-nat.c (mips_linux_register_addr): Handle DSP
	registers.
	(mips64_linux_register_addr): Likewise.
	(mips64_linux_regsets_fetch_registers): Likewise.
	(mips64_linux_regsets_store_registers): Likewise.
	(mips64_linux_fetch_registers): Update call to
	mips64_linux_regsets_fetch_registers.
	(mips64_linux_store_registers): Update call to
	mips64_linux_regsets_store_registers.
	(mips_linux_read_description): Probe for DSP registers.
	(_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux
	and initialize_tdesc_mips64_dsp_linux.
	* mips-linux-tdep.c (supply_gregset, mips64_supply_gregset):
	Remove padding of no longer used embedded register slots.
	* mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros.
	(MIPS_RESTART_REGNUM): Redefine enum value.
	* mips-tdep.c (mips_generic_reg_names): Remove trailing null
	strings.
	(mips_tx39_reg_names): Likewise.
	(mips_linux_reg_names): New array of register names for Linux
	targets.
	(mips_register_name): Check for a null pointer in
	mips_processor_reg_names and return an empty string.
	(mips_register_type): Exclude embedded registers for the IRIX
	and Linux ABIs.
	(mips_pseudo_register_type): Likewise.  Use dynamic numbers to
	refer to FP registers, LO, HI, BadVAddr, Cause and PC.  Handle
	DSP registers.
	(mips_stab_reg_to_regnum): Handle DSP accumulators.
	(mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise.
	(mips_gdbarch_init): Likewise.  Initialize internal register
	indices for the Linux ABI.  Use dynamic numbers to refer to
	registers, as applicable, while parsing the target description.
	* mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets.

	gdb/doc/
	* gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp.

	gdb/gdbserver/
	* linux-low.h (linux_target_ops): Add regset_bitmap member.
	* linux-low.c (use_linux_regsets): New macro.
	[!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise.
	[!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise.
	(linux_register_in_regsets): New function.
	(usr_fetch_inferior_registers): Skip registers covered by
	regsets.
	(usr_store_inferior_registers): Likewise.
	(usr_fetch_inferior_registers): New macro.
	(usr_store_inferior_registers): Likewise.
	(linux_fetch_registers): Handle mixed regset/non-regset targets.
	(linux_store_registers): Likewise.
	* linux-mips-low.c (init_registers_mips_dsp_linux): New
	prototype.
	(init_registers_mips64_dsp_linux): Likewise.
	(init_registers_mips_linux): New macro.
	(init_registers_mips_dsp_linux): Likewise.
	(mips_dsp_num_regs): Likewise.
	(DSP_BASE, DSP_CONTROL): New fallback macros.
	(mips_base_regs): New macro.
	(mips_regmap): Use it.  Fix the size.
	(mips_dsp_regmap): New variable.
	(mips_dsp_regset_bitmap): Likewise.
	(mips_arch_setup): New function.
	(mips_cannot_fetch_register): Use the_low_target.regmap rather
	than mips_regmap.
	(mips_cannot_store_register): Likewise.
	(the_low_target): Update .arch_setup, .num_regs and .regmap
	initializers.  Add .regset_bitmap initializer.
	* linux-arm-low.c (the_low_target): Add .regset_bitmap
	initializer.
	* linux-bfin-low.c (the_low_target): Likewise.
	* linux-cris-low.c (the_low_target): Likewise.
	* linux-crisv32-low.c (the_low_target): Likewise.
	* linux-ia64-low.c (the_low_target): Likewise.
	* linux-m32r-low.c (the_low_target): Likewise.
	* linux-m68k-low.c (the_low_target): Likewise.
	* linux-ppc-low.c (the_low_target): Likewise.
	* linux-s390-low.c (the_low_target): Likewise.
	* linux-sh-low.c (the_low_target): Likewise.
	* linux-sparc-low.c (the_low_target): Likewise.
	* linux-tic6x-low.c (the_low_target): Likewise.
	* linux-x86-low.c (the_low_target): Likewise.
	* linux-xtensa-low.c (the_low_target): Likewise.
	* configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and
	mips64-dsp-linux.o to srv_regobj.  Add mips-dsp-linux.xml,
	mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to
	srv_xmlfiles.
	* Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets.
	(mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise.

	gdb/testsuite/
	* gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS
	core registers.
2012-03-01 22:19:48 +00:00
Joel Brobecker 0b30217134 Copyright year update in most files of the GDB Project.
gdb/ChangeLog:

        Copyright year update in most files of the GDB Project.
2012-01-04 08:17:56 +00:00
Michael Snyder 493e2a69a4 2011-01-05 Michael Snyder <msnyder@msnyder-server.eng.vmware.com>
* gdbreplay.c: Shorten lines of >= 80 columns.
	* linux-low.c: Ditto.
	* linux-ppc-low.c: Ditto.
	* linux-s390-low.c: Ditto.
	* linux-sparc-low.c: Ditto.
	* linux-x86-low.c: Ditto.
	* linux-xtensa-low.c: Ditto.
	* mem-break.c: Ditto.
	* nto-low.c: Ditto.
	* regcache.h: Ditto.
	* remote-utils.c: Ditto.
	* server.c: Ditto.
	* server.h: Ditto.
	* thread-db.c: Ditto.
	* tracepoint.c: Ditto.
	* utils.c: Ditto.
	* win32-low.h: Ditto.
2011-01-06 00:14:09 +00:00
Joel Brobecker 7b6bb8daac run copyright.sh for 2011. 2011-01-01 15:34:07 +00:00
H.J. Lu 1570b33e44 Add x86 AVX support to gdbserver.
2010-04-07  H.J. Lu  <hongjiu.lu@intel.com>

	* Makefile.in (clean): Updated.
	(i386-avx.o): New.
	(i386-avx.c): Likewise.
	(i386-avx-linux.o): Likewise.
	(i386-avx-linux.c): Likewise.
	(amd64-avx.o): Likewise.
	(amd64-avx.c): Likewise.
	(amd64-avx-linux.o): Likewise.
	(amd64-avx-linux.c): Likewise.

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

	* i387-fp.c: Include "i386-xstate.h".
	(i387_xsave): New.
	(i387_cache_to_xsave): Likewise.
	(i387_xsave_to_cache): Likewise.
	(x86_xcr0): Likewise.

	* i387-fp.h (i387_cache_to_xsave): Likewise.
	(i387_xsave_to_cache): Likewise.
	(x86_xcr0): Likewise.

	* linux-arm-low.c (target_regsets): Initialize nt_type to 0.
	* linux-crisv32-low.c (target_regsets): Likewise.
	* linux-m68k-low.c (target_regsets): Likewise.
	* linux-mips-low.c (target_regsets): Likewise.
	* linux-ppc-low.c (target_regsets): Likewise.
	* linux-s390-low.c (target_regsets): Likewise.
	* linux-sh-low.c (target_regsets): Likewise.
	* linux-sparc-low.c (target_regsets): Likewise.
	* linux-xtensa-low.c (target_regsets): Likewise.

	* linux-low.c: Include <sys/uio.h>.
	(regsets_fetch_inferior_registers): Support nt_type.
	(regsets_store_inferior_registers): Likewise.
	(linux_process_qsupported): New.
	(linux_target_ops): Add linux_process_qsupported.

	* linux-low.h (regset_info): Add nt_type.
	(linux_target_ops): Add process_qsupported.

	* linux-x86-low.c: Include "i386-xstate.h", "elf/common.h"
	and <sys/uio.h>.
	(init_registers_i386_avx_linux): New.
	(init_registers_amd64_avx_linux): Likewise.
	(xmltarget_i386_linux_no_xml): Likewise.
	(xmltarget_amd64_linux_no_xml): Likewise.
	(PTRACE_GETREGSET): Likewise.
	(PTRACE_SETREGSET): Likewise.
	(x86_fill_xstateregset): Likewise.
	(x86_store_xstateregset): Likewise.
	(use_xml): Likewise.
	(x86_linux_update_xmltarget): Likewise.
	(x86_linux_process_qsupported): Likewise.
	(target_regsets): Add NT_X86_XSTATE entry and Initialize nt_type.
	(x86_arch_setup): Don't call init_registers_amd64_linux nor
	init_registers_i386_linux here.  Call
	x86_linux_update_xmltarget.
	(the_low_target): Add x86_linux_process_qsupported.

	* server.c (handle_query): Call target_process_qsupported.

	* target.h (target_ops): Add process_qsupported.
	(target_process_qsupported): New.
2010-04-07 18:49:46 +00:00
Pedro Alves 442ea88105 * regcache.h (struct thread_info): Forward declare.
(struct regcache): New.
	(new_register_cache): Adjust prototype.
	(get_thread_regcache): Declare.
	(free_register_cache): Adjust prototype.
	(registers_to_string, registers_from_string): Ditto.
	(supply_register, supply_register_by_name, collect_register)
	(collect_register_as_string, collect_register_by_name): Ditto.
	* regcache.c (struct inferior_regcache_data): Delete.
	(get_regcache): Rename to ...
	(get_thread_regcache): ... this.  Adjust.  Switch inferior before
	fetching registers.
	(regcache_invalidate_one): Adjust.
	(regcache_invalidate): Fix prototype.
	(new_register_cache): Return the new register cache.
	(free_register_cache): Change prototype.
	(realloc_register_cache): Adjust.
	(registers_to_string): Change prototype to take a regcache.  Adjust.
	(registers_from_string): Ditto.
	(register_data): Ditto.
	(supply_register): Ditto.
	(supply_register_by_name): Ditto.
	(collect_register): Ditto.
	(collect_register_as_string): Ditto.
	(collect_register_by_name): Ditto.
	* server.c (process_serial_event): Adjust.
	* linux-low.h (regset_fill_func, regset_store_func): Change
	prototype.
	(get_pc, set_pc, collect_ptrace_register, supply_ptrace_register):
	Change prototype.
	* linux-low.c (get_stop_pc): Adjust.
	(check_removed_breakpoint): Adjust.
	(linux_wait_for_event): Adjust.
	(linux_resume_one_lwp): Adjust.
	(fetch_register): Add regcache parameter.  Adjust.
	(usr_store_inferior_registers): Ditto.
	(regsets_fetch_inferior_registers): Ditto.
	(regsets_store_inferior_registers): Ditto.
	(linux_fetch_registers, linux_store_registers): Ditto.
	* i387-fp.c (i387_cache_to_fsave): Change prototype to take a
	regcache.  Adjust.
	(i387_fsave_to_cache, i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto.
	* i387-fp.h (i387_cache_to_fsave, i387_fsave_to_cache): Change
	prototype to take a regcache.
	(i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto.
	* remote-utils.c (convert_ascii_to_int, outreg)
	(prepare_resume_reply): Change prototype to take a regcache.
	Adjust.
	* target.h (struct target_ops) <fetch_registers, store_registers>:
	Change prototype to take a regcache.
	(fetch_inferior_registers, store_inferior_registers): Change
	prototype to take a regcache.  Adjust.
	* proc-service.c (ps_lgetregs): Adjust.
	* linux-x86-low.c (x86_fill_gregset, x86_store_gregset)
	(x86_fill_fpregset, x86_store_fpregset, x86_fill_fpxregset)
	(x86_store_fpxregset, x86_get_pc, x86_set_pc): Change prototype to
	take a regcache.  Adjust.
	* linux-arm-low.c (arm_fill_gregset, arm_store_gregset)
	(arm_fill_wmmxregset, arm_store_wmmxregset, arm_fill_vfpregset)
	(arm_store_vfpregset, arm_get_pc, arm_set_pc):
	(arm_breakpoint_at): Change prototype to take a regcache.  Adjust.
	* linux-cris-low.c (cris_get_pc, cris_set_pc)
	(cris_cannot_fetch_register):
	(cris_breakpoint_at): Change prototype to take a regcache.
	Adjust.
	* linux-crisv32-low.c (cris_get_pc, cris_set_pc,
	cris_reinsert_addr, cris_write_data_breakpoint): Change prototype
	to take a regcache.  Adjust.
	(cris_breakpoint_at, cris_insert_point, cris_remove_point):
	Adjust.
	* linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Change prototype to
	take a regcache.  Adjust.
	* linux-m68k-low.c (m68k_fill_gregset, m68k_store_gregset)
	(m68k_fill_fpregset, m68k_store_fpregset, m68k_get_pc,
	(m68k_set_pc): Change prototype to take a regcache.  Adjust.
	* linux-mips-low.c (mips_get_pc):
	(mips_set_pc): Change prototype to take a regcache.  Adjust.
	(mips_reinsert_addr): Adjust.
	(mips_collect_register): Change prototype to take a regcache.
	Adjust.
	(mips_supply_register):
	(mips_collect_register_32bit, mips_supply_register_32bit)
	(mips_fill_gregset, mips_store_gregset, mips_fill_fpregset)
	(mips_store_fpregset): Ditto.
	* linux-ppc-low.c (ppc_supply_ptrace_register, ppc_supply_ptrace_register):
	Ditto.
	(parse_spufs_run): Adjust.
	(ppc_get_pc, ppc_set_pc, ppc_fill_gregset, ppc_fill_vsxregset)
	(ppc_store_vsxregset, ppc_fill_vrregset, ppc_store_vrregset)
	(ppc_fill_evrregset, ppc_store_evrregset): Change prototype to
	take a regcache.  Adjust.
	* linux-s390-low.c (s390_collect_ptrace_register)
	(s390_supply_ptrace_register, s390_fill_gregset, s390_get_pc)
	(s390_set_pc): Change prototype to take a regcache.  Adjust.
	(s390_arch_setup): Adjust.
	* linux-sh-low.c (sh_get_pc, sh_breakpoint_at)
	(sh_fill_gregset): Change prototype to take a regcache.  Adjust.
	* linux-sparc-low.c (sparc_fill_gregset_to_stack)
	(sparc_fill_gregset, sparc_store_gregset_from_stack)
	(sparc_store_gregset, sparc_get_pc): Change prototype to take a
	regcache.  Adjust.
	(sparc_breakpoint_at): Adjust.
	* linux-xtensa-low.c (xtensa_fill_gregset):
	(xtensa_store_gregset):
	(xtensa_fill_xtregset, xtensa_store_xtregset, xtensa_get_pc)
	(xtensa_set_pc): Change prototype to take a regcache.  Adjust.
	* nto-low.c (nto_fetch_registers, nto_store_registers): Change
	prototype to take a regcache.  Adjust.
	* win32-arm-low.c (arm_fetch_inferior_register)
	(arm_store_inferior_register): Change prototype to take a
	regcache.  Adjust.
	* win32-i386-low.c (i386_fetch_inferior_register)
	(i386_store_inferior_register): Change prototype to take a
	regcache.  Adjust.
	* win32-low.c (child_fetch_inferior_registers)
	(child_store_inferior_registers): Change prototype to take a
	regcache.  Adjust.
	(win32_wait): Adjust.
	(win32_fetch_inferior_registers): Change prototype to take a
	regcache.  Adjust.
	(win32_store_inferior_registers): Adjust.
	* win32-low.h (struct win32_target_ops) <fetch_inferior_register,
	store_inferior_register>: Change prototype to take a regcache.
2010-01-20 22:55:38 +00:00
Joel Brobecker 4c38e0a4fc Update copyright year in most headers.
Automatic update by copyright.sh.
2010-01-01 07:32:07 +00:00
Pedro Alves 1b3f60162b * i387-fp.c, linux-arm-low.c, linux-cris-low.c,
linux-crisv32-low.c, linux-i386-low.c, linux-low.c,
	linux-mips-low.c, linux-s390-low.c, linux-sparc-low.c,
	linux-x86-64-low.c, linux-xtensa-low.c, proc-service.c,
	regcache.c, remote-utils.c, server.c, spu-low.c, target.h,
	thread-db.c, win32-low.c, xtensa-xtregs.c, gdbreplay.c,
	Makefile.in, configure.ac: Fix whitespace throughout.
	* configure: Regenerate.
2009-03-22 23:57:10 +00:00
Joel Brobecker 0fb0cc7590 Updated copyright notices for most files. 2009-01-03 05:58:08 +00:00
Daniel Jacobowitz dfb64f85d3 2008-11-14 Daniel Gutson <dgutson@codesourcery.com>
* configure.tgt (sparc64-*-linux*): Added gdbserver support.
	* regformats/reg-sparc64.dat: New file.

gdbserver/
2008-11-14  Daniel Gutson  <dgutson@codesourcery.com>

	* Makefile.in (SFILES, clean): Added sparc64 files.
	(reg-sparc64.o, reg-sparc64.c): New.
	* configure.srv (sparc*-*-linux*): New configuration.
	* linux-low.c (regsets_fetch_inferior_registers): Swap ptrace
	syscall arguments for SPARC.
	(regsets_store_inferior_registers): Likewise.
	* linux-sparc-low.c: New file.
2008-11-14 22:06:41 +00:00