Commit Graph

63 Commits

Author SHA1 Message Date
Andreas Arnez f69c5afb18 S390: Correct brace style in s390_get_wordsize
This corrects bad formatting in the newly introduced function
s390_get_wordsize.

gdb/gdbserver/ChangeLog:

	* linux-s390-low.c (s390_get_wordsize): Correct brace style.
2018-03-22 10:02:18 +01:00
Andreas Arnez ce29f8439f S390: Make IPA recognize tdescs with guarded storage
The in-process agent does not handle tdescs with guarded storage yet.
This is fixed.

gdb/gdbserver/ChangeLog:

	* linux-s390-ipa.c (get_ipa_tdesc): Add handling for
	S390_TDESC_GS.
	* linux-s390-low.c (s390_get_ipa_tdesc_idx): Likewise.
	(initialize_low_tracepoint): Call init_registers_s390x_gs_linux64
	and init_registers_s390_gs_linux64.
2018-03-21 17:41:45 +01:00
Andreas Arnez c49bd90bdb S390: gdbserver: Don't write guarded storage registers
On S390, the guarded storage register set is only valid if guarded storage
is active.  Reading/writing the register set yields errors if this is not
the case.  Then gdbserver emits warnings like these:

  Warning: ptrace(regsets_store_inferior_registers): No data available

Apart from confusing the user, this can also lead to test case failures
due to unexpected output.  To suppress this, make the guarded storage
regsets read-only for now.

gdb/gdbserver/ChangeLog:

	* linux-s390-low.c (s390_fill_gs): Remove function.
	(s390_fill_gsbc): Remove function.
	(s390_regsets): Set fill functions for the guarded storage regsets
	to NULL.
2018-03-21 17:41:45 +01:00
Andreas Arnez 7edb9bd32b S390: Enable re-attaching with native-extended-gdbserver
On s390x, when running attach.exp with native-extended-gdbserver,
gdbserver crashes in find_regno like this:

  .../regcache.c:252: A problem internal to GDBserver has been detected.
  Unknown register tdb0 requested

On the GDB side it looks like this:

  (gdb) attach 31568
  Attaching to process 31568
  Remote connection closed

The test case attempts to attach to a new process via the already running
gdbserver.  Thus s390_arch_setup is called a second time, and that's where
the problem occurs.  In order to determine the word width (32 or 64 bits),
s390_arch_setup reads the pswm register through the regcache.  For that it
uses a temporary tdesc which is supposed to work for all s390 targets,
since the actual tdesc has not been determined yet.  But in this second
round this doesn't work, because s390_regsets has been updated already and
now contains regsets not described by the temporary tdesc, such as the one
containing tdb0.

This is fixed by rearranging the logic in s390_arch_setup.

gdb/gdbserver/ChangeLog:

	* linux-s390-low.c (s390_get_hwcap): Replace tdesc parameter by
	the word size.  Add comment.
	(s390_get_wordsize): New function.
	(s390_arch_setup): No longer select a temporary tdesc to fetch the
	pswm with it.  Instead, use s390_get_wordsize to determine the
	word size first and derive the correct tdesc from that directly.
2018-03-21 17:41:44 +01:00
Joel Brobecker e2882c8578 Update copyright year range in all GDB files
gdb/ChangeLog:

        Update copyright year range in all GDB files
2018-01-02 07:38:06 +04:00
Simon Marchi 04ec7890fc linux low: Make the arch code free arch_process_info
For the same reason as the previous patch, we need to make the
arch-specific code free the arch_process_info structure it allocates.

gdb/gdbserver/ChangeLog:

	* linux-low.h (struct linux_target_ops) <delete_process>: New
	field.
	* linux-low.c (linux_mourn): Call the_low_target.delete_process.
	* linux-aarch64-low.c (aarch64_linux_delete_process): New.
	(struct linux_target_ops): Add delete_process callback.
	* linux-arm-low.c (arm_delete_process): New.
	(struct linux_target_ops): Add delete_process callback.
	* linux-bfin-low.c (struct linux_target_ops): Likewise.
	* linux-crisv32-low.c (struct linux_target_ops): Likewise.
	* linux-m32r-low.c (struct linux_target_ops): Likewise.
	* linux-mips-low.c (mips_linux_delete_process): New.
	(struct linux_target_ops): Add delete_process callback.
	* linux-ppc-low.c (struct linux_target_ops): Likewise.
	* linux-s390-low.c (struct linux_target_ops): Likewise.
	* linux-sh-low.c (struct linux_target_ops): Likewise.
	* linux-tic6x-low.c (struct linux_target_ops): Likewise.
	* linux-tile-low.c (struct linux_target_ops): Likewise.
	* linux-x86-low.c (x86_linux_delete_process): New.
	(struct linux_target_ops): Add delete_process callback.
	* linux-xtensa-low.c (struct linux_target_ops): Likewise.
2017-10-12 16:49:27 -04:00
Simon Marchi 466eeceef4 lwp_info: Make the arch code free arch_lwp_info
I have the goal of "poisoning" the XNEW/xfree-family of functions, so
that we catch their usages with non-POD types.  A few things need to be
fixed in the mean time, this is one.

The common lwp code in linux-nat.c and gdbserver/linux-low.c xfrees the
private lwp data of type arch_lwp_info.  However, that type is opaque
from its point of view, as its defined differently in each arch-specific
implementation.  This trips on the std::is_pod<T> check, since the
compiler can't tell whether the type is POD or not if it doesn't know
about it.

My initial patch [1] made a class hierarchy with a virtual destructor.
However, as Pedro pointed out, we only have one native architecture at
the time built in gdb and gdbserver, so that's overkill.  Instead, we
can move the responsibility of free'ing arch_lwp_info to the arch code
(which is also the one that allocated it in the first place).  This is
what this patch does.

Also, I had the concern that if we wanted to use C++ features in these
structures, we would have a problem with the one-definition rule.
However, since a build will only have one version of arch_lwp_info,
that's not a problem.

There are changes in arch-specific files, I was only able to built-test
this patch with the following cross-compilers:

  aarch64-linux-gnu
  alpha-linux-gnu
  arm-linux-gnueabihf
  hppa-linux-gnu
  m68k-linux-gnu
  mips64el-linux-gnuabi64
  powerpc64-linux-gnu
  s390x-linux-gnu
  sh4-linux-gnu
  sparc64-linux-gnu
  x86_64-linux-gnu
  x86_64-w64-mingw32

A buildbot run didn't find any regression.

[1] https://sourceware.org/ml/gdb-patches/2017-08/msg00255.html

gdb/ChangeLog:

	* linux-nat.h (linux_nat_set_delete_thread): New declaration.
	* linux-nat.c (linux_nat_delete_thread): New variable.
	(lwp_free): Invoke linux_nat_delete_thread if set.
	(linux_nat_set_delete_thread): New function.
	* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Assign
	thread delete callback.
	* arm-linux-nat.c (arm_linux_delete_thread): New function.
	(_initialize_arm_linux_nat): Assign thread delete callback.
	* s390-linux-nat.c (s390_delete_thread): New function.
	(_initialize_s390_nat): Assign thread delete callback.
	* x86-linux-nat.c (x86_linux_add_target): Likewise.
	* nat/aarch64-linux.c (aarch64_linux_delete_thread): New
	function.
	* nat/aarch64-linux.h (aarch64_linux_delete_thread): New
	declaration.
	* nat/x86-linux.c (x86_linux_delete_thread): New function.
	* nat/x86-linux.h (x86_linux_delete_thread): New declaration.

gdb/gdbserver/ChangeLog:

	* linux-aarch64-low.c (the_low_target): Add thread delete
	callback.
	* linux-arm-low.c (arm_delete_thread): New function.
	(the_low_target): Add thread delete callback.
	* linux-bfin-low.c (the_low_target): Likewise.
	* linux-crisv32-low.c (the_low_target): Likewise.
	* linux-low.c (delete_lwp): Invoke delete_thread callback if
	set.
	* linux-low.h (struct linux_target_ops) <delete_thread>: New
	field.
	* linux-m32r-low.c (the_low_target): Add thread delete callback.
	* linux-mips-low.c (mips_linux_delete_thread): New function.
	(the_low_target): Add thread delete callback.
	* 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-tic6x-low.c (the_low_target): Likewise.
	* linux-tile-low.c (the_low_target): Likewise.
	* linux-x86-low.c (the_low_target): Likewise.
	* linux-xtensa-low.c (the_low_target): Likewise.
