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
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits