2 # ############################################################################
3 # Time-stamp: <Wed Jun 19 1996 12:26:21 Stardate: [-31]7682.38 hwloidl>
5 # Usage: sn_filter [options] <gr-file> <sn>
7 # Extract all events out of <gr-file> that are related to threads whose
8 # spark name component is <sn>.
11 # -H ... Print header of the <gr-file>, too
12 # -h ... print help message (this text)
15 # ############################################################################
17 $gran_dir = $ENV{'GRANDIR'};
18 if ( $gran_dir eq "" ) {
19 print STDERR "Warning: Env variable GRANDIR is undefined\n";
22 push(@INC, $gran_dir, $gran_dir . "/bin");
23 # print STDERR "INC: " . join(':',@INC) . "\n";
31 if ( $opt_v ) { do print_verbose_message(); }
33 # ----------------------------------------------------------------------------
37 open (FILE,$input) || die "Can't open $file\n";
41 print if $in_header && $opt_H;
42 $in_header = 0 if /^\++$/;
44 next unless /^PE\s*\d+\s*\[\d+\]:\s*\w*\s*([0-9a-fx]+)/;
46 # print STDERR "$id --> " . $id2sn{hex($id)} . " sn: $sn ==> " . ($sn eq $id2sn{hex($id)}) . "\n";
47 print if $sn == $id2sn{hex($id)};
54 # ----------------------------------------------------------------------------
59 die "Usage: sn_filter <gr-file> <sn>\n";
65 print STDERR "File: |$file|; sn: |$sn|\n" if $opt_v;
68 open (ME,$0) || die "!$: $0";
78 # ----------------------------------------------------------------------------
80 sub print_verbose_message {
82 print "Input: $input\tOutput: stdout\tSN: $sn\n";
84 print "Prepending .gr header to the output.\n";
89 # ----------------------------------------------------------------------------