4

ドキュメントの目的で、サーバーのコールグラフを生成しようとしています。いかなる種類のプロファイリングにも使用できません。

私は次のように出力を生成しました:

sudo valgrind --tool=callgrind --dump-instr=yes /opt/ats-trunk/bin/traffic_server

http://code.google.com/p/jrfonseca/wiki/Gprof2Dotで.dotファイルに変換されますが、これにはドキュメントとして役立つにはあまりにも多くの情報が含まれています。

libc、libstdc ++、libtcl、libhwlocなどのライブラリへの呼び出しを除外したいと思います。

nb:役に立たないライブラリをgrepしようとしてきましたが、それは面倒で、せいぜい不完全なようです。

よろしくお願いします。

4

1 に答える 1

10

ここで耳をつんざくような沈黙の後、そして実際に私が尋ねたすべての場所で、私はvalgrind-users@MLに目を向けました。スレッドは次のとおりです。

http://sourceforge.net/mailarchive/forum.php?thread_name=e847e3a9-0d10-4c5e-929f-51258ecf9dfc%40iris&forum_name=valgrind-users

Josefの返信は非常に役に立ち、#perlからの多くの忍耐力で、スクリプトをまとめて、コールグラフで不要なライブラリを除外するのに役立ちました。

このスクリプトは、callgrindに余分な冗長性を指示することに依存しています。

valgrind --tool=callgrind --dump-instr=yes --compress-pos=no \
  --compress-strings=no /opt/ats-trunk/bin/traffic_server

このようにして、参照番号の代わりに文字列を生成し、解析をはるかに簡単にします。

#!/usr/bin/perl

use Modern::Perl;
require File::Temp;

my $cob = qr{^cob=/(?:usr/)?lib};
my $ob = qr{^ob=/(?:usr/)?lib/};
my $calls = qr{^calls=};

open (my $fh, '<', $ARGV[0]) or die $!;
my $tmp = File::Temp->new(UNLINK => 1);

## Skip all external libraries, as defined by $ob
while (readline $fh) {
    if (/$ob/ ) {
        # skip the entire ob= section we don't need.
        0 while defined($_ = readline $fh) && !/^ob=/;

        # put the last line back, we read too far
        seek($fh, -length($_), 1);
    } else {
        print $tmp $_;
    }
}
close ($fh);

## Skip all calls to external libraries, as defined by $cob
my $tmpname = $tmp->filename;
open ($tmp, '<', $tmpname) or die $!;
while (readline $tmp) {
    if (/$cob/) {

        # skip until we find a line starting with calls=
        # skip that line too
        0 while defined($_ = readline $tmp) && !/$calls/;

        # then we skip until we either hit ^word= or an empty line.
        # In other words: skip all lines that start with 0x
        0 while defined($_ = readline $tmp) && /^0x/;

        # put the last line back, we read too far
        seek($tmp, -length($_), 1);
    }  else {
       print;
    }
}
于 2011-10-14T23:56:54.193 に答える