blob: f1fa3f070e10edaee23d7dfbe80f1e962b9133a0 [file] [log] [blame]
florianc5325ef2013-09-17 20:15:36 +00001#! /usr/bin/env perl
2
florian73523fd2013-09-18 09:15:23 +00003# Remove certain <frame>.....</frame> records that are suspected to point
4# to some kind of system library. Those are
5# - frames with <obj>/lib/....
6# - frames with <obj>/usr/lib/....
7# - frames without source informatino and without a function name
8#
9# There may be others...
florianc5325ef2013-09-17 20:15:36 +000010
11use strict;
12use warnings;
13
14my $in_frame = 0;
15my $frame = "";
florian73523fd2013-09-18 09:15:23 +000016
17# Info about the current frame
18my $has_source_info = 0; # <dir>, <file>, <line>
19my $has_function_name = 0; # <fn>
20my $has_system_obj = 0; # <obj>/lib... or <obj>/usr/lib...
florianc5325ef2013-09-17 20:15:36 +000021
22while (my $line = <>)
23{
24 if (! $in_frame) {
25 if ($line =~ /<frame>/) {
26 $frame = $line;
27 $in_frame = 1;
florian73523fd2013-09-18 09:15:23 +000028 $has_source_info = $has_function_name = $has_system_obj = 0;
florianc5325ef2013-09-17 20:15:36 +000029 } else {
30 print $line;
31 }
32 next;
33 }
34
35# We're in a frame
36 $frame .= $line;
37 if ($line =~ /<\/frame>/) {
florian73523fd2013-09-18 09:15:23 +000038# Is this a frame we want to keep?
39 my $ignore_frame = $has_system_obj ||
40 (! $has_source_info && ! $has_function_name);
florianc5325ef2013-09-17 20:15:36 +000041 if (! $ignore_frame) {
42 print $frame;
43 }
44 $in_frame = 0;
45 } else {
florian73523fd2013-09-18 09:15:23 +000046 $has_source_info = 1 if ($line =~ /<(dir|file|line)>/);
47 $has_function_name = 1 if ($line =~ /<fn>/);
48# This may require tweaking; currently /lib and /usr/lib are matched
49 $has_system_obj = 1 if ($line =~ /<obj>\/lib/);
50 $has_system_obj = 1 if ($line =~ /<obj>\/usr\/lib/);
florianc5325ef2013-09-17 20:15:36 +000051 }
52}
53
54exit 0;