From patchwork Mon May 5 09:26:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 801 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 4EA53360076 for ; Mon, 5 May 2014 02:29:44 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id 02F6663827644; Mon, 5 May 2014 02:29:42 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id C36FF63827646 for ; Mon, 5 May 2014 02:29:42 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=yXCSLAWMgncyZkOq91CeaVMEYg1x5 ErCs0Fcf6cOhGoaLwuMVkBLC5I9128TXOGctn1DWSV+hRxmGX3rm+Ccq2A+Natqa ETHk1tf1HIcrAzAoB/dhNukifD9tkPNE6Bzb1r9x1h8zCC8P9MNEtqc4tqZFVi+y jn3qI6DRcLXpEk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=M8FW7pHPAN4K+ZRKVhsGRNOqCeU=; b=GH5 wX132D2LG6h0ZabiiZtV8cierIln+x/77FG0K/odLmYk7MSFRWf/Ry7PnMcxn5Nm e8Ojs17LYPCHWR4RgmOdzEOzc8y+Hn/OQoUAs12Uq8j9mwDX2Y2wAAIf2Egtac/p BIBw5F0/bKL8ZGo81IiYtWZyAc5rS3Qy96clWJGk= Received: (qmail 11360 invoked by alias); 5 May 2014 09:29:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 11349 invoked by uid 89); 5 May 2014 09:29:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 May 2014 09:29:38 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1WhFDK-0006Z2-T7 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Mon, 05 May 2014 02:29:34 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 5 May 2014 02:29:34 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.2.247.3; Mon, 5 May 2014 02:27:47 -0700 From: Yao Qi To: Subject: [PATCH] Fix display of tabulation character for mingw hosts. Date: Mon, 5 May 2014 17:26:58 +0800 Message-ID: <1399282018-8921-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Pierre proposed this patch https://sourceware.org/ml/gdb-patches/2013-10/msg00011.html and Tom gave a suggestion that it's better to do check \t in print_wchar However, I don't see the follow-up to this discussion. We encounter two fails in printcmds.exp on mingw host, and Pierre's patch fixes them. I pick it up, update a little per Tom's comments, and post it here for review. This patch fixes these fails below on mingw32 host. FAIL: gdb.base/charset.exp: print string in ASCII FAIL: gdb.base/charset.exp: try printing '\t' in ASCII FAIL: gdb.base/charset.exp: print string in ISO-8859-1 FAIL: gdb.base/charset.exp: try printing '\t' in ISO-8859-1 FAIL: gdb.base/charset.exp: print string in UTF-32 FAIL: gdb.base/charset.exp: try printing '\t' in UTF-32 FAIL: gdb.base/printcmds.exp: p ctable1[9] FAIL: gdb.base/printcmds.exp: p &ctable1[1*8] Also regression tested on x86_64-linux. Is it OK? gdb: 2014-05-05 Pierre Muller Yao Qi * valprint.c (print_wchar): Move the code on checking whether W is a printable wide char to the default branch of switch statement below. Call wchar_printable instead of gdb_iswprint. --- gdb/valprint.c | 122 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 63 insertions(+), 59 deletions(-) diff --git a/gdb/valprint.c b/gdb/valprint.c index fe23530..f55b5db 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1949,73 +1949,77 @@ print_wchar (gdb_wint_t w, const gdb_byte *orig, int need_escape = *need_escapep; *need_escapep = 0; - if (gdb_iswprint (w) && (!need_escape || (!gdb_iswdigit (w) - && w != LCST ('8') - && w != LCST ('9')))) - { - gdb_wchar_t wchar = w; - if (w == gdb_btowc (quoter) || w == LCST ('\\')) - obstack_grow_wstr (output, LCST ("\\")); - obstack_grow (output, &wchar, sizeof (gdb_wchar_t)); - } - else + /* iswprint implementation on Windows returns 1 for tab character. + In order to avoid different printout on this host, we explicitly + use wchar_printable function. */ + switch (w) { - switch (w) + case LCST ('\a'): + obstack_grow_wstr (output, LCST ("\\a")); + break; + case LCST ('\b'): + obstack_grow_wstr (output, LCST ("\\b")); + break; + case LCST ('\f'): + obstack_grow_wstr (output, LCST ("\\f")); + break; + case LCST ('\n'): + obstack_grow_wstr (output, LCST ("\\n")); + break; + case LCST ('\r'): + obstack_grow_wstr (output, LCST ("\\r")); + break; + case LCST ('\t'): + obstack_grow_wstr (output, LCST ("\\t")); + break; + case LCST ('\v'): + obstack_grow_wstr (output, LCST ("\\v")); + break; + default: { - case LCST ('\a'): - obstack_grow_wstr (output, LCST ("\\a")); - break; - case LCST ('\b'): - obstack_grow_wstr (output, LCST ("\\b")); - break; - case LCST ('\f'): - obstack_grow_wstr (output, LCST ("\\f")); - break; - case LCST ('\n'): - obstack_grow_wstr (output, LCST ("\\n")); - break; - case LCST ('\r'): - obstack_grow_wstr (output, LCST ("\\r")); - break; - case LCST ('\t'): - obstack_grow_wstr (output, LCST ("\\t")); - break; - case LCST ('\v'): - obstack_grow_wstr (output, LCST ("\\v")); - break; - default: - { - int i; + if (wchar_printable (w) && (!need_escape || (!gdb_iswdigit (w) + && w != LCST ('8') + && w != LCST ('9')))) + { + gdb_wchar_t wchar = w; - for (i = 0; i + width <= orig_len; i += width) - { - char octal[30]; - ULONGEST value; + if (w == gdb_btowc (quoter) || w == LCST ('\\')) + obstack_grow_wstr (output, LCST ("\\")); + obstack_grow (output, &wchar, sizeof (gdb_wchar_t)); + } + else + { + int i; + + for (i = 0; i + width <= orig_len; i += width) + { + char octal[30]; + ULONGEST value; - value = extract_unsigned_integer (&orig[i], width, + value = extract_unsigned_integer (&orig[i], width, byte_order); - /* If the value fits in 3 octal digits, print it that - way. Otherwise, print it as a hex escape. */ - if (value <= 0777) - xsnprintf (octal, sizeof (octal), "\\%.3o", - (int) (value & 0777)); - else - xsnprintf (octal, sizeof (octal), "\\x%lx", (long) value); - append_string_as_wide (octal, output); - } - /* If we somehow have extra bytes, print them now. */ - while (i < orig_len) - { - char octal[5]; + /* If the value fits in 3 octal digits, print it that + way. Otherwise, print it as a hex escape. */ + if (value <= 0777) + xsnprintf (octal, sizeof (octal), "\\%.3o", + (int) (value & 0777)); + else + xsnprintf (octal, sizeof (octal), "\\x%lx", (long) value); + append_string_as_wide (octal, output); + } + /* If we somehow have extra bytes, print them now. */ + while (i < orig_len) + { + char octal[5]; - xsnprintf (octal, sizeof (octal), "\\%.3o", orig[i] & 0xff); - append_string_as_wide (octal, output); - ++i; - } + xsnprintf (octal, sizeof (octal), "\\%.3o", orig[i] & 0xff); + append_string_as_wide (octal, output); + ++i; + } - *need_escapep = 1; - } + *need_escapep = 1; + } break; } }