Reputation: 41
How can I set a breakpoint in a shared library by address? Let's say I disassemble a library and find an instruction I want to break at, but the instruction is not associated with a label:
$ objdump -d libFoo.so
...
bc29a: 48 89 f5 mov %rsi,%rbp
...
What is the best way to convert the ELF file address (bc29a) to the correct virtual address after the library has been loaded? And how can this information be conveyed to GDB?
Thanks for any help.
Upvotes: 4
Views: 1815
Reputation: 22589
Maybe the simplest way is to "set stop-on-solib-events 1". This will cause gdb to stop whenever a shared library is loaded or unloaded. When it loads the library you want, you will be able to set a breakpoint.
Then, you can use "info shared" to see the offsets for each library. I forget offhand whether this is the offset of the text section; so you may need to experiment a bit.
Upvotes: 2