Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81719 - in branches/release: boost/context libs/context libs/context/build libs/context/doc libs/context/src libs/context/src/asm
From: oliver.kowalke_at_[hidden]
Date: 2012-12-05 03:48:50


Author: olli
Date: 2012-12-05 03:48:49 EST (Wed, 05 Dec 2012)
New Revision: 81719
URL: http://svn.boost.org/trac/boost/changeset/81719

Log:
context: merge from trunk

Added:
   branches/release/libs/context/src/unsupported.cpp
      - copied unchanged from r81718, /trunk/libs/context/src/unsupported.cpp
Removed:
   branches/release/libs/context/src/seh.cpp
Properties modified:
   branches/release/boost/context/ (props changed)
   branches/release/libs/context/ (props changed)
Text files modified:
   branches/release/libs/context/build/Jamfile.v2 | 24 ++++++++++--------------
   branches/release/libs/context/doc/acknowledgements.qbk | 9 +++++----
   branches/release/libs/context/doc/fcontext.qbk | 6 ++++--
   branches/release/libs/context/src/asm/jump_i386_ms_pe_masm.asm | 2 --
   branches/release/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm | 15 +++++++--------
   branches/release/libs/context/src/asm/make_i386_ms_pe_masm.asm | 34 ++++++++++++++++++++++++++--------
   branches/release/libs/context/src/asm/make_x86_64_ms_pe_masm.asm | 12 ++++++------
   branches/release/libs/context/src/asm/make_x86_64_sysv_macho_gas.S | 1 -
   8 files changed, 58 insertions(+), 45 deletions(-)

Modified: branches/release/libs/context/build/Jamfile.v2
==============================================================================
--- branches/release/libs/context/build/Jamfile.v2 (original)
+++ branches/release/libs/context/build/Jamfile.v2 2012-12-05 03:48:49 EST (Wed, 05 Dec 2012)
@@ -281,8 +281,7 @@
    ;
 
 alias asm_context_sources
- : seh.cpp
- asm/make_i386_ms_pe_masm.asm
+ : asm/make_i386_ms_pe_masm.asm
      asm/jump_i386_ms_pe_masm.asm
    : <abi>ms
      <address-model>32
@@ -293,8 +292,7 @@
    ;
 
 alias asm_context_sources
- : seh.cpp
- asm/make_i386_ms_pe_masm.asm
+ : asm/make_i386_ms_pe_masm.asm
      asm/jump_i386_ms_pe_masm.asm
    : <abi>ms
      <address-model>32
@@ -305,8 +303,7 @@
    ;
 
 alias asm_context_sources
- : seh.cpp
- [ make asm/make_i386_ms_pe_masm.o : asm/make_i386_ms_pe_masm.asm : @masm ]
+ : [ make asm/make_i386_ms_pe_masm.o : asm/make_i386_ms_pe_masm.asm : @masm ]
      [ make asm/jump_i386_ms_pe_masm.o : asm/jump_i386_ms_pe_masm.asm : @masm ]
    : <abi>ms
      <address-model>32
@@ -388,8 +385,7 @@
    ;
 
 alias asm_context_sources
- : seh.cpp
- asm/make_x86_64_ms_pe_masm.asm
+ : asm/make_x86_64_ms_pe_masm.asm
      asm/jump_x86_64_ms_pe_masm.asm
    : <abi>ms
      <address-model>64
@@ -400,8 +396,7 @@
    ;
 
 alias asm_context_sources
- : seh.cpp
- asm/make_x86_64_ms_pe_masm.asm
+ : asm/make_x86_64_ms_pe_masm.asm
      asm/jump_x86_64_ms_pe_masm.asm
    : <abi>ms
      <address-model>64
@@ -412,8 +407,7 @@
    ;
 
 alias asm_context_sources
- : seh.cpp
- [ make asm/make_x86_64_ms_pe_masm.o : asm/make_x86_64_ms_pe_masm.asm : @masm64 ]
+ : [ make asm/make_x86_64_ms_pe_masm.o : asm/make_x86_64_ms_pe_masm.asm : @masm64 ]
      [ make asm/jump_x86_64_ms_pe_masm.o : asm/jump_x86_64_ms_pe_masm.asm : @masm64 ]
    : <abi>ms
      <address-model>64
