From patchwork Sat Dec 24 13:47:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Patchwork-Id: 88994 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp3775321qgi; Sat, 24 Dec 2016 05:48:36 -0800 (PST) X-Received: by 10.84.234.22 with SMTP id m22mr8366318plk.169.1482587316014; Sat, 24 Dec 2016 05:48:36 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 33si37408222ply.89.2016.12.24.05.48.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Dec 2016 05:48:36 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-445037-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-445037-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-445037-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:references:cc:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=YpSPnoisWGn2ObUSn aoc/L/B3aZUlCd/Cc5/z2FHdcEWg0FTGTx7ke9l6DqwJXgp/VeyiI+7oC4QKq38X z0EtLGWpUFy9f5DnPwbu+EeClwUM/NeJqQYPKIxDe+W5wOjl1HPIf6bDPTfnny1P WV0JBIHZY3bjl4Ocjnn8lL5JhY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:references:cc:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=X5W9AEIRhpBkrO+5cP/g2Ag WhoQ=; b=YAoQKUwmHrftXAHbzssIJIQQHy1fTm8Bi0Pdg5nQ7Ns5sw+Vt/cIqY3 wh0loyEZeX65VQi7qFN1F4vu5RNHpk+6+FZL8bSzlAXj6vkgyPS4WgSP4sz0KfBz Uub0wVtxhyBH/DdvhnJaJm9pmeGSeCSQxnT0lDH5P/Z/2g8PojEY= Received: (qmail 79672 invoked by alias); 24 Dec 2016 13:48:21 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 79653 invoked by uid 89); 24 Dec 2016 13:48:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=BAYES_05, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=vers, Printer, adopt, H*r:rev.sfr.net X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wm0-f67.google.com Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 24 Dec 2016 13:47:59 +0000 Received: by mail-wm0-f67.google.com with SMTP id m203so46300714wma.3; Sat, 24 Dec 2016 05:47:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to; bh=bLnRy53HejfChoFI2VQ7f1X2RRgNzgT3b7L49BBHHgc=; b=GGVaTzxfNsqGCBBObbjh/Oc/NfzoTU6dae7ETvWrlKzZgc0HlmotevKPa/SVx21afy OhqLKdYxokS0XZu0+//yoalp3TveavOaj4H/w2//jx8p0ltIMTwvD68WLFPCa/uPi4QW saKEqQhj22wOAbHLzSWljk4D8qESipKgrQKuSN8faW0XukVw9CfC2G43fKFC/Wl/sIxS xjASkTwqVGmU4no0xEaEWCfctU0R5opZfjtfrzTZkwnd7WIpXYejrsz5uhYAeEsHxUUd u9xurVv1oJJEVy4xhQLWk2N/S0jaZ+8TtSjX5UtKItcWt6nPc12LYdNIluSWThkHQ5YM DwSw== X-Gm-Message-State: AIkVDXKaNG2c1BmElgI9H49AF258r4jjS0tVi9UIQ4Qmm8H0eT9rLXCQI848xvTC1GS8zA== X-Received: by 10.28.141.18 with SMTP id p18mr18574732wmd.31.1482587276994; Sat, 24 Dec 2016 05:47:56 -0800 (PST) Received: from [192.168.1.75] (161.153.102.84.rev.sfr.net. [84.102.153.161]) by smtp.googlemail.com with ESMTPSA id b3sm45502030wjy.40.2016.12.24.05.47.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Dec 2016 05:47:56 -0800 (PST) From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= Subject: Re: Pretty printers for versioned namespace To: Jonathan Wakely References: <37f043c2-5022-feb2-598b-5cb8ba11d762@gmail.com> <20161129201709.GL3301@redhat.com> <71a8120b-494a-c074-bb13-1ddfa560fdf2@gmail.com> <20161202004150.GI3301@redhat.com> <1a5de3bf-9cfc-3569-6dc8-7ffcd99c286f@gmail.com> <20161209151830.GH6326@redhat.com> <20161215145717.GB22266@redhat.com> Cc: "libstdc++@gcc.gnu.org" , gcc-patches Message-ID: Date: Sat, 24 Dec 2016 14:47:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161215145717.GB22266@redhat.com> On 15/12/2016 15:57, Jonathan Wakely wrote: > > And we could avoid three re.match expressions with complicated regular > expressions by creating a helper function to do the "startswith" > checks: > > def is_specialization_of(type, template_name): > return re.match('^std::(%s)?%s<.*>$' % (vers_nsp, template_name), > type) is not None > > Then replace impl_type.startswith('std::__uniq_ptr_impl<') with > is_specialization_of(impl_type, '__uniq_ptr_impl') > > And replace impl_type.startswith('std::tuple<') with > is_specialization_of(impl_type, 'tuple') > > And replace nodetype.name.startswith('std::_Rb_tree_node') with > is_specialization_of(nodetype.name, '_Rb_tree_node') > > That makes the code much easier to read. > > I agree that hiding the version namespace will be nicer. I just hope it is possible. I don't think we can really dictate gdb to hide this namespace during the rendering. In the attached path you will see what I tried to do. Problem is that I am not sure that printers.py is intercepting rendering of all types so version namespace will stay visible in those cases. I think the 2 failures that I have with this patch are reflecting this problem: type = holder, std::__7::allocator > > got: type = holder, std::__7::allocator > > FAIL: libstdc++-prettyprinters/whatis.cc whatis ustring_holder type = holder, std::__7::allocator > > got: type = holder, std::__7::allocator > > FAIL: libstdc++-prettyprinters/whatis.cc whatis sstring_holder Shall I simply use regex in those cases and adopt this approach ? François diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 86de1ca..55bdee9 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -36,6 +36,8 @@ import sys # We probably can't do much about this until this GDB PR is addressed: # +vers_nsp = '__7::' + if sys.version_info[0] > 2: ### Python 3 stuff Iterator = object @@ -100,11 +102,15 @@ def find_type(orig, name): raise ValueError("Cannot find type %s::%s" % (str(orig), name)) typ = field.type +# Test if a type is a given template instantiation. +def is_specialization_of(type, template_name): + return re.match('^std::(%s)?%s<.*>$' % (vers_nsp, template_name), type) is not None + class SharedPointerPrinter: "Print a shared_ptr or weak_ptr" def __init__ (self, typename, val): - self.typename = typename + self.typename = typename.replace(vers_nsp, '') self.val = val def to_string (self): @@ -127,9 +133,9 @@ class UniquePointerPrinter: def to_string (self): impl_type = self.val.type.fields()[0].type.tag - if impl_type.startswith('std::__uniq_ptr_impl<'): # New implementation + if is_specialization_of(impl_type, '__uniq_ptr_impl'): # New implementation v = self.val['_M_t']['_M_t']['_M_head_impl'] - elif impl_type.startswith('std::tuple<'): + elif is_specialization_of(impl_type, 'tuple'): v = self.val['_M_t']['_M_head_impl'] else: raise ValueError("Unsupported implementation for unique_ptr: %s" % self.val.type.fields()[0].type.tag) @@ -179,7 +185,7 @@ class StdListPrinter: return ('[%d]' % count, val) def __init__(self, typename, val): - self.typename = typename + self.typename = typename.replace(vers_nsp, '') self.val = val def children(self): @@ -299,7 +305,7 @@ class StdVectorPrinter: return ('[%d]' % count, elt) def __init__(self, typename, val): - self.typename = typename + self.typename = typename.replace(vers_nsp, '') self.val = val self.is_bool = val.type.template_argument(0).code == gdb.TYPE_CODE_BOOL @@ -403,7 +409,7 @@ class StdTuplePrinter: return ('[%d]' % self.count, impl['_M_head_impl']) def __init__ (self, typename, val): - self.typename = typename + self.typename = typename.replace(vers_nsp, '') self.val = val; def children (self): @@ -418,7 +424,7 @@ class StdStackOrQueuePrinter: "Print a std::stack or std::queue" def __init__ (self, typename, val): - self.typename = typename + self.typename = typename.replace(vers_nsp, '') self.visualizer = gdb.default_visualizer(val['c']) def children (self): @@ -496,7 +502,10 @@ class StdRbtreeIteratorPrinter: def __init__ (self, typename, val): self.val = val valtype = self.val.type.template_argument(0).strip_typedefs() - nodetype = gdb.lookup_type('std::_Rb_tree_node<' + str(valtype) + '>') + if typename.startswith('std::' + vers_nsp): + nodetype = gdb.lookup_type('std::' + vers_nsp + '_Rb_tree_node<' + str(valtype) + '>') + else: + nodetype = gdb.lookup_type('std::_Rb_tree_node<' + str(valtype) + '>') self.link_type = nodetype.strip_typedefs().pointer() def to_string (self): @@ -552,7 +561,7 @@ class StdMapPrinter: return result def __init__ (self, typename, val): - self.typename = typename + self.typename = typename.replace(vers_nsp, '') self.val = val def to_string (self): @@ -592,7 +601,7 @@ class StdSetPrinter: return result def __init__ (self, typename, val): - self.typename = typename + self.typename = typename.replace(vers_nsp, '') self.val = val def to_string (self): @@ -609,7 +618,7 @@ class StdBitsetPrinter: "Print a std::bitset" def __init__(self, typename, val): - self.typename = typename + self.typename = typename.replace(vers_nsp, '') self.val = val def to_string (self): @@ -679,7 +688,7 @@ class StdDequePrinter: return result def __init__(self, typename, val): - self.typename = typename + self.typename = typename.replace(vers_nsp, '') self.val = val self.elttype = val.type.template_argument(0) size = self.elttype.sizeof @@ -805,7 +814,7 @@ class Tr1UnorderedSetPrinter: "Print a tr1::unordered_set" def __init__ (self, typename, val): - self.typename = typename + self.typename = typename.replace(vers_nsp, '') self.val = val def hashtable (self): @@ -831,7 +840,7 @@ class Tr1UnorderedMapPrinter: "Print a tr1::unordered_map" def __init__ (self, typename, val): - self.typename = typename + self.typename = typename.replace(vers_nsp, '') self.val = val def hashtable (self): @@ -897,7 +906,7 @@ class StdForwardListPrinter: def __init__(self, typename, val): self.val = val - self.typename = typename + self.typename = typename.replace(vers_nsp, '') def children(self): nodetype = find_type(self.val.type, '_Node') @@ -952,12 +961,11 @@ class SingleObjContainerPrinter(object): return self.visualizer.display_hint () return self.hint - class StdExpAnyPrinter(SingleObjContainerPrinter): "Print a std::any or std::experimental::any" def __init__ (self, typename, val): - self.typename = re.sub('^std::experimental::fundamentals_v\d::', 'std::experimental::', typename, 1) + self.typename = re.sub('^std::experimental::fundamentals_v\d::', 'std::experimental::', typename, 1).replace(vers_nsp, '') self.val = val self.contained_type = None contained_value = None @@ -972,8 +980,11 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): if not m: raise ValueError("Unknown manager function in %s" % self.typename) + mgrname = m.group(1) # FIXME need to expand 'std::string' so that gdb.lookup_type works - mgrname = re.sub("std::string(?!\w)", str(gdb.lookup_type('std::string').strip_typedefs()), m.group(1)) + if 'std::string' in mgrname: + mgrname = re.sub("std::string(?!\w)", str(gdb.lookup_type('std::string').strip_typedefs()), m.group(1)) + mgrtype = gdb.lookup_type(mgrname) self.contained_type = mgrtype.template_argument(0) valptr = None @@ -994,14 +1005,14 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): if hasattr (self.visualizer, 'children'): return desc + self.visualizer.to_string () valtype = self._recognize (self.contained_type) - return desc + valtype + return desc + str(valtype).replace(vers_nsp, '') class StdExpOptionalPrinter(SingleObjContainerPrinter): "Print a std::optional or std::experimental::optional" def __init__ (self, typename, val): valtype = self._recognize (val.type.template_argument(0)) - self.typename = re.sub('^std::(experimental::|)(fundamentals_v\d::|)(.*)', r'std::\1\3<%s>' % valtype, typename, 1) + self.typename = re.sub('^std::(experimental::|)(fundamentals_v\d::|)(.*)', r'std::\1\3<%s>' % valtype, typename, 1).replace(vers_nsp, '') self.val = val contained_value = val['_M_payload'] if self.val['_M_engaged'] else None visualizer = gdb.default_visualizer (val['_M_payload']) @@ -1021,6 +1032,7 @@ class StdVariantPrinter(SingleObjContainerPrinter): def __init__(self, typename, val): alternatives = self._template_args(val) self.typename = "%s<%s>" % (typename, ', '.join([self._recognize(alt) for alt in alternatives])) + self.typename = self.typename.replace(vers_nsp, '') self.index = val['_M_index'] if self.index >= len(alternatives): self.contained_type = None @@ -1058,7 +1070,7 @@ class StdNodeHandlePrinter(SingleObjContainerPrinter): def __init__(self, typename, val): self.value_type = val.type.template_argument(1) nodetype = val.type.template_argument(2).template_argument(0) - self.is_rb_tree_node = nodetype.name.startswith('std::_Rb_tree_node') + 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 nodeptr = val['_M_ptr'] if nodeptr: @@ -1202,7 +1214,7 @@ class Printer(object): # Add a name using _GLIBCXX_BEGIN_NAMESPACE_VERSION. def add_version(self, base, name, function): self.add(base + name, function) - self.add(base + '__7::' + name, function) + self.add(base + vers_nsp + name, function) # Add a name using _GLIBCXX_BEGIN_NAMESPACE_CONTAINER. def add_container(self, base, name, function): @@ -1322,7 +1334,7 @@ class FilteringTypePrinter(object): except: pass if self.type_obj == type_obj: - return self.name + return self.name.replace(vers_nsp, '') return None def instantiate(self): @@ -1331,6 +1343,8 @@ class FilteringTypePrinter(object): def add_one_type_printer(obj, match, name): printer = FilteringTypePrinter(match, 'std::' + name) gdb.types.register_type_printer(obj, printer) + printer = FilteringTypePrinter(match, 'std::' + vers_nsp + name) + gdb.types.register_type_printer(obj, printer) def register_type_printers(obj): global _use_type_printing @@ -1374,7 +1388,6 @@ def register_type_printers(obj): add_one_type_printer(obj, 'fpos', 'streampos') add_one_type_printer(obj, 'basic_string', 'u16string') add_one_type_printer(obj, 'basic_string', 'u32string') - add_one_type_printer(obj, 'basic_string_view', 'u16string_view') add_one_type_printer(obj, 'basic_string_view', 'u32string_view') @@ -1392,46 +1405,47 @@ def register_type_printers(obj): add_one_type_printer(obj, 'discard_block_engine', 'ranlux48') add_one_type_printer(obj, 'shuffle_order_engine', 'knuth_b') - # Do not show defaulted template arguments in class templates - add_one_template_type_printer(obj, 'unique_ptr', - 'unique_ptr<(.*), std::default_delete<\\1 ?> >', + for vers in ('', vers_nsp): + # Do not show defaulted template arguments in class templates + add_one_template_type_printer(obj, 'unique_ptr', + '{0}unique_ptr<(.*), std::{0}default_delete<\\1 ?> >'.format(vers), 'unique_ptr<{1}>') - add_one_template_type_printer(obj, 'deque', - 'deque<(.*), std::allocator<\\1 ?> >', + add_one_template_type_printer(obj, 'deque', + '{0}deque<(.*), std::{0}allocator<\\1 ?> >'.format(vers), 'deque<{1}>') - add_one_template_type_printer(obj, 'forward_list', - 'forward_list<(.*), std::allocator<\\1 ?> >', + add_one_template_type_printer(obj, 'forward_list', + '{0}forward_list<(.*), std::{0}allocator<\\1 ?> >'.format(vers), 'forward_list<{1}>') - add_one_template_type_printer(obj, 'list', - 'list<(.*), std::allocator<\\1 ?> >', + add_one_template_type_printer(obj, 'list', + '{0}list<(.*), std::{0}allocator<\\1 ?> >'.format(vers), 'list<{1}>') - add_one_template_type_printer(obj, 'vector', - 'vector<(.*), std::allocator<\\1 ?> >', + add_one_template_type_printer(obj, 'vector', + '{0}vector<(.*), std::{0}allocator<\\1 ?> >'.format(vers), 'vector<{1}>') - add_one_template_type_printer(obj, 'map', - 'map<(.*), (.*), std::less<\\1 ?>, std::allocator > >', + add_one_template_type_printer(obj, 'map', + '{0}map<(.*), (.*), std::{0}less<\\1 ?>, std::{0}allocator > >'.format(vers), 'map<{1}, {2}>') - add_one_template_type_printer(obj, 'multimap', - 'multimap<(.*), (.*), std::less<\\1 ?>, std::allocator > >', + add_one_template_type_printer(obj, 'multimap', + '{0}multimap<(.*), (.*), std::{0}less<\\1 ?>, std::{0}allocator > >'.format(vers), 'multimap<{1}, {2}>') - add_one_template_type_printer(obj, 'set', - 'set<(.*), std::less<\\1 ?>, std::allocator<\\1 ?> >', + add_one_template_type_printer(obj, 'set', + '{0}set<(.*), std::{0}less<\\1 ?>, std::{0}allocator<\\1 ?> >'.format(vers), 'set<{1}>') - add_one_template_type_printer(obj, 'multiset', - 'multiset<(.*), std::less<\\1 ?>, std::allocator<\\1 ?> >', + add_one_template_type_printer(obj, 'multiset', + '{0}multiset<(.*), std::{0}less<\\1 ?>, std::{0}allocator<\\1 ?> >'.format(vers), 'multiset<{1}>') - add_one_template_type_printer(obj, 'unordered_map', - 'unordered_map<(.*), (.*), std::hash<\\1 ?>, std::equal_to<\\1 ?>, std::allocator > >', + add_one_template_type_printer(obj, 'unordered_map', + '{0}unordered_map<(.*), (.*), std::{0}hash<\\1 ?>, std::{0}equal_to<\\1 ?>, std::{0}allocator > >'.format(vers), 'unordered_map<{1}, {2}>') - add_one_template_type_printer(obj, 'unordered_multimap', - 'unordered_multimap<(.*), (.*), std::hash<\\1 ?>, std::equal_to<\\1 ?>, std::allocator > >', + add_one_template_type_printer(obj, 'unordered_multimap', + '{0}unordered_multimap<(.*), (.*), std::{0}hash<\\1 ?>, std::{0}equal_to<\\1 ?>, std::{0}allocator > >'.format(vers), 'unordered_multimap<{1}, {2}>') - add_one_template_type_printer(obj, 'unordered_set', - 'unordered_set<(.*), std::hash<\\1 ?>, std::equal_to<\\1 ?>, std::allocator<\\1 ?> >', + add_one_template_type_printer(obj, 'unordered_set', + '{0}unordered_set<(.*), std::{0}hash<\\1 ?>, std::{0}equal_to<\\1 ?>, std::{0}allocator<\\1 ?> >'.format(vers), 'unordered_set<{1}>') - add_one_template_type_printer(obj, 'unordered_multiset', - 'unordered_multiset<(.*), std::hash<\\1 ?>, std::equal_to<\\1 ?>, std::allocator<\\1 ?> >', + add_one_template_type_printer(obj, 'unordered_multiset', + '{0}unordered_multiset<(.*), std::{0}hash<\\1 ?>, std::{0}equal_to<\\1 ?>, std::{0}allocator<\\1 ?> >'.format(vers), 'unordered_multiset<{1}>') # strip the "fundamentals_v1" inline namespace from these types @@ -1466,7 +1480,7 @@ def build_libstdcxx_dictionary (): libstdcxx_printer = Printer("libstdc++-v6") # For _GLIBCXX_BEGIN_NAMESPACE_VERSION. - vers = '(__7::)?' + vers = '(' + vers_nsp + ')?' # For _GLIBCXX_BEGIN_NAMESPACE_CONTAINER. container = '(__cxx1998::' + vers + ')?' diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py index 1c9bf3a..ae576d8 100644 --- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py +++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py @@ -148,7 +148,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::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: @@ -265,7 +265,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::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: @@ -309,7 +309,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::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: @@ -390,7 +390,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::(__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: @@ -505,7 +505,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::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: @@ -554,7 +554,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::%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: @@ -586,9 +586,9 @@ class UniquePtrGetWorker(gdb.xmethod.XMethodWorker): def __call__(self, obj): impl_type = obj.dereference().type.fields()[0].type.tag - if impl_type.startswith('std::__uniq_ptr_impl<'): # New implementation + if re.match('^std::(__\d+::)?__uniq_ptr_impl<.*>$', impl_type): # New implementation return obj['_M_t']['_M_t']['_M_head_impl'] - elif impl_type.startswith('std::tuple<'): + elif re.match('^std::(__\d+::)?tuple<.*>$', impl_type): return obj['_M_t']['_M_head_impl'] return None @@ -640,7 +640,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::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: