Sun Java Solaris Communities My SDN Account Join SDN
 
Article

Exploring the Codebase With the OpenSolaris Source Code Browser

 
By John Stearns, September 2005  
If you're new to the Solaris OS, an easy way to get a quick exposure to the code is through the OpenSolaris source browser, which is available at http://cvs.opensolaris.org/source/
Take an online tour of the source and you'll discover cleanly written, extensively commented code that reads like a book. If you're interested in working on an OpenSolaris project, you can download the complete codebase; if you just need to know how some features work in the Solaris OS, the source code browser provides a convenient alternative.
 
Search Options
On the home web page for the source browser, you'll find the following search options:
 
  • Full Search -- Performs a search of the entire codebase for a target string. Use this approach if you think the target string will have a limited number of results, such as an error message.
  • Definition -- Finds all locations where an identifier is used in a definition.
  • Symbol -- Finds all locations where a declared identifier is used in any code.
  • File Path -- Finds the path(s) in the source tree to a specified file.
  • History -- Limits the search for a specified string to the history log comments. You could look up a developer's name, for example.
Combining Search Options
The search options can be used individually or in conjunction with one another in a boolean expression. Wildcards can be used as well. See the online help for more information on search techniques.
 
Guide to the Source Directory
In addition to the search options, you'll find a description of the source file directory organization under /usr/src, with hyperlinks to help you navigate through the file hierarchy.
 
Hyperlinks to Definitions and Searches
Once in the source, you'll find convenient hyperlinks to give you a full understanding of the code. There are hyperlinks that connect local symbols to their definitions. If definitions are not available, the hyperlink performs a search on the given string. So for example, if you're examining a .c file, you can do a search on an included header file with a single click.
 
Search Examples
Let's try out the source browser by looking at how the pwd command works. Entering pwd.c in the File Path field displays two results.
 
code.browser.figure 1
code.browser.figure 1

We want the pwd that is used to "return working directory name". Selecting pwd.c in the /usr/src/cmd/pwd/ directory takes us to the source code. Scrolling down to the main function gives us the code shown in the following figure. You can click on any symbol in the code to initiate a search for that symbol's definition.

 
code.browser.figure 2
code.browser.figure 2
Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.