Dave Lee 13b394312b
[lldb][bytecode] Add Python to formatter bytecode compiler (#113734)
A compiler from Python to the assembly syntax of the [lldb data
formatter
bytecode](https://discourse.llvm.org/t/a-bytecode-for-lldb-data-formatters/82696).

Assisted-by: claude
2026-03-09 13:48:24 -07:00

30 lines
908 B
Plaintext

# RUN: mkdir -p %t
# RUN: %python %S/../../../../examples/python/formatter_bytecode.py --compile %s --format c --type-name RigidArray --output %t/output.txt
# RUN: diff -u %S/Inputs/FormatterBytecode/RigidArrayLLDBFormatter.txt %t/output.txt
import lldb
class RigidArraySynthetic:
valobj: lldb.SBValue
storage: lldb.SBValue
count: int
def __init__(self, valobj: lldb.SBValue, _) -> None:
self.valobj = valobj
def num_children(self) -> int:
return self.count
def get_child_at_index(self, idx: int) -> lldb.SBValue:
return self.storage.GetChildAtIndex(idx)
def update(self) -> None:
self.storage = self.valobj.GetChildMemberWithName(
"_storage"
).GetSyntheticValue()
self.count = (
self.valobj.GetChildMemberWithName("_count")
.GetSyntheticValue()
.GetValueAsUnsigned()
)