From patchwork Tue Feb 11 09:01:15 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: 37893 Received: (qmail 115902 invoked by alias); 11 Feb 2020 09:03: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 115226 invoked by uid 89); 11 Feb 2020 09:03:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.4 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=completion X-HELO: mga07.intel.com Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Feb 2020 09:03:18 +0000 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 01:03:16 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga005.jf.intel.com with ESMTP; 11 Feb 2020 01:03:15 -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 01B93FeK002096; Tue, 11 Feb 2020 09:03:15 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 01B93E77010363; Tue, 11 Feb 2020 10:03:14 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 01B93E8u010359; Tue, 11 Feb 2020 10:03:14 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 03/58] gdbserver: turn target op 'post_create_inferior' into a method Date: Tue, 11 Feb 2020 10:01:15 +0100 Message-Id: <65aed6ff229d2e752ee6d7195d4db1b66187af4c.1581410932.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 post_create_inferior op a method of process_target. * target.h (struct process_stratum_target): Remove the target op. (class process_target): Add the target op. (target_post_create_inferior): Update the macro. * target.c (process_target::post_create_inferior): Define. Update the derived structs and callers below. * linux-low.c (linux_target_ops): Update. (linux_post_create_inferior): Turn into ... (linux_process_target::post_create_inferior): ... this. * 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 | 5 ++--- gdbserver/linux-low.h | 2 ++ gdbserver/lynx-low.c | 1 - gdbserver/nto-low.c | 1 - gdbserver/target.c | 9 +++++++++ gdbserver/target.h | 14 +++++--------- gdbserver/win32-low.c | 1 - 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/gdbserver/linux-low.c b/gdbserver/linux-low.c index fd122535cc5..9e4c6758581 100644 --- a/gdbserver/linux-low.c +++ b/gdbserver/linux-low.c @@ -1029,8 +1029,8 @@ linux_process_target::create_inferior ( /* Implement the post_create_inferior target_ops method. */ -static void -linux_post_create_inferior (void) +void +linux_process_target::post_create_inferior () { struct lwp_info *lwp = get_thread_lwp (current_thread); @@ -7359,7 +7359,6 @@ linux_get_hwcap2 (int wordsize) static linux_process_target the_linux_target; static process_stratum_target linux_target_ops = { - linux_post_create_inferior, linux_attach, linux_kill, linux_detach, diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index acaca0c0070..fab08a6bb7d 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -271,6 +271,8 @@ public: int create_inferior (const char *program, const std::vector &program_args) override; + + void post_create_inferior () override; }; #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 61b56739e36..c6880bc7bc2 100644 --- a/gdbserver/lynx-low.c +++ b/gdbserver/lynx-low.c @@ -726,7 +726,6 @@ static lynx_process_target the_lynx_target; /* The LynxOS target_ops vector. */ static process_stratum_target lynx_target_ops = { - NULL, /* post_create_inferior */ lynx_attach, lynx_kill, lynx_detach, diff --git a/gdbserver/nto-low.c b/gdbserver/nto-low.c index e5df5b3e9db..ce37443385d 100644 --- a/gdbserver/nto-low.c +++ b/gdbserver/nto-low.c @@ -935,7 +935,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, /* post_create_inferior */ nto_attach, nto_kill, nto_detach, diff --git a/gdbserver/target.c b/gdbserver/target.c index a4593cf6df9..81092e81ea4 100644 --- a/gdbserver/target.c +++ b/gdbserver/target.c @@ -393,3 +393,12 @@ target_terminal::info (const char *arg, int from_tty) { /* Placeholder. */ } + +/* Default implementations of target ops. + See target.h for definitions. */ + +void +process_target::post_create_inferior () +{ + /* Nop. */ +} diff --git a/gdbserver/target.h b/gdbserver/target.h index 7caf096b111..bede0a8556c 100644 --- a/gdbserver/target.h +++ b/gdbserver/target.h @@ -70,10 +70,6 @@ class process_target; shared code. */ struct process_stratum_target { - /* Do additional setup after a new process is created, including - exec-wrapper completion. */ - void (*post_create_inferior) (void); - /* Attach to a running process. PID is the process ID to attach to, specified by the user @@ -488,6 +484,10 @@ public: process with the process list. */ virtual int create_inferior (const char *program, const std::vector &program_args) = 0; + + /* Do additional setup after a new process is created, including + exec-wrapper completion. */ + virtual void post_create_inferior (); }; extern process_stratum_target *the_target; @@ -498,11 +498,7 @@ void set_target_ops (process_stratum_target *); the_target->pt->create_inferior (program, program_args) #define target_post_create_inferior() \ - do \ - { \ - if (the_target->post_create_inferior != NULL) \ - (*the_target->post_create_inferior) (); \ - } while (0) + the_target->pt->post_create_inferior () #define myattach(pid) \ (*the_target->attach) (pid) diff --git a/gdbserver/win32-low.c b/gdbserver/win32-low.c index 2e1028b9a8d..e8d4347a4b9 100644 --- a/gdbserver/win32-low.c +++ b/gdbserver/win32-low.c @@ -1828,7 +1828,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, /* post_create_inferior */ win32_attach, win32_kill, win32_detach,