This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to debugg a C++ project using GDB

Tags: None
(comma "," separated)
bdsanthosh
Registered Member
Posts
1
Karma
0
OS

How to debugg a C++ project using GDB

Tue Jul 27, 2010 11:12 am
Hi everyone,
I am currently working with a c++ project which has many .cpp and .h files.
I could not get much information about How can I debug the entire project with GDB. I am using KDevelop IDE for C/C++.

can anybody help me with this problem. Its really important as I am having a segemntation fault error. And for the moment I dont know how to debug the project.

Thanks in advance

with regards
Santhosh
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS
On a segfault you usually get a core dump, basically the memory of your application at the time of the crash.

On the command line this could be analyzed like this

Code: Select all
gdb programname corefile


And the typing "bt" (for backtrace).

There are also several GDB GUIs, e.g. DDD.

Not sure how this works in KDevelop though, maybe ask on the KDevelop forum http://www.kdevelop.org/phorum5/index.php

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
tommywalsh
Registered Member
Posts
3
Karma
0
OS
Can you reproduce the problem? If so, here would be a way to take a quick look at it (if you don't have a core dump, otherwise see anda_skoa's post), assuming your program is called "my_diff_program", and you want to pass the arguments "file1" and "file 2". Modify as necessary with your own details.

$ gdb my_diff_program
(gdb) handle SIGSEGV stop print
(gdb) run arg1 arg 2

Now, recreate the problem in your program. Gdb will break when the SEGV happens. Now, you can examine the call stack with "bt", or look at variables with "print", or adjust your context to the calling function with "up", etc. You can always type "help" to get a quick overview of any command (e.g. "help bt").

Google "gdb tutorial" for more information, if you want to get more in-depth. But, that might be enough to get you pointed in the right direction on this bug.


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]