views:

1735

answers:

13

I'm learning C++ and I want to know what is the best C++ debugger for Linux, because there are some things, that is better to use a debugger to get here in Stack Overflow and ask very very simple questions that can be easily solved by a debugger.
Also, there is any book to learn how to use this debugger?

+18  A: 

gdb is popular, widespread, and powerful, though some people can't stand its lack of GUI (but there are many GUIs that work on top of it, of course!).

The wikipedia entry lists about a dozen GUI front-ends for gdb, including IDEs that also offer similarly gooey front-ends to other development tools (compilers, &c) and ways to integrate gdb in some popular, powerful editors (Emacs and Vim) which some developer prefer to "properly GUIish IDEs", especially but not exclusively for developing on Linux and other Unix-like systems.

Alex Martelli
Worth mentioning that `gdb -tui` will give you a basic but quite serviceable text UI.
therefromhere
+1  A: 

GDB (http://www.gnu.org/software/gdb/) is a fairly common multi-language debugger that's available for most Linux distributions.

Amber
+2  A: 

Code Blocks comes with mingw and gdb on windows. It is my favorite on Windows after VS. So, I think it is very good on Linux also.

AraK
But i don't use Code::Blocks, i like the command line tools!
Nathan Campos
Give it a shot :)
AraK
+3  A: 

If you want a full IDE, I'd recommend checking out KDevelop.

Drakonite
+7  A: 

If you're already using emacs as your editor, you can use

M-x gdb
M-x gdb-many-windows

To use GDB with displays for the source code, registers, etc... Sort of similar to what you get with Visual Studio.

Ryan Fox
+13  A: 

Data Display Debugger

It's a frontend for gdb, I suppose gdb is usable without it, but graphing those pointer swamps is really great.

Anders Eurenius
+2  A: 

If none of the gdb front ends take your fancy then Zero Bugs might be worth looking at:

http://www.zero-bugs.com/2.0/product_intro.html

It's commercial, but a reasonable-sounding USD 40, and there's time-limited demo.

brone
+4  A: 

I know it's not a debugger per-se, but most, if not all, crashes or segfault are because of memory problems. If that's the problem, valgrind is your best bet, as it will tell you exactly what the problem is and how to fix it.

LiraNuna
+3  A: 

totalview. Pricey, but IIRC they have a 2 week demo.

xcramps
how pricey? I looked and only saw info for team licensing, no solo dev prices.
caspin
+1  A: 

To be fair, gdb own interface is the best UI for this debugger I have ever found. With the exception of the front-end provided by a windows IDE that goes by the name of SlickEdit, I have never seen any gdb GUI that beats gdb own interface.

Since you do mention your desire to stay on the console, forget any third-party gdb interfaces and use gdb by itself. You won't regret it and it's very potent.

Krugar
+2  A: 

There is a nice ncurses based frontend for GDB called CGDB: http://cgdb.sourceforge.net/

kyku
+2  A: 

Short answer : gdb

Long Answer : If you learn how to use gdb all of a sudden you now know how to debug on Mac, Solaris, AIX, Linux, HPUX, cygwin (on Windows) and possibly more platforms. In the long run, getting the same debugging interface on multiple platforms is a blessing in disguise.

tc
The perl -d mode uses a similar command set to gdb, I'm sure there are dozens of other examples.
Chris Huang-Leaver
A: 

I would suggest to use gdb with emacs. In emacs, type M-x gdb. You are good to go.

fzhou