I'm looking for a suggested workflow for quickly being able to download various c/c++ open source projects and then begin intelligently navigate sources.

"Intelligently" means being able to jump around to usages, definitions, implementations of a particular symbol, both in the downloaded code base, and also the headers of referenced libraries perhaps installed in /usr/local or /System/Frameworks etc.

this code jumping could be driven by etags, ctags, gnu global, eclipse CDT indexer, Xcode's indexer, I'm open to anything, but I have no idea what is the best solution for most cases out there.

Shortly afterwards I would like to begin stepping through unit tests, examples, demos in the debugger so I can better grok how the code works

Obviously, this isn't going to be possible for every project out there.. but most of the projects I am interested in are either autotools or cmake based -- In general, I don't really care what IDE (emacs, vim, xcode, eclipse, etc) I use, and I don't mind running a command line debugger -- I just want to quickly download a C/C++ project, "fool around with it" at a source level, and then move on if its not interesting.

My question is particularly directed to the guy or gal super hacker who routinely explores several different large C/C++ projects every few days/weeks --> how do YOU productively do this?

(My background/experience level is that I know enough about c/c++ tooling to get things to build/or debug a broken build on several different os'es usually within a few minutes, but it can take hours before I get to the point where I can take a large project and get to the point where I am stepping through examples in the debugger. I have a feeling this is because I try to use modern IDE's, but I'd be better of just using 'old school' tools. when dealing with jvm stuff -- it is usually pretty quick to get to a place where one can get intellij to grok code and start debugging -- I'd like to replicated this as much as possible in C/C++)


  • Step one, find a high level description of the data structures and see if you can find their definitions in the source. Seriously, if you can understand where the data is and how it's stored you're 80% of the way there – Daniel Gratzer Aug 31 '13 at 16:31

Follow the money. And by money I mean data. And of course take advantage of intelligent naming conventions and comments as you go (if there are any). In truly rotten codebases simply searching for references and the flow of passed/returned params often helps me more than IDE features. In well-structured code, I often find setting breakpoints and stepping through given sections of it is a great way to get an early idea of how it all works. This is less helpful when the code is completely bat!@#$ and is more likely to result in a migraine.

Oddly enough the exact opposite seems true when debugging. You can often simply examine references to figure out where a problem is in clean/well-structured code whereas the only way to find a problem in a complete disaster is to walk through all umpteen dozen calls of complete tomfoolery until you see where it's breaking.

Not the answer you're looking for? Browse other questions tagged or ask your own question.