반응형
gprof doesn't produce output
Q: Every time I run the profiler it says "gmon.out: no such file or directory" and no profile is produced. What is this gmon.out file, and why won't gprofcompute the profile?
A: gmon.out is the file with raw execution counts and timing info that gprof needs to produce the profile. The file is written by the profiled program when it exits. If the file isn't created, it might be because of one of the following reasons:
- You didn't compile and/or link your program with the
-pgswitch. Note that both compilation and link need to be done with-pg, because the functions that actually write the results togmon.outare only linked in when GCC sees-pgon the link command line. - You have called
ld.exedirectly to link your program and forgot to mention the files and switches necessary for the profiled program operation. You should usegccto link your program instead of calling the linker directly; a-pgswitch togccis all that it takes to make sure that the linker will get all the necessary arguments22. - Your program exited abnormally. The function which generates
gmon.outis registered with theatexitlibrary function, and won't be called if the program was terminated in an abnormal way. Make sure that your program exits with a call toexitlibrary function or with areturnstatement in yourmainfunction. For example, if your program dies with an exception or a signal, you need to install a handler for that signal and make it callexit.
간만에 프로세스의 성능을 개선해야 할 일이 생겨 gprof을 쓰려고 하니 gmon.out이 생성이 안 되었다. 하루 종일 이리저리 해봐도 안 되었는데... 아주 단순한 문제였다.
linking 시점에도 -pg옵션을 넣으라는... ㅠㅠ
이제 개발도 접어야 하나? 노화가 시작되었다.
반응형