]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Add new function dwarf_cu_die.
authorMark Wielaard <mjw@redhat.com>
Fri, 15 Aug 2014 14:03:21 +0000 (16:03 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 15 Aug 2014 18:29:48 +0000 (20:29 +0200)
Given a Dwarf_Die or Dwarf_Attribute it is often convenient to get at the
CU DIE and the CU header information. There is dwarf_diecu but that doesn't
provide all information from the header and it doesn't work for attributes.
Add a new dwarf_cu_die function that provides all information given a
Dwarf_CU, which both Dwarf_Die and Dwarf_Attribute reference.

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

index dd92265eab5de8c35d29fdff50b73ae20b536f61..d79d269bd7199ed0625d7d2ffc0eeca96f03438d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-08-15  Mark Wielaard  <mjw@redhat.com>
+
+       * NEWS: Add dwarf_cu_die.
+
 2014-08-15  Mark Wielaard  <mjw@redhat.com>
 
        * NEWS: Add dwarf_cu_getdwarf.
diff --git a/NEWS b/NEWS
index 3e4e8cc06257916dd2cde56b58b796d724dbdf95..6ee49673cb30f695477f0545db50e10fb7f14c37 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,6 @@
 Version 0.160
 
-libdw: New function dwarf_cu_getdwarf.
+libdw: New functions dwarf_cu_getdwarf, dwarf_cu_die.
 
 unstrip: New option -F, --force to combining files even if some ELF headers
          don't seem to match.
index 8dfd11e8f1c3c0b05cb9e9a8fa698dabb3aff824..5f9b09719f2b0cedfc16c5101b8854227ca14d9f 100644 (file)
@@ -1,3 +1,10 @@
+2014-08-15  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_cu_die.c: New file.
+       * Makefile.am (libdw_a_SOURCES): Add dwarf_cu_die.c.
+       * libdw.h (dwarf_cu_die): New function declaration.
+       * libdw.map (ELFUTILS_0.160): Add dwarf_cu_die.
+
 2014-08-15  Mark Wielaard  <mjw@redhat.com>
 
        * dwarf_cu_getdwarf.c: New file.
index e39ab9a65495e3d1b5d437554cae5458a678de96..2e42a3764e0d63c0624078f7f589856e54e381a1 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 2002-2010, 2012 Red Hat, Inc.
+## Copyright (C) 2002-2010, 2012, 2014 Red Hat, Inc.
 ## This file is part of elfutils.
 ##
 ## This file is free software; you can redistribute it and/or modify
@@ -86,7 +86,8 @@ 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_cu_getdwarf.c
+                 dwarf_getalt.c dwarf_setalt.c dwarf_cu_getdwarf.c \
+                 dwarf_cu_die.c
 
 if MAINTAINER_MODE
 BUILT_SOURCES = $(srcdir)/known-dwarf.h
diff --git a/libdw/dwarf_cu_die.c b/libdw/dwarf_cu_die.c
new file mode 100644 (file)
index 0000000..48f4176
--- /dev/null
@@ -0,0 +1,68 @@
+/* Internal definitions for libdwarf.
+   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_Die *
+dwarf_cu_die (cu, result, versionp, abbrev_offsetp, address_sizep,
+             offset_sizep, type_signaturep, type_offsetp)
+    Dwarf_CU *cu;
+    Dwarf_Die *result;
+    Dwarf_Half *versionp;
+    Dwarf_Off *abbrev_offsetp;
+    uint8_t *address_sizep;
+    uint8_t *offset_sizep;
+    uint64_t *type_signaturep;
+    Dwarf_Off *type_offsetp;
+{
+  if (cu == NULL)
+    return NULL;
+
+  *result = CUDIE (cu);
+
+  if (versionp != NULL)
+    *versionp = cu->version;
+  if (abbrev_offsetp != NULL)
+    *abbrev_offsetp = cu->orig_abbrev_offset;
+  if (address_sizep != NULL)
+    *address_sizep = cu->address_size;
+  if (offset_sizep != NULL)
+    *offset_sizep = cu->offset_size;
+  if (type_signaturep != NULL)
+    *type_signaturep = cu->type_sig8;
+  if (type_offsetp != NULL)
+    *type_offsetp = cu->type_offset;
+
+  return result;
+}
index 61d3b386602a4e05288087ddedc8fb95bed2aa9d..196d54ae0c1d5bb8b0c7e08ecf2775cfd65432b4 100644 (file)
@@ -364,6 +364,23 @@ extern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result,
                               uint8_t *address_sizep, uint8_t *offset_sizep)
      __nonnull_attribute__ (2);
 
+/* Return the CU DIE and the header info associated with 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 CU or
+   type unit DIE and header information for that Dwarf_CU.  The
+   returned DIE is either a compile_unit, partial_unit or type_unit.
+   If it is a type_unit, then the type signature and type offset are
+   also provided, otherwise type_offset will be set to zero.  See also
+   dwarf_diecu and dwarf_next_unit.  */
+extern Dwarf_Die *dwarf_cu_die (Dwarf_CU *cu, Dwarf_Die *result,
+                               Dwarf_Half *versionp,
+                               Dwarf_Off *abbrev_offsetp,
+                               uint8_t *address_sizep,
+                               uint8_t *offset_sizep,
+                               uint64_t *type_signaturep,
+                               Dwarf_Off *type_offsetp)
+     __nonnull_attribute__ (2);
+
 /* Return CU DIE containing given address.  */
 extern Dwarf_Die *dwarf_addrdie (Dwarf *dbg, Dwarf_Addr addr,
                                 Dwarf_Die *result) __nonnull_attribute__ (3);
index 27e2273e4da06cf4e0f3ddb3f1966ae5eaa4935f..55bc5371a25967de247ace601f25762d70280bf7 100644 (file)
@@ -305,4 +305,5 @@ ELFUTILS_0.159 {
 ELFUTILS_0.160 {
   global:
     dwarf_cu_getdwarf;
+    dwarf_cu_die;
 } ELFUTILS_0.159;
\ No newline at end of file