From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16940 invoked by alias); 23 Oct 2002 15:22:13 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 16933 invoked from network); 23 Oct 2002 15:22:12 -0000 Received: from unknown (HELO mx1.mail.ru) (194.67.57.11) by sources.redhat.com with SMTP; 23 Oct 2002 15:22:12 -0000 Received: from drweb by mx1.mail.ru with drweb-scanned (Exim MX.1) id 184NKl-000ACg-00 for gcc-help@gcc.gnu.org; Wed, 23 Oct 2002 19:22:11 +0400 Received: from f7.int ([10.0.0.104] helo=f7.mail.ru) by mx1.mail.ru with esmtp (Exim MX.1) id 184NKl-000ACa-00 for gcc-help@gcc.gnu.org; Wed, 23 Oct 2002 19:22:11 +0400 Received: from mail by f7.mail.ru with local (Exim FE.1) id 184NKl-000KJY-00 for gcc-help@gcc.gnu.org; Wed, 23 Oct 2002 19:22:11 +0400 Received: from [62.118.80.132] by koi.mail.ru with HTTP; Wed, 23 Oct 2002 19:22:11 +0400 From: "Michael Pakhomov" To: gcc-help@gcc.gnu.org Subject: there is no 'main' function in gprof flat profile results Mime-Version: 1.0 X-Originating-IP: 10.125.25.240, 10.125.16.11 via proxy [62.118.80.132] Date: Wed, 23 Oct 2002 08:22:00 -0000 Reply-To: "Michael Pakhomov" Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 8bit Message-Id: X-SW-Source: 2002-10/txt/msg00287.txt.bz2 hi all, it's quite interesting for me why gprof doesn't display 'main' function in flat profile results. that's what i did: 1. compiled a simple application with -pg key as follows: g++ -o foo foo.cpp -g -pg pls see the code of foo.cpp below: //==================================================================== #include // g++ -o foo foo.cpp -g -pg //=== const int num = 50000; double eval_sum(int n = 200); //==== void f1() { eval_sum(); } void f2_call_f1() { eval_sum(); f1(); } void f3() { eval_sum(); } double eval_sum(int n/* = 200*/){ double sum = 0.0, fact = 1.0; int i, j; // loop // direct order for (i = 1; i <= n; ++i){ fact *= (i + 1); sum += 1.0 / fact; } // reset sum sum = 0.0; // indirect order for (i = n; i >= 1; --i){ fact = 1.0; for (j = 1; j < i + 1; ++j){ fact *= (j + 1); } sum += 1.0 / fact; } return sum; } int main (void) { cout << "start->..." << endl; int i, step; for (i = 0, step = num / 10; i < num; ++i) { // progress bar if ((i % step) == 0) { cout << "*" << flush; } f1(); f2_call_f1(); f3(); } cout << endl << "finish->..." << endl; return 0; } //==================================================================== 2. ran foo 3. execute 'gprof -p -b foo' and got the following output: Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls us/call us/call name 100.00 111.09 111.09 200000 555.45 555.45 eval_sum(int) 0.00 111.09 0.00 100000 0.00 555.45 f1(void) 0.00 111.09 0.00 50000 0.00 1110.90 f2_call_f1(void) 0.00 111.09 0.00 50000 0.00 555.45 f3(void) where is function 'main'? gprof doesn't display it in flat profile results, but display it in the call graph. than i ran gprof on another applications and found out that for some of them gprof displays 'main' and for some of them not. i read documentation on gprof, looked in gcc/binutils maillists archive, but haven't find the answer. did i miss something? can somebody kindly help me? my platform is a p4 running red hat 7.3 gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110) binutils-2.11.93.0.2-11 glibc-2.2.5-34 thanks in advance cheers /mpakhomo