lib/CrashTest/Plugin/StackFilter/FrameTrust.pm
author Vincent Tondellier <tonton+hg@team1664.org>
Wed, 04 Nov 2015 17:43:00 +0100
changeset 78 0ebef32c34af
parent 58 lib/CrashTest/StackFilters/FrameTrust.pm@a3e856c4d161
child 122 8692800ec9ba
permissions -rw-r--r--
Refactor everything - change db access method, use Mojo::{Pg,SQLite,...} instead of DBIx::Class - use Minion as job queue - refactor into a non-Lite Mojolicious app

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

package CrashTest::Plugin::StackFilter::FrameTrust;
use Mojo::Base -base;

sub priority { return 10; }

has [ qw/app/ ];

sub new {
    my $self = shift->SUPER::new(@_);

    return $self;
}

sub apply {
    my ($self, $thread) = @_;

    $thread->each_frame(sub {
            my $frame = shift;

            $self->set_trust($frame);
        }
    );

    return $thread;
}

sub set_trust {
    my ($self, $frame) = @_;

    if(!defined($frame->module) && $frame->offset ne "0x0") {
        push @{$frame->module_warnings}, "No module loaded at this address";
    }

    if($frame->missing_symbols) {
        push @{$frame->module_warnings}, "Missing symbols";
    }

    if($frame->corrupt_symbols) {
        push @{$frame->module_warnings}, "Corrupt symbols";
    }

    if(defined($frame->trust) && $frame->trust eq "scan") {
        push @{$frame->frame_warnings}, "Imprecise stackwalking";
    }

}

1;