]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Add new function dwarf_cu_getdwarf.
authorMark Wielaard <mjw@redhat.com>
Fri, 15 Aug 2014 11:08:24 +0000 (13:08 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 15 Aug 2014 18:29:48 +0000 (20:29 +0200)
In both systemtap and libabigail there is a need to get the actual Dwarf
underlying an Dwarf_Die or Dwarf_Attribute. Following a DIE reference
might end up in an alternate Dwarf since the addition of DWZ multifile
forms. Both Dwarf_Die and Dwarf_Attribute already contain a Dwarf_CU
handle. Add a function dwarf_cu_getdwarf to retrieve the underlying
Dwarf using the Dwarf_CU.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
ChangeLog
NEWS
libdw/ChangeLog
libdw/Makefile.am
libdw/dwarf_cu_getdwarf.c [new file with mode: 0644]
libdw/libdw.h
libdw/libdw.map

index b470b3d7831d6b7fec8aff1506162571dbcd9029..dd92265eab5de8c35d29fdff50b73ae20b536f61 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-08-15  Mark Wielaard  <mjw@redhat.com>
+
+       * NEWS: Add dwarf_cu_getdwarf.
+
 2014-07-18  Mark Wielaard  <mjw@redhat.com>
 
        * configure.ac (AC_CHECK_TYPE): Test for struct user_regs_struct.
diff --git a/NEWS b/NEWS
index 4050200a02c61e276e1f99dd014aa34706a45783..3e4e8cc06257916dd2cde56b58b796d724dbdf95 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
 Version 0.160
 
+libdw: New function dwarf_cu_getdwarf.
+
 unstrip: New option -F, --force to combining files even if some ELF headers
          don't seem to match.
 
index 288441970336aed06352771f458f7159e38806e1..8dfd11e8f1c3c0b05cb9e9a8fa698dabb3aff824 100644 (file)
@@ -1,3 +1,11 @@
+2014-08-15  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_cu_getdwarf.c: New file.
+       * Makefile.am (libdw_a_SOURCES): Add dwarf_cu_getdwarf.c.
+       * libdw.h (Dwarf_CU): New typedef.
+       (dwarf_cu_getdwarf): New function declaration.
+       * libdw.map (ELFUTILS_0.160): New. Add dwarf_cu_getdwarf.
+
 2014-06-18  Mark Wielaard  <mjw@redhat.com>
 
        * dwarf.h: Remove DW_TAG_mutable_type.
index 8538d365166fe6dcaa317336ab95dc49c7423161..e39ab9a65495e3d1b5d437554cae5458a678de96 100644 (file)
@@ -86,7 +86,7 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \
                  dwarf_getcfi.c dwarf_getcfi_elf.c dwarf_cfi_end.c \
                  dwarf_aggregate_size.c dwarf_getlocation_implicit_pointer.c \
                  dwarf_getlocation_die.c dwarf_getlocation_attr.c \
-                 dwarf_getalt.c dwarf_setalt.c
+                 dwarf_getalt.c dwarf_setalt.c dwarf_cu_getdwarf.c
 
 if MAINTAINER_MODE
 BUILT_SOURCES = $(srcdir)/known-dwarf.h
diff --git a/libdw/dwarf_cu_getdwarf.c b/libdw/dwarf_cu_getdwarf.c
new file mode 100644 (file)
index 0000000..f8a2e9b
--- /dev/null
@@ -0,0 +1,47 @@
+/* Retrieve Dwarf descriptor underlying a Dwarf_CU.
+   Copyright (C) 2014 Red Hat, Inc.
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at
+       your option) any later version
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at
+       your option) any later version
+
+   or both in parallel, as here.
+
+   elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stddef.h>
+
+#include "libdwP.h"
+
+
+Dwarf *
+dwarf_cu_getdwarf (cu)
+     Dwarf_CU *cu;
+{
+  if (cu == NULL)
+    /* Some error occurred before.  */
+    return NULL;
+
+  return cu->dbg;
+}
index a4654c44c5b9ebc1b789f5714c8b1a578d628f71..61d3b386602a4e05288087ddedc8fb95bed2aa9d 100644 (file)
@@ -1,5 +1,5 @@
 /* Interfaces for libdw.
-   Copyright (C) 2002-2010, 2013 Red Hat, Inc.
+   Copyright (C) 2002-2010, 2013, 2014 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -112,6 +112,7 @@ typedef struct Dwarf_Aranges_s Dwarf_Aranges;
 
 /* CU representation.  */
 struct Dwarf_CU;
+typedef struct Dwarf_CU Dwarf_CU;
 
 /* Macro information.  */
 typedef struct Dwarf_Macro_s Dwarf_Macro;
@@ -260,6 +261,12 @@ extern Dwarf *dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp);
 /* Retrieve ELF descriptor used for DWARF access.  */
 extern Elf *dwarf_getelf (Dwarf *dwarf);
 
+/* Retieve DWARF descriptor used for a Dwarf_Die or Dwarf_Attribute.
+   A Dwarf_Die or a Dwarf_Attribute is associated with a particular
+   Dwarf_CU handle.  This function returns the DWARF descriptor for
+   that Dwarf_CU.  */
+extern Dwarf *dwarf_cu_getdwarf (Dwarf_CU *cu);
+
 /* Retrieves the DWARF descriptor for debugaltlink data.  Returns NULL
    if no alternate debug data has been supplied.  */
 extern Dwarf *dwarf_getalt (Dwarf *main);
index 899e13e10549d09730e9b2d29b75b2added836d0..27e2273e4da06cf4e0f3ddb3f1966ae5eaa4935f 100644 (file)
@@ -301,3 +301,8 @@ ELFUTILS_0.159 {
     dwelf_elf_gnu_debuglink;
     dwelf_elf_gnu_build_id;
 } ELFUTILS_0.158;
+
+ELFUTILS_0.160 {
+  global:
+    dwarf_cu_getdwarf;
+} ELFUTILS_0.159;
\ No newline at end of file