From patchwork Thu Sep 28 17:46:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 146236 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3490453vqu; Thu, 28 Sep 2023 10:48:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEuTNoldqY19EtrmwaX7qb730JQT4i8af/HlgSkcPZP0iKENQ4lZFYTUg+9rFOCqfm1UqWf X-Received: by 2002:a17:906:32d0:b0:9b2:7148:dd59 with SMTP id k16-20020a17090632d000b009b27148dd59mr1429427ejk.37.1695923312687; Thu, 28 Sep 2023 10:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695923312; cv=none; d=google.com; s=arc-20160816; b=bY0eobDxT3TdRsJQUcZbx4rNNc/6LF5LjbWKM5riBg1+KgGAPDJ3X4pK7IVUUhBOrA LO+RWJ62iRblQSuhqzoIuLwg+N9O9JoxeZBIxjkm8VxuqMJlAVdIGl5Gp16litXORbRo XdzS1t33BPuhlo4nSwytY5NsWRh4hbLfacFk79+phJtQxOtRkScBMVF/2Gc5F8wOMgcJ nmrlf30mpyd+vzMTF8UAjlsHlNfiabQiROTcKqTq2BL5ijbaVAC/mWL+PsZSzGZr+jJ3 KHdLCaERyEj2HSzpUDKdO6ieT0nQY35hDkDYwU7ZQXUvkj1WWafM5PqKI8qbxdIObCBw l/HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=Wkx5TAFMXgHmrNT4Ym/GBEV6jN5nNGT4eiyT0cvi1pA=; fh=Ogh3zaPUNpdNYHofIVNHsbX+D3lwaT1T8Jhe/MolwAA=; b=VJkebzcoLe4iuHjspts9/Lp7kTVlupK7VhQKSSh1tqaVaa0nsXY4/BoLR5Kn0rCode TQv/F+yEw6qQdoNWSYHo76unu8712SSPokYI/FtAFHmr55xdQ/qf8+m5WgJJ9r9KZp65 eITWJkG6r/JY0zROYa07ffymHk/+JZEewjWW51TrDr13nCzXtbJUY2AxEd9puvDSjq4W 4+INE/VDy4RlyyZjgxTQnS/4V4tA5aLs9pJGwRMA9ZDOqB9bzwOPwH0ZusEiSlweSsHL oF2oBPYgGugGl6x0OPegSqELuEI9nvd6T08EkAxOmqv5LUWrvpqk4y9KEbNGG51h9DPp CS5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b="VF/YIHJV"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h11-20020a170906590b00b009ae4f7c9743si15975593ejq.980.2023.09.28.10.48.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:48:32 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b="VF/YIHJV"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A81633882AC7 for ; Thu, 28 Sep 2023 17:47:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id 5C6373858402 for ; Thu, 28 Sep 2023 17:46:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C6373858402 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-350fbd09d8bso42986655ab.0 for ; Thu, 28 Sep 2023 10:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1695923201; x=1696528001; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wkx5TAFMXgHmrNT4Ym/GBEV6jN5nNGT4eiyT0cvi1pA=; b=VF/YIHJVdHW+9L/66GBsLlMio3uxzSHrN+QDAJ4+xeTlAzJ6UffMa2IBYcz2y2+8YM HT7+193UmDCwPitZgDosz9t9r0H4RBw+d4rrVtb4LV5XZSPqgYg0ypJ2vHyP7MjD8TJF cunvENbXYdSWc8pWh5nAVDJTh5rTXpG0v3r6PGBgsGDi7u8I1TYmAk9wlkys0VUpaP34 tjcLbsMc8z8l16rE8FLAL6zKnIquaCM6C+M09XN6fcCECvYonURSi1HqVmdomovxh3gE syMsVLElJ3MCRPYohODh2Egs18dfn8gNOQdm4ltvb8talTDENE97pyYHT44a5W9OVbzc kZRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695923201; x=1696528001; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wkx5TAFMXgHmrNT4Ym/GBEV6jN5nNGT4eiyT0cvi1pA=; b=pO/3izlYQHQS40fI0M42Qil9MnifmV16kC6UVbJSh+kEJ6O16GG+zNj4Lr21vFm4Gr iDorN5iatUo6Vd1S6CpNzUkZoQUn5/QD4pMdpP+cZbpdkDtk/CsK1jKA8CujjGsXNt+g SYp2RhpOLU5YLaoBEM+2doJB+O+wK27pwNRMW/qSUqP9nrRIIC4H5pSWTK9p1Rmy+Z3Z 97v+D2JQNkNKUGUUEIKfvmWKhSAJLACT2qmddMnzJTVf8tVmkWRL4Z1EREciuVdeKMq6 /T8pfNGIlRGMx3DAacDWS8zVUei3c+IAcHQQty9HbHkpdOUocJqVnl/3vu9CBJc/DOL2 n/nw== X-Gm-Message-State: AOJu0YxBrw+8jUvro3CnrTfXvnub+VXJ+xkrn0NO6OSJ+/IZ0j8w9BMl VrDK6EJvaQdxQDdPCa08ze3Fw5pMB18XHg6raZ94jw== X-Received: by 2002:a05:6e02:1112:b0:351:80c:bc29 with SMTP id u18-20020a056e02111200b00351080cbc29mr1740324ilk.17.1695923201626; Thu, 28 Sep 2023 10:46:41 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id p6-20020a92d486000000b0034fc8c1c24fsm3450963ilg.54.2023.09.28.10.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:46:41 -0700 (PDT) From: Tom Tromey To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Tom Tromey Subject: [PATCH 1/7] libstdc++: Show full Python stack on error Date: Thu, 28 Sep 2023 11:46:24 -0600 Message-Id: <20230928174630.4004388-2-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928174630.4004388-1-tromey@adacore.com> References: <20230928174630.4004388-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778304483758705321 X-GMAIL-MSGID: 1778304483758705321 This changes the libstdc++ test suite to arrange for gdb to show the full Python stack if any sort of Python exception occurs. This makes debugging the printers a little simpler. libstdc++-v3/ChangeLog: * testsuite/lib/gdb-test.exp (gdb-test): Enable Python stack traces from gdb. --- libstdc++-v3/testsuite/lib/gdb-test.exp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libstdc++-v3/testsuite/lib/gdb-test.exp b/libstdc++-v3/testsuite/lib/gdb-test.exp index d8e572ef7b3..af7d970d388 100644 --- a/libstdc++-v3/testsuite/lib/gdb-test.exp +++ b/libstdc++-v3/testsuite/lib/gdb-test.exp @@ -141,6 +141,8 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } { puts $fd "set auto-load no" # Now that we've disabled auto-load, it's safe to set the target file puts $fd "file ./$output_file" + # See the full backtrace of any failures. + puts $fd "set python print-stack full" # Load & register *our* copy of the pretty-printers puts $fd "source $printer_code" puts $fd "python register_libstdcxx_printers(None)" From patchwork Thu Sep 28 17:46:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 146243 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3494746vqu; Thu, 28 Sep 2023 10:56:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlLT/W0t/XYf10m1TgX4VoVSfWWlc+O5yYxt0PdRsXHtX3mPIl38Cm0DmlXMUmJT2cIHHa X-Received: by 2002:a17:906:24e:b0:9ae:53af:c57f with SMTP id 14-20020a170906024e00b009ae53afc57fmr2153540ejl.65.1695923805106; Thu, 28 Sep 2023 10:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695923805; cv=none; d=google.com; s=arc-20160816; b=oyX9jQdvSvh1MxtZT6A7sEneQ97eLLWqYWNkG2fDsmBok17WfPX1EWU9BHtg0f+5de WsUG0rVjrn73ZHGvN7+MpS9KWAsHolCUuZM+eni9KwXSkV+fUsIhkv86nE0wk8DZnkK8 qvLVvVO0FaFgL3IVvXSs9uP+oOh+kQ7GnFuLUvMrbVCZUZ6d5qS/a056VuT83DaQ09Ef cHFnjAy/RpA6+zQ4f9abTylYFqUfeGSUfHabmSNSjbPsFllgbX/QsTYk9WQfCQLbq/gC /qAU0Yn9HcPfZQYvSeBVlNyvweo/DT6ANApr8JDJmQgmtsZUUo9VP/HOqSEKAlFzXQKp hmIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=/vPRrldHqgDYL+UAoJalEQR5zTgKO5b8w+o0g3/utGI=; fh=Ogh3zaPUNpdNYHofIVNHsbX+D3lwaT1T8Jhe/MolwAA=; b=Buk4Pbnss31BfRE8GaEwn1t24kO5sbAwmkvvis+QUR34fqMbxXbNeEbQ2FUtU+jrWa DOw7qNlMJ032M0M/lLMDcUWa1IQjAO6bmXsH0hjrg5SyeR5hi42FNI+2QDwd0P9aJMyI JSjLu//z6iZ5i/4Ar/oeoEX5FxT8Gsafa6jyrMbMfLkXDTCUPYFJX4pOMzozGz4HrUNJ +2XtLXQc51kVBCw5CqadSA/PFZq3Qo1ZuRTi+jcdx+m4Gqoilu3R+vkY0iiE54IJaucF BD0fAD0m7Fju/Wv5K03nMg0ckHigTMo9AkLKfwPFmjhZQCVpgjlyWwqwkQhQ/f/fYmIv SfGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=OM8GeJQR; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qc10-20020a170906d8aa00b009ae43ae1dd2si16589068ejb.275.2023.09.28.10.56.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:56:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=OM8GeJQR; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 675483888C66 for ; Thu, 28 Sep 2023 17:50:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 9AACC385841B for ; Thu, 28 Sep 2023 17:46:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9AACC385841B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-3513b5a9e8eso27766485ab.0 for ; Thu, 28 Sep 2023 10:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1695923203; x=1696528003; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/vPRrldHqgDYL+UAoJalEQR5zTgKO5b8w+o0g3/utGI=; b=OM8GeJQRsWxUy9jlnvHgNFu5UOsUWcWRaSbWk2XKviJd2NMvtabrIRvksM5HbeM0NN vEExRxdyFqPe/kSa08vYjur2M6EECMMiaWq49yUBjQOl4Y/XZc/eg2wvW9ZAOKYqgGlO V8ERJ7CTbm6RlDWYidZ1rXbtNLywLvbTRlt0y6v+WKyobtQwowNxjW39oRhuBdr/qH4Z deun2gCf+WwKm8zuI3CUKE56CJvhzqthu1FOIkYR0nffwnbR3Du4xYMrZIL+KO/ApcJa tL0/Cv9ON+hLkveC0EhIPnzvwVphyxY4lPfHUDsvApX8jOxMISRiX7U5Xb4Hvk6wKOpC 9nFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695923203; x=1696528003; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/vPRrldHqgDYL+UAoJalEQR5zTgKO5b8w+o0g3/utGI=; b=mgvy4NKqgmGQtBmSPvlJiIhOr1pxe8TyQfGThoyHKgOavqOxvLuJw7QGQzc3cX+00o SUNYMERTLuuHpNx5OcRwethw5Pu6UNT7ur26V1s2Y+G6EshjJWsPb7L0wJs4aE1pRyWA MmOFWOsPn3MACact0WpIjKuVqKfbt7cwtI+kDKsTOKy6+kdQ+dUksKdPB3PlEuZ87d9F 9wyEu571MqQnnEQ+Uds1bj1IWVTStOtkvEbepsPBVLntvMNwJClp0+6Q9vdu9ecSKdgY F4VSYA57MP340US83ukBhfG5YfUDPB1s1BkonadHWXhQsZscxad/ZOA+/l/0HklMhRk5 oO4A== X-Gm-Message-State: AOJu0YzKqO8A/4jKKUSprDhMjEs9yIktHO6vSPoGLaoomiNttu2dXema N4PMa4+0wCQAIa4/3LG5cA++kUlxtXy59bMYQ8l7HQ== X-Received: by 2002:a05:6e02:e11:b0:351:c52:5092 with SMTP id a17-20020a056e020e1100b003510c525092mr1627622ilk.3.1695923202447; Thu, 28 Sep 2023 10:46:42 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id p6-20020a92d486000000b0034fc8c1c24fsm3450963ilg.54.2023.09.28.10.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:46:42 -0700 (PDT) From: Tom Tromey To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Tom Tromey Subject: [PATCH 2/7] libstdc++: Use gdb.ValuePrinter base class Date: Thu, 28 Sep 2023 11:46:25 -0600 Message-Id: <20230928174630.4004388-3-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928174630.4004388-1-tromey@adacore.com> References: <20230928174630.4004388-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778304999564974956 X-GMAIL-MSGID: 1778304999564974956 GDB 14 will add a new ValuePrinter tag class that will be used to signal that pretty-printers will agree to the "extension protocol" -- essentially that they will follow some simple namespace rules, so that GDB can add new methods over time. A couple new methods have already been added to GDB, to support DAP. While I haven't implemented these for any libstdc++ printers yet, this patch makes the basic conversion: printers derive from gdb.ValuePrinter if it is available, and all "non-standard" (that is, not specified by GDB) members of the various value-printing classes are renamed to have a leading underscore. --- libstdc++-v3/python/libstdcxx/v6/printers.py | 1201 +++++++++--------- 1 file changed, 605 insertions(+), 596 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index d60c8003a63..bbc4375541f 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -97,6 +97,12 @@ try: except ImportError: pass +# Use the base class if available. +if hasattr(gdb, 'ValuePrinter'): + printer_base = gdb.ValuePrinter +else: + printer_base = object + # Starting with the type ORIG, search for the member type NAME. This # handles searching upward through superclasses. This is needed to # work around http://sourceware.org/bugzilla/show_bug.cgi?id=13615. @@ -241,43 +247,43 @@ class SmartPtrIterator(Iterator): "An iterator for smart pointer types with a single 'child' value" def __init__(self, val): - self.val = val + self._val = val def __iter__(self): return self def __next__(self): - if self.val is None: + if self._val is None: raise StopIteration - self.val, val = None, self.val + self._val, val = None, self._val return ('get()', val) -class SharedPointerPrinter: +class SharedPointerPrinter(printer_base): "Print a shared_ptr, weak_ptr, atomic, or atomic" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val - self.pointer = val['_M_ptr'] + self._typename = strip_versioned_namespace(typename) + self._val = val + self._pointer = val['_M_ptr'] def children(self): - return SmartPtrIterator(self.pointer) + return SmartPtrIterator(self._pointer) # Return the _Sp_counted_base<>* that holds the refcounts. def _get_refcounts(self): - if self.typename == 'std::atomic': + if self._typename == 'std::atomic': # A tagged pointer is stored as uintptr_t. - ptr_val = self.val['_M_refcount']['_M_val']['_M_i'] + ptr_val = self._val['_M_refcount']['_M_val']['_M_i'] ptr_val = ptr_val - (ptr_val % 2) # clear lock bit - ptr_type = find_type(self.val['_M_refcount'].type, 'pointer') + ptr_type = find_type(self._val['_M_refcount'].type, 'pointer') return ptr_val.cast(ptr_type) - return self.val['_M_refcount']['_M_pi'] + return self._val['_M_refcount']['_M_pi'] def to_string(self): state = 'empty' refcounts = self._get_refcounts() - targ = self.val.type.template_argument(0) + targ = self._val.type.template_argument(0) targ = strip_versioned_namespace(str(targ)) if refcounts != 0: @@ -288,7 +294,7 @@ class SharedPointerPrinter: else: state = 'use count %d, weak count %d' % ( usecount, weakcount - 1) - return '%s<%s> (%s)' % (self.typename, targ, state) + return '%s<%s> (%s)' % (self._typename, targ, state) def _tuple_impl_get(val): @@ -347,17 +353,17 @@ def unique_ptr_get(val): return tuple_get(0, tuple_member) -class UniquePointerPrinter: +class UniquePointerPrinter(printer_base): "Print a unique_ptr" def __init__(self, typename, val): - self.val = val + self._val = val def children(self): - return SmartPtrIterator(unique_ptr_get(self.val)) + return SmartPtrIterator(unique_ptr_get(self._val)) def to_string(self): - return ('std::unique_ptr<%s>' % (str(self.val.type.template_argument(0)))) + return ('std::unique_ptr<%s>' % (str(self._val.type.template_argument(0)))) def get_value_from_aligned_membuf(buf, valtype): @@ -381,55 +387,56 @@ def get_value_from_list_node(node): raise ValueError("Unsupported implementation for %s" % str(node.type)) -class StdListPrinter: +class StdListPrinter(printer_base): "Print a std::list" class _iterator(Iterator): def __init__(self, nodetype, head): - self.nodetype = nodetype - self.base = head['_M_next'] - self.head = head.address - self.count = 0 + self._nodetype = nodetype + self._base = head['_M_next'] + self._head = head.address + self._count = 0 def __iter__(self): return self def __next__(self): - if self.base == self.head: + if self._base == self._head: raise StopIteration - elt = self.base.cast(self.nodetype).dereference() - self.base = elt['_M_next'] - count = self.count - self.count = self.count + 1 + elt = self._base.cast(self._nodetype).dereference() + self._base = elt['_M_next'] + count = self._count + self._count = self._count + 1 val = get_value_from_list_node(elt) return ('[%d]' % count, val) def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def children(self): - nodetype = lookup_node_type('_List_node', self.val.type).pointer() - return self._iterator(nodetype, self.val['_M_impl']['_M_node']) + nodetype = lookup_node_type('_List_node', self._val.type).pointer() + return self._iterator(nodetype, self._val['_M_impl']['_M_node']) def to_string(self): - headnode = self.val['_M_impl']['_M_node'] + headnode = self._val['_M_impl']['_M_node'] if headnode['_M_next'] == headnode.address: - return 'empty %s' % (self.typename) - return '%s' % (self.typename) + return 'empty %s' % (self._typename) + return '%s' % (self._typename) -class NodeIteratorPrinter: +class NodeIteratorPrinter(printer_base): def __init__(self, typename, val, contname, nodename): - self.val = val - self.typename = typename - self.contname = contname - self.nodetype = lookup_node_type(nodename, val.type) + self._val = val + self._typename = typename + self._contname = contname + self._nodetype = lookup_node_type(nodename, val.type) def to_string(self): - if not self.val['_M_node']: - return 'non-dereferenceable iterator for std::%s' % (self.contname) - node = self.val['_M_node'].cast(self.nodetype.pointer()).dereference() + if not self._val['_M_node']: + return 'non-dereferenceable iterator for std::%s' % (self._contname) + node = self._val['_M_node'].cast( + self._nodetype.pointer()).dereference() return str(get_value_from_list_node(node)) @@ -448,163 +455,164 @@ class StdFwdListIteratorPrinter(NodeIteratorPrinter): '_Fwd_list_node') -class StdSlistPrinter: +class StdSlistPrinter(printer_base): "Print a __gnu_cxx::slist" class _iterator(Iterator): def __init__(self, nodetype, head): - self.nodetype = nodetype - self.base = head['_M_head']['_M_next'] - self.count = 0 + self._nodetype = nodetype + self._base = head['_M_head']['_M_next'] + self._count = 0 def __iter__(self): return self def __next__(self): - if self.base == 0: + if self._base == 0: raise StopIteration - elt = self.base.cast(self.nodetype).dereference() - self.base = elt['_M_next'] - count = self.count - self.count = self.count + 1 + elt = self._base.cast(self._nodetype).dereference() + self._base = elt['_M_next'] + count = self._count + self._count = self._count + 1 return ('[%d]' % count, elt['_M_data']) def __init__(self, typename, val): - self.val = val + self._val = val def children(self): - nodetype = lookup_node_type('__gnu_cxx::_Slist_node', self.val.type) - return self._iterator(nodetype.pointer(), self.val) + nodetype = lookup_node_type('__gnu_cxx::_Slist_node', self._val.type) + return self._iterator(nodetype.pointer(), self._val) def to_string(self): - if self.val['_M_head']['_M_next'] == 0: + if self._val['_M_head']['_M_next'] == 0: return 'empty __gnu_cxx::slist' return '__gnu_cxx::slist' -class StdSlistIteratorPrinter: +class StdSlistIteratorPrinter(printer_base): "Print __gnu_cxx::slist::iterator" def __init__(self, typename, val): - self.val = val + self._val = val def to_string(self): - if not self.val['_M_node']: + if not self._val['_M_node']: return 'non-dereferenceable iterator for __gnu_cxx::slist' nodetype = lookup_node_type( - '__gnu_cxx::_Slist_node', self.val.type).pointer() - return str(self.val['_M_node'].cast(nodetype).dereference()['_M_data']) + '__gnu_cxx::_Slist_node', self._val.type).pointer() + return str(self._val['_M_node'].cast(nodetype).dereference()['_M_data']) -class StdVectorPrinter: +class StdVectorPrinter(printer_base): "Print a std::vector" class _iterator(Iterator): def __init__(self, start, finish, bitvec): - self.bitvec = bitvec + self._bitvec = bitvec if bitvec: - self.item = start['_M_p'] - self.so = 0 - self.finish = finish['_M_p'] - self.fo = finish['_M_offset'] - itype = self.item.dereference().type - self.isize = 8 * itype.sizeof + self._item = start['_M_p'] + self._so = 0 + self._finish = finish['_M_p'] + self._fo = finish['_M_offset'] + itype = self._item.dereference().type + self._isize = 8 * itype.sizeof else: - self.item = start - self.finish = finish - self.count = 0 + self._item = start + self._finish = finish + self._count = 0 def __iter__(self): return self def __next__(self): - count = self.count - self.count = self.count + 1 - if self.bitvec: - if self.item == self.finish and self.so >= self.fo: + count = self._count + self._count = self._count + 1 + if self._bitvec: + if self._item == self._finish and self._so >= self._fo: raise StopIteration - elt = bool(self.item.dereference() & (1 << self.so)) - self.so = self.so + 1 - if self.so >= self.isize: - self.item = self.item + 1 - self.so = 0 + elt = bool(self._item.dereference() & (1 << self._so)) + self._so = self._so + 1 + if self._so >= self._isize: + self._item = self._item + 1 + self._so = 0 return ('[%d]' % count, elt) else: - if self.item == self.finish: + if self._item == self._finish: raise StopIteration - elt = self.item.dereference() - self.item = self.item + 1 + elt = self._item.dereference() + self._item = self._item + 1 return ('[%d]' % count, elt) def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val - self.is_bool = val.type.template_argument(0).code == gdb.TYPE_CODE_BOOL + self._typename = strip_versioned_namespace(typename) + self._val = val + self._is_bool = val.type.template_argument( + 0).code == gdb.TYPE_CODE_BOOL def children(self): - return self._iterator(self.val['_M_impl']['_M_start'], - self.val['_M_impl']['_M_finish'], - self.is_bool) + return self._iterator(self._val['_M_impl']['_M_start'], + self._val['_M_impl']['_M_finish'], + self._is_bool) def to_string(self): - start = self.val['_M_impl']['_M_start'] - finish = self.val['_M_impl']['_M_finish'] - end = self.val['_M_impl']['_M_end_of_storage'] - if self.is_bool: - start = self.val['_M_impl']['_M_start']['_M_p'] - finish = self.val['_M_impl']['_M_finish']['_M_p'] - fo = self.val['_M_impl']['_M_finish']['_M_offset'] + start = self._val['_M_impl']['_M_start'] + finish = self._val['_M_impl']['_M_finish'] + end = self._val['_M_impl']['_M_end_of_storage'] + if self._is_bool: + start = self._val['_M_impl']['_M_start']['_M_p'] + finish = self._val['_M_impl']['_M_finish']['_M_p'] + fo = self._val['_M_impl']['_M_finish']['_M_offset'] itype = start.dereference().type bl = 8 * itype.sizeof length = bl * (finish - start) + fo capacity = bl * (end - start) return ('%s of length %d, capacity %d' - % (self.typename, int(length), int(capacity))) + % (self._typename, int(length), int(capacity))) else: return ('%s of length %d, capacity %d' - % (self.typename, int(finish - start), int(end - start))) + % (self._typename, int(finish - start), int(end - start))) def display_hint(self): return 'array' -class StdVectorIteratorPrinter: +class StdVectorIteratorPrinter(printer_base): "Print std::vector::iterator" def __init__(self, typename, val): - self.val = val + self._val = val def to_string(self): - if not self.val['_M_current']: + if not self._val['_M_current']: return 'non-dereferenceable iterator for std::vector' - return str(self.val['_M_current'].dereference()) + return str(self._val['_M_current'].dereference()) -class StdBitIteratorPrinter: +class StdBitIteratorPrinter(printer_base): "Print std::vector's _Bit_iterator and _Bit_const_iterator" def __init__(self, typename, val): - self.val = val + self._val = val def to_string(self): - if not self.val['_M_p']: + if not self._val['_M_p']: return 'non-dereferenceable iterator for std::vector' - return bool(self.val['_M_p'].dereference() & (1 << self.val['_M_offset'])) + return bool(self._val['_M_p'].dereference() & (1 << self._val['_M_offset'])) -class StdBitReferencePrinter: +class StdBitReferencePrinter(printer_base): "Print std::vector::reference" def __init__(self, typename, val): - self.val = val + self._val = val def to_string(self): - if not self.val['_M_p']: + if not self._val['_M_p']: return 'invalid std::vector::reference' - return bool(self.val['_M_p'].dereference() & (self.val['_M_mask'])) + return bool(self._val['_M_p'].dereference() & (self._val['_M_mask'])) -class StdTuplePrinter: +class StdTuplePrinter(printer_base): "Print a std::tuple" class _iterator(Iterator): @@ -621,25 +629,25 @@ class StdTuplePrinter: "Top of tuple tree does not consist of a single node.") def __init__(self, head): - self.head = head + self._head = head # Set the base class as the initial head of the # tuple. - nodes = self.head.type.fields() + nodes = self._head.type.fields() if self._is_nonempty_tuple(nodes): # Set the actual head to the first pair. - self.head = self.head.cast(nodes[0].type) - self.count = 0 + self._head = self._head.cast(nodes[0].type) + self._count = 0 def __iter__(self): return self def __next__(self): # Check for further recursions in the inheritance tree. - # For a GCC 5+ tuple self.head is None after visiting all nodes: - if not self.head: + # For a GCC 5+ tuple self._head is None after visiting all nodes: + if not self._head: raise StopIteration - nodes = self.head.type.fields() + nodes = self._head.type.fields() # For a GCC 4.x tuple there is a final node with no fields: if len(nodes) == 0: raise StopIteration @@ -650,8 +658,8 @@ class StdTuplePrinter: if len(nodes) == 1: # This is the last node of a GCC 5+ std::tuple. - impl = self.head.cast(nodes[0].type) - self.head = None + impl = self._head.cast(nodes[0].type) + self._head = None else: # Either a node before the last node, or the last node of # a GCC 4.x tuple (which has an empty parent). @@ -660,52 +668,52 @@ class StdTuplePrinter: # - Right node is the actual class contained in the tuple. # Process right node. - impl = self.head.cast(nodes[1].type) + impl = self._head.cast(nodes[1].type) # Process left node and set it as head. - self.head = self.head.cast(nodes[0].type) + self._head = self._head.cast(nodes[0].type) - self.count = self.count + 1 + self._count = self._count + 1 # Finally, check the implementation. If it is # wrapped in _M_head_impl return that, otherwise return # the value "as is". fields = impl.type.fields() if len(fields) < 1 or fields[0].name != "_M_head_impl": - return ('[%d]' % (self.count - 1), impl) + return ('[%d]' % (self._count - 1), impl) else: - return ('[%d]' % (self.count - 1), impl['_M_head_impl']) + return ('[%d]' % (self._count - 1), impl['_M_head_impl']) def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def children(self): - return self._iterator(self.val) + return self._iterator(self._val) def to_string(self): - if len(self.val.type.fields()) == 0: - return 'empty %s' % (self.typename) - return '%s containing' % (self.typename) + if len(self._val.type.fields()) == 0: + return 'empty %s' % (self._typename) + return '%s containing' % (self._typename) -class StdStackOrQueuePrinter: +class StdStackOrQueuePrinter(printer_base): "Print a std::stack or std::queue" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.visualizer = gdb.default_visualizer(val['c']) + self._typename = strip_versioned_namespace(typename) + self._visualizer = gdb.default_visualizer(val['c']) def children(self): - return self.visualizer.children() + return self._visualizer.children() def to_string(self): - return '%s wrapping: %s' % (self.typename, - self.visualizer.to_string()) + return '%s wrapping: %s' % (self._typename, + self._visualizer.to_string()) def display_hint(self): - if hasattr(self.visualizer, 'display_hint'): - return self.visualizer.display_hint() + if hasattr(self._visualizer, 'display_hint'): + return self._visualizer.display_hint() return None @@ -716,24 +724,24 @@ class RbtreeIterator(Iterator): """ def __init__(self, rbtree): - self.size = rbtree['_M_t']['_M_impl']['_M_node_count'] - self.node = rbtree['_M_t']['_M_impl']['_M_header']['_M_left'] - self.count = 0 + self._size = rbtree['_M_t']['_M_impl']['_M_node_count'] + self._node = rbtree['_M_t']['_M_impl']['_M_header']['_M_left'] + self._count = 0 def __iter__(self): return self def __len__(self): - return int(self.size) + return int(self._size) def __next__(self): - if self.count == self.size: + if self._count == self._size: raise StopIteration - result = self.node - self.count = self.count + 1 - if self.count < self.size: + result = self._node + self._count = self._count + 1 + if self._count < self._size: # Compute the next node. - node = self.node + node = self._node if node.dereference()['_M_right']: node = node.dereference()['_M_right'] while node.dereference()['_M_left']: @@ -745,7 +753,7 @@ class RbtreeIterator(Iterator): parent = parent.dereference()['_M_parent'] if node.dereference()['_M_right'] != parent: node = parent - self.node = node + self._node = node return result @@ -769,38 +777,38 @@ def get_value_from_Rb_tree_node(node): # class above. -class StdRbtreeIteratorPrinter: +class StdRbtreeIteratorPrinter(printer_base): "Print std::map::iterator, std::set::iterator, etc." def __init__(self, typename, val): - self.val = val - nodetype = lookup_node_type('_Rb_tree_node', self.val.type) - self.link_type = nodetype.pointer() + self._val = val + nodetype = lookup_node_type('_Rb_tree_node', self._val.type) + self._link_type = nodetype.pointer() def to_string(self): - if not self.val['_M_node']: + if not self._val['_M_node']: return 'non-dereferenceable iterator for associative container' - node = self.val['_M_node'].cast(self.link_type).dereference() + node = self._val['_M_node'].cast(self._link_type).dereference() return str(get_value_from_Rb_tree_node(node)) -class StdDebugIteratorPrinter: +class StdDebugIteratorPrinter(printer_base): "Print a debug enabled version of an iterator" def __init__(self, typename, val): - self.val = val + self._val = val # Just strip away the encapsulating __gnu_debug::_Safe_iterator # and return the wrapped iterator value. def to_string(self): base_type = gdb.lookup_type('__gnu_debug::_Safe_iterator_base') - itype = self.val.type.template_argument(0) - safe_seq = self.val.cast(base_type)['_M_sequence'] + itype = self._val.type.template_argument(0) + safe_seq = self._val.cast(base_type)['_M_sequence'] if not safe_seq: - return str(self.val.cast(itype)) - if self.val['_M_version'] != safe_seq['_M_version']: + return str(self._val.cast(itype)) + if self._val['_M_version'] != safe_seq['_M_version']: return "invalid iterator" - return str(self.val.cast(itype)) + return str(self._val.cast(itype)) def num_elements(num): @@ -808,101 +816,101 @@ def num_elements(num): return '1 element' if num == 1 else '%d elements' % num -class StdMapPrinter: +class StdMapPrinter(printer_base): "Print a std::map or std::multimap" # Turn an RbtreeIterator into a pretty-print iterator. class _iter(Iterator): def __init__(self, rbiter, type): - self.rbiter = rbiter - self.count = 0 - self.type = type + self._rbiter = rbiter + self._count = 0 + self._type = type def __iter__(self): return self def __next__(self): - if self.count % 2 == 0: - n = next(self.rbiter) - n = n.cast(self.type).dereference() + if self._count % 2 == 0: + n = next(self._rbiter) + n = n.cast(self._type).dereference() n = get_value_from_Rb_tree_node(n) - self.pair = n + self._pair = n item = n['first'] else: - item = self.pair['second'] - result = ('[%d]' % self.count, item) - self.count = self.count + 1 + item = self._pair['second'] + result = ('[%d]' % self._count, item) + self._count = self._count + 1 return result def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def to_string(self): - return '%s with %s' % (self.typename, - num_elements(len(RbtreeIterator(self.val)))) + return '%s with %s' % (self._typename, + num_elements(len(RbtreeIterator(self._val)))) def children(self): - node = lookup_node_type('_Rb_tree_node', self.val.type).pointer() - return self._iter(RbtreeIterator(self.val), node) + node = lookup_node_type('_Rb_tree_node', self._val.type).pointer() + return self._iter(RbtreeIterator(self._val), node) def display_hint(self): return 'map' -class StdSetPrinter: +class StdSetPrinter(printer_base): "Print a std::set or std::multiset" # Turn an RbtreeIterator into a pretty-print iterator. class _iter(Iterator): def __init__(self, rbiter, type): - self.rbiter = rbiter - self.count = 0 - self.type = type + self._rbiter = rbiter + self._count = 0 + self._type = type def __iter__(self): return self def __next__(self): - item = next(self.rbiter) - item = item.cast(self.type).dereference() + item = next(self._rbiter) + item = item.cast(self._type).dereference() item = get_value_from_Rb_tree_node(item) # FIXME: this is weird ... what to do? # Maybe a 'set' display hint? - result = ('[%d]' % self.count, item) - self.count = self.count + 1 + result = ('[%d]' % self._count, item) + self._count = self._count + 1 return result def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def to_string(self): - return '%s with %s' % (self.typename, - num_elements(len(RbtreeIterator(self.val)))) + return '%s with %s' % (self._typename, + num_elements(len(RbtreeIterator(self._val)))) def children(self): - node = lookup_node_type('_Rb_tree_node', self.val.type).pointer() - return self._iter(RbtreeIterator(self.val), node) + node = lookup_node_type('_Rb_tree_node', self._val.type).pointer() + return self._iter(RbtreeIterator(self._val), node) -class StdBitsetPrinter: +class StdBitsetPrinter(printer_base): "Print a std::bitset" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def to_string(self): # If template_argument handled values, we could print the # size. Or we could use a regexp on the type. - return '%s' % (self.typename) + return '%s' % (self._typename) def children(self): try: # An empty bitset may not have any members which will # result in an exception being thrown. - words = self.val['_M_w'] + words = self._val['_M_w'] except: return [] @@ -933,102 +941,102 @@ class StdBitsetPrinter: return result -class StdDequePrinter: +class StdDequePrinter(printer_base): "Print a std::deque" class _iter(Iterator): def __init__(self, node, start, end, last, buffer_size): - self.node = node - self.p = start - self.end = end - self.last = last - self.buffer_size = buffer_size - self.count = 0 + self._node = node + self._p = start + self._end = end + self._last = last + self._buffer_size = buffer_size + self._count = 0 def __iter__(self): return self def __next__(self): - if self.p == self.last: + if self._p == self._last: raise StopIteration - result = ('[%d]' % self.count, self.p.dereference()) - self.count = self.count + 1 + result = ('[%d]' % self._count, self._p.dereference()) + self._count = self._count + 1 # Advance the 'cur' pointer. - self.p = self.p + 1 - if self.p == self.end: + self._p = self._p + 1 + if self._p == self._end: # If we got to the end of this bucket, move to the # next bucket. - self.node = self.node + 1 - self.p = self.node[0] - self.end = self.p + self.buffer_size + self._node = self._node + 1 + self._p = self._node[0] + self._end = self._p + self._buffer_size return result def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val - self.elttype = val.type.template_argument(0) - size = self.elttype.sizeof + self._typename = strip_versioned_namespace(typename) + self._val = val + self._elttype = val.type.template_argument(0) + size = self._elttype.sizeof if size < 512: - self.buffer_size = int(512 / size) + self._buffer_size = int(512 / size) else: - self.buffer_size = 1 + self._buffer_size = 1 def to_string(self): - start = self.val['_M_impl']['_M_start'] - end = self.val['_M_impl']['_M_finish'] + start = self._val['_M_impl']['_M_start'] + end = self._val['_M_impl']['_M_finish'] delta_n = end['_M_node'] - start['_M_node'] - 1 delta_s = start['_M_last'] - start['_M_cur'] delta_e = end['_M_cur'] - end['_M_first'] - size = self.buffer_size * delta_n + delta_s + delta_e + size = self._buffer_size * delta_n + delta_s + delta_e - return '%s with %s' % (self.typename, num_elements(long(size))) + return '%s with %s' % (self._typename, num_elements(long(size))) def children(self): - start = self.val['_M_impl']['_M_start'] - end = self.val['_M_impl']['_M_finish'] + start = self._val['_M_impl']['_M_start'] + end = self._val['_M_impl']['_M_finish'] return self._iter(start['_M_node'], start['_M_cur'], start['_M_last'], - end['_M_cur'], self.buffer_size) + end['_M_cur'], self._buffer_size) def display_hint(self): return 'array' -class StdDequeIteratorPrinter: +class StdDequeIteratorPrinter(printer_base): "Print std::deque::iterator" def __init__(self, typename, val): - self.val = val + self._val = val def to_string(self): - if not self.val['_M_cur']: + if not self._val['_M_cur']: return 'non-dereferenceable iterator for std::deque' - return str(self.val['_M_cur'].dereference()) + return str(self._val['_M_cur'].dereference()) -class StdStringPrinter: +class StdStringPrinter(printer_base): "Print a std::basic_string of some kind" def __init__(self, typename, val): - self.val = val - self.new_string = typename.find("::__cxx11::basic_string") != -1 + self._val = val + self._new_string = typename.find("::__cxx11::basic_string") != -1 def to_string(self): # Make sure &string works, too. - type = self.val.type + type = self._val.type if type.code == gdb.TYPE_CODE_REF: type = type.target() # Calculate the length of the string so that to_string returns # the string according to length, not according to first null # encountered. - ptr = self.val['_M_dataplus']['_M_p'] - if self.new_string: - length = self.val['_M_string_length'] + ptr = self._val['_M_dataplus']['_M_p'] + if self._new_string: + length = self._val['_M_string_length'] # https://sourceware.org/bugzilla/show_bug.cgi?id=17728 ptr = ptr.cast(ptr.type.strip_typedefs()) else: @@ -1052,173 +1060,173 @@ def access_streambuf_ptrs(streambuf): return pbase, pptr, egptr -class StdStringBufPrinter: +class StdStringBufPrinter(printer_base): "Print a std::basic_stringbuf" def __init__(self, _, val): - self.val = val + self._val = val def to_string(self): - (pbase, pptr, egptr) = access_streambuf_ptrs(self.val) + (pbase, pptr, egptr) = access_streambuf_ptrs(self._val) # Logic from basic_stringbuf::_M_high_mark() if pptr: if not egptr or pptr > egptr: return pbase.string(length=pptr - pbase) else: return pbase.string(length=egptr - pbase) - return self.val['_M_string'] + return self._val['_M_string'] def display_hint(self): return 'string' -class StdStringStreamPrinter: +class StdStringStreamPrinter(printer_base): "Print a std::basic_stringstream" def __init__(self, typename, val): - self.val = val - self.typename = typename + self._val = val + self._typename = typename # Check if the stream was redirected: # This is essentially: val['_M_streambuf'] == val['_M_stringbuf'].address # However, GDB can't resolve the virtual inheritance, so we do that manually basetype = [f.type for f in val.type.fields() if f.is_base_class][0] gdb.set_convenience_variable('__stream', val.cast(basetype).address) - self.streambuf = gdb.parse_and_eval('$__stream->rdbuf()') - self.was_redirected = self.streambuf != val['_M_stringbuf'].address + self._streambuf = gdb.parse_and_eval('$__stream->rdbuf()') + self._was_redirected = self._streambuf != val['_M_stringbuf'].address def to_string(self): - if self.was_redirected: - return "%s redirected to %s" % (self.typename, self.streambuf.dereference()) - return self.val['_M_stringbuf'] + if self._was_redirected: + return "%s redirected to %s" % (self._typename, self._streambuf.dereference()) + return self._val['_M_stringbuf'] def display_hint(self): - if self.was_redirected: + if self._was_redirected: return None return 'string' class Tr1HashtableIterator(Iterator): def __init__(self, hashtable): - self.buckets = hashtable['_M_buckets'] - self.bucket = 0 - self.bucket_count = hashtable['_M_bucket_count'] - self.node_type = find_type(hashtable.type, '_Node').pointer() - self.node = 0 - while self.bucket != self.bucket_count: - self.node = self.buckets[self.bucket] - if self.node: + self._buckets = hashtable['_M_buckets'] + self._bucket = 0 + self._bucket_count = hashtable['_M_bucket_count'] + self._node_type = find_type(hashtable.type, '_Node').pointer() + self._node = 0 + while self._bucket != self._bucket_count: + self._node = self._buckets[self._bucket] + if self._node: break - self.bucket = self.bucket + 1 + self._bucket = self._bucket + 1 def __iter__(self): return self def __next__(self): - if self.node == 0: + if self._node == 0: raise StopIteration - node = self.node.cast(self.node_type) + node = self._node.cast(self._node_type) result = node.dereference()['_M_v'] - self.node = node.dereference()['_M_next'] - if self.node == 0: - self.bucket = self.bucket + 1 - while self.bucket != self.bucket_count: - self.node = self.buckets[self.bucket] - if self.node: + self._node = node.dereference()['_M_next'] + if self._node == 0: + self._bucket = self._bucket + 1 + while self._bucket != self._bucket_count: + self._node = self._buckets[self._bucket] + if self._node: break - self.bucket = self.bucket + 1 + self._bucket = self._bucket + 1 return result class StdHashtableIterator(Iterator): def __init__(self, hashtable): - self.node = hashtable['_M_before_begin']['_M_nxt'] + self._node = hashtable['_M_before_begin']['_M_nxt'] valtype = hashtable.type.template_argument(1) cached = hashtable.type.template_argument(9).template_argument(0) node_type = lookup_templ_spec('std::__detail::_Hash_node', str(valtype), 'true' if cached else 'false') - self.node_type = node_type.pointer() + self._node_type = node_type.pointer() def __iter__(self): return self def __next__(self): - if self.node == 0: + if self._node == 0: raise StopIteration - elt = self.node.cast(self.node_type).dereference() - self.node = elt['_M_nxt'] + elt = self._node.cast(self._node_type).dereference() + self._node = elt['_M_nxt'] valptr = elt['_M_storage'].address valptr = valptr.cast(elt.type.template_argument(0).pointer()) return valptr.dereference() -class Tr1UnorderedSetPrinter: +class Tr1UnorderedSetPrinter(printer_base): "Print a std::unordered_set or tr1::unordered_set" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val - def hashtable(self): - if self.typename.startswith('std::tr1'): - return self.val - return self.val['_M_h'] + def _hashtable(self): + if self._typename.startswith('std::tr1'): + return self._val + return self._val['_M_h'] def to_string(self): - count = self.hashtable()['_M_element_count'] - return '%s with %s' % (self.typename, num_elements(count)) + count = self._hashtable()['_M_element_count'] + return '%s with %s' % (self._typename, num_elements(count)) @staticmethod - def format_count(i): + def _format_count(i): return '[%d]' % i def children(self): - counter = imap(self.format_count, itertools.count()) - if self.typename.startswith('std::tr1'): - return izip(counter, Tr1HashtableIterator(self.hashtable())) - return izip(counter, StdHashtableIterator(self.hashtable())) + counter = imap(self._format_count, itertools.count()) + if self._typename.startswith('std::tr1'): + return izip(counter, Tr1HashtableIterator(self._hashtable())) + return izip(counter, StdHashtableIterator(self._hashtable())) -class Tr1UnorderedMapPrinter: +class Tr1UnorderedMapPrinter(printer_base): "Print a std::unordered_map or tr1::unordered_map" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val - def hashtable(self): - if self.typename.startswith('std::tr1'): - return self.val - return self.val['_M_h'] + def _hashtable(self): + if self._typename.startswith('std::tr1'): + return self._val + return self._val['_M_h'] def to_string(self): - count = self.hashtable()['_M_element_count'] - return '%s with %s' % (self.typename, num_elements(count)) + count = self._hashtable()['_M_element_count'] + return '%s with %s' % (self._typename, num_elements(count)) @staticmethod - def flatten(list): + def _flatten(list): for elt in list: for i in elt: yield i @staticmethod - def format_one(elt): + def _format_one(elt): return (elt['first'], elt['second']) @staticmethod - def format_count(i): + def _format_count(i): return '[%d]' % i def children(self): - counter = imap(self.format_count, itertools.count()) + counter = imap(self._format_count, itertools.count()) # Map over the hash table and flatten the result. - if self.typename.startswith('std::tr1'): - data = self.flatten( - imap(self.format_one, Tr1HashtableIterator(self.hashtable()))) + if self._typename.startswith('std::tr1'): + data = self._flatten( + imap(self._format_one, Tr1HashtableIterator(self._hashtable()))) # Zip the two iterators together. return izip(counter, data) - data = self.flatten( - imap(self.format_one, StdHashtableIterator(self.hashtable()))) + data = self._flatten( + imap(self._format_one, StdHashtableIterator(self._hashtable()))) # Zip the two iterators together. return izip(counter, data) @@ -1226,50 +1234,50 @@ class Tr1UnorderedMapPrinter: return 'map' -class StdForwardListPrinter: +class StdForwardListPrinter(printer_base): "Print a std::forward_list" class _iterator(Iterator): def __init__(self, nodetype, head): - self.nodetype = nodetype - self.base = head['_M_next'] - self.count = 0 + self._nodetype = nodetype + self._base = head['_M_next'] + self._count = 0 def __iter__(self): return self def __next__(self): - if self.base == 0: + if self._base == 0: raise StopIteration - elt = self.base.cast(self.nodetype).dereference() - self.base = elt['_M_next'] - count = self.count - self.count = self.count + 1 + elt = self._base.cast(self._nodetype).dereference() + self._base = elt['_M_next'] + count = self._count + self._count = self._count + 1 valptr = elt['_M_storage'].address valptr = valptr.cast(elt.type.template_argument(0).pointer()) return ('[%d]' % count, valptr.dereference()) def __init__(self, typename, val): - self.val = val - self.typename = strip_versioned_namespace(typename) + self._val = val + self._typename = strip_versioned_namespace(typename) def children(self): - nodetype = lookup_node_type('_Fwd_list_node', self.val.type).pointer() - return self._iterator(nodetype, self.val['_M_impl']['_M_head']) + nodetype = lookup_node_type('_Fwd_list_node', self._val.type).pointer() + return self._iterator(nodetype, self._val['_M_impl']['_M_head']) def to_string(self): - if self.val['_M_impl']['_M_head']['_M_next'] == 0: - return 'empty %s' % self.typename - return '%s' % self.typename + if self._val['_M_impl']['_M_head']['_M_next'] == 0: + return 'empty %s' % self._typename + return '%s' % self._typename -class SingleObjContainerPrinter(object): +class SingleObjContainerPrinter(printer_base): "Base class for printers of containers of single objects" def __init__(self, val, viz, hint=None): - self.contained_value = val - self.visualizer = viz - self.hint = hint + self._contained_value = val + self._visualizer = viz + self._hint = hint def _recognize(self, type): """Return TYPE as a string after applying type printers""" @@ -1281,30 +1289,30 @@ class SingleObjContainerPrinter(object): class _contained(Iterator): def __init__(self, val): - self.val = val + self._val = val def __iter__(self): return self def __next__(self): - if self.val is None: + if self._val is None: raise StopIteration - retval = self.val - self.val = None + retval = self._val + self._val = None return ('[contained value]', retval) def children(self): - if self.contained_value is None: + if self._contained_value is None: return self._contained(None) - if hasattr(self.visualizer, 'children'): - return self.visualizer.children() - return self._contained(self.contained_value) + if hasattr(self._visualizer, 'children'): + return self._visualizer.children() + return self._contained(self._contained_value) def display_hint(self): # if contained value is a map we want to display in the same way - if hasattr(self.visualizer, 'children') and hasattr(self.visualizer, 'display_hint'): - return self.visualizer.display_hint() - return self.hint + if hasattr(self._visualizer, 'children') and hasattr(self._visualizer, 'display_hint'): + return self._visualizer.display_hint() + return self._hint def function_pointer_to_name(f): @@ -1335,24 +1343,24 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): "Print a std::any or std::experimental::any" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.typename = re.sub( - '^std::experimental::fundamentals_v\d::', 'std::experimental::', self.typename, 1) - self.val = val - self.contained_type = None + self._typename = strip_versioned_namespace(typename) + self._typename = re.sub( + '^std::experimental::fundamentals_v\d::', 'std::experimental::', self._typename, 1) + self._val = val + self._contained_type = None contained_value = None visualizer = None - mgr = self.val['_M_manager'] + mgr = self._val['_M_manager'] if mgr != 0: func = function_pointer_to_name(mgr) if not func: - raise ValueError( - "Invalid function pointer in %s" % (self.typename)) + raise ValueError("Invalid function pointer in %s" % + (self._typename)) rx = r"""({0}::_Manager_\w+<.*>)::_S_manage\((enum )?{0}::_Op, (const {0}|{0} const) ?\*, (union )?{0}::_Arg ?\*\)""".format(typename) m = re.match(rx, func) if not m: raise ValueError( - "Unknown manager function in %s" % self.typename) + "Unknown manager function in %s" % self._typename) mgrname = m.group(1) # FIXME need to expand 'std::string' so that gdb.lookup_type works @@ -1388,27 +1396,27 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): mgrtype = mgrtypes[0] else: mgrtype = gdb.lookup_type(mgrname) - self.contained_type = mgrtype.template_argument(0) + self._contained_type = mgrtype.template_argument(0) valptr = None if '::_Manager_internal' in mgrname: - valptr = self.val['_M_storage']['_M_buffer'].address + valptr = self._val['_M_storage']['_M_buffer'].address elif '::_Manager_external' in mgrname: - valptr = self.val['_M_storage']['_M_ptr'] + valptr = self._val['_M_storage']['_M_ptr'] else: raise ValueError( - "Unknown manager function in %s" % self.typename) + "Unknown manager function in %s" % self._typename) contained_value = valptr.cast( - self.contained_type.pointer()).dereference() + self._contained_type.pointer()).dereference() visualizer = gdb.default_visualizer(contained_value) super(StdExpAnyPrinter, self).__init__(contained_value, visualizer) def to_string(self): - if self.contained_type is None: - return '%s [no contained value]' % self.typename - desc = "%s containing " % self.typename - if hasattr(self.visualizer, 'children'): - return desc + self.visualizer.to_string() - valtype = self._recognize(self.contained_type) + if self._contained_type is None: + return '%s [no contained value]' % self._typename + desc = "%s containing " % self._typename + if hasattr(self._visualizer, 'children'): + return desc + self._visualizer.to_string() + valtype = self._recognize(self._contained_type) return desc + strip_versioned_namespace(str(valtype)) @@ -1418,10 +1426,10 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter): def __init__(self, typename, val): valtype = self._recognize(val.type.template_argument(0)) typename = strip_versioned_namespace(typename) - self.typename = re.sub( + self._typename = re.sub( '^std::(experimental::|)(fundamentals_v\d::|)(.*)', r'std::\1\3', typename, 1) payload = val['_M_payload'] - if self.typename.startswith('std::experimental'): + if self._typename.startswith('std::experimental'): engaged = val['_M_engaged'] contained_value = payload else: @@ -1439,12 +1447,12 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter): contained_value, visualizer) def to_string(self): - if self.contained_value is None: - return "%s [no contained value]" % self.typename - if hasattr(self.visualizer, 'children'): - return "%s containing %s" % (self.typename, - self.visualizer.to_string()) - return self.typename + if self._contained_value is None: + return "%s [no contained value]" % self._typename + if hasattr(self._visualizer, 'children'): + return "%s containing %s" % (self._typename, + self._visualizer.to_string()) + return self._typename class StdVariantPrinter(SingleObjContainerPrinter): @@ -1452,83 +1460,83 @@ class StdVariantPrinter(SingleObjContainerPrinter): def __init__(self, typename, val): alternatives = get_template_arg_list(val.type) - self.typename = strip_versioned_namespace(typename) - self.index = val['_M_index'] - if self.index >= len(alternatives): - self.contained_type = None + self._typename = strip_versioned_namespace(typename) + self._index = val['_M_index'] + if self._index >= len(alternatives): + self._contained_type = None contained_value = None visualizer = None else: - self.contained_type = alternatives[int(self.index)] + self._contained_type = alternatives[int(self._index)] addr = val['_M_u']['_M_first']['_M_storage'].address contained_value = addr.cast( - self.contained_type.pointer()).dereference() + self._contained_type.pointer()).dereference() visualizer = gdb.default_visualizer(contained_value) super(StdVariantPrinter, self).__init__( contained_value, visualizer, 'array') def to_string(self): - if self.contained_value is None: - return "%s [no contained value]" % self.typename - if hasattr(self.visualizer, 'children'): - return "%s [index %d] containing %s" % (self.typename, self.index, - self.visualizer.to_string()) - return "%s [index %d]" % (self.typename, self.index) + if self._contained_value is None: + return "%s [no contained value]" % self._typename + if hasattr(self._visualizer, 'children'): + return "%s [index %d] containing %s" % (self._typename, self._index, + self._visualizer.to_string()) + return "%s [index %d]" % (self._typename, self._index) class StdNodeHandlePrinter(SingleObjContainerPrinter): "Print a container node handle" def __init__(self, typename, val): - self.value_type = val.type.template_argument(1) + self._value_type = val.type.template_argument(1) nodetype = val.type.template_argument(2).template_argument(0) - self.is_rb_tree_node = is_specialization_of( + self._is_rb_tree_node = is_specialization_of( nodetype.name, '_Rb_tree_node') - self.is_map_node = val.type.template_argument(0) != self.value_type + self._is_map_node = val.type.template_argument(0) != self._value_type nodeptr = val['_M_ptr'] if nodeptr: - if self.is_rb_tree_node: + if self._is_rb_tree_node: contained_value = get_value_from_Rb_tree_node( nodeptr.dereference()) else: contained_value = get_value_from_aligned_membuf(nodeptr['_M_storage'], - self.value_type) + self._value_type) visualizer = gdb.default_visualizer(contained_value) else: contained_value = None visualizer = None optalloc = val['_M_alloc'] - self.alloc = optalloc['_M_payload'] if optalloc['_M_engaged'] else None + self._alloc = optalloc['_M_payload'] if optalloc['_M_engaged'] else None super(StdNodeHandlePrinter, self).__init__(contained_value, visualizer, 'array') def to_string(self): desc = 'node handle for ' - if not self.is_rb_tree_node: + if not self._is_rb_tree_node: desc += 'unordered ' - if self.is_map_node: + if self._is_map_node: desc += 'map' else: desc += 'set' - if self.contained_value: + if self._contained_value: desc += ' with element' - if hasattr(self.visualizer, 'children'): - return "%s = %s" % (desc, self.visualizer.to_string()) + if hasattr(self._visualizer, 'children'): + return "%s = %s" % (desc, self._visualizer.to_string()) return desc else: return 'empty %s' % desc -class StdExpStringViewPrinter: +class StdExpStringViewPrinter(printer_base): "Print a std::basic_string_view or std::experimental::basic_string_view" def __init__(self, typename, val): - self.val = val + self._val = val def to_string(self): - ptr = self.val['_M_str'] - len = self.val['_M_len'] + ptr = self._val['_M_str'] + len = self._val['_M_len'] if hasattr(ptr, "lazy_string"): return ptr.lazy_string(length=len) return ptr.string(length=len) @@ -1537,18 +1545,18 @@ class StdExpStringViewPrinter: return 'string' -class StdExpPathPrinter: +class StdExpPathPrinter(printer_base): "Print a std::experimental::filesystem::path" def __init__(self, typename, val): - self.val = val - self.typename = typename - start = self.val['_M_cmpts']['_M_impl']['_M_start'] - finish = self.val['_M_cmpts']['_M_impl']['_M_finish'] - self.num_cmpts = int(finish - start) + self._val = val + self._typename = typename + start = self._val['_M_cmpts']['_M_impl']['_M_start'] + finish = self._val['_M_cmpts']['_M_impl']['_M_finish'] + self._num_cmpts = int(finish - start) def _path_type(self): - t = str(self.val['_M_type']) + t = str(self._val['_M_type']) if t[-9:] == '_Root_dir': return "root-directory" if t[-10:] == '_Root_name': @@ -1556,8 +1564,8 @@ class StdExpPathPrinter: return None def to_string(self): - path = "%s" % self.val['_M_pathname'] - if self.num_cmpts == 0: + path = "%s" % self._val['_M_pathname'] + if self._num_cmpts == 0: t = self._path_type() if t: path = '%s [%s]' % (path, t) @@ -1565,46 +1573,46 @@ class StdExpPathPrinter: class _iterator(Iterator): def __init__(self, cmpts, pathtype): - self.pathtype = pathtype - self.item = cmpts['_M_impl']['_M_start'] - self.finish = cmpts['_M_impl']['_M_finish'] - self.count = 0 + self._pathtype = pathtype + self._item = cmpts['_M_impl']['_M_start'] + self._finish = cmpts['_M_impl']['_M_finish'] + self._count = 0 def __iter__(self): return self def __next__(self): - if self.item == self.finish: + if self._item == self._finish: raise StopIteration - item = self.item.dereference() - count = self.count - self.count = self.count + 1 - self.item = self.item + 1 + item = self._item.dereference() + count = self._count + self._count = self._count + 1 + self._item = self._item + 1 path = item['_M_pathname'] - t = StdExpPathPrinter(self.pathtype, item)._path_type() + t = StdExpPathPrinter(self._pathtype, item)._path_type() if not t: t = count return ('[%s]' % t, path) def children(self): - return self._iterator(self.val['_M_cmpts'], self.typename) + return self._iterator(self._val['_M_cmpts'], self._typename) -class StdPathPrinter: +class StdPathPrinter(printer_base): "Print a std::filesystem::path" def __init__(self, typename, val): - self.val = val - self.typename = typename - impl = unique_ptr_get(self.val['_M_cmpts']['_M_impl']) - self.type = impl.cast(gdb.lookup_type('uintptr_t')) & 3 - if self.type == 0: - self.impl = impl + self._val = val + self._typename = typename + impl = unique_ptr_get(self._val['_M_cmpts']['_M_impl']) + self._type = impl.cast(gdb.lookup_type('uintptr_t')) & 3 + if self._type == 0: + self._impl = impl else: - self.impl = None + self._impl = None def _path_type(self): - t = str(self.type.cast(gdb.lookup_type(self.typename + '::_Type'))) + t = str(self._type.cast(gdb.lookup_type(self._typename + '::_Type'))) if t[-9:] == '_Root_dir': return "root-directory" if t[-10:] == '_Root_name': @@ -1612,8 +1620,8 @@ class StdPathPrinter: return None def to_string(self): - path = "%s" % self.val['_M_pathname'] - if self.type != 0: + path = "%s" % self._val['_M_pathname'] + if self._type != 0: t = self._path_type() if t: path = '%s [%s]' % (path, t) @@ -1621,7 +1629,7 @@ class StdPathPrinter: class _iterator(Iterator): def __init__(self, impl, pathtype): - self.pathtype = pathtype + self._pathtype = pathtype if impl: # We can't access _Impl::_M_size because _Impl is incomplete # so cast to int* to access the _M_size member at offset zero, @@ -1630,96 +1638,96 @@ class StdPathPrinter: char_type = gdb.lookup_type('char') impl = impl.cast(int_type.pointer()) size = impl.dereference() - #self.capacity = (impl + 1).dereference() + #self._capacity = (impl + 1).dereference() if hasattr(gdb.Type, 'alignof'): sizeof_Impl = max(2 * int_type.sizeof, cmpt_type.alignof) else: sizeof_Impl = 2 * int_type.sizeof begin = impl.cast(char_type.pointer()) + sizeof_Impl - self.item = begin.cast(cmpt_type.pointer()) - self.finish = self.item + size - self.count = 0 + self._item = begin.cast(cmpt_type.pointer()) + self._finish = self._item + size + self._count = 0 else: - self.item = None - self.finish = None + self._item = None + self._finish = None def __iter__(self): return self def __next__(self): - if self.item == self.finish: + if self._item == self._finish: raise StopIteration - item = self.item.dereference() - count = self.count - self.count = self.count + 1 - self.item = self.item + 1 + item = self._item.dereference() + count = self._count + self._count = self._count + 1 + self._item = self._item + 1 path = item['_M_pathname'] - t = StdPathPrinter(self.pathtype, item)._path_type() + t = StdPathPrinter(self._pathtype, item)._path_type() if not t: t = count return ('[%s]' % t, path) def children(self): - return self._iterator(self.impl, self.typename) + return self._iterator(self._impl, self._typename) -class StdPairPrinter: +class StdPairPrinter(printer_base): "Print a std::pair object, with 'first' and 'second' as children" def __init__(self, typename, val): - self.val = val + self._val = val class _iter(Iterator): "An iterator for std::pair types. Returns 'first' then 'second'." def __init__(self, val): - self.val = val - self.which = 'first' + self._val = val + self._which = 'first' def __iter__(self): return self def __next__(self): - if self.which is None: + if self._which is None: raise StopIteration - which = self.which + which = self._which if which == 'first': - self.which = 'second' + self._which = 'second' else: - self.which = None - return (which, self.val[which]) + self._which = None + return (which, self._val[which]) def children(self): - return self._iter(self.val) + return self._iter(self._val) def to_string(self): return None -class StdCmpCatPrinter: +class StdCmpCatPrinter(printer_base): "Print a comparison category object" def __init__(self, typename, val): - self.typename = typename[typename.rfind(':')+1:] - self.val = val['_M_value'] + self._typename = typename[typename.rfind(':')+1:] + self._val = val['_M_value'] def to_string(self): - if self.typename == 'strong_ordering' and self.val == 0: + if self._typename == 'strong_ordering' and self._val == 0: name = 'equal' else: names = {2: 'unordered', -1: 'less', 0: 'equivalent', 1: 'greater'} - name = names[int(self.val)] - return 'std::{}::{}'.format(self.typename, name) + name = names[int(self._val)] + return 'std::{}::{}'.format(self._typename, name) -class StdErrorCodePrinter: +class StdErrorCodePrinter(printer_base): "Print a std::error_code or std::error_condition" _system_is_posix = None # Whether std::system_category() use errno values. def __init__(self, typename, val): - self.val = val - self.typename = strip_versioned_namespace(typename) + self._val = val + self._typename = strip_versioned_namespace(typename) # Do this only once ... if StdErrorCodePrinter._system_is_posix is None: try: @@ -1807,14 +1815,14 @@ class StdErrorCodePrinter: return name.split('::')[-1] def to_string(self): - value = self.val['_M_value'] - cat = self.val['_M_cat'] + value = self._val['_M_value'] + cat = self._val['_M_cat'] name, alt_name, enum, is_errno = self._category_info(cat) if value == 0: default_cats = {'error_code': 'system', 'error_condition': 'generic'} - if name == default_cats[self._unqualified_name(self.typename)]: - return self.typename + ' = { }' # default-constructed value + if name == default_cats[self._unqualified_name(self._typename)]: + return self._typename + ' = { }' # default-constructed value strval = str(value) if is_errno and value != 0: @@ -1829,21 +1837,21 @@ class StdErrorCodePrinter: name = '"%s"' % name else: name = alt_name - return '%s = {%s: %s}' % (self.typename, name, strval) + return '%s = {%s: %s}' % (self._typename, name, strval) -class StdRegexStatePrinter: +class StdRegexStatePrinter(printer_base): "Print a state node in the NFA for a std::regex" def __init__(self, typename, val): - self.val = val - self.typename = typename + self._val = val + self._typename = typename def to_string(self): - opcode = str(self.val['_M_opcode']) + opcode = str(self._val['_M_opcode']) if opcode: opcode = opcode[25:] - next_id = self.val['_M_next'] + next_id = self._val['_M_next'] variants = {'repeat': 'alt', 'alternative': 'alt', 'subexpr_begin': 'subexpr', 'subexpr_end': 'subexpr', @@ -1856,113 +1864,113 @@ class StdRegexStatePrinter: v = variants[opcode] s = "opcode={}, next={}".format(opcode, next_id) - if v is not None and self.val['_M_' + v] is not None: - s = "{}, {}={}".format(s, v, self.val['_M_' + v]) + if v is not None and self._val['_M_' + v] is not None: + s = "{}, {}={}".format(s, v, self._val['_M_' + v]) return "{%s}" % (s) -class StdSpanPrinter: +class StdSpanPrinter(printer_base): "Print a std::span" - class iterator(Iterator): + class _iterator(Iterator): def __init__(self, begin, size): - self.count = 0 - self.begin = begin - self.size = size + self._count = 0 + self._begin = begin + self._size = size def __iter__(self): return self def __next__(self): - if self.count == self.size: + if self._count == self._size: raise StopIteration - count = self.count - self.count = self.count + 1 - return '[%d]' % count, (self.begin + count).dereference() + count = self._count + self._count = self._count + 1 + return '[%d]' % count, (self._begin + count).dereference() def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val if val.type.template_argument(1) == gdb.parse_and_eval('static_cast(-1)'): - self.size = val['_M_extent']['_M_extent_value'] + self._size = val['_M_extent']['_M_extent_value'] else: - self.size = val.type.template_argument(1) + self._size = val.type.template_argument(1) def to_string(self): - return '%s of length %d' % (self.typename, self.size) + return '%s of length %d' % (self._typename, self._size) def children(self): - return self.iterator(self.val['_M_ptr'], self.size) + return self._iterator(self._val['_M_ptr'], self._size) def display_hint(self): return 'array' -class StdInitializerListPrinter: +class StdInitializerListPrinter(printer_base): "Print a std::initializer_list" def __init__(self, typename, val): - self.typename = typename - self.val = val - self.size = val['_M_len'] + self._typename = typename + self._val = val + self._size = val['_M_len'] def to_string(self): - return '%s of length %d' % (self.typename, self.size) + return '%s of length %d' % (self._typename, self._size) def children(self): - return StdSpanPrinter.iterator(self.val['_M_array'], self.size) + return StdSpanPrinter._iterator(self._val['_M_array'], self._size) def display_hint(self): return 'array' -class StdAtomicPrinter: +class StdAtomicPrinter(printer_base): "Print a std:atomic" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val - self.shptr_printer = None - self.value_type = self.val.type.template_argument(0) - if self.value_type.tag is not None: - typ = strip_versioned_namespace(self.value_type.tag) + self._typename = strip_versioned_namespace(typename) + self._val = val + self._shptr_printer = None + self._value_type = self._val.type.template_argument(0) + if self._value_type.tag is not None: + typ = strip_versioned_namespace(self._value_type.tag) if typ.startswith('std::shared_ptr<') or typ.startswith('std::weak_ptr<'): impl = val['_M_impl'] - self.shptr_printer = SharedPointerPrinter(typename, impl) + self._shptr_printer = SharedPointerPrinter(typename, impl) self.children = self._shptr_children def _shptr_children(self): - return SmartPtrIterator(self.shptr_printer.pointer) + return SmartPtrIterator(self._shptr_printer._pointer) def to_string(self): - if self.shptr_printer is not None: - return self.shptr_printer.to_string() - - if self.value_type.code == gdb.TYPE_CODE_INT: - val = self.val['_M_i'] - elif self.value_type.code == gdb.TYPE_CODE_FLT: - val = self.val['_M_fp'] - elif self.value_type.code == gdb.TYPE_CODE_PTR: - val = self.val['_M_b']['_M_p'] - elif self.value_type.code == gdb.TYPE_CODE_BOOL: - val = self.val['_M_base']['_M_i'] + if self._shptr_printer is not None: + return self._shptr_printer.to_string() + + if self._value_type.code == gdb.TYPE_CODE_INT: + val = self._val['_M_i'] + elif self._value_type.code == gdb.TYPE_CODE_FLT: + val = self._val['_M_fp'] + elif self._value_type.code == gdb.TYPE_CODE_PTR: + val = self._val['_M_b']['_M_p'] + elif self._value_type.code == gdb.TYPE_CODE_BOOL: + val = self._val['_M_base']['_M_i'] else: - val = self.val['_M_i'] - return '%s<%s> = { %s }' % (self.typename, str(self.value_type), val) + val = self._val['_M_i'] + return '%s<%s> = { %s }' % (self._typename, str(self._value_type), val) -class StdFormatArgsPrinter: +class StdFormatArgsPrinter(printer_base): "Print a std::basic_format_args" # TODO: add printer for basic_format_arg and print out children. # TODO: add printer for __format::_ArgStore. def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def to_string(self): - targs = get_template_arg_list(self.val.type) + targs = get_template_arg_list(self._val.type) char_type = get_template_arg_list(targs[0])[1] if char_type == gdb.lookup_type('char'): typ = 'std::format_args' @@ -1971,32 +1979,32 @@ class StdFormatArgsPrinter: else: typ = 'std::basic_format_args' - size = self.val['_M_packed_size'] + size = self._val['_M_packed_size'] if size == 1: return "%s with 1 argument" % (typ) if size == 0: - size = self.val['_M_unpacked_size'] + size = self._val['_M_unpacked_size'] return "%s with %d arguments" % (typ, size) def std_ratio_t_tuple(ratio_type): # TODO use reduced period i.e. duration::period - period = self.val.type.template_argument(1) + period = self._val.type.template_argument(1) num = period.template_argument(0) den = period.template_argument(1) return (num, den) -class StdChronoDurationPrinter: +class StdChronoDurationPrinter(printer_base): "Print a std::chrono::duration" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def _ratio(self): # TODO use reduced period i.e. duration::period - period = self.val.type.template_argument(1) + period = self._val.type.template_argument(1) num = period.template_argument(0) den = period.template_argument(1) return (num, den) @@ -2023,21 +2031,21 @@ class StdChronoDurationPrinter: return "[{}/{}]s".format(num, den) def to_string(self): - r = self.val['__r'] + r = self._val['__r'] if r.type.strip_typedefs().code == gdb.TYPE_CODE_FLT: r = "%g" % r return "std::chrono::duration = {{ {}{} }}".format(r, self._suffix()) -class StdChronoTimePointPrinter: +class StdChronoTimePointPrinter(printer_base): "Print a std::chrono::time_point" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def _clock(self): - clock = self.val.type.template_argument(0) + clock = self._val.type.template_argument(0) name = strip_versioned_namespace(clock.name) if name == 'std::chrono::_V2::system_clock' \ or name == 'std::chrono::system_clock': @@ -2057,7 +2065,7 @@ class StdChronoTimePointPrinter: def to_string(self, abbrev=False): clock, offset = self._clock() - d = self.val['__d'] + d = self._val['__d'] r = d['__r'] printer = StdChronoDurationPrinter(d.type.name, d) suffix = printer._suffix() @@ -2076,16 +2084,16 @@ class StdChronoTimePointPrinter: return '%s = { %s }' % (clock, s) -class StdChronoZonedTimePrinter: +class StdChronoZonedTimePrinter(printer_base): "Print a std::chrono::zoned_time" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def to_string(self): - zone = self.val['_M_zone'].dereference()['_M_name'] - time = self.val['_M_tp'] + zone = self._val['_M_zone'].dereference()['_M_name'] + time = self._val['_M_tp'] printer = StdChronoTimePointPrinter(time.type.name, time) time = printer.to_string(True) return 'std::chrono::zoned_time = {{ {} {} }}'.format(zone, time) @@ -2098,16 +2106,16 @@ weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] -class StdChronoCalendarPrinter: +class StdChronoCalendarPrinter(printer_base): "Print a std::chrono::day, std::chrono::month, std::chrono::year etc." def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def to_string(self): - val = self.val - typ = self.typename + val = self._val + typ = self._typename if 'month' in typ and typ != 'std::chrono::year_month_day_last': m = val['_M_m'] if typ.startswith('std::chrono::year'): @@ -2161,53 +2169,53 @@ class StdChronoCalendarPrinter: return '{:02}:{:02}:{:02}{}'.format(h, m, s, fract) -class StdChronoTimeZonePrinter: +class StdChronoTimeZonePrinter(printer_base): "Print a chrono::time_zone or chrono::time_zone_link" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def to_string(self): - str = '%s = %s' % (self.typename, self.val['_M_name']) - if self.typename.endswith("_link"): - str += ' -> %s' % (self.val['_M_target']) + str = '%s = %s' % (self._typename, self._val['_M_name']) + if self._typename.endswith("_link"): + str += ' -> %s' % (self._val['_M_target']) return str -class StdChronoLeapSecondPrinter: +class StdChronoLeapSecondPrinter(printer_base): "Print a chrono::leap_second" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def to_string(self): - date = self.val['_M_s']['__r'] + date = self._val['_M_s']['__r'] neg = '+-'[date < 0] - return '%s %d (%c)' % (self.typename, abs(date), neg) + return '%s %d (%c)' % (self._typename, abs(date), neg) -class StdChronoTzdbPrinter: +class StdChronoTzdbPrinter(printer_base): "Print a chrono::tzdb" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def to_string(self): - return '%s %s' % (self.typename, self.val['version']) + return '%s %s' % (self._typename, self._val['version']) -class StdChronoTimeZoneRulePrinter: +class StdChronoTimeZoneRulePrinter(printer_base): "Print a chrono::time_zone rule" def __init__(self, typename, val): - self.typename = strip_versioned_namespace(typename) - self.val = val + self._typename = strip_versioned_namespace(typename) + self._val = val def to_string(self): - on = self.val['on'] + on = self._val['on'] kind = on['kind'] month = months[on['month']] suffixes = {1: 'st', 2: 'nd', 3: 'rd', @@ -2230,24 +2238,24 @@ class StdChronoTimeZoneRulePrinter: direction[1], month, ordinal_day) return 'time_zone rule {} from {} to {} starting on {}'.format( - self.val['name'], self.val['from'], self.val['to'], start) + self._val['name'], self._val['from'], self._val['to'], start) -class StdLocalePrinter: +class StdLocalePrinter(printer_base): "Print a std::locale" def __init__(self, typename, val): - self.val = val - self.typename = typename + self._val = val + self._typename = typename def to_string(self): - names = self.val['_M_impl']['_M_names'] + names = self._val['_M_impl']['_M_names'] mod = '' if names[0] == 0: name = '*' else: - cats = gdb.parse_and_eval(self.typename + '::_S_categories') - ncat = gdb.parse_and_eval(self.typename + '::_S_categories_size') + cats = gdb.parse_and_eval(self._typename + '::_S_categories') + ncat = gdb.parse_and_eval(self._typename + '::_S_categories_size') n = names[0].string() cat = cats[0].string() name = '{}={}'.format(cat, n) @@ -2284,7 +2292,7 @@ class RxPrinter(object): def __init__(self, name, function): super(RxPrinter, self).__init__() self.name = name - self.function = function + self._function = function self.enabled = True def invoke(self, value): @@ -2295,7 +2303,7 @@ class RxPrinter(object): if hasattr(gdb.Value, "referenced_value"): value = value.referenced_value() - return self.function(self.name, value) + return self._function(self.name, value) # A pretty-printer that conforms to the "PrettyPrinter" protocol from # gdb.printing. It can also be used directly as an old-style printer. @@ -2305,20 +2313,20 @@ class Printer(object): def __init__(self, name): super(Printer, self).__init__() self.name = name - self.subprinters = [] - self.lookup = {} + self._subprinters = [] + self._lookup = {} self.enabled = True - self.compiled_rx = re.compile('^([a-zA-Z0-9_:]+)(<.*>)?$') + self._compiled_rx = re.compile('^([a-zA-Z0-9_:]+)(<.*>)?$') def add(self, name, function): # A small sanity check. # FIXME - if not self.compiled_rx.match(name): + if not self._compiled_rx.match(name): raise ValueError( 'libstdc++ programming error: "%s" does not match' % name) printer = RxPrinter(name, function) - self.subprinters.append(printer) - self.lookup[name] = printer + self._subprinters.append(printer) + self._lookup[name] = printer # Add a name using _GLIBCXX_BEGIN_NAMESPACE_VERSION. def add_version(self, base, name, function): @@ -2351,7 +2359,7 @@ class Printer(object): # All the types we match are template types, so we can use a # dictionary. - match = self.compiled_rx.match(typename) + match = self._compiled_rx.match(typename) if not match: return None @@ -2361,8 +2369,8 @@ class Printer(object): if hasattr(gdb.Value, "referenced_value"): val = val.referenced_value() - if basename in self.lookup: - return self.lookup[basename].invoke(val) + if basename in self._lookup: + return self._lookup[basename].invoke(val) # Cannot find a pretty printer. Return None. return None @@ -2384,7 +2392,7 @@ class TemplateTypePrinter(object): def __init__(self, name, defargs): self.name = name - self.defargs = defargs + self._defargs = defargs self.enabled = True class _recognizer(object): @@ -2392,8 +2400,8 @@ class TemplateTypePrinter(object): def __init__(self, name, defargs): self.name = name - self.defargs = defargs - # self.type_obj = None + self._defargs = defargs + # self._type_obj = None def recognize(self, type_obj): """ @@ -2416,7 +2424,7 @@ class TemplateTypePrinter(object): # The actual template argument in the type: targ = template_args[n] # The default template argument for the class template: - defarg = self.defargs.get(n) + defarg = self._defargs.get(n) if defarg is not None: # Substitute other template arguments into the default: defarg = defarg.format(*template_args) @@ -2469,7 +2477,7 @@ class TemplateTypePrinter(object): def instantiate(self): "Return a recognizer object for this type printer." - return self._recognizer(self.name, self.defargs) + return self._recognizer(self.name, self._defargs) def add_one_template_type_printer(obj, name, defargs): @@ -2533,58 +2541,59 @@ class FilteringTypePrinter(object): """ def __init__(self, template, name, targ1=None): - self.template = template + self._template = template self.name = name - self.targ1 = targ1 + self._targ1 = targ1 self.enabled = True class _recognizer(object): "The recognizer class for FilteringTypePrinter." def __init__(self, template, name, targ1): - self.template = template + self._template = template self.name = name - self.targ1 = targ1 - self.type_obj = None + self._targ1 = targ1 + self._type_obj = None def recognize(self, type_obj): """ - If type_obj starts with self.template and is the same type as + If type_obj starts with self._template and is the same type as self.name then return self.name, otherwise None. """ if type_obj.tag is None: return None - if self.type_obj is None: - if self.targ1 is not None: - if not type_obj.tag.startswith('{}<{}'.format(self.template, self.targ1)): + if self._type_obj is None: + if self._targ1 is not None: + if not type_obj.tag.startswith('{}<{}'.format(self._template, self._targ1)): # Filter didn't match. return None - elif not type_obj.tag.startswith(self.template): + elif not type_obj.tag.startswith(self._template): # Filter didn't match. return None try: - self.type_obj = gdb.lookup_type(self.name).strip_typedefs() + self._type_obj = gdb.lookup_type( + self.name).strip_typedefs() except: pass - if self.type_obj is None: + if self._type_obj is None: return None - if gdb.types.get_basic_type(self.type_obj) == gdb.types.get_basic_type(type_obj): + if gdb.types.get_basic_type(self._type_obj) == gdb.types.get_basic_type(type_obj): return strip_inline_namespaces(self.name) # Workaround ambiguous typedefs matching both std:: and std::__cxx11:: symbols. - if self.template.split('::')[-1] == 'basic_string': - if self.type_obj.tag.replace('__cxx11::', '') == type_obj.tag.replace('__cxx11::', ''): + if self._template.split('::')[-1] == 'basic_string': + if self._type_obj.tag.replace('__cxx11::', '') == type_obj.tag.replace('__cxx11::', ''): return strip_inline_namespaces(self.name) return None def instantiate(self): "Return a recognizer object for this type printer." - return self._recognizer(self.template, self.name, self.targ1) + return self._recognizer(self._template, self.name, self._targ1) def add_one_type_printer(obj, template, name, targ1=None): From patchwork Thu Sep 28 17:46:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 146237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3490618vqu; Thu, 28 Sep 2023 10:48:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPAMCK9pQfIbe68x5NDVBIdH10TOpsiVyw9B33JIMlTrvNOexrjszPQxtr97fbTWWsh1uH X-Received: by 2002:a17:906:32d0:b0:9b2:a7c9:fcfe with SMTP id k16-20020a17090632d000b009b2a7c9fcfemr1461046ejk.36.1695923330305; Thu, 28 Sep 2023 10:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695923330; cv=none; d=google.com; s=arc-20160816; b=pgk9q0qqmZA3XRzgAwEyM8i+Yeoe2pKPIDFhogugzSSd+zYvqwtxLON1G+gmggj7e7 VxV9oY/ianslbxk50uA/V9Nj6rdqmmMRaS8m5OCBeQ6YGWur11iTIMQnpxndcfEJeJRM dvpECCMEz9fotgf4N+eJbYXg8lTsi6nROprVP3rx/D7C8nfGZV0YKwdrjC1qaaAaW1/4 8pQOPZAcLO9DIDN3xkj7VkCB7IH0U/5k30k/suDe95aOf2Hxy6ezhUXtjtuEgzFj5DHM gBq7EN++p8TWacE7PpbDGGEAFT88g048AlDmyJNN4iqRpOwYBK4OUVCsaZBZZGNBf8ia yaCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=l2RrlGNByxcZfBqyeFvXiBTS4t+5kprkJSJHKYk9L70=; fh=Ogh3zaPUNpdNYHofIVNHsbX+D3lwaT1T8Jhe/MolwAA=; b=Q1Ciy+5yIrPzITSmTjvqo0tpXUrE/Y12mBkeW/YQ4oLB+bV+BLoZJbjf93/AFH6ACp E8xH0Ii0KCW1xwsCj0E5SGJ6L2x7aDXqNsgPRokZof4hdG5gXPWMPj0bIracUvqG+NFQ 92ITcFtapgCCrMkKms4gj/vQVxONA6f+UlXqC5Tsitw4uT5r4fDX9b4DnIgUje5j3LY3 by+SSOaHHh3h+d1IuSd4lHuF+UM6iSxewcpFlnaI3FzY/Mc4fUAxjIy2tHIHmGf4JXvg fVeul3J7AvhWOIACZtGl0t+Q0DeZp+oyVwBYOQ9+KQssii3pf3gwwH2Q61Hnl4Rn3LQE 45KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=WB9lo3j0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v18-20020a170906859200b00992e26642ddsi6667414ejx.251.2023.09.28.10.48.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:48:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=WB9lo3j0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 867913871037 for ; Thu, 28 Sep 2023 17:47:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id D5D1838582A1 for ; Thu, 28 Sep 2023 17:46:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5D1838582A1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-35133097583so32748775ab.1 for ; Thu, 28 Sep 2023 10:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1695923203; x=1696528003; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l2RrlGNByxcZfBqyeFvXiBTS4t+5kprkJSJHKYk9L70=; b=WB9lo3j0PLD8CUdIKvE8t7Mu4rD2RMifpurpGu+BPca6e5g9X998WrPGK3LSt6EYD0 CGAuTFTgUkyIrnUuA1rDNHMIKNqqAnIT/7WFbKSsqseQZu5s0zVnKDHjUMN16100lx7m H97GUobwAoWJ/AatMbD+WjFhISwcO7yfZ0Gbv9sVa8q+aJClZJqwZQKVYP50LXx6E1BG XtebitkYz+nV1gOHN0vOhmNJSRoIVrffPf6NFcIb1k94otbxaH1MJNm9oKbPnM9uR7gT G0QqgoyyzEzzeugnSJH96O6OfSGOdn8HmLtNH5WYQTefBS3yUoW8wKG6FZFsGMPW2gne 7nag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695923203; x=1696528003; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l2RrlGNByxcZfBqyeFvXiBTS4t+5kprkJSJHKYk9L70=; b=hPttSxsoIo1IMrqIbI6nEvN8Q2AeQ66tnAktUYVfBlfD5UU8/pLw2BAlcsWRBYXryW PaVlLuahbq8UInXc/xEi9qy1tsctlYEMKwEvaQ5Uyb6VoFVkb4S/qt4pnYl2sK+rabOF 1loTvp2wMcRkfr80A+7gneC8s0/WRyCyumCtMvChl71zIQaUbpzd5Dz9GoR+ZiEi3//G bcc2FwKsjH8yXP/vz6ROcTkiaNia1XBAqIqyBcFxYESTiXnnzGUTHYj3UmtjmMtQC1Mv 8MSx8+eraBHATf/5F0CdtTny+IwMVZWUVPZilHNO4ySBF4VJ48qlAaWk09MSFXcrq6qL acuw== X-Gm-Message-State: AOJu0Yxx2CUeDDIe/UKCEhF3Rssd4zHf+8IeG3Ds+flKIiUuVqddipEE HCOHOjJmkNYGJ/hTSfgJJPjLker3Tpntm1Tcn8wkyg== X-Received: by 2002:a05:6e02:be8:b0:34c:bc7e:896c with SMTP id d8-20020a056e020be800b0034cbc7e896cmr1660356ilu.1.1695923203156; Thu, 28 Sep 2023 10:46:43 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id p6-20020a92d486000000b0034fc8c1c24fsm3450963ilg.54.2023.09.28.10.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:46:42 -0700 (PDT) From: Tom Tromey To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Tom Tromey Subject: [PATCH 3/7] libstdc++: Remove unused Python imports Date: Thu, 28 Sep 2023 11:46:26 -0600 Message-Id: <20230928174630.4004388-4-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928174630.4004388-1-tromey@adacore.com> References: <20230928174630.4004388-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778304501787346425 X-GMAIL-MSGID: 1778304501787346425 flake8 pointed out some unused imports. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py: Don't import 'os'. * python/libstdcxx/v6/__init__.py: Don't import 'gdb'. --- libstdc++-v3/python/libstdcxx/v6/__init__.py | 2 -- libstdc++-v3/python/libstdcxx/v6/printers.py | 1 - 2 files changed, 3 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/__init__.py b/libstdc++-v3/python/libstdcxx/v6/__init__.py index df654acd0c2..8b2cbc60a1b 100644 --- a/libstdc++-v3/python/libstdcxx/v6/__init__.py +++ b/libstdc++-v3/python/libstdcxx/v6/__init__.py @@ -13,8 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import gdb - # Load the xmethods if GDB supports them. def gdb_has_xmethods(): try: diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index bbc4375541f..8d44244afb0 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -19,7 +19,6 @@ import gdb import itertools import re import sys -import os import errno import datetime From patchwork Thu Sep 28 17:46:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 146241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3493112vqu; Thu, 28 Sep 2023 10:53:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwQ/zK/oCFA3i77LvNrF35KFVNrM7wBK5aZpLZsIWjGD9hJFCyYacNW2a9bXbNnCmHNCi7 X-Received: by 2002:a05:6512:360d:b0:503:446:b468 with SMTP id f13-20020a056512360d00b005030446b468mr1727408lfs.67.1695923620171; Thu, 28 Sep 2023 10:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695923620; cv=none; d=google.com; s=arc-20160816; b=s4RsayjU98ztcqGL7xl085Wd6DRX7HnjG8jjzrSk5Z9EHaV+fbDCz1l5KYEW5nPvOv hFxpc2vdN7cgBIcuWur1OW8Hh0HV1hGfLHWTeETB5kkJguneHy4/TCcyx/cQ1cpOJcQR WhmL31PLMCJfcRoaSItksMwCCZjAl9HF6BOyOAYq+vd504q/YJYhJeR8WnwzFTQkaAr2 HojRAr+HK+95/xwcvss4X9rVV3lUokpAssPK6C/ehPyHA1NEuL1bOo980+TyRKGtEKds MxgtENNAyjiFWqx59/RoKvsYd7E5o+UHumoPQHIlI4nzyd4qCoD1Cn8qhFWKiKAgue+b /zfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=g65ZFUqbpWfKghBHY26Hxt9+z+42jGr00b4/SOFo5+I=; fh=Ogh3zaPUNpdNYHofIVNHsbX+D3lwaT1T8Jhe/MolwAA=; b=wQTBKgVIBFXoEh1J8rOHT7eXg4+ZIQYepa4cz4eEUhbfSeNOHPXnBUXHWfh24RqGmu 6jcd7wM31D/BiZCa/qJpYPSJ74F8s9E5O1KpxAyJkfbvYAeJoBc/9wR4+DRTwkTQXHmr DZbBZpyV4WsouE/i5oHBQH6FT2NVrRNjl1HN0ao4M6bKai0RJSIisimtoYxGb1iQCNmP xqfCm78gB37mA9ePtxweQOWzobIVpKf/8i0A8JWA+gvlTfkjxWPyF4DkFhjpOyPHUj4B YRy4Or8GjB9I+7rxPJL1/F2KUHwBuH0IajpRE3NPiIc7OlO/KzN7oxqf1sJKtcVG6kWG vd5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=aWzZCe2U; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h22-20020aa7c956000000b00530df47f178si14405695edt.309.2023.09.28.10.53.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=aWzZCe2U; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1F49C38768A7 for ; Thu, 28 Sep 2023 17:48:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id 805203861858 for ; Thu, 28 Sep 2023 17:46:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 805203861858 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-3513fa06bafso28039935ab.3 for ; Thu, 28 Sep 2023 10:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1695923203; x=1696528003; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g65ZFUqbpWfKghBHY26Hxt9+z+42jGr00b4/SOFo5+I=; b=aWzZCe2U+W/HkBsrexif5XXW02UQYuPdpCKQz61LkVVTDNnl8+zWmuMC/+x+JHS+kU SAgmJ/Q7kzbt4qw034W0S9ca6jeslUzvVOGbVJNrX95Bl9KE7i1GGjy1B8/ejfPvmObV f5/U3MW1rTXAAgC5OU20GEgraALydBXrR7DIvgExBKWrTeNkJ2NEvMZOPj3GVfL4ozwP Up0hxNcc30iherDZlS7ECw6k5ojNunS0mqfXmWFSgQHRmcwlVB0ceX5oN9PTwm/PS6hq aBMlfO+xmXZVXe3/m/POKa6DqszonEwcJvXBNm6dO3UNjoBSpsZnnOLrI5Yo1GPgknY3 Lt/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695923203; x=1696528003; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g65ZFUqbpWfKghBHY26Hxt9+z+42jGr00b4/SOFo5+I=; b=By14bDaozW8qzOWH+yUSkg13ffo/N5vGkfd0TffrZjus8+08pTPFnTuki+oRuU0dOF JRDlFfxi+T1jxJ+nYuqhjJbu9aCd+q5EQ0sPHpeOVExgyTLZ+RjzpigvI+JSSbTaLGOb a8vTP5fTW/HwGlvaYqlArPRPaIJGf9GcXMZtHnNV/4sonOmKsgKRKHqylz0gs8eOArNn rBxWJGYutpDfq3veHw8q/cATJgqw1dEwsBSLSx0jn3tAjeb4/gs7bkXqheoau4TThy9G 4NZTYVy80yxEXBL3hyce5ek8ZLZyumvECi63THanCDgOsjBpzGO68RzVrH8cAngoVHH4 qH6Q== X-Gm-Message-State: AOJu0YwntSqzsPGX3ThRIgTzib4agf0DxdwBZi2mreslj+ArkZ2VIbOF 9k66YgoPviEt89GxSA6vWwC9If3bKNS2EsYzIxhdHA== X-Received: by 2002:a05:6e02:1307:b0:351:b22:af5c with SMTP id g7-20020a056e02130700b003510b22af5cmr1376617ilr.32.1695923203790; Thu, 28 Sep 2023 10:46:43 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id p6-20020a92d486000000b0034fc8c1c24fsm3450963ilg.54.2023.09.28.10.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:46:43 -0700 (PDT) From: Tom Tromey To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Tom Tromey Subject: [PATCH 4/7] libstdc++: Remove unused locals from printers.py Date: Thu, 28 Sep 2023 11:46:27 -0600 Message-Id: <20230928174630.4004388-5-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928174630.4004388-1-tromey@adacore.com> References: <20230928174630.4004388-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778304805756009072 X-GMAIL-MSGID: 1778304805756009072 flake8 pointed out some unused local variables in the libstdc++ pretty-printers. This removes them. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdExpOptionalPrinter.__init__, lookup_node_type): Remove unused variables. --- libstdc++-v3/python/libstdcxx/v6/printers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 8d44244afb0..6bf4fe891fd 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -169,7 +169,7 @@ def lookup_node_type(nodename, containertype): valtype = valtype.strip_typedefs() try: return lookup_templ_spec(nodename, valtype) - except gdb.error as e: + except gdb.error: # For debug mode containers the node is in std::__cxx1998. if is_member_of_namespace(nodename, 'std'): if is_member_of_namespace(containertype, 'std::__cxx1998', @@ -1423,7 +1423,6 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter): "Print a std::optional or std::experimental::optional" def __init__(self, typename, val): - valtype = self._recognize(val.type.template_argument(0)) typename = strip_versioned_namespace(typename) self._typename = re.sub( '^std::(experimental::|)(fundamentals_v\d::|)(.*)', r'std::\1\3', typename, 1) From patchwork Thu Sep 28 17:46:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 146239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3492825vqu; Thu, 28 Sep 2023 10:53:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqNulZx7BqJmqHtx8yRNIfSmzuqtkGhKPrv+PpI6wXpP3RiNXczF9IMr9UlP+SqdfKU+nN X-Received: by 2002:a05:6402:14ce:b0:533:87c9:4a81 with SMTP id f14-20020a05640214ce00b0053387c94a81mr1893493edx.29.1695923587219; Thu, 28 Sep 2023 10:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695923587; cv=none; d=google.com; s=arc-20160816; b=lyP3swktrVwuXcjj2lrzjZMk5sTc9lbHWZUo23CMocSVJL3e41rehqN3igxfrMVTA9 Zhquy0H9GV4jKidCqxTNh1SFx2Bngw7Q0Lxc8hWgDAkdqshCIO8kPfMuaHKjIXNFa+VZ jcp0rObfWFBVwzXMnRUZMp/DIa+/8HoUjZTtyVYZ3UsbhnAvvrrA+h098iCmNmg0Eu1z GDYX/Nt/Y9RUehcx1Q44iuLcjGioLbpMaUZLD7faKYCr8QAT3zYRq6AE+4GRfpxgn16Y 2DQVObaZBZggrlxtUXtH5RVnXsTw484gWBzzny588lQCDVsaNO6wqQiwTvO5y3JlUcc0 ncfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=lqL2GzFnpSx3UUgHDf9JMlOrnoCg9AXRMAONIgiIlRo=; fh=Ogh3zaPUNpdNYHofIVNHsbX+D3lwaT1T8Jhe/MolwAA=; b=AB5Cy2FvHcPJYK4oKjxp+ubP1fMiRuT/TjfuuTHZnwsaCO0njCA5m34Npw7PvR8nrB jAtJJBIbojcFQRWdFCSYG/v/1vx3DQ5IhX2Gbg3YEnT/0htD+zJfRbFJnvGKhSsSUlG6 uvn0CZSF9I/4mCyeM19bUe4XKwguEE9VdbWHjj7IFM9sN9AlhgQAq7lLsxN+i49tcbzb vyjfNUkt4nkSa/z1V64yLuxZJ9ljoDJm7XtxSJpMT3+myZUzDaTWk05QCr/RRCvgw3QP i8uUFg6qmqJmH55fYXHY30bzrPFytzXe9Te7rQ2MIu4CvGqpJL3QbfPOPtRDncO6Jr8I hwDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=Pa+B9DD4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r7-20020aa7cfc7000000b00529fae6ac14si14672810edy.158.2023.09.28.10.53.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:53:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=Pa+B9DD4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D515538323C8 for ; Thu, 28 Sep 2023 17:48:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 1FA7B386192A for ; Thu, 28 Sep 2023 17:46:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1FA7B386192A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-3513dcd38ebso26518095ab.1 for ; Thu, 28 Sep 2023 10:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1695923204; x=1696528004; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lqL2GzFnpSx3UUgHDf9JMlOrnoCg9AXRMAONIgiIlRo=; b=Pa+B9DD4RspaZdl/zSfmsyTAAdKqVq/HvOfEpA0F3BRo5jfpPrqYlRExm+q15zuoHV HqF1QDhNQArL2MlkzbCI1hyDWpEPjQWL8PB95pvOciRK5MPvciUI12Pt19NBuJMKzQGO bLVuZyieHRIDDC6LA9bf28J/mdz14zuFzDSdgG9Z2w1PSqoPb4EJQZ1ZUjvRpMRq8dVG 74O2WbdKgHwm7TIqeHFVIA2Rn8UPiHTAC9Ybn4kv6fby6Lm2VRCuHS8fbK3vgTxIkYeG 5yPMlk6Y4iUf3ydaOvDZHCqEoqqwtlOnNISRTvekjiSSr/O1TiItW1U2qUla9q6Og8vG 7C6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695923204; x=1696528004; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lqL2GzFnpSx3UUgHDf9JMlOrnoCg9AXRMAONIgiIlRo=; b=jjPsjTnJj+wWN2l0JYGbHlpKO7K2vD9nKfNB7M7JP2KXAd5sR+o1WjSxOeKq4CJ4o5 y1aO4NC4z+h+bomn5HJm5qDSXxR7/AsiZ6Chuy23Me5xTkbpCXgzDFkNrA3K14arzST8 UyvuzOUkIiS5T3w5GOu0db2K9K/kQZ80BxkmruIkLRgVM12IaS20JLXnC/yK/qILhbco l/I3uaN0XugZ9zJU37KlSP7A8FjnkCgF+TCQdItp4JEyo1lGS7fVk+7lVHXNo+uA7Cjd 3jnUOElI3NQmHxXorFFKvv+Hr2YiK5fe2nrfk9BZ+KQloNr52urWgN7nPvkujbMTlcZU oCAA== X-Gm-Message-State: AOJu0YwbfAoHlRNNVmHY7511piA25mHmf8nzMxtTo3DEmu5VoNVKqV+e Ys5xjZnvDZapnLPW+SLkQB5dkof1IPf2PfgxMj45Kg== X-Received: by 2002:a05:6e02:1543:b0:34f:e4e1:b4aa with SMTP id j3-20020a056e02154300b0034fe4e1b4aamr2010352ilu.14.1695923204438; Thu, 28 Sep 2023 10:46:44 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id p6-20020a92d486000000b0034fc8c1c24fsm3450963ilg.54.2023.09.28.10.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:46:44 -0700 (PDT) From: Tom Tromey To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Tom Tromey Subject: [PATCH 5/7] libstdc++: Remove std_ratio_t_tuple Date: Thu, 28 Sep 2023 11:46:28 -0600 Message-Id: <20230928174630.4004388-6-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928174630.4004388-1-tromey@adacore.com> References: <20230928174630.4004388-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778304771391583196 X-GMAIL-MSGID: 1778304771391583196 This removes the std_ratio_t_tuple function from the Python pretty-printer code. It is not used. Apparently the relevant parts were moved to StdChronoDurationPrinter._ratio at some point in the past. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (std_ratio_t_tuple): Remove. --- libstdc++-v3/python/libstdcxx/v6/printers.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 6bf4fe891fd..94ac9232da7 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -1985,14 +1985,6 @@ class StdFormatArgsPrinter(printer_base): return "%s with %d arguments" % (typ, size) -def std_ratio_t_tuple(ratio_type): - # TODO use reduced period i.e. duration::period - period = self._val.type.template_argument(1) - num = period.template_argument(0) - den = period.template_argument(1) - return (num, den) - - class StdChronoDurationPrinter(printer_base): "Print a std::chrono::duration" From patchwork Thu Sep 28 17:46:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 146240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3492909vqu; Thu, 28 Sep 2023 10:53:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1A55VqNnaQ6LDXp/SSjFSkWtvV+ucACl2mk5J9vsizZXs/o8pNteD0voAw0hPM2YZ/5tY X-Received: by 2002:a17:906:304c:b0:9ae:3d8e:b635 with SMTP id d12-20020a170906304c00b009ae3d8eb635mr1747747ejd.24.1695923599552; Thu, 28 Sep 2023 10:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695923599; cv=none; d=google.com; s=arc-20160816; b=NXyAL2SrCZ3DF7c4vAQfRQi+IgOq3oPqarbCCUhFsQFmq76DkNWA10r7brcRtSVpdZ rENHBnWH8ywIC7DcenJhNBjQubEcq/LT+kn5Kq228gdW/pJUXYPZBozsw+A8PWBfxuNO 1qYibU82G/CsW+fyyDpyLc5c0m1rJpxYPsLGQT3XqA7vyzfoJRnLW2blOXFJYhUJ1QT3 jNJcbpeWZ6XXD1e0cTQBkBWvd9qIuXhag0L0kdT+upJRlHbLYIBUTGR/seH2d49uidQq cTpdwXhH6VaB9Tv16mEKCGc0ZBLy0RsEDIEWOAkBRFkpv7eJedEG3PMP0OPuC6aYNGgj NgGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=SnUC980l8pjVO+FjtthJbSqfKHVI5/r5XXX90PwzZo4=; fh=Ogh3zaPUNpdNYHofIVNHsbX+D3lwaT1T8Jhe/MolwAA=; b=YSnpAEm42K2QOoe302Nrsbh/HX0kXeoU8bH6YU0rhOYT571keJbovXOGLq3yxNuN5f sC1LiCMwYAa3Wd79ZeX5zrbl4+FJuAzVF7ngJyfDEhbPgp3EPfLEcaxs5c3VzwxaoaBx ZnSgfJugxP5MbDTFuGbjfAnn4LjIMhbTf7W4BSLR8GOuAvHNBbWubVkZskvF6+1A350z oPPZD+dNQySyWX1G3TJRWwLcLTeL1GV963L5BS+j44/FUGYxBkho0wZLI7ZK4oO/2HMd H4azP36vPcuoCGnrIF7QBrN1WTMxEbsZk7jdv4nx0p+jQLSfQrmVBiqcR5BDV+zrpq3j w0XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=GwophZ+z; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y3-20020a1709064b0300b009ad87ec8271si16042162eju.1.2023.09.28.10.53.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:53:19 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=GwophZ+z; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4D0B43942009 for ; Thu, 28 Sep 2023 17:48:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id C1F0E38618C1 for ; Thu, 28 Sep 2023 17:46:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C1F0E38618C1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-3525e6dc5dfso329165ab.3 for ; Thu, 28 Sep 2023 10:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1695923205; x=1696528005; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SnUC980l8pjVO+FjtthJbSqfKHVI5/r5XXX90PwzZo4=; b=GwophZ+zpicQOytmWsMNNfJId0e4xRzeX1XzPQ7GMmPgdPdmby8RxXuvPuZIJBG1Wd fvAEfWULAx3Rws26aZ42sJ6Yn1CFpbO9GDpEwwEolPSMGdOR2Yfgyb+AUadUeiTsMfTN Nz0R32kqqbX8A942mDslFwwLWzXg/LLVkopUbhsK6s4jv+pz/6WJTmZCYM5DzE5vQe50 KKOBcYv0cvj4MrCJ5s9nOnas30dQOOcIQLvFRCX+0nx3fEEHuzbO05SmUq2MeJstbMCu jZgedr5AChIaKgoQ4gnjTCyngLOU3OiJW/FSEPo5TD3BryXCY0VR1hr264u64Ikb6964 d08Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695923205; x=1696528005; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SnUC980l8pjVO+FjtthJbSqfKHVI5/r5XXX90PwzZo4=; b=tBszfkNgqlBMtPoRWmy6maz1XvbzGIyDJyvKeVknFwpCAE0vW1rhpA904leB2R2oIy w90sqRaV6Gk3yLNjDwcooOc/5dqPqKJPpSDdthid/hi62Yuv2m+igmQhvggdOrLqZAf9 il/1hGcS5Gu/RaIjIJ/y9+7ugw44R+/RNJnYmz+PGKD1CANieqlY5hM5OJwCxqKNcwBM WgxLu5RWx4uP0kuW4C56tFixLAnIep4u7fm+Y8d+/wAC6j5DrWjEVSIcMKEPLLuOaz5x dufXHhGEWeVHHsdw9s/rMEhRAN9Y47wUuz3rPHWFoE4BtUc0y3D1potHPo5se/ZLFD/R JO8w== X-Gm-Message-State: AOJu0YyD3+s5WQ6BR1I7znEaDJZcoX8lSagYtNZEGgCGDijdd21XQzBy GRU/M6E+RfORheRG7THqJZ/B9dAcpmXhyX6GAuzdlw== X-Received: by 2002:a05:6e02:110f:b0:351:59db:a215 with SMTP id u15-20020a056e02110f00b0035159dba215mr1650185ilk.18.1695923205113; Thu, 28 Sep 2023 10:46:45 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id p6-20020a92d486000000b0034fc8c1c24fsm3450963ilg.54.2023.09.28.10.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:46:44 -0700 (PDT) From: Tom Tromey To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Tom Tromey Subject: [PATCH 6/7] libstdc++: Fix regex escapes in pretty-printers Date: Thu, 28 Sep 2023 11:46:29 -0600 Message-Id: <20230928174630.4004388-7-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928174630.4004388-1-tromey@adacore.com> References: <20230928174630.4004388-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778304784136733203 X-GMAIL-MSGID: 1778304784136733203 flake8 pointed out that some regexes in the pretty-printers are missing a backslash. This patch fixes these. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdExpAnyPrinter.__init__, StdExpOptionalPrinter.__init__): Add missing backslash. * python/libstdcxx/v6/xmethods.py (ArrayMethodsMatcher.match, DequeMethodsMatcher.match) (ForwardListMethodsMatcher.match, ListMethodsMatcher.match) (VectorMethodsMatcher.match) (AssociativeContainerMethodsMatcher.match) (UniquePtrGetWorker.__call__, UniquePtrMethodsMatcher.match) (SharedPtrSubscriptWorker.__call__) (SharedPtrMethodsMatcher.match): Add missing backslash. --- libstdc++-v3/python/libstdcxx/v6/printers.py | 6 +++--- libstdc++-v3/python/libstdcxx/v6/xmethods.py | 22 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 94ac9232da7..d125236b777 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -1344,7 +1344,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) self._typename = re.sub( - '^std::experimental::fundamentals_v\d::', 'std::experimental::', self._typename, 1) + '^std::experimental::fundamentals_v\\d::', 'std::experimental::', self._typename, 1) self._val = val self._contained_type = None contained_value = None @@ -1377,7 +1377,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): mgrtypes = [] for s in strings: try: - x = re.sub("std::string(?!\w)", s, m.group(1)) + x = re.sub("std::string(?!\\w)", s, m.group(1)) # The following lookup might raise gdb.error if the # manager function was never instantiated for 's' in the # program, because there will be no such type. @@ -1425,7 +1425,7 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter): def __init__(self, typename, val): typename = strip_versioned_namespace(typename) self._typename = re.sub( - '^std::(experimental::|)(fundamentals_v\d::|)(.*)', r'std::\1\3', typename, 1) + '^std::(experimental::|)(fundamentals_v\\d::|)(.*)', r'std::\1\3', typename, 1) payload = val['_M_payload'] if self._typename.startswith('std::experimental'): engaged = val['_M_engaged'] diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py index 025b1b86ed0..eafecbb148e 100644 --- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py +++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py @@ -159,7 +159,7 @@ class ArrayMethodsMatcher(gdb.xmethod.XMethodMatcher): self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): - if not re.match('^std::(__\d+::)?array<.*>$', class_type.tag): + if not re.match('^std::(__\\d+::)?array<.*>$', class_type.tag): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: @@ -284,7 +284,7 @@ class DequeMethodsMatcher(gdb.xmethod.XMethodMatcher): self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): - if not re.match('^std::(__\d+::)?deque<.*>$', class_type.tag): + if not re.match('^std::(__\\d+::)?deque<.*>$', class_type.tag): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: @@ -332,7 +332,7 @@ class ForwardListMethodsMatcher(gdb.xmethod.XMethodMatcher): self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): - if not re.match('^std::(__\d+::)?forward_list<.*>$', class_type.tag): + if not re.match('^std::(__\\d+::)?forward_list<.*>$', class_type.tag): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: @@ -419,7 +419,7 @@ class ListMethodsMatcher(gdb.xmethod.XMethodMatcher): self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): - if not re.match('^std::(__\d+::)?(__cxx11::)?list<.*>$', class_type.tag): + if not re.match('^std::(__\\d+::)?(__cxx11::)?list<.*>$', class_type.tag): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: @@ -542,7 +542,7 @@ class VectorMethodsMatcher(gdb.xmethod.XMethodMatcher): self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): - if not re.match('^std::(__\d+::)?vector<.*>$', class_type.tag): + if not re.match('^std::(__\\d+::)?vector<.*>$', class_type.tag): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: @@ -595,7 +595,7 @@ class AssociativeContainerMethodsMatcher(gdb.xmethod.XMethodMatcher): self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): - if not re.match('^std::(__\d+::)?%s<.*>$' % self._name, class_type.tag): + if not re.match('^std::(__\\d+::)?%s<.*>$' % self._name, class_type.tag): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: @@ -629,9 +629,9 @@ class UniquePtrGetWorker(gdb.xmethod.XMethodWorker): def __call__(self, obj): impl_type = obj.dereference().type.fields()[0].type.tag # Check for new implementations first: - if re.match('^std::(__\d+::)?__uniq_ptr_(data|impl)<.*>$', impl_type): + if re.match('^std::(__\\d+::)?__uniq_ptr_(data|impl)<.*>$', impl_type): tuple_member = obj['_M_t']['_M_t'] - elif re.match('^std::(__\d+::)?tuple<.*>$', impl_type): + elif re.match('^std::(__\\d+::)?tuple<.*>$', impl_type): tuple_member = obj['_M_t'] else: return None @@ -696,7 +696,7 @@ class UniquePtrMethodsMatcher(gdb.xmethod.XMethodMatcher): self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): - if not re.match('^std::(__\d+::)?unique_ptr<.*>$', class_type.tag): + if not re.match('^std::(__\\d+::)?unique_ptr<.*>$', class_type.tag): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: @@ -768,7 +768,7 @@ class SharedPtrSubscriptWorker(SharedPtrGetWorker): def __call__(self, obj, index): # Check bounds if _elem_type is an array of known bound - m = re.match('.*\[(\d+)]$', str(self._elem_type)) + m = re.match('.*\\[(\\d+)]$', str(self._elem_type)) if m and index >= int(m.group(1)): raise IndexError('shared_ptr<%s> index "%d" should not be >= %d.' % (self._elem_type, int(index), int(m.group(1)))) @@ -823,7 +823,7 @@ class SharedPtrMethodsMatcher(gdb.xmethod.XMethodMatcher): self.methods = [self._method_dict[m] for m in self._method_dict] def match(self, class_type, method_name): - if not re.match('^std::(__\d+::)?shared_ptr<.*>$', class_type.tag): + if not re.match('^std::(__\\d+::)?shared_ptr<.*>$', class_type.tag): return None method = self._method_dict.get(method_name) if method is None or not method.enabled: From patchwork Thu Sep 28 17:46:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 146242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3493259vqu; Thu, 28 Sep 2023 10:53:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrrlicunPaq5FDTOCmr+KOs4m3836g1EZsTszKAc9+iVPVBBVnF69F+huCRfzqSd6V2HfT X-Received: by 2002:a19:7110:0:b0:500:b7ed:105a with SMTP id m16-20020a197110000000b00500b7ed105amr1593620lfc.29.1695923635607; Thu, 28 Sep 2023 10:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695923635; cv=none; d=google.com; s=arc-20160816; b=XUp9UJwm4ka0ZZQIDXvdFnnS/7KVbPoR3QOr55XhbDD1UIcpHwDwKKxS3zzeq6rI9a qTOEv7uiIj12M1lJySyvklfcNfxbpAYUxn+taC1qn/rWsTrsQpd4enBhI3iq7Ujs7zzp nY7ePxDsIkuLyMAiCDOwwKgEfGo0kTPSlBk0EqMgISNIaUWH+cksJCwe4VaSGXDTRaXh WQ862dbhdjl5Nzct56G4XRddOKqPFOHywwSsn7q47+WY63F1rZ/VvLO4Zn5jrBAafZjz cVpRcy67dkdPX+k/lh2G3J54k63CZ93WhxLHRDQjdwA1xlolUeJ0BRqnqYJpDQRCcBX9 yhgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=nzCDTUskecfdSBaQy086LaR/2B/dhPGAP8Vlr2wmgn4=; fh=Ogh3zaPUNpdNYHofIVNHsbX+D3lwaT1T8Jhe/MolwAA=; b=Q3l+qMo055T3Kh4EypmFa44QuJsU3FP9zS5Mjzucf5Q0hcorSrUaTA+gl6PteI/LYw NkJhTIowDmJjyzMclwEg6p13LrjDsALj7FHZoybdUJN+MCFnmkp+VKwzK6NpfdPvWOWX KVaxGJnELwJCV/CNOwJG2umWFV178QizoHrWKPdrJs1H8vyQtl7aynj8qvIw0b7eo4uy BqlUiOoQer4ViWEdMBuslqCVFf6q1EW96817U0ZFqQyVY3ECMOokp9HQnFaQe+GbWnfT Run4s4pMCn/0VZhBjSr2Vih4pP8zdZWPcx4f6RK2qtivwgk9jvpyLnGehEQJxyCNsRZT vfSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=UhiNLQo4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l14-20020aa7d94e000000b005333a11ab8dsi12562359eds.378.2023.09.28.10.53.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:53:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=UhiNLQo4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 393AB394D8FF for ; Thu, 28 Sep 2023 17:48:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by sourceware.org (Postfix) with ESMTPS id 880C43870C0A for ; Thu, 28 Sep 2023 17:46:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 880C43870C0A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-76c64da0e46so471031139f.0 for ; Thu, 28 Sep 2023 10:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1695923206; x=1696528006; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nzCDTUskecfdSBaQy086LaR/2B/dhPGAP8Vlr2wmgn4=; b=UhiNLQo4u7rfN2gkIZV6t0cAhImmLWLxYMRlZUsHSKpR5X+nqn3J/cxPIFSk+1Tbci HQjkegFfCq5ryUktxkwnjiPmpEq/ITIns7C7PffjAW+uePDat6IVDw0WX7975anhTkQB XueuPKfySJM7QsFQ9+hrMMxyNy3CHwk7czYqCVv9eNyDWww1OJ8CXNbil0BtXrHb6gNN +01yLpNTeWWtI758nIIkOF6j0RaHHWU3qAI7c/aQQx5t9+OfTm2Q8g5Hx9pPxWrh5Wxx pecnHdn6CtMw9k96gsXCA0eEYQMzqOqfiqNSbIzKVgU8sRNXmiwf6ih4olr1rsxIMuUT CVwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695923206; x=1696528006; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nzCDTUskecfdSBaQy086LaR/2B/dhPGAP8Vlr2wmgn4=; b=oRJVF/xIUGawb3wg+qHhtr21E6jJSN+iSdOpZyeJg8g7F3zuEZ9RKootb/+RuviwWx Rq9da/9zkCQDQyCOb6dqG4+fg6xjra1+CW8MTxAwJziUS9ADXgN/8kIFcJfS2zdFX8Ww 03JbgtWWrDyjeaIkEfilWKVCOUKzqvIOsuunddl0Z+UoSe66h2nfxZeMuPufPYFdbikh vgtN5gGCWcOlJGo+8aRxKkxQXrC7GQqP5WoNgFpMCQYJAPSL1lqRdC0dVPzuG2b8+yMb wcYIGYX6Hyz8FNagtCLm7D18vsmzgInEqwDfmTB4Fq+xSEMyrh6eP9LeBeFkfNbPLGMy 7zEQ== X-Gm-Message-State: AOJu0YwZe2ggysO1s6boJ7vg69i45NBlpjcr/ZQ5MONwBk/+ijkTM8X9 VYuZlOzdYctGstgaKjRnvxwuiuek9BaYMdHSqy4LUw== X-Received: by 2002:a05:6e02:1787:b0:349:3503:253b with SMTP id y7-20020a056e02178700b003493503253bmr2313015ilu.17.1695923205804; Thu, 28 Sep 2023 10:46:45 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id p6-20020a92d486000000b0034fc8c1c24fsm3450963ilg.54.2023.09.28.10.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:46:45 -0700 (PDT) From: Tom Tromey To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Tom Tromey Subject: [PATCH 7/7] libstdc++: Use Python "not in" operator Date: Thu, 28 Sep 2023 11:46:30 -0600 Message-Id: <20230928174630.4004388-8-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230928174630.4004388-1-tromey@adacore.com> References: <20230928174630.4004388-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778304822017242026 X-GMAIL-MSGID: 1778304822017242026 flake8 warns about code like not something in "whatever" Ordinarily in Python this should be written as: something not in "whatever" This patch makes this change. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (Printer.add_version) (add_one_template_type_printer) (FilteringTypePrinter.add_one_type_printer): Use Python "not in" operator. --- libstdc++-v3/python/libstdcxx/v6/printers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index d125236b777..380426cd41e 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -2321,7 +2321,7 @@ class Printer(object): # Add a name using _GLIBCXX_BEGIN_NAMESPACE_VERSION. def add_version(self, base, name, function): self.add(base + name, function) - if _versioned_namespace and not '__cxx11' in base: + if _versioned_namespace and '__cxx11' not in base: vbase = re.sub('^(std|__gnu_cxx)::', r'\g<0>%s' % _versioned_namespace, base) self.add(vbase + name, function) @@ -2494,7 +2494,7 @@ def add_one_template_type_printer(obj, name, defargs): printer = TemplateTypePrinter('std::__debug::'+name, defargs) gdb.types.register_type_printer(obj, printer) - if _versioned_namespace and not '__cxx11' in name: + if _versioned_namespace and '__cxx11' not in name: # Add second type printer for same type in versioned namespace: ns = 'std::' + _versioned_namespace # PR 86112 Cannot use dict comprehension here: @@ -2589,7 +2589,7 @@ class FilteringTypePrinter(object): def add_one_type_printer(obj, template, name, targ1=None): printer = FilteringTypePrinter('std::' + template, 'std::' + name, targ1) gdb.types.register_type_printer(obj, printer) - if _versioned_namespace and not '__cxx11' in template: + if _versioned_namespace and '__cxx11' not in template: ns = 'std::' + _versioned_namespace printer = FilteringTypePrinter(ns + template, ns + name, targ1) gdb.types.register_type_printer(obj, printer)