This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Patch to gprof to cope with alien gmon.out formats
- To: binutils at sourceware dot cygnus dot com
- Subject: Patch to gprof to cope with alien gmon.out formats
- From: Nick Clifton <nickc at cygnus dot com>
- Date: Thu, 23 Sep 1999 13:00:05 +0100
- Reply-to: nickc at cygnus dot co dot uk
Hi Guys,
Are there any objections to my applying the following patch ?
It makes gprof complain if it is given a gmon.out file in a format
that it does not recognise. This case was triggered by running
gprof on a gmon.out file produced by a profiled binary under OSF1 on
a DEC alpha. The gmon.out file there appears to use a different
format to that expected by GNU gprof and without this patch it will
try to allocate a ridiculous amount of memory (eg
18446744073709551568 bytes).
The DEC alpha gmon.out file appears to be in PDF format (the file
starts with the characters !<PDF>!) whatever that may be. I could
not find any information on it.
Cheers
Nick
1999-09-23 Nick Clifton <nickc@cygnus.com>
* gmon_io.c (gmon_out_read): Make sure that sensible values
are extracted from a raw header.
Index: gprof/gmon_io.c
===================================================================
RCS file: /cvs/binutils/binutils/gprof/gmon_io.c,v
retrieving revision 1.2
diff -p -r1.2 gmon_io.c
*** gmon_io.c 1999/06/30 22:38:20 1.2
--- gmon_io.c 1999/09/23 11:54:52
*************** DEFUN (gmon_out_read, (filename), const
*** 251,256 ****
--- 251,265 ----
printf ("[gmon_out_read] samp_bytes %d hist_num_bins %d\n",
samp_bytes, hist_num_bins));
+ /* Make sure that we have sensible values. */
+ if (samp_bytes < 0 || lowpc > highpc)
+ {
+ fprintf (stderr,
+ _("%s: file '%s' does not appear to be in gmon.out format\n"),
+ whoami, filename);
+ done (1);
+ }
+
if (hist_num_bins)
{
++nhist;