From patchwork Mon Feb 17 16:57:47 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: 38151 Received: (qmail 121674 invoked by alias); 17 Feb 2020 17:01:38 -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 114960 invoked by uid 89); 17 Feb 2020 17:00:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.2 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=H*RU:mga11.intel.com, HX-Spam-Relays-External:192.55.52.93, HX-Spam-Relays-External:mga11.intel.com, HX-HELO:mga11.intel.com X-HELO: mga11.intel.com Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Feb 2020 16:59:30 +0000 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Feb 2020 08:59:28 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga006.jf.intel.com with ESMTP; 17 Feb 2020 08:59: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 01HGxQCr028329; Mon, 17 Feb 2020 16:59:26 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 01HGxQKo027271; Mon, 17 Feb 2020 17:59:26 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 01HGxQG2027266; Mon, 17 Feb 2020 17:59:26 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Cc: palves@redhat.com Subject: [PATCH v2 39/58] gdbserver: turn target op 'thread_stopped' into a method Date: Mon, 17 Feb 2020 17:57:47 +0100 Message-Id: <8b8dae91ef91c77901aa72aa085bc0bd148f375b.1581956647.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 Turn process_stratum_target's thread_stopped op into a method of process_target. * target.h (struct process_stratum_target): Remove the target op. (class process_target): Add the target op. Also add 'supports_thread_stopped'. (target_thread_stopped): Update the macro. * target.cc (process_target::thread_stopped): Define. (process_target::supports_thread_stopped): Define. (prepare_to_access_memory): Update. Update the derived classes and callers below. * server.cc (queue_stop_reply_callback): Update. * linux-low.cc (linux_target_ops): Update. (linux_process_target::supports_thread_stopped): Define. (linux_thread_stopped): Turn into ... (linux_process_target::thread_stopped): ... this. * linux-low.h (class linux_process_target): Update. * lynx-low.cc (lynx_target_ops): Update. * nto-low.cc (nto_target_ops): Update. * win32-low.cc (win32_target_ops): Update. --- gdbserver/linux-low.cc | 11 ++++++++--- gdbserver/linux-low.h | 4 ++++ gdbserver/lynx-low.cc | 1 - gdbserver/nto-low.cc | 1 - gdbserver/server.cc | 4 ++-- gdbserver/target.cc | 16 ++++++++++++++-- gdbserver/target.h | 13 ++++++++----- gdbserver/win32-low.cc | 1 - 8 files changed, 36 insertions(+), 15 deletions(-) diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 8065632a476..692863d9e4b 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -6568,8 +6568,14 @@ linux_process_target::write_pc (regcache *regcache, CORE_ADDR pc) (*the_low_target.set_pc) (regcache, pc); } -static int -linux_thread_stopped (struct thread_info *thread) +bool +linux_process_target::supports_thread_stopped () +{ + return true; +} + +bool +linux_process_target::thread_stopped (thread_info *thread) { return get_thread_lwp (thread)->stopped; } @@ -7445,7 +7451,6 @@ linux_get_hwcap2 (int wordsize) static linux_process_target the_linux_target; static process_stratum_target linux_target_ops = { - linux_thread_stopped, NULL, linux_pause_all, linux_unpause_all, diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index 67a36c8a67d..cbb2f48e135 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -392,6 +392,10 @@ public: CORE_ADDR read_pc (regcache *regcache) override; void write_pc (regcache *regcache, CORE_ADDR pc) override; + + bool supports_thread_stopped () override; + + bool thread_stopped (thread_info *thread) override; }; #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr))) diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc index 2ac59c3c14a..7cbde7c6e79 100644 --- a/gdbserver/lynx-low.cc +++ b/gdbserver/lynx-low.cc @@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target; /* The LynxOS target_ops vector. */ static process_stratum_target lynx_target_ops = { - NULL, /* thread_stopped */ NULL, /* get_tib_address */ NULL, /* pause_all */ NULL, /* unpause_all */ diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc index 2b5b02b69bd..c144d774f0c 100644 --- a/gdbserver/nto-low.cc +++ b/gdbserver/nto-low.cc @@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size) static nto_process_target the_nto_target; static process_stratum_target nto_target_ops = { - NULL, /* thread_stopped */ NULL, /* get_tib_address */ NULL, /* pause_all */ NULL, /* unpause_all */ diff --git a/gdbserver/server.cc b/gdbserver/server.cc index df307f5594c..f3dca8d3ce0 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -3217,7 +3217,7 @@ queue_stop_reply_callback (thread_info *thread) { /* For now, assume targets that don't have this callback also don't manage the thread's last_status field. */ - if (the_target->thread_stopped == NULL) + if (!the_target->pt->supports_thread_stopped ()) { struct vstop_notif *new_notif = new struct vstop_notif; @@ -3229,7 +3229,7 @@ queue_stop_reply_callback (thread_info *thread) } else { - if (thread_stopped (thread)) + if (target_thread_stopped (thread)) { if (debug_threads) { diff --git a/gdbserver/target.cc b/gdbserver/target.cc index 4f8d91c171f..b44170a7cdd 100644 --- a/gdbserver/target.cc +++ b/gdbserver/target.cc @@ -66,8 +66,8 @@ prepare_to_access_memory (void) { if (mythread_alive (thread->id)) { - if (stopped == NULL && the_target->thread_stopped != NULL - && thread_stopped (thread)) + if (stopped == NULL && the_target->pt->supports_thread_stopped () + && target_thread_stopped (thread)) stopped = thread; if (first == NULL) @@ -626,3 +626,15 @@ process_target::write_pc (regcache *regcache, CORE_ADDR pc) { gdb_assert_not_reached ("process_target::write_pc: Unable to update PC"); } + +bool +process_target::supports_thread_stopped () +{ + return false; +} + +bool +process_target::thread_stopped (thread_info *thread) +{ + gdb_assert_not_reached ("target op thread_stopped not supported"); +} diff --git a/gdbserver/target.h b/gdbserver/target.h index 2aef0208c11..49d5eca479e 100644 --- a/gdbserver/target.h +++ b/gdbserver/target.h @@ -70,9 +70,6 @@ class process_target; shared code. */ struct process_stratum_target { - /* Return true if THREAD is known to be stopped now. */ - int (*thread_stopped) (struct thread_info *thread); - /* Read Thread Information Block address. */ int (*get_tib_address) (ptid_t ptid, CORE_ADDR *address); @@ -488,6 +485,12 @@ public: /* Write PC to REGCACHE. */ virtual void write_pc (regcache *regcache, CORE_ADDR pc); + + /* Return true if the thread_stopped op is supported. */ + virtual bool supports_thread_stopped (); + + /* Return true if THREAD is known to be stopped now. */ + virtual bool thread_stopped (thread_info *thread); }; extern process_stratum_target *the_target; @@ -559,8 +562,8 @@ int kill_inferior (process_info *proc); (the_target->get_min_fast_tracepoint_insn_len \ ? (*the_target->get_min_fast_tracepoint_insn_len) () : 0) -#define thread_stopped(thread) \ - (*the_target->thread_stopped) (thread) +#define target_thread_stopped(thread) \ + the_target->pt->thread_stopped (thread) #define pause_all(freeze) \ do \ diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index a7329fe20cf..712624852d6 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -1852,7 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size) static win32_process_target the_win32_target; static process_stratum_target win32_target_ops = { - NULL, /* thread_stopped */ win32_get_tib_address, NULL, /* pause_all */ NULL, /* unpause_all */