From: John L. <mov...@us...> - 2003-05-16 17:52:30
|
Update of /cvsroot/oprofile/oprofile/libpp In directory sc8-pr-cvs1:/tmp/cvs-serv15383a/libpp Modified Files: Tag: pp-interface-branch format_output.cpp name_storage.cpp name_storage.h profile_container.cpp sample_container.cpp symbol_container.cpp symbol_sort.cpp Log Message: split up the name storage Index: format_output.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/libpp/Attic/format_output.cpp,v retrieving revision 1.1.2.29 retrieving revision 1.1.2.30 diff -u -p -d -r1.1.2.29 -r1.1.2.30 --- format_output.cpp 16 May 2003 17:02:01 -0000 1.1.2.29 +++ format_output.cpp 16 May 2003 17:51:54 -0000 1.1.2.30 @@ -244,16 +244,16 @@ string formatter::format_vma(field_datum string formatter::format_symb_name(field_datum const & f) { - return name_store.demangle(f.symbol.name); + return symbol_names.demangle(f.symbol.name); } namespace { -inline string const & get(name_id id, bool lf) +inline string const & get_image(name_id id, bool lf) { - return lf ? name_store.name(id) - : name_store.basename(id); + return lf ? image_names.name(id) + : image_names.basename(id); } } @@ -261,13 +261,13 @@ inline string const & get(name_id id, bo string formatter::format_image_name(field_datum const & f) { - return get(f.symbol.image_name, long_filenames); + return get_image(f.symbol.image_name, long_filenames); } string formatter::format_app_name(field_datum const & f) { - return get(f.symbol.app_name, long_filenames); + return get_image(f.symbol.app_name, long_filenames); } @@ -275,8 +275,9 @@ string formatter::format_linenr_info(fie { ostringstream out; - string const & filename = - get(f.sample.file_loc.filename, long_filenames); + string const & filename = long_filenames + ? debug_names.name(f.sample.file_loc.filename) + : debug_names.basename(f.sample.file_loc.filename); if (!filename.empty()) { out << filename << ":" << f.sample.file_loc.linenr; Index: name_storage.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/libpp/Attic/name_storage.cpp,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -p -d -r1.1.2.1 -r1.1.2.2 --- name_storage.cpp 16 May 2003 17:02:01 -0000 1.1.2.1 +++ name_storage.cpp 16 May 2003 17:51:54 -0000 1.1.2.2 @@ -22,7 +22,9 @@ int global_id = 0; } -name_storage name_store; +name_storage image_names; +name_storage debug_names; +name_storage symbol_names; name_storage::name_storage() { Index: name_storage.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/libpp/Attic/name_storage.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -p -d -r1.1.2.1 -r1.1.2.2 --- name_storage.h 16 May 2003 17:02:01 -0000 1.1.2.1 +++ name_storage.h 16 May 2003 17:51:54 -0000 1.1.2.2 @@ -65,6 +65,13 @@ private: id_map ids; }; -extern name_storage name_store; +/// for images +extern name_storage image_names; + +/// for debug filenames +extern name_storage debug_names; + +/// for symbols +extern name_storage symbol_names; #endif /* !NAME_STORAGE_H */ Index: profile_container.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/libpp/Attic/profile_container.cpp,v retrieving revision 1.1.2.31 retrieving revision 1.1.2.32 diff -u -p -d -r1.1.2.31 -r1.1.2.32 --- profile_container.cpp 16 May 2003 17:02:01 -0000 1.1.2.31 +++ profile_container.cpp 16 May 2003 17:51:54 -0000 1.1.2.32 @@ -92,7 +92,7 @@ void profile_container::add(profile_t co total_count += symb_entry.sample.count; - symb_entry.name = name_store.create(abfd.syms[i].name()); + symb_entry.name = symbol_names.create(abfd.syms[i].name()); symb_entry.sample.file_loc.linenr = 0; if (debug_info) { @@ -100,11 +100,11 @@ void profile_container::add(profile_t co abfd.get_linenr(i, start, filename, symb_entry.sample.file_loc.linenr); symb_entry.sample.file_loc.filename = - name_store.create(filename); + debug_names.create(filename); } - symb_entry.image_name = name_store.create(image_name); - symb_entry.app_name = name_store.create(app_name); + symb_entry.image_name = image_names.create(image_name); + symb_entry.app_name = image_names.create(app_name); bfd_vma base_vma = abfd.syms[i].vma(); @@ -142,7 +142,7 @@ profile_container::add_samples(profile_t abfd.get_linenr(sym_index, pos, filename, sample.file_loc.linenr); sample.file_loc.filename = - name_store.create(filename); + debug_names.create(filename); } sample.vma = (sym_index != nil_symbol_index) @@ -167,7 +167,7 @@ profile_container::select_symbols(symbol for (; it != end; ++it) { if (choice.match_image - && (name_store.name(it->image_name) != choice.image_name)) + && (image_names.name(it->image_name) != choice.image_name)) continue; double const percent = @@ -177,8 +177,8 @@ profile_container::select_symbols(symbol result.push_back(&*it); if (app_name.empty()) { - app_name = name_store.name(it->app_name); - } else if (app_name != name_store.name(it->app_name)) { + app_name = image_names.name(it->app_name); + } else if (app_name != image_names.name(it->app_name)) { choice.hints = column_flags( choice.hints | cf_multiple_apps); } @@ -216,7 +216,7 @@ vector<string> const profile_container:: for (; sit != send; ++sit) { string const & file = - name_store.name(sit->second.file_loc.filename); + debug_names.name(sit->second.file_loc.filename); filename_set.insert(file); } Index: sample_container.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/libpp/Attic/sample_container.cpp,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -p -d -r1.1.2.6 -r1.1.2.7 --- sample_container.cpp 16 May 2003 17:02:01 -0000 1.1.2.6 +++ sample_container.cpp 16 May 2003 17:51:54 -0000 1.1.2.7 @@ -81,7 +81,7 @@ sample_container::accumulate_samples(str sample_entry lower, upper; - name_id const id = name_store.create(filename); + name_id const id = debug_names.create(filename); lower.file_loc.filename = upper.file_loc.filename = id; lower.file_loc.linenr = 0; @@ -116,7 +116,7 @@ sample_container::accumulate_samples(str sample_entry sample; - sample.file_loc.filename = name_store.create(filename); + sample.file_loc.filename = debug_names.create(filename); sample.file_loc.linenr = linenr; typedef pair<samples_by_loc_t::const_iterator, Index: symbol_container.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/libpp/Attic/symbol_container.cpp,v retrieving revision 1.1.2.14 retrieving revision 1.1.2.15 diff -u -p -d -r1.1.2.14 -r1.1.2.15 --- symbol_container.cpp 16 May 2003 17:02:01 -0000 1.1.2.14 +++ symbol_container.cpp 16 May 2003 17:51:54 -0000 1.1.2.15 @@ -45,7 +45,7 @@ symbol_container::find(string const & fi build_by_loc(); symbol_entry symbol; - symbol.sample.file_loc.filename = name_store.create(filename); + symbol.sample.file_loc.filename = debug_names.create(filename); symbol.sample.file_loc.linenr = linenr; symbols_by_loc_t::const_iterator it = symbols_by_loc.find(&symbol); @@ -65,7 +65,7 @@ symbol_collection const symbol_container symbols_t::const_iterator end = symbols.end(); for (; cit != end; ++cit) { - if (name_store.name(cit->name) == name) + if (symbol_names.name(cit->name) == name) v.push_back(&*cit); } @@ -92,7 +92,7 @@ symbol_entry const * symbol_container::f symbols_t::const_iterator it; for (it = symbols.begin(); it != symbols.end(); ++it) { if (it->sample.vma == vma && - name_store.name(it->image_name) == image_name) + image_names.name(it->image_name) == image_name) return &*it; } Index: symbol_sort.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/libpp/Attic/symbol_sort.cpp,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -p -d -r1.1.2.9 -r1.1.2.10 --- symbol_sort.cpp 16 May 2003 17:02:02 -0000 1.1.2.9 +++ symbol_sort.cpp 16 May 2003 17:51:54 -0000 1.1.2.10 @@ -23,11 +23,19 @@ namespace { bool long_filenames; -inline string const & get(name_id id) +int image_compare(name_id l, name_id r) { if (long_filenames) - return name_store.name(id); - return name_store.basename(id); + return image_names.name(l).compare(image_names.name(r)); + return image_names.basename(l).compare(image_names.basename(r)); +} + + +int debug_compare(name_id l, name_id r) +{ + if (long_filenames) + return debug_names.name(l).compare(debug_names.name(r)); + return debug_names.basename(l).compare(debug_names.basename(r)); } @@ -41,30 +49,35 @@ int compare_by(sort_options::sort_order if (lhs->sample.count > rhs->sample.count) return -1; return 0; + case sort_options::symbol: - return name_store.demangle(lhs->name).compare( - name_store.demangle(rhs->name)); - case sort_options::image: { - return get(lhs->image_name).compare( - get(rhs->image_name)); - } + return symbol_names.demangle(lhs->name).compare( + symbol_names.demangle(rhs->name)); + + case sort_options::image: + return debug_compare(lhs->image_name, rhs->image_name); + case sort_options::vma: if (lhs->sample.vma < rhs->sample.vma) return -1; if (lhs->sample.vma > rhs->sample.vma) return 1; return 0; + case sort_options::debug: { file_location const & f1 = lhs->sample.file_loc; file_location const & f2 = rhs->sample.file_loc; - int ret = get(f1.filename).compare(get(f2.filename)); + int ret = debug_compare(f1.filename, f2.filename); if (ret == 0) ret = f1.linenr - f2.linenr; + return ret; } - default: + + default: { cerr << "compare_by(): unknown sort option: " << order << endl; exit(EXIT_FAILURE); + } } return false; |