public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH 2/3] Make mcontext and stack information available to signal handlers
Date: Tue, 31 Mar 2015 18:46:00 -0000	[thread overview]
Message-ID: <20150331184642.GB15852@calimero.vinschen.de> (raw)
In-Reply-To: <1427824014-19504-3-git-send-email-jon.turney@dronecode.org.uk>

[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]

On Mar 31 18:46, 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.
> 
> XXX: How do we indicate context information is not available (si_cyg == NULL)

If si_cyg is NULL, fetch the current context via RtlCaptureContext.

Two minor nits.  With the outlined changes, ok to apply.

> +      if (thissi.si_cyg)
> +        {
> +          memcpy (&context.uc_mcontext, ((cygwin_exception *)thissi.si_cyg)->context(), sizeof(CONTEXT));
> +        }
> +

At this point, please add a FIXME comment rambling along about
having to tweak this code when we implement sigaltstack.

> +      context.uc_stack.ss_sp = NtCurrentTeb ()->Tib.StackBase;
> +      context.uc_stack.ss_flags = 0;
> +      if (!NtCurrentTeb ()->DeallocationStack)
> +        context.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->Tib.StackLimit - (uintptr_t)NtCurrentTeb ()->Tib.StackBase;
> +      else
> +        context.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->DeallocationStack - (uintptr_t)NtCurrentTeb ()->Tib.StackBase;
> +
> +#ifndef _SYS_UCONTEXT_H_
> +#define _SYS_UCONTEXT_H_
> +
> +#include <cygwin/signal.h>
> +#include <sys/signal.h>

Just include <signal.h> as on Linux, unless there's a really good reason.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-03-31 18:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-31 17:47 [PATCH 0/3] Make detailled exception " Jon TURNEY
2015-03-31 17:47 ` [PATCH 2/3] Make mcontext and stack " Jon TURNEY
2015-03-31 18:46   ` Corinna Vinschen [this message]
2015-03-31 17:47 ` [PATCH 1/3] Rename struct ucontext to struct __mcontext Jon TURNEY
2015-03-31 18:37   ` Corinna Vinschen
2015-03-31 17:47 ` [PATCH 3/3] Add cygwin_internal() operation to convert siginfo_t * to EXCEPTION_RECORD * Jon TURNEY
2015-03-31 19:11   ` Corinna Vinschen
2015-03-31 19:02 ` [PATCH 0/3] Make detailled exception information available to signal handlers 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=20150331184642.GB15852@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --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).