Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$ cat mi-driver.py
from builtins import bytes
import subprocess
import sys
from subprocess import Popen
from subprocess import PIPE
def sendCmd(process, command):
command += "\n"
by_str = bytes(command, 'utf-8')
process.stdin.write(by_str)
process.stdin.flush()
def readOutputLine(process):
byte_str = process.stdout.readline()
return byte_str.decode("utf-8").strip("\n")
def spawnMI(mi_path):
args = [mi_path]
return Popen(args, stdout=PIPE, stdin=PIPE, stderr=PIPE)
def compare(expected, actual):
if expected == actual:
return
print("Mismatch in reply!")
print("Expected: " + expected)
print("Actual: " + actual)
def main():
mi_path = "/Users/davide/work/llvm-project-20170507/build-py/bin/lldb-mi"
proc = spawnMI(mi_path)
reply = readOutputLine(proc)
print(reply)
sendCmd(proc, "-unknown-command")
reply = readOutputLine(proc)
print(reply)
return
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.