aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrjan Friberg <orjanf@axis.com>2005-05-12 12:14:23 +0000
committerOrjan Friberg <orjanf@axis.com>2005-05-12 12:14:23 +0000
commite013ee27c925f173a7e402fce26a2c75f78f9f40 (patch)
treeb4791156d9d0694fda9746c7c550ba420ebcc427
parent119b882a3d5bbb167438b2020cbadd17ba4a9202 (diff)
downloadfsf-binutils-gdb-e013ee27c925f173a7e402fce26a2c75f78f9f40.zip
fsf-binutils-gdb-e013ee27c925f173a7e402fce26a2c75f78f9f40.tar.gz
fsf-binutils-gdb-e013ee27c925f173a7e402fce26a2c75f78f9f40.tar.bz2
2005-05-12 Orjan Friberg <orjanf@axis.com>
* target.h (struct target_ops): Add insert_watchpoint, remove_watchpoint, stopped_by_watchpoint, stopped_data_address function pointers for hardware watchpoint support. * linux-low.h (struct linux_target_ops): Ditto. * linux-low.c (linux_insert_watchpoint, linux_remove_watchpoint) (linux_stopped_by_watchpoint, linux_stopped_data_address): New. Add to linux_target_ops. * remote-utils.c (prepare_resume_reply): Add watchpoint information to reply packet. * server.c (main): Recognize 'Z' and 'z' packets.
-rw-r--r--gdb/gdbserver/ChangeLog13
-rw-r--r--gdb/gdbserver/linux-low.c46
-rw-r--r--gdb/gdbserver/linux-low.h7
-rw-r--r--gdb/gdbserver/remote-utils.c22
-rw-r--r--gdb/gdbserver/server.c60
-rw-r--r--gdb/gdbserver/target.h21
6 files changed, 168 insertions, 1 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 6c8fd3a..311d3ec 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,16 @@
+2005-05-12 Orjan Friberg <orjanf@axis.com>
+
+ * target.h (struct target_ops): Add insert_watchpoint,
+ remove_watchpoint, stopped_by_watchpoint, stopped_data_address function
+ pointers for hardware watchpoint support.
+ * linux-low.h (struct linux_target_ops): Ditto.
+ * linux-low.c (linux_insert_watchpoint, linux_remove_watchpoint)
+ (linux_stopped_by_watchpoint, linux_stopped_data_address): New. Add
+ to linux_target_ops.
+ * remote-utils.c (prepare_resume_reply): Add watchpoint information to
+ reply packet.
+ * server.c (main): Recognize 'Z' and 'z' packets.
+
2005-05-10 Ulrich Weigand <uweigand@de.ibm.com>
* linux-s390-low.c (s390_breakpoint, s390_breakpoint_len): Define.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 4244fc9..c7dab4c 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -1467,7 +1467,47 @@ linux_read_auxv (CORE_ADDR offset, char *myaddr, unsigned int len)
return n;
}
-
+/* These watchpoint related wrapper functions simply pass on the function call
+ if the target has registered a corresponding function. */
+
+static int
+linux_insert_watchpoint (char type, CORE_ADDR addr, int len)
+{
+ if (the_low_target.insert_watchpoint != NULL)
+ return the_low_target.insert_watchpoint (type, addr, len);
+ else
+ /* Unsupported (see target.h). */
+ return 1;
+}
+
+static int
+linux_remove_watchpoint (char type, CORE_ADDR addr, int len)
+{
+ if (the_low_target.remove_watchpoint != NULL)
+ return the_low_target.remove_watchpoint (type, addr, len);
+ else
+ /* Unsupported (see target.h). */
+ return 1;
+}
+
+static int
+linux_stopped_by_watchpoint (void)
+{
+ if (the_low_target.stopped_by_watchpoint != NULL)
+ return the_low_target.stopped_by_watchpoint ();
+ else
+ return 0;
+}
+
+static CORE_ADDR
+linux_stopped_data_address (void)
+{
+ if (the_low_target.stopped_data_address != NULL)
+ return the_low_target.stopped_data_address ();
+ else
+ return 0;
+}
+
static struct target_ops linux_target_ops = {
linux_create_inferior,
linux_attach,
@@ -1483,6 +1523,10 @@ static struct target_ops linux_target_ops = {
linux_look_up_symbols,
linux_send_signal,
linux_read_auxv,
+ linux_insert_watchpoint,
+ linux_remove_watchpoint,
+ linux_stopped_by_watchpoint,
+ linux_stopped_data_address,
};
static void
diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h
index 5e41c48..9c35513 100644
--- a/gdb/gdbserver/linux-low.h
+++ b/gdb/gdbserver/linux-low.h
@@ -57,6 +57,13 @@ struct linux_target_ops
int decr_pc_after_break;
int (*breakpoint_at) (CORE_ADDR pc);
+
+ /* Watchpoint related functions. See target.h for comments. */
+ int (*insert_watchpoint) (char type, CORE_ADDR addr, int len);
+ int (*remove_watchpoint) (char type, CORE_ADDR addr, int len);
+ int (*stopped_by_watchpoint) (void);
+ CORE_ADDR (*stopped_data_address) (void);
+
};
extern struct linux_target_ops the_low_target;
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 7cc9150..8082090 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -639,6 +639,28 @@ prepare_resume_reply (char *buf, char status, unsigned char signo)
if (status == 'T')
{
const char **regp = gdbserver_expedite_regs;
+
+ if (the_target->stopped_by_watchpoint != NULL
+ && (*the_target->stopped_by_watchpoint) ())
+ {
+ CORE_ADDR addr;
+ int i;
+
+ strncpy (buf, "watch:", 6);
+ buf += 6;
+
+ addr = (*the_target->stopped_data_address) ();
+
+ /* Convert each byte of the address into two hexadecimal chars.
+ Note that we take sizeof (void *) instead of sizeof (addr);
+ this is to avoid sending a 64-bit address to a 32-bit GDB. */
+ for (i = sizeof (void *) * 2; i > 0; i--)
+ {
+ *buf++ = tohex ((addr >> (i - 1) * 4) & 0xf);
+ }
+ *buf++ = ';';
+ }
+
while (*regp)
{
buf = outreg (find_regno (*regp), buf);
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index c8ba5a2..137ae9e 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -509,6 +509,66 @@ main (int argc, char *argv[])
signal = mywait (&status, 1);
prepare_resume_reply (own_buf, status, signal);
break;
+ case 'Z':
+ {
+ char *lenptr;
+ char *dataptr;
+ CORE_ADDR addr = strtoul (&own_buf[3], &lenptr, 16);
+ int len = strtol (lenptr + 1, &dataptr, 16);
+ char type = own_buf[1];
+
+ if (the_target->insert_watchpoint == NULL
+ || (type < '2' || type > '4'))
+ {
+ /* No watchpoint support or not a watchpoint command;
+ unrecognized either way. */
+ own_buf[0] = '\0';
+ }
+ else
+ {
+ int res;
+
+ res = (*the_target->insert_watchpoint) (type, addr, len);
+ if (res == 0)
+ write_ok (own_buf);
+ else if (res == 1)
+ /* Unsupported. */
+ own_buf[0] = '\0';
+ else
+ write_enn (own_buf);
+ }
+ break;
+ }
+ case 'z':
+ {
+ char *lenptr;
+ char *dataptr;
+ CORE_ADDR addr = strtoul (&own_buf[3], &lenptr, 16);
+ int len = strtol (lenptr + 1, &dataptr, 16);
+ char type = own_buf[1];
+
+ if (the_target->remove_watchpoint == NULL
+ || (type < '2' || type > '4'))
+ {
+ /* No watchpoint support or not a watchpoint command;
+ unrecognized either way. */
+ own_buf[0] = '\0';
+ }
+ else
+ {
+ int res;
+
+ res = (*the_target->remove_watchpoint) (type, addr, len);
+ if (res == 0)
+ write_ok (own_buf);
+ else if (res == 1)
+ /* Unsupported. */
+ own_buf[0] = '\0';
+ else
+ write_enn (own_buf);
+ }
+ break;
+ }
case 'k':
fprintf (stderr, "Killing inferior\n");
kill_inferior ();
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index f1e0d6e..38708fd 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -133,6 +133,27 @@ struct target_ops
Read LEN bytes at OFFSET into a buffer at MYADDR. */
int (*read_auxv) (CORE_ADDR offset, char *myaddr, unsigned int len);
+
+ /* Insert and remove a hardware watchpoint.
+ Returns 0 on success, -1 on failure and 1 on unsupported.
+ The type is coded as follows:
+ 2 = write watchpoint
+ 3 = read watchpoint
+ 4 = access watchpoint
+ */
+
+ int (*insert_watchpoint) (char type, CORE_ADDR addr, int len);
+ int (*remove_watchpoint) (char type, CORE_ADDR addr, int len);
+
+ /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise. */
+
+ int (*stopped_by_watchpoint) (void);
+
+ /* Returns the address associated with the watchpoint that hit, if any;
+ returns 0 otherwise. */
+
+ CORE_ADDR (*stopped_data_address) (void);
+
};
extern struct target_ops *the_target;