[gprof] disjoint histograms

Vladimir Prus vladimir@codesourcery.com
Mon Feb 12 11:13:00 GMT 2007


Hello!

At present, gprof allows the input file to contain several histogram records,
but requires that the start and end addresses for each histogram is the same.

When doing profiling for a bare-metal target, this is a bit limiting. For
example, we might have 32-bit address space, with lowest 1MB being
flash, highest 1MB being SDRAM and some region in the middle being
SRAM. There's no virtual memory to make "gap-less" space of those
memory regions, so profiling data for all memory regions cannot be
stored in a single histogram record.

It is possible to only collect profiling data for a single region,
but since collecting profiling data might take quite some time, users
would prefer to collect profiling data for all memory ranges,
and then run gprof with different executables separate profiling
for different code stored in memory.

The attached patch makes gprof support histogram records
will different memory ranges, provided those memory ranges
never overlap. This is done by adding new structure, 'struct histogram'
adding a linked list of such structures and modifying gprof to use this
linked list.

I've tested this change on i686 against unmodified gprof, and I get
exactly same textual output when processing a file with single
histogram record and when merging two output files and running gprof
on output.

The functionality of having histograms for different memory ranges
was tested when implementing profiling for Fido boards.

Is this patch OK?

Thanks,
Volodya

	* hist.h (struct histogram)
	(histograms, num_histograms): New.
	* hist.c (find_histogram, find_histogram_for_pc)
	(read_histogram_header): New.
	(s_lowpc, s_highpc, lowpc, highpc, hist_num_bins)
	(hist_sample): Remove.
	(hist_read_rec): Use the above, and handle multiple
	histogram records with disjoint address ranges.
	(hist_write_hist): Support several histogram records.
	(scale_and_align_entries): Adjust for multiple histograms.
	(hist_assign_samples_1): New.
	(hist_assign_samples): Use the above.
	(hist_clip_symbol_address): New.
	* hist.h (hist_check_address)
	(hist_clip_symbol_address): Declare.
	* gmon_io.c (gmon_out_read, gmon_out_write): Adjust handling
	of legacy format for multiple histogram changes.
	* corefile.c (find_call): Check for core_text_space and
	clip symbol address range here.
	* vax.c	(vax_find_call): Don't check for
	core_text_space, or clip the symbol's address range here.
	Use hist_check_address to check call's target address.	
	* sparc.c: Likewise.
	* tahoe.c: Likewise.
	* i386.c: Likewise.
	* mips.c: Likewise. Also use core_text_sect->vma as the base
	address for code accesses, just like other machine-specific
	routines do.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: multipe_histograms.diff
Type: text/x-diff
Size: 28863 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20070212/4a2301a1/attachment.bin>


More information about the Binutils mailing list