@@ -422,6 +416,10 @@
      <target-os>windows
    ;
 
+alias asm_context_sources
+ : unsupported.cpp
+ ;
+
 explicit asm_context_sources ;
 
 alias select_asm_context_sources
@@ -430,8 +428,6 @@
     [ architecture.address-model ]
   ;
 
-explicit context_sources ;
-
 lib boost_context
    : select_asm_context_sources
    : <link>shared:<define>BOOST_CONTEXT_DYN_LINK=1

Modified: branches/release/libs/context/doc/acknowledgements.qbk
==============================================================================
--- branches/release/libs/context/doc/acknowledgements.qbk (original)
+++ branches/release/libs/context/doc/acknowledgements.qbk 2012-12-05 03:48:49 EST (Wed, 05 Dec 2012)
@@ -7,9 +7,10 @@
 
 [section:acknowledgements Acknowledgments]
 
-I'd like to thank Adreas Fett, Artyom Beilis, Daniel Larimer, Fernando Pelliccioni,
-Giovanni Piero Deretta, Gordon Woodhull, Helge Bahmann, Holger Grund,
-Jeffrey Lee Hellrung (Jr.), Keith Jeffery, Phil Endecott, Robert Stewart,
-Steven Watanabe, Vicente J. Botet Escriba, Wayne Piekarski.
+I'd like to thank Adreas Fett, Artyom Beilis, Daniel Larimer, David Deakins,
+Fernando Pelliccioni, Giovanni Piero Deretta, Gordon Woodhull, Helge Bahmann,
+Holger Grund, Jeffrey Lee Hellrung (Jr.), Keith Jeffery, Phil Endecott,
+Robert Stewart, Sergey Cheban, Steven Watanabe, Vicente J. Botet Escriba,
+Wayne Piekarski.
 
 [endsect]

Modified: branches/release/libs/context/doc/fcontext.qbk
==============================================================================
--- branches/release/libs/context/doc/fcontext.qbk (original)
+++ branches/release/libs/context/doc/fcontext.qbk 2012-12-05 03:48:49 EST (Wed, 05 Dec 2012)
@@ -168,14 +168,16 @@
 
 [heading Exceptions in __context_fn__]
 
-If the __context_fn__ emits an exception, the application will terminate.
+If the __context_fn__ emits an exception, the behaviour is undefined.
+
+[important __context_fn__ should wrap the code in a try/catch block.]
 
 
 [heading Preserving floating point registers]
 
 Preserving the floating point registers increases the cycle count for a context
 switch (see performance tests).
