This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] Support 1-sized reads in read_ubyte_unaligned_inc and read_sbyte_unaligned_inc
- From: Petr Machata <pmachata at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Wed, 10 Sep 2014 23:09:50 +0200
- Subject: [PATCH] Support 1-sized reads in read_ubyte_unaligned_inc and read_sbyte_unaligned_inc
I propose this change mostly for consistency. Having one entry point
for reading all (reasonable) widths is very convenient, and I make use
of this interface in my upcoming patch for .debug_macro support.
---8<-----------------------------------------------------------------
Signed-off-by: Petr Machata <pmachata@redhat.com>
---
libdw/ChangeLog | 5 +++++
libdw/memory-access.h | 10 ++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 5f9b097..b8c5acd 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2014-09-10 Petr Machata <pmachata@redhat.com>
+
+ * memory-access.h (read_ubyte_unaligned_inc)
+ (read_sbyte_unaligned_inc): Read 1-sized fields as well.
+
2014-08-15 Mark Wielaard <mjw@redhat.com>
* dwarf_cu_die.c: New file.
diff --git a/libdw/memory-access.h b/libdw/memory-access.h
index f41f783..caa92f6 100644
--- a/libdw/memory-access.h
+++ b/libdw/memory-access.h
@@ -259,13 +259,15 @@ read_8sbyte_unaligned_1 (bool other_byte_order, const void *p)
#define read_ubyte_unaligned_inc(Nbytes, Dbg, Addr) \
- ((Nbytes) == 2 ? read_2ubyte_unaligned_inc (Dbg, Addr) \
- : (Nbytes) == 4 ? read_4ubyte_unaligned_inc (Dbg, Addr) \
+ ((Nbytes) == 1 ? (uint8_t) *Addr++ \
+ : (Nbytes) == 2 ? read_2ubyte_unaligned_inc (Dbg, Addr) \
+ : (Nbytes) == 4 ? read_4ubyte_unaligned_inc (Dbg, Addr) \
: read_8ubyte_unaligned_inc (Dbg, Addr))
#define read_sbyte_unaligned_inc(Nbytes, Dbg, Addr) \
- ((Nbytes) == 2 ? read_2sbyte_unaligned_inc (Dbg, Addr) \
- : (Nbytes) == 4 ? read_4sbyte_unaligned_inc (Dbg, Addr) \
+ ((Nbytes) == 1 ? (int8_t) *Addr++ \
+ : (Nbytes) == 2 ? read_2sbyte_unaligned_inc (Dbg, Addr) \
+ : (Nbytes) == 4 ? read_4sbyte_unaligned_inc (Dbg, Addr) \
: read_8sbyte_unaligned_inc (Dbg, Addr))
#endif /* memory-access.h */
--
1.7.6.5