mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-27 16:51:06 -07:00
New modulefile prmcw3.c avoids duplication of code between prmcw3i3.c and prmcw3i6.c.
Implement MutatorContextCheck on Windows. Add AVERT(MutatorContext, context) in PoolAccess and other functions. Document initialization functions MutatorContextInitFault and MutatorContextInitThread and implement them on Windows. Add a union discriminator to MutatorContextStruct on Windows so that we don't accidentally try to get the stack pointer from a fault context, or the exception address from a thread context. Copied from Perforce Change: 192567 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
4457a77a07
commit
1a04431cff
18 changed files with 242 additions and 86 deletions
|
|
@ -213,6 +213,7 @@
|
|||
#include "vmw3.c" /* Windows virtual memory */
|
||||
#include "protw3.c" /* Windows protection */
|
||||
#include "prmci3.c" /* 32-bit Intel mutator context decoding */
|
||||
#include "prmcw3.c" /* Windows mutator context */
|
||||
#include "prmcw3i3.c" /* Windows on 32-bit Intel mutator context */
|
||||
#include "ssw3i3mv.c" /* Windows on 32-bit Intel stack scan for Microsoft C */
|
||||
#include "spw3i3.c" /* Windows on 32-bit Intel stack probe */
|
||||
|
|
@ -227,6 +228,7 @@
|
|||
#include "vmw3.c" /* Windows virtual memory */
|
||||
#include "protw3.c" /* Windows protection */
|
||||
#include "prmci6.c" /* 64-bit Intel mutator context decoding */
|
||||
#include "prmcw3.c" /* Windows mutator context */
|
||||
#include "prmcw3i6.c" /* Windows on 64-bit Intel mutator context */
|
||||
#include "ssw3i6mv.c" /* Windows on 64-bit Intel stack scan for Microsoft C */
|
||||
#include "spw3i6.c" /* Windows on 64-bit Intel stack probe */
|
||||
|
|
@ -241,6 +243,7 @@
|
|||
#include "vmw3.c" /* Windows virtual memory */
|
||||
#include "protw3.c" /* Windows protection */
|
||||
#include "prmci3.c" /* 32-bit Intel mutator context decoding */
|
||||
#include "prmcw3.c" /* Windows mutator context */
|
||||
#include "prmcw3i3.c" /* Windows on 32-bit Intel mutator context */
|
||||
#include "ssw3i3pc.c" /* Windows on 32-bit stack scan for Pelles C */
|
||||
#include "spw3i3.c" /* 32-bit Intel stack probe */
|
||||
|
|
@ -255,6 +258,7 @@
|
|||
#include "vmw3.c" /* Windows virtual memory */
|
||||
#include "protw3.c" /* Windows protection */
|
||||
#include "prmci6.c" /* 64-bit Intel mutator context decoding */
|
||||
#include "prmcw3.c" /* Windows mutator context */
|
||||
#include "prmcw3i6.c" /* Windows on 64-bit Intel mutator context */
|
||||
#include "ssw3i6pc.c" /* Windows on 64-bit stack scan for Pelles C */
|
||||
#include "spw3i6.c" /* 64-bit Intel stack probe */
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ Res PoolAccess(Pool pool, Seg seg, Addr addr,
|
|||
AVER(SegBase(seg) <= addr);
|
||||
AVER(addr < SegLimit(seg));
|
||||
AVERT(AccessSet, mode);
|
||||
/* Can't check MutatorContext as there is no check method (job003957) */
|
||||
AVERT(MutatorContext, context);
|
||||
|
||||
return Method(Pool, pool, access)(pool, seg, addr, mode, context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ Res PoolNoAccess(Pool pool, Seg seg, Addr addr,
|
|||
AVER(SegBase(seg) <= addr);
|
||||
AVER(addr < SegLimit(seg));
|
||||
AVERT(AccessSet, mode);
|
||||
/* can't check context as there is no Check method */
|
||||
AVERT(MutatorContext, context);
|
||||
UNUSED(mode);
|
||||
UNUSED(context);
|
||||
|
||||
|
|
@ -454,7 +454,7 @@ Res PoolSegAccess(Pool pool, Seg seg, Addr addr,
|
|||
AVER(addr < SegLimit(seg));
|
||||
AVER(SegPool(seg) == pool);
|
||||
AVERT(AccessSet, mode);
|
||||
/* can't check context as there is no Check method */
|
||||
AVERT(MutatorContext, context);
|
||||
|
||||
UNUSED(addr);
|
||||
UNUSED(context);
|
||||
|
|
@ -490,7 +490,7 @@ Res PoolSingleAccess(Pool pool, Seg seg, Addr addr,
|
|||
AVER(addr < SegLimit(seg));
|
||||
AVER(SegPool(seg) == pool);
|
||||
AVERT(AccessSet, mode);
|
||||
/* can't check context as there is no Check method */
|
||||
AVERT(MutatorContext, context);
|
||||
|
||||
arena = PoolArena(pool);
|
||||
|
||||
|
|
|
|||
|
|
@ -1116,7 +1116,8 @@ static Res AWLAccess(Pool pool, Seg seg, Addr addr,
|
|||
AVER(addr < SegLimit(seg));
|
||||
AVER(SegPool(seg) == pool);
|
||||
AVERT(AccessSet, mode);
|
||||
|
||||
AVERT(MutatorContext, context);
|
||||
|
||||
/* Attempt scanning a single reference if permitted */
|
||||
if(AWLCanTrySingleAccess(PoolArena(pool), awl, seg, addr)) {
|
||||
res = PoolSingleAccess(pool, seg, addr, mode, context);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,14 @@
|
|||
|
||||
#define MutatorContextSig ((Sig)0x519302C0) /* SIGnature MUTator COntext */
|
||||
|
||||
enum {
|
||||
MutatorContextFAULT, /* Context of thread stopped by protection fault. */
|
||||
MutatorContextTHREAD, /* Context of thread stopped by thread manager. */
|
||||
MutatorContextLIMIT
|
||||
};
|
||||
|
||||
typedef unsigned MutatorContextVar;
|
||||
|
||||
extern Bool MutatorContextCheck(MutatorContext context);
|
||||
extern Bool MutatorContextCanStepInstruction(MutatorContext context);
|
||||
extern Res MutatorContextStepInstruction(MutatorContext context);
|
||||
|
|
|
|||
137
mps/code/prmcw3.c
Normal file
137
mps/code/prmcw3.c
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/* prmcw3.c: MUTATOR CONTEXT FOR WIN32
|
||||
*
|
||||
* $Id$
|
||||
* Copyright (c) 2016 Ravenbrook Limited. See end of file for license.
|
||||
*
|
||||
* .purpose: Implement the mutator context module. See <design/prmc/>.
|
||||
*
|
||||
*
|
||||
* ASSUMPTIONS
|
||||
*
|
||||
* .context.regroots: The root registers are assumed to be recorded in
|
||||
* the context at word-aligned boundaries.
|
||||
*
|
||||
* .context.flags: The ContextFlags field in the CONTEXT structure
|
||||
* determines what is recorded by GetThreadContext. This must include:
|
||||
*
|
||||
* .context.sp: CONTEXT_CONTROL, so that the stack pointer (Esp on
|
||||
* IA-32; Rsp on x86-64) is recorded.
|
||||
*
|
||||
* .context.regroots: CONTEXT_INTEGER, so that the root registers
|
||||
* (Edi, Esi, Ebx, Edx, Ecx, Eax on IA-32; Rdi, Rsi, Rbx, Rbp, Rdx,
|
||||
* Rcx, Rax, R8, ..., R15 on x86-64) are recorded.
|
||||
*
|
||||
* See the header WinNT.h for documentation of CONTEXT and
|
||||
* ContextFlags.
|
||||
*/
|
||||
|
||||
#include "prmcw3.h"
|
||||
|
||||
SRCID(prmcw3, "$Id$");
|
||||
|
||||
#if !defined(MPS_OS_W3)
|
||||
#error "prmcw3.c is specific to MPS_OS_W3"
|
||||
#endif
|
||||
|
||||
|
||||
Bool MutatorContextCheck(MutatorContext context)
|
||||
{
|
||||
CHECKS(MutatorContext, context);
|
||||
CHECKL(NONNEGATIVE(context->var));
|
||||
CHECKL(context->var < MutatorContextLIMIT);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Res MutatorContextInitThread(MutatorContext context, HANDLE thread)
|
||||
{
|
||||
BOOL success;
|
||||
|
||||
AVER(context != NULL);
|
||||
|
||||
context->var = MutatorContextTHREAD;
|
||||
/* This dumps the relevant registers into the context */
|
||||
/* .context.flags */
|
||||
context->the.context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER;
|
||||
success = GetThreadContext(thread, &context->the.context);
|
||||
if (!success)
|
||||
return ResFAIL;
|
||||
context->sig = MutatorContextSig;
|
||||
|
||||
AVERT(MutatorContext, context);
|
||||
return ResOK;
|
||||
}
|
||||
|
||||
|
||||
void MutatorContextInitFault(MutatorContext context,
|
||||
LPEXCEPTION_POINTERS ep)
|
||||
{
|
||||
AVER(context != NULL);
|
||||
AVER(ep != NULL);
|
||||
|
||||
context->var = MutatorContextFAULT;
|
||||
context->the.ep = ep;
|
||||
context->sig = MutatorContextSig;
|
||||
|
||||
AVERT(MutatorContext, context);
|
||||
}
|
||||
|
||||
|
||||
Res MutatorContextScan(ScanState ss, MutatorContext context,
|
||||
mps_area_scan_t scan_area, void *closure)
|
||||
{
|
||||
CONTEXT *cx;
|
||||
Res res;
|
||||
|
||||
AVERT(ScanState, ss);
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextTHREAD);
|
||||
|
||||
cx = &context->the.context;
|
||||
res = TraceScanArea(ss, (Word *)cx, (Word *)((char *)cx + sizeof *cx),
|
||||
scan_area, closure); /* .context.regroots */
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/* C. COPYRIGHT AND LICENSE
|
||||
*
|
||||
* Copyright (C) 2001-2016 Ravenbrook Limited <http://www.ravenbrook.com/>.
|
||||
* All rights reserved. This is an open source license. Contact
|
||||
* Ravenbrook for commercial licensing options.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Redistributions in any form must be accompanied by information on how
|
||||
* to obtain complete source code for this software and any accompanying
|
||||
* software that uses this software. The source code must either be
|
||||
* included in the distribution or be available for no more than the cost
|
||||
* of distribution plus a nominal fee, and must be freely redistributable
|
||||
* under reasonable conditions. For an executable file, complete source
|
||||
* code means the source code for all modules it contains. It does not
|
||||
* include source code for modules or files that typically accompany the
|
||||
* major components of the operating system on which the executable file
|
||||
* runs.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* prmcw3.h: PROTECTION FOR WIN32
|
||||
/* prmcw3.h: MUTATOR CONTEXT FOR WIN32
|
||||
*
|
||||
* $Id$
|
||||
* Copyright (c) 2001-2016 Ravenbrook Limited. See end of file for license.
|
||||
|
|
@ -9,17 +9,20 @@
|
|||
#ifndef prmcw3_h
|
||||
#define prmcw3_h
|
||||
|
||||
|
||||
#include "mpm.h"
|
||||
|
||||
#include "mpswin.h"
|
||||
|
||||
|
||||
typedef struct MutatorContextStruct {
|
||||
CONTEXT context; /* Thread context. */
|
||||
LPEXCEPTION_POINTERS ep; /* Windows Exception Pointers */
|
||||
Sig sig; /* <design/sig/> */
|
||||
MutatorContextVar var; /* Union discriminator */
|
||||
union {
|
||||
LPEXCEPTION_POINTERS ep; /* Windows Exception Pointers */
|
||||
CONTEXT context; /* Thread context */
|
||||
} the;
|
||||
} MutatorContextStruct;
|
||||
|
||||
extern Res MutatorContextInitThread(MutatorContext context, HANDLE thread);
|
||||
extern void MutatorContextInitFault(MutatorContext context, LPEXCEPTION_POINTERS ep);
|
||||
|
||||
#endif /* prmcw3_h */
|
||||
|
||||
|
|
|
|||
|
|
@ -17,14 +17,9 @@
|
|||
* .assume.regref: The registers in the context can be modified by
|
||||
* storing into an MRef pointer.
|
||||
*
|
||||
* .assume.regroots: The root registers (Edi, Esi, Ebx, Edx, Ecx, Eax)
|
||||
* are stored in the CONTEXT data structure and are stored at
|
||||
* word-aligned addresses. This requires CONTEXT_INTEGER to be set in
|
||||
* ContextFlags when GetThreadContext is called.
|
||||
*
|
||||
* .assume.sp: The stack pointer is stored in CONTEXT.Esp. This
|
||||
* requires CONTEXT_CONTROL to be set in ContextFlags when
|
||||
* GetThreadContext is called.
|
||||
* GetThreadContext is called (see <code/prmcw3.c>).
|
||||
*/
|
||||
|
||||
#include "prmcw3.h"
|
||||
|
|
@ -44,10 +39,12 @@ MRef Prmci3AddressHoldingReg(MutatorContext context, unsigned int regnum)
|
|||
{
|
||||
PCONTEXT wincont;
|
||||
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextFAULT);
|
||||
AVER(NONNEGATIVE(regnum));
|
||||
AVER(regnum <= 7);
|
||||
|
||||
wincont = context->ep->ContextRecord;
|
||||
wincont = context->the.ep->ContextRecord;
|
||||
|
||||
switch (regnum) {
|
||||
case 0: return (MRef)&wincont->Eax;
|
||||
|
|
@ -72,14 +69,19 @@ void Prmci3DecodeFaultContext(MRef *faultmemReturn, Byte **insvecReturn,
|
|||
{
|
||||
LPEXCEPTION_RECORD er;
|
||||
|
||||
er = context->ep->ExceptionRecord;
|
||||
AVER(faultmemReturn != NULL);
|
||||
AVER(insvecReturn != NULL);
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextFAULT);
|
||||
|
||||
er = context->the.ep->ExceptionRecord;
|
||||
|
||||
/* Assert that this is an access violation. The computation of */
|
||||
/* faultmem depends on this. */
|
||||
/* faultmemReturn depends on this. */
|
||||
AVER(er->ExceptionCode == EXCEPTION_ACCESS_VIOLATION);
|
||||
|
||||
*faultmemReturn = (MRef)er->ExceptionInformation[1];
|
||||
*insvecReturn = (Byte*)context->ep->ContextRecord->Eip;
|
||||
*insvecReturn = (Byte*)context->the.ep->ContextRecord->Eip;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -87,26 +89,19 @@ void Prmci3DecodeFaultContext(MRef *faultmemReturn, Byte **insvecReturn,
|
|||
|
||||
void Prmci3StepOverIns(MutatorContext context, Size inslen)
|
||||
{
|
||||
context->ep->ContextRecord->Eip += (DWORD)inslen;
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextFAULT);
|
||||
|
||||
context->the.ep->ContextRecord->Eip += (DWORD)inslen;
|
||||
}
|
||||
|
||||
|
||||
Addr MutatorContextSP(MutatorContext context)
|
||||
{
|
||||
return (Addr)context->context.Esp; /* .assume.sp */
|
||||
}
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextTHREAD);
|
||||
|
||||
|
||||
Res MutatorContextScan(ScanState ss, MutatorContext context,
|
||||
mps_area_scan_t scan_area, void *closure)
|
||||
{
|
||||
CONTEXT *cx;
|
||||
Res res;
|
||||
|
||||
cx = &context->context;
|
||||
res = TraceScanArea(ss, (Word *)cx, (Word *)((char *)cx + sizeof *cx),
|
||||
scan_area, closure); /* .assume.regroots */
|
||||
return res;
|
||||
return (Addr)context->the.context.Esp; /* .assume.sp */
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,6 @@
|
|||
* .assume.regref: The registers in the context can be modified by
|
||||
* storing into an MRef pointer.
|
||||
*
|
||||
* .assume.regroots: The root registers (Rdi, Rsi, Rbx, Rbp, Rdx, Rcx,
|
||||
* Rax, R8, ..., R15) are stored in the CONTEXT data structure and are
|
||||
* stored at word-aligned addresses. This requires CONTEXT_INTEGER to
|
||||
* be set in ContextFlags when GetThreadContext is called.
|
||||
*
|
||||
* .assume.sp: The stack pointer is stored in CONTEXT.Rsp. This
|
||||
* requires CONTEXT_CONTROL to be set in ContextFlags when
|
||||
* GetThreadContext is called.
|
||||
|
|
@ -42,10 +37,12 @@ MRef Prmci6AddressHoldingReg(MutatorContext context, unsigned int regnum)
|
|||
{
|
||||
PCONTEXT wincont;
|
||||
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextFAULT);
|
||||
AVER(NONNEGATIVE(regnum));
|
||||
AVER(regnum <= 16);
|
||||
|
||||
wincont = context->ep->ContextRecord;
|
||||
wincont = context->the.ep->ContextRecord;
|
||||
|
||||
switch (regnum) {
|
||||
case 0: return (MRef)&wincont->Rax;
|
||||
|
|
@ -78,14 +75,19 @@ void Prmci6DecodeFaultContext(MRef *faultmemReturn, Byte **insvecReturn,
|
|||
{
|
||||
LPEXCEPTION_RECORD er;
|
||||
|
||||
er = context->ep->ExceptionRecord;
|
||||
AVER(faultmemReturn != NULL);
|
||||
AVER(insvecReturn != NULL);
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextFAULT);
|
||||
|
||||
er = context->the.ep->ExceptionRecord;
|
||||
|
||||
/* Assert that this is an access violation. The computation of */
|
||||
/* faultmem depends on this. */
|
||||
AVER(er->ExceptionCode == EXCEPTION_ACCESS_VIOLATION);
|
||||
|
||||
*faultmemReturn = (MRef)er->ExceptionInformation[1];
|
||||
*insvecReturn = (Byte*)context->ep->ContextRecord->Rip;
|
||||
*insvecReturn = (Byte*)context->the.ep->ContextRecord->Rip;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -93,26 +95,19 @@ void Prmci6DecodeFaultContext(MRef *faultmemReturn, Byte **insvecReturn,
|
|||
|
||||
void Prmci6StepOverIns(MutatorContext context, Size inslen)
|
||||
{
|
||||
context->ep->ContextRecord->Rip += (DWORD64)inslen;
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextFAULT);
|
||||
|
||||
context->the.ep->ContextRecord->Rip += (DWORD64)inslen;
|
||||
}
|
||||
|
||||
|
||||
Addr MutatorContextSP(MutatorContext context)
|
||||
{
|
||||
return (Addr)context->context.Rsp; /* .assume.sp */
|
||||
}
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextTHREAD);
|
||||
|
||||
|
||||
Res MutatorContextScan(ScanState ss, MutatorContext context,
|
||||
mps_area_scan_t scan_area, void *closure)
|
||||
{
|
||||
CONTEXT *cx;
|
||||
Res res;
|
||||
|
||||
cx = &context->context;
|
||||
res = TraceScanArea(ss, (Word *)cx, (Word *)((char *)cx + sizeof *cx),
|
||||
scan_area, closure); /* .assume.regroots */
|
||||
return res;
|
||||
return (Addr)context->the.context.Rsp; /* .assume.sp */
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,8 @@
|
|||
* Copyright (c) 2001-2016 Ravenbrook Limited. See end of file for license.
|
||||
*/
|
||||
|
||||
#include "mpm.h"
|
||||
/* prmcw3.h needed to share MutatorContextStruct declation */
|
||||
/* with <code/prmcw3i3.c> */
|
||||
#include "prmcw3.h"
|
||||
#include "vm.h"
|
||||
#include "vm.h" /* PageSize */
|
||||
|
||||
#ifndef MPS_OS_W3
|
||||
#error "protw3.c is Win32-specific, but MPS_OS_W3 is not set"
|
||||
|
|
@ -53,8 +50,8 @@ LONG WINAPI ProtSEHfilter(LPEXCEPTION_POINTERS info)
|
|||
|
||||
if(er->ExceptionCode != EXCEPTION_ACCESS_VIOLATION)
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
||||
context.ep = info;
|
||||
|
||||
MutatorContextInitFault(&context, info);
|
||||
|
||||
/* assert that the exception is continuable */
|
||||
/* Note that Microsoft say that this field should be 0 or */
|
||||
|
|
|
|||
|
|
@ -50,16 +50,6 @@
|
|||
* CloseHandle
|
||||
* SuspendThread
|
||||
* ResumeThread
|
||||
* CONTEXT
|
||||
* CONTEXT_CONTROL | CONTEXT_INTEGER
|
||||
* GetThreadContext
|
||||
*
|
||||
* .context: ContextFlags determine what is recorded by
|
||||
* GetThreadContext. This should be set to whichever bits of the
|
||||
* context that need to be recorded. This should include:
|
||||
* .context.sp: sp assumed to be recorded by CONTEXT_CONTROL.
|
||||
* .context.regroots: assumed to be recorded by CONTEXT_INTEGER.
|
||||
* see winnt.h for description of CONTEXT and ContextFlags.
|
||||
*/
|
||||
|
||||
#include "mpm.h"
|
||||
|
|
@ -279,18 +269,13 @@ Res ThreadScan(ScanState ss, Thread thread, Word *stackCold,
|
|||
|
||||
if (id != thread->id) { /* .thread.id */
|
||||
MutatorContextStruct context;
|
||||
BOOL success;
|
||||
Word *stackBase, *stackLimit;
|
||||
Addr stackPtr;
|
||||
|
||||
/* scan stack and register roots in other threads */
|
||||
|
||||
/* This dumps the relevant registers into the context */
|
||||
/* .context.flags */
|
||||
context.context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER;
|
||||
/* .thread.handle.get-context */
|
||||
success = GetThreadContext(thread->handle, &context.context);
|
||||
if (!success) {
|
||||
res = MutatorContextInitThread(&context, thread->handle);
|
||||
if (res != ResOK) {
|
||||
/* .error.get-context */
|
||||
/* We assume that the thread must have been destroyed. */
|
||||
/* We ignore the situation by returning immediately. */
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ MPMPF = \
|
|||
[lockw3] \
|
||||
[mpsiw3] \
|
||||
[prmci3] \
|
||||
[prmcw3] \
|
||||
[prmcw3i3] \
|
||||
[protw3] \
|
||||
[spw3i3] \
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ MPMPF = \
|
|||
[lockw3] \
|
||||
[mpsiw3] \
|
||||
[prmci3] \
|
||||
[prmcw3] \
|
||||
[prmcw3i3] \
|
||||
[protw3] \
|
||||
[spw3i3] \
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ MPMPF = \
|
|||
[lockw3] \
|
||||
[mpsiw3] \
|
||||
[prmci6] \
|
||||
[prmcw3] \
|
||||
[prmcw3i6] \
|
||||
[protw3] \
|
||||
[spw3i6] \
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# w3i6pc.nmk: NMAKE FILE FOR WINDOWS/x64/PELLES C
|
||||
#
|
||||
# $Id: //info.ravenbrook.com/project/mps/branch/2014-03-21/pellesc/code/w3i6pc.nmk#1 $
|
||||
# $Id$
|
||||
# Copyright (c) 2001-2016 Ravenbrook Limited. See end of file for license.
|
||||
|
||||
PFM = w3i6pc
|
||||
|
|
@ -13,6 +13,7 @@ MPMPF = \
|
|||
[lockw3] \
|
||||
[mpsiw3] \
|
||||
[prmci6] \
|
||||
[prmcw3] \
|
||||
[prmcw3i6] \
|
||||
[protw3] \
|
||||
[spw3i6] \
|
||||
|
|
|
|||
|
|
@ -74,6 +74,18 @@ collection to work. See design.mps.thread-manager.if.scan_.)
|
|||
Interface
|
||||
---------
|
||||
|
||||
``typedef unsigned MutatorContextVar``
|
||||
|
||||
_`.if.var`: The type ``MutatorContextVar`` is the type of the
|
||||
discriminator for the union within ``MutatorContextStruct``:
|
||||
|
||||
======================== ================================================
|
||||
Value Description
|
||||
======================== ================================================
|
||||
``MutatorContextFAULT`` Context of thread stopped by a protection fault.
|
||||
``MutatorContextTHREAD`` Context of thread stopped by the thread manager.
|
||||
======================== ================================================
|
||||
|
||||
``typedef MutatorContextStruct *MutatorContext``
|
||||
|
||||
_`.if.context`: A structure representing the context of the mutator at
|
||||
|
|
@ -91,6 +103,20 @@ design.mps.check_.
|
|||
|
||||
.. _design.mps.check: check
|
||||
|
||||
``Res MutatorContextInitFault(MutatorContext context, ...)``
|
||||
|
||||
_`.if.init.thread`: Initialize with the context of the mutator at the
|
||||
point where it was stopped by a protection fault. The arguments are
|
||||
platform-specific and the return may be ``void`` instead of ``Res`` if
|
||||
this always succeeds.
|
||||
|
||||
``Res MutatorContextInitThread(MutatorContext context, ...)``
|
||||
|
||||
_`.if.init.thread`: Initialize with the context of the mutator at the
|
||||
point where it was suspended by the thread manager. The arguments are
|
||||
platform-specific and the return may be ``void`` instead of ``Res`` if
|
||||
this always succeeds.
|
||||
|
||||
``Bool MutatorContextCanStepInstruction(MutatorContext context)``
|
||||
|
||||
_`.if.canstep`: Examine the context to determine whether the
|
||||
|
|
|
|||
|
|
@ -175,6 +175,7 @@ prmcix.c Mutator context implementation for POSIX.
|
|||
prmcix.h Mutator context interface for POSIX.
|
||||
prmclii3.c Mutator context implementation for Linux, IA-32.
|
||||
prmclii6.c Mutator context implementation for Linux, x86-64.
|
||||
prmcw3.c Mutator context implementation for Windows.
|
||||
prmcw3.h Mutator context interface for Windows.
|
||||
prmcw3i3.c Mutator context implementation for Windows, IA-32.
|
||||
prmcw3i6.c Mutator context implementation for Windows, x86-64.
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ TYPES = '''
|
|||
Arena Attr Bool BootBlock BT Buffer BufferMode Byte Chain Chunk
|
||||
Clock Compare Count Epoch EventClock FindDelete Format Fun GenDesc
|
||||
Globals Index Land LD Lock LocusPref LocusPrefKind Message
|
||||
MessageType MutatorContext Page Pointer Pool PoolGen PThreadext
|
||||
Range Rank RankSet ReadonlyAddr Ref RefSet Res Ring Root RootMode
|
||||
RootVar ScanState Seg SegBuf Serial Shift Sig Size Space SplayNode
|
||||
SplayTree StackContext Thread Trace TraceId TraceSet TraceStartWhy
|
||||
TraceState ULongest VM Word ZoneSet
|
||||
MessageType MutatorContext MutatorContextVar Page Pointer Pool
|
||||
PoolGen PThreadext Range Rank RankSet ReadonlyAddr Ref RefSet Res
|
||||
Ring Root RootMode RootVar ScanState Seg SegBuf Serial Shift Sig
|
||||
Size Space SplayNode SplayTree StackContext Thread Trace TraceId
|
||||
TraceSet TraceStartWhy TraceState ULongest VM Word ZoneSet
|
||||
|
||||
'''
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue