From patchwork Tue Feb 11 09:02:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aktemur, Tankut Baris" X-Patchwork-Id: 37945 Received: (qmail 126446 invoked by alias); 11 Feb 2020 09:04:20 -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 121539 invoked by uid 89); 11 Feb 2020 09:03:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.8 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=literally X-HELO: mga04.intel.com Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Feb 2020 09:03:50 +0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 01:03:28 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 11 Feb 2020 01:03:27 -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 01B93QUx002316; Tue, 11 Feb 2020 09:03:27 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 01B93Qh2010716; Tue, 11 Feb 2020 10:03:26 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 01B93QQJ010712; Tue, 11 Feb 2020 10:03:26 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 53/58] gdbserver: turn target ops 'thread_name' and 'thread_handle' into methods Date: Tue, 11 Feb 2020 10:02:05 +0100 Message-Id: <1d8904ae5a6a44a03f692d02d12219f4824ccedb.1581410935.git.tankut.baris.aktemur@intel.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes gdbserver/ChangeLog: 2020-02-10 Tankut Baris Aktemur Make process_stratum_target's thread_name and thread_handle ops methods of process_target. * target.h (struct process_stratum_target): Remove the target ops. (class process_target): Add the target ops. (target_thread_name): Update the macro. (target_thread_handle): Update the macro. * target.c (process_target::thread_name): Define. (process_target::thread_handle): Define. Update the derived structs and callers below. * linux-low.c (linux_target_ops): Update. (linux_process_target::thread_name): Define. (linux_process_target::thread_handle): Define. * linux-low.h (class linux_process_target): Update. * lynx-low.c (lynx_target_ops): Update. * nto-low.c (nto_target_ops): Update. * win32-low.c (win32_target_ops): Update. --- gdbserver/linux-low.c | 21 +++++++++++++++------ gdbserver/linux-low.h | 7 +++++++ gdbserver/lynx-low.c | 2 -- gdbserver/nto-low.c | 2 -- gdbserver/target.c | 13 +++++++++++++ gdbserver/target.h | 27 +++++++++++++-------------- gdbserver/win32-low.c | 2 -- 7 files changed, 48 insertions(+), 26 deletions(-) diff --git a/gdbserver/linux-low.c b/gdbserver/linux-low.c index de011c126c0..82bb9a680bf 100644 --- a/gdbserver/linux-low.c +++ b/gdbserver/linux-low.c @@ -7386,6 +7386,21 @@ linux_process_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr) return breakpoint_kind_from_pc (pcptr); } +const char * +linux_process_target::thread_name (ptid_t thread) +{ + return linux_proc_tid_get_name (thread); +} + +#if USE_THREAD_DB +bool +linux_process_target::thread_handle (ptid_t ptid, gdb_byte **handle, + int *handle_len) +{ + return thread_db_thread_handle (ptid, handle, handle_len); +} +#endif + /* Default implementation of linux_target_ops method "set_pc" for 32-bit pc register which is literally named "pc". */ @@ -7498,15 +7513,9 @@ linux_get_hwcap2 (int wordsize) static linux_process_target the_linux_target; static process_stratum_target linux_target_ops = { - linux_proc_tid_get_name, linux_supports_software_single_step, linux_supports_catch_syscall, linux_get_ipa_tdesc_idx, -#if USE_THREAD_DB - thread_db_thread_handle, -#else - NULL, -#endif &the_linux_target, }; diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index 6a531ed3aab..e77c54043b8 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -471,6 +471,13 @@ public: const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override; int breakpoint_kind_from_current_state (CORE_ADDR *pcptr) override; + + const char *thread_name (ptid_t thread) override; + +#if USE_THREAD_DB + bool thread_handle (ptid_t ptid, gdb_byte **handle, + int *handle_len) override; +#endif }; #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr))) diff --git a/gdbserver/lynx-low.c b/gdbserver/lynx-low.c index aa4c5b24b0e..3f0dbd385fa 100644 --- a/gdbserver/lynx-low.c +++ b/gdbserver/lynx-low.c @@ -742,11 +742,9 @@ static lynx_process_target the_lynx_target; /* The LynxOS target_ops vector. */ static process_stratum_target lynx_target_ops = { - NULL, /* thread_name */ NULL, /* supports_software_single_step */ NULL, /* supports_catch_syscall */ NULL, /* get_ipa_tdesc_idx */ - NULL, /* thread_handle */ &the_lynx_target, }; diff --git a/gdbserver/nto-low.c b/gdbserver/nto-low.c index 3e2e8eaa521..89c59a0f4bb 100644 --- a/gdbserver/nto-low.c +++ b/gdbserver/nto-low.c @@ -947,11 +947,9 @@ nto_process_target::sw_breakpoint_from_kind (int kind, int *size) static nto_process_target the_nto_target; static process_stratum_target nto_target_ops = { - NULL, /* thread_name */ NULL, /* supports_software_single_step */ NULL, /* supports_catch_syscall */ NULL, /* get_ipa_tdesc_idx */ - NULL, /* thread_handle */ &the_nto_target, }; diff --git a/gdbserver/target.c b/gdbserver/target.c index a29c9fda4eb..b8c58be751a 100644 --- a/gdbserver/target.c +++ b/gdbserver/target.c @@ -801,3 +801,16 @@ process_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr) { return breakpoint_kind_from_pc (pcptr); } + +const char * +process_target::thread_name (ptid_t thread) +{ + return nullptr; +} + +bool +process_target::thread_handle (ptid_t ptid, gdb_byte **handle, + int *handle_len) +{ + return false; +} diff --git a/gdbserver/target.h b/gdbserver/target.h index 8da04a58150..1b63376a495 100644 --- a/gdbserver/target.h +++ b/gdbserver/target.h @@ -70,10 +70,6 @@ class process_target; shared code. */ struct process_stratum_target { - /* Return the thread's name, or NULL if the target is unable to determine it. - The returned value must not be freed by the caller. */ - const char *(*thread_name) (ptid_t thread); - /* Returns true if the target can software single step. */ int (*supports_software_single_step) (void); @@ -84,11 +80,6 @@ struct process_stratum_target /* Return tdesc index for IPA. */ int (*get_ipa_tdesc_idx) (void); - /* Thread ID to (numeric) thread handle: Return true on success and - false for failure. Return pointer to thread handle via HANDLE - and the handle's length via HANDLE_LEN. */ - bool (*thread_handle) (ptid_t ptid, gdb_byte **handle, int *handle_len); - /* The object that will gradually replace this struct. */ process_target *pt; }; @@ -503,6 +494,17 @@ public: PC. The PCPTR is adjusted to the real memory location in case a flag (e.g., the Thumb bit on ARM) is present in the PC. */ virtual int breakpoint_kind_from_current_state (CORE_ADDR *pcptr); + + /* Return the thread's name, or NULL if the target is unable to + determine it. The returned value must not be freed by the + caller. */ + virtual const char *thread_name (ptid_t thread); + + /* Thread ID to (numeric) thread handle: Return true on success and + false for failure. Return pointer to thread handle via HANDLE + and the handle's length via HANDLE_LEN. */ + virtual bool thread_handle (ptid_t ptid, gdb_byte **handle, + int *handle_len); }; extern process_stratum_target *the_target; @@ -683,13 +685,10 @@ void done_accessing_memory (void); the_target->pt->core_of_thread (ptid) #define target_thread_name(ptid) \ - (the_target->thread_name ? (*the_target->thread_name) (ptid) \ - : NULL) + the_target->pt->thread_name (ptid) #define target_thread_handle(ptid, handle, handle_len) \ - (the_target->thread_handle ? (*the_target->thread_handle) \ - (ptid, handle, handle_len) \ - : false) + the_target->pt->thread_handle (ptid, handle, handle_len) int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len); diff --git a/gdbserver/win32-low.c b/gdbserver/win32-low.c index 017cfd3c245..ef8f7408669 100644 --- a/gdbserver/win32-low.c +++ b/gdbserver/win32-low.c @@ -1848,11 +1848,9 @@ win32_process_target::sw_breakpoint_from_kind (int kind, int *size) static win32_process_target the_win32_target; static process_stratum_target win32_target_ops = { - NULL, /* thread_name */ NULL, /* supports_software_single_step */ NULL, /* supports_catch_syscall */ NULL, /* get_ipa_tdesc_idx */ - NULL, /* thread_handle */ &the_win32_target, };