15

私はこれに慣れていないので、おそらく基本的な何かが欠けています。gcc 4.8 (MinGW) と -g オプションを使用して C プログラムをコンパイルします。

次にそれを実行し、Very Sleepy でキャプチャします。すべて動作しますが、Sleepy の出力は次のようになります。

memcpy             0.98 0.98 7.65 7.65  msvcrt unknown 0
[00000000004038FE] 0.77 0.77 6.02 6.02  a              0
memset             0.63 0.63 4.92 4.93  msvcrt unknown 0
[0000000000404549] 0.42 0.42 3.29 3.29  a              0
[000000000040282A] 0.35 0.35 2.73 2.73  a              0
[0000000000404600] 0.25 0.25 1.99 1.99  a              0
....
etc.

(私のアプリケーションは a.exe と呼ばれます)
Sleepy には関数名が表示されません。動作させるにはどのようにコンパイル/実行する必要がありますか? 眠そうなウェブサイトは以下を提供します:

GCC/mingw のサポート。DWARF2 データが埋め込まれた実行可能ファイルをプロファイリングできるようになり、動作するはずです。これには特別なオプションは必要ありません。「-g」を指定してコンパイルするだけで、シンボルが存在することを確認できます。通常、Sleepy はどちらの方法でも機能しますが、「-fno-omit-frame-pointer」を使用して正しいコールスタックを確保することもできます。「-pg」やゴミを使用する必要はありません。Microsoft DLL から GCC DLL への正しいスタックをウォークスルーすることもできますが、これは想像以上に困難でした。

しかし、私の場合は十分ではありません。

4

1 に答える 1

7

Usually we call the very sleepy command (or any other debugging tool) with the arguments:

  • -O0: sets default code optimization (more optimized code used to reduce time or space can hide some functions)
  • -g: it's used to retain the name of the functions and the variable, that are mangled by default in order to optimize the executable, but it makes it less debuggable: gcc -g :what will happen
  • -fno-omit-frame-pointer : it's also used to improve debugging by ommiting frame pointers (a feature used to improve performance but that makes the debug less readable), according to When should I omit the frame pointer?. With that option, the output assembly code is more simple. That helps the debugger
  • -gdwarf-2: https://gcc.gnu.org/onlinedocs/gcc-3.4.5/gcc/Debugging-Options.html specifies that it's set to force the output debugging format to "dwarf2". In fact, the -g option just tells the compiler to "retain some information". gdwarf will specify the output format (if possible).

You can also add a -glevel to indicate the precision of the output information. The default one is 2. It does not retain macros and some definitions. Maybe you can set it to 3.

If it's not enough maybe you can give a minimal working sample to see the exact problem (which function should appear in the log)?

I hope it will help

于 2016-06-23T20:23:53.967 に答える