3 # Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
5 # This file is part of simavr.
7 # simavr is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # simavr is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with simavr. If not, see <http://www.gnu.org/licenses/>.
23 tags = File.new(ARGV[0])
28 next unless tags.readline.chomp.match(/([^\t]+)\t([^\t]+)\t(.*)\$\/;"\t([^\t]+)/);
34 next if key[4] == 'm' or key[4] == 't' or key[4] == 's' or key[4] == 'e' or key[4] == 'v';
35 next if key[0].match(/[us]?int[0-9]+_t/);
36 next if key[0] == "ROM_BASED";
38 key[1].gsub!(/.*\/|\.[ch]$/,"");
40 unless $files.key? key[1]
41 $files[key[1]] = Hash.new
43 unless $files[key[1]].key? key[0]
44 $files[key[1]][key[0]] = Hash.new
45 $syms[key[0]] = key[1]
47 #puts key[0] + " = '#{key[4]}'"
50 puts "digraph dump { node [shape=rect]; compound=true; nodesep=.1; ranksep=2; rankdir=LR; concentrate=true; "
55 1.upto(ARGV.length-1) { |i|
57 use = File.new(ARGV[i])
58 # puts "<<<<<<<<FILE " + ARGV[i]
60 fil = ARGV[i].gsub(/.*\/|\.[ch]$/,"");
65 next if line.match(/[ \t]*\/\//);
66 line.gsub!(/[^a-zA-Z0-9_]/, " ");
67 line.gsub!(/[ \t]+/, " ");
69 words = line.split(/[ \t]+/);
71 if $syms.key? w and $syms[w] != fil
72 unless $files[$syms[w]][w].key? fil
73 # puts w + " is in " + $syms[w]
74 $files[$syms[w]][w][fil] = 1
77 unless modules.key? fil
78 modules[fil] = Array.new
80 modules[fil] += [ "\"cc_#{fil}_#{sym}\" [label=\"#{sym}\",color=\"gray\",height=\".08\",style=dotted];" ]
81 links += ["\"cc_#{fil}_#{sym}\" -> \"dd_#{$syms[w]}_#{sym}\";"]
88 $files.keys.each { |fil|
89 # puts "File #{fil} ?"
90 $files[fil].keys.each { |sym|
91 # puts "\tSym #{sym} : #{$files[fil][sym].length} ?"
92 if $files[fil][sym].length > 0
93 unless modules.key? fil
94 modules[fil] = Array.new
96 modules[fil] += [ "\"dd_#{fil}_#{sym}\" [label=\"#{sym}\"];" ]
100 modules.keys.each {|fil|
101 puts "\tsubgraph cluster_#{fil} {\n\t\tlabel=\"#{fil}\"; fontsize=\"18\"; "
102 modules[fil].each { |lin|