Commit 57236961e6

Jacob Young <jacobly0@users.noreply.github.com>
2023-02-27 04:18:33
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.
1 parent a3529c2
tools/stage2_gdb_pretty_printers.py
@@ -3,13 +3,55 @@
 import re
 import gdb.printing
 
-import sys
-from pathlib import Path
-sys.path.insert(0, str(Path(__file__).parent))
-import stage2_pretty_printers_common as common
-
-
 class TypePrinter:
+    no_payload_count = 4096
+
+    # Keep in sync with src/type.zig
+    # Types which have no payload do not need to be entered here.
+    payload_type_names = {
+        'array_u8': 'Type.Payload.Len',
+        'array_u8_sentinel_0': 'Type.Payload.Len',
+
+        'single_const_pointer': 'Type.Payload.ElemType',
+        'single_mut_pointer': 'Type.Payload.ElemType',
+        'many_const_pointer': 'Type.Payload.ElemType',
+        'many_mut_pointer': 'Type.Payload.ElemType',
+        'c_const_pointer': 'Type.Payload.ElemType',
+        'c_mut_pointer': 'Type.Payload.ElemType',
+        'const_slice': 'Type.Payload.ElemType',
+        'mut_slice': 'Type.Payload.ElemType',
+        'optional': 'Type.Payload.ElemType',
+        'optional_single_mut_pointer': 'Type.Payload.ElemType',
+        'optional_single_const_pointer': 'Type.Payload.ElemType',
+        'anyframe_T': 'Type.Payload.ElemType',
+
+        'int_signed': 'Type.Payload.Bits',
+        'int_unsigned': 'Type.Payload.Bits',
+
+        'error_set': 'Type.Payload.ErrorSet',
+        'error_set_inferred': 'Type.Payload.ErrorSetInferred',
+        'error_set_merged': 'Type.Payload.ErrorSetMerged',
+
+        'array': 'Type.Payload.Array',
+        'vector': 'Type.Payload.Array',
+
+        'array_sentinel': 'Type.Payload.ArraySentinel',
+        'pointer': 'Type.Payload.Pointer',
+        'function': 'Type.Payload.Function',
+        'error_union': 'Type.Payload.ErrorUnion',
+        'error_set_single': 'Type.Payload.Name',
+        'opaque': 'Type.Payload.Opaque',
+        'struct': 'Type.Payload.Struct',
+        'union': 'Type.Payload.Union',
+        'union_tagged': 'Type.Payload.Union',
+        'enum_full, .enum_nonexhaustive': 'Type.Payload.EnumFull',
+        'enum_simple': 'Type.Payload.EnumSimple',
+        'enum_numbered': 'Type.Payload.EnumNumbered',
+        'empty_struct': 'Type.Payload.ContainerScope',
+        'tuple': 'Type.Payload.Tuple',
+        'anon_struct': 'Type.Payload.AnonStruct',
+    }
+
     def __init__(self, val):
         self.val = val
 
@@ -17,7 +59,7 @@ class TypePrinter:
         tag_if_small_enough = self.val['tag_if_small_enough']
         tag_type = tag_if_small_enough.type
 
-        if tag_if_small_enough < common.Type.no_payload_count:
+        if tag_if_small_enough < TypePrinter.no_payload_count:
             return tag_if_small_enough
         else:
             return self.val['ptr_otherwise'].dereference()['tag']
@@ -27,7 +69,7 @@ class TypePrinter:
         if tag is None:
             return None
 
-        type_name = common.Type.payload_type_names.get(str(tag))
+        type_name = TypePrinter.payload_type_names.get(str(tag))
         if type_name is None:
             return None
         return gdb.lookup_type('struct type.%s' % type_name)
@@ -36,12 +78,12 @@ class TypePrinter:
         tag = self.tag()
         if tag is None:
             return '(invalid type)'
-        if self.val['tag_if_small_enough'] < common.Type.no_payload_count:
+        if self.val['tag_if_small_enough'] < TypePrinter.no_payload_count:
             return '.%s' % str(tag)
         return None
 
     def children(self):
-        if self.val['tag_if_small_enough'] < common.Type.no_payload_count:
+        if self.val['tag_if_small_enough'] < TypePrinter.no_payload_count:
             return
 
         yield ('tag', '.%s' % str(self.tag()))
