/* Remote target communications for serial-line targets in custom GDB protocol
- Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
- 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+ 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
/* See the GDB User Guide for details of the GDB remote protocol. */
#include "value.h"
#include "gdb_assert.h"
#include "observer.h"
+#include "solib.h"
#include <ctype.h>
#include <sys/time.h>
static void remote_files_info (struct target_ops *ignore);
-static int remote_xfer_memory (CORE_ADDR memaddr, char *myaddr,
- int len, int should_write,
- struct mem_attrib *attrib,
- struct target_ops *target);
-
static void remote_prepare_to_store (void);
static void remote_fetch_registers (int regno);
static long read_frame (char *buf, long sizeof_buf);
-static int remote_insert_breakpoint (CORE_ADDR, char *);
+static int remote_insert_breakpoint (CORE_ADDR, bfd_byte *);
-static int remote_remove_breakpoint (CORE_ADDR, char *);
+static int remote_remove_breakpoint (CORE_ADDR, bfd_byte *);
static int hexnumlen (ULONGEST num);
static int fromhex (int a);
-static int hex2bin (const char *hex, char *bin, int count);
+static int hex2bin (const char *hex, gdb_byte *bin, int count);
-static int bin2hex (const char *bin, char *hex, int count);
+static int bin2hex (const gdb_byte *bin, char *hex, int count);
static int putpkt_binary (char *buf, int cnt);
int regnum;
struct remote_state *rs = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct remote_state);
- if (deprecated_register_bytes () != 0)
- rs->sizeof_g_packet = deprecated_register_bytes ();
- else
- rs->sizeof_g_packet = 0;
+ rs->sizeof_g_packet = 0;
/* Assume a 1:1 regnum<->pnum table. */
rs->regs = GDBARCH_OBSTACK_CALLOC (gdbarch, NUM_REGS + NUM_PSEUDO_REGS,
/* ...name = REGISTER_NAME (regnum); */
/* Compute packet size by accumulating the size of all registers. */
- if (deprecated_register_bytes () == 0)
- rs->sizeof_g_packet += register_size (current_gdbarch, regnum);
+ if (regnum < NUM_REGS)
+ rs->sizeof_g_packet += register_size (current_gdbarch, regnum);
}
/* Default maximum number of characters in a packet body. Many
\f
/* User configurable variables for the number of characters in a
- memory read/write packet. MIN ((rs->remote_packet_size),
+ memory read/write packet. MIN (rs->remote_packet_size,
rs->sizeof_g_packet) is the default. Some targets need smaller
- values (fifo overruns, et.al.) and some users need larger values
+ values (fifo overruns, et.al.) and some users need larger values
(speed up transfers). The variables ``preferred_*'' (the user
request), ``current_*'' (what was actually set) and ``forced_*''
(Positive - a soft limit, negative - a hard limit). */
}
else
{
- what_they_get = (rs->remote_packet_size);
+ what_they_get = rs->remote_packet_size;
/* Limit the packet to the size specified by the user. */
if (config->size > 0
&& what_they_get > config->size)
long size = get_memory_packet_size (&memory_read_packet_config);
/* FIXME: cagney/1999-11-07: Functions like getpkt() need to get an
extra buffer size argument before the memory read size can be
- increased beyond (rs->remote_packet_size). */
- if (size > (rs->remote_packet_size))
- size = (rs->remote_packet_size);
+ increased beyond RS->remote_packet_size. */
+ if (size > rs->remote_packet_size)
+ size = rs->remote_packet_size;
return size;
}
buf[3] = '\0';
}
else if (th < 0)
- sprintf (&buf[2], "-%x", -th);
+ xsnprintf (&buf[2], rs->remote_packet_size - 2, "-%x", -th);
else
- sprintf (&buf[2], "%x", th);
+ xsnprintf (&buf[2], rs->remote_packet_size - 2, "%x", th);
putpkt (buf);
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
if (gen)
general_thread = th;
else
char buf[16];
if (tid < 0)
- sprintf (buf, "T-%08x", -tid);
+ xsnprintf (buf, sizeof (buf), "T-%08x", -tid);
else
- sprintf (buf, "T%08x", tid);
+ xsnprintf (buf, sizeof (buf), "T%08x", tid);
putpkt (buf);
getpkt (buf, sizeof (buf), 0);
return (buf[0] == 'O' && buf[1] == 'K');
int active; /* Has state interesting to GDB?
regs, stack. */
char display[256]; /* Brief state display, name,
- blocked/syspended. */
+ blocked/suspended. */
char shortname[32]; /* To be used to name threads. */
char more_display[256]; /* Long info, statistics, queue depth,
whatever. */
int i, value = 0;
unsigned char *scan;
- scan = (char *) ref;
+ scan = *ref;
scan += 4;
i = 4;
while (i-- > 0)
{
struct remote_state *rs = get_remote_state ();
int mask, length;
- unsigned int tag;
+ int tag;
threadref ref;
- char *limit = pkt + (rs->remote_packet_size); /* plausable parsing limit */
+ char *limit = pkt + rs->remote_packet_size; /* Plausible parsing limit. */
int retval = 1;
/* info->threadid = 0; FIXME: implement zero_threadref. */
pack_threadinfo_request (threadinfo_pkt, fieldset, threadid);
putpkt (threadinfo_pkt);
- getpkt (threadinfo_pkt, (rs->remote_packet_size), 0);
+ getpkt (threadinfo_pkt, rs->remote_packet_size, 0);
result = remote_unpack_thread_info_response (threadinfo_pkt + 2,
threadid, info);
return result;
resultcount = 0;
/* Assume the 'q' and 'M chars have been stripped. */
- limit = pkt + ((rs->remote_packet_size) - BUF_THREAD_ID_SIZE);
+ limit = pkt + (rs->remote_packet_size - BUF_THREAD_ID_SIZE);
/* done parse past here */
pkt = unpack_byte (pkt, &count); /* count field */
pkt = unpack_nibble (pkt, &done);
int result = 1;
/* Trancate result limit to be smaller than the packet size. */
- if ((((result_limit + 1) * BUF_THREAD_ID_SIZE) + 10) >= (rs->remote_packet_size))
- result_limit = ((rs->remote_packet_size) / BUF_THREAD_ID_SIZE) - 2;
+ if ((((result_limit + 1) * BUF_THREAD_ID_SIZE) + 10) >= rs->remote_packet_size)
+ result_limit = (rs->remote_packet_size / BUF_THREAD_ID_SIZE) - 2;
pack_threadlist_request (threadlist_packet,
startflag, result_limit, nextthread);
putpkt (threadlist_packet);
- getpkt (t_response, (rs->remote_packet_size), 0);
+ getpkt (t_response, rs->remote_packet_size, 0);
*result_count =
parse_threadlist_response (t_response + 2, result_limit, &echo_nextthread,
char *buf = alloca (rs->remote_packet_size);
putpkt ("qC");
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
if (buf[0] == 'Q' && buf[1] == 'C')
/* Use strtoul here, so we'll correctly parse values whose highest
bit is set. The protocol carries them as a simple series of
{
putpkt ("qfThreadInfo");
bufp = buf;
- getpkt (bufp, (rs->remote_packet_size), 0);
+ getpkt (bufp, rs->remote_packet_size, 0);
if (bufp[0] != '\0') /* q packet recognized */
{
while (*bufp++ == 'm') /* reply contains one or more TID */
while (*bufp++ == ','); /* comma-separated list */
putpkt ("qsThreadInfo");
bufp = buf;
- getpkt (bufp, (rs->remote_packet_size), 0);
+ getpkt (bufp, rs->remote_packet_size, 0);
}
return; /* done */
}
if (use_threadextra_query)
{
- sprintf (bufp, "qThreadExtraInfo,%x", PIDGET (tp->ptid));
+ xsnprintf (bufp, rs->remote_packet_size, "qThreadExtraInfo,%x",
+ PIDGET (tp->ptid));
putpkt (bufp);
- getpkt (bufp, (rs->remote_packet_size), 0);
+ getpkt (bufp, rs->remote_packet_size, 0);
if (bufp[0] != 0)
{
n = min (strlen (bufp) / 2, sizeof (display_buf));
- result = hex2bin (bufp, display_buf, n);
+ result = hex2bin (bufp, (gdb_byte *) display_buf, n);
display_buf [result] = '\0';
return display_buf;
}
if (threadinfo.active)
{
if (*threadinfo.shortname)
- n += sprintf(&display_buf[0], " Name: %s,", threadinfo.shortname);
+ n += xsnprintf (&display_buf[0], sizeof (display_buf) - n,
+ " Name: %s,", threadinfo.shortname);
if (*threadinfo.display)
- n += sprintf(&display_buf[n], " State: %s,", threadinfo.display);
+ n += xsnprintf (&display_buf[n], sizeof (display_buf) - n,
+ " State: %s,", threadinfo.display);
if (*threadinfo.more_display)
- n += sprintf(&display_buf[n], " Priority: %s",
- threadinfo.more_display);
+ n += xsnprintf (&display_buf[n], sizeof (display_buf) - n,
+ " Priority: %s", threadinfo.more_display);
if (n > 0)
{
}
return NULL;
}
-
\f
-/* Restart the remote side; this is an extended protocol operation. */
+/* Restart the remote side; this is an extended protocol operation. */
static void
extended_remote_restart (void)
/* Send the restart command; for reasons I don't understand the
remote side really expects a number after the "R". */
- buf[0] = 'R';
- sprintf (&buf[1], "%x", 0);
+ xsnprintf (buf, rs->remote_packet_size, "R%x", 0);
putpkt (buf);
/* Now query for status so this looks just like we restarted
gdbserver from scratch. */
putpkt ("?");
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
}
\f
/* Clean up connection to a remote debugger. */
struct section_offsets *offs;
putpkt ("qOffsets");
-
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
if (buf[0] == '\000')
return; /* Return silently. Stub doesn't support
/* Invite target to request symbol lookups. */
putpkt ("qSymbol::");
- getpkt (reply, (rs->remote_packet_size), 0);
+ getpkt (reply, rs->remote_packet_size, 0);
packet_ok (reply, &remote_protocol_qSymbol);
while (strncmp (reply, "qSymbol:", 8) == 0)
{
tmp = &reply[8];
- end = hex2bin (tmp, msg, strlen (tmp) / 2);
+ end = hex2bin (tmp, (gdb_byte *) msg, strlen (tmp) / 2);
msg[end] = '\0';
sym = lookup_minimal_symbol (msg, NULL, NULL);
if (sym == NULL)
- sprintf (msg, "qSymbol::%s", &reply[8]);
+ xsnprintf (msg, rs->remote_packet_size, "qSymbol::%s", &reply[8]);
else
- sprintf (msg, "qSymbol:%s:%s",
- paddr_nz (SYMBOL_VALUE_ADDRESS (sym)),
- &reply[8]);
+ xsnprintf (msg, rs->remote_packet_size, "qSymbol:%s:%s",
+ paddr_nz (SYMBOL_VALUE_ADDRESS (sym)),
+ &reply[8]);
putpkt (msg);
- getpkt (reply, (rs->remote_packet_size), 0);
+ getpkt (reply, rs->remote_packet_size, 0);
}
}
remote_open_1 (char *name, int from_tty, struct target_ops *target,
int extended_p, int async_p)
{
- struct gdb_exception ex;
struct remote_state *rs = get_remote_state ();
if (name == 0)
error (_("To open a remote debug connection, you need to specify what\n"
wait_forever_enabled_p = 0;
}
-#ifdef SOLIB_CREATE_INFERIOR_HOOK
/* First delete any symbols previously loaded from shared libraries. */
no_shared_libraries (NULL, 0);
-#endif
/* Start the remote connection. If error() or QUIT, discard this
target (we'd otherwise be in an inconsistent state) and then
been fixed - the function set_cmd_context() makes it possible for
all the ``target ....'' commands to share a common callback
function. See cli-dump.c. */
- ex = catch_exception (uiout, remote_start_remote, NULL, RETURN_MASK_ALL);
- if (ex.reason < 0)
- {
- pop_target ();
- if (async_p)
- wait_forever_enabled_p = 1;
- throw_exception (ex);
- }
+ {
+ struct gdb_exception ex
+ = catch_exception (uiout, remote_start_remote, NULL, RETURN_MASK_ALL);
+ if (ex.reason < 0)
+ {
+ pop_target ();
+ if (async_p)
+ wait_forever_enabled_p = 1;
+ throw_exception (ex);
+ }
+ }
if (async_p)
wait_forever_enabled_p = 1;
/* Tell the remote that we are using the extended protocol. */
char *buf = alloca (rs->remote_packet_size);
putpkt ("!");
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
}
-#ifdef SOLIB_CREATE_INFERIOR_HOOK
+
/* FIXME: need a master target_open vector from which all
remote_opens can be called, so that stuff like this can
go there. Failing that, the following code must be copied
/* Set up to detect and load shared libraries. */
if (exec_bfd) /* No use without an exec file. */
{
+#ifdef SOLIB_CREATE_INFERIOR_HOOK
SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
+#else
+ solib_create_inferior_hook ();
+#endif
remote_check_symbols (symfile_objfile);
}
-#endif
observer_notify_inferior_created (¤t_target, from_tty);
}
/* Tell the remote target to detach. */
strcpy (buf, "D");
- remote_send (buf, (rs->remote_packet_size));
+ remote_send (buf, rs->remote_packet_size);
/* Unregister the file descriptor from the event loop. */
if (target_is_async_p ())
}
static int
-hex2bin (const char *hex, char *bin, int count)
+hex2bin (const char *hex, gdb_byte *bin, int count)
{
int i;
}
static int
-bin2hex (const char *bin, char *hex, int count)
+bin2hex (const gdb_byte *bin, char *hex, int count)
{
int i;
/* May use a length, or a nul-terminated string as input. */
if (count == 0)
- count = strlen (bin);
+ count = strlen ((char *) bin);
for (i = 0; i < count; i++)
{
remote_wait (ptid_t ptid, struct target_waitstatus *status)
{
struct remote_state *rs = get_remote_state ();
- unsigned char *buf = alloca (rs->remote_packet_size);
+ char *buf = alloca (rs->remote_packet_size);
ULONGEST thread_num = -1;
ULONGEST addr;
while (1)
{
- unsigned char *p;
+ char *p;
ofunc = signal (SIGINT, remote_interrupt);
- getpkt (buf, (rs->remote_packet_size), 1);
+ getpkt (buf, rs->remote_packet_size, 1);
signal (SIGINT, ofunc);
/* This is a hook for when we need to do something (perhaps the
continue;
case 'T': /* Status with PC, SP, FP, ... */
{
- char regs[MAX_REGISTER_SIZE];
+ gdb_byte regs[MAX_REGISTER_SIZE];
/* Expedited reply, containing Signal, {regno, reg} repeat. */
/* format is: 'Tssn...:r...;n...:r...;n...:r...;#cc', where
while (*p)
{
- unsigned char *p1;
+ char *p1;
char *p_temp;
int fieldsize;
LONGEST pnum = 0;
{
/* Read the ``P'' register number. */
pnum = strtol (p, &p_temp, 16);
- p1 = (unsigned char *) p_temp;
+ p1 = p_temp;
}
else
p1 = p;
if (p1 == p) /* No register number present here. */
{
- p1 = (unsigned char *) strchr (p, ':');
+ p1 = strchr (p, ':');
if (p1 == NULL)
warning (_("Malformed packet(a) (missing colon): %s\n\
Packet: '%s'\n"),
{
p_temp = unpack_varlen_hex (++p1, &thread_num);
record_currthread (thread_num);
- p = (unsigned char *) p_temp;
+ p = p_temp;
}
else if ((strncmp (p, "watch", p1 - p) == 0)
|| (strncmp (p, "rwatch", p1 - p) == 0)
/* Silently skip unknown optional info. */
p_temp = strchr (p1 + 1, ';');
if (p_temp)
- p = (unsigned char *) p_temp;
+ p = p_temp;
}
}
else
Packet: '%s'\n"),
phex_nz (pnum, 0), p, buf);
- fieldsize = hex2bin (p, regs,
+ fieldsize = hex2bin (p, regs,
register_size (current_gdbarch,
reg->regnum));
p += 2 * fieldsize;
remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
{
struct remote_state *rs = get_remote_state ();
- unsigned char *buf = alloca (rs->remote_packet_size);
+ char *buf = alloca (rs->remote_packet_size);
ULONGEST thread_num = -1;
ULONGEST addr;
while (1)
{
- unsigned char *p;
+ char *p;
if (!target_is_async_p ())
ofunc = signal (SIGINT, remote_interrupt);
_never_ wait for ever -> test on target_is_async_p().
However, before we do that we need to ensure that the caller
knows how to take the target into/out of async mode. */
- getpkt (buf, (rs->remote_packet_size), wait_forever_enabled_p);
+ getpkt (buf, rs->remote_packet_size, wait_forever_enabled_p);
if (!target_is_async_p ())
signal (SIGINT, ofunc);
continue;
case 'T': /* Status with PC, SP, FP, ... */
{
- char regs[MAX_REGISTER_SIZE];
+ gdb_byte regs[MAX_REGISTER_SIZE];
/* Expedited reply, containing Signal, {regno, reg} repeat. */
/* format is: 'Tssn...:r...;n...:r...;n...:r...;#cc', where
while (*p)
{
- unsigned char *p1;
+ char *p1;
char *p_temp;
int fieldsize;
long pnum = 0;
{
/* Read the register number. */
pnum = strtol (p, &p_temp, 16);
- p1 = (unsigned char *) p_temp;
+ p1 = p_temp;
}
else
p1 = p;
if (p1 == p) /* No register number present here. */
{
- p1 = (unsigned char *) strchr (p, ':');
+ p1 = strchr (p, ':');
if (p1 == NULL)
error (_("Malformed packet(a) (missing colon): %s\n\
Packet: '%s'\n"),
{
p_temp = unpack_varlen_hex (++p1, &thread_num);
record_currthread (thread_num);
- p = (unsigned char *) p_temp;
+ p = p_temp;
}
else if ((strncmp (p, "watch", p1 - p) == 0)
|| (strncmp (p, "rwatch", p1 - p) == 0)
else
{
/* Silently skip unknown optional info. */
- p_temp = (unsigned char *) strchr (p1 + 1, ';');
+ p_temp = strchr (p1 + 1, ';');
if (p_temp)
p = p_temp;
}
Packet: '%s'\n"),
pnum, p, buf);
- fieldsize = hex2bin (p, regs,
+ fieldsize = hex2bin (p, regs,
register_size (current_gdbarch,
reg->regnum));
p += 2 * fieldsize;
}
sprintf (buf, "g");
- remote_send (buf, (rs->remote_packet_size));
+ remote_send (buf, rs->remote_packet_size);
/* Save the size of the packet sent to us by the target. Its used
as a heuristic when determining the max size of packets that the
if (remote_debug)
fprintf_unfiltered (gdb_stdlog,
"Bad register packet; fetching a new packet\n");
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
}
/* Reply describes registers byte by byte, each byte encoded as two
{
struct remote_state *rs = get_remote_state ();
int i;
- char buf[MAX_REGISTER_SIZE];
+ gdb_byte buf[MAX_REGISTER_SIZE];
/* Make sure the entire registers array is valid. */
switch (remote_protocol_P.support)
struct packet_reg *reg = packet_reg_from_regnum (rs, regnum);
/* Try storing a single register. */
char *buf = alloca (rs->remote_packet_size);
- char regp[MAX_REGISTER_SIZE];
+ gdb_byte regp[MAX_REGISTER_SIZE];
char *p;
- sprintf (buf, "P%s=", phex_nz (reg->pnum, 0));
+ xsnprintf (buf, rs->remote_packet_size, "P%s=", phex_nz (reg->pnum, 0));
p = buf + strlen (buf);
regcache_raw_collect (current_regcache, reg->regnum, regp);
bin2hex (regp, p, register_size (current_gdbarch, reg->regnum));
{
struct remote_state *rs = get_remote_state ();
char *buf;
- char *regs;
+ gdb_byte *regs;
char *p;
set_thread (PIDGET (inferior_ptid), 1);
*p++ = 'G';
/* remote_prepare_to_store insures that register_bytes_found gets set. */
bin2hex (regs, p, register_bytes_found);
- remote_send (buf, (rs->remote_packet_size));
+ remote_send (buf, rs->remote_packet_size);
}
\f
check_binary_download (CORE_ADDR addr)
{
struct remote_state *rs = get_remote_state ();
+
switch (remote_protocol_binary_download.support)
{
case PACKET_DISABLE:
*p = '\0';
putpkt_binary (buf, (int) (p - buf));
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
if (buf[0] == '\0')
{
error. Only transfer a single packet. */
int
-remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
+remote_write_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
{
- unsigned char *buf;
- unsigned char *p;
- unsigned char *plen;
+ char *buf;
+ char *p;
+ char *plen;
long sizeof_buf;
int plenlen;
int todo;
int nr_bytes;
int payload_size;
- unsigned char *payload_start;
+ char *payload_start;
/* Verify that the target can support a binary download. */
check_binary_download (memaddr);
handling partial reads. */
int
-remote_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
+remote_read_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
{
char *buf;
int max_buf_size; /* Max size of packet output buffer. */
read; 0 for error. TARGET is unused. */
static int
-remote_xfer_memory (CORE_ADDR mem_addr, char *buffer, int mem_len,
+remote_xfer_memory (CORE_ADDR mem_addr, gdb_byte *buffer, int mem_len,
int should_write, struct mem_attrib *attrib,
struct target_ops *target)
{
/* Send a packet to the remote machine, with error checking. The data
of the packet is in BUF. The string in BUF can be at most
- (rs->remote_packet_size) - 5 to account for the $, # and checksum,
+ RS->remote_packet_size - 5 to account for the $, # and checksum,
and for a possible /0 if we are debugging (remote_debug) and want
to print the sent packet as a string. */
int i;
unsigned char csum = 0;
char *buf2 = alloca (cnt + 6);
- long sizeof_junkbuf = (rs->remote_packet_size);
+ long sizeof_junkbuf = rs->remote_packet_size;
char *junkbuf = alloca (sizeof_junkbuf);
int ch;
of bytes returned by BREAKPOINT_FROM_PC. */
static int
-remote_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
+remote_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
{
struct remote_state *rs = get_remote_state ();
#ifdef DEPRECATED_REMOTE_BREAKPOINT
sprintf (p, ",%d", bp_size);
putpkt (buf);
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_SOFTWARE_BP]))
{
}
static int
-remote_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+remote_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
{
struct remote_state *rs = get_remote_state ();
int bp_size;
sprintf (p, ",%d", bp_size);
putpkt (buf);
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
return (buf[0] == 'E');
}
sprintf (p, ",%x", len);
putpkt (buf);
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
switch (packet_ok (buf, &remote_protocol_Z[packet]))
{
p += hexnumstr (p, (ULONGEST) addr);
sprintf (p, ",%x", len);
putpkt (buf);
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
switch (packet_ok (buf, &remote_protocol_Z[packet]))
{
static int
-remote_insert_hw_breakpoint (CORE_ADDR addr, char *shadow)
+remote_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
{
int len = 0;
struct remote_state *rs = get_remote_state ();
sprintf (p, ",%x", len);
putpkt (buf);
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_HARDWARE_BP]))
{
static int
-remote_remove_hw_breakpoint (CORE_ADDR addr, char *shadow)
+remote_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
{
int len;
struct remote_state *rs = get_remote_state ();
sprintf (p, ",%x", len);
putpkt(buf);
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_HARDWARE_BP]))
{
matched = 1; /* do this section */
lma = s->lma;
/* FIXME: assumes lma can fit into long. */
- sprintf (buf, "qCRC:%lx,%lx", (long) lma, (long) size);
+ xsnprintf (buf, rs->remote_packet_size, "qCRC:%lx,%lx",
+ (long) lma, (long) size);
putpkt (buf);
/* Be clever; compute the host_crc before waiting for target
bfd_get_section_contents (exec_bfd, s, sectdata, 0, size);
host_crc = crc32 ((unsigned char *) sectdata, size, 0xffffffff);
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
if (buf[0] == 'E')
error (_("target memory fault, section %s, range 0x%s -- 0x%s"),
sectname, paddr (lma), paddr (lma + size));
static LONGEST
remote_xfer_partial (struct target_ops *ops, enum target_object object,
- const char *annex, void *readbuf, const void *writebuf,
- ULONGEST offset, LONGEST len)
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
struct remote_state *rs = get_remote_state ();
int i;
buffer size. */
if (offset == 0 && len == 0)
return (rs->remote_packet_size);
- /* Minimum outbuf size is (rs->remote_packet_size) - if bufsiz is
- not large enough let the caller. */
- if (len < (rs->remote_packet_size))
+ /* Minimum outbuf size is RS->remote_packet_size. If LEN is not
+ large enough let the caller deal with it. */
+ if (len < rs->remote_packet_size)
return -1;
len = rs->remote_packet_size;
(remote_debug), we have PBUFZIZ - 7 left to pack the query
string. */
i = 0;
- while (annex[i] && (i < ((rs->remote_packet_size) - 8)))
+ while (annex[i] && (i < (rs->remote_packet_size - 8)))
{
/* Bad caller may have sent forbidden characters. */
gdb_assert (isprint (annex[i]) && annex[i] != '$' && annex[i] != '#');
if (i < 0)
return i;
- getpkt (readbuf, len, 0);
+ getpkt ((char *) readbuf, len, 0);
- return strlen (readbuf);
+ return strlen ((char *) readbuf);
}
static void
strcpy (buf, "qRcmd,");
p = strchr (buf, '\0');
- if ((strlen (buf) + strlen (command) * 2 + 8/*misc*/) > (rs->remote_packet_size))
+ if ((strlen (buf) + strlen (command) * 2 + 8/*misc*/) > rs->remote_packet_size)
error (_("\"monitor\" command ``%s'' is too long."), command);
/* Encode the actual command. */
- bin2hex (command, p, 0);
+ bin2hex ((gdb_byte *) command, p, 0);
if (putpkt (buf) < 0)
error (_("Communication problem with target."));
{
/* XXX - see also tracepoint.c:remote_get_noisy_reply(). */
buf[0] = '\0';
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
if (buf[0] == '\0')
error (_("Target does not support this command."));
if (buf[0] == 'O' && buf[1] != 'K')
puts_filtered ("\n");
putpkt (args);
- getpkt (buf, (rs->remote_packet_size), 0);
+ getpkt (buf, rs->remote_packet_size, 0);
puts_filtered ("received: ");
print_packet (buf);
puts_filtered ("\n");
remote_pid_to_str (ptid_t ptid)
{
static char buf[32];
- int size;
- size = snprintf (buf, sizeof buf, "thread %d", ptid_get_pid (ptid));
- gdb_assert (size < sizeof buf);
+ xsnprintf (buf, sizeof buf, "thread %d", ptid_get_pid (ptid));
return buf;
}
return result;
}
else if (result == PACKET_UNKNOWN)
- {
- struct gdb_exception e
- = { RETURN_ERROR, TLS_GENERIC_ERROR,
- "Remote target doesn't support qGetTLSAddr packet" };
- throw_exception (e);
- }
+ throw_error (TLS_GENERIC_ERROR,
+ _("Remote target doesn't support qGetTLSAddr packet"));
else
- {
- struct gdb_exception e
- = { RETURN_ERROR, TLS_GENERIC_ERROR,
- "Remote target failed to process qGetTLSAddr request" };
- throw_exception (e);
-
- }
+ throw_error (TLS_GENERIC_ERROR,
+ _("Remote target failed to process qGetTLSAddr request"));
}
else
- {
- struct gdb_exception e
- = { RETURN_ERROR, TLS_GENERIC_ERROR,
- "TLS not supported or disabled on this target" };
- throw_exception (e);
- }
+ throw_error (TLS_GENERIC_ERROR,
+ _("TLS not supported or disabled on this target"));
/* Not reached. */
return 0;
}