summaryrefslogtreecommitdiffstats
path: root/src/script/bdev_grep.pl
blob: a343aad450c9ff568722b25c0e37e57d701f743a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/perl

my $offset = shift @ARGV;

while (<>) {
    #    next unless / \d\d bdev /;
    my $rest = $_;
    my @hit;
    while ($rest =~ /([\da-f]+)[~\+]([\da-f]+)/) {
	my ($o, $l) = $rest =~ /([\da-f]+)[~\+]([\da-f]+)/;
	$rest = $';
	if (hex($offset) >= hex($o) &&
	    hex($offset) < hex($o) + hex($l)) {
	    my $rel = hex($offset) - hex($o);
	    push(@hit, sprintf("%x",$rel));
	}
    }
    print join(',',@hit) . "\t$_" if @hit;
}