Date: Fri, 10 Mar 1995 01:11:46 -0800 (PST) From: Poul-Henning Kamp <phk@ref.tfs.com> To: current@FreeBSD.org Cc: faq@FreeBSD.org Subject: Basic Block Profiling in the kernel Message-ID: <199503100911.BAA03127@ref.tfs.com>
next in thread | raw e-mail | index | archive | help
To use basic-block profiling on the kernel follow these steps:
0. Recompile & install
src/gnu/usr.bin/cc
src/usr.sbin/kernbb
1. Compile your kernel. The source files you want to profile must be
compiled with "-g -a" in CFLAGS.
3. "strip -x kernel", install and reboot
4. Run the machine through its paces, and torture it as you want to excercise
the code.
5. Run the "kernbb" program:
kernbb > /some/where
the output can be up to a couple of megabytes on the format:
../../ddb/db_aout.c 108 X_db_sym_init 4027583916 3108
The fields are:
source file (relative to /sys/compile/<KERNEL>
line number
function
address in decimal
number of times executed.
6. You can use this tcl program to merge the counts into the source:
sort /some/where | tcl merge.tcl > /some/place/else
you can grep on funtions and filenames to limit the output:
grep comwakeup /some/where | sort | tcl merge.tcl > /some/place/else
Here is the code I use: merge.tcl
#!/usr/local/bin/tcl
# change to your kernel compile directory
set dir "/sys/compile/FLAGMOSE"
set line "----------------------------------------------"
set m 0
set f ""
while 1 {
set i ""
set j [gets stdin b]
if {[lindex $b 0] != $f} {
if {$f != ""} {
set p [open $dir/$f]
set k 0
puts ""
puts [string range $line 1 [string length $f]]
puts $f
puts stderr "doing $f"
puts [string range $line 1 [string length $f]]
for {set i 1} {$i <= $m || $k >= 0} {incr i} {
set x ""
catch {set x $lno($i)}
set lno($i) ""
set k [gets $p l]
puts [format "%5u|%-20s|%s" $i $x $l]
}
close $p
}
set m 0
set f [lindex $b 0]
} else {
set l [lindex $b 1]
append lno($l) "[lindex $b 4] "
if {$l > $m} {set m $l}
}
if {$j < 0} break
}
--
Poul-Henning Kamp <phk@login.dknet.dk> -- TRW Financial Systems, Inc.
'All relevant people are pertinent' && 'All rude people are impertinent'
=> 'no rude people are relevant'
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503100911.BAA03127>
