gdbserver/linux-low: turn watchpoint ops into methods

gdbserver/ChangeLog:
2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn the 'stopped_by_watchpoint' and 'stopped_data_address' linux
	target ops into methods of linux_process_target.

	* linux-low.h (struct linux_target_ops): Remove the ops.
	(class linux_process_target) <check_stopped_by_watchpoint>
	<low_stopped_by_watchpoint>
	<low_stopped_data_address>: Declare.
	* linux-low.cc (check_stopped_by_watchpoint): Turn into...
	(linux_process_target::check_stopped_by_watchpoint): ...this.
	(linux_process_target::low_stopped_by_watchpoint): Define.
	(linux_process_target::low_stopped_data_address): Define.
	* linux-x86-low.cc (class x86_target) <low_stopped_by_watchpoint>
	<low_stopped_data_address>: Declare.
	(x86_stopped_by_watchpoint): Turn into...
	(x86_target::low_stopped_by_watchpoint): ...this.
	(x86_stopped_data_address): Turn into...
	(x86_target::low_stopped_data_address): ...this.
	(the_low_target): Remove the op fields.
	* linux-aarch64-low.cc (class aarch64_target)
	<low_stopped_by_watchpoint>
	<low_stopped_data_address>: Declare.
	(aarch64_stopped_by_watchpoint): Turn into...
	(aarch64_target::low_stopped_by_watchpoint): ...this.
	(aarch64_stopped_data_address): Turn into...
	(aarch64_target::low_stopped_data_address): ...this.
	(the_low_target): Remove the op fields.
	* linux-arm-low.cc (class arm_target) <low_stopped_by_watchpoint>
	<low_stopped_data_address>: Declare.
	(arm_stopped_by_watchpoint): Turn into...
	(arm_target::low_stopped_by_watchpoint): ...this.
	(arm_stopped_data_address): Turn into...
	(arm_target::low_stopped_data_address): ...this.
	(the_low_target): Remove the op fields.
	* linux-crisv32-low.cc (class crisv32_target)
	<low_stopped_by_watchpoint>
	<low_stopped_data_address>: Declare.
	(cris_stopped_by_watchpoint): Turn into...
	(crisv32_target::low_stopped_by_watchpoint): ...this.
	(cris_stopped_data_address): Turn into...
	(crisv32_target::low_stopped_data_address): ...this.
	(the_low_target): Remove the op fields.
	* linux-mips-low.cc (class mips_target) <low_stopped_by_watchpoint>
	<low_stopped_data_address>: Declare.
	(mips_stopped_by_watchpoint): Turn into...
	(mips_target::low_stopped_by_watchpoint): ...this.
	(mips_stopped_data_address): Turn into...
	(mips_target::low_stopped_data_address): ...this.
	(the_low_target): Remove the op fields.
	* linux-bfin-low.cc (the_low_target): Remove the op fields.
	* linux-m32r-low.cc (the_low_target): Ditto.
	* linux-m68k-low.cc (the_low_target): Ditto.
	* linux-ppc-low.cc (the_low_target): Ditto.
	* linux-s390-low.cc (the_low_target): Ditto.
	* linux-sh-low.cc (the_low_target): Ditto.
	* linux-sparc-low.cc (the_low_target): Ditto.
	* linux-tic6x-low.cc (the_low_target): Ditto.
	* linux-tile-low.cc (the_low_target): Ditto.
	* linux-xtensa-low.cc (the_low_target): Ditto.
This commit is contained in:
Tankut Baris Aktemur
2020-04-02 15:11:27 +02:00
parent 9db9aa232a
commit ac1bbaca10
18 changed files with 158 additions and 107 deletions

View File

@ -786,8 +786,6 @@ get_syscall_trapinfo (struct lwp_info *lwp, int *sysno)
current_thread = saved_thread;
}
static int check_stopped_by_watchpoint (struct lwp_info *child);
bool
linux_process_target::save_stop_reason (lwp_info *lwp)
{
@ -2245,48 +2243,35 @@ dequeue_one_deferred_signal (struct lwp_info *lwp, int *wstat)
return 0;
}
/* Fetch the possibly triggered data watchpoint info and store it in
CHILD.
On some archs, like x86, that use debug registers to set
watchpoints, it's possible that the way to know which watched
address trapped, is to check the register that is used to select
which address to watch. Problem is, between setting the watchpoint
and reading back which data address trapped, the user may change
the set of watchpoints, and, as a consequence, GDB changes the
debug registers in the inferior. To avoid reading back a stale
stopped-data-address when that happens, we cache in LP the fact
that a watchpoint trapped, and the corresponding data address, as
soon as we see CHILD stop with a SIGTRAP. If GDB changes the debug
registers meanwhile, we have the cached data we can rely on. */
static int
check_stopped_by_watchpoint (struct lwp_info *child)
bool
linux_process_target::check_stopped_by_watchpoint (lwp_info *child)
{
if (the_low_target.stopped_by_watchpoint != NULL)
struct thread_info *saved_thread = current_thread;
current_thread = get_lwp_thread (child);
if (low_stopped_by_watchpoint ())
{
struct thread_info *saved_thread;
saved_thread = current_thread;
current_thread = get_lwp_thread (child);
if (the_low_target.stopped_by_watchpoint ())
{
child->stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
if (the_low_target.stopped_data_address != NULL)
child->stopped_data_address
= the_low_target.stopped_data_address ();
else
child->stopped_data_address = 0;
}
current_thread = saved_thread;
child->stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
child->stopped_data_address = low_stopped_data_address ();
}
current_thread = saved_thread;
return child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
}
bool
linux_process_target::low_stopped_by_watchpoint ()
{
return false;
}
CORE_ADDR
linux_process_target::low_stopped_data_address ()
{
return 0;
}
/* Return the ptrace options that we want to try to enable. */
static int