From: Philippe E. <ph...@us...> - 2003-08-26 06:45:03
|
Update of /cvsroot/oprofile/oprofile/pp In directory sc8-pr-cvs1:/tmp/cvs-serv7721/pp Modified Files: opannotate.cpp opannotate_options.cpp opannotate_options.h opreport_options.cpp Log Message: opannotate: enable multiple events Index: opannotate.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opannotate.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -p -d -r1.18 -r1.19 --- opannotate.cpp 16 Aug 2003 19:54:46 -0000 1.18 +++ opannotate.cpp 25 Aug 2003 13:01:36 -0000 1.19 @@ -35,10 +35,12 @@ using namespace options; namespace { +size_t nr_events; + scoped_ptr<profile_container> samples; // needed to display samples file information -scoped_ptr<opd_header> header; +vector<opd_header> header; /// how opannotate was invoked string cmdline; @@ -89,12 +91,14 @@ image_set populate_samples(profile_conta } -void save_sample_file_header(partition_files const & files) +void save_sample_file_header(vector<partition_files> const & files) { - if (files.nr_set()) { - partition_files::filename_set const & file_set = files.set(0); - opd_header temp = read_header(file_set.begin()->sample_filename); - header.reset(new opd_header(temp)); + for (size_t i = 0; i < files.size(); ++i) { + partition_files::filename_set const & file_set = + files[i].set(0); + opd_header temp = + read_header(file_set.begin()->sample_filename); + header.push_back(temp); } } @@ -103,9 +107,16 @@ string get_annotation_fill() { string str; - str += string(count_width, ' ') + ' '; - str += string(percent_width, ' '); + for (size_t i = 0; i < nr_events; ++i) { + str += string(count_width, ' ') + ' '; + str += string(percent_width, ' '); + } + + for (size_t i = 1; i < nr_events; ++i) { + str += " "; + } + str += " :"; return str; } @@ -162,8 +173,9 @@ void output_info(ostream & out) stringstream stream; - output_cpu_info(stream, *header); - stream << *header; + output_cpu_info(stream, header[0]); + for (size_t i = 0; i < header.size(); ++i) + stream << header[i]; stream.seekp(0); string line; @@ -179,11 +191,12 @@ string count_str(count_array_t const & c count_array_t const & total) { ostringstream os; - os << setw(count_width) << count[0] << ' '; + for (size_t i = 0; i < nr_events; ++i) { + os << setw(count_width) << count[i] << ' '; - // FIXME: multiple counts - os << format_double(op_ratio(count[0], total[0]) * 100.0, - percent_int_width, percent_fract_width); + os << format_double(op_ratio(count[i], total[i]) * 100.0, + percent_int_width, percent_fract_width); + } return os.str(); } @@ -201,13 +214,15 @@ string asm_line_annotation(symbol_entry string str; sample_entry const * sample = samples->find_sample(last_symbol, vma); - if (sample) + if (sample) { str += count_str(sample->counts, samples->samples_count()); - - if (str.empty()) + for (size_t i = 1; i < nr_events; ++i) + str += " "; + str += " :"; + } else { str = annotation_fill; + } - str += " :"; return str; } @@ -264,7 +279,7 @@ symbol_entry const * output_objdump_asm_ if (pos == str.length() || !isxdigit(str[pos])) { if (do_output) { - cout << annotation_fill << " :" << str << '\n'; + cout << annotation_fill << str << '\n'; return last_symbol; } } @@ -274,7 +289,7 @@ symbol_entry const * output_objdump_asm_ if (pos == str.length() || (!isspace(str[pos]) && str[pos] != ':')) { if (do_output) { - cout << annotation_fill << " :" << str << '\n'; + cout << annotation_fill << str << '\n'; return last_symbol; } } @@ -425,13 +440,15 @@ string const source_line_annotation(debu string str; count_array_t counts = samples->samples_count(filename, linenr); - if (!counts.zero()) + if (!counts.zero()) { str += count_str(counts, samples->samples_count()); - - if (str.empty()) + for (size_t i = 1; i < nr_events; ++i) + str += " "; + str += " :"; + } else { str = annotation_fill; + } - str += " :"; return str; } @@ -620,7 +637,7 @@ void output_source(path_filter const & f } -bool annotate_source(image_set const & images) +bool annotate_source(set<string> const & images) { annotation_fill = get_annotation_fill(); @@ -647,13 +664,11 @@ bool annotate_source(image_set const & i if (assembly) { bool some_output = false; - image_set::const_iterator it; - for (it = images.begin(); it != images.end(); ) { - if (output_asm(it->first)) { + set<string>::const_iterator it; + for (it = images.begin(); it != images.end(); ++it) { + if (output_asm(*it)) { some_output = true; } - - it = images.upper_bound(it->first); } if (!some_output) { @@ -674,12 +689,22 @@ int opannotate(vector<string> const & no { handle_options(non_options); + nr_events = sample_file_partition.size(); + samples.reset(new profile_container(true, true)); - save_sample_file_header(*sample_file_partition); + save_sample_file_header(sample_file_partition); + + set<string> images; + + for (size_t i = 0; i < sample_file_partition.size(); ++i) { + image_set images_set = populate_samples(*samples, + sample_file_partition[i], false, i); + image_set::const_iterator it; + for (it = images_set.begin(); it != images_set.end(); ++it) + images.insert(it->first); + } - image_set images = populate_samples(*samples, *sample_file_partition, - false, 0); annotate_source(images); return 0; Index: opannotate_options.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opannotate_options.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -p -d -r1.7 -r1.8 --- opannotate_options.cpp 4 Aug 2003 17:15:57 -0000 1.7 +++ opannotate_options.cpp 25 Aug 2003 13:01:36 -0000 1.8 @@ -22,7 +22,7 @@ using namespace std; -scoped_ptr<partition_files> sample_file_partition; +vector<partition_files> sample_file_partition; namespace options { bool demangle = true; @@ -125,16 +125,8 @@ void handle_options(vector<string> const exit(EXIT_FAILURE); } - if (unmerged_profile.size() > 1) { - // quick and dirty check for now - cerr << "Can't handle multiple counter!" << endl; - cerr << "use event:xxxx and/or count:yyyyy to restrict " - << "samples files set considered\n" << endl; - exit(EXIT_FAILURE); - } - // we always merge but this have no effect on output since at source - // or assembly point of view the result be merged anyway + // or assembly point of view the result will be merged anyway merge_option merge_by; merge_by.cpu = true; merge_by.lib = true; @@ -142,6 +134,15 @@ void handle_options(vector<string> const merge_by.tgid = true; merge_by.unitmask = true; - sample_file_partition.reset( - new partition_files(sample_files, merge_by)); + unmergeable_samplefile unmerged_samplefile = + unmerge_samplefile(sample_files, unmerged_profile); + + unmergeable_samplefile::const_iterator const cend = + unmerged_samplefile.end(); + unmergeable_samplefile::const_iterator cit = + unmerged_samplefile.begin(); + for ( ; cit != cend ; ++cit) { + sample_file_partition.push_back( + partition_files(*cit, merge_by)); + } } Index: opannotate_options.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opannotate_options.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -p -d -r1.5 -r1.6 --- opannotate_options.h 4 Aug 2003 17:15:57 -0000 1.5 +++ opannotate_options.h 25 Aug 2003 13:01:36 -0000 1.6 @@ -40,7 +40,7 @@ namespace options { * a partition of sample filename to treat, each sub-list is a list of * sample to merge. filled by handle_options() */ -extern scoped_ptr<partition_files> sample_file_partition; +extern std::vector<partition_files> sample_file_partition; /** * handle_options - process command line Index: opreport_options.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opreport_options.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -p -d -r1.6 -r1.7 --- opreport_options.cpp 11 Aug 2003 01:46:17 -0000 1.6 +++ opreport_options.cpp 25 Aug 2003 13:01:36 -0000 1.7 @@ -241,17 +241,6 @@ void handle_options(vector<string> const exit(EXIT_FAILURE); } -/* This should probably be removed now ? */ -#if 0 - if (unmerged_profile.size() > 1) { - // quick and dirty check for now - cerr << "Can't handle multiple counters." << endl; - cerr << "use event:xxxx and/or count:yyyyy to restrict " - << "samples files set considered\n" << endl; - exit(EXIT_FAILURE); - } -#endif - unmergeable_samplefile unmerged_samplefile = unmerge_samplefile(sample_files, unmerged_profile); |