public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* missing #include <dwarf.h> in libdw.h?
@ 2017-10-03 19:30 Bill Williams
  2017-10-04 19:02 ` Mark Wielaard
  0 siblings, 1 reply; 3+ messages in thread
From: Bill Williams @ 2017-10-03 19:30 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Bill Williams

Hi all,

libdw.h uses the DW_CIE_ID_64 define from dwarf.h in a macro definition, but does not itself include dwarf.h. This makes the libdw.h header not self-contained if and only if your code uses the dwarf_cfi_cie_p macro. Is this behavior by design, or a bug?

--bw

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: missing #include <dwarf.h> in libdw.h?
  2017-10-03 19:30 missing #include <dwarf.h> in libdw.h? Bill Williams
@ 2017-10-04 19:02 ` Mark Wielaard
       [not found]   ` <DM5PR0601MB37671FEDC5248BD6003184149B730@DM5PR0601MB3767.namprd06.prod.outlook.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Wielaard @ 2017-10-04 19:02 UTC (permalink / raw)
  To: Bill Williams, elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

On Tue, 2017-10-03 at 19:30 +0000, Bill Williams wrote:
> libdw.h uses the DW_CIE_ID_64 define from dwarf.h in a macro
> definition, but does not itself include dwarf.h. This makes the
> libdw.h header not self-contained if and only if your code uses the
> dwarf_cfi_cie_p macro. Is this behavior by design, or a bug?

I don't think this is by design. It seems a bug nobody noticed before
because people often do include dwarf.h also. But nothing else
explicitly needs the dwarf.h constants. It would probably not break
anything to explicitly include dwarf.h in libdw.h, but it seems better
to just define this constant explicitly in libdw.h as the attached
patch does. Does that make sense to you?

Thanks,

Mark

[-- Attachment #2: 0001-libdw-Define-LIBDW_CIE_ID-and-use-it-in-dwarf_cfi_ci.patch --]
[-- Type: text/x-patch, Size: 1482 bytes --]

From 251bb1c8c4a0a523791874c14826c391173bce4c Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Tue, 3 Oct 2017 23:08:01 +0200
Subject: [PATCH] libdw: Define LIBDW_CIE_ID and use it in dwarf_cfi_cie_p.

dwarf_cfi_cie_p used DW_CIE_ID_64 from dwarf.h which meant you had
to include dwarf.h just to use the dwarf_cfi_cie_p macros. Just define
the constant as LIBDW_CIE_ID in libdw.h to keep it independent.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdw/ChangeLog | 4 ++++
 libdw/libdw.h   | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 94e9c9a..e6e7f3b 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2017-10-03  Mark Wielaard  <mark@klomp.org>
+
+	* libdw.h: Define LIBDW_CIE_ID and use it in dwarf_cfi_cie_p.
+
 2017-08-18  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* memory-access.h: Use attribute_packed.
diff --git a/libdw/libdw.h b/libdw/libdw.h
index 63a38ff..e42c087 100644
--- a/libdw/libdw.h
+++ b/libdw/libdw.h
@@ -211,7 +211,9 @@ typedef union
   Dwarf_FDE fde;
 } Dwarf_CFI_Entry;
 
-#define dwarf_cfi_cie_p(entry)	((entry)->cie.CIE_id == DW_CIE_ID_64)
+/* Same as DW_CIE_ID_64 from dwarf.h to keep libdw.h independent.  */
+#define LIBDW_CIE_ID 0xffffffffffffffffULL
+#define dwarf_cfi_cie_p(entry)	((entry)->cie.CIE_id == LIBDW_CIE_ID)
 
 /* Opaque type representing a frame state described by CFI.  */
 typedef struct Dwarf_Frame_s Dwarf_Frame;
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: missing #include <dwarf.h> in libdw.h?
       [not found]   ` <DM5PR0601MB37671FEDC5248BD6003184149B730@DM5PR0601MB3767.namprd06.prod.outlook.com>
@ 2017-10-05 12:01     ` Mark Wielaard
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2017-10-05 12:01 UTC (permalink / raw)
  To: Bill Williams, elfutils-devel

On Wed, 2017-10-04 at 19:07 +0000, Bill Williams wrote:
> Works for me. This showed up on my desk from a broken configuration,
> but I figured I’d best pass it upstream too. :)

Thanks. I pushed this to master.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-05 12:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-03 19:30 missing #include <dwarf.h> in libdw.h? Bill Williams
2017-10-04 19:02 ` Mark Wielaard
     [not found]   ` <DM5PR0601MB37671FEDC5248BD6003184149B730@DM5PR0601MB3767.namprd06.prod.outlook.com>
2017-10-05 12:01     ` 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).