File: filter_memcheck

package info (click to toggle)
valgrind 1%3A3.12.0~svn20160714-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 120,428 kB
  • ctags: 70,855
  • sloc: ansic: 674,645; exp: 26,134; xml: 21,574; asm: 7,570; cpp: 7,567; makefile: 7,380; sh: 6,188; perl: 5,855; haskell: 195
file content (67 lines) | stat: -rwxr-xr-x 2,093 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env perl

use warnings;
use strict;

#---------------------------------------------------------------------
# A list of files specific to the tool at hand. Line numbers in
# these files will be removed from backtrace entries matching these files.
#---------------------------------------------------------------------
my @tool_files = ( "vg_replace_strmem.c", "vg_replace_malloc.c" );


sub massage_backtrace_line ($$$) {
    my ($line, $tool_files, $cmdlin_files) = @_;
    my ($string, $qstring);

# If LINE matches any of the file names passed on the command line
# (i.e. in CMDLIN_FILES) return LINE unmodified.

    foreach $string (@$cmdlin_files) {
        $qstring = quotemeta($string);
        return $line if ($line =~ /$qstring/);
    }

# If LINE matches any of the file names in TOOL_FILES remove the line
# number and return the so modified line.

    foreach $string (@$tool_files) {
        $qstring = quotemeta($string);
        return $line if ($line =~ s/$qstring:[0-9]+/$string:.../m);
# Special case for functions whose line numbers have been removed in 
# filter_stderr_basic. FIXME: filter_stderr_basic should not do that.
        return $line if ($line =~ s/$qstring:\.\.\./$string:.../m);
    }

# Did not match anything
    $line =~ s/[\w]+.*/.../m;

    return "$line";
}


#---------------------------------------------------------------------
# Process lines. Two categories
# (a) lines from back traces
#     pass through those lines that contain file names we're interested in
# (b) everything else
#     pass through as is
#---------------------------------------------------------------------
my $prev_line = "";
while (<STDIN>) {
    my $line = $_;
    chomp($line);
    if ($line =~ /^\s+(at |by )/)  {   # lines in a back trace
        $line = massage_backtrace_line($line, \@tool_files, \@ARGV);
        if ($line =~ /\s+\.\.\./) {
            print "$line\n" if ($prev_line !~ /\s+\.\.\./);
        } else {
            print "$line\n";
        }
    } else {
        print "$line\n";  # everything else
    }
    $prev_line = $line
}

exit 0;