views:

407

answers:

10

Primarily I've done basic (novice level) software development on a Windows machine, but I've always had MS Visual Studio to help me step through the process of debugging.

Now, however, it looks like I will be on Linux, so in order to get ready for the jump I want to make sure I have a tool/tools lined up to help me step through the code and debug.

Unfortunately when I've verbally asked folks how they go about debugging on Linux, I typically get the following answer, "Oh, I just put a bunch of print statements." OMG! No way you say, but yes that is their answer.

Since it is on Linux, and will be working with C++ code on the CentOS 32-bit OS, I am hoping here is a preferred OpenSource solution. So, I guess I asking for the preferred OpenSource IDE for C++ code on CentOS Linux.

Thanks for any insight and suggestions.

+4  A: 
  • Eclipse
  • NetBeans
  • KDevelop
Mehrdad Afshari
+1  A: 

Mostly, for an IDE similar (?) to VS - use Eclipse.

See moving Microsoft VS projects to Eclipse C/C++ Development Toolkit - a brief step-by-step procedure for migrating Microsoft Visual Studio C/C++ (MSVC) projects to Eclipse. It compares and contrasts the benefits of MSVC and Eclipse CDT.

gimel
+3  A: 

I would suggest using Eclipse

Eclipse is a mature IDE with plenty of support available.

There is also Code::Blocks if you want to try something different

Shane O'Grady
Code::Blocks uses GDB internally as well, I've found GDB alone to be less of a pain for debugging compared to C::B's.
Jukka Dahlbom
Wow - Never expected all these wonderful responses. Now I have to find the time and take advantage of the opportunity to experiment with all these ideas. I will probably start with Eclipse and see if I can coax the existing Linux code base into an IDE, which has never been done before, and there are tons of files and very little existing or accurate documentation - this unfortunately no *.dsw or existing workspace or solution:( I guess the next step will to see how to get this beast of code to work in an IDE. Thanks again for all the replies they are truly great.
JustADude
+2  A: 

There is always GDB. XCode for OSX uses GDB internally for debugging.

epochwolf
+2  A: 

Valgrind, its your friend and may save you from having to suffer though GDB.

Tim Post
+1  A: 

Anjuta is a really great IDE for GNOME. For debugging it uses GDB internally.

Zifre
+6  A: 

A few years ago I made the move from VS to an emacs/make type environment and I have never looked back.

The idea is to use a makefile to handle the project management side of an IDE and I use emacs+gdb for editing and debugging. It will take you a while to get used to emacs but if you stick at it it's well worth the effort. Once you've started emacs, press "Ctrl+H" followed by "t" and this will bring you to the tutorial page.

After you've mastered the basics, you can debug a program in a similar way to any IDE/debugger interface. I must admit that even after all this time, I still use a set of VS key mappings that I setup when I first moved to emacs!

(global-set-key [f7] 'compile)          ;; Run the compile command
(global-set-key [f4] 'next-error)       ;; The next compile error
(global-set-key [S-f4] 'previous-error) ;; The previous compile error
(global-set-key [f5] 'gdb)              ;; Start the debugger

The following sets the "VS" key mappings to the different GDB commands which you might use:

(add-hook 'gud-mode-hook
  '(lambda ()
     (define-key (current-local-map)
       [f10]
       'gud-next)
     (define-key (current-local-map)
       [f11]
       'gud-step)
     (define-key (current-local-map)
       [\S-f11]
       'gud-finish)
     (define-key (current-local-map)
       [f5]
       'gud-cont)
))

With the above keymappings, I press 'f5' which prompts me to run gdb (and to this command I add the binary I wish to debug). Once gdb is loaded, you press 'f5' to continue, 'f10' to step-over, 'f11' to step-into and 'shirt+f11' to step-out.

Finally, every time you start 'gdb', it will read a file called '.gdbinit' in your home directory. A different StackOverflow question had this answer which brought stl-views to my attention. stl-views is a set of helper functions for gdb that show you the contents of the different types of STL containers. The instructions for how to use it can be found at the top of the link.

Richard Corden
+1  A: 

If you just want a good debugger, check out DDD.

supercheetah
A: 

I use a combination of gdb and cscope when debugging on linux.

semiuseless