From patchwork Thu Dec 8 13:37:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 87261 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp848114qgi; Thu, 8 Dec 2016 05:38:21 -0800 (PST) X-Received: by 10.84.173.195 with SMTP id p61mr158729085plb.158.1481204301781; Thu, 08 Dec 2016 05:38:21 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y4si28794918pgo.299.2016.12.08.05.38.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Dec 2016 05:38:21 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443783-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-443783-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443783-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=LMaAs+DMT3GqwZYYCUqIVWhwx3v+GRUqI0y4x03PUnF8Q5bWo0 EGODdQ0JVUpKcf+C0EITiO7gW7zXTcU/AnEsqUxyn3o+0qM4DkUT9ztKfetWT9o7 S94sHF6Kr3SimPBSHg+HC//O41NkmV/OhxbHJH/kn9yxZds9cH1TtEcjU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=gmdf5lN8TcpSo+SVdWVeAmLwhTU=; b=t5zONEAJ59+HW3VVq/wO ZefzbQRfEB+nCbn280rGj7IU9Q/xCvUAwWq9WYQ4Kn+iuqaSWvYuPE7Qvrd9eEVp 9pNOzx/KgU5QJDnOLvdE2z30byfZ772FKp/YF0aSAMLSlaLGFN5DepohLUM5+ZOw OEr7dJemKz4c/UpS1dtIIPA= Received: (qmail 96722 invoked by alias); 8 Dec 2016 13:38:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 96704 invoked by uid 89); 8 Dec 2016 13:38:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1345, Python X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Dec 2016 13:37:55 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B8566ACC1 for ; Thu, 8 Dec 2016 13:37:52 +0000 (UTC) To: GCC Patches From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] Escape non-printable chars in dumped strings. Message-ID: <5e9b02e8-9bf7-5429-fda7-2b6efbcbef0a@suse.cz> Date: Thu, 8 Dec 2016 14:37:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-IsSubscribed: yes 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 Date: Thu, 8 Dec 2016 11:22:44 +0100 Subject: [PATCH] Escape non-printable chars in strings. gcc/ChangeLog: 2016-12-08 Martin Liska * 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