14d161f03STom Zanussi# failed system call counts 24d161f03STom Zanussi# (c) 2010, Tom Zanussi <tzanussi@gmail.com> 34d161f03STom Zanussi# Licensed under the terms of the GNU GPL License version 2 44d161f03STom Zanussi# 54d161f03STom Zanussi# Displays system-wide failed system call totals 64d161f03STom Zanussi# If a [comm] arg is specified, only syscalls called by [comm] are displayed. 74d161f03STom Zanussi 84d161f03STom Zanussiuse lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib"; 94d161f03STom Zanussiuse lib "./Perf-Trace-Util/lib"; 104d161f03STom Zanussiuse Perf::Trace::Core; 114d161f03STom Zanussiuse Perf::Trace::Context; 124d161f03STom Zanussiuse Perf::Trace::Util; 134d161f03STom Zanussi 14c3f5fd28STom Zanussimy $for_comm = shift; 15c3f5fd28STom Zanussi 164d161f03STom Zanussimy %failed_syscalls; 174d161f03STom Zanussi 184d161f03STom Zanussisub raw_syscalls::sys_exit 194d161f03STom Zanussi{ 204d161f03STom Zanussi my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 21*67439d55SMichael Petlan $common_pid, $common_comm, $common_callchain, 224d161f03STom Zanussi $id, $ret) = @_; 234d161f03STom Zanussi 244d161f03STom Zanussi if ($ret < 0) { 254d161f03STom Zanussi $failed_syscalls{$common_comm}++; 264d161f03STom Zanussi } 274d161f03STom Zanussi} 284d161f03STom Zanussi 2907100877SDaniel Bristot de Oliveirasub syscalls::sys_exit 3007100877SDaniel Bristot de Oliveira{ 3107100877SDaniel Bristot de Oliveira raw_syscalls::sys_exit(@_) 3207100877SDaniel Bristot de Oliveira} 3307100877SDaniel Bristot de Oliveira 344d161f03STom Zanussisub trace_end 354d161f03STom Zanussi{ 364d161f03STom Zanussi printf("\nfailed syscalls by comm:\n\n"); 374d161f03STom Zanussi 384d161f03STom Zanussi printf("%-20s %10s\n", "comm", "# errors"); 394d161f03STom Zanussi printf("%-20s %6s %10s\n", "--------------------", "----------"); 404d161f03STom Zanussi 414d161f03STom Zanussi foreach my $comm (sort {$failed_syscalls{$b} <=> $failed_syscalls{$a}} 424d161f03STom Zanussi keys %failed_syscalls) { 43c3f5fd28STom Zanussi next if ($for_comm && $comm ne $for_comm); 44c3f5fd28STom Zanussi 454d161f03STom Zanussi printf("%-20s %10s\n", $comm, $failed_syscalls{$comm}); 464d161f03STom Zanussi } 474d161f03STom Zanussi} 48