From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: "'Pedro Alves'" <pedro@codesourcery.com>
Cc: "'Joel Brobecker'" <brobecker@adacore.com>, <gdb-patches@sourceware.org>
Subject: [RFA] Add watchpoint hit address function to procfs.c
Date: Mon, 10 May 2010 22:19:00 -0000 [thread overview]
Message-ID: <001b01caf08e$ba7d5a40$2f780ec0$@muller@ics-cnrs.unistra.fr> (raw)
In-Reply-To: <201005102249.20383.pedro@codesourcery.com>
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 <muller@ics.u-strasbg.fr>
* 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;
}
/*
next prev parent reply other threads:[~2010-05-10 22:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-26 14:17 [RFC] " Pierre Muller
2010-05-07 15:25 ` Pedro Alves
2010-05-08 16:46 ` Pierre Muller
2010-05-08 17:24 ` Pedro Alves
2010-05-10 7:16 ` Pierre Muller
2010-05-10 19:27 ` Pedro Alves
2010-05-10 21:23 ` Joel Brobecker
2010-05-12 2:31 ` Reformat procfs.c (was: Re: [RFC] Add watchpoint hit address function to procfs.c) Pedro Alves
2010-05-17 10:50 ` Pedro Alves
2010-05-10 21:33 ` [RFC] Add watchpoint hit address function to procfs.c Pierre Muller
2010-05-10 21:49 ` Pedro Alves
2010-05-10 22:19 ` Pierre Muller [this message]
2010-05-11 11:49 ` [RFA] " Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='001b01caf08e$ba7d5a40$2f780ec0$@muller@ics-cnrs.unistra.fr' \
--to=pierre.muller@ics-cnrs.unistra.fr \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox