blob: e2ef18bfea44c235b9693eb67447eacd646b3ce1 [file] [log] [blame]
Enrico Granata91239502012-05-08 19:21:13 +00001"""
2Summary and synthetic providers for LLDB-specific shared pointers
3
4part of The LLVM Compiler Infrastructure
5This file is distributed under the University of Illinois Open Source
6License. See LICENSE.TXT for details.
7"""
8
Enrico Granata91239502012-05-08 19:21:13 +00009
Kate Stoneb9c1b512016-09-06 20:57:50 +000010class SharedPtr_SyntheticChildrenProvider:
11
12 def __init__(self, valobj, dict):
13 self.valobj = valobj
14 self.update()
15
16 def update(self):
17 pass
18
19 def num_children(self):
20 return 1
21
22 def get_child_index(self, name):
23 if name == "ptr":
24 return 0
25 if name == "count":
26 return 1
27 return None
28
29 def get_child_at_index(self, index):
30 if index == 0:
31 return self.valobj.GetChildMemberWithName('_M_ptr')
32 if index == 1:
33 return self.valobj.GetChildMemberWithName('_M_refcount').GetChildMemberWithName(
34 '_M_pi').GetChildMemberWithName('_M_use_count')
35 return None
36
37
38def SharedPtr_SummaryProvider(valobj, dict):
39 return 'use = ' + \
40 str(valobj.GetChildMemberWithName("count").GetValueAsUnsigned())
41
Enrico Granata91239502012-05-08 19:21:13 +000042
43class ValueObjectSP_SyntheticChildrenProvider:
Enrico Granata91239502012-05-08 19:21:13 +000044
Kate Stoneb9c1b512016-09-06 20:57:50 +000045 def __init__(self, valobj, dict):
46 self.valobj = valobj
47 self.update()
48
49 def update(self):
50 pass
51
52 def num_children(self):
53 return 1
54
55 def get_child_index(self, name):
56 if name == "ptr":
57 return 0
58 if name == "count":
59 return 1
60 return None
61
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(
67 'cntrl_').GetChildMemberWithName('shared_owners_')
68 return None
69
70
71def ValueObjectSP_SummaryProvider(valobj, dict):
72 return 'use = ' + \
73 str(1 + valobj.GetChildMemberWithName("count").GetValueAsUnsigned())
74
Enrico Granata91239502012-05-08 19:21:13 +000075
76def __lldb_init_module(debugger, dict):
Kate Stoneb9c1b512016-09-06 20:57:50 +000077 debugger.HandleCommand(
78 'type summary add -x ".*ValueObjectSP" --expand -F sp_cp.ValueObjectSP_SummaryProvider')
79 debugger.HandleCommand(
80 'type synthetic add -x ".*ValueObjectSP" -l sp_cp.ValueObjectSP_SyntheticChildrenProvider')
81 debugger.HandleCommand(
82 'type summary add -x ".*SP" --expand -F sp_cp.SharedPtr_SummaryProvider')
83 debugger.HandleCommand(
84 'type synthetic add -x ".*SP" -l sp_cp.SharedPtr_SyntheticChildrenProvider')