From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Subject: Re: [PATCH] libdwfl: Use process_vm_readv when available.
Date: Wed, 21 Mar 2018 00:47:00 -0000 [thread overview]
Message-ID: <20180321004714.GH6269@wildebeest.org> (raw)
In-Reply-To: <20180320232848.GB12453@altlinux.org>
On Wed, Mar 21, 2018 at 02:28:48AM +0300, Dmitry V. Levin wrote:
> On Sun, Mar 18, 2018 at 01:43:23AM +0100, Mark Wielaard wrote:
> > + /* Let the ptrace fallback deal with the corner case of the address
> > + possibly crossing a page boundery. */
> > + if ((addr & ((Dwarf_Addr)__LIBDWFL_REMOTE_MEM_CACHE_SIZE - 1))
> > + > (Dwarf_Addr)__LIBDWFL_REMOTE_MEM_CACHE_SIZE - sizeof (unsigned long))
>
> It looks odd that the variable that is going to be assigned has type
> Dwarf_Word, while the size being checked has type unsigned long.
> Shouldn't it be sizeof(*result) instead?
>
> > + d = &mem_cache->buf[addr - mem_cache->addr];
> > + *result = *(unsigned long *) d;
>
> Likewise, shouldn't it be memcpy(result, d, sizeof(*result)) instead?
That is indeed not immediately clear. I'll add some documentation.
Although the functions do use Dwarf_Word (which is always 64bits)
they actually return the result of an unsigned long/address. This
is true for both the pid based and core based memory read functions.
I am not completely sure if this was originally deliberate, or if
this was the accidental result of the ptrace interface returning a
long (target word) for PTRACE_PEEKDATA.
Thanks for reviewing.
Cheers,
Mark
prev parent reply other threads:[~2018-03-21 0:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-18 0:43 Mark Wielaard
2018-03-20 22:32 ` Mark Wielaard
2018-03-28 14:33 ` Mark Wielaard
2018-03-28 21:42 ` Dmitry V. Levin
2018-03-20 23:28 ` Dmitry V. Levin
2018-03-21 0:47 ` Mark Wielaard [this message]
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=20180321004714.GH6269@wildebeest.org \
--to=mark@klomp.org \
--cc=elfutils-devel@sourceware.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).