diff options
author | Chris Johns <chrisj@rtems.org> | 2020-09-15 13:10:56 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2020-09-15 13:10:56 +1000 |
commit | 463831374ce73e6792c6fc6c02e705cf3b8fc349 (patch) | |
tree | 783cd45ad8e2f3f403dbc41e574641b95559e951 /rtemstoolkit | |
parent | linkers/exeinfo: Output TLS data (diff) | |
download | rtems-tools-463831374ce73e6792c6fc6c02e705cf3b8fc349.tar.bz2 |
linker/exeinfo: Optionally output full flags when listing object files
- Start adding support to dump configuration tables
Diffstat (limited to 'rtemstoolkit')
-rw-r--r-- | rtemstoolkit/rld-dwarf.cpp | 138 | ||||
-rw-r--r-- | rtemstoolkit/rld-dwarf.h | 69 |
2 files changed, 206 insertions, 1 deletions
diff --git a/rtemstoolkit/rld-dwarf.cpp b/rtemstoolkit/rld-dwarf.cpp index 1e62b3c..fc4399a 100644 --- a/rtemstoolkit/rld-dwarf.cpp +++ b/rtemstoolkit/rld-dwarf.cpp @@ -575,6 +575,104 @@ namespace rld return *this; } + variable::variable (file& debug, debug_info_entry& die) + : debug (debug), + external_ (false), + declaration_ (false) + { + dwarf_bool db; + + if (die.attribute (DW_AT_external, db, false)) + external_ = db ? true : false; + + if (die.attribute (DW_AT_declaration, db, false)) + declaration_ = db ? true : false; + + /* + * Get the name attribute. (if present) + */ + die.attribute (DW_AT_name, name_); + die.attribute (DW_AT_decl_file, decl_file_); + die.attribute (DW_AT_decl_line, decl_line_); + + if (rld::verbose () >= RLD_VERBOSE_FULL_DEBUG) + { + std::cout << "dwarf::variable: "; + dump (std::cout); + std::cout << std::endl; + } + } + + variable::variable (const variable& orig) + : debug (orig.debug), + external_ (orig.external_), + declaration_ (orig.declaration_), + name_ (orig.name_), + decl_file_ (orig.decl_file_), + decl_line_ (orig. decl_line_) + { + } + + variable::~variable () + { + } + + std::string + variable::name () const + { + return name_; + } + + bool + variable::is_external () const + { + return external_; + } + + bool + variable::is_declaration () const + { + return declaration_; + } + + size_t + variable::size () const + { + size_t s = 0; + return s; + } + + variable& + variable::operator = (const variable& rhs) + { + if (this != &rhs) + { + debug = rhs.debug; + external_ = rhs.external_; + declaration_ = rhs.declaration_; + name_ = rhs.name_; + decl_file_ = rhs.decl_file_; + decl_line_ = rhs.decl_line_; + } + return *this; + } + + void + variable::dump (std::ostream& out) const + { + if (name_.empty ()) + out << "NO-NAME"; + else + out << name_; + out << " [" + << (char) (external_ ? 'E' : '-') + << (char) (declaration_ ? 'D' : '-') + << "] size=" << size () + << std::hex << std::setfill ('0') + << " (0x" << size () << ')' + << std::dec << std::setfill (' '); + } + function::function (file& debug, debug_info_entry& die) : debug (debug), @@ -1513,7 +1611,6 @@ namespace rld source_ (debug, die_offset) { die.attribute (DW_AT_name, name_); - name_ = name_; die.attribute (DW_AT_producer, producer_); @@ -1674,6 +1771,38 @@ namespace rld } void + compilation_unit::load_variables () + { + debug_info_entry die (debug, die_offset); + debug_info_entry child (debug); + if (die.get_child (child)) + load_variables (child); + } + + void + compilation_unit::load_variables (debug_info_entry& die) + { + while (true) + { + if (die.tag () == DW_TAG_variable) + { + function func (debug, die); + functions_.push_back (func); + } + + debug_info_entry next (die.get_debug ()); + + if (die.get_child (next)) + load_functions (next); + + if (!die.get_sibling (next)) + break; + + die = next; + } + } + + void compilation_unit::load_functions () { debug_info_entry die (debug, die_offset); @@ -1993,6 +2122,13 @@ namespace rld } void + file::load_variables () + { + for (auto& cu : cus) + cu.load_variables (); + } + + void file::load_functions () { for (auto& cu : cus) diff --git a/rtemstoolkit/rld-dwarf.h b/rtemstoolkit/rld-dwarf.h index 030be3a..45fbab1 100644 --- a/rtemstoolkit/rld-dwarf.h +++ b/rtemstoolkit/rld-dwarf.h @@ -277,6 +277,59 @@ namespace rld }; /** + * Variable. + */ + class variable + { + public: + + variable (file& debug, debug_info_entry& die); + variable (const variable& orig); + ~variable (); + + /** + * Get the name of the variable. + */ + std::string name () const; + + /** + * Is the variable external? + */ + bool is_external () const; + + /** + * Is this just a declaration? + */ + bool is_declaration () const; + + /** + * Size of the variable. + */ + size_t size () const; + + /** + * Assigment operator. + */ + variable& operator = (const variable& rhs); + + /** + * Dump the variable. + */ + void dump (std::ostream& out) const; + + private: + + file& debug; + bool external_; + bool declaration_; + std::string name_; + std::string decl_file_; + dwarf_unsigned decl_line_; + }; + + typedef std::vector < variable > variables; + + /** * Function. */ class function @@ -620,6 +673,11 @@ namespace rld void load_types (); /** + * Load the variables. + */ + void load_variables (); + + /** * Load the functions. */ void load_functions (); @@ -677,6 +735,7 @@ namespace rld private: + void load_variables (debug_info_entry& die); void load_functions (debug_info_entry& die); file& debug; ///< The DWARF debug handle. @@ -781,6 +840,11 @@ namespace rld void load_functions (); /** + * Load the DWARF variables information. + */ + void load_variables (); + + /** * Get the source location given an address. */ bool get_source (const unsigned int address, @@ -793,6 +857,11 @@ namespace rld void get_producer_sources (producer_sources& producers); /** + * Get the variable given a name. Raises an exception if not found. + */ + variable& get_variable (std::string& name); + + /** * Does the function exist. */ bool function_valid (std::string&name); |