xref: /llvm-project/lldb/examples/python/step_and_print.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1a6976269SJim Ingham""" Does a step-over then prints the local variables or only the ones passed in """
2a6976269SJim Inghamimport lldb
3a6976269SJim Ingham
4*2238dcc3SJonas Devlieghere
5a6976269SJim Inghamclass StepAndPrint:
6a6976269SJim Ingham    def __init__(self, debugger, unused):
7a6976269SJim Ingham        return
8a6976269SJim Ingham
9a6976269SJim Ingham    def __call__(self, debugger, command, exe_ctx, result):
10a6976269SJim Ingham        # Set the command to synchronous so the step will complete
11a6976269SJim Ingham        # before we try to run the frame variable.
12a6976269SJim Ingham        old_async = debugger.GetAsync()
13a6976269SJim Ingham        debugger.SetAsync(False)
14a6976269SJim Ingham
15a6976269SJim Ingham        debugger.HandleCommand("thread step-over")
16a6976269SJim Ingham        print("---------- Values: -------------------\n")
17a6976269SJim Ingham        debugger.HandleCommand("frame variable %s" % (command))
18a6976269SJim Ingham
19a6976269SJim Ingham        debugger.SetAsync(old_async)
20a6976269SJim Ingham
21a6976269SJim Ingham    def get_short_help(self):
22*2238dcc3SJonas Devlieghere        return (
23*2238dcc3SJonas Devlieghere            "Does a step-over then runs frame variable passing the command args to it\n"
24*2238dcc3SJonas Devlieghere        )
25*2238dcc3SJonas Devlieghere
26a6976269SJim Ingham
27a6976269SJim Inghamdef __lldb_init_module(debugger, unused):
28e3930e77SMed Ismail Bennani    debugger.HandleCommand("command script add -o -c step_and_print.StepAndPrint sap")
29