From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17804 invoked by alias); 10 May 2010 22:19:05 -0000 Received: (qmail 17796 invoked by uid 22791); 10 May 2010 22:19:04 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,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.152) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 May 2010 22:18:59 +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 o4AMITMM092462 ; Tue, 11 May 2010 00:18:30 +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 o4AMITqr059189 ; Tue, 11 May 2010 00:18:29 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from d620muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o4AMISZX079713 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) ; Tue, 11 May 2010 00:18:29 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Pedro Alves'" Cc: "'Joel Brobecker'" , References: <006601cae54b$368452f0$a38cf8d0$@muller@ics-cnrs.unistra.fr> <201005102027.10080.pedro@codesourcery.com> <001801caf088$4d8a7ae0$e89f70a0$@muller@ics-cnrs.unistra.fr> <201005102249.20383.pedro@codesourcery.com> In-Reply-To: <201005102249.20383.pedro@codesourcery.com> Subject: [RFA] Add watchpoint hit address function to procfs.c Date: Mon, 10 May 2010 22:19:00 -0000 Message-ID: <001b01caf08e$ba7d5a40$2f780ec0$@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-05/txt/msg00238.txt.bz2 Just to be sure, here is the final version of the patch. I did not change the issue of si_addr reporting zero, but we need to remember this possibility if any target reports new failures after that patch. Is this OK to commit? Pierre 2010-05-11 Pierre Muller * procfs.c (proc_watchpoint_address): New function. (procfs_stopped_by_watchpoint): Remove useless check after find_procinfo_or_die call. (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 10 May 2010 22:09:19 -0000 @@ -1313,6 +1313,34 @@ proc_what (procinfo *pi) #endif } +/* + * Function: proc_watchpoint_address + * + * This function is only called when PI is stopped by a watchpoint. + * Assuming OS supports it, write to *ADDR the data address which + * triggered it and return 1. + * Return 0 if it is not possible to know the address. + */ + +static int +proc_watchpoint_address (procinfo *pi, CORE_ADDR *addr) +{ + if (!pi->status_valid) + if (!proc_get_status (pi)) + return 0; + +#ifdef NEW_PROC_API + *addr = (CORE_ADDR) gdbarch_pointer_to_address (target_gdbarch, + builtin_type (target_gdbarch)->builtin_data_ptr, + (gdb_byte *) &pi->prstatus.pr_lwp.pr_info.si_addr); +#else + *addr = (CORE_ADDR) gdbarch_pointer_to_address (target_gdbarch, + builtin_type (target_gdbarch)->builtin_data_ptr, + (gdb_byte *) &pi->prstatus.pr_info.si_addr); +#endif + return 1; +} + #ifndef PIOCSSPCACT /* The following is not supported on OSF. */ /* * Function: proc_nsysarg @@ -5541,9 +5569,6 @@ procfs_stopped_by_watchpoint (void) 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) @@ -5561,6 +5586,26 @@ procfs_stopped_by_watchpoint (void) return 0; } +/* + * Function procfs_stopped_data_address + * + * Returns 1 if we the OS knows the position of the triggered + * watchpoint. Sets *ADDR to that address. + * Returns 0 if OS cannot report that address. + * This function is only called if procfs_stopped_by_watchpoint + * returned 1, thus no further checks are done. + * The function also assumes that ADDR is not NULL. + */ + +static int +procfs_stopped_data_address (struct target_ops *targ, CORE_ADDR *addr) +{ + procinfo *pi; + + pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); + return proc_watchpoint_address (pi, addr); +} + static int procfs_insert_watchpoint (CORE_ADDR addr, int len, int type) { @@ -5607,6 +5652,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; } /*