source: vis_dev/vis-2.3/share/createfunctionmap @ 14

Last change on this file since 14 was 14, checked in by cecile, 13 years ago

vis2.3

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1#!/usr/local/bin/perl
2#
3# Script to process the output of purify in terms of memory use.
4#
5# Abelardo Pardo <abel@vlsi.colorado.edu>
6#
7# Revision [$Id: createfunctionmap,v 1.4 1996/12/18 23:43:46 hsv Exp $]
8
9require 5.001;
10use Getopt::Long;
11
12# Define default variables
13#
14$version = 1.3;
15
16# Initialize the different options
17#
18$opt_h = 0;
19$opt_v = 0;
20
21# Read the options
22#
23$optionResult = GetOptions("h","v");
24
25# Print the version if required
26#
27if ($opt_v) {
28    print <<ENDOFMESSAGE;
29$0 -- Version: $version -- by Abelardo Pardo <abel\@vlsi.colorado.edu>
30ENDOFMESSAGE
31    exit;
32}
33
34# Print the help message if required
35#
36if ($opt_h || !$optionResult) {
37    print <<ENDOFMESSAGE;
38
39$0 - Program to extract the function declarations from C source code files and
40     create a map of functions to files. The files must contain the declaration
41     of the functions encapsulated between the keywords "AutomaticStart" and
42     "AutomaticEnd". The tool "extproto" provides an automatic way to create
43     this encapsulations in any *.[ch] file. The file must also contain a
44     "FileName" and a "PackageName" field on its header in order for the map to
45     be extracted correctly.
46
47Usage:
48  $0 [-h] [-v] <files>
49
50Options:
51  -h                Print this message
52  -v                Print the version
53
54Author: Abelardo Pardo <abel\@vlsi.colorado.edu>
55
56ENDOFMESSAGE
57    exit;
58}
59
60# Open the input files
61#
62foreach $filename (@ARGV) {
63
64    if (open(INPUT, $filename)) {
65
66        $indefinition = 0;
67        while(<INPUT>) {
68            chop;
69           
70            if (/FileName\s+\[\s*(.+)\s*\]/) {
71                $cfilename = $1;
72            }
73            if (/PackageName\s+\[\s*(.+)\s*\]/) {
74                $pkgname = $1;
75            }
76            if (/^\/\*\*AutomaticStart\*+\/$/) {
77                $indefinition = 1;
78            }
79            if (/^\/\*\*AutomaticEnd\*+\/$/) {
80                $indefinition = 0;
81            }
82           
83            if ($indefinition == 1) {
84                if (/static\s*.*\s+([a-zA-Z0-9_]+\(.*\))/) {
85                    $function = $1;
86                    $function =~ /([a-zA-Z0-9_]+)\(.*\)/;
87                    print "$pkgname $cfilename $1\n";
88                }
89            }
90        }
91        close(INPUT);
92    }
93    else {
94        print "Unable to open $filename. Ignoring it.\n";
95    }
96} 
97
98exit;
Note: See TracBrowser for help on using the repository browser.