# HG changeset patch # User Vincent Tondellier # Date 1407448975 -7200 # Node ID 6fa3cf9cf915916c36e911386ae8ad927df07cd6 # Parent 013953be0f3b85c098ff439104e6f3d8669204a0 Add a filter to display warnings when the backtrace has bad frames diff -r 013953be0f3b -r 6fa3cf9cf915 lib/CrashTest/StackFilters/FrameTrust.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/CrashTest/StackFilters/FrameTrust.pm Fri Aug 08 00:02:55 2014 +0200 @@ -0,0 +1,87 @@ +# 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 . + +package CrashTest::StackFilters::FrameTrust; +use Mojo::Base -base; + +sub priority { return 10; } + +has [ qw/app/ ]; + +sub new { + my $self = shift->SUPER::new(@_); + + # Search for inline templates in this class too + push @{$self->app->renderer->classes}, __PACKAGE__; + + return $self; +} + +sub apply { + my ($self, $thread) = @_; + + # create a pseudo controller to render templates + my $c = $self->app->controller_class->new(app => $self->app); + + $thread->each_frame(sub { + my $frame = shift; + + $self->set_trust($c, $frame); + } + ); + + return $thread; +} + +sub set_trust { + my ($self, $c, $frame) = @_; + + if(!defined($frame->module) && $frame->offset ne "0x0") { + $frame->module_name( + $c->render( + template => "stackfilters/frame_trust/warning", partial => 1, + content_text => $frame->module_name, popup_text => "No module loaded at this address" + ) + ); + } + + if($frame->missing_symbols) { + $frame->module_name( + $c->render( + template => "stackfilters/frame_trust/warning", partial => 1, + content_text => $frame->module_name, popup_text => "Missing symbols" + ) + ); + } + + if(defined($frame->trust) && $frame->trust eq "scan") { + $frame->function_name( + $c->render( + template => "stackfilters/frame_trust/warning", partial => 1, + content_text => $frame->function_name, popup_text => "Imprecise stackwalking" + ) + ); + } + +} + +1; + +__DATA__ + +@@ stackfilters/frame_trust/warning.html.ep +%= tag a => (href => "#", class => "text-danger", "data-toggle" => "tooltip", "data-original-title" => $popup_text) => begin + %= tag span => (class => "glyphicon glyphicon-warning-sign") => "" +% end +%= $content_text + diff -r 013953be0f3b -r 6fa3cf9cf915 public/assets/js/application.js --- a/public/assets/js/application.js Fri Aug 08 00:00:49 2014 +0200 +++ b/public/assets/js/application.js Fri Aug 08 00:02:55 2014 +0200 @@ -9,4 +9,6 @@ $(this).remove(); return false; }); + + $('a[data-toggle="tooltip"]').tooltip(); });