2017-10-12 16:48:22 -04:00
Andreas Arnez ad3396348e S390: Add guarded-storage register support to gdbserver
Enable gdbserver to deal with the new guarded-storage register sets.

gdb/gdbserver/ChangeLog:

	* configure.srv (s390*-*-linux*): Add s390-gs-linux64.o and
	s390x-gs-linux64.o to srv_regobj.  Add s390-gs-linux64.xml,
	s390x-gs-linux64.xml, s390-gs.xml, and s390-gsbc.xml to
	srv_xmlfiles.  Add s390-gs-linux64-ipa.o and
	s390x-gs-linux64-ipa.o to ipa_obj.
	* linux-s390-low.c (HWCAP_S390_GS): New define.
	(s390_fill_gs, s390_store_gs, s390_fill_gsbc, s390_store_gsbc):
	New functions.
	(s390_regsets): Add regsets for NT_S390_GS_CB and NT_S390_GS_BC.
	(s390_arch_setup): Check for guarded-storage support and choose
	appropriate tdesc.
	(initialize_low_arch): Invoke init_registers_s390_gs_linux64 and
	init_registers_s390x_gs_linux64.
	* linux-s390-tdesc.h (enum s390_linux_tdesc) <S390_TDESC_GS>: New
	enum value.
	(init_registers_s390x_gs_linux64, tdesc_s390x_gs_linux64)
	(init_registers_s390_gs_linux64, tdesc_s390_gs_linux64): Declare.
2017-09-25 16:02:23 +02:00
Joel Brobecker 61baf725ec update copyright year range in GDB files
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.
2017-01-01 10:52:34 +04:00
Andreas Arnez 782c112285 S390 gdbserver: Mark local funcs/vars as static
Compiling with '-Wmissing-declarations' yields warnings in
linux-s390-low.c.  To fix this, mark appropriate functions as static.

gdb/gdbserver/ChangeLog:

	* linux-s390-low.c (s390_emit_eq_goto): Mark function static.
	(s390_emit_ne_goto): Likewise.
	(s390_emit_lt_goto): Likewise.
	(s390_emit_le_goto): Likewise.
	(s390_emit_gt_goto): Likewise.
	(s390_emit_ge_goto): Likewise.
	(s390x_emit_eq_goto): Likewise.
	(s390x_emit_ne_goto): Likewise.
	(s390x_emit_lt_goto): Likewise.
	(s390x_emit_le_goto): Likewise.
	(s390x_emit_gt_goto): Likewise.
	(s390x_emit_ge_goto): Likewise.
	(s390_emit_ops_impl): Mark variable static.
	(s390x_emit_ops): Likewise.
2016-06-21 13:26:11 +02:00
Pedro Alves 3451269c41 Fix s390 GNU/Linux gdb and gdbserver builds
Now that gdb/gdbserver compile as C++ programs by default, the s390
GNU/Linux build started failing with:

 In file included from ../../src/gdb/common/common-defs.h:64:0,
		  from ../../src/gdb/defs.h:28,
		  from ../../src/gdb/s390-linux-nat.c:22:
 ../../src/gdb/s390-linux-nat.c: In function ‘void fetch_regset(regcache*, int, int, int, const regset*)’:
 ../../src/gdb/../include/libiberty.h:711:38: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive]
  # define alloca(x) __builtin_alloca(x)
				       ^
 ../../src/gdb/s390-linux-nat.c:297:19: note: in expansion of macro ‘alloca’
    gdb_byte *buf = alloca (regsize);
		    ^

etc.

gdb/ChangeLog:
2016-04-21  Pedro Alves  <palves@redhat.com>

	* s390-linux-nat.c (fetch_regset, store_regset, check_regset): Use
	void * instead of gdb_byte *.

gdb/gdbserver/ChangeLog:
2016-04-21  Pedro Alves  <palves@redhat.com>

	* linux-s390-low.c (s390_collect_ptrace_register)
	(s390_supply_ptrace_register, s390_get_hwcap): Use gdb_byte * and
	add casts.
	(s390_check_regset): Use void * instead of gdb_byte *.
2016-04-21 12:03:53 +01:00
Marcin Kościelnicki f39e874354 gdbserver/s390: Add support for compiled agent expressions.
These sequences assume a z900+ CPU, like the rest of fast tracepoint
support.

gdb/gdbserver/ChangeLog:

	PR 18377
	* linux-s390-low.c (add_insns): New function.
	(s390_emit_prologue): New function.
	(s390_emit_epilogue): New function.
	(s390_emit_add): New function.
	(s390_emit_sub): New function.
	(s390_emit_mul): New function.
	(s390_emit_lsh): New function.
	(s390_emit_rsh_signed): New function.
	(s390_emit_rsh_unsigned): New function.
	(s390_emit_ext): New function.
	(s390_emit_log_not): New function.
	(s390_emit_bit_and): New function.
	(s390_emit_bit_or): New function.
	(s390_emit_bit_xor): New function.
	(s390_emit_bit_not): New function.
	(s390_emit_equal): New function.
	(s390_emit_less_signed): New function.
	(s390_emit_less_unsigned): New function.
	(s390_emit_ref): New function.
	(s390_emit_if_goto): New function.
	(s390_emit_goto): New function.
	(s390_write_goto_address): New function.
	(s390_emit_litpool): New function.
	(s390_emit_const): New function.
	(s390_emit_call): New function.
	(s390_emit_reg): New function.
	(s390_emit_pop): New function.
	(s390_emit_stack_flush): New function.
	(s390_emit_zero_ext): New function.
	(s390_emit_swap): New function.
	(s390_emit_stack_adjust): New function.
	(s390_emit_set_r2): New function.
	(s390_emit_int_call_1): New function.
	(s390_emit_void_call_2): New function.
	(s390_emit_eq_goto): New function.
	(s390_emit_ne_goto): New function.
	(s390_emit_lt_goto): New function.
	(s390_emit_le_goto): New function.
	(s390_emit_gt_goto): New function.
	(s390_emit_ge_goto): New function.
	(s390x_emit_prologue): New function.
	(s390x_emit_epilogue): New function.
	(s390x_emit_add): New function.
	(s390x_emit_sub): New function.
	(s390x_emit_mul): New function.
	(s390x_emit_lsh): New function.
	(s390x_emit_rsh_signed): New function.
	(s390x_emit_rsh_unsigned): New function.
	(s390x_emit_ext): New function.
	(s390x_emit_log_not): New function.
	(s390x_emit_bit_and): New function.
	(s390x_emit_bit_or): New function.
	(s390x_emit_bit_xor): New function.
	(s390x_emit_bit_not): New function.
	(s390x_emit_equal): New function.
	(s390x_emit_less_signed): New function.
	(s390x_emit_less_unsigned): New function.
	(s390x_emit_ref): New function.
	(s390x_emit_if_goto): New function.
	(s390x_emit_const): New function.
	(s390x_emit_call): New function.
	(s390x_emit_reg): New function.
	(s390x_emit_pop): New function.
	(s390x_emit_stack_flush): New function.
	(s390x_emit_zero_ext): New function.
	(s390x_emit_swap): New function.
	(s390x_emit_stack_adjust): New function.
	(s390x_emit_int_call_1): New function.
	(s390x_emit_void_call_2): New function.
	(s390x_emit_eq_goto): New function.
	(s390x_emit_ne_goto): New function.
	(s390x_emit_lt_goto): New function.
	(s390x_emit_le_goto): New function.
	(s390x_emit_gt_goto): New function.
	(s390x_emit_ge_goto): New function.
	(s390_emit_ops): New function.
	(struct linux_target_ops): Fill in emit_ops hook.
