[Lldb-commits] [lldb] [lldb] Add lldb.summary and lldb.synthetic decorators (PR #195351)

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Tue May 5 09:13:06 PDT 2026


kastiglione wrote:

This [comment](https://github.com/llvm/llvm-project/pull/195351#discussion_r3186174146) by @JDevlieghere gave me an idea of another way to implement this, a way which works similarly to `@lldb.command` (i.e. immediate not deferred `HandleCommand`).

Here's a slightly simplified version of how the `summary` decorator would look:

```python
def summary(type_name):
    interp = debugger.GetCommandInterpreter()
    def decorator(func):
        qualified = f"{func.__module__}.{func.__qualname__}"
        cmd = f"type summary add -F {qualified} {type_name}"
        result = lldb.SBCommandReturnObject()
        interp.HandleCommand(cmd, result)
        if err := result.GetError():
            if "class does not exist" not in err:
                print(err, file=sys.stderr)
        return func
    return decorator
```

The reason I didn't go with this to begin with is because `type summary add` and `type synthetic add` both emit warnings if the function/class does not exist. But, by using `SBCommandInterpreter.HandleCommand` (instead of `SBDebugger`), we can capture the output (`SBCommandReturnObject`), and ignore the specific warning we know to be a false positive.

So, @jimingham, @medismailben, @JDevlieghere: should I update this PR to something like the above?

https://github.com/llvm/llvm-project/pull/195351


More information about the lldb-commits mailing list