]> sourceware.org Git - systemtap.git/commitdiff
PR10499: Integrate attributes in dwarf_decl_file/line
authorJosh Stone <jistone@redhat.com>
Mon, 10 Aug 2009 21:48:39 +0000 (14:48 -0700)
committerJosh Stone <jistone@redhat.com>
Mon, 10 Aug 2009 21:48:39 +0000 (14:48 -0700)
Elfutils prior to 0.143 didn't use attr_integrate when looking up the
decl_file or decl_line, so the attributes would sometimes be missed.
For those old versions, we define custom implementations to do the
integration.

* dwarf_wrappers.cxx (dwarf_decl_file_integrate): New.
  (dwarf_decl_line_integrate): New.
* dwarf_wrappers.h: Add macros to redirect calls to the above functions.
* dwflpp.cxx (dwflpp::iterate_over_labels): Replace a manual attribute
  lookup that is the same as dwarf_decl_line.

dwarf_wrappers.cxx
dwarf_wrappers.h
dwflpp.cxx

index 03979ca25c3ff58808a5b3f12df334e5e1b7b239..0cb3cc0fbed99d7eb623d85310eed20f1e2fd255 100644 (file)
@@ -47,4 +47,46 @@ void dwfl_assert(const std::string& desc, bool condition)
 }
 
 
+#if !_ELFUTILS_PREREQ(0, 143)
+// Elfutils prior to 0.143 didn't use attr_integrate when looking up the
+// decl_file or decl_line, so the attributes would sometimes be missed.  For
+// those old versions, we define custom implementations to do the integration.
+
+const char *
+dwarf_decl_file_integrate (Dwarf_Die *die)
+{
+  Dwarf_Attribute attr_mem;
+  Dwarf_Sword idx = 0;
+  if (dwarf_formsdata (dwarf_attr_integrate (die, DW_AT_decl_file, &attr_mem),
+                       &idx) != 0
+      || idx == 0)
+    return NULL;
+
+  Dwarf_Die cudie;
+  Dwarf_Files *files = NULL;
+  if (dwarf_getsrcfiles (dwarf_diecu (die, &cudie, NULL, NULL),
+                         &files, NULL) != 0)
+    return NULL;
+
+  return dwarf_filesrc(files, idx, NULL, NULL);
+}
+
+int
+dwarf_decl_line_integrate (Dwarf_Die *die, int *linep)
+{
+  Dwarf_Attribute attr_mem;
+  Dwarf_Sword line;
+
+  int res = dwarf_formsdata (dwarf_attr_integrate
+                             (die, DW_AT_decl_line, &attr_mem),
+                             &line);
+  if (res == 0)
+    *linep = line;
+
+  return res;
+}
+
+#endif // !_ELFUTILS_PREREQ(0, 143)
+
+
 /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
index 9233fc1d9dd749ea2ad747b64363230ac63b9a32..54ab8fd4270e0f9f3400bb22cfe924e84fd0d1dd 100644 (file)
@@ -103,6 +103,21 @@ public:
 };
 
 
+#if !_ELFUTILS_PREREQ(0, 143)
+// Elfutils prior to 0.143 didn't use attr_integrate when looking up the
+// decl_file or decl_line, so the attributes would sometimes be missed.  For
+// those old versions, we define custom implementations to do the integration.
+
+const char *dwarf_decl_file_integrate (Dwarf_Die *die);
+#define dwarf_decl_file dwarf_decl_file_integrate
+
+int dwarf_decl_line_integrate (Dwarf_Die *die, int *linep)
+  __nonnull_attribute__ (2);
+#define dwarf_decl_line dwarf_decl_line_integrate
+
+#endif // !_ELFUTILS_PREREQ(0, 143)
+
+
 #endif
 
 /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
index e436a9cafdfb999eed2cf98eb7ae34f1ca9d531b..c31fbe4e886954e4f9402a64081819f0b8a6f642 100644 (file)
@@ -978,11 +978,11 @@ dwflpp::iterate_over_labels (Dwarf_Die *begin_die,
               && function_name_matches_pattern (name, sym)))
         {
           const char *file = dwarf_decl_file (&die);
+
           // Get the line number for this label
-          Dwarf_Attribute attr;
-          dwarf_attr (&die,DW_AT_decl_line, &attr);
-          Dwarf_Sword dline;
-          dwarf_formsdata (&attr, &dline);
+          int dline;
+          dwarf_decl_line (&die, &dline);
+
           Dwarf_Addr stmt_addr;
           if (dwarf_lowpc (&die, &stmt_addr) != 0)
             {
@@ -993,7 +993,7 @@ dwflpp::iterate_over_labels (Dwarf_Die *begin_die,
               size_t nlines = 0;
               // Get the line for this label
               Dwarf_Line **aline;
-              dwarf_getsrc_file (module_dwarf, file, (int)dline, 0, &aline, &nlines);
+              dwarf_getsrc_file (module_dwarf, file, dline, 0, &aline, &nlines);
               // Get the address
               for (size_t i = 0; i < nlines; i++)
                 {
@@ -1009,7 +1009,7 @@ dwflpp::iterate_over_labels (Dwarf_Die *begin_die,
           if (nscopes > 1)
             {
               callback(function_name.c_str(), file,
-                       (int)dline, &scopes[1], stmt_addr, q);
+                       dline, &scopes[1], stmt_addr, q);
               add_label_name(q, name);
             }
         }
This page took 0.037084 seconds and 5 git commands to generate.