Release 980301
[wine.git] / tools / examine-relay
blob6030f08e4bf8119251afef93e4b9a9b2f5f7cafe
1 #!/usr/bin/perl -w
2 # -----------------------------------------------------------------------------
4 my $srcfile = $ARGV[0];
5 my @callstack = ();
7 open (IN, "<$srcfile") || die "Cannot open $srcfile for reading: $!\n";
8 LINE:
9 while (<IN>) {
10 if (/^Call ([A-Za-z0-9]+\.[0-9]+): .*\)/) {
11 my $func = $1;
12 if (/ ret=(........)$/ ||
13 / ret=(....:....) ds=....$/) {
14 my $retaddr = $1;
15 push @callstack, [$func,$retaddr];
16 next;
17 } else {
18 # Assume a line got cut by a line feed in a string.
19 $_ .= scalar (<IN>);
20 print "[$_]";
21 redo;
26 if (/^Ret ([A-Za-z0-9]+\.[0-9]+): .* ret=(........)$/ ||
27 /^Ret ([A-Za-z0-9]+\.[0-9]+): .* ret=(....:....) ds=....$/) {
28 my $func = $1;
29 my $retaddr = $2;
30 my ($topfunc,$topaddr);
32 POP:
33 while (1) {
34 if ($#callstack == -1) {
35 print "Error: Return from $func to $retaddr with empty stack.\n";
36 next LINE;
39 ($topfunc,$topaddr) = @{pop @callstack};
41 if ($topfunc ne $func) {
42 print "Error: Return from $topfunc, but call from $func.\n";
43 next POP
45 last POP;
48 if ($topaddr eq $retaddr) {
49 print "OK: $func from $retaddr.\n";
50 } else {
51 print "Error: Return from $func is to $retaddr, not $topaddr.\n";
56 while ($#callstack != -1) {
57 my ($topfunc,$topaddr) = @{pop @callstack};
58 print "Error: leftover call to $topfunc from $topaddr.\n";
61 close (IN);