public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Dragos Tarcatu <tarcatu_dragosh@yahoo.com>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: Problem with gprof for code containing static functions
Date: Wed, 09 Jul 2014 07:49:00 -0000	[thread overview]
Message-ID: <1404892147.73620.YahooMailNeo@web122402.mail.ne1.yahoo.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]

I've been encountering some problems using gprof (GNU gprof (GNU Binutils) 2.24.51.20140623) in the most recent cygwin (32 bits) . Basically gprof seems to be missing static functions calls in the flat profile report. For the attached source file (compiled with -Wall -g -pedantic -std=c99 -pg -O0) if I disable the USE_STATIC macro the flat report seems ok. 
Each sample counts as 0.01 seconds. 
  %   cumulative   self              self     total 
 time   seconds   seconds    calls   s/call   s/call  name 
 89.24      1.99     1.99 100000000     0.00     0.00  f5 
  8.07      2.17     0.18                             _mcount_private 
  1.79      2.21     0.04  1000000     0.00     0.00  f4 
  0.90      2.23     0.02                             _fentry__ 
  0.00      2.23     0.00    10000     0.00     0.00  f3 
  0.00      2.23     0.00      100     0.00     0.02  f2 
  0.00      2.23     0.00        1     0.00     2.03  f1 
  
But if I enable it (making those functions static) I get pretty weird results: 
Each sample counts as 0.01 seconds. 
  %   cumulative   self              self     total 
 time   seconds   seconds    calls  Ts/call  Ts/call  name 
 87.78      1.94     1.94                             f5 
  8.60      2.13     0.19                             _mcount_private 
  1.81      2.17     0.04                             _fentry__ 
  1.81      2.21     0.04                             f4 
  0.00      2.21     0.00 101010000     0.00     0.00  __gcc_deregister_frame 
  0.00      2.21     0.00      100     0.00     0.00  f2 
  0.00      2.21     0.00        1     0.00     0.00  f1 
Is this a known issue? 

[-- Attachment #2: test.c --]
[-- Type: text/plain, Size: 691 bytes --]

#include<stdio.h>
#include<stdlib.h>


#define N1 100
#define N2 100
#define N3 100
#define N4 100

#define USE_STATIC

#ifdef USE_STATIC
static
#endif
void f5() {
    int i;
    for (i = 0; i < 10; i++) {
    }
}

#ifdef USE_STATIC
static
#endif
void f4()  {
    int i;
    for (i = 0; i < N4; i++) {
        f5();
    }
}

#ifdef USE_STATIC
static
#endif
void f3() {
    int i;
    for (i = 0; i < N3; i++) {
        f4();
    }
}


void f2() {
    int i;
    for (i = 0; i < N2; i++) {
        f3();
    }
}

void f1() {
    int i;
    for (i = 0; i < N1; i++) {
        f2();
    }
}


int main() {
    f1();
    return 0;
}


[-- Attachment #3: Type: text/plain, Size: 218 bytes --]

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

                 reply	other threads:[~2014-07-09  7:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1404892147.73620.YahooMailNeo@web122402.mail.ne1.yahoo.com \
    --to=tarcatu_dragosh@yahoo.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).