public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: George Barrett <bob@bob131.so>
To: gdb-patches@sourceware.org
Subject: [PING**2] [PATCH] Fix handling of null stap semaphores
Date: Sat, 28 Dec 2019 05:28:00 -0000	[thread overview]
Message-ID: <v6nx3ree0369t9c8tkvy2vp2&1rbg1r.u2a46s2mn931c8i_xo.t@mail.bob131.so> (raw)
In-Reply-To: <mubccjid2gvckqpr&9pjaaagwoontycq0bnb/yfeuw8yvktsnskt@mail.bob131.so>

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

  reply	other threads:[~2019-12-28  5:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03 19:59 George Barrett
2019-12-18 17:20 ` [PING] " George Barrett
2019-12-28  5:28   ` George Barrett [this message]
2019-12-29 18:58 ` Simon Marchi
2019-12-30 15:38   ` George Barrett
2019-12-30 17:59     ` Simon Marchi
2019-12-31  4:39       ` George Barrett
2019-12-31 17:37         ` Simon Marchi
2019-12-31 17:59           ` George Barrett
2019-12-31 17:56   ` Simon Marchi

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='v6nx3ree0369t9c8tkvy2vp2&1rbg1r.u2a46s2mn931c8i_xo.t@mail.bob131.so' \
    --to=bob@bob131.so \
    --cc=gdb-patches@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).