llvm-project/lldb/examples/python/step_and_print.py
Med Ismail Bennani e3930e77fc [lldb] Update custom commands to always be overrriden
This is a follow-up patch to 6f7835f309b9.

As explained previously, when running from an IDE, it can happen that
the IDE imports some lldb scripts by itself. If the user also tries to
import these commands, lldb will show the following message:

```
error: cannot add command: user command exists and force replace not set
```

This message is confusing to the user, because it suggests that the
command import failed and that the execution should stop. However, in
this case, lldb will continue the execution with the command added
previously by the user.

To prevent that, this patch updates every first-party lldb-packaged
custom commands to override commands that were pre-imported in lldb.

Differential Revision: https://reviews.llvm.org/D140293

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2023-01-12 19:20:51 -08:00

25 lines
889 B
Python

""" Does a step-over then prints the local variables or only the ones passed in """
import lldb
class StepAndPrint:
def __init__(self, debugger, unused):
return
def __call__(self, debugger, command, exe_ctx, result):
# Set the command to synchronous so the step will complete
# before we try to run the frame variable.
old_async = debugger.GetAsync()
debugger.SetAsync(False)
debugger.HandleCommand("thread step-over")
print("---------- Values: -------------------\n")
debugger.HandleCommand("frame variable %s"%(command))
debugger.SetAsync(old_async)
def get_short_help(self):
return "Does a step-over then runs frame variable passing the command args to it\n"
def __lldb_init_module(debugger, unused):
debugger.HandleCommand("command script add -o -c step_and_print.StepAndPrint sap")