Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <kettenis@chello.nl>
To: eliz@elta.co.il
Cc: gdb@sources.redhat.com
Subject: Re: [RFC] Non-executable stack on SPARC
Date: Mon, 26 Jan 2004 12:42:00 -0000	[thread overview]
Message-ID: <200401261242.i0QCgUoB026534@elgar.kettenis.dyndns.org> (raw)
In-Reply-To: <uad4b2odj.fsf@elta.co.il> (message from Eli Zaretskii on 26 Jan 2004 08:52:08 +0200)

   Date: 26 Jan 2004 08:52:08 +0200
   From: Eli Zaretskii <eliz@elta.co.il>

   > Date: Mon, 26 Jan 2004 00:50:11 +0100 (CET)
   > From: Mark Kettenis <kettenis@chello.nl>
   > 
   > A while ago, I established that getting inferior function calls on
   > SPARC working with a non-executable stack is remarkably simple.  Just
   > acknowledging that breakpoint instructions may cause SIGSEGV, as per
   > the attached patch, is enough.  However, some people were afraid that
   > blindly applying this patch might cause some problems on other
   > targets.

   I think I've located the past discussion you refer to here:

     http://sources.redhat.com/ml/gdb-patches/2003-10/msg00500.html

   If that's the one, and there was no other discussions except the
   thread started by the above message, then I must agree with the fears
   that blindly accepting SIGSEGV as a sign of a breakpoint might not be
   a good idea for all targets.  Perhaps I'm missing something, but one
   scenario that frightens me is that the inferior function causes a real
   SIGSEGV--how will GDB handle that with your patch applied?  (Sorry, I
   cannot test this myself where I'm typing this.)  For that matter,
   what's to prevent a ``normal'' SIGSEGV, due to a bug in the inferior's
   normal thread of execution, from passing this test and being treated
   as a breakpoint during inferior function being run by GDB?

Yup, it's the one.  And I agree that there is a risk, and therefore I
don't want to treat SIGSEGV that way on all targets.  With my patch,
or with the suggestions I made below, GDB will usually still see
SIGSEG under normal circumstances.  GDB will only convert such a
signal into SIGTRAP if there's a breakpoint inserted at the point
where the inferior stopped.  The question is what happens when somehow
the program generates a SIGSEGV at a location very close to the point
where we've inserted a breakpoint.  Michael suggested that my patch
would do the wrong thing if the SIGSEGV generating instruction and the
breakpoint instruction are contained within the same instruction
bundle on a VLIW machine.  There might be problems on machines with
some sort of deferred trap mechanism too.

   > I think there are two alternatives:
   > 
   > 1. Only check for SIGSEGV if the target in question uses "ON_STACK"
   >    for its call_dummy_location.
   > 
   > 2. Add a new method to the architecture vector to check whether a
   >    particular signal may have been the result of a breakpoint
   >    instruction.  Suggested name & signature:
   > 
   >    int breakpoint_signal_p (struct gdbarch *gdbarch, int signal)
   > 
   > Preferences?

   I think 2) might be hard on some targets, so I like 1) better.  But
   I'd like to see if there's a better alternative, like if an affected
   target would convert SIGSEGV to SIGTRAP in this case, so we don't need
   to involve the application level of GDB.

Let me clarify 2) first.  My only intention is that the
breakpoint_signal_p() method would return non-zero for all signals
that could be caused by hitting a breakpoint, i.e. SIGILL and SIGEMT
by default, and SIGILL, SIGEMT and SIGSEGV for the particular case of
SPARC.

As to punting the SIGSEGV to SIGTRAP conversion to the architecture:
we could do this in target_wait() or target_wait_hook(), but that
would offload it to the target we're running on and not to the
architecture.

Mark


  reply	other threads:[~2004-01-26 12:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-25 23:50 Mark Kettenis
2004-01-25 23:59 ` Daniel Jacobowitz
2004-01-26  6:51   ` Eli Zaretskii
2004-01-26  6:51 ` Eli Zaretskii
2004-01-26 12:42   ` Mark Kettenis [this message]
2004-01-27  8:16     ` Eli Zaretskii
2004-02-01 17:48       ` Mark Kettenis
2004-02-01 20:13         ` Eli Zaretskii
2004-02-02 18:37           ` Andrew Cagney
2004-01-26 16:21 ` Andrew Cagney
2004-01-27  8:00   ` Eli Zaretskii
2004-02-01 17:54   ` Mark Kettenis
2004-02-02 18:27     ` Andrew Cagney

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=200401261242.i0QCgUoB026534@elgar.kettenis.dyndns.org \
    --to=kettenis@chello.nl \
    --cc=eliz@elta.co.il \
    --cc=gdb@sources.redhat.com \
    /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