LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-06-2005, 11:56 PM   #1
hemk76
LQ Newbie
 
Registered: Jun 2004
Location: bangalore
Posts: 9

Rep: Reputation: 0
gprof: gmon.out: not in a.out format


hello
i having problem with using GPROF ,
i compiled my programme with -pg option ,it created file gmon.out file
but when i tried using command

gcc -g -pg -Wall scan.c -o scan
gprof -b gmon.out > LOG

it giving this error

gprof: gmon.out: not in a.out format

how do i use gprof with ELF

Thanks in advance
hemanth
eSpark Infotech
 
Old 01-07-2005, 07:27 PM   #2
stanleyg76
LQ Newbie
 
Registered: Dec 2004
Posts: 16

Rep: Reputation: 0
hey,

first off, gmon.out is created when you run the program, not when you compile it.
Now, to run gprof, you need 2 things, an executable, and gmon.out file created
after you've ran the executable at least once (you can run it many times and it
will accumulate the results). Once you get those 2 files, do:

% gprof scan gmon.out

If you don't specify any arguments, gprof will assume executable name
is 'a.out' and profile name is 'gmon.out', but their order is significant. In your
case, gprof thinks that gmon.out is your executable, and so it chokes.
 
Old 01-08-2005, 12:42 AM   #3
hemk76
LQ Newbie
 
Registered: Jun 2004
Location: bangalore
Posts: 9

Original Poster
Rep: Reputation: 0
hello stanleyg76

Thanks for u r reply,i tried the same way u had replied
it gave an error
gcc -g -pg -Wall scan.c -o scan
./scan
gprof scan gmon.out > LOG
gprof: gmon.out file is missing call-graph data

plz help me

Thanks in advance
hemanth
 
Old 01-10-2005, 07:15 PM   #4
stanleyg76
LQ Newbie
 
Registered: Dec 2004
Posts: 16

Rep: Reputation: 0
Note: The -pg option must be part of your compilation options
! as well as your link options. If it is not, when you run gprof
! you will get no profile report and an error message like this:

gprof: gmon.out file is missing call-graph data

If you run the linker ld directly instead of through a compiler
such as gcc, you may have to specify a profiling startup file
gcrt0.o as the first input file instead of the usual startup
 
Old 04-15-2005, 06:52 AM   #5
erwinan
LQ Newbie
 
Registered: Apr 2005
Posts: 1

Rep: Reputation: 0
Still error not in a.out format

hello stanleyg76,

i have tried even the last version:

gprof my_executable gprof > gprof.output

but it still gives an error
gprof: my_executable: not in a.out format

the gprof version is 2.15

i have already googled a bit, but couldn't find any other plausible info on this error.

thanks in advance,
erwin
 
Old 08-15-2005, 09:19 AM   #6
meyers66
LQ Newbie
 
Registered: Aug 2005
Location: Taiwan
Posts: 1

Rep: Reputation: 0
Question gmon.out appearing

I'm new to this forum. I just noticed gmon.out appearing on my Mac Hard Disk. I don't know where it came from. Can I delete it? I'm running 10.3 on an iMac G5.
 
Old 08-15-2005, 03:09 PM   #7
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Yes, you can delete gmon.out.
 
Old 11-06-2005, 11:05 AM   #8
roshankulkarni
LQ Newbie
 
Registered: Nov 2005
Location: Bombay, India
Posts: 5

Rep: Reputation: 0
Use -rdynamic or -static option with the compiler.

Hi,

I faced the same problem as posted by hemant and erwin. The solution is to use one of the following along with the -pg option:

* The -static option to gcc, if you are not using dynamic linking.
* If you are using dynamic linking, then use the -rdynamic option to gcc. This adds the global symbol table to the executable that is generated. I think this should have been on by default, when the -pg option is used.

So, try something like:

$ gcc -static -g -pg -Wall scan.c -o scan
or
$ gcc -rdynamic -g -pg -Wall scan.c -o scan

Then,
$ ./scan
$ gprof scan gmon.out

Hope this helps.
Roshan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gprof problem bogdanpa Programming 2 09-19-2005 09:26 AM
gprof newbie questions windmaomao Programming 2 08-04-2005 12:57 PM
gprof: gmon.out file is missing call-graph data hemk76 Programming 0 01-08-2005 12:54 AM
gprof error Sinner6 Linux - Software 0 07-12-2004 10:06 AM
Is there a gprof for C++? jhirshon Programming 2 04-29-2004 07:35 PM


All times are GMT -5. The time now is 09:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration