[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gprof/13993] New: gprof failed to accumulate hist time
From: |
manjian2006 at gmail dot com |
Subject: |
[Bug gprof/13993] New: gprof failed to accumulate hist time |
Date: |
Thu, 19 Apr 2012 03:35:31 +0000 |
http://sourceware.org/bugzilla/show_bug.cgi?id=13993
Bug #: 13993
Summary: gprof failed to accumulate hist time
Product: binutils
Version: 2.22
Status: NEW
Severity: normal
Priority: P2
Component: gprof
AssignedTo: address@hidden
ReportedBy: address@hidden
Classification: Unclassified
This bug occurred in hist_assign_samples_1 which is located in hist.c.When
bin_high_pc < sym_low_pc was true at first hit,the variable j kept decreasing
until it overflowed.No symbol would be find in this situation.The following is
my fix of this bug,may harm the performance.
static void
hist_assign_samples_1 (histogram *r)
{
bfd_vma bin_low_pc, bin_high_pc;
bfd_vma sym_low_pc, sym_high_pc;
bfd_vma overlap, addr;
unsigned int bin_count;
unsigned int i;
double count_time, credit;
bfd_vma lowpc = r->lowpc / sizeof (UNIT);
/* Iterate over all sample bins. */
for (i = 0; i < r->num_bins; ++i)
{
unsigned int j;
bin_count = r->sample[i];
if (! bin_count)
continue;
bin_low_pc = lowpc + (bfd_vma) (hist_scale * i);
bin_high_pc = lowpc + (bfd_vma) (hist_scale * (i + 1));
count_time = bin_count;
DBG (SAMPLEDEBUG,
printf (
"[assign_samples] bin_low_pc=0x%lx, bin_high_pc=0x%lx, bin_count=%u\n",
(unsigned long) (sizeof (UNIT) * bin_low_pc),
(unsigned long) (sizeof (UNIT) * bin_high_pc),
bin_count));
total_time += count_time;
/* Credit all symbols that are covered by bin I. */
for (j = 1; j < symtab.len; ++j)
{
sym_low_pc = symtab.base[j].hist.scaled_addr;
sym_high_pc = symtab.base[j + 1].hist.scaled_addr;
/* If high end of bin is below entry address,
go for next bin. */
if (bin_high_pc < sym_low_pc)
{
j++;
break;
}
/* If low end of bin is above high end of symbol,
go for next symbol. */
if (bin_low_pc >= sym_high_pc)
continue;
overlap =
MIN (bin_high_pc, sym_high_pc) - MAX (bin_low_pc, sym_low_pc);
if (overlap > 0)
{
DBG (SAMPLEDEBUG,
printf (
"[assign_samples] [0x%lx,0x%lx) %s gets %f ticks %ld overlap\n",
(unsigned long) symtab.base[j].addr,
(unsigned long) (sizeof (UNIT) * sym_high_pc),
symtab.base[j].name, overlap * count_time / hist_scale,
(long) overlap));
addr = symtab.base[j].addr;
credit = overlap * count_time / hist_scale;
/* Credit symbol if it appears in INCL_FLAT or that
table is empty and it does not appear it in
EXCL_FLAT. */
if (sym_lookup (&syms[INCL_FLAT], addr)
|| (syms[INCL_FLAT].len == 0
&& !sym_lookup (&syms[EXCL_FLAT], addr)))
{
symtab.base[j].hist.time += credit;
}
else
{
total_time -= credit;
}
}
}
}
DBG (SAMPLEDEBUG, printf ("[assign_samples] total_time %f\n",
total_time));
}
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug gprof/13993] New: gprof failed to accumulate hist time,
manjian2006 at gmail dot com <=