How to debug shared libraries with gdb?

zhaozj2021-02-16  131

The Simplest Method (Maybe the Only Method) IS:

SET A BREAK POINT IN Main ()

2. List the source code or symbol name of the shared library, and set the break point.

You could use add-symbol-file to load the symbols of the shared library. Use ldd, you can see the link address of this shared library, this is the address for the add-symbol-file command. But even you specify the correct Address, Because At this Time, this Library Has NOT BEEN LOADED IN MEMORY, You CAN NOT SET A BREAK POINT. It will Will Prompt Such Error "Cannot Access Memory At Address 0x00xx00xx".

Another way, you can set a signal handler in gdb, eg, (gdb) handle SIGINT stop. Then when you press Ctrl C, the debugger will intercept the SIGINT signal to debuging application, then it will stop, you can set break point At That Time. Use Kill -l, You Could List All signals in your system.

转载请注明原文地址:https://www.9cbs.com/read-9087.html

New Post(0)