2016-03-29 23:39:46 +02:00
Marcin Kościelnicki abd9baf9c6 gdbserver/s390: Add fast tracepoint support.
Fast tracepoints will only work on 6-byte intructions, and assume at least
a z900 CPU.  s390 also has 4-byte jump instructions, which also work on
pre-z900, but their range is limitted to +-64kiB, which is not very useful
(and wouldn't work at all with current jump pad allocation).

There's a little problem with s390_relocate_instruction function: it
converts BRAS/BRASL instructions to LARL of the return address + JG
to the target address.  On 31-bit, this sets the high bit of the target
register to 0, while BRAS/BRASL would set it to 1.  While this is not
a problem when the result is only used to address memory, it could
possibly break something that expects to compare such addresses for
equality without first masking the bit off.  In particular, I'm not sure
whether leaving the return address high bit unset is ABI-compliant
(could confuse some unwinder?).  If that's a problem, it could be fixed
by handling it in the jump pad (since at that point we can just modify
the GPRs in the save area without having to worry about preserving
CCs and only having that one GPR to work with - I'm not sure if it's
even possible to set the high bit with such constraints).

gdb/gdbserver/ChangeLog:

	PR 18377
	* Makefile.in: Add s390 IPA files.
	* configure.srv: Build IPA for s390.
	* linux-s390-ipa.c: New file.
	* linux-s390-low.c: New includes - inttypes.h and linux-s390-tdesc.h.
	(init_registers_s390_linux32): Move declaration to linux-s390-tdesc.h.
	(tdesc_s390_linux32): Likewise.
	(init_registers_s390_linux32v1): Likewise.
	(tdesc_s390_linux32v1): Likewise.
	(init_registers_s390_linux32v2): Likewise.
	(tdesc_s390_linux32v2): Likewise.
	(init_registers_s390_linux64): Likewise.
	(tdesc_s390_linux64): Likewise.
	(init_registers_s390_linux64v1): Likewise.
	(tdesc_s390_linux64v1): Likewise.
	(init_registers_s390_linux64v2): Likewise.
	(tdesc_s390_linux64v2): Likewise.
	(init_registers_s390_te_linux64): Likewise.
	(tdesc_s390_te_linux64): Likewise.
	(init_registers_s390_vx_linux64): Likewise.
	(tdesc_s390_vx_linux64): Likewise.
	(init_registers_s390_tevx_linux64): Likewise.
	(tdesc_s390_tevx_linux64): Likewise.
	(init_registers_s390x_linux64): Likewise.
	(tdesc_s390x_linux64): Likewise.
	(init_registers_s390x_linux64v1): Likewise.
	(tdesc_s390x_linux64v1): Likewise.
	(init_registers_s390x_linux64v2): Likewise.
	(tdesc_s390x_linux64v2): Likewise.
	(init_registers_s390x_te_linux64): Likewise.
	(tdesc_s390x_te_linux64): Likewise.
	(init_registers_s390x_vx_linux64): Likewise.
	(tdesc_s390x_vx_linux64): Likewise.
	(init_registers_s390x_tevx_linux64): Likewise.
	(tdesc_s390x_tevx_linux64): Likewise.
	(have_hwcap_s390_vx): New static variable.
	(s390_arch_setup): Fill have_hwcap_s390_vx.
	(s390_get_thread_area): New function.
	(s390_ft_entry_gpr_esa): New const.
	(s390_ft_entry_gpr_zarch): New const.
	(s390_ft_entry_misc): New const.
	(s390_ft_entry_fr): New const.
	(s390_ft_entry_vr): New const.
	(s390_ft_main_31): New const.
	(s390_ft_main_64): New const.
	(s390_ft_exit_fr): New const.
	(s390_ft_exit_vr): New const.
	(s390_ft_exit_misc): New const.
	(s390_ft_exit_gpr_esa): New const.
	(s390_ft_exit_gpr_zarch): New const.
	(append_insns): New function.
	(s390_relocate_instruction): New function.
	(s390_install_fast_tracepoint_jump_pad): New function.
	(s390_get_min_fast_tracepoint_insn_len): New function.
	(s390_get_ipa_tdesc_idx): New function.
	(struct linux_target_ops): Wire in the above functions.
	(initialize_low_arch) [!__s390x__]: Don't initialize s390x tdescs.
	* linux-s390-tdesc.h: New file.
2016-03-29 23:39:00 +02:00
Marcin Kościelnicki a4105d04e1 gdbserver/s390: Switch on tracepoint support.
Also adds s390 support to gdb.trace testsuite.

gdb/gdbserver/ChangeLog:

	* linux-s390-low.c (s390_supports_tracepoints): New function.
	(struct linux_target_ops): Fill supports_tracepoints hook.

gdb/testsuite/ChangeLog:

	* gdb.trace/ftrace.exp: Set arg0exp for s390.
	* gdb.trace/mi-trace-frame-collected.exp: Expect 4 registers on s390.
	* gdb.trace/mi-trace-unavailable.exp: Set pcnum for s390, add gpr0num
	variable for GPR 0 instead of assuming it is register 0.
	* gdb.trace/trace-common.h: Add s390 fast tracepoint placeholder.
	* lib/trace-support.exp: Add s390 registers.
2016-03-29 23:08:05 +02:00
Marcin Kościelnicki ab50308758 gdbserver/s390: Enable high GPRs, VX, TDB with 31-bit gdbserver.
Currently, 31-bit gdbserver doesn't support collecting/supplying high
GPRs, VX registers, and TDB data.  This is not much of a problem now,
since machines that have them usually have a 64-bit gdbserver that can
be used to debug 31-bit targets just fine.  However, with fast
tracepoints, it's not possible to use a 64-bit gdbserver with a 31-bit
IPA (and thus a 31-bit target), so 31-bit gdbserver has to be used
for 31-bit targets.  Thus, this patch is needed to allow collecting
high GPRs and VX registers on 31-bit targets via fast tracepoints.

gdb/gdbserver/ChangeLog:

	* linux-s390-low.c (s390_num_regs_3264): Define on 31-bit too.
	(s390_regmap_3264) [!__s390x__]: New global.
	(s390_collect_ptrace_register): Skip map entries containing -1.
	(s390_supply_ptrace_register): Ditto.
	(s390_fill_gprs_high): New function.
	(s390_store_gprs_high): New function.
	(s390_regsets): Add NT_S390_HIGH_GPRS.
	(s390_get_hwcap): Enable on 31-bit.
	(have_hwcap_s390_high_gprs): Enable on 31-bit.
	(s390_arch_setup): Enable detection of high GPRs, TDB, VX on 31-bit.
	Detect NT_S390_HIGH_GPRS.
	(s390_usrregs_info_3264): Enable on 31-bit.
	(s390_regs_info): Enable regs_info_3264 on 31-bit.
	(initialize_low_arch): Initialize s390_regsets_info_3264 on 31-bit.
2016-02-25 20:05:38 +01:00
Marcin Kościelnicki b00b61e1fd gdbserver/s390: Advertise Z0 packet support.
This is necessary for upcoming tracepoint support - otherwise, setting
a tracepoint and a breakpoint on the same address will fail, since gdbserver
won't know about gdb's breakpoint.

Tested on s390x-ibm-linux-gnu and s390-ibm-linux-gnu, RHEL 7.2.

gdb/gdbserver/ChangeLog:

	* linux-s390-low.c (s390_supports_z_point_type): New function.
	(struct linux_target_ops): Wire s390_supports_z_point_type in.
2016-02-17 10:45:58 +01:00
Joel Brobecker 618f726fcb GDB copyright headers update after running GDB's copyright.py script.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Antoine Tremblay 7d00775ece Refactor queries for hardware and software single stepping support in GDBServer.
Before this patch there was only one call: can_hardware_single_step. Its
implementation was a check on breakpoint_reinsert_addr if NULL it assumed
that the target could hardware single step.

This patch prepares for the case where this is not true anymore.

In order to improve software single stepping in GDBServer the
breakpoint_reinsert_addr operation of targets that had a very simple
software implementation used only for stepping over thread creation events
will be removed.

This will create a case where a target does not support hardware single
step and has the operation breakpoint_reinsert_addr set to NULL, thus
can_hardware_single_step needs to be implemented another way.

A new target operation supports_hardware_single_step is introduced and is
to return true if the target does support such a feature, support for the
feature is manually hardcoded.

Note that the hardware single step support was enabled as per the current
behavior, I did not check if tile for example really has ptrace singlestep
support but since the current implementation assumed it had, I kept it
that way.

No regressions on Ubuntu 14.04 on ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }

Compilation tested on: aarch64,arm,bfind,crisv32,m32r,ppc,s390,tic6x,tile,
xtensa.
Not tested : sh.

gdb/gdbserver/ChangeLog:

	* linux-aarch64-low.c (aarch64_supports_hardware_single_step):
	New function.
	(struct linux_target_ops) <supports_hardware_single_step>: Initialize.
	* linux-arm-low.c (arm_supports_hardware_single_step): New function.
	(struct linux_target_ops) <supports_hardware_single_step>: Initialize.
	* linux-bfin-low.c (bfin_supports_hardware_single_step): New function.
	(struct linux_target_ops) <bfin_supports_hardware_single_step>:
	Initialize.
	* linux-crisv32-low.c (cris_supports_hardware_single_step):
	New function.
	(struct linux_target_ops) <supports_hardware_single_step>: Initialize.
	* linux-low.c (can_hardware_single_step): Use
	supports_hardware_single_step.
	(can_software_single_step): New function.
	(start_step_over): Call can_software_single_step.
	(linux_supports_hardware_single_step): New function.
	(struct target_ops) <supports_software_single_step>: Initialize.
	* linux-low.h (struct linux_target_ops)
	<supports_hardware_single_step>: Initialize.
	* linux-m32r-low.c (m32r_supports_hardware_single_step): New function.
	(struct linux_target_ops) <supports_hardware_single_step>: Initialize.
	* linux-ppc-low.c (ppc_supports_hardware_single_step): New function.
	(struct linux_target_ops) <supports_hardware_single_step> Initialize.
	* linux-s390-low.c (s390_supports_hardware_single_step): New function.
	(struct linux_target_ops) <supports_hardware_single_step>: Initialize.
	* linux-sh-low.c (sh_supports_hardware_single_step): New function.
	(struct linux_target_ops) <supports_hardware_single_step>: Initialize.
	* linux-tic6x-low.c (tic6x_supports_hardware_single_step): New function.
	(struct linux_target_ops) <tic6x_supports_hardware_single_step>:
	Initialize.
	* linux-tile-low.c (tile_supports_hardware_single_step): New function.
	(struct linux_target_ops) <tile_supports_hardware_single_step>:
	Initialize.
	* linux-x86-low.c (x86_supports_hardware_single_step) New function.
	(struct linux_target_ops) <supports_hardware_single_step>: Initialize.
	* linux-xtensa-low.c (xtensa_supports_hardware_single_step):
	New function.
	(struct linux_target_ops) <supports_hardware_single_step>: Initialize.
	* target.h (struct target_ops): <supports_software_single_step>:
	New field.
	(target_supports_software_single_step): New macro.
2015-11-30 15:17:36 -05:00
Pedro Alves 50bc912a20 gdbserver/Linux: Introduce NULL_REGSET
Fixes errors like:

 src/gdb/gdbserver/linux-x86-low.c:477:1: error: invalid conversion from 'int' to 'regset_type' [-fpermissive]

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

	* linux-low.h (NULL_REGSET): Define.
	* linux-aarch64-low.c (aarch64_regsets): Use NULL_REGSET.
	* linux-arm-low.c (arm_regsets): Likewise.
	* linux-crisv32-low.c (cris_regsets): Likewise.
	* linux-m68k-low.c (m68k_regsets): Likewise.
	* linux-mips-low.c (mips_regsets): Likewise.
	* linux-nios2-low.c (nios2_regsets): Likewise.
	* linux-ppc-low.c (ppc_regsets): Likewise.
	* linux-s390-low.c (s390_regsets): Likewise.
	* linux-sh-low.c (sh_regsets): Likewise.
	* linux-sparc-low.c (sparc_regsets): Likewise.
	* linux-tic6x-low.c (tic6x_regsets): Likewise.
	* linux-tile-low.c (tile_regsets): Likewise.
	* linux-x86-low.c (x86_regsets): Likewise.
	* linux-xtensa-low.c (xtensa_regsets): Likewise.
2015-10-29 12:55:02 +00:00
Antoine Tremblay dd37334957 Add the target_ops needed for software breakpoints in GDBServer.
This patch is in preparation for software breakpoints on ARM linux.  It
refactors breakpoint and breakpoint_len into breakpoint_kind_from_pc and
sw_breakpoint_from kind to prepare the case where we have multiple types of
breakpoints.

Kind is the type of breakpoint (hardware or software) to be inserted, usually it
is the lenght of the software breakpoint but can be something else depending on
the target.

This patch introduces the linux_target_ops breakpoint_kind_from_pc and
sw_breakpoint_from_kind.

breakpoint_kind_from_pc returns the breakpoint kind and adjusts the PC to the
real memory location in case a flag was present in the PC. E.g the instruction
mode on ARM.

sw_breakpoint_from_kind returns the software breakpoint for this kind as a
string of bytes, the length of the breakpoint is adjusted for the breakpoint's
size in memory.

For targets that have only one kind of breakpoint, the default value 0 is
returned by linux_breakpoint_kind_from_pc so that not all targets need to
implement the breakpoint_kind_from_pc operation.

No regressions, tested on Ubuntu 14.04 on ARMv7 and x86
With gdbserver-{native,extended} / { -marm -mthumb }

Also since the target_ops have been changed compilation was tested on
affected archs namely : aarch64, arm, bfin, cris, crisv32, m32r,
m68k, mips, nios2, ppc, s390, sparc, tic6x, tile, x86, steins.

Not tested : sh

