Re: How to have gdb step into a function from the application's shared library?
On Fri, Jul 17, 2009 at 11:34:40PM +0000, sobtwmxt wrote:
> Consider the following pseudo code:
>
> ::::::::
> appLib.h
> ::::::::
> int funcInAppLib(void);
>
>
> ::::::
> main.c
> ::::::
> #include "appLib.h"
>
> int main(void) {
> if (funcInAppLib() < 0) printf("funcInAppLib() < 0\n");
> }
>
>
> Where the application is debianized, and appLib is installed as a
> shared library. It has an associated -dev library, which is not
> normally installed.
>
> I want to have gdb step into funcInAppLib(). What should I do so
> that single step in main will actually step into funcInAppLib()? What
> I did so far is:
> 1) Make the deb without stripping debugging symbols.
> 2) Single step main() with gdb, by gdb s command. But that process
> skipped stepping into funcInAppLib().
You might want to install ddd (just to make it easier) and use it to
set a breakpoint at the start of the function before running the
program.
That still doesn't guarantee that the function is called. There can be
circumstances under which a function somehow gets "optimized away",
like getting inlined. In such a case, you might need to turn off all
optimization when compiling and/or put in some extra code for
debugging to the function being called.
I would change the code like that:
int main(void) {
int ret;
ret = funcInAppLib();
if(ret < 0) {
puts("funcInAppLib() < 0\n");
fflush(stdout);
}
}
Doing it step by step in the source like that can make it easier to
trace. Do the like in the function, and set a breakpoint in the
function.
Reply to: