简体   繁体   中英

Invoke gdb from python script

where should my python files be stored so that I can run that using gdb. I have custom gdb located at /usr/local/myproject/bin. I start my gdb session by calling ./arm-none-eabi-gdb from the above location.

I don't know how this gdb and python are integrated into each other.

Can anyone help.?

You'd better use Python subprocess module - you could start GDB from python and drive GDB from python, passing commands on-the-fly

https://docs.python.org/3.6/library/subprocess.html#subprocess.run

I was able to figure out. What I understood is

GDB embeds the Python interpreter so it can use Python as an extension language.

You can't just import gdb from /usr/bin/python like it's an ordinary Python library because GDB isn't structured as a library.

What you can do is source MY-SCRIPT.py from within gdb (equivalent to running gdb -x MY-SCRIPT.py).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM