On daily basis we are using C library functions (glibc / standard functions) in our code. For example printf( ) resides in stdio.h header file. We can see declarations and definitions of all these functions in glibc(standard library). So if we want to know which function will be called after printf( ) call. So we can find all over call stack through using GDB (GNU debugger). Here two or three options to find out call stack:
Insert your file for GDB : gcc -g filename.c (gcc compiler -g is an option to insert our file or load symbol table and filename.c our source file )
After this we have to do run this command: gdb ./a.out
Then it will show a prompt with gdb version or license information:
So after this prompt you have to give command : start. We can set breakpoints using command b line number. Then we will set break point at printf() function also we can set break point on function through command : b printf.
you can use option si for single stepping this command will show call stack.
Comments
Post a Comment