From patchwork Wed Jun 19 17:04:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Weghorn X-Patchwork-Id: 1118899 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-503289-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=posteo.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="x/PDyouh"; dkim=pass (2048-bit key; secure) header.d=posteo.de header.i=@posteo.de header.b="BHZQYQ45"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 45TWXy4SBkz9s5c for ; Thu, 20 Jun 2019 03:05:14 +1000 (AEST) 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=sik33jgmTehR9qnzs33FYhCvHKGqR5Hwos6ZCVo4KcPb26zPMj IGK9kFhhG15oTxVWaaDPDXYPBjXn4DBqwtmbyyqDIIRd4qeDaG6m+b5dQejAqEHw ya/GWW0DiEycWXT25FrVie6hRafc1UKMD71XqxFC96vKrk1YRJoEpd4vs= 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=dO+kHRVBx6BxcrEPL18HhJQq9bw=; b=x/PDyouh1VHZzEZoG9oo kgqpqdQ5D0YjCUxzkmdFdWTjrTLivyZau5OLWCvFsvLlvOI4Elt9Ci5sPuPPCOFb +dBG0dQoAW4g2GHUMRfZwQJVLVeYNC6L18JRgreszHsXEOIy9NAha1SkmOkvlqhx LslT/5kw4HuEzHnZUgDY2TE= Received: (qmail 55523 invoked by alias); 19 Jun 2019 17:05: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 55490 invoked by uid 89); 19 Jun 2019 17:05:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_PASS autolearn=unavailable version=3.3.1 spammy=H*MI:2001, H*M:2001 X-HELO: mout01.posteo.de Received: from mout01.posteo.de (HELO mout01.posteo.de) (185.67.36.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Jun 2019 17:05:03 +0000 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 471B816005F for ; Wed, 19 Jun 2019 19:05:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1560963901; bh=YxOlIfNGWXTUcDQDML/8g+Ct9M53Mvsgdl+NrAlLc1w=; h=To:From:Subject:Date:From; b=BHZQYQ45bWn8Q7/sBFgyPtTCsrbsJimqtFVnFn+bg+fdggb1eXt+d2fnEVjRps8SK +M7Xhppf1CXQJqpd0TB6cV8M2xrRScBjwunf/kipPusZfZfOkZPmNMN99gTNDtbV67 aSOpWfyeWKkBi0UoCpQE3E9wWTFKYIOOKgKHOWgB2ppKGa5DUznRb4MTW6aawDN1+S Ov/Ut97W7nkt5MSns0JtiZLjDyUNu1KAArolGXhhZ7/9A6oIVlQzPRdecS4IbgRyLf Yp7PoAny14++l+zwCF9XsgDOL5emTvJncLxMVQGTJN3ZIYqLaCJdh2utCbSL/o0Z7/ jfYA3tR+e1YMQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 45TWXX3kQqz6tmG; Wed, 19 Jun 2019 19:04:58 +0200 (CEST) To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org From: Michael Weghorn Subject: PR libstdc++/90945 Patch to have pretty printer for std::vector return bool intead of int for elements Message-ID: <97d0c4da-2001-af3d-b220-079ac85a46fa@posteo.de> Date: Wed, 19 Jun 2019 19:04:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi everyone, the Python pretty printer for a 'std::vector' currently returns integers as values for the elements, which e.g. leads to the situation that a 'gdb.Value' constructed from that doesn't have 'bool' type, but an integer type ('long long' for my test with gdb 8.2.1 on Debian testing, amd64). Returning bool values ('True'/'False') would make sure that the type is clear and can thus help improve the displayed type. More details in [1]. The attached patch changes the behaviour of the pretty printer accordingly. I'd be glad to receive feedback on this and also notes in case anything else is needed. (This is my first contribution.) So far, I've tested this with GDB 8.2.1 on Debian testing. ChangeLog: * PR libstdc++/90945: Have pretty printer return bool instead of int for value of std::vector elements Regards, Michael [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90945 From c62cbd47ea8602e2351ff3b0c4c80fa8cb71e313 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Wed, 19 Jun 2019 17:22:16 +0200 Subject: [PATCH] Have std::vector printer's iterator return bool Have the pretty-printer for 'std::vector' return a value of type 'bool' rather than an 'int'. This way, the type is clear and that can be used for better display and a 'gdb.Value' constructed from the returned value will have type 'bool' again, not e.g. 'long long' as happened previously (at least with GDB 8.2.1 on amd64). diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 05143153bee..177db3c0fdb 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -363,15 +363,12 @@ class StdVectorPrinter: if self.item == self.finish and self.so >= self.fo: raise StopIteration elt = self.item.dereference() - if elt & (1 << self.so): - obit = 1 - else: - obit = 0 + val = elt & (1 << self.so) != 0 self.so = self.so + 1 if self.so >= self.isize: self.item = self.item + 1 self.so = 0 - return ('[%d]' % count, obit) + return ('[%d]' % count, val) else: if self.item == self.finish: raise StopIteration -- 2.20.1