I want to know how to debug the inner source of a so file. I have a so file,and i use dlopen() to open it,then I use dlsym() to load the method. Now,I use g++ tools with the flag -g to compile it.It works very well, however I can't step into the so source by using the gdb command 'next'.
Asked
Active
Viewed 387 times
0
-
3That's because "next" steps over function calls. Use "step" to step into functions! – Kaz Nov 01 '13 at 06:05
-
Also: Since you're targetting gdb, you might want to use `-ggdb`. – kfsone Nov 01 '13 at 06:19
-
1Bonus also: Modern GDB has a text ui, add '-tui' to your gdb command line, e.g. `$ gdb -tui myapp`. https://sourceware.org/gdb/onlinedocs/gdb/TUI.html – kfsone Nov 01 '13 at 06:21
-
1the .so is also compiled with -g ? – tristan Nov 01 '13 at 07:24
-
BTW, you are `dlsym`-ing not methods but function names. And please check that `dlopen` and `dlsym` succeeded (use `dlerror` on failure, like [here](http://stackoverflow.com/a/19716028/841108) ...) – Basile Starynkevitch Nov 01 '13 at 08:49
-
@tristan ,yes I did.I have known that.3Q. – kidoher Nov 01 '13 at 08:55
-
@Kaz,3q for answering this in time. – kidoher Nov 01 '13 at 08:58
-
@kfsone ,3q for telling me the para -tui. – kidoher Nov 01 '13 at 08:59
-
@kidoher: please accept and/or upvote appropriate answers. – Basile Starynkevitch Nov 01 '13 at 09:26
2 Answers
1
You seem to be confusing two different ways of running gdb. Here's a link explaining how to iterate over your source code.
http://sourceware.org/gdb/onlinedocs/gdb/Continuing-and-Stepping.html

It'sPete
- 5,083
- 8
- 39
- 72
1
If all the code is compiled with -g
(and that includes the code of the dlopen
-ed shared object .so
file and all the code of the main dlopen
-ing program), then you can step into a function of your plugin with gdb
(or even add a breakpoint inside).
It may be useful to use quite recent versions of the GCC compiler (e.g. 4.8) and of the GDB debugger (i.e. 7.6). Both have improved significantly and recently on these aspects.

Basile Starynkevitch
- 223,805
- 18
- 296
- 547