Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:52:38

0001 // Copyright 2024 Braden Ganetsky
0002 // Distributed under the Boost Software License, Version 1.0.
0003 // https://www.boost.org/LICENSE_1_0.txt
0004 
0005 // Generated on 2024-08-25T17:48:54
0006 
0007 #ifndef BOOST_UNORDERED_UNORDERED_PRINTERS_HPP
0008 #define BOOST_UNORDERED_UNORDERED_PRINTERS_HPP
0009 
0010 #ifndef BOOST_ALL_NO_EMBEDDED_GDB_SCRIPTS
0011 #if defined(__ELF__)
0012 #ifdef __clang__
0013 #pragma clang diagnostic push
0014 #pragma clang diagnostic ignored "-Woverlength-strings"
0015 #endif
0016 __asm__(".pushsection \".debug_gdb_scripts\", \"MS\",%progbits,1\n"
0017         ".ascii \"\\4gdb.inlined-script.BOOST_UNORDERED_UNORDERED_PRINTERS_HPP\\n\"\n"
0018         ".ascii \"import gdb.printing\\n\"\n"
0019         ".ascii \"import gdb.xmethod\\n\"\n"
0020         ".ascii \"import re\\n\"\n"
0021         ".ascii \"import math\\n\"\n"
0022 
0023         ".ascii \"class BoostUnorderedHelpers:\\n\"\n"
0024         ".ascii \"    def maybe_unwrap_atomic(n):\\n\"\n"
0025         ".ascii \"        if f\\\"{n.type.strip_typedefs()}\\\".startswith(\\\"std::atomic<\\\"):\\n\"\n"
0026         ".ascii \"            underlying_type = n.type.template_argument(0)\\n\"\n"
0027         ".ascii \"            return n.cast(underlying_type)\\n\"\n"
0028         ".ascii \"        else:\\n\"\n"
0029         ".ascii \"            return n\\n\"\n"
0030 
0031         ".ascii \"    def maybe_unwrap_foa_element(e):\\n\"\n"
0032         ".ascii \"        if f\\\"{e.type.strip_typedefs()}\\\".startswith(\\\"boost::unordered::detail::foa::element_type<\\\"):\\n\"\n"
0033         ".ascii \"            return e[\\\"p\\\"]\\n\"\n"
0034         ".ascii \"        else:\\n\"\n"
0035         ".ascii \"            return e\\n\"\n"
0036 
0037         ".ascii \"    def maybe_unwrap_reference(value):\\n\"\n"
0038         ".ascii \"        if value.type.code == gdb.TYPE_CODE_REF:\\n\"\n"
0039         ".ascii \"            return value.referenced_value()\\n\"\n"
0040         ".ascii \"        else:\\n\"\n"
0041         ".ascii \"            return value\\n\"\n"
0042 
0043         ".ascii \"    def countr_zero(n):\\n\"\n"
0044         ".ascii \"        for i in range(32):\\n\"\n"
0045         ".ascii \"            if (n & (1 << i)) != 0:\\n\"\n"
0046         ".ascii \"                return i\\n\"\n"
0047         ".ascii \"        return 32\\n\"\n"
0048 
0049         ".ascii \"class BoostUnorderedPointerCustomizationPoint:\\n\"\n"
0050         ".ascii \"    def __init__(self, any_ptr):\\n\"\n"
0051         ".ascii \"        vis = gdb.default_visualizer(any_ptr)\\n\"\n"
0052         ".ascii \"        if vis is None:\\n\"\n"
0053         ".ascii \"            self.to_address = lambda ptr: ptr\\n\"\n"
0054         ".ascii \"            self.next = lambda ptr, offset: ptr + offset\\n\"\n"
0055         ".ascii \"        else:\\n\"\n"
0056         ".ascii \"            self.to_address = lambda ptr: ptr if (ptr.type.code == gdb.TYPE_CODE_PTR) else type(vis).boost_to_address(ptr)\\n\"\n"
0057         ".ascii \"            self.next = lambda ptr, offset: type(vis).boost_next(ptr, offset)\\n\"\n"
0058 
0059         ".ascii \"class BoostUnorderedFcaPrinter:\\n\"\n"
0060         ".ascii \"    def __init__(self, val):\\n\"\n"
0061         ".ascii \"        self.val = BoostUnorderedHelpers.maybe_unwrap_reference(val)\\n\"\n"
0062         ".ascii \"        self.name = f\\\"{self.val.type.strip_typedefs()}\\\".split(\\\"<\\\")[0]\\n\"\n"
0063         ".ascii \"        self.name = self.name.replace(\\\"boost::unordered::\\\", \\\"boost::\\\")\\n\"\n"
0064         ".ascii \"        self.is_map = self.name.endswith(\\\"map\\\")\\n\"\n"
0065         ".ascii \"        self.cpo = BoostUnorderedPointerCustomizationPoint(self.val[\\\"table_\\\"][\\\"buckets_\\\"][\\\"buckets\\\"])\\n\"\n"
0066 
0067         ".ascii \"    def to_string(self):\\n\"\n"
0068         ".ascii \"        size = self.val[\\\"table_\\\"][\\\"size_\\\"]\\n\"\n"
0069         ".ascii \"        return f\\\"{self.name} with {size} elements\\\"\\n\"\n"
0070 
0071         ".ascii \"    def display_hint(self):\\n\"\n"
0072         ".ascii \"        return \\\"map\\\"\\n\"\n"
0073 
0074         ".ascii \"    def children(self):\\n\"\n"
0075         ".ascii \"        def generator():\\n\"\n"
0076         ".ascii \"            grouped_buckets = self.val[\\\"table_\\\"][\\\"buckets_\\\"]\\n\"\n"
0077 
0078         ".ascii \"            size = grouped_buckets[\\\"size_\\\"]\\n\"\n"
0079         ".ascii \"            buckets = grouped_buckets[\\\"buckets\\\"]\\n\"\n"
0080         ".ascii \"            bucket_index = 0\\n\"\n"
0081 
0082         ".ascii \"            count = 0\\n\"\n"
0083         ".ascii \"            while bucket_index != size:\\n\"\n"
0084         ".ascii \"                current_bucket = self.cpo.next(self.cpo.to_address(buckets), bucket_index)\\n\"\n"
0085         ".ascii \"                node = self.cpo.to_address(current_bucket.dereference()[\\\"next\\\"])\\n\"\n"
0086         ".ascii \"                while node != 0:\\n\"\n"
0087         ".ascii \"                    value = node.dereference()[\\\"buf\\\"][\\\"t_\\\"]\\n\"\n"
0088         ".ascii \"                    if self.is_map:\\n\"\n"
0089         ".ascii \"                        first = value[\\\"first\\\"]\\n\"\n"
0090         ".ascii \"                        second = value[\\\"second\\\"]\\n\"\n"
0091         ".ascii \"                        yield \\\"\\\", first\\n\"\n"
0092         ".ascii \"                        yield \\\"\\\", second\\n\"\n"
0093         ".ascii \"                    else:\\n\"\n"
0094         ".ascii \"                        yield \\\"\\\", count\\n\"\n"
0095         ".ascii \"                        yield \\\"\\\", value\\n\"\n"
0096         ".ascii \"                    count += 1\\n\"\n"
0097         ".ascii \"                    node = self.cpo.to_address(node.dereference()[\\\"next\\\"])\\n\"\n"
0098         ".ascii \"                bucket_index += 1\\n\"\n"
0099 
0100         ".ascii \"        return generator()\\n\"\n"
0101 
0102         ".ascii \"class BoostUnorderedFcaIteratorPrinter:\\n\"\n"
0103         ".ascii \"    def __init__(self, val):\\n\"\n"
0104         ".ascii \"        self.val = val\\n\"\n"
0105         ".ascii \"        self.cpo = BoostUnorderedPointerCustomizationPoint(self.val[\\\"p\\\"])\\n\"\n"
0106 
0107         ".ascii \"    def to_string(self):\\n\"\n"
0108         ".ascii \"        if self.valid():\\n\"\n"
0109         ".ascii \"            value = self.cpo.to_address(self.val[\\\"p\\\"]).dereference()[\\\"buf\\\"][\\\"t_\\\"]\\n\"\n"
0110         ".ascii \"            return f\\\"iterator = {{ {value} }}\\\"\\n\"\n"
0111         ".ascii \"        else:\\n\"\n"
0112         ".ascii \"            return \\\"iterator = { end iterator }\\\"\\n\"\n"
0113 
0114         ".ascii \"    def valid(self):\\n\"\n"
0115         ".ascii \"        return (self.cpo.to_address(self.val[\\\"p\\\"]) != 0) and (self.cpo.to_address(self.val[\\\"itb\\\"][\\\"p\\\"]) != 0)\\n\"\n"
0116 
0117         ".ascii \"class BoostUnorderedFoaTableCoreCumulativeStatsPrinter:\\n\"\n"
0118         ".ascii \"    def __init__(self, val):\\n\"\n"
0119         ".ascii \"        self.val = val\\n\"\n"
0120 
0121         ".ascii \"    def to_string(self):\\n\"\n"
0122         ".ascii \"        return \\\"[stats]\\\"\\n\"\n"
0123 
0124         ".ascii \"    def display_hint(self):\\n\"\n"
0125         ".ascii \"        return \\\"map\\\"\\n\"\n"
0126 
0127         ".ascii \"    def children(self):\\n\"\n"
0128         ".ascii \"        def generator():\\n\"\n"
0129         ".ascii \"            members = [\\\"insertion\\\", \\\"successful_lookup\\\", \\\"unsuccessful_lookup\\\"]\\n\"\n"
0130         ".ascii \"            for member in members:\\n\"\n"
0131         ".ascii \"                yield \\\"\\\", member\\n\"\n"
0132         ".ascii \"                yield \\\"\\\", self.val[member]\\n\"\n"
0133         ".ascii \"        return generator()\\n\"\n"
0134 
0135         ".ascii \"class BoostUnorderedFoaCumulativeStatsPrinter:\\n\"\n"
0136         ".ascii \"    def __init__(self, val):\\n\"\n"
0137         ".ascii \"        self.val = val\\n\"\n"
0138         ".ascii \"        self.n = self.val[\\\"n\\\"]\\n\"\n"
0139         ".ascii \"        self.N = self.val.type.template_argument(0)\\n\"\n"
0140 
0141         ".ascii \"    def display_hint(self):\\n\"\n"
0142         ".ascii \"        return \\\"map\\\"\\n\"\n"
0143 
0144         ".ascii \"    def children(self):\\n\"\n"
0145         ".ascii \"        def generator():\\n\"\n"
0146         ".ascii \"            yield \\\"\\\", \\\"count\\\"\\n\"\n"
0147         ".ascii \"            yield \\\"\\\", self.n\\n\"\n"
0148 
0149         ".ascii \"            sequence_stats_data = gdb.lookup_type(\\\"boost::unordered::detail::foa::sequence_stats_data\\\")\\n\"\n"
0150         ".ascii \"            data = self.val[\\\"data\\\"]\\n\"\n"
0151         ".ascii \"            arr = data.address.reinterpret_cast(sequence_stats_data.pointer())\\n\"\n"
0152         ".ascii \"            def build_string(idx):\\n\"\n"
0153         ".ascii \"                entry = arr[idx]\\n\"\n"
0154         ".ascii \"                avg = float(entry[\\\"m\\\"])\\n\"\n"
0155         ".ascii \"                var = float(entry[\\\"s\\\"] / self.n) if (self.n != 0) else 0.0\\n\"\n"
0156         ".ascii \"                dev = math.sqrt(var)\\n\"\n"
0157         ".ascii \"                return f\\\"{{avg = {avg}, var = {var}, dev = {dev}}}\\\"\\n\"\n"
0158 
0159         ".ascii \"            if self.N > 0:\\n\"\n"
0160         ".ascii \"                yield \\\"\\\", \\\"probe_length\\\"\\n\"\n"
0161         ".ascii \"                yield \\\"\\\", build_string(0)\\n\"\n"
0162         ".ascii \"            if self.N > 1:\\n\"\n"
0163         ".ascii \"                yield \\\"\\\", \\\"num_comparisons\\\"\\n\"\n"
0164         ".ascii \"                yield \\\"\\\", build_string(1)\\n\"\n"
0165 
0166         ".ascii \"        return generator()\\n\"\n"
0167 
0168         ".ascii \"class BoostUnorderedFoaPrinter:\\n\"\n"
0169         ".ascii \"    def __init__(self, val):\\n\"\n"
0170         ".ascii \"        self.val = BoostUnorderedHelpers.maybe_unwrap_reference(val)\\n\"\n"
0171         ".ascii \"        self.name = f\\\"{self.val.type.strip_typedefs()}\\\".split(\\\"<\\\")[0]\\n\"\n"
0172         ".ascii \"        self.name = self.name.replace(\\\"boost::unordered::\\\", \\\"boost::\\\")\\n\"\n"
0173         ".ascii \"        self.is_map = self.name.endswith(\\\"map\\\")\\n\"\n"
0174         ".ascii \"        self.cpo = BoostUnorderedPointerCustomizationPoint(self.val[\\\"table_\\\"][\\\"arrays\\\"][\\\"groups_\\\"])\\n\"\n"
0175 
0176         ".ascii \"    def to_string(self):\\n\"\n"
0177         ".ascii \"        size = BoostUnorderedHelpers.maybe_unwrap_atomic(self.val[\\\"table_\\\"][\\\"size_ctrl\\\"][\\\"size\\\"])\\n\"\n"
0178         ".ascii \"        return f\\\"{self.name} with {size} elements\\\"\\n\"\n"
0179 
0180         ".ascii \"    def display_hint(self):\\n\"\n"
0181         ".ascii \"        return \\\"map\\\"\\n\"\n"
0182 
0183         ".ascii \"    def is_regular_layout(self, group):\\n\"\n"
0184         ".ascii \"        typename = group[\\\"m\\\"].type.strip_typedefs()\\n\"\n"
0185         ".ascii \"        array_size = typename.sizeof // typename.target().sizeof\\n\"\n"
0186         ".ascii \"        if array_size == 16:\\n\"\n"
0187         ".ascii \"            return True\\n\"\n"
0188         ".ascii \"        elif array_size == 2:\\n\"\n"
0189         ".ascii \"            return False\\n\"\n"
0190 
0191         ".ascii \"    def match_occupied(self, group):\\n\"\n"
0192         ".ascii \"        m = group[\\\"m\\\"]\\n\"\n"
0193         ".ascii \"        at = lambda b: BoostUnorderedHelpers.maybe_unwrap_atomic(m[b][\\\"n\\\"])\\n\"\n"
0194 
0195         ".ascii \"        if self.is_regular_layout(group):\\n\"\n"
0196         ".ascii \"            bits = [1 << b for b in range(16) if at(b) == 0]\\n\"\n"
0197         ".ascii \"            return 0x7FFF & ~sum(bits)\\n\"\n"
0198         ".ascii \"        else:\\n\"\n"
0199         ".ascii \"            xx = at(0) | at(1)\\n\"\n"
0200         ".ascii \"            yy = xx | (xx >> 32)\\n\"\n"
0201         ".ascii \"            return 0x7FFF & (yy | (yy >> 16))\\n\"\n"
0202 
0203         ".ascii \"    def is_sentinel(self, group, pos):\\n\"\n"
0204         ".ascii \"        m = group[\\\"m\\\"]\\n\"\n"
0205         ".ascii \"        at = lambda b: BoostUnorderedHelpers.maybe_unwrap_atomic(m[b][\\\"n\\\"])\\n\"\n"
0206 
0207         ".ascii \"        N = group[\\\"N\\\"]\\n\"\n"
0208         ".ascii \"        sentinel_ = group[\\\"sentinel_\\\"]\\n\"\n"
0209         ".ascii \"        if self.is_regular_layout(group):\\n\"\n"
0210         ".ascii \"            return pos == N-1 and at(N-1) == sentinel_\\n\"\n"
0211         ".ascii \"        else:\\n\"\n"
0212         ".ascii \"            return pos == N-1 and (at(0) & 0x4000400040004000) == 0x4000 and (at(1) & 0x4000400040004000) == 0\\n\"\n"
0213 
0214         ".ascii \"    def children(self):\\n\"\n"
0215         ".ascii \"        def generator():\\n\"\n"
0216         ".ascii \"            table = self.val[\\\"table_\\\"]\\n\"\n"
0217         ".ascii \"            groups = self.cpo.to_address(table[\\\"arrays\\\"][\\\"groups_\\\"])\\n\"\n"
0218         ".ascii \"            elements = self.cpo.to_address(table[\\\"arrays\\\"][\\\"elements_\\\"])\\n\"\n"
0219 
0220         ".ascii \"            pc_ = groups.cast(gdb.lookup_type(\\\"unsigned char\\\").pointer())\\n\"\n"
0221         ".ascii \"            p_ = elements\\n\"\n"
0222         ".ascii \"            first_time = True\\n\"\n"
0223         ".ascii \"            mask = 0\\n\"\n"
0224         ".ascii \"            n0 = 0\\n\"\n"
0225         ".ascii \"            n = 0\\n\"\n"
0226 
0227         ".ascii \"            count = 0\\n\"\n"
0228         ".ascii \"            while p_ != 0:\\n\"\n"
0229         ".ascii \"                # This if block mirrors the condition in the begin() call\\n\"\n"
0230         ".ascii \"                if (not first_time) or (self.match_occupied(groups.dereference()) & 1):\\n\"\n"
0231         ".ascii \"                    pointer = BoostUnorderedHelpers.maybe_unwrap_foa_element(p_)\\n\"\n"
0232         ".ascii \"                    value = self.cpo.to_address(pointer).dereference()\\n\"\n"
0233         ".ascii \"                    if self.is_map:\\n\"\n"
0234         ".ascii \"                        first = value[\\\"first\\\"]\\n\"\n"
0235         ".ascii \"                        second = value[\\\"second\\\"]\\n\"\n"
0236         ".ascii \"                        yield \\\"\\\", first\\n\"\n"
0237         ".ascii \"                        yield \\\"\\\", second\\n\"\n"
0238         ".ascii \"                    else:\\n\"\n"
0239         ".ascii \"                        yield \\\"\\\", count\\n\"\n"
0240         ".ascii \"                        yield \\\"\\\", value\\n\"\n"
0241         ".ascii \"                    count += 1\\n\"\n"
0242         ".ascii \"                first_time = False\\n\"\n"
0243 
0244         ".ascii \"                n0 = pc_.cast(gdb.lookup_type(\\\"uintptr_t\\\")) % groups.dereference().type.sizeof\\n\"\n"
0245         ".ascii \"                pc_ = self.cpo.next(pc_, -n0)\\n\"\n"
0246 
0247         ".ascii \"                mask = (self.match_occupied(pc_.cast(groups.type).dereference()) >> (n0+1)) << (n0+1)\\n\"\n"
0248         ".ascii \"                while mask == 0:\\n\"\n"
0249         ".ascii \"                    pc_ = self.cpo.next(pc_, groups.dereference().type.sizeof)\\n\"\n"
0250         ".ascii \"                    p_ = self.cpo.next(p_, groups.dereference()[\\\"N\\\"])\\n\"\n"
0251         ".ascii \"                    mask = self.match_occupied(pc_.cast(groups.type).dereference())\\n\"\n"
0252 
0253         ".ascii \"                n = BoostUnorderedHelpers.countr_zero(mask)\\n\"\n"
0254         ".ascii \"                if self.is_sentinel(pc_.cast(groups.type).dereference(), n):\\n\"\n"
0255         ".ascii \"                    p_ = 0\\n\"\n"
0256         ".ascii \"                else:\\n\"\n"
0257         ".ascii \"                    pc_ = self.cpo.next(pc_, n)\\n\"\n"
0258         ".ascii \"                    p_ = self.cpo.next(p_, n - n0)\\n\"\n"
0259 
0260         ".ascii \"        return generator()\\n\"\n"
0261 
0262         ".ascii \"class BoostUnorderedFoaIteratorPrinter:\\n\"\n"
0263         ".ascii \"    def __init__(self, val):\\n\"\n"
0264         ".ascii \"        self.val = val\\n\"\n"
0265         ".ascii \"        self.cpo = BoostUnorderedPointerCustomizationPoint(self.val[\\\"p_\\\"])\\n\"\n"
0266 
0267         ".ascii \"    def to_string(self):\\n\"\n"
0268         ".ascii \"        if self.valid():\\n\"\n"
0269         ".ascii \"            element = self.cpo.to_address(self.val[\\\"p_\\\"])\\n\"\n"
0270         ".ascii \"            pointer = BoostUnorderedHelpers.maybe_unwrap_foa_element(element)\\n\"\n"
0271         ".ascii \"            value = self.cpo.to_address(pointer).dereference()\\n\"\n"
0272         ".ascii \"            return f\\\"iterator = {{ {value} }}\\\"\\n\"\n"
0273         ".ascii \"        else:\\n\"\n"
0274         ".ascii \"            return \\\"iterator = { end iterator }\\\"\\n\"\n"
0275 
0276         ".ascii \"    def valid(self):\\n\"\n"
0277         ".ascii \"        return (self.cpo.to_address(self.val[\\\"p_\\\"]) != 0) and (self.cpo.to_address(self.val[\\\"pc_\\\"]) != 0)\\n\"\n"
0278 
0279         ".ascii \"def boost_unordered_build_pretty_printer():\\n\"\n"
0280         ".ascii \"    pp = gdb.printing.RegexpCollectionPrettyPrinter(\\\"boost_unordered\\\")\\n\"\n"
0281         ".ascii \"    add_template_printer = lambda name, printer: pp.add_printer(name, f\\\"^{name}<.*>$\\\", printer)\\n\"\n"
0282         ".ascii \"    add_concrete_printer = lambda name, printer: pp.add_printer(name, f\\\"^{name}$\\\", printer)\\n\"\n"
0283 
0284         ".ascii \"    add_template_printer(\\\"boost::unordered::unordered_map\\\", BoostUnorderedFcaPrinter)\\n\"\n"
0285         ".ascii \"    add_template_printer(\\\"boost::unordered::unordered_multimap\\\", BoostUnorderedFcaPrinter)\\n\"\n"
0286         ".ascii \"    add_template_printer(\\\"boost::unordered::unordered_set\\\", BoostUnorderedFcaPrinter)\\n\"\n"
0287         ".ascii \"    add_template_printer(\\\"boost::unordered::unordered_multiset\\\", BoostUnorderedFcaPrinter)\\n\"\n"
0288 
0289         ".ascii \"    add_template_printer(\\\"boost::unordered::detail::iterator_detail::iterator\\\", BoostUnorderedFcaIteratorPrinter)\\n\"\n"
0290         ".ascii \"    add_template_printer(\\\"boost::unordered::detail::iterator_detail::c_iterator\\\", BoostUnorderedFcaIteratorPrinter)\\n\"\n"
0291 
0292         ".ascii \"    add_template_printer(\\\"boost::unordered::unordered_flat_map\\\", BoostUnorderedFoaPrinter)\\n\"\n"
0293         ".ascii \"    add_template_printer(\\\"boost::unordered::unordered_flat_set\\\", BoostUnorderedFoaPrinter)\\n\"\n"
0294         ".ascii \"    add_template_printer(\\\"boost::unordered::unordered_node_map\\\", BoostUnorderedFoaPrinter)\\n\"\n"
0295         ".ascii \"    add_template_printer(\\\"boost::unordered::unordered_node_set\\\", BoostUnorderedFoaPrinter)\\n\"\n"
0296         ".ascii \"    add_template_printer(\\\"boost::unordered::concurrent_flat_map\\\", BoostUnorderedFoaPrinter)\\n\"\n"
0297         ".ascii \"    add_template_printer(\\\"boost::unordered::concurrent_flat_set\\\", BoostUnorderedFoaPrinter)\\n\"\n"
0298         ".ascii \"    add_template_printer(\\\"boost::unordered::concurrent_node_map\\\", BoostUnorderedFoaPrinter)\\n\"\n"
0299         ".ascii \"    add_template_printer(\\\"boost::unordered::concurrent_node_set\\\", BoostUnorderedFoaPrinter)\\n\"\n"
0300 
0301         ".ascii \"    add_template_printer(\\\"boost::unordered::detail::foa::table_iterator\\\", BoostUnorderedFoaIteratorPrinter)\\n\"\n"
0302 
0303         ".ascii \"    add_concrete_printer(\\\"boost::unordered::detail::foa::table_core_cumulative_stats\\\", BoostUnorderedFoaTableCoreCumulativeStatsPrinter)\\n\"\n"
0304         ".ascii \"    add_template_printer(\\\"boost::unordered::detail::foa::cumulative_stats\\\", BoostUnorderedFoaCumulativeStatsPrinter)\\n\"\n"
0305         ".ascii \"    add_template_printer(\\\"boost::unordered::detail::foa::concurrent_cumulative_stats\\\", BoostUnorderedFoaCumulativeStatsPrinter)\\n\"\n"
0306 
0307         ".ascii \"    return pp\\n\"\n"
0308 
0309         ".ascii \"gdb.printing.register_pretty_printer(gdb.current_objfile(), boost_unordered_build_pretty_printer())\\n\"\n"
0310 
0311 
0312 
0313         ".ascii \"# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Writing-an-Xmethod.html\\n\"\n"
0314         ".ascii \"class BoostUnorderedFoaGetStatsMethod(gdb.xmethod.XMethod):\\n\"\n"
0315         ".ascii \"    def __init__(self):\\n\"\n"
0316         ".ascii \"        gdb.xmethod.XMethod.__init__(self, \\\"get_stats\\\")\\n\"\n"
0317 
0318         ".ascii \"    def get_worker(self, method_name):\\n\"\n"
0319         ".ascii \"        if method_name == \\\"get_stats\\\":\\n\"\n"
0320         ".ascii \"            return BoostUnorderedFoaGetStatsWorker()\\n\"\n"
0321 
0322         ".ascii \"class BoostUnorderedFoaGetStatsWorker(gdb.xmethod.XMethodWorker):\\n\"\n"
0323         ".ascii \"    def get_arg_types(self):\\n\"\n"
0324         ".ascii \"        return None\\n\"\n"
0325 
0326         ".ascii \"    def get_result_type(self, obj):\\n\"\n"
0327         ".ascii \"        return gdb.lookup_type(\\\"boost::unordered::detail::foa::table_core_cumulative_stats\\\")\\n\"\n"
0328 
0329         ".ascii \"    def __call__(self, obj):\\n\"\n"
0330         ".ascii \"        try:\\n\"\n"
0331         ".ascii \"            return obj[\\\"table_\\\"][\\\"cstats\\\"]\\n\"\n"
0332         ".ascii \"        except gdb.error:\\n\"\n"
0333         ".ascii \"            print(\\\"Error: Binary was compiled without stats. Recompile with `BOOST_UNORDERED_ENABLE_STATS` defined.\\\")\\n\"\n"
0334         ".ascii \"            return\\n\"\n"
0335 
0336         ".ascii \"class BoostUnorderedFoaMatcher(gdb.xmethod.XMethodMatcher):\\n\"\n"
0337         ".ascii \"    def __init__(self):\\n\"\n"
0338         ".ascii \"        gdb.xmethod.XMethodMatcher.__init__(self, 'BoostUnorderedFoaMatcher')\\n\"\n"
0339         ".ascii \"        self.methods = [BoostUnorderedFoaGetStatsMethod()]\\n\"\n"
0340 
0341         ".ascii \"    def match(self, class_type, method_name):\\n\"\n"
0342         ".ascii \"        template_name = f\\\"{class_type.strip_typedefs()}\\\".split(\\\"<\\\")[0]\\n\"\n"
0343         ".ascii \"        regex = \\\"^boost::unordered::(unordered|concurrent)_(flat|node)_(map|set)$\\\"\\n\"\n"
0344         ".ascii \"        if not re.match(regex, template_name):\\n\"\n"
0345         ".ascii \"            return None\\n\"\n"
0346 
0347         ".ascii \"        workers = []\\n\"\n"
0348         ".ascii \"        for method in self.methods:\\n\"\n"
0349         ".ascii \"            if method.enabled:\\n\"\n"
0350         ".ascii \"                worker = method.get_worker(method_name)\\n\"\n"
0351         ".ascii \"                if worker:\\n\"\n"
0352         ".ascii \"                    workers.append(worker)\\n\"\n"
0353         ".ascii \"        return workers\\n\"\n"
0354 
0355         ".ascii \"gdb.xmethod.register_xmethod_matcher(None, BoostUnorderedFoaMatcher())\\n\"\n"
0356 
0357 
0358 
0359         ".ascii \"\\\"\\\"\\\" Fancy pointer support \\\"\\\"\\\"\\n\"\n"
0360 
0361         ".ascii \"\\\"\\\"\\\"\\n\"\n"
0362         ".ascii \"To allow your own fancy pointer type to interact with Boost.Unordered GDB pretty-printers,\\n\"\n"
0363         ".ascii \"create a pretty-printer for your own type with the following additional methods.\\n\"\n"
0364 
0365         ".ascii \"(Note, this is assuming the presence of a type alias `pointer` for the underlying\\n\"\n"
0366         ".ascii \"raw pointer type, Substitute whichever name is applicable in your case.)\\n\"\n"
0367 
0368         ".ascii \"`boost_to_address(fancy_ptr)`\\n\"\n"
0369         ".ascii \"    * A static method, but `@staticmethod` is not required\\n\"\n"
0370         ".ascii \"    * Parameter `fancy_ptr` of type `gdb.Value`\\n\"\n"
0371         ".ascii \"        * Its `.type` will be your fancy pointer type\\n\"\n"
0372         ".ascii \"    * Returns a `gdb.Value` with the raw pointer equivalent to your fancy pointer\\n\"\n"
0373         ".ascii \"        * This method should be equivalent to calling `operator->()` on your fancy pointer in C++\\n\"\n"
0374 
0375         ".ascii \"`boost_next(raw_ptr, offset)`\\n\"\n"
0376         ".ascii \"    * Parameter `raw_ptr` of type `gdb.Value`\\n\"\n"
0377         ".ascii \"        * Its `.type` will be `pointer`\\n\"\n"
0378         ".ascii \"    * Parameter `offset`\\n\"\n"
0379         ".ascii \"        * Either has integer type, or is of type `gdb.Value` with an underlying integer\\n\"\n"
0380         ".ascii \"    * Returns a `gdb.Value` with the raw pointer equivalent to your fancy pointer, as if you did the following operations\\n\"\n"
0381         ".ascii \"        1. Convert the incoming raw pointer to your fancy pointer\\n\"\n"
0382         ".ascii \"        2. Use operator+= to add the offset to the fancy pointer\\n\"\n"
0383         ".ascii \"        3. Convert back to the raw pointer\\n\"\n"
0384         ".ascii \"    * Note, you will not actually do these operations as stated. You will do equivalent lower-level operations that emulate having done the above\\n\"\n"
0385         ".ascii \"        * Ultimately, it will be as if you called `operator+()` on your fancy pointer in C++, but using only raw pointers\\n\"\n"
0386 
0387         ".ascii \"Example\\n\"\n"
0388         ".ascii \"```\\n\"\n"
0389         ".ascii \"class MyFancyPtrPrinter:\\n\"\n"
0390         ".ascii \"    ...\\n\"\n"
0391 
0392         ".ascii \"    # Equivalent to `operator->()`\\n\"\n"
0393         ".ascii \"    def boost_to_address(fancy_ptr):\\n\"\n"
0394         ".ascii \"        ...\\n\"\n"
0395         ".ascii \"        return ...\\n\"\n"
0396 
0397         ".ascii \"    # Equivalent to `operator+()`\\n\"\n"
0398         ".ascii \"    def boost_next(raw_ptr, offset):\\n\"\n"
0399         ".ascii \"        ...\\n\"\n"
0400         ".ascii \"        return ...\\n\"\n"
0401 
0402         ".ascii \"    ...\\n\"\n"
0403         ".ascii \"```\\n\"\n"
0404         ".ascii \"\\\"\\\"\\\"\\n\"\n"
0405 
0406         ".byte 0\n"
0407         ".popsection\n");
0408 #ifdef __clang__
0409 #pragma clang diagnostic pop
0410 #endif
0411 #endif // defined(__ELF__)
0412 #endif // !defined(BOOST_ALL_NO_EMBEDDED_GDB_SCRIPTS)
0413 
0414 #endif // !defined(BOOST_UNORDERED_UNORDERED_PRINTERS_HPP)