I have reproduced this problem on both my old and new laptops.

Last year I used MSYS2 gprof extensively for a couple of C projects and
it definitely was working properly.

--
David May
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


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

Reply via email to