JustADude
JustADude

Reputation: 2707

Debugging on Linux for Windows Developer

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.

Upvotes: 7

Views: 1548

Answers (10)

Stan Graves
Stan Graves

Reputation: 6965

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

Upvotes: 0

supercheetah
supercheetah

Reputation: 3250

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

Upvotes: 1

Richard Corden
Richard Corden

Reputation: 21731

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.

Upvotes: 6

gimel
gimel

Reputation: 86492

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.

Upvotes: 2

Zifre
Zifre

Reputation: 27008

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

Upvotes: 1

user50049
user50049

Reputation:

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

Upvotes: 2

epochwolf
epochwolf

Reputation: 12802

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

Upvotes: 2

Shane O'Grady
Shane O'Grady

Reputation: 2495

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

Upvotes: 5

Mehrdad Afshari
Mehrdad Afshari

Reputation: 422252

  • Eclipse
  • NetBeans
  • KDevelop

Upvotes: 4

Related Questions