2 # -----------------------------------------------------------------------------
6 # This program will inspect a log file with relay information and tell you
7 # whether calls and returns match. If not, this suggests that the parameter
8 # list might be incorrect. (It could be something else also.)
10 # Copyright 1997-1998 Morten Welinder (terra@diku.dk)
12 # -----------------------------------------------------------------------------
14 my $srcfile = $ARGV[0];
19 open (IN
, "<$srcfile") || die "Cannot open $srcfile for reading: $!\n";
22 if (/^Call ([A-Za-z0-9]+\.\d+): .*\)/) {
24 if (/ ret=(........)$/ ||
25 / ret=(....:....) (ds=....)$/ ||
26 / ret=(........) (fs=....)$/) {
30 $segreg = "none" unless defined $segreg;
31 push @callstack, [$func,$retaddr, $segreg];
34 # Assume a line got cut by a line feed in a string.
37 print "Error: string probably cut by newline.\n";
46 if (/^Ret ([A-Za-z0-9]+\.\d+): .* ret=(........)$/ ||
47 /^Ret ([A-Za-z0-9]+\.\d+): .* ret=(....:....) (ds=....)$/ ||
48 /^Ret ([A-Za-z0-9]+\.\d+): .* ret=(........) (fs=....)$/) {
52 my ($topfunc,$topaddr,$topseg);
54 $segreg = "none" unless defined $segreg;
58 if ($#callstack == -1) {
59 print "Error: Return from $func to $retaddr with empty stack.\n";
63 ($topfunc,$topaddr,$topseg) = @
{pop @callstack};
65 if ($topfunc ne $func) {
66 print "Error: Return from $topfunc, but call from $func.\n";
72 my $addrok = ($topaddr eq $retaddr);
73 my $segok = ($topseg eq $segreg);
74 if ($addrok && $segok) {
75 print "OK: ", ($indentp ?
(' ' x
(1 + $#callstack)) : '');
76 print "$func from $retaddr with $segreg.\n";
78 print "Error: Return from $func is to $retaddr, not $topaddr.\n"
80 print "Error: Return from $func with segreg $segreg, not $topseg.\n"
86 while ($#callstack != -1) {
87 my ($topfunc,$topaddr) = @
{pop @callstack};
88 print "Error: leftover call to $topfunc from $topaddr.\n";