From patchwork Fri Mar 6 21:31:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tankut Baris Aktemur X-Patchwork-Id: 38513 Received: (qmail 56036 invoked by alias); 6 Mar 2020 21:33:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 53673 invoked by uid 89); 6 Mar 2020 21:32:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mga03.intel.com Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Mar 2020 21:32:36 +0000 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2020 13:32:22 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga004.jf.intel.com with ESMTP; 06 Mar 2020 13:32:21 -0800 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 026LWKVB022497; Fri, 6 Mar 2020 21:32:20 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 026LWKPe020509; Fri, 6 Mar 2020 22:32:20 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 026LWKbj020505; Fri, 6 Mar 2020 22:32:20 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 24/31] gdbserver/linux-low: turn 'get_thread_area' into a method Date: Fri, 6 Mar 2020 22:31:32 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes gdbserver/ChangeLog: 2020-03-06 Tankut Baris Aktemur Turn the 'get_thread_area' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) : Declare. * linux-low.cc (supports_fast_tracepoints): Remove. (linux_fast_tracepoint_collecting): Turn into... (linux_process_target::linux_fast_tracepoint_collecting): ...this. (linux_process_target::low_get_thread_area): Define. (stuck_in_jump_pad_callback): Turn into... (linux_process_target::stuck_in_jump_pad): ...this. Update the caller below. (linux_process_target::stabilize_threads) * linux-x86-low.cc (class x86_target) : Declare. (x86_get_thread_area): Turn into... (x86_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) : Declare. (aarch64_get_thread_area): Turn into... (aarch64_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) : Declare. (ppc_get_thread_area): Turn into... (ppc_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) : Declare. (s390_get_thread_area): Turn into... (s390_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (the_low_target): Remove the op field. * linux-bfin-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-sh-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. --- gdbserver/linux-aarch64-low.cc | 9 +++--- gdbserver/linux-arm-low.cc | 1 - gdbserver/linux-bfin-low.cc | 1 - gdbserver/linux-crisv32-low.cc | 1 - gdbserver/linux-low.cc | 50 ++++++++++++++-------------------- gdbserver/linux-low.h | 19 ++++++++++--- gdbserver/linux-m32r-low.cc | 1 - gdbserver/linux-m68k-low.cc | 1 - gdbserver/linux-ppc-low.cc | 7 +++-- gdbserver/linux-s390-low.cc | 9 +++--- gdbserver/linux-sh-low.cc | 1 - gdbserver/linux-tic6x-low.cc | 1 - gdbserver/linux-tile-low.cc | 1 - gdbserver/linux-x86-low.cc | 7 +++-- gdbserver/linux-xtensa-low.cc | 1 - 15 files changed, 53 insertions(+), 57 deletions(-) diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 833652c214b..5477bd60316 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -108,6 +108,8 @@ protected: void low_new_fork (process_info *parent, process_info *child) override; void low_prepare_to_resume (lwp_info *lwp) override; + + int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override; }; /* The singleton target ops object. */ @@ -732,10 +734,10 @@ aarch64_target::supports_tracepoints () } } -/* Implementation of linux_target_ops method "get_thread_area". */ +/* Implementation of linux target ops method "low_get_thread_area". */ -static int -aarch64_get_thread_area (int lwpid, CORE_ADDR *addrp) +int +aarch64_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp) { struct iovec iovec; uint64_t reg; @@ -3150,7 +3152,6 @@ aarch64_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - aarch64_get_thread_area, aarch64_install_fast_tracepoint_jump_pad, aarch64_emit_ops, aarch64_get_min_fast_tracepoint_insn_len, diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc index ae415cd9db7..c5c27fd7435 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -1119,7 +1119,6 @@ arm_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* get_thread_area */ NULL, /* install_fast_tracepoint_jump_pad */ NULL, /* emit_ops */ NULL, /* get_min_fast_tracepoint_insn_len */ diff --git a/gdbserver/linux-bfin-low.cc b/gdbserver/linux-bfin-low.cc index 494adefe79b..2caad4910dc 100644 --- a/gdbserver/linux-bfin-low.cc +++ b/gdbserver/linux-bfin-low.cc @@ -165,7 +165,6 @@ bfin_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* get_thread_area */ NULL, /* install_fast_tracepoint_jump_pad */ NULL, /* emit_ops */ NULL, /* get_min_fast_tracepoint_insn_len */ diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc index 8c75bd86387..ccb14b4077a 100644 --- a/gdbserver/linux-crisv32-low.cc +++ b/gdbserver/linux-crisv32-low.cc @@ -470,7 +470,6 @@ crisv32_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* get_thread_area */ NULL, /* install_fast_tracepoint_jump_pad */ NULL, /* emit_ops */ NULL, /* get_min_fast_tracepoint_insn_len */ diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index cc4230cd6e1..a183aced74d 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -322,16 +322,6 @@ linux_process_target::low_get_next_pcs (regcache *regcache) "implemented"); } -/* Returns true if this target can support fast tracepoints. This - does not mean that the in-process agent has been loaded in the - inferior. */ - -static int -supports_fast_tracepoints (void) -{ - return the_low_target.install_fast_tracepoint_jump_pad != NULL; -} - /* True if LWP is stopped in its stepping range. */ static int @@ -1997,29 +1987,29 @@ handle_tracepoints (struct lwp_info *lwp) return 0; } -/* Convenience wrapper. Returns information about LWP's fast tracepoint - collection status. */ - -static fast_tpoint_collect_result -linux_fast_tracepoint_collecting (struct lwp_info *lwp, - struct fast_tpoint_collect_status *status) +fast_tpoint_collect_result +linux_process_target::linux_fast_tracepoint_collecting + (lwp_info *lwp, fast_tpoint_collect_status *status) { CORE_ADDR thread_area; struct thread_info *thread = get_lwp_thread (lwp); - if (the_low_target.get_thread_area == NULL) - return fast_tpoint_collect_result::not_collecting; - /* Get the thread area address. This is used to recognize which thread is which when tracing with the in-process agent library. We don't read anything from the address, and treat it as opaque; it's the address itself that we assume is unique per-thread. */ - if ((*the_low_target.get_thread_area) (lwpid_of (thread), &thread_area) == -1) + if (low_get_thread_area (lwpid_of (thread), &thread_area) == -1) return fast_tpoint_collect_result::not_collecting; return fast_tracepoint_collecting (thread_area, lwp->stop_pc, status); } +int +linux_process_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp) +{ + return -1; +} + bool linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat) { @@ -2834,7 +2824,6 @@ unsuspend_all_lwps (struct lwp_info *except) }); } -static bool stuck_in_jump_pad_callback (thread_info *thread); static bool lwp_running (thread_info *thread); /* Stabilize threads (move out of jump pads). @@ -2870,7 +2859,10 @@ static bool lwp_running (thread_info *thread); void linux_process_target::stabilize_threads () { - thread_info *thread_stuck = find_thread (stuck_in_jump_pad_callback); + thread_info *thread_stuck = find_thread ([this] (thread_info *thread) + { + return stuck_in_jump_pad (thread); + }); if (thread_stuck != NULL) { @@ -2926,7 +2918,10 @@ linux_process_target::stabilize_threads () if (debug_threads) { - thread_stuck = find_thread (stuck_in_jump_pad_callback); + thread_stuck = find_thread ([this] (thread_info *thread) + { + return stuck_in_jump_pad (thread); + }); if (thread_stuck != NULL) debug_printf ("couldn't stabilize, LWP %ld got stuck in jump pad\n", @@ -3949,13 +3944,8 @@ linux_process_target::wait_for_sigstop () } } -/* Returns true if THREAD is stopped in a jump pad, and we can't - move it out, because we need to report the stop event to GDB. For - example, if the user puts a breakpoint in the jump pad, it's - because she wants to debug it. */ - -static bool -stuck_in_jump_pad_callback (thread_info *thread) +bool +linux_process_target::stuck_in_jump_pad (thread_info *thread) { struct lwp_info *lwp = get_thread_lwp (thread); diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index 5c2de8afe93..999277eed5d 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -131,10 +131,6 @@ struct lwp_info; struct linux_target_ops { - /* Fill ADDRP with the thread area address of LWPID. Returns 0 on - success, -1 on failure. */ - int (*get_thread_area) (int lwpid, CORE_ADDR *addrp); - /* Install a fast tracepoint jump pad. See target.h for comments. */ int (*install_fast_tracepoint_jump_pad) (CORE_ADDR tpoint, CORE_ADDR tpaddr, @@ -626,6 +622,17 @@ class linux_process_target : public process_stratum_target ptid_t filter_exit_event (lwp_info *event_child, target_waitstatus *ourstatus); + /* Returns true if THREAD is stopped in a jump pad, and we can't + move it out, because we need to report the stop event to GDB. For + example, if the user puts a breakpoint in the jump pad, it's + because she wants to debug it. */ + bool stuck_in_jump_pad (thread_info *thread); + + /* Convenience wrapper. Returns information about LWP's fast tracepoint + collection status. */ + fast_tpoint_collect_result linux_fast_tracepoint_collecting + (lwp_info *lwp, fast_tpoint_collect_status *status); + protected: /* The architecture-specific "low" methods are listed below. */ @@ -712,6 +719,10 @@ class linux_process_target : public process_stratum_target /* Hook to call prior to resuming a thread. */ virtual void low_prepare_to_resume (lwp_info *lwp); + /* Fill ADDRP with the thread area address of LWPID. Returns 0 on + success, -1 on failure. */ + virtual int low_get_thread_area (int lwpid, CORE_ADDR *addrp); + /* How many bytes the PC should be decremented after a break. */ int m_decr_pc_after_break; }; diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc index 01f32bc356c..36d7c7451e1 100644 --- a/gdbserver/linux-m32r-low.cc +++ b/gdbserver/linux-m32r-low.cc @@ -163,7 +163,6 @@ m32r_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* get_thread_area */ NULL, /* install_fast_tracepoint_jump_pad */ NULL, /* emit_ops */ NULL, /* get_min_fast_tracepoint_insn_len */ diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc index 1c5e8f4487f..1ba5b827dff 100644 --- a/gdbserver/linux-m68k-low.cc +++ b/gdbserver/linux-m68k-low.cc @@ -259,7 +259,6 @@ m68k_supports_hardware_single_step (void) } struct linux_target_ops the_low_target = { - NULL, /* get_thread_area */ NULL, /* install_fast_tracepoint_jump_pad */ NULL, /* emit_ops */ NULL, /* get_min_fast_tracepoint_insn_len */ diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc index 691d0e67bda..16eff5dcbf0 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -88,6 +88,8 @@ protected: int low_remove_point (raw_bkpt_type type, CORE_ADDR addr, int size, raw_breakpoint *bp) override; + + int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override; }; /* The singleton target ops object. */ @@ -1042,8 +1044,8 @@ ppc_target::supports_tracepoints () don't read anything from the address, and treat it as opaque; it's the address itself that we assume is unique per-thread. */ -static int -ppc_get_thread_area (int lwpid, CORE_ADDR *addr) +int +ppc_target::low_get_thread_area (int lwpid, CORE_ADDR *addr) { struct lwp_info *lwp = find_lwp_pid (ptid_t (lwpid)); struct thread_info *thr = get_lwp_thread (lwp); @@ -3433,7 +3435,6 @@ ppc_get_ipa_tdesc_idx (void) } struct linux_target_ops the_low_target = { - ppc_get_thread_area, ppc_install_fast_tracepoint_jump_pad, ppc_emit_ops, ppc_get_min_fast_tracepoint_insn_len, diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc index 29c28ea13d0..3171dc4397e 100644 --- a/gdbserver/linux-s390-low.cc +++ b/gdbserver/linux-s390-low.cc @@ -91,6 +91,8 @@ protected: void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; bool low_breakpoint_at (CORE_ADDR pc) override; + + int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override; }; /* The singleton target ops object. */ @@ -774,10 +776,10 @@ s390_target::supports_tracepoints () return true; } -/* Implementation of linux_target_ops method "get_thread_area". */ +/* Implementation of linux target ops method "low_get_thread_area". */ -static int -s390_get_thread_area (int lwpid, CORE_ADDR *addrp) +int +s390_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp) { CORE_ADDR res = ptrace (PTRACE_PEEKUSER, lwpid, (long) PT_ACR0, (long) 0); #ifdef __s390x__ @@ -2841,7 +2843,6 @@ s390_emit_ops (void) } struct linux_target_ops the_low_target = { - s390_get_thread_area, s390_install_fast_tracepoint_jump_pad, s390_emit_ops, s390_get_min_fast_tracepoint_insn_len, diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc index 9dfa8bb9dfd..bdbd004586b 100644 --- a/gdbserver/linux-sh-low.cc +++ b/gdbserver/linux-sh-low.cc @@ -194,7 +194,6 @@ sh_target::low_arch_setup () } struct linux_target_ops the_low_target = { - NULL, /* get_thread_area */ NULL, /* install_fast_tracepoint_jump_pad */ NULL, /* emit_ops */ NULL, /* get_min_fast_tracepoint_insn_len */ diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc index cffef111f63..5bb2b415a17 100644 --- a/gdbserver/linux-tic6x-low.cc +++ b/gdbserver/linux-tic6x-low.cc @@ -425,7 +425,6 @@ tic6x_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* get_thread_area */ NULL, /* install_fast_tracepoint_jump_pad */ NULL, /* emit_ops */ NULL, /* get_min_fast_tracepoint_insn_len */ diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc index 4938ececcb6..520c11409a4 100644 --- a/gdbserver/linux-tile-low.cc +++ b/gdbserver/linux-tile-low.cc @@ -226,7 +226,6 @@ tile_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - NULL, /* get_thread_area */ NULL, /* install_fast_tracepoint_jump_pad */ NULL, /* emit_ops */ NULL, /* get_min_fast_tracepoint_insn_len */ diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index 8d88ecba449..b6b8209ff57 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -158,6 +158,8 @@ protected: void low_prepare_to_resume (lwp_info *lwp) override; + int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override; + private: /* Update all the target description of all processes; a new GDB @@ -311,8 +313,8 @@ ps_get_thread_area (struct ps_prochandle *ph, don't read anything from the address, and treat it as opaque; it's the address itself that we assume is unique per-thread. */ -static int -x86_get_thread_area (int lwpid, CORE_ADDR *addr) +int +x86_target::low_get_thread_area (int lwpid, CORE_ADDR *addr) { #ifdef __x86_64__ int use_64bit = is_64bit_tdesc (); @@ -2962,7 +2964,6 @@ x86_get_ipa_tdesc_idx (void) struct linux_target_ops the_low_target = { - x86_get_thread_area, x86_install_fast_tracepoint_jump_pad, x86_emit_ops, x86_get_min_fast_tracepoint_insn_len, diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc index f99106cad31..93e74aef705 100644 --- a/gdbserver/linux-xtensa-low.cc +++ b/gdbserver/linux-xtensa-low.cc @@ -331,7 +331,6 @@ xtensa_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* get_thread_area */ NULL, /* install_fast_tracepoint_jump_pad */ NULL, /* emit_ops */ NULL, /* get_min_fast_tracepoint_insn_len */