diff options
-rw-r--r-- | gdbserver/ChangeLog | 44 | ||||
-rw-r--r-- | gdbserver/linux-aarch64-low.cc | 17 | ||||
-rw-r--r-- | gdbserver/linux-arm-low.cc | 19 | ||||
-rw-r--r-- | gdbserver/linux-low.cc | 49 | ||||
-rw-r--r-- | gdbserver/linux-low.h | 20 | ||||
-rw-r--r-- | gdbserver/linux-ppc-low.cc | 1 | ||||
-rw-r--r-- | gdbserver/linux-s390-low.cc | 1 | ||||
-rw-r--r-- | gdbserver/linux-x86-low.cc | 15 |
8 files changed, 123 insertions, 43 deletions
diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog index 9f14c57..4649ec2 100644 --- a/gdbserver/ChangeLog +++ b/gdbserver/ChangeLog @@ -1,5 +1,49 @@ 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 override the process_stratum_target's op definition in linux_process_target to return true. diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 4f7c257..f1eae95 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -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. */ diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc index 2e3d00a..4577c83 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -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. */ diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 5661543..cd04160 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -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 () { diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index 0182be1..1f1c382 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -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 (); }; diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc index 5c69307..71ad842 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -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, }; diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc index 3ab14d8..d09860f 100644 --- a/gdbserver/linux-s390-low.cc +++ b/gdbserver/linux-s390-low.cc @@ -2855,7 +2855,6 @@ s390_target::emit_ops () } struct linux_target_ops the_low_target = { - NULL, /* get_syscall_trapinfo */ s390_get_ipa_tdesc_idx, }; diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index c05928d..2837994 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -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, }; |