FreeBSD/Linux Kernel Cross Reference
sys/pci/locate.pl
1 #!/usr/bin/perl -w
2 # $FreeBSD: releng/9.2/sys/pci/locate.pl 62183 2000-06-27 22:41:12Z alfred $
3
4 use strict;
5
6 if (!defined($ARGV[0])) {
7 print(
8 "
9 Perl script to convert NCR script address into label+offset.
10 Useful to find the failed NCR instruction ...
11
12 usage: $0 <address>
13 ");
14 exit(1);
15 }
16
17 my $errpos = hex($ARGV[0])/4;
18 my $ofs=0;
19
20 open (INPUT, "cc -E ncr.c 2>/dev/null |");
21
22 while ($_ = <INPUT>)
23 {
24 last if /^struct script \{/;
25 }
26
27 while ($_ = <INPUT>)
28 {
29 last if /^\}\;/;
30 my ($label, $size) = /ncrcmd\s+(\S+)\s+\[([^]]+)/;
31 $size = eval($size);
32 if (defined($label) && $label) {
33 if ($errpos) {
34 if ($ofs + $size > $errpos) {
35 printf ("%4x: %s\n", $ofs * 4, $label);
36 printf ("%4x: %s + %d\n", $errpos * 4, $label, $errpos - $ofs);
37 last;
38 }
39 $ofs += $size;
40 } else {
41 printf ("%4x: %s\n", $ofs * 4, $label);
42 }
43 }
44 }
45
Cache object: 05c57675050ac1db2a8a5ca7fcffa71b
|