Hello. Following patch changes behavior in pretty_print_string, where all non-printable characters are encoded as \x%x. Currently, when some non-printable characters are directly printed to a dump file stream. That makes it complicated to read a dump file for instance via a Python script.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Ready to be installed? Martin
>From 0241ee4a366d3c4912def45770945b17c528f920 Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Thu, 8 Dec 2016 11:22:44 +0100 Subject: [PATCH] Escape non-printable chars in strings. gcc/ChangeLog: 2016-12-08 Martin Liska <mli...@suse.cz> * tree-pretty-print.c (pretty_print_string): Escape non-printable chars in strings. --- gcc/tree-pretty-print.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 95db710..5b3e23e 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -3869,7 +3869,14 @@ pretty_print_string (pretty_printer *pp, const char *str) break; default: - pp_character (pp, str[0]); + if (!ISPRINT (str[0])) + { + char buf[5]; + sprintf (buf, "\\x%x", (unsigned char)str[0]); + pp_string (pp, buf); + } + else + pp_character (pp, str[0]); break; } str++; -- 2.10.2