Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - gprof broken?: (5 Items)
   
gprof broken?  
hmmm - I am trying gprof against a very basic C program, on native neutrino...I need to use a number of packages that 
build a *whole* lot easier using GNU autoconf, than trying to shoe-horn them into the IDE's make.  This works fine under
 Linux, Solaris, etc. etc.

thanks in advance!
Chris
---------------------------------------------------------------------- 

$ uname -a 
QNX localhost 6.4.0 2008/10/21-11:10:24EDT x86pc x86

$ which gcc
/usr/qnx640/host/qnx6/x86/usr/bin/gcc

$ cat foo.c

#include <stdio.h>
void waste_cpu() {
        int i;
        double j, k, q;
        for (i = 0, j = 1.0, k = 2.0; i < 10000000; i++, j += 1.0, k += 1.0) {
                q = j / k;
        }
}
main() {
        int m;
        for (m = 1; m < 10; m++) {
                waste_cpu();
                printf(".");
        }
        printf("\n");
}

$ gcc -pg foo.c
$./a.out
$..........

$gprof ./a.out | more

Flat profile:

Each sample counts as 0.001 seconds.
 no time accumulated

  %   cumulative   self              self     total
 time   seconds   seconds    calls  Ts/call  Ts/call  name
  0.00      0.00     0.00        9     0.00     0.00  main
  0.00      0.00     0.00        1     0.00     0.00  _start




Re: gprof broken?  
Chris Nicholas wrote:
> hmmm - I am trying gprof against a very basic C program, on native neutrino...I need to use a number of packages that 
build a *whole* lot easier using GNU autoconf, than trying to shoe-horn them into the IDE's make.  This works fine under
 Linux, Solaris, etc. etc.

The gear in libc that does the sampling needs I/O privileges so you will 
need to run your program as root.

Regards,

Ryan Mansfield
Re: gprof broken?  
thank you; that trivial example works now...

but now when I built my app with -pg, including the final link stage, and run it, the first pass doesn't produce a gmon.
out file ... even running as root...

hmmm...

any suggestions greatly appreciated!
Chris
--------------------------------
# id
uid=0(root) gid=0(root) groups=0(root),1(bin),3(sys),4(adm),5(tty)
#

# make -f Makefile.qnx
(lots of compiling with -c and -pg option...)
g++ -c -pg -w -g -fno-strict-aliasing -fno-common -I/usr/local/include -I/usr/qnx640/target/qnx6/usr/include -I../Libs/
eigen/src -I../Libs/tinyxpath
 -I../Libs/jpeg-6b -DQNX -DTOUCHSCREEN  -o qnx_main.o qnx_main.cpp


g++ -pg -w -g -fno-strict-aliasing -fno-common -I/usr/local/include -I/usr/qnx640/target/qnx6/usr/include -I../Libs/
eigen/src -I../Libs/tinyxpath -I../Libs/jpeg-6b -DQNX -DTOUCHSCREEN  Application.o Configuration.o Graphic.o 
InputHandler.o Md3dm.o Position.o Button.o ContentManager.o Ground.o Interface.o Model.o Rectangle.o Transformer.o 
Camera.o Events.o Image.o JPEG.o PNG.o Renderer.o Vehicle.o BoundingBox.o Region.o UtfConverter.o ConvertUTF.o Text.o 
Autopilot.o Route.o Waypoint.o Control.o ListBox.o MyDDS.o Stats.o Graphic3D.o POI.o qnx_main.o ../Libs/jpeg-6b/libjpeg.
a /usr/local/lib/libpng.a -lGLES_CM /usr/local/lib/libproj.a ../Libs/tinyxpath/libtinyxpath.a /usr/local/lib/libz.a -lm 
-lgf -pg -o ../Bin/nav

# cd ../Bin
# ls
.      ..     nav
# ./nav
(lots of goo....)
^C
# ls
.      ..     nav
#

.
Re: gprof broken?  
The process needs to call exit() to generate a gmon.out - although that's not needed with the IDE based live profiling
stuff.

Colin

