From: Philippe E. <ph...@us...> - 2003-03-19 17:53:05
|
Update of /cvsroot/oprofile/oprofile/pp In directory sc8-pr-cvs1:/tmp/cvs-serv13926/pp Modified Files: oprofpp.cpp Log Message: get_vma_range() by one error; do_dump_gprof(), it's ok now. regards, Phil Index: oprofpp.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/oprofpp.cpp,v retrieving revision 1.100 retrieving revision 1.101 diff -u -d -r1.100 -r1.101 --- oprofpp.cpp 18 Mar 2003 04:19:52 -0000 1.100 +++ oprofpp.cpp 19 Mar 2003 17:52:58 -0000 1.101 @@ -146,6 +146,9 @@ // FIXME: see do_dump_gprof() abfd.get_vma_range(low_pc, high_pc); + // round-down low_pc to ensure bin number is correct in the inner loop + low_pc = (low_pc / gap) * gap; + for (symbol_index_t i = 0; i < abfd.syms.size(); i++) { abfd.get_symbol_range(i, start, end); for (j = start; j < end; j++) { @@ -203,7 +206,12 @@ // the size of gmon.out by getting the lowest/higest vma with sample abfd.get_vma_range(low_pc, high_pc); - histsize = ((high_pc - low_pc + multiplier - 1) / multiplier) + 1; + // round-down low_pc to ensure bin number is correct in the inner loop + low_pc = (low_pc / multiplier) * multiplier; + // round-up high_pc to ensure a correct histsize calculus + high_pc = ((high_pc + multiplier - 1) / multiplier) * multiplier; + + histsize = (high_pc - low_pc) / multiplier; op_write_vma(fp, abfd, low_pc); op_write_vma(fp, abfd, high_pc); @@ -222,11 +230,9 @@ for (j = start; j < end; j++) { u32 count; u32 pos; - // we must offset by multiplier - 1 so rounding during - // division don't put samples in the previous chunk - pos = (abfd.sym_offset(i, j) + abfd.syms[i].vma() - low_pc + multiplier - 1) / multiplier; + pos = (abfd.sym_offset(i, j) + abfd.syms[i].vma() - low_pc) / multiplier; - /* opp_get_options have set ctr to one value != -1 */ + // opp_get_options have set ctr to one value != -1 count = samples_files.samples_count(sort_by_ctr, j); if (pos >= histsize) { |