Created
February 25, 2019 21:12
-
-
Save dcci/94a4936a227d9c7627b91ae9575b7b68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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