From: Philippe E. <ph...@us...> - 2004-01-18 02:21:20
|
Update of /cvsroot/oprofile/oprofile/pp In directory sc8-pr-cvs1:/tmp/cvs-serv25275/pp Modified Files: Makefile.am opannotate.cpp opannotate_options.cpp opgprof.cpp opgprof_options.cpp opreport.cpp opreport_options.cpp Added Files: opstack.cpp opstack_options.cpp opstack_options.h Removed Files: image_errors.cpp image_errors.h populate.cpp populate.h Log Message: merge BRANCH_CALLGRAPH to HEAD Index: Makefile.am =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/Makefile.am,v retrieving revision 1.17 retrieving revision 1.18 diff -u -p -d -r1.17 -r1.18 --- Makefile.am 30 Oct 2003 02:35:24 -0000 1.17 +++ Makefile.am 18 Jan 2004 02:21:15 -0000 1.18 @@ -9,12 +9,11 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = @OP_CXXFLAGS@ -bin_PROGRAMS = opreport opannotate opgprof +bin_PROGRAMS = opreport opannotate opgprof opstack LIBS=@POPT_LIBS@ @BFD_LIBS@ -pp_common = common_option.cpp common_option.h \ - image_errors.h image_errors.cpp +pp_common = common_option.cpp common_option.h common_libs = \ ../libpp/libpp.a \ @@ -27,15 +26,20 @@ common_libs = \ opreport_SOURCES = opreport.cpp \ opreport_options.h opreport_options.cpp \ - populate.cpp populate.h $(pp_common) + $(pp_common) opreport_LDADD = $(common_libs) opannotate_SOURCES = opannotate.cpp \ opannotate_options.h opannotate_options.cpp \ - populate.cpp populate.h $(pp_common) + $(pp_common) opannotate_LDADD = $(common_libs) opgprof_SOURCES = opgprof.cpp \ opgprof_options.h opgprof_options.cpp \ $(pp_common) opgprof_LDADD = $(common_libs) + +opstack_SOURCES = opstack.cpp \ + opstack_options.h opstack_options.cpp \ + $(pp_common) +opstack_LDADD = $(common_libs) Index: opannotate.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opannotate.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -p -d -r1.30 -r1.31 --- opannotate.cpp 13 Nov 2003 15:22:58 -0000 1.30 +++ opannotate.cpp 18 Jan 2004 02:21:15 -0000 1.31 @@ -665,7 +665,8 @@ int opannotate(vector<string> const & no bool debug_info = false; for (; it != end; ++it) { - debug_info |= populate_for_image(*samples, *it); + debug_info |= populate_for_image(*samples, *it, + options::symbol_filter); images.push_back(it->image); } Index: opannotate_options.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opannotate_options.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -p -d -r1.14 -r1.15 --- opannotate_options.cpp 1 Jan 2004 19:39:36 -0000 1.14 +++ opannotate_options.cpp 18 Jan 2004 02:21:15 -0000 1.15 @@ -108,7 +108,7 @@ void handle_options(vector<string> const profile_spec const spec = profile_spec::create(non_options, options::extra_found_images); - list<string> sample_files = spec.generate_file_list(exclude_dependent); + list<string> sample_files = spec.generate_file_list(exclude_dependent, true); cverb << "Matched sample files: " << sample_files.size() << endl; copy(sample_files.begin(), sample_files.end(), @@ -122,6 +122,8 @@ void handle_options(vector<string> const classes = arrange_profiles(sample_files, merge_by); + cverb << "profile_classes:\n" << classes << endl; + if (classes.v.empty()) { cerr << "error: no sample files found: profile specification " "too strict ?" << endl; Index: opgprof.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opgprof.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -p -d -r1.16 -r1.17 --- opgprof.cpp 3 Nov 2003 23:48:50 -0000 1.16 +++ opgprof.cpp 18 Jan 2004 02:21:15 -0000 1.17 @@ -22,6 +22,7 @@ #include "image_errors.h" #include "opgprof_options.h" #include "cverb.h" +#include "op_file.h" using namespace std; @@ -29,6 +30,7 @@ namespace { #define GMON_VERSION 1 #define GMON_TAG_TIME_HIST 0 +#define GMON_TAG_CG_ARC 1 struct gmon_hdr { char cookie[4]; @@ -101,8 +103,27 @@ bool aligned_samples(profile_container c } -void output_gprof(profile_container const & samples, - string gmon_filename, op_bfd const & abfd) +void output_cg(FILE * fp, op_bfd const & abfd, profile_t const & cg_db) +{ + bfd_vma offset = abfd.get_start_offset(); + if (!cg_db.get_header().is_kernel) + offset = 0; + + profile_t::iterator_pair p_it = cg_db.samples_range(); + for (; p_it.first != p_it.second; ++p_it.first) { + bfd_vma from = p_it.first.vma() >> 32; + bfd_vma to = p_it.first.vma() & 0xffffffff; + + 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)); + op_write_u32(fp, p_it.first.count()); + } +} + + +void output_gprof(op_bfd const & abfd, profile_container const & samples, + profile_t const & cg_db, string const & gmon_filename) { static gmon_hdr hdr = { { 'g', 'm', 'o', 'n' }, GMON_VERSION, {0,0,0,},}; @@ -131,6 +152,11 @@ void output_gprof(profile_container cons size_t histsize = (high_pc - low_pc) / multiplier; + // FIXME: must we skip the flat profile write if histsize == 0 ? + // (this can occur with callgraph w/o samples to the binary) but in + // this case user must gprof --no-flat-profile whiwh is a bit boring + // and result *seems* weirds. + FILE * fp = op_open_file(gmon_filename.c_str(), "w"); op_write_file(fp,&hdr, sizeof(gmon_hdr)); @@ -164,7 +190,7 @@ void output_gprof(profile_container cons if (pos >= histsize) { cerr << "Bogus histogram bin " << pos - << ", larger than " << pos << " !\n"; + << ", larger than " << pos << " !\n"; continue; } @@ -179,23 +205,32 @@ void output_gprof(profile_container cons } op_write_file(fp, hist, histsize * sizeof(u16)); + + if (!cg_db.empty()) + output_cg(fp, abfd, cg_db); + op_close_file(fp); free(hist); } -void load_samples(op_bfd const & abfd, list<string> const & files, +void +load_samples(op_bfd const & abfd, list<profile_sample_files> const & files, string const & image, profile_container & samples) { - list<string>::const_iterator it = files.begin(); - list<string>::const_iterator const end = files.end(); + list<profile_sample_files>::const_iterator it = files.begin(); + list<profile_sample_files>::const_iterator const end = files.end(); for (; it != end; ++it) { + // we can get call graph w/o any samples to the binary + if (it->sample_filename.empty()) + continue; profile_t profile; - profile.add_sample_file(*it, abfd.get_start_offset()); + profile.add_sample_file(it->sample_filename, + abfd.get_start_offset()); check_mtime(abfd.get_filename(), profile.get_header()); @@ -204,6 +239,27 @@ void load_samples(op_bfd const & abfd, l } +void load_cg(profile_t & cg_db, list<profile_sample_files> const & files) +{ + list<profile_sample_files>::const_iterator it = files.begin(); + list<profile_sample_files>::const_iterator const end = files.end(); + + /* the list of non cg files is a super set of the list of cg file + * (module always log a samples to non-cg files before logging + * call stack) so by using the list of non-cg file we are sure to get + * all existing cg files. + */ + for (; it != end; ++it) { + list<string>::const_iterator cit; + list<string>::const_iterator const cend = it->cg_files.end(); + for (cit = it->cg_files.begin(); cit != cend; ++cit) { + // FIXME: do we need filtering ? + cg_db.add_sample_file(*cit, 0); + } + } +} + + int opgprof(vector<string> const & non_options) { handle_options(non_options); @@ -224,7 +280,11 @@ int opgprof(vector<string> const & non_o load_samples(abfd, image_profile.groups[0].begin()->files, image_profile.image, samples); - output_gprof(samples, options::gmon_filename, abfd); + profile_t cg_db; + + load_cg(cg_db, image_profile.groups[0].begin()->files); + + output_gprof(abfd, samples, cg_db, options::gmon_filename); return 0; } Index: opgprof_options.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opgprof_options.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -p -d -r1.12 -r1.13 --- opgprof_options.cpp 2 Jan 2004 13:40:18 -0000 1.12 +++ opgprof_options.cpp 18 Jan 2004 02:21:15 -0000 1.13 @@ -43,7 +43,7 @@ popt::option options_array[] = { bool try_merge_profiles(profile_spec const & spec, bool exclude_dependent) { - list<string> sample_files = spec.generate_file_list(exclude_dependent); + list<string> sample_files = spec.generate_file_list(exclude_dependent, false); cverb << "Matched sample files: " << sample_files.size() << endl; copy(sample_files.begin(), sample_files.end(), @@ -60,6 +60,8 @@ bool try_merge_profiles(profile_spec con profile_classes classes = arrange_profiles(sample_files, merge_by); + cverb << "profile_classes:\n" << classes << endl; + size_t nr_classes = classes.v.size(); list<inverted_profile> iprofiles Index: opreport.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opreport.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -u -p -d -r1.43 -r1.44 --- opreport.cpp 1 Nov 2003 23:32:09 -0000 1.43 +++ opreport.cpp 18 Jan 2004 02:21:15 -0000 1.44 @@ -47,21 +47,29 @@ struct summary { } /// add a set of files to a summary - size_t add_files(list<string> const & files, size_t pclass); + size_t add_files(list<profile_sample_files> const & files, + size_t pclass); }; -size_t summary::add_files(list<string> const & files, size_t pclass) +size_t summary:: +add_files(list<profile_sample_files> const & files, size_t pclass) { size_t subtotal = 0; - list<string>::const_iterator it = files.begin(); - list<string>::const_iterator const end = files.end(); + 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); + size_t count = profile_t::sample_count(it->sample_filename); counts[pclass] += count; subtotal += count; + + // FIXME: is it worth (for now yes I expect bugs ...) + if (!it->cg_files.empty()) { + throw "opreport.cpp::add_files(): unxpected non empty " + "cg file set\n"; + } } return subtotal; @@ -415,7 +423,7 @@ int opreport(vector<string> const & non_ list<inverted_profile>::iterator const end = iprofiles.end(); for (; it != end; ++it) - populate_for_image(samples, *it); + populate_for_image(samples, *it, options::symbol_filter); output_header(); Index: opreport_options.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opreport_options.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -p -d -r1.17 -r1.18 --- opreport_options.cpp 3 Nov 2003 23:48:50 -0000 1.17 +++ opreport_options.cpp 18 Jan 2004 02:21:15 -0000 1.18 @@ -197,7 +197,7 @@ void handle_options(vector<string> const profile_spec const spec = profile_spec::create(non_options, extra_found_images); - list<string> sample_files = spec.generate_file_list(exclude_dependent); + list<string> sample_files = spec.generate_file_list(exclude_dependent, true); cverb << "Matched sample files: " << sample_files.size() << endl; copy(sample_files.begin(), sample_files.end(), @@ -205,6 +205,8 @@ void handle_options(vector<string> const classes = arrange_profiles(sample_files, merge_by); + cverb << "profile_classes:\n" << classes << endl; + if (classes.v.empty()) { cerr << "error: no sample files found: profile specification " "too strict ?" << endl; --- image_errors.cpp DELETED --- --- image_errors.h DELETED --- --- populate.cpp DELETED --- --- populate.h DELETED --- |