-The foruth argument of __jump_fcontext__ controls if fpu registers should be
+The fourth argument of __jump_fcontext__ controls if fpu registers should be
 preserved by the context jump.
 
 [important The use of the fpu controlling argument of __jump_fcontext__ must

Modified: branches/release/libs/context/src/asm/jump_i386_ms_pe_masm.asm
==============================================================================
--- branches/release/libs/context/src/asm/jump_i386_ms_pe_masm.asm (original)
+++ branches/release/libs/context/src/asm/jump_i386_ms_pe_masm.asm 2012-12-05 03:48:49 EST (Wed, 05 Dec 2012)
@@ -43,8 +43,6 @@
 .386
 .XMM
 .model flat, c
-_exit PROTO, value:SDWORD
-seh_fcontext PROTO, except:DWORD, frame:DWORD, context:DWORD, dispatch:DWORD
 .code
 
 jump_fcontext PROC EXPORT

Modified: branches/release/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm
==============================================================================
--- branches/release/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm (original)
+++ branches/release/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm 2012-12-05 03:48:49 EST (Wed, 05 Dec 2012)
@@ -49,44 +49,43 @@
 ; ----------------------------------------------------------------------------------
 ; | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
 ; ----------------------------------------------------------------------------------
-; | 0x90 | 0x94 | 0x98 | 0x9c | 0x100 | 0x104 | 0x108 | 0x10c |
+; | 0x90 | 0x94 | 0x98 | 0x9c | 0xa0 | 0xa4 | 0xa8 | 0xac |
 ; ----------------------------------------------------------------------------------
 ; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
 ; | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
 ; ----------------------------------------------------------------------------------
-; | 0x110 | 0x114 | 0x118 | 0x11c | 0x120 | 0x124 | 0x128 | 0x12c |
+; | 0xb0 | 0xb4 | 0xb8 | 0xbc | 0xc0 | 0xc4 | 0xc8 | 0xcc |
 ; ----------------------------------------------------------------------------------
 ; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
+; | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
 ; ----------------------------------------------------------------------------------
-; | 0x130 | 0x134 | 0x138 | 0x13c| 0x140 | 0x144 | 0x148 | 0x14c |
+; | 0xd0 | 0xd4 | 0xd8 | 0xdc | 0xe0 | 0xe4 | 0xe8 | 0xec |
 ; ----------------------------------------------------------------------------------
 ; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
 ; | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
 ; ----------------------------------------------------------------------------------
-; | 0x150 | 0x154 | 0x158 | 0x15c | 0x160 | 0x164 | 0x168 | 0x16c |
+; | 0xf0 | 0xf4 | 0xf8 | 0xfc | 0x100 | 0x104 | 0x108 | 0x10c |
 ; ----------------------------------------------------------------------------------
 ; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
 ; | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
 ; ----------------------------------------------------------------------------------
-; | 0x170 | 0x174 | 0x178 | 0x17c | 0x180 | 0x184 | 0x188 | 0x18c |
+; | 0x110 | 0x114 | 0x118 | 0x11c | 0x120 | 0x124 | 0x128 | 0x12c |
 ; ----------------------------------------------------------------------------------
 ; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 
 EXTERN _exit:PROC ; standard C library function
-EXTERN seh_fcontext:PROC ; exception handler
 .code
 
-jump_fcontext PROC EXPORT FRAME:seh_fcontext
+jump_fcontext PROC EXPORT FRAME
     .endprolog
 
     mov [rcx], r12 ; save R12

Modified: branches/release/libs/context/src/asm/make_i386_ms_pe_masm.asm
==============================================================================
--- branches/release/libs/context/src/asm/make_i386_ms_pe_masm.asm (original)
+++ branches/release/libs/context/src/asm/make_i386_ms_pe_masm.asm 2012-12-05 03:48:49 EST (Wed, 05 Dec 2012)
@@ -44,7 +44,6 @@
 .XMM
 .model flat, c
 _exit PROTO, value:SDWORD
-seh_fcontext PROTO, except:DWORD, frame:DWORD, context:DWORD, dispatch:DWORD
 .code
 
 make_fcontext PROC EXPORT
@@ -53,7 +52,7 @@
 
     ; shift address in EAX to lower 16 byte boundary
     ; == pointer to fcontext_t and address of context stack
- and eax, -16
+ and eax, -16
 
     mov ecx, [esp+04h] ; load 1. arg of make_fcontext, pointer to context stack (base)
     mov [eax+018h], ecx ; save address of context stack (base) in fcontext_t
@@ -71,17 +70,36 @@
     lea edx, [eax-01ch] ; reserve space for last frame and seh on context stack, (ESP - 0x4) % 16 == 0
     mov [eax+010h], edx ; save address in EDX as stack pointer for context function
 
- mov ecx, seh_fcontext ; set ECX to exception-handler
- mov [edx+018h], ecx ; save ECX as SEH handler
+ mov ecx, finish ; abs address of finish
+ mov [edx], ecx ; save address of finish as return address for context function
+ ; entered after context function returns
+
+ ; traverse current seh chain to get the last exception handler installed by Windows
+ ; note that on Windows Server 2008 and 2008 R2, SEHOP is activated by default
+ ; the exception handler chain is tested for the presence of ntdll.dll!FinalExceptionHandler
+ ; at its end by RaiseException all seh andlers are disregarded if not present and the
+ ; program is aborted
+ assume fs:nothing
+ mov ecx, fs:[018h] ; load NT_TIB into ECX
+ assume fs:error
+
+walk:
+ mov edx, [ecx] ; load 'next' member of current SEH into EDX
+ inc edx ; test if 'next' of current SEH is last (== 0xffffffff)
+ jz found
+ dec edx
+ xchg edx, ecx ; exchange content; ECX contains address of next SEH
+ jmp walk ; inspect next SEH
+
+found:
+ mov ecx, [ecx+04h] ; load 'handler' member of SEH == address of last SEH handler installed by Windows
+ mov edx, [eax+010h] ; load address of stack pointer for context function
+ mov [edx+018h], ecx ; save address in ECX as SEH handler for context
     mov ecx, 0ffffffffh ; set ECX to -1
     mov [edx+014h], ecx ; save ECX as next SEH item
     lea ecx, [edx+014h] ; load address of next SEH item
     mov [eax+024h], ecx ; save next SEH
 
- mov ecx, finish ; abs address of finish
- mov [edx], ecx ; save address of finish as return address for context function
- ; entered after context function returns
-
     ret
 
 finish:

Modified: branches/release/libs/context/src/asm/make_x86_64_ms_pe_masm.asm
==============================================================================
--- branches/release/libs/context/src/asm/make_x86_64_ms_pe_masm.asm (original)
+++ branches/release/libs/context/src/asm/make_x86_64_ms_pe_masm.asm 2012-12-05 03:48:49 EST (Wed, 05 Dec 2012)
@@ -49,35 +49,35 @@
 ; ----------------------------------------------------------------------------------
 ; | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
 ; ----------------------------------------------------------------------------------
-; | 0x90 | 0x94 | 0x98 | 0x9c | 0x100 | 0x104 | 0x108 | 0x10c |
+; | 0x90 | 0x94 | 0x98 | 0x9c | 0xa0 | 0xa4 | 0xa8 | 0xac |
 ; ----------------------------------------------------------------------------------
 ; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
 ; | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
 ; ----------------------------------------------------------------------------------
-; | 0x110 | 0x114 | 0x118 | 0x11c | 0x120 | 0x124 | 0x128 | 0x12c |
+; | 0xb0 | 0xb4 | 0xb8 | 0xbc | 0xc0 | 0xc4 | 0xc8 | 0xcc |
 ; ----------------------------------------------------------------------------------
 ; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
+; | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
 ; ----------------------------------------------------------------------------------
-; | 0x130 | 0x134 | 0x138 | 0x13c| 0x140 | 0x144 | 0x148 | 0x14c |
+; | 0xd0 | 0xd4 | 0xd8 | 0xdc | 0xe0 | 0xe4 | 0xe8 | 0xec |
 ; ----------------------------------------------------------------------------------
 ; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
 ; | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
 ; ----------------------------------------------------------------------------------
-; | 0x150 | 0x154 | 0x158 | 0x15c | 0x160 | 0x164 | 0x168 | 0x16c |
+; | 0xf0 | 0xf4 | 0xf8 | 0xfc | 0x100 | 0x104 | 0x108 | 0x10c |
 ; ----------------------------------------------------------------------------------
 ; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
 ; | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
 ; ----------------------------------------------------------------------------------
-; | 0x170 | 0x174 | 0x178 | 0x17c | 0x180 | 0x184 | 0x188 | 0x18c |
+; | 0x110 | 0x114 | 0x118 | 0x11c | 0x120 | 0x124 | 0x128 | 0x12c |
 ; ----------------------------------------------------------------------------------
 ; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------

Modified: branches/release/libs/context/src/asm/make_x86_64_sysv_macho_gas.S
==============================================================================
--- branches/release/libs/context/src/asm/make_x86_64_sysv_macho_gas.S (original)
+++ branches/release/libs/context/src/asm/make_x86_64_sysv_macho_gas.S 2012-12-05 03:48:49 EST (Wed, 05 Dec 2012)
@@ -69,4 +69,3 @@
     /* RSP points to same address as RSP on entry of context function + 0x8 */
     xorq %rdi, %rdi /* exit code is zero */
     call __exit /* exit application */
-

Deleted: branches/release/libs/context/src/seh.cpp
==============================================================================
--- branches/release/libs/context/src/seh.cpp 2012-12-05 03:48:49 EST (Wed, 05 Dec 2012)
+++ (empty file)
@@ -1,92 +0,0 @@
-
-// Copyright Oliver Kowalke 2009.
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#define BOOST_CONTEXT_SOURCE
-
-extern "C" {
-
-#include <stddef.h>
-#include <stdio.h>
-
-#include <excpt.h>
-#include <windows.h>
-#include <winnt.h>
-
-#if defined(_MSC_VER)
-# define SNPRINTF _snprintf
-#else
-# define SNPRINTF snprintf
-#endif
-
-#if defined(_MSC_VER)
-# pragma warning(push)
-# pragma warning(disable:4996)
-# endif
-
-static const char * exception_description(
- _EXCEPTION_RECORD const* record, char * description, size_t len)
-{
- const DWORD code = record->ExceptionCode;
- const ULONG_PTR * info = record->ExceptionInformation;
-
- switch ( code)
- {
- case EXCEPTION_ACCESS_VIOLATION:
- {
- const char * accessType = ( info[0]) ? "writing" : "reading";
- const ULONG_PTR address = info[1];
- SNPRINTF( description, len, "Access violation %s %p", accessType, reinterpret_cast< void * >( address) );
- return description;
- }
- case EXCEPTION_DATATYPE_MISALIGNMENT: return "Datatype misalignment";
- case EXCEPTION_BREAKPOINT: return "Breakpoint";
- case EXCEPTION_SINGLE_STEP: return "Single step";
- case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: return "Array bounds exceeded";
- case EXCEPTION_FLT_DENORMAL_OPERAND: return "FPU denormal operand";
- case EXCEPTION_FLT_DIVIDE_BY_ZERO: return "FPU divide by zero";
- case EXCEPTION_FLT_INEXACT_RESULT: return "FPU inexact result";
- case EXCEPTION_FLT_INVALID_OPERATION: return "FPU invalid operation";
- case EXCEPTION_FLT_OVERFLOW: return "FPU overflow";
- case EXCEPTION_FLT_STACK_CHECK: return "FPU stack check";
- case EXCEPTION_FLT_UNDERFLOW: return "FPU underflow";
- case EXCEPTION_INT_DIVIDE_BY_ZERO: return "Integer divide by zero";
- case EXCEPTION_INT_OVERFLOW: return "Integer overflow";
- case EXCEPTION_PRIV_INSTRUCTION: return "Privileged instruction";
- case EXCEPTION_IN_PAGE_ERROR: return "In page error";
- case EXCEPTION_ILLEGAL_INSTRUCTION: return "Illegal instruction";
- case EXCEPTION_NONCONTINUABLE_EXCEPTION: return "Noncontinuable exception";
- case EXCEPTION_STACK_OVERFLOW: return "Stack overflow";
- case EXCEPTION_INVALID_DISPOSITION: return "Invalid disposition";
- case EXCEPTION_GUARD_PAGE: return "Guard page";
- case EXCEPTION_INVALID_HANDLE: return "Invalid handle";
- }
-
- SNPRINTF( description, len, "Unknown (0x%08lX)", code);
- return description;
-}
-
-EXCEPTION_DISPOSITION seh_fcontext(
- struct _EXCEPTION_RECORD * record,
- void *,
- struct _CONTEXT *,
- void *)
-{
- char description[255];
-
- fprintf( stderr, "exception: %s (%08lX)\n",
- exception_description( record, description, sizeof( description) ),
- record->ExceptionCode);
-
- ExitProcess( -1);
-
- return ExceptionContinueSearch; // never reached
-}
-
-# if defined(BOOST_MSVC)
-# pragma warning(pop)
-# endif
-
-}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk