diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 0537eea9e..65adef564 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2015-07-17 Corinna Vinschen + + * exceptions.cc (getcontext/x86_64): Drop comment on RtlCaptureContext. + (swapcontext/x86_64): Fix comment yet again. + (getcontext/i686): Move comment from x86_64 getcontext, slightly + rearranged, to preceeding comment. + 2015-07-17 Corinna Vinschen * exceptions.cc (__unwind_single_frame): Move up in file to be diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 7e10ba927..6e9890e32 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1886,11 +1886,6 @@ getcontext (ucontext_t *ucp) PCONTEXT ctx = (PCONTEXT) &ucp->uc_mcontext; ctx->ContextFlags = CONTEXT_FULL; RtlCaptureContext (ctx); - /* Amazing, but true: On 32 bit, RtlCaptureContext returns the context - matching the caller of getcontext, so all we have to do is call it. - On 64 bit, RtlCaptureContext returns the exact context of its own - caller, so we have to unwind virtually by a single frame to get the - context of the caller of getcontext. */ __unwind_single_frame (ctx); /* Successful getcontext is supposed to return 0. If we don't set rax to 0 here, there's a chance that code like this: @@ -1911,8 +1906,8 @@ swapcontext (ucontext_t *oucp, const ucontext_t *ucp) PCONTEXT ctx = (PCONTEXT) &oucp->uc_mcontext; ctx->ContextFlags = CONTEXT_FULL; RtlCaptureContext (ctx); - /* See comments in getcontext. */ __unwind_single_frame (ctx); + /* See comment in getcontext. */ oucp->uc_mcontext.rax = 0; oucp->uc_sigmask = oucp->uc_mcontext.oldmask = _my_tls.sigmask; return setcontext (ucp); @@ -1941,6 +1936,11 @@ __cont_link_context: \n\ the callee-saved registers, especially $ebx, are not changed by the calling function. If so, makecontext/__cont_link_context would be broken. + Amazing, but true: While on 64 bit RtlCaptureContext returns the exact + context of its own caller, as expected, on 32 bit RtlCaptureContext returns + the context of the callers caller. So while we have to unwind another frame + on 64 bit, we can skip this step on 32 bit. + Both functions are split into the first half in assembler, and the second half in C to allow easy access to _my_tls. */