I've noticed that if you run gprof with -z (unused functions) you'll see it provides all the expected functions but with 0 measures for everything (even _mcount_private).

- David

On 4/29/2021 7:46 PM, [email protected] wrote:
Yeah, that matches up with what I've experienced using Mingw64-Builds 8.1.0 release as well.

I need the newer C++ features of 10.2 for the project I was originally trying to profile though.

I've raised an issue 8503 on the MSYS2 github for this. https://github.com/msys2/MINGW-packages/issues/8503

Though I don't know if that's the best place to raise it?

- David


-------- Original message --------
From: DAVID MAY <[email protected]>
Date: Thu, 29 Apr 2021, 19:16
To: [email protected], David Murphy <[email protected]> Subject: Re: [Mingw-w64-public] Compiling with -pg and executable's gmon.out has empty gprof results

    Some more information on this issue:

    I looked at one of my old C++ projects developed using MSYS2 last year
    and reran the current gprof program using the old project profiled
    executable and its gmon.out file created on 10 November 2020. A
    correct
    report was generated.

    On 28/04/2021 10:41 am, David Murphy wrote:
    > There's lots of detail in my question here
    >
    
https://stackoverflow.com/questions/67240792/gprof-producing-no-output-for-a-program-that-takes-reasonable-time-to-execute
    >
    >
    > To summarise:
    >
    > 1. I'm using Mingw64 latest packages from MSYS2
    > 2. Program is compiled and linked with -g -pg
    > 3. Program, when executed, produces gmon.out
    > 4. Parsing gmon.out through gprof gives empty results
    >
    > I've checked:
    >
    > 1. Program exits normally
    > 2. I've tested two different programs (code below) in an attempt to
    > ensure there's enough time spent in the functions to generate
    results.
    > Both programs take a long time to execute.
    > 3. I've compiled with and without -no-pie
    > 4. I've tried both 32bit and 64bit releases
    > 5. Tried both GCC and G++
    >
    > In the stack overflow question I've also provided additional
    info from
    > VTune (that I don't fully understand).
    >
    > Everyone else who's compiled and tested the programs gives them a
    > gmon.out and gprof gives them output. I'm not sure what else I
    can do to
    > figure out why I'm unable to profile code. I've asked MSYS2 devs but
    > they've not responded. Considering MSYS2 is pretty much just
    packaging
    > Mingw64 I was hoping someone in this mailing list might be able
    to help,
    > or at least point me in the right direction.
    >
    >
    > Program for Primes:
    >
    > #include <iostream>
    >
    > bool is_prime(const int& number)
    > {
    >     if(number == 0 || number == 1)
    >         return false;
    >     else
    >     {
    >         for(int i = 2; i <= number / 2; ++i)
    >         {
    >             if(number % i == 0)
    >             {
    >                 return false;
    >             }
    >         }
    >     }
    >
    >     return true;
    > }
    >
    > int main()
    > {
    >     int low = 0;
    >     int high = 1000000;
    >
    >     while(low < high)
    >     {
    >         if(is_prime(low))
    >             std::cout << low << ", ";
    >
    >         ++low;
    >     }
    >
    >     std::cout << std::endl;
    >
    >     return 0;
    > }
    >
    >
    > Program for long function calls:
    >
    > //test_gprof.c
    > #include<stdio.h>
    >
    > void new_func1(void)
    > {
    >     printf("\n Inside new_func1()\n");
    >     int i = 0;
    >
    >     for(;i<0xffffffff;i++);
    >
    >     return;
    > }
    >
    > void func1(void)
    > {
    >     printf("\n Inside func1 \n");
    >     int i = 0;
    >
    >     for(;i<0xffffffff;i++);
    >     new_func1();
    >
    >     return;
    > }
    >
    > static void func2(void)
    > {
    >     printf("\n Inside func2 \n");
    >     int i = 0;
    >
    >     for(;i<0xffffffff;i++);
    >     return;
    > }
    >
    > int main(void)
    > {
    >     printf("\n Inside main()\n");
    >     int i = 0;
    >
    >     for(;i<0xffffff;i++);
    >     func1();
    >     func2();
    >     func1();
    >     func2();
    >
    >     return 0;
    > }
    >
    > Any help would be greatly appreciated.
    >
    > Cheers,
    > David
    >
    >
    >
    > _______________________________________________
    > Mingw-w64-public mailing list
    > [email protected]
    > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

-- David May


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to