[PATCH 2/3] Make mcontext and stack information available to signal handlers
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue Mar 31 18:46:00 GMT 2015
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20150331/76b7e431/attachment.sig>
More information about the Cygwin-patches
mailing list