Consider the following simple program for GCC:
#include <stdio.h>
int calledtest(int a)
{
return(a + 5);
}
asm(
".pushsection .text;"
".type calltest, @function;"
"calltest:"
" call calledtest;"
" ret;"
".size calltest, .-calltest;"
".popsection;"
);
int calltest(int);
int main(int argc, char **argv)
{
printf("%i\n", calltest(2));
return(0);
}
This program works as expected and all that, but my problem is that, when running it in gdb, gdb does not understand how to "step into" the calltest function. Running the step command on the printf line simply steps right into printf, skipping the calltest call entirely. Do note that stepping into calltest itself isn't really a problem for me in my current use-case, but what bothers me all the much more is that gdb even skips the whole call to calledtest. I can of course get into calltest and calledtest by stepping instructions, but that can be pretty tedious, especially when calltest is called on a line with complex expressions and/or other function calls.
If I put the calltest function into its own, separate assembly file that I compile with GAS, I can simply pass the -g flag to GAS and gdb will work entirely as expected, but I'm not aware of any way to make GCC do anything similar with inline assembly, and I do need inline assembly since I generate these little stubs of mine with CPP macros as part of a greater library.
It appears to me that this is possible to fix somehow, since calltest seems to be very similar to the standard PLT stubs that gdb certainly has no trouble with, but I don't know how debug info is generated for those.
So my question is twofold: First, what kind of information is it that gdb is really looking for to "understand" these functions, and, second, how can I generate it?
calltest, and put theasm()as the body of the function.asm()doesn't putcalltestin the debugging information, which is what the debugger uses.