{ NULL, 0, NULL, OPTION_DOC, N_("Output options:"), 1 },
{ "verbose", 'v', NULL, 0, N_ ("Increase verbosity of logging messages."), 0 },
{ "gmon", 'g', NULL, 0, N_("Generate gmon.BUILDID.out files for each binary."), 0 },
- { "hist-split", 'h', HIST_SPLIT_OPTS, 0, N_("Histogram splitting method for gmon, default 'flex'."), 0 },
+ { "hist-split",'G', HIST_SPLIT_OPTS, 0, N_("Histogram splitting method for gmon, default 'even'."), 0 },
{ "output", 'o', "DIR", 0, N_("Output directory for gmon files."), 0 },
{ "force", 'f', NULL, 0, N_("Unlink output files to force writing as new."), 0 },
{ "pid", 'p', "PID", 0, N_("Profile given PID, and its future children."), 0 },
// Globals set based on command line options:
static unsigned verbose;
static bool gmon;
-static hist_split_method gmon_hist_split = HIST_SPLIT_FLEX;
+static hist_split_method gmon_hist_split = HIST_SPLIT_EVEN;
static string output_dir = ".";
static bool output_force = false; // overwrite preexisting output files?
static int pid;
gmon = true;
break;
- case 'h':
+ case 'G':
/* TODO: Error if -g is not set? */
if (strcmp (arg, "none") == 0)
gmon_hist_split = HIST_SPLIT_NONE;
if (pc - low_pc > opt_size)
{
/* Record a histogram from low_pc to low_pc+opt_size. */
- this->record_gmon_hist(of, m.histogram, low_pc, low_pc+opt_size /* >= prev_pc */, alignment);
+ this->record_gmon_hist(of, m.histogram,
+ low_pc, low_pc+opt_size-1 /* >= prev_pc */,
+ alignment);
low_pc = pc;
}
prev_pc = pc;
}
/* Record a final histogram from low_pc to low_pc+opt_size.
TODO: Edge case -- adjust for overflow of low_pc+opt_size at end of address space. */
- this->record_gmon_hist(of, m.histogram, low_pc, low_pc+opt_size /* >= prev_pc */, alignment);
+ this->record_gmon_hist(of, m.histogram,
+ low_pc, low_pc+opt_size-1 /* >= prev_pc */,
+ alignment);
}
else if (gmon_hist_split == HIST_SPLIT_FLEX)
{
grep "Starting stack profile collection pid" test.out
grep -E "^buildid [0-9a-f]+" test.out
+export DEBUGINFOD_URLS=https://debuginfod.elfutils.org/
+
for f in gmon.*.out
do
- gprof `basename "$f" .out`.exe "$f"
+ exe="`basename "$f" .out`.exe"
+ echo "NOTE: analyzing $exe `readlink $exe`"
+ tempfiles gprof_output.txt
+ # Try a plain gprof attempt on the executable
+ if gprof "$exe" > gprof_output.txt 2>&1; then
+ # Success, use the output
+ cat gprof_output.txt
+ else
+ # Fall back to debuginfod if necessary (e.g., if debug info is missing)
+ echo "NOTE: stripped binary found, attempting to find debuginfo"
+ if testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $exe; then
+ debuginfo="`debuginfod-find debuginfo $exe`"
+ gprof "$debuginfo" "$f"
+ else
+ echo "SKIPPING: debuginfo not found"
+ fi
+ fi
done
exit 0