@@ -51,6 +93,55 @@ class TypePrinter:
             yield ('payload', self.val['ptr_otherwise'].cast(payload_type.pointer()).dereference()['data'])
 
 class ValuePrinter:
+    no_payload_count = 4096
+
+    # Keep in sync with src/value.zig
+    # Values which have no payload do not need to be entered here.
+    payload_type_names = {
+        'big_int_positive': 'Value.Payload.BigInt',
+        'big_int_negative': 'Value.Payload.BigInt',
+
+        'extern_fn': 'Value.Payload.ExternFn',
+
+        'decl_ref': 'Value.Payload.Decl',
+
+        'repeated': 'Value.Payload.SubValue',
+        'eu_payload': 'Value.Payload.SubValue',
+        'opt_payload': 'Value.Payload.SubValue',
+        'empty_array_sentinel': 'Value.Payload.SubValue',
+
+        'eu_payload_ptr': 'Value.Payload.PayloadPtr',
+        'opt_payload_ptr': 'Value.Payload.PayloadPtr',
+
+        'bytes': 'Value.Payload.Bytes',
+        'enum_literal': 'Value.Payload.Bytes',
+
+        'slice': 'Value.Payload.Slice',
+
+        'enum_field_index': 'Value.Payload.U32',
+
+        'ty': 'Value.Payload.Ty',
+        'int_type': 'Value.Payload.IntType',
+        'int_u64': 'Value.Payload.U64',
+        'int_i64': 'Value.Payload.I64',
+        'function': 'Value.Payload.Function',
+        'variable': 'Value.Payload.Variable',
+        'decl_ref_mut': 'Value.Payload.DeclRefMut',
+        'elem_ptr': 'Value.Payload.ElemPtr',
+        'field_ptr': 'Value.Payload.FieldPtr',
+        'float_16': 'Value.Payload.Float_16',
+        'float_32': 'Value.Payload.Float_32',
+        'float_64': 'Value.Payload.Float_64',
+        'float_80': 'Value.Payload.Float_80',
+        'float_128': 'Value.Payload.Float_128',
+        'error': 'Value.Payload.Error',
+        'inferred_alloc': 'Value.Payload.InferredAlloc',
+        'inferred_alloc_comptime': 'Value.Payload.InferredAllocComptime',
+        'aggregate': 'Value.Payload.Aggregate',
+        'union': 'Value.Payload.Union',
+        'bound_fn': 'Value.Payload.BoundFn',
+    }
+
     def __init__(self, val):
         self.val = val
 
@@ -58,7 +149,7 @@ class ValuePrinter:
         tag_if_small_enough = self.val['tag_if_small_enough']
         tag_type = tag_if_small_enough.type
 
-        if tag_if_small_enough < common.Value.no_payload_count:
+        if tag_if_small_enough < ValuePrinter.no_payload_count:
             return tag_if_small_enough
         else:
             return self.val['ptr_otherwise'].dereference()['tag']
@@ -68,7 +159,7 @@ class ValuePrinter:
         if tag is None:
             return None
 
-        type_name = Comman.Value.payload_type_names.get(str(tag))
+        type_name = ValuePrinter.payload_type_names.get(str(tag))
         if type_name is None:
             return None
         return gdb.lookup_type('struct value.%s' % type_name)
@@ -77,12 +168,12 @@ class ValuePrinter:
         tag = self.tag()
         if tag is None:
             return '(invalid value)'
-        if self.val['tag_if_small_enough'] < common.Value.no_payload_count:
+        if self.val['tag_if_small_enough'] < ValuePrinter.no_payload_count:
             return '.%s' % str(tag)
         return None
 
     def children(self):
-        if self.val['tag_if_small_enough'] < common.Value.no_payload_count:
+        if self.val['tag_if_small_enough'] < ValuePrinter.no_payload_count:
             return
 
         yield ('tag', '.%s' % str(self.tag()))
tools/stage2_pretty_printers_common.py
@@ -1,98 +0,0 @@
-class Type:
-    no_payload_count = 4096
-
-    # Keep in sync with src/type.zig
-    # Types which have no payload do not need to be entered here.
-    payload_type_names = {
-        'array_u8': 'Type.Payload.Len',
-        'array_u8_sentinel_0': 'Type.Payload.Len',
-
-        'single_const_pointer': 'Type.Payload.ElemType',
-        'single_mut_pointer': 'Type.Payload.ElemType',
-        'many_const_pointer': 'Type.Payload.ElemType',
-        'many_mut_pointer': 'Type.Payload.ElemType',
-        'c_const_pointer': 'Type.Payload.ElemType',
-        'c_mut_pointer': 'Type.Payload.ElemType',
-        'const_slice': 'Type.Payload.ElemType',
-        'mut_slice': 'Type.Payload.ElemType',
-        'optional': 'Type.Payload.ElemType',
-        'optional_single_mut_pointer': 'Type.Payload.ElemType',
-        'optional_single_const_pointer': 'Type.Payload.ElemType',
-        'anyframe_T': 'Type.Payload.ElemType',
-
-        'int_signed': 'Type.Payload.Bits',
-        'int_unsigned': 'Type.Payload.Bits',
-
-        'error_set': 'Type.Payload.ErrorSet',
-        'error_set_inferred': 'Type.Payload.ErrorSetInferred',
-        'error_set_merged': 'Type.Payload.ErrorSetMerged',
-
-        'array': 'Type.Payload.Array',
-        'vector': 'Type.Payload.Array',
-
-        'array_sentinel': 'Type.Payload.ArraySentinel',
-        'pointer': 'Type.Payload.Pointer',
-        'function': 'Type.Payload.Function',
-        'error_union': 'Type.Payload.ErrorUnion',
-        'error_set_single': 'Type.Payload.Name',
-        'opaque': 'Type.Payload.Opaque',
-        'struct': 'Type.Payload.Struct',
-        'union': 'Type.Payload.Union',
-        'union_tagged': 'Type.Payload.Union',
-        'enum_full, .enum_nonexhaustive': 'Type.Payload.EnumFull',
-        'enum_simple': 'Type.Payload.EnumSimple',
-        'enum_numbered': 'Type.Payload.EnumNumbered',
-        'empty_struct': 'Type.Payload.ContainerScope',
-        'tuple': 'Type.Payload.Tuple',
-        'anon_struct': 'Type.Payload.AnonStruct',
-    }
-
-class Value:
-    no_payload_count = 4096
-
-    # Keep in sync with src/value.zig
-    # Values which have no payload do not need to be entered here.
-    payload_type_names = {
-        'big_int_positive': 'Value.Payload.BigInt',
-        'big_int_negative': 'Value.Payload.BigInt',
-
-        'extern_fn': 'Value.Payload.ExternFn',
-
-        'decl_ref': 'Value.Payload.Decl',
-
-        'repeated': 'Value.Payload.SubValue',
-        'eu_payload': 'Value.Payload.SubValue',
-        'opt_payload': 'Value.Payload.SubValue',
-        'empty_array_sentinel': 'Value.Payload.SubValue',
-
-        'eu_payload_ptr': 'Value.Payload.PayloadPtr',
-        'opt_payload_ptr': 'Value.Payload.PayloadPtr',
-
-        'bytes': 'Value.Payload.Bytes',
-        'enum_literal': 'Value.Payload.Bytes',
-
-        'slice': 'Value.Payload.Slice',
-
-        'enum_field_index': 'Value.Payload.U32',
-
-        'ty': 'Value.Payload.Ty',
-        'int_type': 'Value.Payload.IntType',
-        'int_u64': 'Value.Payload.U64',
-        'int_i64': 'Value.Payload.I64',
-        'function': 'Value.Payload.Function',
-        'variable': 'Value.Payload.Variable',
-        'decl_ref_mut': 'Value.Payload.DeclRefMut',
-        'elem_ptr': 'Value.Payload.ElemPtr',
-        'field_ptr': 'Value.Payload.FieldPtr',
-        'float_16': 'Value.Payload.Float_16',
-        'float_32': 'Value.Payload.Float_32',
-        'float_64': 'Value.Payload.Float_64',
-        'float_80': 'Value.Payload.Float_80',
-        'float_128': 'Value.Payload.Float_128',
-        'error': 'Value.Payload.Error',
-        'inferred_alloc': 'Value.Payload.InferredAlloc',
-        'inferred_alloc_comptime': 'Value.Payload.InferredAllocComptime',
-        'aggregate': 'Value.Payload.Aggregate',
-        'union': 'Value.Payload.Union',
-        'bound_fn': 'Value.Payload.BoundFn',
-    }