From: Sergio Durigan Junior Date: Mon, 29 Dec 2014 19:22:20 +0000 (-0500) Subject: Sanitize input_interrupt output X-Git-Tag: gdb-7.9.0-release~204 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fafcc06ab29fe98d2767234dc77062d08ea0d3c7;p=external%2Fbinutils.git Sanitize input_interrupt output Hi, This patch is a follow-up of the following discussions: input_interrupt is currently emiting non-printable characters, which is confusing the dg-extract-results.sh script. This is obviously not a good thing, and, by following Pedro's advices here: I adapted the function to print "client connection closed" when it receives a NUL character, or use the "isprint" function to decide how to print the received char. I tested it by running the testcases that were printing the non-printable chars before: gdb.base/gdb-sigterm.exp gdb.threads/non-ldr-exc-1.exp gdb.threads/non-ldr-exc-2.exp gdb.threads/non-ldr-exc-3.exp gdb.threads/non-ldr-exc-4.exp gdb.threads/thread-execl.exp and confirming that they print the right message. I tried a bit to come up with a testcase for this, but failed, and since I did not want to spend too much time on it, I'm sending the patch anyway. Comments are welcome, as usual. gdb/gdbserver/ChangeLog: 2014-12-29 Sergio Durigan Junior * remote-utils.c: Include ctype.h. (input_interrupt): Explicitly handle the case when the char received is the NUL byte. Improve the printing of non-ASCII characters. --- diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index a95bce5..9414417 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,10 @@ +2014-12-29 Sergio Durigan Junior + + * remote-utils.c: Include ctype.h. + (input_interrupt): Explicitly handle the case when the char + received is the NUL byte. Improve the printing of non-ASCII + characters. + 2014-12-16 Joel Brobecker * linux-low.c (linux_low_filter_event): Update call to diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index 373fc15..bc54518 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -23,6 +23,7 @@ #include "tdesc.h" #include "dll.h" #include "rsp-low.h" +#include #if HAVE_SYS_IOCTL_H #include #endif @@ -741,10 +742,18 @@ input_interrupt (int unused) cc = read_prim (&c, 1); - if (cc != 1 || c != '\003' || current_thread == NULL) + if (cc == 0) { - fprintf (stderr, "input_interrupt, count = %d c = %d ('%c')\n", - cc, c, c); + fprintf (stderr, "client connection closed\n"); + return; + } + else if (cc != 1 || c != '\003' || current_thread == NULL) + { + fprintf (stderr, "input_interrupt, count = %d c = %d ", cc, c); + if (isprint (c)) + fprintf (stderr, "('%c')\n", c); + else + fprintf (stderr, "('\\x%02x')\n", c & 0xff); return; }