summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2014-08-15 16:03:21 +0200
committerMark Wielaard <mjw@redhat.com>2014-08-15 20:29:48 +0200
commitf18f233615cdae0a3633506238348a1dee9d3ea0 (patch)
tree1dee65146fe9a46b30881ca35c07b7fe738a5e7a
parent209f149fdcdb5ecad8d5660429128b771d9b44cd (diff)
downloadelfutils-f18f233615cdae0a3633506238348a1dee9d3ea0.tar.gz
libdw: Add new function dwarf_cu_die.
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>
-rw-r--r--ChangeLog4
-rw-r--r--NEWS2
-rw-r--r--libdw/ChangeLog7
-rw-r--r--libdw/Makefile.am5
-rw-r--r--libdw/dwarf_cu_die.c68
-rw-r--r--libdw/libdw.h17
-rw-r--r--libdw/libdw.map1
7 files changed, 101 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index dd92265e..d79d269b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
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.
2014-07-18 Mark Wielaard <mjw@redhat.com>
diff --git a/NEWS b/NEWS
index 3e4e8cc0..6ee49673 100644
--- 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.
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 8dfd11e8..5f9b0971 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,12 @@
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.
* Makefile.am (libdw_a_SOURCES): Add dwarf_cu_getdwarf.c.
* libdw.h (Dwarf_CU): New typedef.
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index e39ab9a6..2e42a376 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -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
index 00000000..48f4176f
--- /dev/null
+++ b/libdw/dwarf_cu_die.c
@@ -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;
+}
diff --git a/libdw/libdw.h b/libdw/libdw.h
index 61d3b386..196d54ae 100644
--- a/libdw/libdw.h
+++ b/libdw/libdw.h
@@ -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);
diff --git a/libdw/libdw.map b/libdw/libdw.map
index 27e2273e..55bc5371 100644
--- a/libdw/libdw.map
+++ b/libdw/libdw.map
@@ -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