User forums > Using Code::Blocks

I have enabled "Profile code when executed [-pg]" but can't get Gprof to work.

(1/3) > >>

Dice:
I'm using Code::Blocks 13.12 with MinGW -w64 (TDM-GCC suite) compiler on Windows 7.  I have went to --> Settings --> Compiler--> Compiler Settings and checked the box next to "Profile code when executed [-pg]".  Next I build and ran my program in "Debug" mode.  Then I went to --> Plugins --> Code Profiler and selected "Debug" and then pressed "OK".  I then get a pop-up message that says "Cannot find gmon.out.  No profile data found!  Be sure to enable "Profile Code when executed" for the current target.  The target must have been run at least one time after that.  Do you want to search for the profile data file?"

I checked the /bin folder where my compiler is stored and I found gprof.exe so I'm pretty sure I have Gprof.  Is there something else I need to do in order to profile my code?  Am I doing something completely wrong?  Thanks for your time.  This is my first time using a profiler.

oBFusCATed:
The profile data is stored in a gmon.out file.
Do you have one created after you run your exe?
Have you checked the build log after you've enabled the option?

p.s. If you don't have a project probably it is a good idea to create one.

Dice:

--- Quote from: oBFusCATed on January 14, 2016, 09:32:24 am ---The profile data is stored in a gmon.out file.
Do you have one created after you run your exe?
Have you checked the build log after you've enabled the option?

p.s. If you don't have a project probably it is a good idea to create one.

--- End quote ---

Thanks for the reply.  Yes I have created a project and I've checked the project folder but don't see gmon.out in there.  I've also checked the "bin" and "obj" sub-folders but don't see gmon.out.  The project is just a simple printf("Hello World!\n");.  In the build log there is nothing unusual or mention of Gprof.

stahta01:
Remember the "-pg" option needs to be with both the compiler and the linker.

Edit:
My build and run logs; the gmon.out was created in the project folder. If you still have problems post the build log.

--- Code: ----------------- Build: Debug in profile_test (compiler: GNU GCC Compiler)---------------

x86_64-w64-mingw32-g++.exe -Wall -pg -fexceptions -g -Wmissing-include-dirs -DHAVE_TR1_TYPE_TRAITS -DGIT_BUILD  -c C:\SourceCode\test\profile_test\main.cpp -o obj\Debug\main.o
x86_64-w64-mingw32-g++.exe  -o bin\Debug\profile_test.exe obj\Debug\main.o  -pg -lgmon -pg 
Output file is bin\Debug\profile_test.exe with size 164.69 KB
Process terminated with status 0 (0 minute(s), 12 second(s))
0 error(s), 0 warning(s) (0 minute(s), 12 second(s))
 

-------------- Run: Debug in profile_test (compiler: GNU GCC Compiler)---------------

Checking for existence: C:\SourceCode\test\profile_test\bin\Debug\profile_test.exe
Executing: "C:\Program Files (x86)\CodeBlocks_13_12/cb_console_runner.exe" "C:\SourceCode\test\profile_test\bin\Debug\profile_test.exe"  (in C:\SourceCode\test\profile_test\.)
Process terminated with status 0 (0 minute(s), 2 second(s))

--- End code ---

Tim S.

oBFusCATed:

--- Quote from: Dice on January 14, 2016, 11:13:42 am ---Thanks for the reply.  Yes I have created a project and I've checked the project folder but don't see gmon.out in there.  I've also checked the "bin" and "obj" sub-folders but don't see gmon.out.  The project is just a simple printf("Hello World!\n");.  In the build log there is nothing unusual or mention of Gprof.

--- End quote ---
Have you read the docs for gprof? If not take a look at them. It will enlighten you what gprof is capable and what it isn't.
Probably you're app is running for too short time. Try doing some work for 10-20 seconds and report back it still doesn't work.

Navigation

[0] Message Index

[#] Next page

Go to full version