locate.pl revision 10641
1#!/usr/local/bin/perl
2
3$errpos = hex($ARGV[0])/4;
4$ofs=0;
5
6open (INPUT, "cc -E ncr.c 2>/dev/null |");
7
8while ($_ = <INPUT>)
9{
10    last if /^struct script \{/;
11}
12
13while ($_ = <INPUT>)
14{
15    last if /^\}\;/;
16    ($label, $size) = /ncrcmd\s+(\S+)\s+\[([^]]+)/;
17    $size = eval($size);
18    if ($label) {
19	if ($errpos) {
20	    if ($ofs + $size > $errpos) {
21		printf ("%4x: %s\n", $ofs * 4, $label);
22		printf ("%4x: %s + %d\n", $errpos * 4, $label, $errpos - $ofs);
23		last;
24	    }
25	    $ofs += $size;
26	} else {
27	    printf ("%4x: %s\n", $ofs * 4, $label);
28	}
29    }
30}
31
32