39 lines · python
1""" Test command for checking the Python commands can run in a stop-hook """2import lldb3 4did_run = False5 6 7class SomeCommand:8 def __init__(self, debugger, unused):9 self.dbg = debugger10 11 def __call__(self, debugger, command, exe_ctx, result):12 global did_run13 did_run = True14 result.PutCString("some output\n")15 16 def get_short_help(self):17 return "Test command - sets a variable."18 19 20class OtherCommand:21 def __init__(self, debugger, unused):22 self.dbg = debugger23 24 def __call__(self, debugger, command, exe_ctx, result):25 global did_run26 if did_run:27 result.SetStatus(lldb.eReturnStatusSuccessFinishNoResult)28 else:29 result.SetStatus(lldb.eReturnStatusFailed)30 31 def get_short_help(self):32 return "Test command - sets a variable."33 34 35def __lldb_init_module(debugger, unused):36 print("Adding command some-cmd and report-cmd")37 debugger.HandleCommand("command script add -c some_cmd.SomeCommand some-cmd")38 debugger.HandleCommand("command script add -c some_cmd.OtherCommand report-cmd")39