M
M
Mark_Aizek2019-01-20 11:52:06
Python
Mark_Aizek, 2019-01-20 11:52:06

How to organize interactive data exchange (i / o) between the gdb console and the control python script?

Good afternoon. It is required to organize a control module that writes data to gdb and reads the reaction. Different commands are generated for gdb depending on the console response.
The essence of the task is the automation of debugging. Feature - unfortunately, this is needed under Windows.
Python is not the main language, I tried async subprocess, something did not take off.
Please point me in the right direction :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bbkmzzzz, 2019-01-21
@bbkmzzzz

p = subprocess.Popen('gdb.exe',
                 stdout=subprocess.PIPE,
                 stderr=subprocess.PIPE,
                 stdin=subprocess.PIPE)

while not p.poll(): # щупает процесс на предмет кода завершения, если кода нет - возвращает None
    print(p.stdout.readline()) # будет ждать целую строку из stdout
    p.stdin.write(b'testbytes') # напишет в stdin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question