Any way to specify the location of profile data

前端 未结 4 2067
青春惊慌失措
青春惊慌失措 2021-01-01 22:03

The default the profile file is from the executable is run and the file is called gmon.out. Is there any way to specify a new location?

I\'m using gcc 3

4条回答
  •  我在风中等你
    2021-01-01 22:41

    I encountered the same problem last week and I solved it in the following way. idea here is to change the process current directory to wherever you want to generate gmon.out file. file name can't be changed this way. It allows you to change where you can save the file.

    #ifdef GPROF
                           /* so we can gprof */
                           if (1) {
                               char tmpdir[32];
                               snprintf(tmpdir, 32, "/tmp/%05d", mypid);
                               mkdir(tmpdir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
                               chdir(tmpdir);
                           }
    #endif
    

提交回复
热议问题