binutils-gdb/gdb/nat
Pedro Alves e7ad2f145c Handle MIPS Linux SIGTRAP siginfo.si_code values
This unbreaks pending/delayed breakpoints handling, as well as
hardware watchpoints, on MIPS.

Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html

The MIPS kernel reports SI_KERNEL for all kernel generated traps,
instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this.

Basically, this commit:

- Folds watchpoints logic into check_stopped_by_breakpoint, and
  renames it to save_stop_reason.

- Adds GDB_ARCH_IS_TRAP_HWBKPT.

- Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and
  GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL.  In save_stop_reason, we
  handle the case of the same si_code returning true for both
  TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers
  say.

Tested on x86-64 Fedora 20, native and gdbserver.

gdb/ChangeLog:
2016-02-24  Pedro Alves  <palves@redhat.com>

	* linux-nat.c (save_sigtrap) Delete.
	(stop_wait_callback): Call save_stop_reason instead of
	save_sigtrap.
	(check_stopped_by_breakpoint): Rename to ...
	(save_stop_reason): ... this.  Bits of save_sigtrap folded here.
	Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous
	GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT.  Factor out
	common code between the USE_SIGTRAP_SIGINFO and
	!USE_SIGTRAP_SIGINFO blocks.
	(linux_nat_filter_event): Call save_stop_reason instead of
	save_sigtrap.
	* nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT
	si_code for MIPS.
	* nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table.  Add
	comments on MIPS behavior.
	(GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs.

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

	* linux-low.c (check_stopped_by_breakpoint): Rename to ...
	(save_stop_reason): ... this.  Use GDB_ARCH_IS_TRAP_HWBKPT and
	handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT.
	Factor out common code between the USE_SIGTRAP_SIGINFO and
	!USE_SIGTRAP_SIGINFO blocks.
	(linux_low_filter_event): Call save_stop_reason instead of
	check_stopped_by_breakpoint and check_stopped_by_watchpoint.
	Update comments.
	(linux_wait_1): Update comments.
2016-02-24 22:52:06 +00:00
..
aarch64-linux-hw-point.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
aarch64-linux-hw-point.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
aarch64-linux.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
aarch64-linux.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
amd64-linux-siginfo.c Adaptation of siginfo fixup for the new bnd fields 2016-02-02 12:02:16 +01:00
amd64-linux-siginfo.h Adaptation of siginfo fixup for the new bnd fields 2016-02-02 12:02:16 +01:00
gdb_ptrace.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
gdb_thread_db.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
glibc_thread_db.h Move shared native target specific code to gdb/nat 2014-06-20 14:06:48 +01:00
linux-btrace.c Remove trademark acknowledgements throughout 2016-01-12 15:03:11 +00:00
linux-btrace.h Remove trademark acknowledgements throughout 2016-01-12 15:03:11 +00:00
linux-namespaces.c Fix gdbserver build failure on targets without fork 2016-01-18 11:39:42 +00:00
linux-namespaces.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
linux-nat.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
linux-osdata.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
linux-osdata.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
linux-personality.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
linux-personality.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
linux-procfs.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
linux-procfs.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
linux-ptrace.c Fix invalid conversion from void * to gdb_byte * 2016-01-12 16:29:30 +00:00
linux-ptrace.h Handle MIPS Linux SIGTRAP siginfo.si_code values 2016-02-24 22:52:06 +00:00
linux-waitpid.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
linux-waitpid.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mips-linux-watch.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
mips-linux-watch.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
ppc-linux.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
ppc-linux.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
x86-cpuid.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
x86-dregs.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
x86-dregs.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
x86-gcc-cpuid.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
x86-linux-dregs.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
x86-linux-dregs.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
x86-linux.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
x86-linux.h GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00