This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/3] Make mcontext and stack information available to signal handlers


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: pgpZom39VeB1_.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]