* Re: [PATCH 1/2] libdw: Add new function dwarf_cu_getdwarf.
@ 2014-08-18 14:03 Mark Wielaard
0 siblings, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2014-08-18 14:03 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 1574 bytes --]
On Sun, 2014-08-17 at 12:52 +0200, Dodji Seketeli wrote:
> Mark Wielaard <mjw@redhat.com> writes:
>
> > 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.
>
> Thanks Mark!
>
> This, indeed, is going to be useful for libabigail at least. This new
> dwarf_cu_getdwarf function, along with the existing dwarf_diecu function
> will allow us to get the actual Dwarf a given DIE comes from. And with
> the recently added dwarf_getalt function, we'll be able to tel if the
> DIE comes from the alternate Dwarf or not. This is awesome.
Glad it is useful.
Do note that the existing dwarf_diecu gives you the top-level Dwarf_Die
for the CU, not a Dwarf_CU. Both the original Dwarf_Die and the result
from dwarf_diecu should have the same Dwarf_CU handle that you can use
with dwarf_cu_getdwarf. The Dwarf_CU represents the actual DWARF CU
concept, from which you can get some extra information not like address
or offset size used in the particular DIE tree (see also dwarf_cudie
that returns both that extra information and the top level Dwarf_DIE for
the CU). While the top-level Dwarf_Die is the compile/partial/type_unit
DIE (all other DIEs in the CU are children of this DIE).
Cheers,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] libdw: Add new function dwarf_cu_getdwarf.
@ 2014-08-20 9:31 Mark Wielaard
0 siblings, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2014-08-20 9:31 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 202 bytes --]
On Mon, 2014-08-18 at 16:03 +0200, Mark Wielaard wrote:
> Glad it is useful.
I pushed both patches to master now.
libdw: Add new function dwarf_cu_getdwarf.
libdw: Add new function dwarf_cu_die.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] libdw: Add new function dwarf_cu_getdwarf.
@ 2014-08-17 10:52 Dodji Seketeli
0 siblings, 0 replies; 4+ messages in thread
From: Dodji Seketeli @ 2014-08-17 10:52 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 851 bytes --]
Mark Wielaard <mjw@redhat.com> writes:
> 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.
Thanks Mark!
This, indeed, is going to be useful for libabigail at least. This new
dwarf_cu_getdwarf function, along with the existing dwarf_diecu function
will allow us to get the actual Dwarf a given DIE comes from. And with
the recently added dwarf_getalt function, we'll be able to tel if the
DIE comes from the alternate Dwarf or not. This is awesome.
Thanks again.
Cheers.
--
Dodji
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] libdw: Add new function dwarf_cu_getdwarf.
@ 2014-08-15 14:08 Mark Wielaard
0 siblings, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2014-08-15 14:08 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 5744 bytes --]
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 | 4 ++++
NEWS | 2 ++
libdw/ChangeLog | 8 ++++++++
libdw/Makefile.am | 2 +-
libdw/dwarf_cu_getdwarf.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
libdw/libdw.h | 9 ++++++++-
libdw/libdw.map | 5 +++++
7 files changed, 75 insertions(+), 2 deletions(-)
create mode 100644 libdw/dwarf_cu_getdwarf.c
diff --git a/ChangeLog b/ChangeLog
index b470b3d..dd92265 100644
--- 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 4050200..3e4e8cc 100644
--- 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.
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 2884419..8dfd11e 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -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.
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 8538d36..e39ab9a 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -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
index 0000000..f8a2e9b
--- /dev/null
+++ b/libdw/dwarf_cu_getdwarf.c
@@ -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;
+}
diff --git a/libdw/libdw.h b/libdw/libdw.h
index a4654c4..61d3b38 100644
--- a/libdw/libdw.h
+++ b/libdw/libdw.h
@@ -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);
diff --git a/libdw/libdw.map b/libdw/libdw.map
index 899e13e..27e2273 100644
--- a/libdw/libdw.map
+++ b/libdw/libdw.map
@@ -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
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-20 9:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-18 14:03 [PATCH 1/2] libdw: Add new function dwarf_cu_getdwarf Mark Wielaard
-- strict thread matches above, loose matches on Subject: below --
2014-08-20 9:31 Mark Wielaard
2014-08-17 10:52 Dodji Seketeli
2014-08-15 14:08 Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).