Update of /cvsroot/oprofile/oprofile/libutil++ In directory sc8-pr-cvs1:/tmp/cvs-serv16495/libutil++ Modified Files: Tag: BRANCH_CALLGRAPH file_manip.cpp file_manip.h op_bfd.cpp op_bfd.h string_manip.cpp string_manip.h Log Message: merge from HEAD Index: file_manip.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/libutil++/file_manip.cpp,v retrieving revision 1.18 retrieving revision 1.18.2.1 diff -u -p -d -r1.18 -r1.18.2.1 --- file_manip.cpp 29 May 2003 01:10:08 -0000 1.18 +++ file_manip.cpp 23 Aug 2003 16:47:10 -0000 1.18.2.1 @@ -27,6 +27,15 @@ using namespace std; + +bool is_directory(string const & dirname) +{ + struct stat st; + + return !stat(dirname.c_str(), &st) && S_ISDIR(st.st_mode); +} + + /** * is_file_identical - check for identical files * @param file1 first filename Index: file_manip.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/libutil++/file_manip.h,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -u -p -d -r1.13 -r1.13.2.1 --- file_manip.h 29 May 2003 01:10:08 -0000 1.13 +++ file_manip.h 23 Aug 2003 16:47:10 -0000 1.13.2.1 @@ -15,6 +15,10 @@ #include <string> #include <list> + +/// return true if dir is an existing directory +bool is_directory(std::string const & dirname); + /// return true if the two files are the same file bool is_files_identical(std::string const & file1, std::string const & file2); /// return the contents of a symbolic link or an empty string on failure Index: op_bfd.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/libutil++/op_bfd.cpp,v retrieving revision 1.24.2.6 retrieving revision 1.24.2.7 diff -u -p -d -r1.24.2.6 -r1.24.2.7 --- op_bfd.cpp 11 Aug 2003 21:18:40 -0000 1.24.2.6 +++ op_bfd.cpp 23 Aug 2003 16:47:10 -0000 1.24.2.7 @@ -150,11 +150,11 @@ bool interesting_symbol(asymbol * sym) if (sym->name[0] == '.' && sym->name[1] == 'L') return false; - // This is still necessary because the symbol - // sits at the same VMA as a real function, - // so we can end up dropping the real function - // symbol when we remove duplicate VMAs in our - // caller. + /* This case cannot be moved to boring_symbol(), + * because that's only used for duplicate VMAs, + * and sometimes this symbol appears at an address + * different from all other symbols. + */ if (!strcmp("gcc2_compiled.", sym->name)) return false; @@ -237,8 +237,6 @@ void op_bfd::get_symbols(op_bfd::symbols // we need to ensure than for a given vma only one symbol exist else // we read more than one time some samples. Fix #526098 - // ELF symbols size : potential bogosity here because when using - // elf symbol size we need to check than two symbols does not overlap. for (; it != symbols.end();) { symbols_found_t::iterator temp = it; ++temp; @@ -433,63 +431,13 @@ bool op_bfd::get_linenr(symbol_index_t s } -// #define USE_ELF_INTERNAL - -#ifdef USE_ELF_INTERNAL -struct elf_internal_sym { - bfd_vma st_value; /* Value of the symbol */ - bfd_vma st_size; /* Associated symbol size */ - unsigned long st_name; /* Symbol name, index in string tbl */ - unsigned char st_info; /* Type and binding attributes */ - unsigned char st_other; /* No defined meaning, 0 */ - unsigned short st_shndx; /* Associated section index */ -}; - -typedef struct elf_internal_sym Elf_Internal_Sym; - -typedef struct -{ - /* The BFD symbol. */ - asymbol symbol; - /* ELF symbol information. */ - Elf_Internal_Sym internal_elf_sym; -} elf_symbol_type; - -#endif /* USE_ELF_INTERNAL */ - size_t op_bfd::symbol_size(op_bfd_symbol const & sym, op_bfd_symbol const * next) const { u32 start = sym.filepos(); - size_t length; - -#ifndef USE_ELF_INTERNAL - u32 end; - if (next) { - end = next->filepos(); - } else - end = file_size; - - length = end - start; -#else /* !USE_ELF_INTERNAL */ - size_t length = - ((elf_symbol_type *)sym)->internal_elf_sym.st_size; - - // some asm symbol can have a zero length such system_call - // entry point in vmlinux. Calculate the length from the next - // symbol vma - if (length == 0) { - u32 next_offset = start; - if (next) { - next_offset = next->filepos(); - } else { - next_offset = file_size; - } - length = next_offset - start; - } -#endif /* USE_ELF_INTERNAL */ + u32 end = next ? next->filepos() : file_size; - return length; + return end - start; } Index: op_bfd.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/libutil++/op_bfd.h,v retrieving revision 1.18.2.2 retrieving revision 1.18.2.3 diff -u -p -d -r1.18.2.2 -r1.18.2.3 --- op_bfd.h 3 Aug 2003 19:22:01 -0000 1.18.2.2 +++ op_bfd.h 23 Aug 2003 16:47:10 -0000 1.18.2.3 @@ -28,7 +28,6 @@ class string_filter; /// all symbol vector indexing uses this type typedef size_t symbol_index_t; -symbol_index_t const nil_symbol_index = symbol_index_t(-1); /** * A symbol description from a bfd point of view. This duplicate Index: string_manip.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/libutil++/string_manip.cpp,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -u -p -d -r1.22 -r1.22.2.1 --- string_manip.cpp 8 Jun 2003 05:08:37 -0000 1.22 +++ string_manip.cpp 23 Aug 2003 16:47:10 -0000 1.22.2.1 @@ -18,17 +18,6 @@ using namespace std; -string erase_from_last_of(string const & str, char ch) -{ - string result = str; - - string::size_type pos = result.find_last_of(ch); - if (pos != string::npos) - result.erase(pos, result.length() - pos); - - return result; -} - string erase_to_last_of(string const & str, char ch) { @@ -114,23 +103,17 @@ void separate_token(vector<string> & res string ltrim(string const & str, string const & totrim) { - string result; - string::size_type pos = str.find_first_not_of(totrim); - if (pos != string::npos) { - result = str.substr(pos); - } - return result; + string result(str); + + return result.erase(0, result.find_first_not_of(totrim)); } string rtrim(string const & str, string const & totrim) { string result(str); - string::size_type pos = str.find_last_not_of(totrim); - if (pos != string::npos) { - result = str.substr(0, pos + 1); - } - return result; + + return result.erase(result.find_last_not_of(totrim) + 1); } Index: string_manip.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/libutil++/string_manip.h,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -p -d -r1.17 -r1.17.2.1 --- string_manip.h 29 May 2003 01:10:09 -0000 1.17 +++ string_manip.h 23 Aug 2003 16:47:10 -0000 1.17.2.1 @@ -19,15 +19,6 @@ /** * @param str string - * @param ch the char from where we erase character - * - * erase char from the last occurence of ch to the end of str and return - * the string - */ -std::string erase_from_last_of(std::string const & str, char ch); - -/** - * @param str string * @param ch the characterto search * * erase char from the begin of str to the last |