0

I am looking for a way to access results from gdb from python. I need to debug a c program using gdb and access the results from python. It is like calling gdb from python to debug c program.

2 Answers 2

0

Use subprocess to call gdb on the compiled binary (e.g. a.out):

import subprocess

# if you have arguments to gdb, you can supply then in the list itself.
proc = subprocess.Popen(['gdb', 'a.out'],
                        stdin=subprocess.PIPE,
                        )
proc.communicate('\tGDB Output:\n')

Reference:

http://pymotw.com/2/subprocess/

Sign up to request clarification or add additional context in comments.

Comments

0

I think you should invert the problem and instead add support what you need by extending gdb: https://sourceware.org/gdb/onlinedocs/gdb/Extending-GDB.html. When python runs within gdb it has access to gdb API. See How to import 'GDB' in python for some extra details.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.