简体   繁体   English

用-pg编译的gcc不会产生gprof所需的二进制文件

[英]gcc compiling with -pg doesn't produce binary needed for gprof

I'm running into a little problem and require some assistance. 我遇到了一个小问题,需要一些帮助。 I would like to run gprof on some OpenMP and MPI hybrid code as a part of my testing. 作为测试的一部分,我想在一些OpenMP和MPI混合代码上运行gprof。 I understand that gprof relies on a binary file which is created when you compile gcc (or mpicc) with a -pg switch. 我了解gprof依赖于使用-pg开关编译gcc(或mpicc)时创建的二进制文件。

I have tried adding this switch and my compiling succeeds (as in no errors are reported), however, the binary file is not created but the executable is created as normal. 我尝试添加此开关,并且编译成功(因为未报告任何错误),但是,未创建二进制文件,而是按常规方式创建了可执行文件。 I have also tried doing this on much simpler code, which utilizes pthreads, with the same result. 我也尝试过在使用pthreads的更简单的代码上执行此操作,结果相同。

Please examine the below and let me hear your thoughts. 请检查以下内容,让我听听您的想法。

gcc -pg --std=gnu99 -pthread -Wall -o pthreadsv0 pthreads.c

I suspect that binary file you mention is in fact the profile data file ( gmon.out ) and it is generated when you run your program (which has to be compiled with the -pg flag). 我怀疑您提到的二进制文件实际上是配置文件数据文件( gmon.out ),它是在运行程序时生成的(必须使用-pg标志进行编译)。 Just execute your program and see if a gmon.out file is there. 只需执行您的程序,看看是否有gmon.out文件。

The gprof information is created when you execute the program after you compile with the -pg option. 使用-pg选项编译 执行程序时,将创建gprof信息。 Try running your program. 尝试运行您的程序。 (You're profiling (gprof) the execution of the program) (您正在分析(gprof)程序的执行)

The -pg compile option adds the necessary logic to create the profiling information when the program is executed. -pg compile选项添加了执行程序时创建概要分析信息所必需的逻辑。 Executing the program, several times if desired or needed, allows the 'instrumented' code to write the data describing the logic flow and timing to the gmon.out file. 如果需要或需要多次执行该程序,则允许“插入”代码将描述逻辑流和时序的数据写入gmon.out文件。

Encountered the same problem. 遇到同样的问题。 The problem arose because I was shutting the program's execution with Ctrl-C instead of a proper exit (closing the GUI window in my case). 之所以出现此问题,是因为我用Ctrl-C而不是适当的退出来关闭程序的执行(在我的情况下,关闭GUI窗口)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM