17 Commits

Author SHA1 Message Date
Dave Lee
d70ebc84ac
[lldb][bytecode] Compile pick ops using unsigned literal (#187376)
The `pick` op requires an unsigned integer index. Use the `u` suffix
when generating `pick` operations in the Python->formatter-bytecode
compiler.
2026-03-18 14:15:24 -07:00
Dave Lee
6903a58870
[lldb][bytecode] Add swift output to Python->bytecode compiler (#185773)
For swift projects using the compiler, having a swift output option will
make it easier to integrate bytecode formatters into the build.
2026-03-11 15:36:52 -07:00
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
Dave Lee
9145a7484e
[lldb] Use "assemble" instead of "compile" in formatter_bytecode.py (#184714)
Replace "compile" with "assemble" in formatter_bytecode. This is in
preparation for the addition of a Python to formatter bytecode compiler.
It will be more clear to have one meaning for "compile".
2026-03-05 11:11:32 -08:00
Dave Lee
ece4b75932
[lldb] Add C source output mode to formatter_bytecode.py (#184242)
Add the ability to generate a C source file, which is in addition to the
existing functionality of generating binary.

An example of the generated source:

```c
#ifdef __APPLE__
#define FORMATTER_SECTION "__DATA_CONST,__lldbformatters"
#else
#define FORMATTER_SECTION ".lldbformatters"
#endif

__attribute__((used, section(FORMATTER_SECTION)))
unsigned char _Account_synthetic[] =
    // version
    "\x01"
    // remaining record size
    "\x15"
    // type name size
    "\x07"
    // type name
    "Account"
    // flags
    "\x00"
    // sig_get_num_children
    "\x02"
    // program size
    "\x02"
    // program
    "\x20\x01"
    // sig_get_child_at_index
    "\x04"
    // program size
    "\x06"
    // program
    "\x02\x20\x00\x23\x11\x60"
;
```
2026-03-03 15:48:30 -08:00
Dave Lee
a0fb4f6708
[lldb] Add BytecodeSection class to formatter_bytecode.py (#183876)
Changes `formatter_bytecode.compile_file` to return a `BytecodeSection`
value. The `BytecodeSection` holds the data that needs to be emitted to
an `__lldbformatters` section.

The `BytecodeSection` currently provides `write_binary`, but will be
updated in a follow up commit to include `write_source` which will allow
the data to be emitted as C source code, or Swift source code. This will
make it easier to integrate into build systems, as it's easier to get
data into a binary via source code, than as a raw binary file.
2026-02-28 14:31:26 -08:00
Dave Lee
fd9421cccd
[lldb] Fix sys.path manipulation failure in formatter_bytecode.py (#183868)
Fix bug in #183804.
2026-02-28 00:07:41 +00:00
Dave Lee
abbba22f45
[lldb] Add synthetic support to formatter_bytecode.py (#183804)
Updates formatter_bytecode.py to support compilation and disassembly for
synthetic formatters, in other words support for multiple functions
(signatures).

This includes a number of other changes:
* String parsing and encoding have bugs fixed
* CLI args are updated, primarily to support an output file
* Added uleb encoding/decoding support

This work is a prelude the ongoing work of a Python to formatter
bytecode compiler. The python compiler to emit assembly, and this module
(formatter_bytecode) will compile it into binary bytecode.
2026-02-27 14:20:19 -08:00
Dave Lee
0668d9939f
[lldb] Improve unittest invocation in formatter_bytecode.py (#183394) 2026-02-25 14:40:17 -08:00
Dave Lee
4baab258b8
[lldb] Add Get(Non)SyntheticValue formatter bytecodes (#174839)
`GetSyntheticValue` in synthetic providers which need to operate on raw
root values, but will often want to use the synthetic value of children,
or nested children.
2026-02-12 10:07:17 -08:00
Adrian Prantl
ee1adc5aab
[lldb] Add a return opcode to the formatter bytecode (#121602)
In LLVM we love our early exists and this opcode allows for simpler code
generation.
2025-01-03 15:26:40 -08:00
Adrian Prantl
9f98949c94 [lldb] Move the python module import workaround further up 2024-12-06 17:01:58 -08:00
Adrian Prantl
fffe8c6684 [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to examples
This PR adds a proof-of-concept for a bytecode designed to ship and
run LLDB data formatters. More motivation and context can be found in
the formatter-bytecode.rst file and on discourse.

https://discourse.llvm.org/t/a-bytecode-for-lldb-data-formatters/82696

Relanding with a fix for a case-sensitive path.
2024-12-06 16:27:16 -08:00
Adrian Prantl
b504c8771f Revert "[lldb] Add a compiler/interpreter of LLDB data formatter bytecode to examples"
This reverts commit 60380cd27c6fa5ed6e39866c51b18a64bc4d566a.
2024-12-06 16:26:55 -08:00
Adrian Prantl
60380cd27c [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to examples
This PR adds a proof-of-concept for a bytecode designed to ship and
run LLDB data formatters. More motivation and context can be found in
the formatter-bytecode.rst file and on discourse.

https://discourse.llvm.org/t/a-bytecode-for-lldb-data-formatters/82696

Relanding with a fix for a case-sensitive path.
2024-12-06 16:10:09 -08:00
Adrian Prantl
8ab76a47b2 Revert "[lldb] Add a compiler/interpreter of LLDB data formatter bytecode to examples"
This reverts commit 7e3da87ca896484a11ac09df297183147154ac91.

I managed to break the bots.
2024-12-06 15:34:12 -08:00
Adrian Prantl
0ee364d2a2
[lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (#113398)
This PR adds a proof-of-concept for a bytecode designed to ship and run
LLDB data formatters. More motivation and context can be found in the
`formatter-bytecode.md` file and on discourse.

https://discourse.llvm.org/t/a-bytecode-for-lldb-data-formatters/82696
2024-12-06 15:11:21 -08:00