Here is an example of the output for a 1000+ line program in 4 files:
Mkfunctmap was used in a study of static call graph extractors by Gail Murphy, Davis Notkin, and Erica S.-C Lan of the University of Washington. The report is here.
The output of Mkfunctmap is a DOT language file. DOT is a directed graph layout program from AT&T Bell Labs.
Documentation of structure of program with respect to functions.
Analysis of the overall module structure. The fewer arcs between modules, the better (usually).
Analysis of the placement of functions in modules. Maybe a function should be put in another module. Or perhaps a new module should be created or two combined.
The frequency of calls to functions.
Seeing if local functions truly are local.
function calls need to be one line or continued with a "\"
function header needs to be at the start of a line (no spaces but return type is okay)
macros ignored so function calls within them are ignored
"}" closing a function body needs to be at the start of a line
if might fail if what looks like a function call or declaration is in a multi-line comment
? tell me of any others you find
Version 0.2 allows several format options for the graph. It was beta-tested by the students in ECS 165A, Database Systems, taught by Prof. Walters in Winter 1995.
Version 1.0 added the output options -mail, -dot, -mailto, and -lang, was released on February 3, 1995 and is now available (see below) .
Availability
Mkfunctmap is free for non-commercial uses. The only restriction is that you send me e-mail or a postcard telling me you are using it. If you want to use it for commercial uses, contact me.
You are free to modify the program as you wish as long as you clearly mark your changes and send me your modified version.
You can redistribute the program for no change as long as you include are reference to this WWW page.
The program is (c) copyright 1995 by James Hoagland. Standard legal disclaimers apply. Void where prohibited.
Here is version 1.0 [4k]. Remember to name the download "mkfunctmap.pl" and to make the file executable (i.e. "chmod +x mkfunctmap.pl").
mkfunctmap.pl { source_file } [-portrait|-landscape] [-concentrate|-noconcentrate] [-fill|-nofill] [{-Ggraph_attr=value}] [{-Nnode_attr=value}] [{-Eedge_attr=value}] [-mail|-dot] [-mailto=email_addr] [-lang=outputlang] [-help]The -help options shows this usage.
The C source files to be mapped are passed as input on the command line. The output is either a output language file (i.e. Postscript), a DOT language file, or sent to DOT mail server.
% mkfunctmap.pl -dot *.c > map.ps
Other output formats are available. See below.
% mkfunctmap.pl -mail *.c
Then you wait for mail to arrive from the server. This typically takes 20 minutes, longer during East Coast (US) business hours. Save the body of the mail message as a postscript file.
You can control the destination of the mail message. See below.
% mkfunctmap.pl *.c > map.dot
You can now modify the output if you desire. The language is fairly intuitive, but here is a manual.
Then, if you have DOT locally:
% dot -Tps map.dot > map.ps
Otherwise, use the DOT mail server:
% Mail -s "dot -Tps" drawdag@toucan.research.att.com < map.dot
-portrait, -landscape
-concentrate, -noconcentrate
-fill, -nofill
-Ggraph_attr=value
-Gcenter=false and -Gfontsize=14. Attributes listed are on page 6 of the User's Manual.
-Nnode_attr=value
-Nshape=box and -Ncolor=palevioletred. Attributes listed are on page 6 of the User's Manual.
-Eedge_attr=value
-Elabel="calls" and -Estyle=dotted. Attributes listed are on page 6 of the User's Manual.
-dot
-mail.
-mail
-dot.
-mailto=emailaddr
-mail, this option indicates where to e-mail the output. The default is the DOT mail server.
-language=emailaddr
-dot or -mail, this option indicates the language that DOT should output in. The default is postscript (ps).
Some possible future additions to the program include:
Reducing the number of limitations on the input format.
Limiting the graph presented to functions accessible from specified functions.
Providing more DOT format options.
Display of global data on the graph.
Add new languages: Perl, Pascal, C++, ...
See other programs the Jim has written