From: Roland McGrath Date: Wed, 1 Dec 2010 01:16:09 +0000 (-0800) Subject: Remove directory_table/include_directories as distinct item from line_info_table. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b0a30dcc30135b85bcf216b1b7d239a4e34123a3;p=thirdparty%2Felfutils.git Remove directory_table/include_directories as distinct item from line_info_table. --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index e0d844343..e1b440f37 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,20 @@ +2010-11-30 Roland McGrath + + * c++/dwarf (dwarf::directory_table): Remove class. + (dwarf::compile_unit::include_directories): Remove method. + (dwarf::line_info_table::include_directories): Remove method. + (dwarf::line_info_table::operator==): Don't use it. + * c++/dwarf_data (dwarf_data::directory_table): Remove class. + (dwarf_data::compile_unit::include_directories): Remove method. + (dwarf_data::line_info_table::include_directories): Remove method. + (dwarf_data::line_info_table::hasher): Replace. + (dwarf_data::line_info_table::operator==): Don't use it. + * c++/dwarf_output (dwarf_output::directory_table): Remove class. + * c++/values.cc (line_info_string): Ignore include_directories. + (dwarf::directory_table): Remove methods. + * c++/line_info.cc (dwarf::directory_table): Remove methods. + * c++/edit-values.cc (dwarf_data::line_table): Update instantiation. + 2010-10-13 Roland McGrath * dwarf.h: Add DW_LANG_Go. diff --git a/libdw/c++/dwarf b/libdw/c++/dwarf index 4ab57ce8f..0c24bb3d2 100644 --- a/libdw/c++/dwarf +++ b/libdw/c++/dwarf @@ -408,7 +408,6 @@ namespace elfutils class range_list; class ranges; class line_info_table; - class directory_table; class file_table; class line_table; class line_entry; @@ -1034,10 +1033,6 @@ namespace elfutils const line_info_table line_info () const; // Convenience methods for line_info_table sub-containers. - inline const directory_table include_directories () const - { - return line_info ().include_directories (); - } inline const file_table files () const { return line_info ().files (); @@ -1601,67 +1596,6 @@ namespace elfutils */ }; - // This describes a CU's directory table, a simple array of strings. - class directory_table - { - private: - ::Dwarf_Files *_m_files; - - template - inline bool table_equal (const table &other) const - { - /* We ignore the first element, the compilation directory. - This is not encoded in the .debug_line table, but in - the DW_AT_comp_dir attribute of the referring CU. - The directory table itself matches regardless. */ - const_iterator i = begin (); - typename table::const_iterator j = other.begin (); - return subr::container_equal - (++i, end (), ++j, other.end (), - subr::deref > ()); - } - - public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef const char *value_type; - - inline directory_table (::Dwarf_Files *const files) - : _m_files (files) {} - inline directory_table (const directory_table &t) - : _m_files (t._m_files) {} - - std::string to_string () const; - - typedef const char *const *const_iterator; - - inline bool empty () const - { - return size () == 0; - } - - size_t size () const; - const_iterator begin () const; - const_iterator end () const; - - template - inline bool operator== (const table &other) const - { - return table_equal (other); - } - template - inline bool operator!= (const table &other) const - { - return !(*this == other); - } - // Short-circuit for comparing to self. - inline bool operator== (const directory_table &other) const - { - return _m_files == other._m_files || table_equal (other); - } - }; - /* This describes a CU's file table. It works like a read-only std::vector, and also supports lookup by name. */ class file_table @@ -1887,10 +1821,6 @@ namespace elfutils std::string to_string () const; - inline const directory_table include_directories () const - { - return directory_table (_m_files); - } inline const file_table files () const { return file_table (_m_files); @@ -1900,8 +1830,7 @@ namespace elfutils template inline bool operator== (const table &other) const { - return (include_directories () == other.include_directories () - && lines () == other.lines ()); + return lines () == other.lines (); } template inline bool operator!= (const table &other) const diff --git a/libdw/c++/dwarf_data b/libdw/c++/dwarf_data index ebf5b0e4d..2e8f06131 100644 --- a/libdw/c++/dwarf_data +++ b/libdw/c++/dwarf_data @@ -157,11 +157,6 @@ namespace elfutils } // Convenience methods for line_info_table sub-containers. - inline const typename impl::directory_table &include_directories () const - { - return line_info ().include_directories (); - } - inline const typename impl::line_table &lines () const { return line_info ().lines (); @@ -173,11 +168,6 @@ namespace elfutils return this->attributes ()[::DW_AT_stmt_list].line_info (); } - inline typename impl::directory_table &include_directories () - { - return line_info ().include_directories (); - } - inline typename impl::line_table &lines () { return line_info ().lines (); @@ -298,46 +288,6 @@ namespace elfutils } }; - // This describes a CU's directory table, a simple array of strings. - class directory_table : public std::vector - { - private: - typedef std::vector _base; - - public: - struct hasher : public subr::container_hasher {}; - - directory_table () {} - - template - directory_table (const table &other) - { - /* The first entry is "special". It can be NULL/empty. - This is not encoded in the .debug_line table, but in - the DW_AT_comp_dir attribute of the referring CU. */ - typename table::const_iterator first = other.begin (); - _base::push_back (*first ?: ""); - _base::insert (_base::end (), ++first, other.end ()); - } - - std::string to_string () const; - - template - inline bool operator== (const table &other) const - { - /* We ignore the first element, the compilation directory. - This is actually part of the CU, not part of the line info. - The directory table itself matches regardless. */ - return (size () == other.size () - && subr::container_tail_equal (*this, other, 1)); - } - template - inline bool operator!= (const table &other) const - { - return !(*this == other); - } - }; - private: /* This is the common base class for all line_entry instantiations. @@ -550,58 +500,52 @@ namespace elfutils const_iterator find (::Dwarf_Addr) const; }; - /* This holds the entirety of line information. It's parameterized - by the directory_table and line_table representations. */ - template + /* This holds the entirety of line information. + The line_table is all there actually is. */ + template class line_info_table - : private std::pair { private: - typedef std::pair _base; + line_table _m_lines; public: - friend class subr::base_hasher; - typedef subr::base_hasher hasher; + struct hasher : public std::unary_function + { + inline size_t operator () (const line_info_table &info) const + { + return subr::hash_this (info._m_lines); + } + }; - inline line_info_table () : _base () {} + inline line_info_table () {} template inline line_info_table (const table &other) - : _base (other.include_directories (), other.lines ()) + : _m_lines (other.lines ()) {} template inline line_info_table &operator= (const table &other) { - this->first = directory_table (other.include_directories ()); - this->second = line_table (other.lines ()); + _m_lines = line_table (other.lines ()); return *this; } std::string to_string () const; - inline directory_table &include_directories () - { - return this->first; - } - inline const directory_table &include_directories () const - { - return this->first; - } inline line_table &lines () { - return this->second; + return _m_lines; } inline const line_table &lines () const { - return this->second; + return _m_lines; } template inline bool operator== (const table &other) const { - return (include_directories () == other.include_directories () - && lines () == other.lines ()); + return lines () == other.lines (); } template inline bool operator!= (const table &other) const diff --git a/libdw/c++/dwarf_edit b/libdw/c++/dwarf_edit index 19e5493f1..fd41100c9 100644 --- a/libdw/c++/dwarf_edit +++ b/libdw/c++/dwarf_edit @@ -95,11 +95,9 @@ namespace elfutils public: typedef dwarf_data::source_file source_file; - typedef dwarf_data::directory_table directory_table; typedef dwarf_data::line_entry line_entry; typedef dwarf_data::line_table line_table; - typedef dwarf_data::line_info_table line_info_table; + typedef dwarf_data::line_info_table line_info_table; typedef dwarf_data::dwarf_enum dwarf_enum; typedef dwarf_data::range_list range_list; typedef dwarf_data::location_attr location_attr; @@ -390,8 +388,7 @@ namespace elfutils // Explicit instantiations. extern template class dwarf_data::line_entry; extern template class dwarf_data::line_table; - extern template class dwarf_data::line_info_table; + extern template class dwarf_data::line_info_table; extern template class dwarf_data::attr_value; extern template class dwarf_data::value; diff --git a/libdw/c++/dwarf_output b/libdw/c++/dwarf_output index 86e59a2ed..b7bbaadc9 100644 --- a/libdw/c++/dwarf_output +++ b/libdw/c++/dwarf_output @@ -87,11 +87,9 @@ namespace elfutils public: typedef dwarf_data::source_file source_file; - typedef dwarf_data::directory_table directory_table; typedef dwarf_data::line_entry line_entry; typedef dwarf_data::line_table line_table; - typedef dwarf_data::line_info_table line_info_table; + typedef dwarf_data::line_info_table line_info_table; typedef dwarf_data::dwarf_enum dwarf_enum; typedef dwarf_data::range_list range_list; typedef dwarf_data::location_attr location_attr; diff --git a/libdw/c++/edit-values.cc b/libdw/c++/edit-values.cc index 976d315e8..7c17b2bf4 100644 --- a/libdw/c++/edit-values.cc +++ b/libdw/c++/edit-values.cc @@ -1,5 +1,5 @@ /* elfutils::dwarf_edit attribute value interfaces. - Copyright (C) 2009 Red Hat, Inc. + Copyright (C) 2009-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -56,8 +56,7 @@ using namespace elfutils; // Explicit instantiations. template class dwarf_data::line_entry; template class dwarf_data::line_table; -template class dwarf_data::line_info_table; +template class dwarf_data::line_info_table; template class dwarf_data::attr_value; template class dwarf_data::value; diff --git a/libdw/c++/line_info.cc b/libdw/c++/line_info.cc index 83e625109..e613c16bf 100644 --- a/libdw/c++/line_info.cc +++ b/libdw/c++/line_info.cc @@ -171,33 +171,6 @@ dwarf::source_file::to_string () const return os.str (); } -// dwarf::directory_table - -size_t -dwarf::directory_table::size () const -{ - return _m_files->ndirs; -} - -static inline dwarf::directory_table::const_iterator -directory_table_array (Dwarf_Files *files) -{ - // See dwarf_getsrcdirs. - return reinterpret_cast (&files->info[files->nfiles]); -} - -dwarf::directory_table::const_iterator -dwarf::directory_table::begin () const -{ - return directory_table_array (_m_files); -} - -dwarf::directory_table::const_iterator -dwarf::directory_table::end () const -{ - return directory_table_array (_m_files) + _m_files->ndirs; -} - // dwarf::file_table size_t diff --git a/libdw/c++/values.cc b/libdw/c++/values.cc index 851abf689..f255d7943 100644 --- a/libdw/c++/values.cc +++ b/libdw/c++/values.cc @@ -663,8 +663,7 @@ template static inline std::string line_info_string (const line_info_table *table) { - return ("[" + table->include_directories ().to_string () - + ", " + table->lines ().to_string () + "]"); + return ("[" + table->lines ().to_string () + "]"); } std::string @@ -684,26 +683,6 @@ namespace elfutils }; -// dwarf::directory_table - -static std::string -dirtable_string (size_t ndirs) -{ - return dec_string (ndirs, "{", " dirs}"); -} - -std::string -dwarf::directory_table::to_string () const -{ - return dirtable_string (_m_files->ndirs); -} - -std::string -dwarf_data::directory_table::to_string () const -{ - return dirtable_string (size ()); -} - // dwarf::line_table std::string