+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
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. */
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;
struct linux_target_ops the_low_target =
{
- aarch64_get_syscall_trapinfo,
};
/* The linux target ops object. */
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. */
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);
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
{
}
struct linux_target_ops the_low_target = {
- arm_get_syscall_trapinfo,
};
/* The linux target ops object. */
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);
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)
{
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
/* 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)
{
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 ()
{
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);
};
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. */
/* 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 ();
};
}
struct linux_target_ops the_low_target = {
- NULL, /* get_syscall_trapinfo */
ppc_get_ipa_tdesc_idx,
};
}
struct linux_target_ops the_low_target = {
- NULL, /* get_syscall_trapinfo */
s390_get_ipa_tdesc_idx,
};
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
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;
struct linux_target_ops the_low_target =
{
- x86_get_syscall_trapinfo,
x86_get_ipa_tdesc_idx,
};