diff options
Diffstat (limited to 'src/ToolBox/SOS/tests/testutils.py')
-rw-r--r-- | src/ToolBox/SOS/tests/testutils.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/ToolBox/SOS/tests/testutils.py b/src/ToolBox/SOS/tests/testutils.py new file mode 100644 index 0000000000..1ddb6560e6 --- /dev/null +++ b/src/ToolBox/SOS/tests/testutils.py @@ -0,0 +1,40 @@ +import lldb +import re + +def checkResult(res): + if not res.Succeeded(): + print(res.GetOutput()) + print(res.GetError()) + exit(1) + +def exec_and_find(commandInterpreter, cmd, regexp): + res = lldb.SBCommandReturnObject() + commandInterpreter.HandleCommand(cmd, res) + checkResult(res) + + expr = re.compile(regexp) + addr = None + + print(res.GetOutput()) + lines = res.GetOutput().splitlines() + for line in lines: + match = expr.match(line) + if match is not None: + addr = match.group(1) + break + + print("Found addr: " + str(addr)) + return addr + +def stop_in_main(commandInterpreter, process, assemblyName): + res = lldb.SBCommandReturnObject() + commandInterpreter.HandleCommand("bpmd " + assemblyName + " Program.Main", res) + checkResult(res) + print(res.GetOutput()) + print(res.GetError()) + res.Clear() + + + # Use Python API to continue the process. The listening thread should be + # able to receive the state changed events. + process.Continue()
\ No newline at end of file |