From: Jon TURNEY <jon.turney@dronecode.org.uk>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH 2/3] Provide ucontext to signal handlers
Date: Thu, 23 Apr 2015 13:53:00 -0000 [thread overview]
Message-ID: <5538F94A.3080402@dronecode.org.uk> (raw)
In-Reply-To: <551C2CB7.4@dronecode.org.uk>
[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]
On 01/04/2015 18:36, Jon TURNEY wrote:
> On 01/04/2015 15:22, Corinna Vinschen wrote:
>> On Apr 1 14:19, Jon TURNEY wrote:
>>> Add ucontext.h header, defining ucontext_t and mcontext_t types.
>>>
>>> Provide sigaction sighandlers with a ucontext_t parameter, containing
>>> stack and
>>> context information.
>>>
>>> * include/sys/ucontext.h : New header.
>>> * include/ucontext.h : Ditto.
>>> * exceptions.cc (call_signal_handler): Provide ucontext_t
>>> parameter to signal handler function.
>>
>> Patch is ok with a single change: Please add a "FIXME?" comment to:
>>
>> else
>> RtlCaptureContext();
>>
>> On second thought, calling RtlCaptureContext here is probably wrong.
>>
>> What we really need is the context of the thread when calling
>> call_signal_handler I think.
>
> I had the same thought, but this is going to be quite tricky to achieve.
>> It would be better to call RtlCaptureContext
>> before calling call_signal_handler. But this requires a change in how
>> call_signal_handler is called.
>>
>> We should discuss this at one point, I think.
I noticed that we already prepare a context for continuing after the
signal for the debugger, so perhaps this is not quite as complex as I
thought and something like the attached is needed.
It's very hard to reason about if this is doing the right thing when the
signal is delivered across threads, though.
[-- Attachment #2: 0001-Use-the-same-continuation-context-in-a-signal-as-we-.patch --]
[-- Type: text/plain, Size: 1694 bytes --]
From d6385aa66e26e86832e1e95222e8026146bb63df Mon Sep 17 00:00:00 2001
From: Jon TURNEY <jon.turney@dronecode.org.uk>
Date: Thu, 23 Apr 2015 14:45:05 +0100
Subject: [PATCH] Use the same continuation context in a signal as we would
send to the debugger
---
winsup/cygwin/exceptions.cc | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 4a6c21e..c97cc19 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -1503,12 +1503,7 @@ _cygtls::call_signal_handler ()
if (thissi.si_cyg)
memcpy (&context.uc_mcontext, ((cygwin_exception *)thissi.si_cyg)->context(), sizeof(CONTEXT));
else
- {
- /* FIXME: Really this should be the context which the signal interrupted? */
- memset(&context.uc_mcontext, 0, sizeof(struct __mcontext));
- context.uc_mcontext.ctxflags = CONTEXT_FULL;
- RtlCaptureContext ((CONTEXT *)&context.uc_mcontext);
- }
+ memcpy (&context.uc_mcontext, &thread_context, sizeof(CONTEXT));
/* FIXME: If/when sigaltstack is implemented, this will need to do
something more complicated */
@@ -1549,9 +1544,10 @@ void
_cygtls::signal_debugger (siginfo_t& si)
{
HANDLE th;
- /* If si.si_cyg is set then the signal was already sent to the debugger. */
+ /* If si.si_cyg is set then the signal was caused by an exception which has
+ already been sent to the debugger. */
if (isinitialized () && !si.si_cyg && (th = (HANDLE) *this)
- && being_debugged () && SuspendThread (th) >= 0)
+ && SuspendThread (th) >= 0)
{
CONTEXT c;
c.ContextFlags = CONTEXT_FULL;
--
2.1.4
next prev parent reply other threads:[~2015-04-23 13:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-01 13:20 [PATCH 0/3] Make detailed exception information available to signal handlers (v4) Jon TURNEY
2015-04-01 13:20 ` [PATCH 2/3] Provide ucontext to signal handlers Jon TURNEY
2015-04-01 14:22 ` Corinna Vinschen
2015-04-01 17:37 ` Jon TURNEY
2015-04-01 17:53 ` Corinna Vinschen
2015-04-23 13:53 ` Jon TURNEY [this message]
2015-04-23 15:32 ` Corinna Vinschen
2015-04-03 22:09 ` Jon TURNEY
2015-04-04 8:40 ` Corinna Vinschen
2015-04-04 16:06 ` Jon TURNEY
2015-04-05 16:58 ` Jon TURNEY
2015-04-07 10:17 ` Corinna Vinschen
2015-04-01 13:20 ` [PATCH 1/3] Rename struct ucontext to struct __mcontext Jon TURNEY
2015-04-01 14:01 ` Corinna Vinschen
2015-04-01 13:20 ` [PATCH 3/3] Add cygwin_internal() operation to retrieve the EXCEPTION_RECORD from a siginfo_t * Jon TURNEY
2015-04-01 14:23 ` Corinna Vinschen
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=5538F94A.3080402@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--cc=cygwin-patches@cygwin.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).