This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] gdbserver: Add support for Z0/Z1 packets
- From: Aleksandar Ristovski <aristovski at qnx dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 16 Jun 2009 21:18:51 -0400
- Subject: [patch] gdbserver: Add support for Z0/Z1 packets
Hello,
This adds support for Z0 and Z1 (and z0 and z1) packets.
Thanks,
--
Aleksandar Ristovski
QNX Software Systems
ChangeLog:
* target.h (insert_breakpoint, remove_breakpoint): New
target functions.
* server.c (handle_query): 'Z' and 'z' packet - add support
for [Zz]0 and [Zz]1 - software and hardware breakpoints.
* linux-low.c (linux_target_ops): Add new fields.
* spu-low.c (spu_target_ops): Likewise.
* win32-low.c (win32_target_ops): Likewise.
Index: target.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/target.h,v
retrieving revision 1.36
diff -u -p -r1.36 target.h
--- target.h 1 Apr 2009 22:50:24 -0000 1.36
+++ target.h 17 Jun 2009 01:11:04 -0000
@@ -228,6 +228,14 @@ struct target_ops
int (*stopped_by_watchpoint) (void);
+ /* Insert and remove breakpoint. Argument TYPE can be:
+ '0' = software-breakpoint
+ '1' = hardware-breakpoint
+ Returns 0 if successful, 1 otherwise. */
+
+ int (*insert_breakpoint) (char type, CORE_ADDR addr);
+ int (*remove_breakpoint) (char type, CORE_ADDR addr);
+
/* Returns the address associated with the watchpoint that hit, if any;
returns 0 otherwise. */
Index: server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.97
diff -u -p -r1.97 server.c
--- server.c 24 May 2009 21:06:53 -0000 1.97
+++ server.c 17 Jun 2009 01:11:05 -0000
@@ -1106,7 +1106,8 @@ handle_query (char *own_buf, int packet_
if (the_target->qxfer_osdata != NULL)
strcat (own_buf, ";qXfer:osdata:read+");
- strcat (own_buf, ";multiprocess+");
+ if (multi_process)
+ strcat (own_buf, ";multiprocess+");
if (target_supports_non_stop ())
strcat (own_buf, ";QNonStop+");
@@ -2373,28 +2374,48 @@ process_serial_event (void)
CORE_ADDR addr = strtoul (&own_buf[3], &lenptr, 16);
int len = strtol (lenptr + 1, &dataptr, 16);
char type = own_buf[1];
+ int res = -1;
+
+ /* Type: '0' - software-breakpoint
+ '1' - hardware-breakpoint
+ '2' - write watchpoint
+ '3' - read watchpoint
+ '4' - access watchpoint */
- if (the_target->insert_watchpoint == NULL
- || (type < '2' || type > '4'))
+ if (type < '2' && type >= '0')
{
- /* No watchpoint support or not a watchpoint command;
- unrecognized either way. */
- own_buf[0] = '\0';
+ /* Insert breakpoint. */
+ if (the_target->insert_breakpoint == NULL)
+ {
+ /* Not supported. */
+ own_buf[0] = '\0';
+ res = 1;
+ }
+ else
+ res = (*the_target->insert_breakpoint) (type, addr);
}
else
{
- int res;
-
- require_running (own_buf);
- res = (*the_target->insert_watchpoint) (type, addr, len);
- if (res == 0)
- write_ok (own_buf);
- else if (res == 1)
- /* Unsupported. */
- own_buf[0] = '\0';
+ if (the_target->insert_watchpoint == NULL)
+ {
+ /* No watchpoint support or not a watchpoint command;
+ unrecognized either way. */
+ own_buf[0] = '\0';
+ res = 1;
+ }
else
- write_enn (own_buf);
+ {
+ require_running (own_buf);
+ 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':
@@ -2404,28 +2425,48 @@ process_serial_event (void)
CORE_ADDR addr = strtoul (&own_buf[3], &lenptr, 16);
int len = strtol (lenptr + 1, &dataptr, 16);
char type = own_buf[1];
+ int res = -1;
- if (the_target->remove_watchpoint == NULL
- || (type < '2' || type > '4'))
+ /* Type: '0' - software-breakpoint
+ '1' - hardware-breakpoint
+ '2' - write watchpoint
+ '3' - read watchpoint
+ '4' - access watchpoint */
+
+ if (type < '2' && type >= '0')
{
- /* No watchpoint support or not a watchpoint command;
- unrecognized either way. */
- own_buf[0] = '\0';
+ /* Remove breakpoint. */
+ if (the_target->remove_breakpoint == NULL)
+ {
+ /* Not supported. */
+ own_buf[0] = '\0';
+ res = 1;
+ }
+ else
+ res = (*the_target->remove_breakpoint) (type, addr);
}
else
{
- int res;
-
- require_running (own_buf);
- res = (*the_target->remove_watchpoint) (type, addr, len);
- if (res == 0)
- write_ok (own_buf);
- else if (res == 1)
- /* Unsupported. */
- own_buf[0] = '\0';
+ if (the_target->remove_watchpoint == NULL)
+ {
+ /* No watchpoint support or not a watchpoint command;
+ unrecognized either way. */
+ own_buf[0] = '\0';
+ res = 1;
+ }
else
- write_enn (own_buf);
+ {
+ require_running (own_buf);
+ 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':
Index: linux-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v
retrieving revision 1.105
diff -u -p -r1.105 linux-low.c
--- linux-low.c 24 May 2009 17:44:19 -0000 1.105
+++ linux-low.c 17 Jun 2009 01:11:05 -0000
@@ -3027,6 +3027,8 @@ static struct target_ops linux_target_op
linux_insert_watchpoint,
linux_remove_watchpoint,
linux_stopped_by_watchpoint,
+ NULL, /* insert_breakpoint */
+ NULL, /* remove_breakpoint */
linux_stopped_data_address,
#if defined(__UCLIBC__) && defined(HAS_NOMMU)
linux_read_offsets,
Index: spu-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/spu-low.c,v
retrieving revision 1.24
diff -u -p -r1.24 spu-low.c
--- spu-low.c 3 Apr 2009 14:38:39 -0000 1.24
+++ spu-low.c 17 Jun 2009 01:11:05 -0000
@@ -615,6 +615,8 @@ static struct target_ops spu_target_ops
NULL,
NULL,
NULL,
+ NULL, /* insert_breakpoint */
+ NULL, /* remove_breakpoint */
NULL,
NULL,
NULL,
Index: win32-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/win32-low.c,v
retrieving revision 1.35
diff -u -p -r1.35 win32-low.c
--- win32-low.c 1 Apr 2009 22:50:24 -0000 1.35
+++ win32-low.c 17 Jun 2009 01:11:05 -0000
@@ -1700,6 +1700,8 @@ static struct target_ops win32_target_op
NULL,
NULL,
NULL,
+ NULL, /* insert_breakpoint */
+ NULL, /* remove_breakpoint */
NULL,
NULL,
NULL,