gdb/gdbserver/ChangeLog:

	* linux-aarch64-low.c (aarch64_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-arm-low.c (arm_breakpoint_kind_from_pc): New function.
	(arm_sw_breakpoint_from_kind): New function.
	* linux-bfin-low.c (bfin_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-cris-low.c (cris_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-crisv32-low.c (cris_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-low.c (linux_wait_1): Call breakpoint_kind_from_pc
	and sw_breakpoint_from_kind to increment the pc.
	(linux_breakpoint_kind_from_pc): New function.
	(linux_sw_breakpoint_from_kind): New function.
	(struct target_ops) <sw_breakpoint_from_kind>: Initialize field.
	(initialize_low): Call breakpoint_kind_from_pc and
	sw_breakpoint_from_kind to replace breakpoint_data/len.
	* linux-low.h (struct linux_target_ops) <breakpoint_kind_from_pc>:
	New field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Likewise.
	* linux-m32r-low.c (m32r_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-m68k-low.c (m68k_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-mips-low.c (mips_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-nios2-low.c (nios2_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-ppc-low.c (ppc_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-s390-low.c (s390_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-sh-low.c (sh_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-sparc-low.c (sparc_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-tic6x-low.c (tic6x_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-tile-low.c (tile_sw_breakpoint_from_kind): New function.
	* linux-x86-low.c (x86_sw_breakpoint_from_kind): New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
	* linux-xtensa-low.c (xtensa_sw_breakpoint_from_kind) New function.
	(struct linux_target_ops) <breakpoint>: Remove.
	(struct linux_target_ops) <breakpoint_len>: Remove.
	(struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field.
	(struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
2015-10-21 11:24:55 -04: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
Yao Qi ca9b78ce90 Move PTRACE_GETREGSET and PTRACE_SETREGSET to nat/linux-ptrace.h
Macros PTRACE_GETREGSET and PTRACE_SETREGSET are defined locally in
some places in GDB and GDBserver.  This patch is to move them to
nat/linux-ptrace.h to avoid duplication.

gdb:

2015-06-01  Yao Qi  <yao.qi@linaro.org>

	* amd64-linux-nat.c: Include "nat/linux-ptrace.h".
	* i386-linux-nat.c: Likewise.
	* nat/linux-ptrace.h (PTRACE_GETREGSET, PTRACE_SETREGSET): Define.
	* s390-linux-nat.c: Include "nat/linux-ptrace.h".
	(PTRACE_GETREGSET, PTRACE_SETREGSET): Remove.
	* x86-linux-nat.c: Include "nat/linux-ptrace.h".
	* x86-linux-nat.h (PTRACE_GETREGSET, PTRACE_SETREGSET): Remove.

gdb/gdbserver:

2015-06-01  Yao Qi  <yao.qi@linaro.org>

	* linux-s390-low.c (PTRACE_GETREGSET, PTRACE_SETREGSET): Remove.
	* linux-x86-low.c: Likewise.
2015-06-01 12:13:02 +01:00
Andreas Arnez bf2d68ab8c S390: Add vector register support to gdbserver
On S/390 targets with vector registers, enable gdbserver to advertise
and handle the feature "org.gnu.gdb.s390.vx".

gdb/gdbserver/ChangeLog:

	* Makefile.in (s390-vx-linux64.c, s390-tevx-linux64.c)
	(s390x-vx-linux64.c, s390x-tevx-linux64.c): New rules.
	(clean): Add "rm -f" for above C files.
	* configure.srv (srv_regobj): Add s390-vx-linux64.o,
	s390-tevx-linux64.o, s390x-vx-linux64.o, and s390x-tevx-linux64.o.
	(srv_xmlfiles): Add s390-vx-linux64.xml, s390-tevx-linux64.xml,
	s390x-vx-linux64.xml, s390x-tevx-linux64.xml, and s390-vx.xml.
	* linux-s390-low.c (HWCAP_S390_VX): New macro.
	(init_registers_s390_vx_linux64, init_registers_s390_tevx_linux64)
	(init_registers_s390x_vx_linux64)
	(init_registers_s390x_tevx_linux64)
	(tdesc_s390_vx_linux64, tdesc_s390_tevx_linux64)
	(tdesc_s390x_vx_linux64, tdesc_s390x_tevx_linux64): New extern
	declarations.
	(s390_fill_vxrs_low, s390_store_vxrs_low, s390_fill_vxrs_high)
	(s390_store_vxrs_high): New functions.
	(s390_regsets): Add entries for NT_S390_VXRS_LOW and
	NT_S390_VXRS_HIGH.
	(s390_arch_setup): Add logic for selecting one of the new target
	descriptions.  Activate the new vector regsets if applicable.
	(initialize_low_arch): Also invoke init_registers_s390_vx_linux64,
	init_registers_s390_tevx_linux64, init_registers_s390x_vx_linux64,
	and init_registers_s390x_tevx_linux64.
2015-03-02 10:57:40 +01:00
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
Andreas Arnez e5a9158d09 S390: Fix gdbserver support for TDB
This makes gdbserver actually provide values for the TDB registers
when the inferior was stopped in a transaction.  The change in
linux-low.c is needed to suppress the warning for an unavailable TDB.

The test case 's390-tdbregs.exp' passes with this patch and fails
without.

gdb/gdbserver/ChangeLog:

	* linux-low.c (regsets_fetch_inferior_registers): Suppress the
	warning upon ENODATA from ptrace.
	* linux-s390-low.c (s390_store_tdb): New.
	(s390_regsets): Add regset for NT_S390_TDB.
2014-12-12 14:15:07 +01:00
Andreas Arnez feea5f36a9 gdbserver: Support read-only regsets in linux-low.c
For GNU/Linux targets using the regsets interface, this change
supports regsets that can be read but not written.  The S390 "last
break" regset is an example.  So far it had been defined with
regset->set_request == PTRACE_GETREGSET, such that the respective
ptrace call does not cause any harm.  Now we just skip the whole
read/modify/write sequence for regsets that do not define a
fill_function.

gdb/gdbserver/ChangeLog:

	* linux-low.c (regsets_store_inferior_registers): Skip regsets
	without a fill_function.
	* linux-s390-low.c (s390_fill_last_break): Remove.
	(s390_regsets): Set fill_function to NULL for NT_S390_LAST_BREAK.
	(s390_arch_setup): Use regset's size instead of fill_function for
	loop end condition.
2014-12-12 14:15:07 +01: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 d86d4aafd4 Remove all_lwps global.
* inferiors.h (ptid_of): Move here from linux-low.h.
	(pid_of, lwpid_of): Ditto.
	* linux-aarch64-low.c (debug_reg_change_callback): Update, "entry"
	parameter is a struct thread_info * now.
	(aarch64_notify_debug_reg_change): Fetch pid from current_inferior
	directly.  Pass &all_threads to find_inferior instead of &all_lwps.
	(aarch64_stopped_data_address): Fetch lwpid from current_inferior
	directly.
	(aarch64_linux_prepare_to_resume): Fetch ptid from thread.
	(aarch64_arch_setup): Fetch lwpid from current_inferior directly.
	* linux-arm-low.c (update_registers_callback): Update, "entry"
	parameter is a struct thread_info * now.
	Fetch lwpid from current_inferior directly.
	(arm_insert_point): Pass &all_threads to find_inferior instead of
	&all_lwps.
	(arm_remove_point): Ditto.
	(arm_stopped_by_watchpoint): Fetch lwp from current_inferior.
	(arm_prepare_to_resume): Fetch pid from thread.
	(arm_read_description): Fetch lwpid from current_inferior directly.
	* linux-low.c (all_lwps): Delete.
	(delete_lwp): Delete call to remove_inferior.
	(handle_extended_wait): Fetch lwpid from thread.
	(add_lwp): Don't set lwp->entry.id.  Remove call to
	add_inferior_to_list.
	(linux_attach_lwp_1): Fetch pid from current_inferior directly.
	(linux_kill_one_lwp): Fetch ptid,lwpid from thread.
	(kill_one_lwp_callback): Ditto.
	(linux_kill): Don't dereference NULL pointer.
	Fetch ptid,lwpid from thread.
	(get_detach_signal): Fetch ptid from thread.
	(linux_detach_one_lwp): Fetch ptid,lwpid from thread.
	Simplify call to regcache_invalidate_thread.
	(delete_lwp_callback): Update, "entry" parameter is a
	struct thread_info * now.  Fetch pid from thread.
	(linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps.
	(status_pending_p_callback): Update, "entry" parameter is a
	struct thread_info * now.  Fetch ptid from thread.
	(find_lwp_pid): Update, "entry" parameter is a
	struct thread_info * now.
	(linux_wait_for_lwp): Fetch pid from thread.
	(linux_fast_tracepoint_collecting): Fetch lwpid from thread.
	(maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior.
	(enqueue_one_deferred_signal): Fetch lwpid from thread.
	(dequeue_one_deferred_signal): Ditto.
	(cancel_breakpoint): Fetch ptid from current_inferior.
	(linux_wait_for_event): Pass &all_threads to find_inferior,
	not &all_lwps.  Fetch ptid, lwpid from thread.
	(count_events_callback): Update, "entry" parameter is a
	struct thread_info * now.
	(select_singlestep_lwp_callback): Ditto.
	(select_event_lwp_callback): Ditto.
	(cancel_breakpoints_callback): Ditto.
	(linux_cancel_breakpoints): Pass &all_threads to find_inferior,
	not &all_lwps.
	(select_event_lwp): Ditto.  Fetch ptid from event_thread.
	(unsuspend_one_lwp): Update, "entry" parameter is a
	struct thread_info * now.
	(unsuspend_all_lwps): Pass &all_threads to find_inferior,
	not &all_lwps.
	(linux_stabilize_threads): Ditto.  And for for_each_inferior.
	Fetch lwpid from thread, not lwp.
	(linux_wait_1): Fetch ptid, lwpid from current_inferior.
	Pass &all_threads to find_inferior, not &all_lwps.
	(send_sigstop): Fetch lwpid from thread, not lwp.
	(send_sigstop_callback): Update, "entry" parameter is a
	struct thread_info * now.
	(suspend_and_send_sigstop_callback): Ditto.
	(wait_for_sigstop): Ditto.  Fetch ptid, lwpid from thread, lwp.
	(stuck_in_jump_pad_callback): Update, "entry" parameter is a
	struct thread_info * now.
	(move_out_of_jump_pad_callback): Ditto.  Fetch ptid, lwpid
	from thread, lwp.
	(lwp_running): Update, "entry" parameter is a
	struct thread_info * now.
	(stop_all_lwps): Fetch ptid from thread.
	Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps.
	(linux_resume_one_lwp): Fetch lwpid from thread.
	(linux_set_resume_request): Update, "entry" parameter is a
	struct thread_info * now.  Fetch pid, lwpid from thread.
	(resume_status_pending_p): Update, "entry" parameter is a
	struct thread_info * now.
	(need_step_over_p): Ditto.  Fetch lwpid from thread.
	(start_step_over): Fetch lwpid from thread.
	(linux_resume_one_thread): Update, "entry" parameter is a
	struct thread_info * now.  Fetch lwpid from thread.
	(linux_resume): Pass &all_threads to find_inferior, not &all_lwps.
	(proceed_one_lwp): Update, "entry" parameter is a
	struct thread_info * now.  Fetch lwpid from thread.
	(unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a
	struct thread_info * now.
	(proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps.
	(unstop_all_lwps): Ditto.  Fetch lwpid from thread.
	(regsets_fetch_inferior_registers): Fetch lwpid from current_inferior
	directly.
	(regsets_store_inferior_registers): Ditto.
	(fetch_register, store_register): Ditto.
	(linux_read_memory, linux_write_memory): Ditto.
	(linux_request_interrupt): Ditto.
	(linux_read_auxv): Ditto.
	(linux_xfer_siginfo): Ditto.
	(linux_qxfer_spu): Ditto.
	(linux_qxfer_libraries_svr4): Ditto.
	* linux-low.h (ptid_of, pid_of, lwpid_of): Delete,
	moved to inferiors.h.
	(get_lwp): Delete.
	(get_thread_lwp): Update.
	(struct lwp_info): Delete member "entry".  Simplify comment for
	member "thread".
	(all_lwps): Delete.
	* linux-mips-low.c (mips_read_description): Fetch lwpid from
	current_inferior directly.
	(update_watch_registers_callback): Update, "entry" parameter is a
	struct thread_info * now.  Fetch pid from thread.
	(mips_linux_prepare_to_resume): Fetch ptid from thread.
	(mips_insert_point): Fetch lwpid from current_inferior.
	Pass &all_threads to find_inferior, not &all_lwps.
	(mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps.
	(mips_stopped_by_watchpoint): Fetch lwpid from current_inferior
	directly.
	(mips_stopped_data_address): Ditto.
	* linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior
	directly.
	* linux-tile-low.c (tile_arch_setup): Ditto.
	* linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread.
	(update_debug_registers_callback): Update, "entry" parameter is a
	struct thread_info * now.  Fetch pid from thread.
	(i386_dr_low_set_addr): Fetch pid from current_inferior directly.
	Pass &all_threads to find_inferior, not &all_lwps.
	(i386_dr_low_get_addr): Fetch ptid from current_inferior directly.
	(i386_dr_low_set_control): Fetch pid from current_inferior directly.
	Pass &all_threads to find_inferior, not &all_lwps.
	(i386_dr_low_get_control): Fetch ptid from current_inferior directly.
	(i386_dr_low_get_status): Ditto.
	(x86_linux_prepare_to_resume): Fetch ptid from thread.
	(x86_siginfo_fixup): Fetch lwpid from current_inferior directly.
	(x86_linux_read_description): Ditto.
	* proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 12:25:18 -08:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Andreas Arnez 6682d9595e S390: Fix TDB regset recognition
When checking for the presence of the TDB regset, the current code
interprets ENODATA from PTRACE_GETREGSET as an indication that the TDB
regset *could* occur on this system, but the inferior stopped outside
a transaction.  However, the Linux kernel actually reports ENODATA
even on systems without the transactional execution facility.  Thus
the logic is now changed to check the TE field in the HWCAP as well.

This version also checks the existence of the TDB regset -- just to be
on the safe side when running on TE-enabled hardware with a kernel
that does not offer the TDB regset for some reason.

gdb/
	* s390-linux-nat.c (s390_read_description): Consider the TE field
	in the HWCAP for determining 'have_regset_tdb'.

gdbserver/
	* linux-s390-low.c (HWCAP_S390_TE): New define.
	(s390_arch_setup): Consider the TE field in the HWCAP for
	determining 'have_regset_tdb'.
2013-11-06 21:44:31 +01:00
Ulrich Weigand 4ac33720d6 gdb/ChangeLog:
2013-09-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	* NEWS: Mention TDB support.
	* features/s390-tdb.xml: New file.
	* features/s390-te-linux64.xml: New file.
	* features/s390x-te-linux64.xml: New file.
	* features/Makefile (WHICH): Add new tdescs above.
	(s390-te-linux64-expedite): Set.
	(s390x-te-linux64-expedite): Set.
	* features/s390-te-linux64.c: New file (generated).
	* features/s390x-te-linux64.c: New file (generated).
	* regformats/s390-te-linux64.dat: New file (generated).
	* regformats/s390x-te-linux64.dat: New file (generated).
	* s390-tdep.h (HWCAP_S390_HIGH_GPRS): Define.
	(HWCAP_S390_TE): Likewise.
	(S390_TDB_DWORD0_REGNUM): Likewise.
	(S390_TDB_DWORD0_REGNUM): Likewise.
	(S390_TDB_ABORT_CODE_REGNUM): Likewise.
	(S390_TDB_CONFLICT_TOKEN_REGNUM): Likewise.
	(S390_TDB_ATIA_REGNUM): Likewise.
	(S390_TDB_R0_REGNUM): Likewise.
	(S390_TDB_R1_REGNUM): Likewise.
	(S390_TDB_R2_REGNUM): Likewise.
	(S390_TDB_R3_REGNUM): Likewise.
	(S390_TDB_R4_REGNUM): Likewise.
	(S390_TDB_R5_REGNUM): Likewise.
	(S390_TDB_R6_REGNUM): Likewise.
	(S390_TDB_R7_REGNUM): Likewise.
	(S390_TDB_R8_REGNUM): Likewise.
	(S390_TDB_R9_REGNUM): Likewise.
	(S390_TDB_R10_REGNUM): Likewise.
	(S390_TDB_R11_REGNUM): Likewise.
	(S390_TDB_R12_REGNUM): Likewise.
	(S390_TDB_R13_REGNUM): Likewise.
	(S390_TDB_R14_REGNUM): Likewise.
	(S390_TDB_R15_REGNUM): Likewise.
	(S390_NUM_REGS): Increase.
	(S390_IS_TDBREGSET_REGNUM): New macro.
	(s390_regmap_tdb): Declare.
	(s390_sizeof_tdbregset): Define.
	(tdesc_s390_te_linux64): Declare.
	(tdesc_s390x_te_linux64): Likewise.
	* s390-tdep.c: Add includes for "auxv.h", <elf.h>,
	"features/s390-te-linux64.c", and "features/s390x-te-linux64.c".
	(s390_regmap_tdb): New regmap.
	(s390_supply_tdb_regset): New function.
	(s390_tdb_regset): New regset.
	(s390_linux64v2_regset_sections): Add TDB regset to list.
	(s390x_linux64v2_regset_sections): Likewise.
	(s390_regset_from_core_section): Recognize TDB core note section.
	(s390_core_read_description): If HWCAP indicates TE support,
	select tdesc_s390_te_linux64 or tdesc_s390_s390x_te_linux64.
	(s390_gdbarch_init): Handle TDB regset.
	(_initialize_s390_tdep): Initialize new tdescs.
	* s390-nat.c (HWCAP_S390_HIGH_GPRS): Remove define.
	(have_regset_tdb): New variable.
	(s390_native_supply): Support register invalidation.
	(fetch_regset): Invalidate registers if ptrace yields ENODATA.
	(check_regset): Treat ENODATA as "regset exists".
	(s390_linux_fetch_inferior_registers): Add TDB.
	(s390_read_description): Check for TDB existence and select
	appropriate tdesc.
	* gdbserver/Makefile.in (clean): Add removal of new makefile
	targets.
	(s390-te-linux64.c): New makefile target.
	(s390x-te-linux64.c): Likewise.
	* gdbserver/configure.srv (srv_regobj): Append new objects
	s390-te-linux64.o and s390x-te-linux64.o.
	(srv_xmlfiles): Append new files s390-te-linux64.xml,
	s390x-te-linux64.xml, and s390-tdb.xml.
	* gdbserver/linux-s390-low.c (init_registers_s390_te_linux64): New
	declaration.
	(tdesc_s390_te_linux64): Likewise.
	(init_registers_s390x_te_linux64): Likewise.
	(tdesc_s390x_te_linux64): Likewise.
	(s390_check_regset): Treat ENODATA as "regset exists".
	(s390_arch_setup): Add TDB regset support.
	(initialize_low_arch): Initialize registers for new tdescs.

gdb/doc/ChangeLog:
2013-09-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	* gdb.texinfo (Decimal Floating Point format): Mention S/390.
	(Standard Target Features): Add new node to menu.
	(S/390 and System z Features): New node.

gdb/testsuite/ChangeLog:
2013-09-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	* gdb.arch/s390-tdbregs.c: New file.
	* gdb.arch/s390-tdbregs.exp: New file.
2013-09-13 14:17:31 +00: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 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
Ulrich Weigand c642a43456 ChangeLog:
* s390-tdep.h (S390_ORIG_R2_REGNUM): Define.
	(S390_LAST_BREAK_REGNUM): Likewise.
	(S390_SYSTEM_CALL_REGNUM): Likewise.
	(S390_NUM_REGS): Update.

	(s390_regmap_last_break): Add declaration.
	(s390x_regmap_last_break): Likewise.
	(s390_regmap_system_call): Likewise.

	(tdesc_s390_linux32v1): Add declaration.
	(tdesc_s390_linux32v2): Likewise.
	(tdesc_s390_linux64v1): Likewise.
	(tdesc_s390_linux64v2): Likewise.
	(tdesc_s390x_linux64v1): Likewise.
	(tdesc_s390x_linux64v2): Likewise.

	* s390-tdep.c: Include new target description files
	"features/s390-linux32v1.c", "features/s390-linux32v2.c",
	"features/s390-linux64v1.c", "features/s390-linux64v2.c",
	"features/s390x-linux64v1.c", and "features/s390x-linux64v2.c".
	(s390_cannot_store_register): New function.
	(s390_write_pc): Likewise.
	(s390_dwarf_regmap): Add fields for new registers.
	(s390_regmap_gregset): Likewise.
	(s390x_regmap_gregset): Likewise.
	(s390_regmap_fpregset): Likewise.
	(s390_regmap_upper): Likewise.
	(s390_regmap_last_break): New variable.
	(s390x_regmap_last_break): Likewise.
	(s390_regmap_system_call): Likewise.
	(s390_last_break_regset): Likewise.
	(s390x_last_break_regset): Likewise.
	(s390_system_call_regset): Likewise.
	(s390_upper_regset_sections): Rename to ...
	(s390_linux64_regset_sections): ... this.
	(s390_linux32_regset_sections): New variable.
	(s390x_linux64_regset_sections): Likewise.
	(s390_linux32v1_regset_sections): Likewise.
	(s390_linux32v2_regset_sections): Likewise.
	(s390_linux64v1_regset_sections): Likewise.
	(s390_linux64v2_regset_sections): Likewise.
	(s390x_linux64v1_regset_sections): Likewise.
	(s390x_linux64v2_regset_sections): Likewise.
	(s390_regset_from_core_section): Handle .reg-s390-last-break and
	.reg-s390-system-call core file sections.
	(s390_core_read_description): Check for presence of
	.reg-s390-last-break and .reg-s390-system-call core file
	sections and return appropriate target description.
	(s390_gdbarch_init): Detect Linux-specific registers "orig_r2",
	"last_break" and "system_call" in target description.  Install
	appropriate gdbarch_core_regset_sections array.
	Call set_gdbarch_cannot_store_register and set_gdbarch_write_pc.
	(_initialize_s390_tdep): Initialize additional target descriptions.

	* s390-nat.c: Include "elf/common.h".
	(PTRACE_GETREGSET, PTRACE_SETREGSET): Define if undefined.
	(have_regset_last_break): New static variable.
	(have_regset_system_call): Likewise.
	(s390_native_supply): Handle S390_ORIG_R2_REGNUM.
	(s390_native_collect): Likewise.
	(fetch_regset, store_regset, check_regset): New functions.
	(s390_linux_fetch_inferior_registers): Handle S390_LAST_BREAK_REGNUM
	and S390_SYSTEM_CALL_REGNUM.
	(s390_linux_store_inferior_registers): Likewise.
	(s390_read_description): Check for presence of NT_S390_LAST_BREAK
	and NT_S390_SYSTEM_CALL regsets and use appropriate description.

	* features/Makefile (WHICH): Add s390-linux32v1, s390-linux64v1,
	s390x-linux64v1, s390-linux32v2, s390-linux64v2, and s390x-linux64v2.
	(s390-linux32v1-expedite): Define.
	(s390-linux32v2-expedite): Likewise.
	(s390-linux64v1-expedite): Likewise.
	(s390-linux64v2-expedite): Likewise.
	(s390x-linux64v1-expedite): Likewise.
	(s390x-linux64v2-expedite): Likewise.

	* features/s390-linux32.xml: Add orig_r2 register.
	* features/s390-linux64.xml: Likewise.
	* features/s390x-linux64.xml: Likewise.
	* features/s390-linux32v1.xml: New file.
	* features/s390-linux32v2.xml: Likewise.
	* features/s390-linux64v1.xml: Likewise.
	* features/s390-linux64v2.xml: Likewise.
	* features/s390x-linux64v1.xml: Likewise.
	* features/s390x-linux64v2.xml: Likewise.

	* features/s390-linux32.c: Regenerate.
	* features/s390-linux64.c: Likewise.
	* features/s390x-linux64.c: Likewise.
	* features/s390-linux32v1.c: New generated file.
	* features/s390-linux32v2.c: Likewise.
	* features/s390-linux64v1.c: Likewise.
	* features/s390-linux64v2.c: Likewise.
	* features/s390x-linux64v1.c: Likewise.
	* features/s390x-linux64v2.c: Likewise.

	* regformats/s390-linux32.dat: Regenerate.
	* regformats/s390-linux64.dat: Regenerate.
	* regformats/s390x-linux64.dat: Regenerate.
	* regformats/s390-linux32v1.dat: New generated file.
	* regformats/s390-linux32v2.dat: Likewise.
	* regformats/s390-linux64v1.dat: Likewise.
	* regformats/s390-linux64v2.dat: Likewise.
	* regformats/s390x-linux64v1.dat: Likewise.
	* regformats/s390x-linux64v2.dat: Likewise.

gdbserver/ChangeLog:

	* Makefile.in (s390-linux32v1.o, s390-linux32v1.c): New rules.
	(s390-linux32v2.o, s390-linux32v2.c): Likewise.
	(s390-linux64v1.o, s390-linux64v1.c): Likewise.
	(s390-linux64v2.o, s390-linux64v2.c): Likewise.
	(s390x-linux64v1.o, s390x-linux64v1.c): Likewise.
	(s390x-linux64v2.o, s390x-linux64v2.c): Likewise.
	* configure.srv [s390*-*-linux*] (srv_regobj): Add new objects.
	(srv_xmlfiles): Add new XML files.

	* linux-s390-low.c: Include "elf/common.h", <sys/ptrace.h>,
	and <sys/uio.h>.
	(PTRACE_GETREGSET, PTRACE_SETREGSET): Define if undefined.
	(init_registers_s390_linux32v1): Add prototype.
	(init_registers_s390_linux32v2): Likewise.
	(init_registers_s390_linux64v1): Likewise.
	(init_registers_s390_linux64v2): Likewise.
	(init_registers_s390x_linux64v1): Likewise.
	(init_registers_s390x_linux64v2): Likewise.
	(s390_num_regs): Increment to 52.
	(s390_regmap): Add orig_r2 register.
	(s390_num_regs_3264): Increment to 68.
	(s390_regmap_3264): Add orig_r2 register.
	(s390_collect_ptrace_register): Handle orig_r2 register.
	(s390_supply_ptrace_register): Likewise.
	(s390_fill_last_break): New function.
	(s390_store_last_break): Likewise.
	(s390_fill_system_call): New function.
	(s390_store_system_call): Likewise.
	(target_regsets): Handle NT_S390_LAST_BREAK and NT_S390_SYSTEM_CALL
	register sets.
	(s390_check_regset): New function.
	(s390_arch_setup): Check for presence of NT_S390_LAST_BREAK and
	NT_S390_SYSTEM_CALL regsets and use appropriate description.
	Update target_regsets for available register sets.

testsuite/ChangeLog:

	* gdb.base/callfuncs.exp (fetch_all_registers): Filter out read-only
	last_break register on s390*-*-* targets.
2011-12-06 14:14:50 +00:00
Ulrich Weigand d6db1fabcc ChangeLog:
* s390-nat.c (SUBOFF): Remove.
	(s390_native_supply, s390_native_collect): New functions.
	(supply_gregset, supply_fpregset): Use s390_native_supply.
	(fill_gregset, fill_fpregset): Use s390_native_collect.

	* s390-tdep.c (s390_pseudo_register_reggroup_p): Update comment.
	(s390_unwind_pseudo_register): New function.
	(s390_prologue_frame_unwind_cache): Unwind PSW address and mask
	registers instead of PC and CC.
	(s390_backchain_frame_unwind_cache): Likewise.
	(s390_sigtramp_frame_unwind_cache): Do not unwind PC, CC, or
	full GPR pseudos.
	(s390_trad_frame_prev_register): New function.
	(s390_frame_prev_register): Use it.
	(s390_sigtramp_frame_prev_register): Likewise.
	(s390_dwarf2_prev_register): Use s390_unwind_pseudo_register.
	(s390_dwarf2_frame_init_reg): Unwind PSW address and mask.  Use
	special callback to unwind any pseudo.

	* features/s390-core32.xml: Add pswm/pswa to save/restore group.
	* features/s390-core64.xml: Likewise.
	* features/s390x-core64.xml: Likewise.
	* features/s390-linux32.c: Regenerate.
	* features/s390-linux64.c: Likewise.
	* features/s390x-linux64.c: Likewise.

gdbserver/ChangeLog:

	* linux-s390-low.c (s390_collect_ptrace_register): Fully convert
	PSW address/mask between 8-byte and 16-byte formats.
	(s390_supply_ptrace_register): Likewise.
	(s390_get_pc, s390_set_pc): 4-byte PSW address always includes
	basic addressing mode bit.
2011-11-30 16:06:55 +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
Ulrich Weigand 92b729071e * linux-ppc-low.c (ppc_arch_setup): Use private regcache to test MSR.
* linux-s390-low.c (ppc_arch_setup): Use private regcache to test PSW.
2010-06-14 13:53:04 +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
Jan Kratochvil 18f5de3bf8 gdb/gdbserver/
* linux-s390-low.c (s390_collect_ptrace_register)
	(s390_supply_ptrace_register): Adjust it for the new regcache parameter.
2010-01-21 19:26:49 +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
Ulrich Weigand 7803799a0f * features/Makefile (WHICH): Add s390-linux32, s390-linux64,
and s390x-linux64.
	(s390-linux32-expedite): Define.
	(s390-linux64-expedite): Define.
	(s390x-linux64-expedite): Define.
	* features/s390-acr.xml: New file.
	* features/s390-fpr.xml: New file.
	* features/s390-core32.xml: New file.
	* features/s390-core64.xml: New file.
	* features/s390x-core64.xml: New file.
	* features/s390-linux32.xml: New file.
	* features/s390-linux64.xml: New file.
	* features/s390x-linux64.xml: New file.
	* features/s390-linux32.c: New generated file.
	* features/s390-linux64.c: New generated file.
	* features/s390x-linux64.c: New generated file.

	* regformats/s390-linux32.dat: New generated file.
	* regformats/s390-linux64.dat: New generated file.
	* regformats/s390x-linux64.dat: New generated file.
	* regformats/reg-s390.dat: Remove.
	* regformats/reg-s390x.dat: Remove.

	* s390-nat.c: Include "auxv.h" and <elf.h>.
	(HWCAP_S390_HIGH_GPRS): Define if undefined.
	(s390_target_wordsize): New function.
	(s390_auxv_parse): Likewise.
	(s390_get_hwcap): Likewise.
	(s390_read_description): Likewise.
	(_initialize_s390_nat): Install s390_auxv_parse and
	s390_read_description.

	* s390-tdep.c: Include "features/s390-linux32.c",
	"features/s390-linux64.c", and "features/s390x-linux64.c".
	(struct gdbarch_tdep): Add gpr_full_regnum, pc_regnum, and cc_regnum.
	(s390_register_call_saved): New function.
	(s390_register_name): Remove.
	(s390_register_type): Remove.
	(s390_dwarf_regmap): Add lower half GPR pseudo DWARF CFI regnums.
	(s390_dwarf_reg_to_regnum): Remap GPR regnums to full GPRs.
	(s390_adjust_frame_regnum): Remap GPR regnums to lower halves for CFI.
	(s390_pseudo_register_name): New function.
	(s390_pseudo_register_type): New function.
	(s390_pseudo_register_read): Handle both 32-bit and 64-bit cases.
	Handle full GPR pesudos and varying pseudo register numbers.
	(s390_pseudo_register_write): Likewise
	(s390x_pseudo_register_read): Remove.
	(s390x_pseudo_register_write): Likewise.
	(s390_register_group): Remove.
	(s390_pseudo_register_group): New function.
	(s390_regmap_gregset): Add GPR upper halves.
	(s390x_regmap_gregset): Likewise.
	(s390_regmap_fpregset): Likewise.
	(s390_regmap_upper): New global variable.
	(s390_upper_regset): New global variable.
	(s390_upper_regset_sections): New global variable.
	(s390_regset_from_core_section): Handle GPR upper halves.
	(s390_core_read_description): New function.
	(s390_prologue_frame_unwind_cache): Set up ABI call-saved/clobbered
	register information.  Handle varying pseudo register numbers.
	(s390_backchain_frame_unwind_cache): Likewise.
	(s390_frame_prev_register): Unwind full GPRs to show lower halves.
	(s390_stub_frame_unwind_cache): Handle varying pseudo register numbers.
	(s390_sigtramp_frame_unwind_cache): Unwind PSWM and PSWA as well as
	PC and CC pseudos.  Unwind upper halves and full GPRs as appropriate.
	Handle varying pseudo register numbers.
	(s390_unwind_pc): Handle varying pseudo register numbers.
	(s390_dwarf2_prev_register): New function.
	(s390_dwarf2_frame_init_reg): Set up ABI call-saved/clobbered
	register information.  Handle varying pseudo register numbers.
	Install s390_dwarf2_prev_register to unwind full GPRs.
	(s390_gdbarch_init): Handle target descriptions.  Assign varying
	pseudo register numbers.  Install s390_adjust_frame_regnum.
	(_initialize_s390_tdep): Initialize target descriptions.

	* s390-tdep.h (S390_R0_UPPER_REGNUM .. S390_R15_UPPER_REGNUM): Define.
	(S390_NUM_REGS): Redefine to include upper half registers.
	(S390_PC_REGNUM, S390_CC_REGNUM): Remove.
	(S390_NUM_PSEUDO_REGS, S390_NUM_TOTAL_REGS): Likewise.
	(tdesc_s390_linux32): Add declaration.
	(tdesc_s390_linux64): Likewise.
	(tdesc_s390x_linux64): Likewise.

gdb/testsuite/
	* gdb.xml/tdesc-regs.exp: Support s390*-*-* targets.

gdbserver/
	* Makefile.in (clean): Remove new generated files.
	(reg-s390.o, reg-s390.c): Remove rules.
	(reg-s390x.o, reg-s390x.c): Likewise.
	(s390-linux32.o, s390-linux32.c): Add rules.
	(s390-linux64.o, s390-linux64.c): Likewise.
	(s390x-linux64.o, s390x-linux64.c): Likewise.
	* configure.srv (s390*-*-linux*): Update srv_regobj and srv_xmlfiles.
	* linux-s390-low.c: Include <elf.h>.
	(HWCAP_S390_HIGH_GPRS): Define if undefined.
	(init_registers_s390): Remove prototype.
	(init_registers_s390x): Likewise.
	(init_registers_s390_linux32): Add prototype.
	(init_registers_s390_linux64): Likewise.
	(init_registers_s390x_linux64): Likewise.
	(s390_num_regs_3264): New define.
	(s390_regmap_3264): New global variable.
	(s390_cannot_fetch_register): Remove obsolete check.
	(s390_cannot_store_register): Likewise.
	(s390_collect_ptrace_register): Handle upper/lower register halves.
	(s390_supply_ptrace_register): Likewise.
	(s390_fill_gregset): Update to register number changes.
	(s390_get_hwcap): New routine.
	(s390_arch_setup): Detect 32-bit process running on 64-bit system.
	Install appropriate regmap and register set.
2010-01-04 15:03:01 +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
Ulrich Weigand ee1a7ae440 * linux-low.h (struct linux_target_ops): Replace left_pad_xfer field
by collect_ptrace_register and supply_ptrace_register hooks.
	* linux-low.c (fetch_register): Use supply_ptrace_register callback
	instead of checking for the_low_target.left_pad_xfer.
	(usr_store_inferior_registers): Use collect_ptrace_register callback
	instead of checking for the_low_target.left_pad_xfer.

	* linux-s390-low.c (s390_collect_ptrace_register): New function.
	(s390_supply_ptrace_register): Likewise.
	(s390_fill_gregset): Call s390_collect_ptrace_register.
	(the_low_target): Update.

	* linux-ppc64-low.c (ppc_collect_ptrace_register): New function.
	(ppc_supply_ptrace_register): Likewise.
	(the_low_target): Update.

	* linux-i386-low.c (the_low_target): Update.
	* linux-x86-64-low.c (the_low_target): Update.
2008-02-27 03:33:07 +00:00