From patchwork Tue Feb 11 09:01:30 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: 37918 Received: (qmail 121448 invoked by alias); 11 Feb 2020 09:03:52 -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 118673 invoked by uid 89); 11 Feb 2020 09:03:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.9 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; Tue, 11 Feb 2020 09:03:24 +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:20 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 11 Feb 2020 01:03:19 -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 01B93Ioq002180; Tue, 11 Feb 2020 09:03:18 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 01B93IBe010468; Tue, 11 Feb 2020 10:03:18 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 01B93Isc010464; Tue, 11 Feb 2020 10:03:18 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 18/58] gdbserver: turn target op 'supports_z_point_type' into a method Date: Tue, 11 Feb 2020 10:01:30 +0100 Message-Id: <93dd8080d122cb1c6f43a01cdddc2d87d55484fa.1581410933.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 supports_z_point_type op a method of process_target. * target.h (struct process_stratum_target): Remove the target op. (class process_target): Add the target op. * target.c (process_target::supports_z_point_type): Define. Update the derived structs and callers below. * mem-break.c (z_type_supported): Update. * linux-low.c (linux_target_ops): Update. (linux_supports_z_point_type): Turn into ... (linux_process_target::supports_z_point_type): ... this. * linux-low.h (class linux_process_target): Update. * lynx-low.c (lynx_target_ops): Update. * nto-low.c (nto_target_ops): Update. (nto_supports_z_point_type): Turn into ... (nto_process_target::supports_z_point_type): ... this. * nto-low.h (class nto_process_target): Update. * win32-low.c (win32_target_ops): Update. (win32_supports_z_point_type): Turn into ... (win32_process_target::supports_z_point_type): ... this. * win32-low.h (class win32_process_target): Update. --- gdbserver/linux-low.c | 5 ++--- gdbserver/linux-low.h | 2 ++ gdbserver/lynx-low.c | 1 - gdbserver/mem-break.c | 3 +-- gdbserver/nto-low.c | 9 ++++----- gdbserver/nto-low.h | 2 ++ gdbserver/target.c | 6 ++++++ gdbserver/target.h | 20 ++++++++++---------- gdbserver/win32-low.c | 5 ++--- gdbserver/win32-low.h | 2 ++ 10 files changed, 31 insertions(+), 24 deletions(-) diff --git a/gdbserver/linux-low.c b/gdbserver/linux-low.c index 1bbd215d775..da03b8c3b03 100644 --- a/gdbserver/linux-low.c +++ b/gdbserver/linux-low.c @@ -5957,8 +5957,8 @@ linux_process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr, pass on the function call if the target has registered a corresponding function. */ -static int -linux_supports_z_point_type (char z_type) +bool +linux_process_target::supports_z_point_type (char z_type) { return (the_low_target.supports_z_point_type != NULL && the_low_target.supports_z_point_type (z_type)); @@ -7376,7 +7376,6 @@ linux_get_hwcap2 (int wordsize) static linux_process_target the_linux_target; static process_stratum_target linux_target_ops = { - linux_supports_z_point_type, linux_insert_point, linux_remove_point, linux_stopped_by_sw_breakpoint, diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index eccd65c795e..c51027bb0dc 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -313,6 +313,8 @@ public: int read_auxv (CORE_ADDR offset, unsigned char *myaddr, unsigned int len) override; + + bool supports_z_point_type (char z_type) 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 730c66a33a3..4be6e841d44 100644 --- a/gdbserver/lynx-low.c +++ b/gdbserver/lynx-low.c @@ -729,7 +729,6 @@ static lynx_process_target the_lynx_target; /* The LynxOS target_ops vector. */ static process_stratum_target lynx_target_ops = { - NULL, /* supports_z_point_type */ NULL, /* insert_point */ NULL, /* remove_point */ NULL, /* stopped_by_sw_breakpoint */ diff --git a/gdbserver/mem-break.c b/gdbserver/mem-break.c index 43a07c390d1..b00e9fca353 100644 --- a/gdbserver/mem-break.c +++ b/gdbserver/mem-break.c @@ -1005,8 +1005,7 @@ static int z_type_supported (char z_type) { return (z_type >= '0' && z_type <= '4' - && the_target->supports_z_point_type != NULL - && the_target->supports_z_point_type (z_type)); + && the_target->pt->supports_z_point_type (z_type)); } /* Create a new GDB breakpoint of type Z_TYPE at ADDR with kind KIND. diff --git a/gdbserver/nto-low.c b/gdbserver/nto-low.c index c5de7540079..132d57bfe79 100644 --- a/gdbserver/nto-low.c +++ b/gdbserver/nto-low.c @@ -789,8 +789,8 @@ nto_process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr, return nto_read_auxv_from_initial_stack (initial_stack, myaddr, len); } -static int -nto_supports_z_point_type (char z_type) +bool +nto_process_target::supports_z_point_type (char z_type) { switch (z_type) { @@ -799,9 +799,9 @@ nto_supports_z_point_type (char z_type) case Z_PACKET_WRITE_WP: case Z_PACKET_READ_WP: case Z_PACKET_ACCESS_WP: - return 1; + return true; default: - return 0; + return false; } } @@ -950,7 +950,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size) static nto_process_target the_nto_target; static process_stratum_target nto_target_ops = { - nto_supports_z_point_type, nto_insert_point, nto_remove_point, NULL, /* stopped_by_sw_breakpoint */ diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h index f1e9e31478c..d99d5d7acc7 100644 --- a/gdbserver/nto-low.h +++ b/gdbserver/nto-low.h @@ -83,6 +83,8 @@ public: int read_auxv (CORE_ADDR offset, unsigned char *myaddr, unsigned int len) override; + + bool supports_z_point_type (char z_type) override; }; /* The inferior's target description. This is a global because the diff --git a/gdbserver/target.c b/gdbserver/target.c index 97e9d4ac507..22339622e09 100644 --- a/gdbserver/target.c +++ b/gdbserver/target.c @@ -427,3 +427,9 @@ process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr, { gdb_assert_not_reached ("target op read_auxv not supported"); } + +bool +process_target::supports_z_point_type (char z_type) +{ + return false; +} diff --git a/gdbserver/target.h b/gdbserver/target.h index 0d3e16c6ed5..383a848fcb9 100644 --- a/gdbserver/target.h +++ b/gdbserver/target.h @@ -70,16 +70,6 @@ class process_target; shared code. */ struct process_stratum_target { - /* Returns true if GDB Z breakpoint type TYPE is supported, false - otherwise. The type is coded as follows: - '0' - software-breakpoint - '1' - hardware-breakpoint - '2' - write watchpoint - '3' - read watchpoint - '4' - access watchpoint - */ - int (*supports_z_point_type) (char z_type); - /* Insert and remove a break or watchpoint. Returns 0 on success, -1 on failure and 1 on unsupported. */ @@ -476,6 +466,16 @@ public: Read LEN bytes at OFFSET into a buffer at MYADDR. */ virtual int read_auxv (CORE_ADDR offset, unsigned char *myaddr, unsigned int len); + + /* Returns true if GDB Z breakpoint type TYPE is supported, false + otherwise. The type is coded as follows: + '0' - software-breakpoint + '1' - hardware-breakpoint + '2' - write watchpoint + '3' - read watchpoint + '4' - access watchpoint + */ + virtual bool supports_z_point_type (char z_type); }; extern process_stratum_target *the_target; diff --git a/gdbserver/win32-low.c b/gdbserver/win32-low.c index 18e977993dc..74b70659465 100644 --- a/gdbserver/win32-low.c +++ b/gdbserver/win32-low.c @@ -255,8 +255,8 @@ child_delete_thread (DWORD pid, DWORD tid) /* These watchpoint related wrapper functions simply pass on the function call if the low target has registered a corresponding function. */ -static int -win32_supports_z_point_type (char z_type) +bool +win32_process_target::supports_z_point_type (char z_type) { return (the_low_target.supports_z_point_type != NULL && the_low_target.supports_z_point_type (z_type)); @@ -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 = { - win32_supports_z_point_type, win32_insert_point, win32_remove_point, NULL, /* stopped_by_sw_breakpoint */ diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h index 078ae7255f3..f40dfb48822 100644 --- a/gdbserver/win32-low.h +++ b/gdbserver/win32-low.h @@ -137,6 +137,8 @@ public: int len) override; void request_interrupt () override; + + bool supports_z_point_type (char z_type) override; }; /* Retrieve the context for this thread, if not already retrieved. */