diff options
author | Pedro Alves <palves@redhat.com> | 2008-11-19 14:45:09 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2008-11-19 14:45:09 +0000 |
commit | 6e5abd65ae1e883e278d29249784d3bb225c6912 (patch) | |
tree | 3d2ab38cbce3d9f84b33a01a4811bf9b0e205449 /gdb/utils.c | |
parent | c91e322a293ce2af9687b5926bb45b1de83e4b13 (diff) | |
download | gdb-6e5abd65ae1e883e278d29249784d3bb225c6912.zip gdb-6e5abd65ae1e883e278d29249784d3bb225c6912.tar.gz gdb-6e5abd65ae1e883e278d29249784d3bb225c6912.tar.bz2 |
* remote.c (escape_buffer): New.
(putpkt_binary, read_frame, getpkt_or_notif_sane_1): Use it. Make
sure debug output printing a packet buffer goes through a single
fprintf_unfiltered call.
* utils.c (vfprintf_unfiltered): If outputting timestamps, end
output with a newline if it wasn't going to already.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index fed2e7e..d14009f 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2286,13 +2286,22 @@ vfprintf_unfiltered (struct ui_file *stream, const char *format, va_list args) { struct timeval tm; char *timestamp; + int len, need_nl; gettimeofday (&tm, NULL); - timestamp = xstrprintf ("%ld:%ld ", (long) tm.tv_sec, (long) tm.tv_usec); + + len = strlen (linebuffer); + need_nl = (len > 0 && linebuffer[len - 1] != '\n'); + + timestamp = xstrprintf ("%ld:%ld %s%s", + (long) tm.tv_sec, (long) tm.tv_usec, + linebuffer, + need_nl ? "\n": ""); make_cleanup (xfree, timestamp); fputs_unfiltered (timestamp, stream); } - fputs_unfiltered (linebuffer, stream); + else + fputs_unfiltered (linebuffer, stream); do_cleanups (old_cleanups); } |