gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method

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

	Turn the 'get_syscall_trapinfo' linux target op into a method
	of process_stratum_target.

	* linux-low.h (struct linux_target_ops): Remove the op.
	(class linux_process_target) <get_syscall_trapinfo>
	<gdb_catch_this_syscall>
	<low_supports_catch_syscall>
	<low_get_syscall_trapinfo>: Declare.
	* linux-low.cc (get_syscall_trapinfo): Turn into...
	(linux_process_target::get_syscall_trapinfo): ...this.
	(linux_process_target::low_get_syscall_trapinfo): Define.
	(gdb_catch_this_syscall_p): Turn into...
	(linux_process_target::gdb_catch_this_syscall): ...this.
	(linux_process_target::low_supports_catch_syscall): Define.

	Update the callers below.

	(linux_process_target::wait_1)
	(linux_process_target::supports_catch_syscall)

	* linux-x86-low.cc (class x86_target) <low_supports_catch_syscall>
	<low_get_syscall_trapinfo>: Declare.
	(x86_target::low_supports_catch_syscall): Define.
	(x86_get_syscall_trapinfo): Turn into...
	(x86_target::low_get_syscall_trapinfo): ...this.
	(the_low_target): Remove the op field.
	* linux-aarch64-low.cc (class aarch64_target)
	<low_supports_catch_syscall>
	<low_get_syscall_trapinfo>: Declare.
	(aarch64_target::low_supports_catch_syscall): Define.
	(aarch64_get_syscall_trapinfo): Turn into...
	(aarch64_target::low_get_syscall_trapinfo): ...this.
	(the_low_target): Remove the op field.
	* linux-arm-low.cc (class arm_target) <low_supports_catch_syscall>
	<low_get_syscall_trapinfo>: Declare.
	(arm_target::low_supports_catch_syscall): Define.
	(arm_get_syscall_trapinfo): Turn into...
	(arm_target::low_get_syscall_trapinfo): ...this.
	(the_low_target): Remove the op field.
	* linux-ppc-low.cc (the_low_target): Remove the op field.
	* linux-s390-low.cc (the_low_target): Remove the op field.
This commit is contained in:
Tankut Baris Aktemur 2020-04-02 15:11:31 +02:00
parent b31cdfa69f
commit 9eedd27d42
8 changed files with 123 additions and 43 deletions

View File

@ -1,3 +1,47 @@
2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Turn the 'get_syscall_trapinfo' linux target op into a method
of process_stratum_target.
* linux-low.h (struct linux_target_ops): Remove the op.
(class linux_process_target) <get_syscall_trapinfo>
<gdb_catch_this_syscall>
<low_supports_catch_syscall>
<low_get_syscall_trapinfo>: Declare.
* linux-low.cc (get_syscall_trapinfo): Turn into...
(linux_process_target::get_syscall_trapinfo): ...this.
(linux_process_target::low_get_syscall_trapinfo): Define.
(gdb_catch_this_syscall_p): Turn into...
(linux_process_target::gdb_catch_this_syscall): ...this.
(linux_process_target::low_supports_catch_syscall): Define.
Update the callers below.
(linux_process_target::wait_1)
(linux_process_target::supports_catch_syscall)
* linux-x86-low.cc (class x86_target) <low_supports_catch_syscall>
<low_get_syscall_trapinfo>: Declare.
(x86_target::low_supports_catch_syscall): Define.
(x86_get_syscall_trapinfo): Turn into...
(x86_target::low_get_syscall_trapinfo): ...this.
(the_low_target): Remove the op field.
* linux-aarch64-low.cc (class aarch64_target)
<low_supports_catch_syscall>
<low_get_syscall_trapinfo>: Declare.
(aarch64_target::low_supports_catch_syscall): Define.
(aarch64_get_syscall_trapinfo): Turn into...
(aarch64_target::low_get_syscall_trapinfo): ...this.
(the_low_target): Remove the op field.
* linux-arm-low.cc (class arm_target) <low_supports_catch_syscall>
<low_get_syscall_trapinfo>: Declare.
(arm_target::low_supports_catch_syscall): Define.
(arm_get_syscall_trapinfo): Turn into...
(arm_target::low_get_syscall_trapinfo): ...this.
(the_low_target): Remove the op field.
* linux-ppc-low.cc (the_low_target): Remove the op field.
* linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Remove the 'supports_hardware_single_step' linux target op and

