+2010-11-30 Roland McGrath <roland@redhat.com>
+
+ * 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 <roland@redhat.com>
* dwarf.h: Add DW_LANG_Go.
class range_list;
class ranges;
class line_info_table;
- class directory_table;
class file_table;
class line_table;
class line_entry;
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 ();
*/
};
- // This describes a CU's directory table, a simple array of strings.
- class directory_table
- {
- private:
- ::Dwarf_Files *_m_files;
-
- template<typename table>
- 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<directory_table, table,
- subr::name_equal<typename table::value_type> > ());
- }
-
- 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<typename table>
- inline bool operator== (const table &other) const
- {
- return table_equal (other);
- }
- template<typename table>
- 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<source_file>, and also supports lookup by name. */
class file_table
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);
template<typename table>
inline bool operator== (const table &other) const
{
- return (include_directories () == other.include_directories ()
- && lines () == other.lines ());
+ return lines () == other.lines ();
}
template<typename table>
inline bool operator!= (const table &other) const
}
// 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 ();
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 ();
}
};
- // This describes a CU's directory table, a simple array of strings.
- class directory_table : public std::vector<std::string>
- {
- private:
- typedef std::vector<std::string> _base;
-
- public:
- struct hasher : public subr::container_hasher<directory_table> {};
-
- directory_table () {}
-
- template<typename table>
- 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<typename table>
- 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<typename table>
- inline bool operator!= (const table &other) const
- {
- return !(*this == other);
- }
- };
-
private:
/* This is the common base class for all line_entry<T> instantiations.
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<typename directory_table, typename line_table>
+ /* This holds the entirety of line information.
+ The line_table is all there actually is. */
+ template<typename line_table>
class line_info_table
- : private std::pair<directory_table, line_table>
{
private:
- typedef std::pair<directory_table, line_table> _base;
+ line_table _m_lines;
public:
- friend class subr::base_hasher<line_info_table, _base>;
- typedef subr::base_hasher<line_info_table, _base> hasher;
+ struct hasher : public std::unary_function<line_info_table, size_t>
+ {
+ 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<typename table>
inline line_info_table (const table &other)
- : _base (other.include_directories (), other.lines ())
+ : _m_lines (other.lines ())
{}
template<typename table>
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<typename table>
inline bool operator== (const table &other) const
{
- return (include_directories () == other.include_directories ()
- && lines () == other.lines ());
+ return lines () == other.lines ();
}
template<typename table>
inline bool operator!= (const table &other) const
public:
typedef dwarf_data::source_file source_file;
- typedef dwarf_data::directory_table directory_table;
typedef dwarf_data::line_entry<source_file> line_entry;
typedef dwarf_data::line_table<line_entry> line_table;
- typedef dwarf_data::line_info_table<directory_table,
- line_table> line_info_table;
+ typedef dwarf_data::line_info_table<line_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;
// Explicit instantiations.
extern template class dwarf_data::line_entry<dwarf_edit::source_file>;
extern template class dwarf_data::line_table<dwarf_edit::line_entry>;
- extern template class dwarf_data::line_info_table<dwarf_edit::directory_table,
- dwarf_edit::line_table>;
+ extern template class dwarf_data::line_info_table<dwarf_edit::line_table>;
extern template class dwarf_data::attr_value<dwarf_edit>;
extern template class dwarf_data::value<dwarf_edit>;
public:
typedef dwarf_data::source_file source_file;
- typedef dwarf_data::directory_table directory_table;
typedef dwarf_data::line_entry<source_file> line_entry;
typedef dwarf_data::line_table<line_entry> line_table;
- typedef dwarf_data::line_info_table<directory_table,
- line_table> line_info_table;
+ typedef dwarf_data::line_info_table<line_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;
/* 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
// Explicit instantiations.
template class dwarf_data::line_entry<dwarf_edit::source_file>;
template class dwarf_data::line_table<dwarf_edit::line_entry>;
-template class dwarf_data::line_info_table<dwarf_edit::directory_table,
- dwarf_edit::line_table>;
+template class dwarf_data::line_info_table<dwarf_edit::line_table>;
template class dwarf_data::attr_value<dwarf_edit>;
template class dwarf_data::value<dwarf_edit>;
return os.str ();
}
\f
-// 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<const char *const *> (&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;
-}
-\f
// dwarf::file_table
size_t
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
};
\f
-// 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 ());
-}
-\f
// dwarf::line_table
std::string