From: Petr Machata <pmachata@redhat.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: [PATCH] Support 1-sized reads in read_ubyte_unaligned_inc and read_sbyte_unaligned_inc
Date: Wed, 10 Sep 2014 23:09:50 +0200 [thread overview]
Message-ID: <40f6a3f1c6a66f860b64efbc56f5be9204d1d53c.1410383170.git.pmachata@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1977 bytes --]
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
next reply other threads:[~2014-09-10 21:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-10 21:09 Petr Machata [this message]
2014-09-10 21:22 Roland McGrath
2014-09-10 23:46 Petr Machata
2014-09-11 22:16 Roland McGrath
2014-09-12 12:24 Petr Machata
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40f6a3f1c6a66f860b64efbc56f5be9204d1d53c.1410383170.git.pmachata@redhat.com \
--to=pmachata@redhat.com \
--cc=elfutils-devel@lists.fedorahosted.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).