From: David Schleef Date: Tue, 18 Sep 2001 22:51:01 +0000 (+0000) Subject: Scripts to extract documentation X-Git-Tag: r0_7_61~75 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=02e62aecaf237bc486e26030d8a9e07d3fbdacd6;p=comedi.git Scripts to extract documentation --- diff --git a/scripts/call_trace b/scripts/call_trace new file mode 100755 index 00000000..8e2971d6 --- /dev/null +++ b/scripts/call_trace @@ -0,0 +1,75 @@ +#!/usr/bin/perl +# vi: set ts=4: + + +$ARGV=shift @ARGV; +@output=`objdump -dr $ARGV`; + +$obj=$ARGV; + +$state=0; +while($_=shift @output){ + chomp; + if(m/^\w+\.o:\s+file format.*/){ + $obj = $_; + $obj =~ s/^(\w+\.o):\s+file format.*/\1/ + } + if(m/^0[0-9a-fA-F]+\s<\w+>:$/){ + $func = $_; + $func =~ s/^0[0-9a-fA-F]+\s<(\w+)>:$/\1/; + + $addr = $_; + $addr =~ s/^(0[0-9a-fA-F]+)\s<\w+>:$/\1/; + + if(@cfuncs){ + @cfuncs = sort @cfuncs; + @last=""; + foreach $f (@cfuncs) { + if($f ne $last){ + if($f ne "::_GLOBAL_OFFSET_TABLE_"){ + print " $f\n"; + } + } + $last=$f; + } + } + @cfuncs=(); + print "${obj}::$func:\n"; + + $state=0; + } + if(m/\scall\s/){ + if(m/\scall\s.*<.*>/){ + $cfunc = $_; + $cfunc =~ s/.*\scall\s.*<(.*)>$/\1/; + + if($cfunc =~ m/$func\+0x/){ + # wait for a reloc + $state=1; + }else{ + push @cfuncs, "${obj}::$cfunc"; + $state=0; + } + }else{ + if($state==2){ + push @cfuncs, "#$cfunc"; + }else{ + push @cfuncs, "#"; + } + $state=0; + } + } + if(m/^\s+[0-9a-fA-F]+:\s\w+\s+\w+$/){ + $cfunc = $_; + $cfunc =~ s/.*\s(\w+)$/\1/; + if($state==0){ + # it just showed up. We might attach it to the next line. + $state=2; + }elsif($state==1){ + # we're waiting for a reloc + push @cfuncs, "::$cfunc"; + $state=0; + } + } +} + diff --git a/scripts/doc_devlist b/scripts/doc_devlist new file mode 100755 index 00000000..6fd44590 --- /dev/null +++ b/scripts/doc_devlist @@ -0,0 +1,89 @@ +#!/usr/bin/perl -w +# vi: set ts=4: + +sub parse_devices; + +@ARGV = ('-') unless @ARGV; + +$ARGV=shift @ARGV; +if(!open(FILE,$ARGV)){ + warn "Can't open $ARGV: $!\n"; + exit 1; +} + +while(){ + push @lines,$_; +} + +$driver = ""; +while($_=shift @lines){ + if( m/^[\w-]+: / ){ + if($l){ + #print "$l\n"; + if($l =~ m/^Driver: /){ + $_ = $l; + s/^Driver: //; + $driver = $_; + } + } + chomp; + $l=$_; + }elsif( m/^ / ){ + s/^ +//; + chomp; + $l="$l $_"; + }else{ + if($l){ + #print "$l\n"; + if($l =~ m/^Driver: /){ + $_ = $l; + s/^Driver: //; + $driver = $_; + } + if($l =~ m/^Devices: /){ + $_ = $l; + s/^Devices: //; + parse_devices($_); + } + $l=""; + } + } +} + + +sub parse_devices +{ + my $devs = $_[0]; + my $mfr = "unknown"; + my $dev = "unknown"; + my $name = "unknown"; + + #print("parse_devices $devs\n"); + + while($devs){ + $_=$devs; + if(m/^ *\[([^\]]+)\](.*)/){ + $mfr = $1; + #print "recognized mfr $mfr\n"; + $devs = $2; + }elsif(m/^ *\(([^\)]+)\)(.*)/){ + $name = $1; + #print "recognized name $name\n"; + $devs = $2; + }elsif(m/^ *([^\(,]+)(.*)/){ + $dev = $1; + $devs = $2; + $dev =~ s/ *$//; + #print "recognized dev $dev\n"; + }elsif(m/^ *,(.*)/){ + $devs = $1; + printf "%-28s %-17s %-17s %-10s\n", $mfr, $dev, $driver, $name; + }else{ + print "parse error $_\n"; + $devs = ""; + } + } + printf "%-28s %-17s %-17s %-10s\n", $mfr, $dev, $driver, $name; +} + + diff --git a/scripts/dump_doc b/scripts/dump_doc new file mode 100755 index 00000000..f790a901 --- /dev/null +++ b/scripts/dump_doc @@ -0,0 +1,28 @@ +#!/usr/bin/perl +# vi: set ts=4: + +@ARGV = ('-') unless @ARGV; + +$ARGV=shift @ARGV; +if(!open(FILE,$ARGV)){ + warn "Can't open $ARGV: $!\n"; + exit 1; +} + +$go=0; +while() { + if( m/^Driver: / ){ + $go=1; + } + if( m/\*\// ){ + if($go){ + print "\n\n\n"; + } + $go=0; + } + if( $go ){ + #chomp; + print $_; + } +} +