GDB – a useful tool

I have just started hacking with Libreoffice. For that I downloaded the source code of libreoffice and tried building it on my ArchLinux and Windows 8. But the build was failing in both the cases somewhere in the unit test portion. I posted my problem on libreoffice mailing list about the segmentation fault I was getting during the build. One of the developers mentioned to me about using “gdb” to print the backtrace of the segmentation fault. That’s where I learnt about this new tool called “gdb” or GNU debugger which is a very useful tool for debugging programs. so, here’s how to debug programs with gdb.

First, into a terminal type:

gdb program-name

After running it , you will enter into the gdb interactive prompt:

at the prompt type “run” to start the execution of the program.

Now , if at any point, your program crashes, gdb will stop the execution of the program at that point.

now , type “bt” command at the prompt to generate the backtrace of execution and get the exact file which caused the problem.

Happy Debugging…!!!

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s