From patchwork Fri Mar 6 21:31:29 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: 38497 Received: (qmail 52766 invoked by alias); 6 Mar 2020 21:32:40 -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 52021 invoked by uid 89); 6 Mar 2020 21:32:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.6 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: 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; Fri, 06 Mar 2020 21:32:23 +0000 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2020 13:32:21 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga007.jf.intel.com with ESMTP; 06 Mar 2020 13:32:20 -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 026LWJgm022488; 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 026LWJSH020488; Fri, 6 Mar 2020 22:32:19 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 026LWJ8b020484; Fri, 6 Mar 2020 22:32:19 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 21/31] gdbserver/linux-low: turn 'prepare_to_resume' into a method Date: Fri, 6 Mar 2020 22:31:29 +0100 Message-Id: <5ad6574d570e05d45d503f1f59aff85ed1005779.1583529167.git.tankut.baris.aktemur@intel.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes gdbserver/ChangeLog: 2020-03-06 Tankut Baris Aktemur Turn the 'prepare_to_resume' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) : Declare. * linux-low.cc (linux_process_target::low_prepare_to_resume): Define. Update the callers below: (linux_process_target::resume_one_lwp_throw) (linux_process_target::low_prepare_to_resume) * linux-x86-low.cc (class x86_target) : Declare. (x86_target::low_prepare_to_resume): Define. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) : Declare. (aarch64_target::low_prepare_to_resume): Define. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) : Declare. (arm_prepare_to_resume): Turn into... (arm_target::low_prepare_to_resume): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) : Declare. (mips_linux_prepare_to_resume): Turn into... (mips_target::low_prepare_to_resume): ...this. (the_low_target): Remove the op field. * linux-bfin-low.cc (the_low_target): Remove the op field. * 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-ppc-low.cc (the_low_target): Ditto. * linux-s390-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 | 7 ++++--- gdbserver/linux-bfin-low.cc | 1 - gdbserver/linux-crisv32-low.cc | 1 - gdbserver/linux-low.cc | 12 ++++++++---- gdbserver/linux-low.h | 6 +++--- gdbserver/linux-m32r-low.cc | 1 - gdbserver/linux-m68k-low.cc | 1 - gdbserver/linux-mips-low.cc | 11 ++++++----- gdbserver/linux-ppc-low.cc | 1 - gdbserver/linux-s390-low.cc | 1 - gdbserver/linux-sh-low.cc | 1 - gdbserver/linux-tic6x-low.cc | 1 - gdbserver/linux-tile-low.cc | 1 - gdbserver/linux-x86-low.cc | 10 +++++++++- gdbserver/linux-xtensa-low.cc | 1 - 16 files changed, 38 insertions(+), 27 deletions(-) diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 1b5efd56168..cece3fc6dca 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -104,6 +104,8 @@ protected: void low_delete_thread (arch_lwp_info *) override; void low_new_fork (process_info *parent, process_info *child) override; + + void low_prepare_to_resume (lwp_info *lwp) override; }; /* The singleton target ops object. */ @@ -124,6 +126,12 @@ aarch64_target::low_cannot_store_register (int regno) "is not implemented by the target"); } +void +aarch64_target::low_prepare_to_resume (lwp_info *lwp) +{ + aarch64_linux_prepare_to_resume (lwp); +} + /* Per-process arch-specific data we want to keep. */ struct arch_process_info @@ -3140,7 +3148,6 @@ aarch64_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - aarch64_linux_prepare_to_resume, NULL, /* process_qsupported */ aarch64_supports_tracepoints, aarch64_get_thread_area, diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc index cc2f3919e27..83a7608c787 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -111,6 +111,8 @@ protected: void low_delete_thread (arch_lwp_info *) override; void low_new_fork (process_info *parent, process_info *child) override; + + void low_prepare_to_resume (lwp_info *lwp) override; }; /* The singleton target ops object. */ @@ -815,8 +817,8 @@ arm_target::low_new_fork (process_info *parent, process_info *child) /* Called when resuming a thread. If the debug regs have changed, update the thread's copies. */ -static void -arm_prepare_to_resume (struct lwp_info *lwp) +void +arm_target::low_prepare_to_resume (lwp_info *lwp) { struct thread_info *thread = get_lwp_thread (lwp); int pid = lwpid_of (thread); @@ -1117,7 +1119,6 @@ arm_target::get_regs_info () } struct linux_target_ops the_low_target = { - arm_prepare_to_resume, NULL, /* process_qsupported */ NULL, /* supports_tracepoints */ NULL, /* get_thread_area */ diff --git a/gdbserver/linux-bfin-low.cc b/gdbserver/linux-bfin-low.cc index 21facb24cd0..82bae1d1e82 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, /* prepare_to_resume */ NULL, /* process_qsupported */ NULL, /* supports_tracepoints */ NULL, /* get_thread_area */ diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc index 1397603ee36..b85eac87698 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, /* prepare_to_resume */ NULL, /* process_qsupported */ NULL, /* supports_tracepoints */ NULL, /* get_thread_area */ diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 50addb9d68e..41bb44a2010 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -1530,8 +1530,7 @@ linux_process_target::detach_one_lwp (lwp_info *lwp) regcache_invalidate_thread (thread); /* Finally, let it resume. */ - if (the_low_target.prepare_to_resume != NULL) - the_low_target.prepare_to_resume (lwp); + low_prepare_to_resume (lwp); } catch (const gdb_exception_error &ex) { @@ -4322,8 +4321,7 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step, lwpid_of (thread), step ? "step" : "continue", signal, lwp->stop_expected ? "expected" : "not expected"); - if (the_low_target.prepare_to_resume != NULL) - the_low_target.prepare_to_resume (lwp); + low_prepare_to_resume (lwp); regcache_invalidate_thread (thread); errno = 0; @@ -4355,6 +4353,12 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step, lwp->stop_reason = TARGET_STOPPED_BY_NO_REASON; } +void +linux_process_target::low_prepare_to_resume (lwp_info *lwp) +{ + /* Nop. */ +} + /* Called when we try to resume a stopped LWP and that errors out. If the LWP is no longer in ptrace-stopped state (meaning it's zombie, or about to become), discard the error, clear any pending status diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index 16d9b389275..0ccc8644c07 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -131,9 +131,6 @@ struct lwp_info; struct linux_target_ops { - /* Hook to call prior to resuming a thread. */ - void (*prepare_to_resume) (struct lwp_info *); - /* Hook to support target specific qSupported. */ void (*process_qsupported) (char **, int count); @@ -722,6 +719,9 @@ class linux_process_target : public process_stratum_target /* Hook to call, if any, when a new fork is attached. */ virtual void low_new_fork (process_info *parent, process_info *child); + /* Hook to call prior to resuming a thread. */ + virtual void low_prepare_to_resume (lwp_info *lwp); + /* 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 bb1a2a0cd17..b82d5ab5132 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, /* prepare_to_resume */ NULL, /* process_qsupported */ NULL, /* supports_tracepoints */ NULL, /* get_thread_area */ diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc index bfc682bacbe..051dd4554ed 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, /* prepare_to_resume */ NULL, /* process_qsupported */ NULL, /* supports_tracepoints */ NULL, /* get_thread_area */ diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc index 3ec56d404e5..073e924619c 100644 --- a/gdbserver/linux-mips-low.cc +++ b/gdbserver/linux-mips-low.cc @@ -82,6 +82,8 @@ protected: void low_delete_thread (arch_lwp_info *) override; void low_new_fork (process_info *parent, process_info *child) override; + + void low_prepare_to_resume (lwp_info *lwp) override; }; /* The singleton target ops object. */ @@ -493,12 +495,12 @@ mips_target::low_new_fork (process_info *parent, child_private->watch_mirror = parent_private->watch_mirror; } -/* This is the implementation of linux_target_ops method - prepare_to_resume. If the watch regs have changed, update the +/* This is the implementation of linux target ops method + low_prepare_to_resume. If the watch regs have changed, update the thread's copies. */ -static void -mips_linux_prepare_to_resume (struct lwp_info *lwp) +void +mips_target::low_prepare_to_resume (lwp_info *lwp) { ptid_t ptid = ptid_of (get_lwp_thread (lwp)); struct process_info *proc = find_process_pid (ptid.pid ()); @@ -998,7 +1000,6 @@ mips_target::get_regs_info () } struct linux_target_ops the_low_target = { - mips_linux_prepare_to_resume }; /* The linux target ops object. */ diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc index 9035b82be9d..0561ab366f6 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -3430,7 +3430,6 @@ ppc_get_ipa_tdesc_idx (void) } struct linux_target_ops the_low_target = { - NULL, /* prepare_to_resume */ NULL, /* process_qsupported */ ppc_supports_tracepoints, ppc_get_thread_area, diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc index 27bd292b20a..73b246e3134 100644 --- a/gdbserver/linux-s390-low.cc +++ b/gdbserver/linux-s390-low.cc @@ -2839,7 +2839,6 @@ s390_emit_ops (void) } struct linux_target_ops the_low_target = { - NULL, /* prepare_to_resume */ NULL, /* process_qsupported */ s390_supports_tracepoints, s390_get_thread_area, diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc index 3a111658b81..03549d1bf78 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, /* prepare_to_resume */ NULL, /* process_qsupported */ NULL, /* supports_tracepoints */ NULL, /* get_thread_area */ diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc index 00821e0d85f..62ff0da55b8 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, /* prepare_to_resume */ NULL, /* process_qsupported */ NULL, /* supports_tracepoints */ NULL, /* get_thread_area */ diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc index 0b2aafcf5c4..99423fda832 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, /* prepare_to_resume */ NULL, /* process_qsupported */ NULL, /* supports_tracepoints */ NULL, /* get_thread_area */ diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index b55fb44fb10..b5eff688609 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -155,6 +155,8 @@ protected: void low_delete_thread (arch_lwp_info *) override; void low_new_fork (process_info *parent, process_info *child) override; + + void low_prepare_to_resume (lwp_info *lwp) override; }; /* The singleton target ops object. */ @@ -756,6 +758,13 @@ x86_target::low_new_fork (process_info *parent, process_info *child) *child->priv->arch_private = *parent->priv->arch_private; } +void +x86_target::low_prepare_to_resume (lwp_info *lwp) +{ + /* This comes from nat/. */ + x86_linux_prepare_to_resume (lwp); +} + /* See nat/x86-dregs.h. */ struct x86_debug_reg_state * @@ -2947,7 +2956,6 @@ x86_get_ipa_tdesc_idx (void) struct linux_target_ops the_low_target = { - x86_linux_prepare_to_resume, x86_linux_process_qsupported, x86_supports_tracepoints, x86_get_thread_area, diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc index c17c53c9bf9..1c4db4cfaca 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, /* prepare_to_resume */ NULL, /* process_qsupported */ NULL, /* supports_tracepoints */ NULL, /* get_thread_area */