View File

@ -125,6 +125,10 @@ protected:
int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override;
bool low_supports_range_stepping () override;
bool low_supports_catch_syscall () override;
void low_get_syscall_trapinfo (regcache *regcache, int *sysno) override;
};
/* The singleton target ops object. */
@ -768,10 +772,16 @@ aarch64_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp)
return 0;
}
/* Implementation of linux_target_ops method "get_syscall_trapinfo". */
bool
aarch64_target::low_supports_catch_syscall ()
{
return true;
}
static void
aarch64_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
/* Implementation of linux target ops method "low_get_syscall_trapinfo". */
void
aarch64_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno)
{
int use_64bit = register_size (regcache->tdesc, 0) == 8;
@ -3159,7 +3169,6 @@ aarch64_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
struct linux_target_ops the_low_target =
{
aarch64_get_syscall_trapinfo,
};
/* The linux target ops object. */

View File

@ -113,6 +113,10 @@ protected:
void low_new_fork (process_info *parent, process_info *child) override;
void low_prepare_to_resume (lwp_info *lwp) override;
bool low_supports_catch_syscall () override;
void low_get_syscall_trapinfo (regcache *regcache, int *sysno) override;
};
/* The singleton target ops object. */
@ -1038,10 +1042,16 @@ arm_target::supports_hardware_single_step ()
return false;
}
/* Implementation of linux_target_ops method "get_syscall_trapinfo". */
bool
arm_target::low_supports_catch_syscall ()
{
return true;
}
static void
arm_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
/* Implementation of linux target ops method "low_get_syscall_trapinfo". */
void
arm_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno)
{
if (arm_is_thumb_mode ())
collect_register_by_name (regcache, "r7", sysno);
@ -1052,7 +1062,7 @@ arm_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
collect_register_by_name (regcache, "pc", &pc);
if (the_target->read_memory (pc - 4, (unsigned char *) &insn, 4))
if (read_memory (pc - 4, (unsigned char *) &insn, 4))
*sysno = UNKNOWN_SYSCALL;
else
{
@ -1119,7 +1129,6 @@ arm_target::get_regs_info ()
}
struct linux_target_ops the_low_target = {
arm_get_syscall_trapinfo,
};
/* The linux target ops object. */

View File

@ -754,28 +754,17 @@ linux_process_target::get_pc (lwp_info *lwp)
return pc;
}
/* This function should only be called if LWP got a SYSCALL_SIGTRAP.
Fill *SYSNO with the syscall nr trapped. */
static void
get_syscall_trapinfo (struct lwp_info *lwp, int *sysno)
void
linux_process_target::get_syscall_trapinfo (lwp_info *lwp, int *sysno)
{
struct thread_info *saved_thread;
struct regcache *regcache;
if (the_low_target.get_syscall_trapinfo == NULL)
{
/* If we cannot get the syscall trapinfo, report an unknown
system call number. */
*sysno = UNKNOWN_SYSCALL;
return;
}
saved_thread = current_thread;
current_thread = get_lwp_thread (lwp);
regcache = get_thread_regcache (current_thread, 1);
(*the_low_target.get_syscall_trapinfo) (regcache, sysno);
low_get_syscall_trapinfo (regcache, sysno);
if (debug_threads)
debug_printf ("get_syscall_trapinfo sysno %d\n", *sysno);
@ -783,6 +772,13 @@ get_syscall_trapinfo (struct lwp_info *lwp, int *sysno)
current_thread = saved_thread;
}
void
linux_process_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno)
{
/* By default, report an unknown system call number. */
*sysno = UNKNOWN_SYSCALL;
}
bool
linux_process_target::save_stop_reason (lwp_info *lwp)
{
@ -2961,29 +2957,26 @@ gdb_catching_syscalls_p (struct lwp_info *event_child)
return !proc->syscalls_to_catch.empty ();
}
/* Returns 1 if GDB is interested in the event_child syscall.
Only to be called when stopped reason is SYSCALL_SIGTRAP. */
static int
gdb_catch_this_syscall_p (struct lwp_info *event_child)
bool
linux_process_target::gdb_catch_this_syscall (lwp_info *event_child)
{
int sysno;
struct thread_info *thread = get_lwp_thread (event_child);
struct process_info *proc = get_thread_process (thread);
if (proc->syscalls_to_catch.empty ())
return 0;
return false;
if (proc->syscalls_to_catch[0] == ANY_SYSCALL)
return 1;
return true;
get_syscall_trapinfo (event_child, &sysno);
for (int iter : proc->syscalls_to_catch)
if (iter == sysno)
return 1;
return true;
return 0;
return false;
}
ptid_t
@ -3326,7 +3319,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
/* Check if GDB is interested in this syscall. */
if (WIFSTOPPED (w)
&& WSTOPSIG (w) == SYSCALL_SIGTRAP
&& !gdb_catch_this_syscall_p (event_child))
&& !gdb_catch_this_syscall (event_child))
{
if (debug_threads)
{
@ -6404,10 +6397,16 @@ linux_process_target::read_loadmap (const char *annex, CORE_ADDR offset,
bool
linux_process_target::supports_catch_syscall ()
{
return (the_low_target.get_syscall_trapinfo != NULL
return (low_supports_catch_syscall ()
&& linux_supports_tracesysgood ());
}
bool
linux_process_target::low_supports_catch_syscall ()
{
return false;
}
int
linux_process_target::get_ipa_tdesc_idx ()
{

View File

@ -131,10 +131,6 @@ struct lwp_info;
struct linux_target_ops
{
/* Fill *SYSNO with the syscall nr trapped. Only to be called when
inferior is stopped due to SYSCALL_SIGTRAP. */
void (*get_syscall_trapinfo) (struct regcache *regcache, int *sysno);
/* See target.h. */
int (*get_ipa_tdesc_idx) (void);
};
@ -591,6 +587,14 @@ private: /* Back to private. */
fast_tpoint_collect_result linux_fast_tracepoint_collecting
(lwp_info *lwp, fast_tpoint_collect_status *status);
/* This function should only be called if LWP got a SYSCALL_SIGTRAP.
Fill *SYSNO with the syscall nr trapped. */
void get_syscall_trapinfo (lwp_info *lwp, int *sysno);
/* Returns true if GDB is interested in the event_child syscall.
Only to be called when stopped reason is SYSCALL_SIGTRAP. */
bool gdb_catch_this_syscall (lwp_info *event_child);
protected:
/* The architecture-specific "low" methods are listed below. */
@ -684,6 +688,14 @@ protected:
/* Returns true if the low target supports range stepping. */
virtual bool low_supports_range_stepping ();
/* Return true if the target supports catch syscall. Such targets
override the low_get_syscall_trapinfo method below. */
virtual bool low_supports_catch_syscall ();
/* Fill *SYSNO with the syscall nr trapped. Only to be called when
inferior is stopped due to SYSCALL_SIGTRAP. */
virtual void low_get_syscall_trapinfo (regcache *regcache, int *sysno);
/* How many bytes the PC should be decremented after a break. */
virtual int low_decr_pc_after_break ();
};

View File

@ -3446,7 +3446,6 @@ ppc_get_ipa_tdesc_idx (void)
}
struct linux_target_ops the_low_target = {
NULL, /* get_syscall_trapinfo */
ppc_get_ipa_tdesc_idx,
};

View File

@ -2855,7 +2855,6 @@ s390_target::emit_ops ()
}
struct linux_target_ops the_low_target = {
NULL, /* get_syscall_trapinfo */
s390_get_ipa_tdesc_idx,
};

View File

@ -176,6 +176,10 @@ protected:
bool low_supports_range_stepping () override;
bool low_supports_catch_syscall () override;
void low_get_syscall_trapinfo (regcache *regcache, int *sysno) override;
private:
/* Update all the target description of all processes; a new GDB
@ -1110,11 +1114,17 @@ x86_target::low_arch_setup ()
current_process ()->tdesc = x86_linux_read_description ();
}
bool
x86_target::low_supports_catch_syscall ()
{
return true;
}
/* Fill *SYSNO and *SYSRET with the syscall nr trapped and the syscall return
code. This should only be called if LWP got a SYSCALL_SIGTRAP. */
static void
x86_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
void
x86_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno)
{
int use_64bit = register_size (regcache->tdesc, 0) == 8;
@ -2985,7 +2995,6 @@ x86_get_ipa_tdesc_idx (void)
struct linux_target_ops the_low_target =
{
x86_get_syscall_trapinfo,
x86_get_ipa_tdesc_idx,
};