From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AGHT+IH5bCE7S/uEhdD7D5lTkBfw+FyQGlPgze+rQPpJF38tbbHqYE9P8f0URoZ7ipnIcT2xB6YAgA== 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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: -- 2.40.1