brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 549ab27 Raw
91 lines · python
1"""2Summary and synthetic providers for LLDB-specific shared pointers3 4Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5See https://llvm.org/LICENSE.txt for license information.6SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7"""8 9 10class SharedPtr_SyntheticChildrenProvider:11    def __init__(self, valobj, dict):12        self.valobj = valobj13        self.update()14 15    def update(self):16        pass17 18    def num_children(self):19        return 120 21    def get_child_index(self, name):22        if name == "ptr":23            return 024        if name == "count":25            return 126        return None27 28    def get_child_at_index(self, index):29        if index == 0:30            return self.valobj.GetChildMemberWithName("_M_ptr")31        if index == 1:32            return (33                self.valobj.GetChildMemberWithName("_M_refcount")34                .GetChildMemberWithName("_M_pi")35                .GetChildMemberWithName("_M_use_count")36            )37        return None38 39 40def SharedPtr_SummaryProvider(valobj, dict):41    return "use = " + str(valobj.GetChildMemberWithName("count").GetValueAsUnsigned())42 43 44class ValueObjectSP_SyntheticChildrenProvider:45    def __init__(self, valobj, dict):46        self.valobj = valobj47        self.update()48 49    def update(self):50        pass51 52    def num_children(self):53        return 154 55    def get_child_index(self, name):56        if name == "ptr":57            return 058        if name == "count":59            return 160        return None61 62    def get_child_at_index(self, index):63        if index == 0:64            return self.valobj.GetChildMemberWithName("ptr_")65        if index == 1:66            return self.valobj.GetChildMemberWithName("cntrl_").GetChildMemberWithName(67                "shared_owners_"68            )69        return None70 71 72def ValueObjectSP_SummaryProvider(valobj, dict):73    return "use = " + str(74        1 + valobj.GetChildMemberWithName("count").GetValueAsUnsigned()75    )76 77 78def __lldb_init_module(debugger, dict):79    debugger.HandleCommand(80        'type summary add -x ".*ValueObjectSP" --expand -F sp_cp.ValueObjectSP_SummaryProvider'81    )82    debugger.HandleCommand(83        'type synthetic add -x ".*ValueObjectSP" -l sp_cp.ValueObjectSP_SyntheticChildrenProvider'84    )85    debugger.HandleCommand(86        'type summary add -x ".*SP" --expand -F sp_cp.SharedPtr_SummaryProvider'87    )88    debugger.HandleCommand(89        'type synthetic add -x ".*SP" -l sp_cp.SharedPtr_SyntheticChildrenProvider'90    )91