2017-04-07 6 views
1

は、私は次のような簡単なC++プログラムをプロファイルするuftraceをしようとしています:uftraceを使ってC++プログラムをプロファイリングした後、2つのmain()関数を理解するには?

#include <iostream> 

class A { 
public: 
     A() {std::cout << "A is created" << std::endl;} 
     ~A() {std::cout << "A is destroyed" << std::endl;} 
}; 

int main() { 
     A a; 
     return 0; 
} 

プロファイル結果はこのようなものです:2 main()機能があるものを私に混乱することはあり

# uftrace a.out 
A is created 
A is destroyed 
# DURATION TID  FUNCTION 
    2.026 us [ 4828] | __cxa_atexit(); 
      [ 4828] | main() { 
      [ 4828] | __static_initialization_and_destruction_0() { 
    89.397 us [ 4828] |  std::ios_base::Init::Init(); 
    0.768 us [ 4828] |  __cxa_atexit(); 
    93.029 us [ 4828] | } /* __static_initialization_and_destruction_0 */ 
    94.425 us [ 4828] | } /* main */ 
      [ 4828] | main() { 
      [ 4828] | A::A() { 
    11.104 us [ 4828] |  std::operator <<(); 
    10.825 us [ 4828] |  std::basic_ostream::operator <<(); 
    24.514 us [ 4828] | } /* A::A */ 
      [ 4828] | A::~A() { 
    0.978 us [ 4828] |  std::operator <<(); 
    1.676 us [ 4828] |  std::basic_ostream::operator <<(); 
    4.819 us [ 4828] | } /* A::~A */ 
    31.428 us [ 4828] | } /* main */ 
    2.095 us [ 4828] | std::ios_base::Init::~Init(); 

。トレースから、私はiostreamの初期化に関連していると思いますが、実行可能ファイルごとに1 main()のエントリしかないはずです。それをどのように解釈するのですか? https://github.com/namhyung/uftrace/pull/87

ですから、現在のマスターにuftraceを更新した場合 - ので、私はそれを維持するためのパッチを提出し、それが今、合併のシンボルデマングラにいくつかのプレフィックスを除去するために使用されるが、それは一部のユーザーを混乱させる可能性

+0

グローバルオブジェクトの初期化に使用される、プログラムへの実際のエントリポイントとして使用される内部 'main'関数があります。次に、ユーザ定義の 'main'関数を呼び出します。 – Barmar

+0

@Barmar: "ユーザー定義の' main'関数を呼び出すので、 'main'関数は' main'関数の最初の関数に表示されます。 –

+0

名前のついていないランタイムコードが両方あると思われます。 – Barmar

答えて

1

uftrace。最初のmain()_GLOBAL__sub_I_main()になります。

ご意見ありがとうございます。

関連する問題