Chris Nicholas wrote:
> thank you; that trivial example works now...
> 
> but now when I built my app with -pg, including the final link stage, and run it, the first pass doesn't produce a 
gmon.out file ... even running as root...
> 
> hmmm...
> 
> any suggestions greatly appreciated!
> Chris
> --------------------------------
> # id
> uid=0(root) gid=0(root) groups=0(root),1(bin),3(sys),4(adm),5(tty)
> #
> 
> # make -f Makefile.qnx
> (lots of compiling with -c and -pg option...)
> g++ -c -pg -w -g -fno-strict-aliasing -fno-common -I/usr/local/include -I/usr/qnx640/target/qnx6/usr/include -I../Libs
/eigen/src -I../Libs/tinyxpath
>  -I../Libs/jpeg-6b -DQNX -DTOUCHSCREEN  -o qnx_main.o qnx_main.cpp
> 
> 
> g++ -pg -w -g -fno-strict-aliasing -fno-common -I/usr/local/include -I/usr/qnx640/target/qnx6/usr/include -I../Libs/
eigen/src -I../Libs/tinyxpath -I../Libs/jpeg-6b -DQNX -DTOUCHSCREEN  Application.o Configuration.o Graphic.o 
InputHandler.o Md3dm.o Position.o Button.o ContentManager.o Ground.o Interface.o Model.o Rectangle.o Transformer.o 
Camera.o Events.o Image.o JPEG.o PNG.o Renderer.o Vehicle.o BoundingBox.o Region.o UtfConverter.o ConvertUTF.o Text.o 
Autopilot.o Route.o Waypoint.o Control.o ListBox.o MyDDS.o Stats.o Graphic3D.o POI.o qnx_main.o ../Libs/jpeg-6b/libjpeg.
a /usr/local/lib/libpng.a -lGLES_CM /usr/local/lib/libproj.a ../Libs/tinyxpath/libtinyxpath.a /usr/local/lib/libz.a -lm 
-lgf -pg -o ../Bin/nav
> 
> # cd ../Bin
> # ls
> .      ..     nav
> # ./nav
> (lots of goo....)
> ^C
> # ls
> .      ..     nav
> #
> 
> .
> 
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post21807
> 

-- 
cburgess@qnx.com
Re: gprof broken?  
So you can add signal handler on "^C" (signal 15 o 2) and do "exit(15)" to trigger gmon creation.

Colin Burgess wrote:
> The process needs to call exit() to generate a gmon.out - although that's not needed with the IDE based live profiling

> stuff.
> 
> Colin
> 
> Chris Nicholas wrote:
>> thank you; that trivial example works now...
>>
>> but now when I built my app with -pg, including the final link stage, and run it, the first pass doesn't produce a 
gmon.out file ... even running as root...
>>
>> hmmm...
>>
>> any suggestions greatly appreciated!
>> Chris
>> --------------------------------
>> # id
>> uid=0(root) gid=0(root) groups=0(root),1(bin),3(sys),4(adm),5(tty)
>> #
>>
>> # make -f Makefile.qnx
>> (lots of compiling with -c and -pg option...)
>> g++ -c -pg -w -g -fno-strict-aliasing -fno-common -I/usr/local/include -I/usr/qnx640/target/qnx6/usr/include -I../
Libs/eigen/src -I../Libs/tinyxpath
>>  -I../Libs/jpeg-6b -DQNX -DTOUCHSCREEN  -o qnx_main.o qnx_main.cpp
>>
>>
>> g++ -pg -w -g -fno-strict-aliasing -fno-common -I/usr/local/include -I/usr/qnx640/target/qnx6/usr/include -I../Libs/
eigen/src -I../Libs/tinyxpath -I../Libs/jpeg-6b -DQNX -DTOUCHSCREEN  Application.o Configuration.o Graphic.o 
InputHandler.o Md3dm.o Position.o Button.o ContentManager.o Ground.o Interface.o Model.o Rectangle.o Transformer.o 
Camera.o Events.o Image.o JPEG.o PNG.o Renderer.o Vehicle.o BoundingBox.o Region.o UtfConverter.o ConvertUTF.o Text.o 
Autopilot.o Route.o Waypoint.o Control.o ListBox.o MyDDS.o Stats.o Graphic3D.o POI.o qnx_main.o ../Libs/jpeg-6b/libjpeg.
a /usr/local/lib/libpng.a -lGLES_CM /usr/local/lib/libproj.a ../Libs/tinyxpath/libtinyxpath.a /usr/local/lib/libz.a -lm 
-lgf -pg -o ../Bin/nav
>>
>> # cd ../Bin
>> # ls
>> .      ..     nav
>> # ./nav
>> (lots of goo....)
>> ^C
>> # ls
>> .      ..     nav
>> #
>>
>> .
>>
>>
>> _______________________________________________
>> General
>> http://community.qnx.com/sf/go/post21807
>>
>