File: filter_xml_frames

package info (click to toggle)
valgrind 1:3.10.0-4~bpo7+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 97,940 kB
  • sloc: ansic: 589,429; xml: 21,096; exp: 8,751; cpp: 7,366; asm: 6,526; perl: 5,656; sh: 5,334; makefile: 4,946; haskell: 195
file content (54 lines) | stat: -rwxr-xr-x 1,472 bytes parent folder | download | duplicates (5)
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
#! /usr/bin/env perl

# Remove certain <frame>.....</frame> records that are suspected to point
# to some kind of system library. Those are
# - frames with <obj>/lib/....
# - frames with <obj>/usr/lib/....
# - frames without source informatino and without a function name
#
# There may be others...

use strict;
use warnings;

my $in_frame = 0;
my $frame = "";

# Info about the current frame
my $has_source_info   = 0;    # <dir>, <file>, <line>
my $has_function_name = 0;    # <fn>
my $has_system_obj    = 0;    # <obj>/lib...   or  <obj>/usr/lib...

while (my $line = <>)
{
    if (! $in_frame) {
        if ($line =~ /<frame>/) {
            $frame = $line;
            $in_frame = 1;
            $has_source_info = $has_function_name = $has_system_obj = 0;
        } else {
            print $line;
        }
        next;
    }

# We're in a frame
    $frame .= $line;
    if ($line =~ /<\/frame>/) {
# Is this a frame we want to keep?
        my $ignore_frame = $has_system_obj ||
            (! $has_source_info && ! $has_function_name);
        if (! $ignore_frame) {
            print $frame;
        }
        $in_frame = 0;
    } else {
        $has_source_info   = 1 if ($line =~ /<(dir|file|line)>/);
        $has_function_name = 1 if ($line =~ /<fn>/);
# This may require tweaking; currently  /lib and /usr/lib are matched
        $has_system_obj = 1 if ($line =~ /<obj>\/lib/);
        $has_system_obj = 1 if ($line =~ /<obj>\/usr\/lib/);
    }
}

exit 0;