From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65173 invoked by alias); 20 Mar 2018 23:28:53 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 64760 invoked by uid 89); 20 Mar 2018 23:28:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-Spam-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: vmicros1.altlinux.org Received: from vmicros1.altlinux.org (HELO vmicros1.altlinux.org) (194.107.17.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Mar 2018 23:28:51 +0000 Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id B03D472D564 for ; Wed, 21 Mar 2018 02:28:48 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id A55C37CC76C; Wed, 21 Mar 2018 02:28:48 +0300 (MSK) Date: Tue, 20 Mar 2018 23:28:00 -0000 From: "Dmitry V. Levin" To: elfutils-devel@sourceware.org Subject: Re: [PATCH] libdwfl: Use process_vm_readv when available. Message-ID: <20180320232848.GB12453@altlinux.org> Mail-Followup-To: elfutils-devel@sourceware.org References: <20180318004323.21340-1-mark@klomp.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dTy3Mrz/UPE2dbVg" Content-Disposition: inline In-Reply-To: <20180318004323.21340-1-mark@klomp.org> X-IsSubscribed: yes X-SW-Source: 2018-q1/txt/msg00089.txt.bz2 --dTy3Mrz/UPE2dbVg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1571 On Sun, Mar 18, 2018 at 01:43:23AM +0100, Mark Wielaard wrote: [...] > @@ -115,12 +116,80 @@ __libdwfl_ptrace_attach (pid_t tid, bool *tid_was_s= toppedp) > return true; > } >=20=20 > +#ifdef HAVE_PROCESS_VM_READV > +static bool > +read_cached_memory (struct __libdwfl_pid_arg *pid_arg, > + Dwarf_Addr addr, Dwarf_Word *result) > +{ > + /* 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 l= ong)) 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? > + return false; > + > + struct __libdwfl_remote_mem_cache *mem_cache =3D pid_arg->mem_cache; > + if (mem_cache =3D=3D NULL) > + { > + size_t mem_cache_size =3D sizeof (struct __libdwfl_remote_mem_cach= e); > + mem_cache =3D (struct __libdwfl_remote_mem_cache *) malloc (mem_ca= che_size); > + if (mem_cache =3D=3D NULL) > + return false; > + > + mem_cache->addr =3D 0; > + mem_cache->len =3D 0; > + pid_arg->mem_cache =3D mem_cache; > + } > + > + unsigned char *d; > + if (addr >=3D mem_cache->addr && addr - mem_cache->addr < mem_cache->l= en) > + { > + d =3D &mem_cache->buf[addr - mem_cache->addr]; > + *result =3D *(unsigned long *) d; Likewise, shouldn't it be memcpy(result, d, sizeof(*result)) instead? --=20 ldv --dTy3Mrz/UPE2dbVg Content-Type: application/pgp-signature; name="signature.asc" Content-length: 801 -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJasZkwAAoJEAVFT+BVnCUIOwoQANMjRdRy8fEt700scQfdCo1w hxcVA4tS1VmQnnymeSklFxZqMcMpzArLoH7QA0ZV5nR4BlBzZj7GNEAWPbEOcVQn mTfeCKg74/pSbvpPMnVZ/gz4u/RhyPBYXpz28qvhWHpBJ8+XoISmb+NFDL2c8OTF smRC7cOafygulzAaUdaOmra6Gg/0dBY1hUvacId/54BRr0H809XZ++gQJqVmyS5b fdzkphPYZGaD9EgjzyzM9MXFl6k4sG05+61w+P44wwG6GFQQQ3vIeqEA9zNm5Jpu rkCaEmknB+GjY5jNp936Fccr5dx14oDKQ/CawPQWp8LVQZQboZcAWKgimBhApAFu mpiFhOBpzZEAWUsYGRJNmxtpSLxK4XZOStxvjyIam34uVKYrLopLCgH+yuAwpYAa sjwHP7Jdw3rpWegk0T0msmIaiaHLuV9C2f6on/Hv7WXMiJdawGgmX9LpsNOvt3ll A32trIF+0/NZ2KQgRyeY7IokREJum01+a3mhCbddj/pQSOrB2GURfm6x27phrse7 HtEoGNMZfNf14vT8IUdoWquJJSPt1k1OtpTNHusCTRe7dht166pmjihbJiXXT9Yx dEjGjS5jmymDwPP0xbNFNBIySOO0ouU1wWkGY8Ec9WPTgLvjHWK0jNpENbC1M9+5 XthVFaQdKOD7CB8gHJZx =/OTn -----END PGP SIGNATURE----- --dTy3Mrz/UPE2dbVg--