Author Topic: How to profile?  (Read 25026 times)

Offline z0b

  • Single posting newcomer
  • *
  • Posts: 9
    • http://koti.mbnet.fi/~z0b
How to profile?
« on: June 05, 2005, 04:25:35 pm »
How can I generate profiling information? I have enabled the "Profile code when executed" flag (have checked it on ALL options pages I've found), but I can't generate the gmon.out file.

Is the problem in CB or am I doing something wrong?

As I understand, the gmon.out is produced by the target application, but it does not. Adding -pg to compiler/linker switches does nothing either.

Any ideas?

Offline z0b

  • Single posting newcomer
  • *
  • Posts: 9
    • http://koti.mbnet.fi/~z0b
How to profile?
« Reply #1 on: June 06, 2005, 05:05:16 pm »
Anybody?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
How to profile?
« Reply #2 on: June 06, 2005, 05:55:08 pm »
Do you mind posting the full compile log?
(You have to enable it first: Compiler->Compiler options->Other->Compiler logging->Full)

Yiannis.
Be patient!
This bug will be fixed soon...

Offline z0b

  • Single posting newcomer
  • *
  • Posts: 9
    • http://koti.mbnet.fi/~z0b
How to profile?
« Reply #3 on: June 06, 2005, 07:03:10 pm »
Sure.

Code
Project   : PortalCraft
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\projects\editor2\
--------------------------------------------------------------------------------
Switching to target: default
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c console.cpp -o obj\console.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c editing_utility.cpp -o obj\editing_utility.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c export.cpp -o obj\export.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c glstuff.cpp -o obj\glstuff.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c level.cpp -o obj\level.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c main.cpp -o obj\main.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c mathutil.cpp -o obj\mathutil.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c objects.cpp -o obj\objects.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c options.cpp -o obj\options.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c osfunctions.cpp -o obj\osfunctions.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c portalbsp.cpp -o obj\portalbsp.o
windres.exe -i portalcraft.rc -J rc -o obj\portalcraft.res -O coff  
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c portals.cpp -o obj\portals.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c prefab.cpp -o obj\prefab.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c primitives.cpp -o obj\primitives.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c profile.cpp -o obj\profile.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c properties.cpp -o obj\properties.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c sb_vertex_editor.cpp -o obj\sb_vertex_editor.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c sectors.cpp -o obj\sectors.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c sidebar.cpp -o obj\sidebar.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c texture.cpp -o obj\texture.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c texturefitter.cpp -o obj\texturefitter.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c utility.cpp -o obj\utility.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c view2d_front.cpp -o obj\view2d_front.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c view2d_side.cpp -o obj\view2d_side.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c view2d_top.cpp -o obj\view2d_top.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c view3d.cpp -o obj\view3d.o
mingw32-g++.exe   -pg -g     -IC:\MinGW\include -c viewutil.cpp -o obj\viewutil.o
mingw32-g++.exe    -LC:\MinGW\lib -o pc.exe obj\console.o obj\editing_utility.o obj\export.o
obj\glstuff.o obj\level.o obj\main.o obj\mathutil.o obj\objects.o obj\options.o obj\osfunctions.o
obj\portalbsp.o obj\portals.o obj\prefab.o obj\primitives.o obj\profile.o obj\properties.o
obj\sb_vertex_editor.o obj\sectors.o obj\sidebar.o obj\texture.o obj\texturefitter.o obj\utility.o
obj\view2d_front.o obj\view2d_side.o obj\view2d_top.o obj\view3d.o obj\viewutil.o  obj\portalcraft.res
   -pg -lgmon     -lstdc++ -lgcc -lgdi32 -lcomdlg32 -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32
   -lcomctl32 -lctl3d32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid C:\mingw\lib\libfio.a
   c:\mingw\lib\libcfg.a C:\MinGW\lib\libmsimg32.a C:\mingw\lib\liballeg.a  -mwindows
Process terminated with status 0 (0 minutes, 46 seconds)
0 errors, 0 warnings

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
How to profile?
« Reply #4 on: June 06, 2005, 10:27:59 pm »
Everything seems just fine.
Create a new "Hello world" console project, enable profiling and see if it works. I tried it here and it works. If yours doesn't, something might be wrong with your MinGW installation...

Yiannis.
Be patient!
This bug will be fixed soon...

Offline z0b

  • Single posting newcomer
  • *
  • Posts: 9
    • http://koti.mbnet.fi/~z0b
How to profile?
« Reply #5 on: June 07, 2005, 07:33:56 am »
OK, created new project (not exactly "Hello World" but new project from the Win32GUI template) and it did create profiling output. So the problem is somewhere else. Something in my project prevents the profiling output generation.

Does anyone have any idea what would cause that? Perhaps one of those libraries I'm using?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
How to profile?
« Reply #6 on: June 07, 2005, 08:54:46 am »
Quote
-lstdc++ -lgcc

Are these options necessary in your linker options?

Also make sure of the following:
Quote
Your program exited abnormally. The function which generates gmon.out is registered with the atexit library function, and won't be called if the program was terminated in an abnormal way. Make sure that your program exits with a call to exit library function or with a return statement in your main function. For example, if your program dies with an exception or a signal, you need to install a handler for that signal and make it call exit.


Yiannis.
Be patient!
This bug will be fixed soon...

Offline z0b

  • Single posting newcomer
  • *
  • Posts: 9
    • http://koti.mbnet.fi/~z0b
How to profile?
« Reply #7 on: June 07, 2005, 10:11:23 am »
Quote

Your program exited abnormally. The function which generates gmon.out is registered with the atexit library function, and won't be called if the program was terminated in an abnormal way. Make sure that your program exits with a call to exit library function or with a return statement in your main function. For example, if your program dies with an exception or a signal, you need to install a handler for that signal and make it call exit.


That's it! You see, I have one function called exitEditor() that I call when user clicks the X, chooses File/Exit, etc. The last line in that function was "exit(1);", I changed it to "exit(0);" and behold, gmon.out appeared to same directory with the EXE and gprof is happy.

So that was it. Thanks mandrav! :D

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
How to profile?
« Reply #8 on: June 07, 2005, 11:01:31 am »
I 'm glad we got it working :)

Yiannis.
Be patient!
This bug will be fixed soon...