summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2004-01-18 03:37:03 +0000
committerDaniel Jacobowitz <dan@debian.org>2004-01-18 03:37:03 +0000
commit3a07515f50f408d02bf8dd7f83cdca07944db58a (patch)
tree32c4c81182cdac475fd789acef4f9e400b7d48c0
parent0e0d5050b6b53ccebfb4f88e1ce651d11a9a6112 (diff)
downloadgdb-3a07515f50f408d02bf8dd7f83cdca07944db58a.tar.gz
* 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 0404da023d1..52870f3609a 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 1ed3680c707..453074f8945 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);