____

Thursday, July 9, 2009

Debugging Under Linux

in these hard days in Iran college term finished, being stuck at home, nothing better to do than working programming projects .
last night I didn't sleep because the program that I wrote was giving me strange crushes and I was pulling out my hairs .

I found this great great tool to debugg programs in linux called gdb .


let me show you few examples of how it works .
after installing it .
- go to your program's source code directory .
- type this in terminal

gdb

- now run your binary file to debugg
run name_of_your_binaryfile

it will give detailed errors of what happend

- there is another thing called Backtrace (a report of the active stack frames instantiated by the execution of a program )
after "run" you can type :
backtrace


-you can also do : breakpoint , which makes your program stop at certain points
for example you want a report to be given to you in the function1. you type :
b function1


-the last thing I teach you is, file
you can import another binary file to examine using :
file NAMEOFFILE

have fun with GDB .

Related Posts: