[rtems-tools commit] rtemstoolkit/dwarf: Change the address source line to signed so valid() works.

Chris Johns chrisj at rtems.org
Tue Jun 19 03:43:58 UTC 2018


Module:    rtems-tools
Branch:    master
Commit:    1c8538039ee0789a6d91ed201050e183faa50316
Changeset: http://git.rtems.org/rtems-tools/commit/?id=1c8538039ee0789a6d91ed201050e183faa50316

Author:    Chris Johns <chrisj at rtems.org>
Date:      Fri May 11 17:21:05 2018 +1200

rtemstoolkit/dwarf: Change the address source line to signed so valid() works.

Also add a check to valid where there must be source to be valid.

---

 rtemstoolkit/rld-dwarf.cpp | 45 ++++++++++++++++++++++++---------------------
 rtemstoolkit/rld-dwarf.h   |  4 ++--
 2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/rtemstoolkit/rld-dwarf.cpp b/rtemstoolkit/rld-dwarf.cpp
index ed135d9..15cf8e2 100644
--- a/rtemstoolkit/rld-dwarf.cpp
+++ b/rtemstoolkit/rld-dwarf.cpp
@@ -63,24 +63,26 @@ namespace rld
         block (false),
         end_sequence (false)
     {
-        dwarf_error de;
-        int         dr;
-        dr = ::dwarf_lineaddr(line, &addr, &de);
-        libdwarf_error_check ("address::address", dr, de);
-        dr = ::dwarf_line_srcfileno(line, &source_index, &de);
-        libdwarf_error_check ("address::address", dr, de);
-        dr = ::dwarf_lineno(line, &source_line, &de);
-        libdwarf_error_check ("address::address", dr, de);
-        dwarf_bool b;
-        dr = ::dwarf_linebeginstatement(line, &b, &de);
-        libdwarf_error_check ("address::address", dr, de);
-        begin_statement = b ? true : false;
-        dr = ::dwarf_lineblock(line, &b, &de);
-        libdwarf_error_check ("address::address", dr, de);
-        block = b ? true : false;
-        dr = ::dwarf_lineendsequence(line, &b, &de);
-        libdwarf_error_check ("address::address", dr, de);
-        end_sequence = b ? true : false;
+      dwarf_error de;
+      int         dr;
+      dr = ::dwarf_lineaddr(line, &addr, &de);
+      libdwarf_error_check ("address::address", dr, de);
+      dr = ::dwarf_line_srcfileno(line, &source_index, &de);
+      libdwarf_error_check ("address::address", dr, de);
+      dwarf_unsigned src_line;
+      dr = ::dwarf_lineno(line, &src_line, &de);
+      libdwarf_error_check ("address::address", dr, de);
+      source_line = src_line;
+      dwarf_bool b;
+      dr = ::dwarf_linebeginstatement(line, &b, &de);
+      libdwarf_error_check ("address::address", dr, de);
+      begin_statement = b ? true : false;
+      dr = ::dwarf_lineblock(line, &b, &de);
+      libdwarf_error_check ("address::address", dr, de);
+      block = b ? true : false;
+      dr = ::dwarf_lineendsequence(line, &b, &de);
+      libdwarf_error_check ("address::address", dr, de);
+      end_sequence = b ? true : false;
     }
 
     address::address (const address& orig)
@@ -108,12 +110,13 @@ namespace rld
     address::~address ()
     {
       source = nullptr;
+      source_line = -1;
     }
 
     bool
     address::valid () const
     {
-      return source_line > 0;
+      return source != nullptr && source_line > 0;
     }
 
     dwarf_address
@@ -155,7 +158,7 @@ namespace rld
     }
 
     address&
-    address::operator = (address& rhs)
+    address::operator = (const address& rhs)
     {
       if (this != &rhs)
       {
@@ -612,7 +615,7 @@ namespace rld
                                   address&            addr_line)
     {
       if (addr_lines_.find (addr) == addr_lines_.end ())
-        return false;
+          return false;
       addr_line = addr_lines_[addr];
       return true;
     }
diff --git a/rtemstoolkit/rld-dwarf.h b/rtemstoolkit/rld-dwarf.h
index 8a61755..c69cb9d 100644
--- a/rtemstoolkit/rld-dwarf.h
+++ b/rtemstoolkit/rld-dwarf.h
@@ -88,14 +88,14 @@ namespace rld
       /**
        * Assigment operator.
        */
-      address& operator = (address& rhs);
+      address& operator = (const address& rhs);
 
     private:
 
       dwarf_address  addr;
       sources const* source;
       dwarf_unsigned source_index;
-      dwarf_unsigned source_line;
+      dwarf_signed   source_line;
       bool           begin_statement;
       bool           block;
       bool           end_sequence;



More information about the vc mailing list