authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-02-26 22:18:33-05:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-02-27 05:37:03-05:00
log57236961e6fc9da02623f79131f58113e3fa0531
treece52320895dcc292ecb694de6c4940a996328d2a
parenta3529c2dea579e0a15dcde1b8ee71d9ec9c75330

tools: revert sharing of stage2 pretty printer info

Partial revert of 1e963053d0ff67361b587b046a917375e963d5e9. Now that lldb has a new method for accessing this data that does not require manual updating, there is no longer any reason to share this data.

2 files changed, 105 insertions(+), 112 deletions(-)

tools/stage2_gdb_pretty_printers.py+105-14
......@@ -3,13 +3,55 @@
33import re
44import gdb.printing
55
6import sys
7from pathlib import Path
8sys.path.insert(0, str(Path(__file__).parent))
9import stage2_pretty_printers_common as common
10
11
126class TypePrinter:
7 no_payload_count = 4096
8
9 # Keep in sync with src/type.zig
10 # Types which have no payload do not need to be entered here.
11 payload_type_names = {
12 'array_u8': 'Type.Payload.Len',
13 'array_u8_sentinel_0': 'Type.Payload.Len',
14
15 'single_const_pointer': 'Type.Payload.ElemType',
16 'single_mut_pointer': 'Type.Payload.ElemType',
17 'many_const_pointer': 'Type.Payload.ElemType',
18 'many_mut_pointer': 'Type.Payload.ElemType',
19 'c_const_pointer': 'Type.Payload.ElemType',
20 'c_mut_pointer': 'Type.Payload.ElemType',
21 'const_slice': 'Type.Payload.ElemType',
22 'mut_slice': 'Type.Payload.ElemType',
23 'optional': 'Type.Payload.ElemType',
24 'optional_single_mut_pointer': 'Type.Payload.ElemType',
25 'optional_single_const_pointer': 'Type.Payload.ElemType',
26 'anyframe_T': 'Type.Payload.ElemType',
27
28 'int_signed': 'Type.Payload.Bits',
29 'int_unsigned': 'Type.Payload.Bits',
30
31 'error_set': 'Type.Payload.ErrorSet',
32 'error_set_inferred': 'Type.Payload.ErrorSetInferred',
33 'error_set_merged': 'Type.Payload.ErrorSetMerged',
34
35 'array': 'Type.Payload.Array',
36 'vector': 'Type.Payload.Array',
37
38 'array_sentinel': 'Type.Payload.ArraySentinel',
39 'pointer': 'Type.Payload.Pointer',
40 'function': 'Type.Payload.Function',
41 'error_union': 'Type.Payload.ErrorUnion',
42 'error_set_single': 'Type.Payload.Name',
43 'opaque': 'Type.Payload.Opaque',
44 'struct': 'Type.Payload.Struct',
45 'union': 'Type.Payload.Union',
46 'union_tagged': 'Type.Payload.Union',
47 'enum_full, .enum_nonexhaustive': 'Type.Payload.EnumFull',
48 'enum_simple': 'Type.Payload.EnumSimple',
49 'enum_numbered': 'Type.Payload.EnumNumbered',
50 'empty_struct': 'Type.Payload.ContainerScope',
51 'tuple': 'Type.Payload.Tuple',
52 'anon_struct': 'Type.Payload.AnonStruct',
53 }
54
1355 def __init__(self, val):
1456 self.val = val
1557
......@@ -17,7 +59,7 @@ class TypePrinter:
1759 tag_if_small_enough = self.val['tag_if_small_enough']
1860 tag_type = tag_if_small_enough.type
1961
20 if tag_if_small_enough < common.Type.no_payload_count:
62 if tag_if_small_enough < TypePrinter.no_payload_count:
2163 return tag_if_small_enough
2264 else:
2365 return self.val['ptr_otherwise'].dereference()['tag']
......@@ -27,7 +69,7 @@ class TypePrinter:
2769 if tag is None:
2870 return None
2971
30 type_name = common.Type.payload_type_names.get(str(tag))
72 type_name = TypePrinter.payload_type_names.get(str(tag))
3173 if type_name is None:
3274 return None
3375 return gdb.lookup_type('struct type.%s' % type_name)
......@@ -36,12 +78,12 @@ class TypePrinter:
3678 tag = self.tag()
3779 if tag is None:
3880 return '(invalid type)'
39 if self.val['tag_if_small_enough'] < common.Type.no_payload_count:
81 if self.val['tag_if_small_enough'] < TypePrinter.no_payload_count:
4082 return '.%s' % str(tag)
4183 return None
4284
4385 def children(self):
44 if self.val['tag_if_small_enough'] < common.Type.no_payload_count:
86 if self.val['tag_if_small_enough'] < TypePrinter.no_payload_count:
4587 return
4688
4789 yield ('tag', '.%s' % str(self.tag()))
......@@ -51,6 +93,55 @@ class TypePrinter:
5193 yield ('payload', self.val['ptr_otherwise'].cast(payload_type.pointer()).dereference()['data'])
5294
5395class ValuePrinter:
96 no_payload_count = 4096
97
98 # Keep in sync with src/value.zig
99 # Values which have no payload do not need to be entered here.
100 payload_type_names = {
101 'big_int_positive': 'Value.Payload.BigInt',
102 'big_int_negative': 'Value.Payload.BigInt',
103
104 'extern_fn': 'Value.Payload.ExternFn',
105
106 'decl_ref': 'Value.Payload.Decl',
107
108 'repeated': 'Value.Payload.SubValue',
109 'eu_payload': 'Value.Payload.SubValue',
110 'opt_payload': 'Value.Payload.SubValue',
111 'empty_array_sentinel': 'Value.Payload.SubValue',
112
113 'eu_payload_ptr': 'Value.Payload.PayloadPtr',
114 'opt_payload_ptr': 'Value.Payload.PayloadPtr',
115
116 'bytes': 'Value.Payload.Bytes',
117 'enum_literal': 'Value.Payload.Bytes',
118
119 'slice': 'Value.Payload.Slice',
120
121 'enum_field_index': 'Value.Payload.U32',
122
123 'ty': 'Value.Payload.Ty',
124 'int_type': 'Value.Payload.IntType',
125 'int_u64': 'Value.Payload.U64',
126 'int_i64': 'Value.Payload.I64',
127 'function': 'Value.Payload.Function',
128 'variable': 'Value.Payload.Variable',
129 'decl_ref_mut': 'Value.Payload.DeclRefMut',
130 'elem_ptr': 'Value.Payload.ElemPtr',
131 'field_ptr': 'Value.Payload.FieldPtr',
132 'float_16': 'Value.Payload.Float_16',
133 'float_32': 'Value.Payload.Float_32',
134 'float_64': 'Value.Payload.Float_64',
135 'float_80': 'Value.Payload.Float_80',
136 'float_128': 'Value.Payload.Float_128',
137 'error': 'Value.Payload.Error',
138 'inferred_alloc': 'Value.Payload.InferredAlloc',
139 'inferred_alloc_comptime': 'Value.Payload.InferredAllocComptime',
140 'aggregate': 'Value.Payload.Aggregate',
141 'union': 'Value.Payload.Union',
142 'bound_fn': 'Value.Payload.BoundFn',
143 }
144
54145 def __init__(self, val):
55146 self.val = val
56147
......@@ -58,7 +149,7 @@ class ValuePrinter:
58149 tag_if_small_enough = self.val['tag_if_small_enough']
59150 tag_type = tag_if_small_enough.type
60151
61 if tag_if_small_enough < common.Value.no_payload_count:
152 if tag_if_small_enough < ValuePrinter.no_payload_count:
62153 return tag_if_small_enough
63154 else:
64155 return self.val['ptr_otherwise'].dereference()['tag']
......@@ -68,7 +159,7 @@ class ValuePrinter:
68159 if tag is None:
69160 return None
70161
71 type_name = Comman.Value.payload_type_names.get(str(tag))
162 type_name = ValuePrinter.payload_type_names.get(str(tag))
72163 if type_name is None:
73164 return None
74165 return gdb.lookup_type('struct value.%s' % type_name)
......@@ -77,12 +168,12 @@ class ValuePrinter:
77168 tag = self.tag()
78169 if tag is None:
79170 return '(invalid value)'
80 if self.val['tag_if_small_enough'] < common.Value.no_payload_count:
171 if self.val['tag_if_small_enough'] < ValuePrinter.no_payload_count:
81172 return '.%s' % str(tag)
82173 return None
83174
84175 def children(self):
85 if self.val['tag_if_small_enough'] < common.Value.no_payload_count:
176 if self.val['tag_if_small_enough'] < ValuePrinter.no_payload_count:
86177 return
87178
88179 yield ('tag', '.%s' % str(self.tag()))
tools/stage2_pretty_printers_common.py deleted-98
......@@ -1,98 +0,0 @@
1class Type:
2 no_payload_count = 4096
3
4 # Keep in sync with src/type.zig
5 # Types which have no payload do not need to be entered here.
6 payload_type_names = {
7 'array_u8': 'Type.Payload.Len',
8 'array_u8_sentinel_0': 'Type.Payload.Len',
9
10 'single_const_pointer': 'Type.Payload.ElemType',
11 'single_mut_pointer': 'Type.Payload.ElemType',
12 'many_const_pointer': 'Type.Payload.ElemType',
13 'many_mut_pointer': 'Type.Payload.ElemType',
14 'c_const_pointer': 'Type.Payload.ElemType',
15 'c_mut_pointer': 'Type.Payload.ElemType',
16 'const_slice': 'Type.Payload.ElemType',
17 'mut_slice': 'Type.Payload.ElemType',
18 'optional': 'Type.Payload.ElemType',
19 'optional_single_mut_pointer': 'Type.Payload.ElemType',
20 'optional_single_const_pointer': 'Type.Payload.ElemType',
21 'anyframe_T': 'Type.Payload.ElemType',
22
23 'int_signed': 'Type.Payload.Bits',
24 'int_unsigned': 'Type.Payload.Bits',
25
26 'error_set': 'Type.Payload.ErrorSet',
27 'error_set_inferred': 'Type.Payload.ErrorSetInferred',
28 'error_set_merged': 'Type.Payload.ErrorSetMerged',
29
30 'array': 'Type.Payload.Array',
31 'vector': 'Type.Payload.Array',
32
33 'array_sentinel': 'Type.Payload.ArraySentinel',
34 'pointer': 'Type.Payload.Pointer',
35 'function': 'Type.Payload.Function',
36 'error_union': 'Type.Payload.ErrorUnion',
37 'error_set_single': 'Type.Payload.Name',
38 'opaque': 'Type.Payload.Opaque',
39 'struct': 'Type.Payload.Struct',
40 'union': 'Type.Payload.Union',
41 'union_tagged': 'Type.Payload.Union',
42 'enum_full, .enum_nonexhaustive': 'Type.Payload.EnumFull',
43 'enum_simple': 'Type.Payload.EnumSimple',
44 'enum_numbered': 'Type.Payload.EnumNumbered',
45 'empty_struct': 'Type.Payload.ContainerScope',
46 'tuple': 'Type.Payload.Tuple',
47 'anon_struct': 'Type.Payload.AnonStruct',
48 }
49
50class Value:
51 no_payload_count = 4096
52
53 # Keep in sync with src/value.zig
54 # Values which have no payload do not need to be entered here.
55 payload_type_names = {
56 'big_int_positive': 'Value.Payload.BigInt',
57 'big_int_negative': 'Value.Payload.BigInt',
58
59 'extern_fn': 'Value.Payload.ExternFn',
60
61 'decl_ref': 'Value.Payload.Decl',
62
63 'repeated': 'Value.Payload.SubValue',
64 'eu_payload': 'Value.Payload.SubValue',
65 'opt_payload': 'Value.Payload.SubValue',
66 'empty_array_sentinel': 'Value.Payload.SubValue',
67
68 'eu_payload_ptr': 'Value.Payload.PayloadPtr',
69 'opt_payload_ptr': 'Value.Payload.PayloadPtr',
70
71 'bytes': 'Value.Payload.Bytes',
72 'enum_literal': 'Value.Payload.Bytes',
73
74 'slice': 'Value.Payload.Slice',
75
76 'enum_field_index': 'Value.Payload.U32',
77
78 'ty': 'Value.Payload.Ty',
79 'int_type': 'Value.Payload.IntType',
80 'int_u64': 'Value.Payload.U64',
81 'int_i64': 'Value.Payload.I64',
82 'function': 'Value.Payload.Function',
83 'variable': 'Value.Payload.Variable',
84 'decl_ref_mut': 'Value.Payload.DeclRefMut',
85 'elem_ptr': 'Value.Payload.ElemPtr',
86 'field_ptr': 'Value.Payload.FieldPtr',
87 'float_16': 'Value.Payload.Float_16',
88 'float_32': 'Value.Payload.Float_32',
89 'float_64': 'Value.Payload.Float_64',
90 'float_80': 'Value.Payload.Float_80',
91 'float_128': 'Value.Payload.Float_128',
92 'error': 'Value.Payload.Error',
93 'inferred_alloc': 'Value.Payload.InferredAlloc',
94 'inferred_alloc_comptime': 'Value.Payload.InferredAllocComptime',
95 'aggregate': 'Value.Payload.Aggregate',
96 'union': 'Value.Payload.Union',
97 'bound_fn': 'Value.Payload.BoundFn',
98 }