Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×

Source Code Browsing Tools? 165

Marco Sanvido asks: "I often look at source code (especially C, but this question is valid for other languages as well) and I have a really hard time in understanding how it works. Documentation is often missing or quite outdated, and the only way to see how the program works is to try to understand the source code. Which tools do you prefer to use for browsing and studying source code? So far I have used LXR for Linux, Eclipse for java, and CScope, but I'm not sure that these tools are the best solution." It's tempting to flood this question with answers for your IDE, but the key thing here is _browsing_, not _development_. What decent, lightweight programs would work well as source code viewers?
This discussion has been archived. No new comments can be posted.

Source Code Browsing Tools?

Comments Filter:
  • A couple of options (Score:5, Informative)

    by plover ( 150551 ) * on Wednesday June 07, 2006 @11:37PM (#15492204) Homepage Journal
    If you're looking for really lightweight, run the code through a prettyprinter [wikipedia.org] first. Pick the style you can most easily read. For example, I personally don't like K&R style, but that's entirely up to you.

    If you're looking more for documentation of existing code, doxygen [stack.nl] is great. It produces click-to-follow hierarchies, graphical pictures of trees, and can will intelligently display some of the comments it encounters. It can produce output in html, LaTeX, rtf, PS, PDF, and even man pages. And I know from experience that it can handle some pretty massive projects.

  • OpenGrok (Score:5, Informative)

    by Lucractius ( 649116 ) <Lucractius&gmail,com> on Wednesday June 07, 2006 @11:43PM (#15492237) Journal
    the opensolaris code browser is built off a bunch of open source stuff.

    OpenGrok
    its incredibly easy to use, and makes things very easy to read. and is now packaged for your enjoyment.
    and available at http://www.opensolaris.org/os/project/opengrok/ [opensolaris.org]
  • Krugle (Score:3, Informative)

    by WeAzElMaN ( 667859 ) on Wednesday June 07, 2006 @11:47PM (#15492264)
    If I'm looking at third-party code (instead of my own), I like to use Krugle [krugle.com]. It's still in beta and I was lucky enough to get a beta invite, but it's an extremely powerful tool for searching through repositories and documentation.
  • LXR (Score:2, Informative)

    by ashridah ( 72567 ) on Wednesday June 07, 2006 @11:49PM (#15492276)
    I've always considered stuff like LXR (linux cross reference) [linux.no] to be good for this kind of thing.

    LXR's claim to fame is that it started out being a cross-referenced browser for the linux kernel source code, but since it was released, the newer versions has moved towards becoming more of a general source browser. (might need to use cvs, don't know if a proper release was made)

    It does neat tricks like processing source code, building function/variable/header/etc line references for usage, definition, declaration etc, and cramming them into a db for retreival. It can also handle interfacing with CVS to pull source code directly from a CVS server, which is interesting. Also handles full text searching too, if you get glimpse or whatever.

    Of course, the interface to LXR is a web browser, which makes it less than ideal if you consider that it isn't integrated into an IDE, but for the purpose of tracing/searching large amounts of code, it's still pretty useful.

    ash
  • codeviz (Score:5, Informative)

    by meowsqueak ( 599208 ) on Wednesday June 07, 2006 @11:52PM (#15492292)
    You can make some useful call graphs with codeviz + graphviz. I sometimes find this useful for tracing the heirarchy of abstraction through a set of C source files.

    http://www.csn.ul.ie/~mel/projects/codeviz/ [csn.ul.ie]
  • by dracken ( 453199 ) on Wednesday June 07, 2006 @11:56PM (#15492308) Homepage
    ..is Redhat Sourcenavigator [sourceforge.net]. You can look at class hierarchy, static call graphs, jump to function declarations/definitions/callsites. Try it out.
  • SciTe (Score:2, Informative)

    by stony3k ( 709718 ) <stony3k@@@gmail...com> on Thursday June 08, 2006 @12:08AM (#15492361) Homepage
    I prefer to use SciTe - it's really lightweight - supports code folding, syntax highlighting and it's open source.
  • by plover ( 150551 ) * on Thursday June 08, 2006 @12:11AM (#15492373) Homepage Journal
    For windows, I've completely replaced "notepad.exe" with "notepad2.exe" [flos-freeware.ch] And when I say completely, I mean I crawled through my system registry editing every occurrance of "notepad.exe" to "notepad2.exe". Shell opens, file associations, defaults of every sort use it. I love it. And unless someone using the computer is particularly observant, they don't even notice it's not the original notepad.

    It has a very simple interface that looks like the original notepad, it does syntax coloring for two dozen different languages and file formats, shows bracket matching, adds line numbers, word wrap features, support for UNIX- and mac-style line terminations, regexps, and is in general what notepad itself should have been back in the 1990s. Plus, it's freeware. What more could you want?

  • by Klowner ( 145731 ) on Thursday June 08, 2006 @12:12AM (#15492376) Homepage
    I've found Doxygen to be pretty handy, it'll output to a bunch of HTML files and even create nifty relationship graphs for OO languages like C++

    http://www.stack.nl/~dimitri/doxygen/ [stack.nl]
  • by b17bmbr ( 608864 ) on Thursday June 08, 2006 @12:54AM (#15492544)
    or, you could have copied the executable to C:\windows and renamed it notepad.exe. it sucks that windows doesn't use symlinks though. would make it a whole lot easier. but then again, isn't that the point of windows, making what need to do impossible, everything you don't want to do easy.
  • by Flu ( 16236 ) on Thursday June 08, 2006 @02:42AM (#15492806)
    I regulary use Understand C/C++ from SCITools [scitools.com] (is available for Java and other languages) to browse source code (in my case, embedded sources that is supposed to be compiled using the Keil compiler). It's "right-click, for information" attetude makes browsing around a breeze. The reason is that it builds an internal database when loading the project (which takes a second or a few, depending on the size of the sources), and once built, the interface is astonishingly fast!

    One of the things I like most, is that it also colours all parts of the code that is #ifdef'ed out. Another thing is that the information windows for any token displays all kind of information: calls, callees, references, uses (including sets/get/modifies), used locals, used globals, exposed globals etc - all of which in a tree view, so it is very easy to decide what's important and what's not.

    It is possible to use it as an editor as well, which I do, but as such it isn't perfect.

    Also, importing a completely new project requires almost no intervension - it will simply prompt for where any missing #includes are located and add them to the searchpath, so just setting it up for a quick test is done in no-time.

  • SourceNavigator (Score:2, Informative)

    by schlenk ( 941701 ) on Thursday June 08, 2006 @04:13AM (#15493026)
    You could also take a look at SourceNavigator at http://sourcenav.sourceforge.net/index.html [sourceforge.net].
  • by dolmen.fr ( 583400 ) on Thursday June 08, 2006 @05:20AM (#15493182) Homepage
    Notepad.exe is both in %WINDIR% and %WINDIR%\System32 and as the other poster pointer, it is a hard task to replace them in XP due to system file protection.
  • by Anonymous Coward on Thursday June 08, 2006 @05:50AM (#15493244)
    ATTRIB -S %WINDIR%\NOTEPAD.EXE
    I've not really used XP, but if the guy can edit the registry then I'd wager he can do the above. Am I missing something here?
  • by ZorroXXX ( 610877 ) <hlovdal@gmSTRAWail.com minus berry> on Thursday June 08, 2006 @05:55AM (#15493257)
    Lxr is good for browsing "static" code like the different linux releases. But as a tool for browsing arbitrary source code it is too cumbersome to set up and use.

    I have sometimes used GNU Global [gnu.org] which makes indexed html pages of the code. Somewhat similar to lxr but there is no setup, just run two commands, gtags and htags. One nice thing about global is that it can be used on any incomplete subset of a software system. Want to just look at the files in the drivers/net/wireless directory in the linux kernel tree? Fine, just run gtags and htags from that directory (and no other setup is necessary).

    I have also used NCC [upatras.gr] which "compiles" each file and makes a index file with information like "function AAA calls functions BBB, CCC and DDD, reads variables EEE, writes variables FFF and GGG". The format is not exactly like that but you get the idea. NCC includes a text mode gopher-like variable usage/function call browser and there is a script to make graphical call graphs (via dot from graphviz). At work I have also used information from ncc files in combination with with information from the map file to find maximum stack usage.

    This study [psu.edu] (which I just found while writing this) seems to have an interesting analysis of this topic.

  • Source Navigator (Score:3, Informative)

    by avdi ( 66548 ) on Thursday June 08, 2006 @09:37AM (#15494007) Homepage
    Source Navigator [sourceforge.net] is the perhaps the most amazingly useful freebie I've ever downloaded. It's absolutely indispensible for making sense of large C/C++ codebases (and it has some support for other languages too). The cross-referencing ability is particularly useful; it's great to be able to call up a graphical call-tree of any function.
  • by Jerf ( 17166 ) on Thursday June 08, 2006 @10:39AM (#15494417) Journal
    emacs used to be a heavy editor. But "heavy" is a relative term. In an era where people will open Eclipse to edit a file, is emacs really heavy anymore? Probably not. Most of the features people will complain about like news reader, etc., are loadable modules anyhow and who cares what modules the program might load?

    On my personal system, emacs in text mode loads before I'm ready to edit the file, which is all I can ask for, and it's still the fastest XWindows editor I can open. It may be "heavier" than other editors based on GTK or QT, but it seems GTK and QT aren't necessarily "light" themselves, so my emacs will be up way before even lightweight things like GEdit.

    I think calling emacs "heavy" now is just inertia from the era of 1MB machines. If emacs is heavy, than so is damn near every app I run and that's not a very useful definition if it never distinguishes between anything.
  • by Anonymous Coward on Friday June 09, 2006 @08:17AM (#15501201)
    There's a useful product called Agent Ransack that I use all the time to search through source code either for variable/member references or for common coding errors (e.g. '=' instead of '=='). http://www.mythicsoft.com/agentransack [mythicsoft.com]. Also supports regular expressions.

This file will self-destruct in five minutes.

Working...