xref: /llvm-project/lldb/test/API/commands/command/script/welcome.py (revision fd35a92300a00edaf56ae94176317390677569a4)
1import lldb
2import sys
3
4
5class WelcomeCommand(object):
6    def __init__(self, debugger, session_dict):
7        pass
8
9    def get_short_help(self):
10        return (
11            "Just a docstring for welcome_impl\nA command that says hello to LLDB users"
12        )
13
14    def __call__(self, debugger, args, exe_ctx, result):
15        print("Hello " + args + ", welcome to LLDB", file=result)
16        return None
17
18
19class TargetnameCommand(object):
20    def __init__(self, debugger, session_dict):
21        pass
22
23    def __call__(self, debugger, args, exe_ctx, result):
24        target = debugger.GetSelectedTarget()
25        file = target.GetExecutable()
26        print("Current target " + file.GetFilename(), file=result)
27        if args == "fail":
28            result.SetError("a test for error in command")
29
30    def get_flags(self):
31        return lldb.eCommandRequiresTarget
32
33
34def print_wait_impl(debugger, args, result, dict):
35    result.SetImmediateOutputFile(sys.stdout)
36    print("Trying to do long task..", file=result)
37    import time
38
39    time.sleep(1)
40    print("Still doing long task..", file=result)
41    time.sleep(1)
42    print("Done; if you saw the delays I am doing OK", file=result)
43
44
45def check_for_synchro(debugger, args, result, dict):
46    if debugger.GetAsync():
47        print("I am running async", file=result)
48    if not debugger.GetAsync():
49        print("I am running sync", file=result)
50
51
52def takes_exe_ctx(debugger, args, exe_ctx, result, dict):
53    print(str(exe_ctx.GetTarget()), file=result)
54