I already know the calling procedure is like above, and wishing to write some lines of code to backtrace the functions called. The saved %ebp chain is no problem.
But how can I know the arguments, and their number merely from this call chain?
I figured out gdb did it every well, it prints something like:> #4 0xf0100069 in test_backtra开发者_JS百科ce (x=3) at kern/init.c:16
> #5 0xf0100069 in test_backtrace (x=4) at kern/init.c:16
> #6 0xf0100069 in test_backtrace (x=5) at kern/init.c:16
> #7 0xf01000ea in i386_init () at kern/init.c:39
which means it know exactly what each function arguments are. How does it accomplish so?
Many tks.
GDB is a symbolic debugger. It knows to do this only when you build your code with debug symbols since it does it by looking at the function prototype in C. Try to compile the code with out debug symbols (lost the -g in CFLAGS) and you will see gdb suddenly loses the ability to do so...
精彩评论