mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-03-26 08:41:47 -07:00
Add discriminator to mutatorcontextstruct and implement mutatorcontextinitfault and mutatorcontextinitthread on os x.
Copied from Perforce Change: 192572 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
d38c74a0b2
commit
bcd592b96b
6 changed files with 36 additions and 9 deletions
|
|
@ -24,19 +24,39 @@ SRCID(prmcxc, "$Id$");
|
|||
Bool MutatorContextCheck(MutatorContext context)
|
||||
{
|
||||
CHECKS(MutatorContext, context);
|
||||
CHECKL(sizeof *context->threadState == sizeof(THREAD_STATE_S));
|
||||
CHECKL(NONNEGATIVE(context->var));
|
||||
CHECKL(context->var < MutatorContextLIMIT);
|
||||
CHECKL((context->var == MutatorContextTHREAD) == (context->address == NULL));
|
||||
CHECKL(context->threadState != NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void MutatorContextInit(MutatorContext context, Addr address,
|
||||
THREAD_STATE_S *threadState)
|
||||
void MutatorContextInitFault(MutatorContext context, Addr address,
|
||||
THREAD_STATE_S *threadState)
|
||||
{
|
||||
AVER(context != NULL);
|
||||
AVER(address != NULL);
|
||||
AVER(threadState != NULL);
|
||||
|
||||
context->var = MutatorContextFAULT;
|
||||
context->address = address;
|
||||
context->threadState = threadState;
|
||||
context->sig = MutatorContextSig;
|
||||
|
||||
AVERT(MutatorContext, context);
|
||||
}
|
||||
|
||||
|
||||
void MutatorContextInitThread(MutatorContext context,
|
||||
THREAD_STATE_S *threadState)
|
||||
{
|
||||
AVER(context != NULL);
|
||||
AVER(threadState != NULL);
|
||||
|
||||
context->address = address;
|
||||
AVER(sizeof *context->threadState == sizeof(THREAD_STATE_S));
|
||||
context->var = MutatorContextTHREAD;
|
||||
context->address = NULL;
|
||||
context->threadState = threadState;
|
||||
context->sig = MutatorContextSig;
|
||||
|
||||
|
|
@ -50,7 +70,9 @@ Res MutatorContextScan(ScanState ss, MutatorContext context,
|
|||
THREAD_STATE_S *mc;
|
||||
Res res;
|
||||
|
||||
AVERT(ScanState, ss);
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextTHREAD);
|
||||
|
||||
/* This scans the root registers (.context.regroots). It also
|
||||
unnecessarily scans the rest of the context. The optimisation
|
||||
|
|
|
|||
|
|
@ -16,13 +16,16 @@
|
|||
|
||||
typedef struct MutatorContextStruct {
|
||||
Sig sig; /* <design/sig/> */
|
||||
Addr address;
|
||||
MutatorContextVar var; /* Discriminator. */
|
||||
Addr address; /* Fault address, if stopped by protection
|
||||
* fault; NULL if stopped by thread manager. */
|
||||
THREAD_STATE_S *threadState;
|
||||
/* FIXME: Might need to get the floats in case the compiler stashes
|
||||
intermediate values in them. */
|
||||
} MutatorContextStruct;
|
||||
|
||||
extern void MutatorContextInit(MutatorContext context, Addr address, THREAD_STATE_S *threadState);
|
||||
extern void MutatorContextInitFault(MutatorContext context, Addr address, THREAD_STATE_S *threadState);
|
||||
extern void MutatorContextInitThread(MutatorContext context, THREAD_STATE_S *threadState);
|
||||
|
||||
#endif /* prmcxc_h */
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ void Prmci3DecodeFaultContext(MRef *faultmemReturn,
|
|||
AVER(faultmemReturn != NULL);
|
||||
AVER(insvecReturn != NULL);
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextFAULT);
|
||||
|
||||
*faultmemReturn = (MRef)context->address;
|
||||
*insvecReturn = (Byte*)context->threadState->__eip;
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ void Prmci6DecodeFaultContext(MRef *faultmemReturn,
|
|||
AVER(faultmemReturn != NULL);
|
||||
AVER(insvecReturn != NULL);
|
||||
AVERT(MutatorContext, context);
|
||||
AVER(context->var == MutatorContextFAULT);
|
||||
|
||||
*faultmemReturn = (MRef)context->address;
|
||||
*insvecReturn = (Byte*)context->threadState->__rip;
|
||||
|
|
|
|||
|
|
@ -238,8 +238,8 @@ static void protCatchOne(void)
|
|||
|
||||
/* The cast via Word suppresses "cast to pointer from integer of
|
||||
different size" warnings in GCC, for the XCI3GC build. */
|
||||
MutatorContextInit(&context, (Addr)(Word)request.code[1],
|
||||
(void *)request.old_state);
|
||||
MutatorContextInitFault(&context, (Addr)(Word)request.code[1],
|
||||
(void *)request.old_state);
|
||||
|
||||
if (ArenaAccess(context.address,
|
||||
AccessREAD | AccessWRITE,
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ Res ThreadScan(ScanState ss, Thread thread, Word *stackCold,
|
|||
order to assert that the thread is suspended, but it's probably
|
||||
unnecessary and is a lot of work to check a static condition. */
|
||||
|
||||
MutatorContextInit(&context, NULL, &threadState);
|
||||
MutatorContextInitThread(&context, &threadState);
|
||||
|
||||
count = THREAD_STATE_COUNT;
|
||||
AVER(sizeof(*context.threadState) == count * sizeof(natural_t));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue