From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121338 invoked by alias); 28 Dec 2019 05:28:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 121315 invoked by uid 89); 28 Dec 2019 05:28:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=H*r:sk:server2, H*RU:sk:server2, HX-Spam-Relays-External:sk:server2, relocated X-HELO: mail.bob131.so Received: from server2.bob131.so (HELO mail.bob131.so) (128.199.153.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 28 Dec 2019 05:28:49 +0000 Received: from internal.mail.bob131.so (localhost [127.0.0.1]) by mail.bob131.so (Postfix) with ESMTP id EC87752CEE for ; Sat, 28 Dec 2019 05:28:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.bob131.so EC87752CEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bob131.so; s=default; t=1577510926; bh=eATZei0+9cwu7sfzBxbuIULmTSTeZilWovzrLBmThsk=; h=Date:From:To:Subject:References:In-Reply-To:From; b=VcPV6zpmw9gkg5yN4v8nJO+hLX5NHvH5EbfAKn+e4cAZHtJIMYniGes8emsqG892F PH0hWyeQ34JgZZiBLakHmes95+lctVSVa0TWrtDEnyFoyzD8pTnW90PcFCow6Fcjm8 XHSgSXUbYXTyIa4zA9O6HIOIO6gE339sw8b+xTlaUDDFNWXsksAwCiXJdwe/zPvfHN 5gYK5jbf2G+sYO4YPXATVtzLuPEWMQOlytI2HnT+dKKiO/mV5wI0k/BHpINpy328KS MOEHlfieKKMw7Oi1eu793mWfDzV9eXzmYlNS4alhnDO4f83g3CnFixvxmouDej5Gm5 OqQ7h2+DRqSSQ== Date: Sat, 28 Dec 2019 05:28:00 -0000 From: George Barrett To: gdb-patches@sourceware.org Subject: [PING**2] [PATCH] Fix handling of null stap semaphores Message-ID: References: <5we87igzwt5_kr.5b-38floyexzwmozuj6vb-.hmx8r4u3r41_sy@mail.bob131.so> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SW-Source: 2019-12/txt/msg01051.txt.bz2 On Thu, Dec 19, 2019 at 04:20:50AM +1100, George Barrett wrote: > Ping > > On Wed, Dec 04, 2019 at 06:59:25AM +1100, George Barrett wrote: > > According to the SystemTap documentation on user-space probes[0], stap > > probe points without semaphores are denoted by setting the semaphore > > address in the probe's note to zero. At present the code does do a > > comparison of the semaphore address against zero, but only after it's > > been relocated; as such it will (almost?) always fail, commonly > > resulting in GDB trying to overwrite the ELF magic located at the > > image's base address. > > > > This commit tests the address as specified in the SDT note rather than > > the relocated value in order to correctly detect absent probe > > semaphores. > > > > [0]: https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation > > > > gdb/Changelog: > > > > * stap-probe.c: Fix handling of null stap semaphores > > --- > > gdb/stap-probe.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c > > index ba927790a5..e5e3cceacd 100644 > > --- a/gdb/stap-probe.c > > +++ b/gdb/stap-probe.c > > @@ -1425,9 +1425,6 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch) > > struct type *type = builtin_type (gdbarch)->builtin_unsigned_short; > > ULONGEST value; > > > > - if (address == 0) > > - return; > > - > > /* Swallow errors. */ > > if (target_read_memory (address, bytes, TYPE_LENGTH (type)) != 0) > > { > > @@ -1461,6 +1458,8 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch) > > void > > stap_probe::set_semaphore (struct objfile *objfile, struct gdbarch *gdbarch) > > { > > + if (m_sem_addr == 0) > > + return; > > stap_modify_semaphore (relocate_address (m_sem_addr, objfile), 1, gdbarch); > > } > > > > @@ -1469,6 +1468,8 @@ stap_probe::set_semaphore (struct objfile *objfile, struct gdbarch *gdbarch) > > void > > stap_probe::clear_semaphore (struct objfile *objfile, struct gdbarch *gdbarch) > > { > > + if (m_sem_addr == 0) > > + return; > > stap_modify_semaphore (relocate_address (m_sem_addr, objfile), 0, gdbarch); > > } > > > > -- > > 2.23.0