From patchwork Thu Apr 12 16:57:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 26694 Received: (qmail 92272 invoked by alias); 12 Apr 2018 16:57:48 -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 92263 invoked by uid 89); 12 Apr 2018 16:57:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.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.2 spammy=Forward X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Apr 2018 16:57:46 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83A5D406805A for ; Thu, 12 Apr 2018 16:57:44 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BF371208F8E for ; Thu, 12 Apr 2018 16:57:43 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH] Eliminate procfs.c:procfs_use_watchpoints Date: Thu, 12 Apr 2018 17:57:43 +0100 Message-Id: <20180412165743.27235-1-palves@redhat.com> Now that procfs.c is only ever used by Solaris, and, both x86 and SPARC Solaris support watchpoints (*), we don't need the separate procfs_use_watchpoints function. Getting rid of it simplifies C++ification of target_ops. (*) and I assume that any other Solaris port would use the same kernel debug API interfaces for watchpoints. Otherwise, we can worry about it if it ever happens. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * procfs.c (procfs_stopped_by_watchpoint) (procfs_insert_watchpoint, procfs_remove_watchpoint) (procfs_region_ok_for_hw_watchpoint, procfs_stopped_data_address): Forward declare. (procfs_use_watchpoints): Delete, move contents... (procfs_target): ... here. * procfs.h (procfs_use_watchpoints): Delete declaration. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Don't call procfs_use_watchpoints. * sparc-sol2-nat.c (_initialize_sparc_sol2_nat): Don't call procfs_use_watchpoints. --- gdb/i386-sol2-nat.c | 2 -- gdb/procfs.c | 34 +++++++++++++++++++++++----------- gdb/procfs.h | 6 ------ gdb/sparc-sol2-nat.c | 1 - 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/gdb/i386-sol2-nat.c b/gdb/i386-sol2-nat.c index 679bb861eb..359fc3203d 100644 --- a/gdb/i386-sol2-nat.c +++ b/gdb/i386-sol2-nat.c @@ -138,8 +138,6 @@ _initialize_amd64_sol2_nat (void) /* Fill in the generic procfs methods. */ t = procfs_target (); - procfs_use_watchpoints (t); - #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) amd64_native_gregset32_reg_offset = amd64_sol2_gregset32_reg_offset; amd64_native_gregset32_num_regs = diff --git a/gdb/procfs.c b/gdb/procfs.c index 3c747cd3e2..0143f2621c 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -126,6 +126,22 @@ static int procfs_can_use_hw_breakpoint (struct target_ops *self, static void procfs_info_proc (struct target_ops *, const char *, enum info_proc_what); +static int procfs_stopped_by_watchpoint (struct target_ops *); + +static int procfs_insert_watchpoint (struct target_ops *, + CORE_ADDR, int, + enum target_hw_bp_type, + struct expression *); + +static int procfs_remove_watchpoint (struct target_ops *, + CORE_ADDR, int, + enum target_hw_bp_type, + struct expression *); + +static int procfs_region_ok_for_hw_watchpoint (struct target_ops *, + CORE_ADDR, int); +static int procfs_stopped_data_address (struct target_ops *, CORE_ADDR *); + #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) /* When GDB is built as 64-bit application on Solaris, the auxv data is presented in 64-bit format. We need to provide a custom parser @@ -186,6 +202,13 @@ procfs_target (void) t->to_auxv_parse = procfs_auxv_parse; #endif + t->to_stopped_by_watchpoint = procfs_stopped_by_watchpoint; + t->to_insert_watchpoint = procfs_insert_watchpoint; + t->to_remove_watchpoint = procfs_remove_watchpoint; + t->to_region_ok_for_hw_watchpoint = procfs_region_ok_for_hw_watchpoint; + t->to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint; + t->to_stopped_data_address = procfs_stopped_data_address; + t->to_magic = OPS_MAGIC; return t; @@ -3385,17 +3408,6 @@ procfs_region_ok_for_hw_watchpoint (struct target_ops *self, return 1; } -void -procfs_use_watchpoints (struct target_ops *t) -{ - t->to_stopped_by_watchpoint = procfs_stopped_by_watchpoint; - t->to_insert_watchpoint = procfs_insert_watchpoint; - t->to_remove_watchpoint = procfs_remove_watchpoint; - t->to_region_ok_for_hw_watchpoint = procfs_region_ok_for_hw_watchpoint; - t->to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint; - t->to_stopped_data_address = procfs_stopped_data_address; -} - /* Memory Mappings Functions: */ /* Call a callback function once for each mapping, passing it the diff --git a/gdb/procfs.h b/gdb/procfs.h index 9419a700e0..beeb876a73 100644 --- a/gdb/procfs.h +++ b/gdb/procfs.h @@ -24,12 +24,6 @@ struct target_ops; extern struct target_ops *procfs_target (void); -/* Call this in the native _initialize routine that creates and - customizes the prototype target returned by procfs_target, if the - native debug interface supports procfs watchpoints. */ - -extern void procfs_use_watchpoints (struct target_ops *t); - /* Return a ptid for which we guarantee we will be able to find a 'live' procinfo. */ diff --git a/gdb/sparc-sol2-nat.c b/gdb/sparc-sol2-nat.c index 2ec2cfb3b1..482050d008 100644 --- a/gdb/sparc-sol2-nat.c +++ b/gdb/sparc-sol2-nat.c @@ -104,6 +104,5 @@ _initialize_sparc_sol2_nat (void) struct target_ops *t; t = procfs_target (); - procfs_use_watchpoints (t); add_target (t); }