From: Philippe E. <ph...@us...> - 2005-08-15 20:26:43
|
Update of /cvsroot/oprofile/oprofile/pp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30662/pp Modified Files: opgprof.cpp opreport.cpp Log Message: Fix #1256978: sum of samples count overflow Index: opgprof.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opgprof.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -p -d -r1.25 -r1.26 --- opgprof.cpp 9 Aug 2005 12:49:06 -0000 1.25 +++ opgprof.cpp 15 Aug 2005 20:26:35 -0000 1.26 @@ -118,6 +118,12 @@ void output_cg(FILE * fp, op_bfd const & op_write_u8(fp, GMON_TAG_CG_ARC); op_write_vma(fp, abfd, abfd.offset_to_pc(from + offset)); op_write_vma(fp, abfd, abfd.offset_to_pc(to + offset)); + count_type count = p_it.first.count(); + if (count != p_it.first.count()) { + cerr << "Warning: capping sample count by " + << count - ((u32)-1) << endl; + count = (u32)-1; + } op_write_u32(fp, p_it.first.count()); } } @@ -187,7 +193,7 @@ void output_gprof(op_bfd const & abfd, p sample_container::samples_iterator end = samples.end(*sit); for (; it != end ; ++it) { u32 pos = (it->second.vma - low_pc) / multiplier; - u32 count = it->second.counts[0]; + count_type count = it->second.counts[0]; if (pos >= histsize) { cerr << "Bogus histogram bin " << pos Index: opreport.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opreport.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -u -p -d -r1.55 -r1.56 --- opreport.cpp 7 Aug 2005 15:29:04 -0000 1.55 +++ opreport.cpp 15 Aug 2005 20:26:35 -0000 1.56 @@ -49,21 +49,21 @@ struct summary { } /// add a set of files to a summary - size_t add_files(list<profile_sample_files> const & files, - size_t pclass); + count_type add_files(list<profile_sample_files> const & files, + size_t pclass); }; -size_t summary:: +count_type summary:: add_files(list<profile_sample_files> const & files, size_t pclass) { - size_t subtotal = 0; + count_type subtotal = 0; list<profile_sample_files>::const_iterator it = files.begin(); list<profile_sample_files>::const_iterator const end = files.end(); for (; it != end; ++it) { - size_t count = profile_t::sample_count(it->sample_filename); + count_type count = profile_t::sample_count(it->sample_filename); counts[pclass] += count; subtotal += count; @@ -91,7 +91,7 @@ struct app_summary { vector<summary> deps; /// construct and fill in the data - size_t add_profile(profile_set const & profile, size_t pclass); + count_type add_profile(profile_set const & profile, size_t pclass); bool operator<(app_summary const & rhs) const { return options::reverse_sort @@ -120,14 +120,14 @@ summary & app_summary::find_summary(stri } -size_t app_summary::add_profile(profile_set const & profile, +count_type app_summary::add_profile(profile_set const & profile, size_t pclass) { - size_t group_total = 0; + count_type group_total = 0; // first the main image summary & summ = find_summary(profile.image); - size_t app_count = summ.add_files(profile.files, pclass); + count_type app_count = summ.add_files(profile.files, pclass); counts[pclass] += app_count; group_total += app_count; @@ -137,7 +137,7 @@ size_t app_summary::add_profile(profile_ for (; it != end; ++it) { summary & summ = find_summary(it->lib_image); - size_t lib_count = summ.add_files(it->files, pclass); + count_type lib_count = summ.add_files(it->files, pclass); counts[pclass] += lib_count; group_total += lib_count; } @@ -221,7 +221,7 @@ string get_filename(string const & filen /// Output a count and a percentage -void output_count(double total_count, size_t count) +void output_count(count_type total_count, count_type count) { cout << setw(9) << count << ' '; double ratio = op_ratio(count, total_count); @@ -301,7 +301,7 @@ output_deps(summary_container const & su cout << '\t'; for (size_t i = 0; i < nr_classes; ++i) { - double tot_count = options::global_percent + count_type tot_count = options::global_percent ? summaries.total_counts[i] : app.counts[i]; output_count(tot_count, summ.counts[i]); |