From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6512 invoked by alias); 26 Apr 2010 14:17:36 -0000 Received: (qmail 6504 invoked by uid 22791); 26 Apr 2010 14:17:34 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,MSGID_MULTIPLE_AT X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.154) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 26 Apr 2010 14:17:26 +0000 Received: from baal.u-strasbg.fr (baal.u-strasbg.fr [IPv6:2001:660:2402::41]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o3QEHMZf030426 for ; Mon, 26 Apr 2010 16:17:22 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms1.u-strasbg.fr [IPv6:2001:660:2402:d::10]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id o3QEHMGC042535 for ; Mon, 26 Apr 2010 16:17:22 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from d620muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o3QEHMnG050646 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Mon, 26 Apr 2010 16:17:22 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: Subject: [RFC] Add watchpoint hit address function to procfs.c Date: Mon, 26 Apr 2010 14:17:00 -0000 Message-ID: <006601cae54b$368452f0$a38cf8d0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00869.txt.bz2 The following patch adds support for to_stopped_data_address field of target_ops, using prstatus.pr_lwp.pr_info.__data.__fault.__addr field. (or prstatus.pr_info.__data.__fault.__addr if NEW_PROC_API is not defined) I found that in the OpenSolaris sources. It works for my OpenSolaris 2.11. The main problem is that I have no ideas if this works for other targets using procfs.c source. How should this be modified to avoid problem if other targets do not have/set these fields? Comments welcome. Pierre Muller Pascal language support maintainer for GDB 2010-04-26 Pierre Muller * procfs.c (proc_watchpoint_address): New function. (procfs_stopped_data_address): New function. (procfs_use_watchpoints): Register new watchpoint related function. Index: procfs.c =================================================================== RCS file: /cvs/src/src/gdb/procfs.c,v retrieving revision 1.131 diff -u -p -r1.131 procfs.c --- procfs.c 20 Apr 2010 22:36:35 -0000 1.131 +++ procfs.c 26 Apr 2010 14:05:29 -0000 @@ -1312,6 +1312,30 @@ proc_what (procinfo *pi) return pi->prstatus.pr_what; #endif } +/* + * Function: proc_watchpoint_address + * + * returns the prstatus.pr_lwp.pr_info.__data.__fault.__addr field. + */ + +CORE_ADDR +proc_watchpoint_address (procinfo *pi) +{ + if (!pi->status_valid) + if (!proc_get_status (pi)) + return 0; /* FIXME: not a good failure value (but what is?) */ + +#ifdef NEW_PROC_API + return unsigned_pointer_to_address (target_gdbarch, + builtin_type (target_gdbarch)->builtin_data_ptr, + (gdb_byte *) &pi->prstatus.pr_lwp.pr_info.__data.__fault.__addr); +#else + return unsigned_pointer_to_address (target_gdbarch, + builtin_type (target_gdbarch)->builtin_data_ptr, + (gdb_byte *) &pi->prstatus.pr_info.__data.__fault.__addr); +#endif +} + #ifndef PIOCSSPCACT /* The following is not supported on OSF. */ /* @@ -5560,6 +5584,45 @@ procfs_stopped_by_watchpoint (void) } return 0; } +/* + * Function procfs_stopped_data_address + * Returns non-zero if we can find the position + * of the triggring watchpoint. + */ + +static int +procfs_stopped_data_address (struct target_ops *targ, CORE_ADDR *addr) +{ + CORE_ADDR waddr; + procinfo *pi; + int watchpoint_hit = 0; + + pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); + + if (!pi) /* If no process, then not stopped by watchpoint! */ + return 0; + + if (proc_flags (pi) & (PR_STOPPED | PR_ISTOP)) + { + if (proc_why (pi) == PR_FAULTED) + { +#ifdef FLTWATCH + if (proc_what (pi) == FLTWATCH) + watchpoint_hit = 1; +#endif +#ifdef FLTKWATCH + if (proc_what (pi) == FLTKWATCH) + watchpoint_hit = 1; +#endif + } + } + if (!watchpoint_hit) + return 0; + waddr = proc_watchpoint_address (pi); + if (addr) + *addr = waddr; + return (waddr != 0); +} static int procfs_insert_watchpoint (CORE_ADDR addr, int len, int type) @@ -5607,6 +5670,7 @@ procfs_use_watchpoints (struct target_op 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; } /*