mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 00:23:30 +00:00
Organize companion code and materials by book part: part-01/ Foundations part-02/ Kernel & driver fundamentals part-03/ Character & block devices part-04/ Networking & storage part-05/ Buses & advanced topics part-06/ Debugging & performance part-07/ Real-world drivers appendices/ Supplementary material README.md Overview and build instructions
24 lines
693 B
Bash
Executable file
24 lines
693 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# callgraph.sh - collect callgraph samples while a workload runs.
|
|
#
|
|
# Usage: ./callgraph.sh [duration_seconds]
|
|
#
|
|
# Produces pmc.cg, which can be converted to a flame graph with:
|
|
# pmcstat -R pmc.cg -G - | stackcollapse-pmc.pl | flamegraph.pl > out.svg
|
|
# (stackcollapse-pmc.pl and flamegraph.pl are from Brendan Gregg's
|
|
# FlameGraph repository.)
|
|
|
|
DURATION=${1:-30}
|
|
|
|
if ! kldstat | grep -q hwpmc; then
|
|
echo "Loading hwpmc..."
|
|
sudo kldload hwpmc
|
|
fi
|
|
|
|
echo "Collecting callgraph samples for $DURATION seconds..."
|
|
sudo pmcstat -S cycles -O pmc.cg -n 1 sleep $DURATION
|
|
|
|
echo
|
|
echo "Samples written to pmc.cg. Top functions by call count:"
|
|
sudo pmcstat -R pmc.cg -G - | head -30
|