aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2004-01-18 03:37:03 +0000
committerDaniel Jacobowitz <drow@false.org>2004-01-18 03:37:03 +0000
commit2963ee1d7c76b0ce775d0037557cd82f8aae827c (patch)
tree71abdb09fe78066cc84503ef9cd5d7ce6aca99c4
parentb0cecf36fdb8ca470bf1e14be2ffc8b7b175d476 (diff)
downloadgdb-2963ee1d7c76b0ce775d0037557cd82f8aae827c.zip
gdb-2963ee1d7c76b0ce775d0037557cd82f8aae827c.tar.gz
gdb-2963ee1d7c76b0ce775d0037557cd82f8aae827c.tar.bz2
* remote.c (remote_vcont_resume): Use xstrprintf instead of sprintf.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/remote.c33
2 files changed, 23 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0404da0..52870f3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2004-01-17 Daniel Jacobowitz <drow@mvista.com>
+
+ * remote.c (remote_vcont_resume): Use xstrprintf instead of sprintf.
+
2004-01-17 Andrew Cagney <cagney@redhat.com>
* mdebugread.c: Update copyright.
diff --git a/gdb/remote.c b/gdb/remote.c
index 1ed3680..453074f 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2583,7 +2583,7 @@ remote_vcont_resume (ptid_t ptid, int step, enum target_signal siggnal)
{
struct remote_state *rs = get_remote_state ();
int pid = PIDGET (ptid);
- char *buf = NULL;
+ char *buf = NULL, *outbuf;
struct cleanup *old_cleanup;
buf = xmalloc (rs->remote_packet_size);
@@ -2608,40 +2608,45 @@ remote_vcont_resume (ptid_t ptid, int step, enum target_signal siggnal)
don't have any PID numbers the inferior will understand. Make sure
to only send forms that do not specify a PID. */
if (step && siggnal != TARGET_SIGNAL_0)
- sprintf (buf, "vCont;S%02x", siggnal);
+ outbuf = xstrprintf ("vCont;S%02x", siggnal);
else if (step)
- sprintf (buf, "vCont;s");
+ outbuf = xstrprintf ("vCont;s");
else if (siggnal != TARGET_SIGNAL_0)
- sprintf (buf, "vCont;C%02x", siggnal);
+ outbuf = xstrprintf ("vCont;C%02x", siggnal);
else
- sprintf (buf, "vCont;c");
+ outbuf = xstrprintf ("vCont;c");
}
else if (pid == -1)
{
/* Resume all threads, with preference for INFERIOR_PTID. */
if (step && siggnal != TARGET_SIGNAL_0)
- sprintf (buf, "vCont;S%02x:%x;c", siggnal, PIDGET (inferior_ptid));
+ outbuf = xstrprintf ("vCont;S%02x:%x;c", siggnal,
+ PIDGET (inferior_ptid));
else if (step)
- sprintf (buf, "vCont;s:%x;c", PIDGET (inferior_ptid));
+ outbuf = xstrprintf ("vCont;s:%x;c", PIDGET (inferior_ptid));
else if (siggnal != TARGET_SIGNAL_0)
- sprintf (buf, "vCont;C%02x:%x;c", siggnal, PIDGET (inferior_ptid));
+ outbuf = xstrprintf ("vCont;C%02x:%x;c", siggnal,
+ PIDGET (inferior_ptid));
else
- sprintf (buf, "vCont;c");
+ outbuf = xstrprintf ("vCont;c");
}
else
{
/* Scheduler locking; resume only PTID. */
if (step && siggnal != TARGET_SIGNAL_0)
- sprintf (buf, "vCont;S%02x:%x", siggnal, pid);
+ outbuf = xstrprintf ("vCont;S%02x:%x", siggnal, pid);
else if (step)
- sprintf (buf, "vCont;s:%x", pid);
+ outbuf = xstrprintf ("vCont;s:%x", pid);
else if (siggnal != TARGET_SIGNAL_0)
- sprintf (buf, "vCont;C%02x:%x", siggnal, pid);
+ outbuf = xstrprintf ("vCont;C%02x:%x", siggnal, pid);
else
- sprintf (buf, "vCont;c:%x", pid);
+ outbuf = xstrprintf ("vCont;c:%x", pid);
}
- putpkt (buf);
+ gdb_assert (outbuf && strlen (outbuf) < rs->remote_packet_size);
+ make_cleanup (xfree, outbuf);
+
+ putpkt (outbuf);
do_cleanups (old_cleanup);