tranter@testeng1.misemi (Jeff Tranter) (02/27/91)
I have a large application program that is written C and runs under HP-UX 7.0 on an HP 360. Part of the application is a yacc generated compiler. Compile times are long, so I planned to profile the code to see where it could be optimized. I compiled all of the source files for the application with the "-G" option so I could use gprof(1). When I run the program I immediately get a bus error and core dump. I tried using the "-p" option to use prof(1), and I still have the problem. If I only compile the source file containing the routines I want to profile, the bus error still occurs. From the debugger, I have been able to determine that the bus error occurs before the application executes the first line in main(). It is somewhere in the routine "mcount" which I believe is part of the profiler code (but it is a library routine so I do not have source). Any ideas on what the problem is and how it can be solved? -- Jeff Tranter uunet: uunet!mitel!testeng1!tranter Mitel Corporation internet: Jeff_Tranter@mitel.com Kanata, Ontario, CANADA tel: (613) 592-2122 X4957 Fax: (613) 592-4784
mev@hpfcso.FC.HP.COM (Mike Vermeulen) (02/28/91)
> Any ideas on what the problem is and how it can be solved?
My guess is you forgot the -G (or -p) on the command line during
the link step. The final link should look something like:
cc -G -o a.out *.o
The -G option is necessary to make certain the appropriate startup
code (/lib/gcrt0.o for gprof or /lib/mcrt0.o for prof) is linked in
to the program instead of the standard startup code (/lib/crt0.o).
If you accidentally forget the -G on the link step, the appropriate
buffers are not set up and the first time mcount (the counting routine
called at the start of each routine) is called it dies.
--mev