diff --git a/lldb/examples/python/formatter_bytecode.py b/lldb/examples/python/formatter_bytecode.py index 58cd2f81f92c..a7c524d98827 100644 --- a/lldb/examples/python/formatter_bytecode.py +++ b/lldb/examples/python/formatter_bytecode.py @@ -295,11 +295,6 @@ class BytecodeSection: builder.emit_uleb(len(bc), "program size") builder.emit_bytes(bc, "program") - @property - def _var_name(self): - var_name = re.sub(r"\W", "_", self.type_name) - return f"_{var_name}_formatter" - def write_c(self, output: TextIO) -> None: self.validate() @@ -322,7 +317,8 @@ class BytecodeSection: "__attribute__((used, section(FORMATTER_SECTION)))", file=output, ) - print(f"unsigned char {self._var_name}[] =", file=output) + var_name = re.sub(r"\W", "_", self.type_name) + print(f"unsigned char _{var_name}_formatter[] =", file=output) indent = " " for string, comment in builder.entries: print(f"{indent}// {comment}", file=output) @@ -339,7 +335,7 @@ class BytecodeSection: textwrap.dedent( """\ #if swift(>=6.3) - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) + #if objectFormat(MachO) @section("__DATA_CONST,__lldbformatters") #else @section(".lldbformatters") @@ -349,7 +345,7 @@ class BytecodeSection: file=output, ) print( - f"let {self._var_name}: {builder.type_decl} = (", + f"let `{self.type_name} formatter`: {builder.type_decl} = (", file=output, ) indent = " " diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt index 914d499cdd7d..7c0beb23bbef 100644 --- a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt +++ b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt @@ -1,11 +1,11 @@ #if swift(>=6.3) -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) +#if objectFormat(MachO) @section("__DATA_CONST,__lldbformatters") #else @section(".lldbformatters") #endif @used -let _RigidArray_formatter: (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) = ( +let `RigidArray formatter`: (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) = ( // version 0x01, // remaining record size