Graphing the Solaris kernel

Free Code Graphing Project was an attempt to visualize Linux kernel source code. Now that Solaris is free code, too, why not try to graph it. This blog entry describes my little effort of debugging the thing into existence. I can't afford to spend any more time on this, so hopefully someone picks the baton.

The end result is a huge PostScript file that looks like this:

Sample close-up, common/vm/seg_kmem.c:

Roughly, the algorithm used:

  • Function: sequential code is a line, loop is an arc, branch splits the line.
  • Color: normal functions are blue, static functions are green.
  • File: functions are put in boxes, sorted by size and arranged in a spiral.
  • Ring: Files are put in boxes, sorted by size and arranged in a circle.
  • Rings can be broken into sectors.

Here's how rings are defined for Linux:

RING1:=init lib mm kernel ipc
RING2:=net fs
RING3:=$(subst $(KERNEL_DIR)/,,$(wildcard $(KERNEL_DIR)/arch/\*))
RING4:=drivers crypto sound security

Solaris has a bit different directory structure. Here's what I used:

RING1:=common/os common/vm common/c2 common/cpr common/disp common/dtrace common/exec common/krtld common/syscall
RING2:=common/fs common/inet common/ipp common/ktli common/rpc
RING3:=i86pc sparc sun sun4 sun4u sun4v
RING4:=common/io

Steps to make it work in Solaris

1. Prerequisites:

2. Set you KERNEL_DIR environment variable to usr/src/uts subdirectory of OpenSolaris source, e.g.:

KERNEL_DIR=$HOME/solgraph/usr/src/uts; export KERNEL_DIR

3. Preprocess OpenSolaris code, since the fcgp parser does not like Solaris coding style (ignore warnings):

chmod -R +w $KERNEL_DIR
find $KERNEL_DIR -name '\*.c' -exec indent -npsl {} \\;

4. Modify your path to look in /usr/xpg4/bin first: Alternatively you can replace all 'tail -n number' occurences in fcgp scripts with 'tail -number', but it's easier to just use /usr/xpg4/bin/tail.

PATH=/usr/xpg4/bin:$PATH; export PATH

5. If using X, turn off the bell. Fcgp spits out some escape sequences that would drive you nuts (they might not look pretty on some terminals either):

xset -b

6. Kick off the build process. Takes about 9 minutes on my Ferrari 3400.

cd lgp-2.6.0a-solaris
gmake CC=gcc

7. Generate viewable/printable postscript files. Examples for a single file and for a 6x6 poster:

./posterize a4 1
./posterize a4 6

See README for more information on printing and assembling a poster.

To do list

  • Fix the parser to handle Solaris coding style.
  • Some files, e.g. common/c2/audit_syscalls.c and common/disp/ts.c, are not rendered correctly, resulting in very large bounding boxes. The rest of the files are scaled down too much. This problem might take care of itself when parser is fixed.
  • Replace the Tux in the center of the circle with OpenSolaris logo. See tux.ps.
  • Figure out what's in 'codemap' and 'zoom' directories and make it work.
  • Come up with an easy way to locate files and functions on the map.

I won't have time for these in the next two months, so feel free to pick up where I left. I can be reached at artem dot kachitchkin at sun dot com.


Tags:

Comments:

Nice work Artem! Very nice!

Posted by Dan Price on September 08, 2005 at 06:22 PM PDT #

Good picture, Artem! There is idea to listen open source projects as music (not realized yet). I believe garmony of code can be represented by means of art, music, paint etc.

Posted by Kanat on December 16, 2005 at 03:32 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

artem

Search

Top Tags
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today