Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using gdb to debug a dynamically loaded shared library

Tags:

linux

gdb

shared

I wrote a little unit test framework that uses python to dynamically loaded shared libraries and invoke test methods on them. I am able to invoke unit tests through my build scripts by executing:

make test_library

Make then spawns python with a script that invokes my test methods. This works great but I am having trouble setting it up with GDB so that I can invoke the same make target but and have GDB break when my library test code is reached. Any suggestions on how to best go about it? This is all on linux.

Thanks

like image 722
samwise Avatar asked Sep 05 '26 16:09

samwise


1 Answers

There are several approaches.

You can

  • gdb myprog < myscript

  • gdb source myscript

  • etc

Here's a link on GDB commands:

  • http://sourceware.org/gdb/onlinedocs/gdb/Command-Files.html

Here's a good GDB cheat sheet:

  • http://www.yolinux.com/TUTORIALS/GDB-Commands.html

Here's a specialized technique ("hooks") that might also be applicable:

  • http://www.cse.yorku.ca/tdb/_doc.php/userg/man_g/file/gdb/node/Hooks
like image 167
paulsm4 Avatar answered Sep 07 '26 08:09

paulsm4