/usr/share/doc/graphviz/examples/demo/modgraph.pl is in graphviz-doc 2.38.0-17.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #!/usr/bin/perl -w
# Change ^^ to the version of Perl you installed the SWIG modules / Graphviz with
#
# Change this to point to your installed graphviz lib dir
# Normally either /usr/local/lib/graphviz/perl or /usr/lib/graphviz/perl
#use lib '/home/maxb/lib/graphviz/perl';
use gv;
use Getopt::Long;
GetOptions(\%Args, 'h|help','d|debug');
$Debug = $Args{d} || 0;
$Modules = shift @ARGV || '/proc/modules';
die &usage if $Args{h};
die "Cannot read $Modules. $!\n" unless (-r $Modules);
$G = gv::digraph("G");
$N = gv::protonode($G);
$E = gv::protoedge($G);
gv::setv($G, "rankdir", "LR");
gv::setv($G, "nodesep", "0.05");
gv::setv($N, "shape", "box");
gv::setv($N, "width", "0");
gv::setv($N, "height", "0");
gv::setv($N, "margin", ".03");
gv::setv($N, "fontsize", "8");
gv::setv($N, "fontname", "helvetica");
gv::setv($E, "arrowsize", ".4");
open (M,"<$Modules") or die "Can't open $Modules. $!\n";
while (<M>) {
chomp;
my @f = split(/\s+/);
# Should be at least three columns
next unless scalar @f >= 3;
# Linux 2.4 : parport 36832 1 (autoclean) [parport_pc lp]
# Linux 2.6 : eeprom 14929 0 - Live 0xffffffff88cc5000
my $module = shift @f;
my $size = shift @f;
my $used_by = shift @f;
# this is ugly, needed to clean up the list of deps from 2.4 or 2.6
my $deps = join (' ',@f);
$deps =~ s/ Live.*//;
$deps =~ s/[\[\]\-(),]/ /g;
Debug("$module");
my $n = gv::node($G,$module);
foreach my $d ( split(/\s+/,$deps) ){
# gv::node($G, $d) creates the node, if needed,
# but doesn't complain if it already exists
Debug(" $d -> $module");
gv::edge($n, gv::node($G, $d) );
}
}
gv::layout($G, "dot");
gv::render($G, "xlib");
sub Debug {
return unless $Debug;
warn join(" ",@_), "\n";
}
sub usage {
return << "end_usage";
modgraph.pl
Displays Linux kernel module dependencies from $Modules
Author: John Ellson <ellson\@research.att.com>
Perl Port: Max Baker <max\@warped.org>
Usage: $0 [--debug] [/proc/modules]
end_usage
}
|