#!/bin/perl # Use this script with the following dbx ksh function. # This script parses some dbx output and create a # graphml file that yEd can read. Probably other graph # tools can read it to, but yEd is the one I use. # # syncgraph() { # out=$(syncs|grep 'thread mutex'|awk '{print $1}') # ofile=/tmp/syncgraph # gfile=/tmp/syncgraph.graphml # rm -f $ofile $gfile # touch $ofile # for i in $out # do # case $i in # 0x*) addr="$i"; ;; # *) addr="(unsigned)&$i"; ;; # esac # >> $ofile echo ======== $i # >> $ofile sync -info $[-flx $addr ] # done # syncs_to_graphml < $ofile > $gfile # echo Load $gfile into the yEd graph editor. # echo http://www.yworks.com/en/products_yed_about.htm # echo "Then use Tools -> Fit Node To Label (hit OK)" # echo "Then use Layout -> Classic (hit OK)" # echo "or use whichever layout seems to work for you." # } # # use Data::Dumper; while (<>) { if (/^=+ (.*)$/) { $name=$1; next; } if (/^Lock owned by (.*)$/) { $ownedby{$name}=$1; $longname{$1} .= "\n$name"; next; } # ___ t@2 ___ a ___ l@2 ___ func_name() if (/^\s+(\S+)\s+\S+\s+\S+\s+(\S+)/) { $blockedby{$1} = $name; $longname{$1} .= ""; # make sure it shows up in list next; } } $start=< EOM $end=< EOM print STDOUT $start; foreach my $thr ( keys %longname ) { # printf("thread %s : %s\n",$thr,$longname{$thr}); node($thr, $thr . $longname{$thr}); $bblock = $blockedby{$thr}; if ($bblock) { # printf("lock=%s from=%s to=%s\n",$bblock, $thr, $ownedby{$bblock}); edge($thr, $ownedby{$bblock}, $bblock); } } print STDOUT $end; sub node { my ($id,$label)=@_; print STDOUT < $label EOM } $edge = 0; sub edge { my ($src,$dst,$lock)=@_; $edge++; print STDOUT < $lock EOM }