]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Unfinished DW_AT_macro_info support.
authorRoland McGrath <roland@redhat.com>
Thu, 29 Jan 2009 20:47:42 +0000 (12:47 -0800)
committerRoland McGrath <roland@redhat.com>
Thu, 29 Jan 2009 20:47:42 +0000 (12:47 -0800)
libdw/c++/dwarf
libdw/c++/values.cc
libdw/dwarf_getmacros.c

index fc07c5d25f816eadafbe6ba4b144298051194158..3092c089eb1f7f24319219686d43562738190d1d 100644 (file)
@@ -380,6 +380,7 @@ namespace elfutils
     class file_table;
     class line_table;
     class line_entry;
+    class macro_info_table;
 
     class debug_info_entry
     {
@@ -914,15 +915,8 @@ namespace elfutils
        return line_info ().lines ();
       }
 
-      /*
-       containers/iterators:
-
-       XXX lines
-       XXX macros
-
-       abbrevs (punt)
-
-      */
+      // Fetch the CU's DW_AT_macro_info.
+      const macro_info_table macro_info () const;
     };
 
     // These are the kinds of values that attributes can have.
@@ -1058,8 +1052,7 @@ namespace elfutils
       }
 
       const line_info_table line_info () const;
-
-      // XXX macptr
+      const macro_info_table macro_info () const;
 
       template<typename value>
       inline bool operator== (const value &other) const
@@ -1082,8 +1075,9 @@ namespace elfutils
            case VS_lineptr:
              return line_info () == other.line_info ();
 
-           case VS_macptr:     // XXX punt for now, treat as constant
-             /*FALLTHRU*/
+           case VS_macptr:
+              return macro_info () == macro_info ();
+
            case VS_constant:
            case VS_dwarf_constant:
            case VS_source_line:
@@ -1587,6 +1581,37 @@ namespace elfutils
       }
     };
 
+    class macro_entry;         // XXX
+    // The DW_AT_macro_info attribute yields a line info table.
+    class macro_info_table
+    {
+      friend class attr_value;
+    private:
+      compile_unit _m_cu;
+
+      macro_info_table (const debug_info_entry &die) : _m_cu (die) {}
+
+    public:
+      typedef macro_entry value_type;
+
+      macro_info_table (const macro_info_table &t) : _m_cu (t._m_cu) {}
+
+      typedef void **const_iterator; // XXX
+      const_iterator begin () const { return NULL; } // dummy
+      const_iterator end () const { return NULL; }   // dummy
+
+      template<typename table>
+      inline bool operator== (const table &other) const
+      {
+       return std::equal (begin (), end (), other.begin ());
+      }
+      template<typename table>
+      inline bool operator!= (const table &other) const
+      {
+       return !(*this == other);
+      }
+    };
+
     // This describes one attribute, equivalent to pair<const int, attr_value>.
     class attribute
     {
index 45f2ce30c9d37400c0f4a3198cc6b043b2464e03..3a52dbe456925b34966161301ac7e0dfb011865f 100644 (file)
@@ -296,6 +296,16 @@ dwarf::attr_value::constant_block () const
   const uint8_t *const end = begin + block.length;
   return const_vector<uint8_t> (begin, end);
 }
+
+const dwarf::macro_info_table
+dwarf::attr_value::macro_info () const
+{
+  assert (dwarf_whatattr (thisattr ()) == DW_AT_macro_info);
+  CUDIE (cudie, _m_attr.cu);
+  debug_info_entry die;
+  die._m_die = cudie;
+  return macro_info_table (die);
+}
 \f
 // dwarf::location_attr
 
index 743ade3bb4aa6000a1a59cbe178574e2928917b9..5421dfc10c2de902919848b7ffe25f90e6167675 100644 (file)
@@ -1,5 +1,5 @@
 /* Get macro information.
-   Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -142,9 +142,8 @@ dwarf_getmacros (die, callback, arg, offset)
        mac.param2.s = str;
 
       if (callback (&mac, arg) != DWARF_CB_OK)
-       return (readp
-               - ((unsigned char *) die->cu->dbg->sectiondata[IDX_debug_macinfo]->d_buf
-                  + offset));
+       return readp - ((unsigned char *) die->cu->dbg->sectiondata
+                       [IDX_debug_macinfo]->d_buf);
     }
 
   /* If we come here the termination of the data for the CU is not