This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Remote protocol: Z-packets
- From: Grace Sainsbury <graces at redhat dot com>
- To: gdb at sources dot redhat dot com
- Date: Fri, 16 Aug 2002 12:48:11 -0400
- Subject: Remote protocol: Z-packets
The following function, a modified version of a patch written by
Fernando Nasser, can be used to probe for hardware break/watchpoint
support when called each time a watchpoint is created. This seems to
be the best way of doing this, but if anyone can think of a better way
I'd appreciate it.
I also think that it would be a good idea to change the errors that
are returned when insertion fails. Right now the same error is returned
for a syntax error, a bad address, or when the breakpoint registers
are full; so the error message the user gets cannot be very
specific.
thanks,
grace
/* This is checked by some targets to check if HW watchpoints can be
used. */
int
remote_check_watch_resources (int type, int cnt, int ot)
{
char *buf;
enum Z_packet_type packet;
struct remote_state *rs = get_remote_state ();
/* Before connecting, we have no means to figure what kind of
watchpoints we support, so we don't let them be set at all (we do
not recover well from failing to insert when continuing. */
if (remote_desc == NULL)
error ("Cannot set watchpoints before connecting to remote
target\n");
switch (type)
{
case bp_hardware_breakpoint:
packet = Z_PACKET_HARDWARE_BP;
break;
case bp_hardware_watchpoint:
packet = Z_PACKET_WRITE_WP;
break;
case bp_read_watchpoint:
packet = Z_PACKET_READ_WP;
break;
case bp_access_watchpoint:
packet = Z_PACKET_ACCESS_WP;
break;
default: /* Unknown type. */
return 0;
}
/* Try a bogus "Z" packet (if it is not already disabled). If the
request succeeds with an error then it is supported. If it
fails, set it to PACKET_DISABLE. */
if (remote_protocol_Z[packet].support == PACKET_SUPPORT_UNKNOWN)
{
buf = alloca (rs->remote_packet_size);
/* The packet that we send is malformed -- we don't want to set
anything. If the response is NUL then the packet is not
supported, otherwise we receive an error but we know that the
packet was taken. */
sprintf (buf, "Z%x,1,", packet);
putpkt (buf);
getpkt (buf, rs->remote_packet_size, 0);
if (buf[0] != '\0')
{
remote_protocol_Z[packet].support = PACKET_ENABLE;
return 1;
}
else
{
remote_protocol_Z[packet].support = PACKET_DISABLE;
return 0;
}
}
return (remote_protocol_Z[packet].support != PACKET_DISABLE);
}