server: Set the context flags in get_thread_context to indicate which
parts of the returned context are valid.
diff --git a/server/context_i386.c b/server/context_i386.c
index c2a985b..1d90482 100644
--- a/server/context_i386.c
+++ b/server/context_i386.c
@@ -147,6 +147,7 @@
context->SegFs = regs.fs;
context->SegGs = regs.gs;
}
+ context->ContextFlags |= flags & CONTEXT_FULL;
}
if (flags & CONTEXT_DEBUG_REGISTERS)
{
@@ -156,6 +157,7 @@
if (get_debug_reg( pid, 3, &context->Dr3 ) == -1) goto error;
if (get_debug_reg( pid, 6, &context->Dr6 ) == -1) goto error;
if (get_debug_reg( pid, 7, &context->Dr7 ) == -1) goto error;
+ context->ContextFlags |= CONTEXT_DEBUG_REGISTERS;
}
if (flags & CONTEXT_FLOATING_POINT)
{
@@ -163,6 +165,7 @@
/* correct structure (the same as fsave/frstor) */
if (ptrace( PTRACE_GETFPREGS, pid, 0, &context->FloatSave ) == -1) goto error;
context->FloatSave.Cr0NpxState = 0; /* FIXME */
+ context->ContextFlags |= CONTEXT_FLOATING_POINT;
}
return;
error:
@@ -263,6 +266,7 @@
context->SegFs = regs.r_fs & 0xffff;
context->SegGs = regs.r_gs & 0xffff;
}
+ context->ContextFlags |= flags & CONTEXT_FULL;
}
if (flags & CONTEXT_DEBUG_REGISTERS)
{
@@ -274,6 +278,7 @@
/* correct structure (the same as fsave/frstor) */
if (ptrace( PTRACE_GETFPREGS, pid, (int) &context->FloatSave, 0 ) == -1) goto error;
context->FloatSave.Cr0NpxState = 0; /* FIXME */
+ context->ContextFlags |= CONTEXT_FLOATING_POINT;
}
return;
error:
@@ -371,6 +376,7 @@
context->SegFs = regs.r_fs & 0xffff;
context->SegGs = regs.r_gs & 0xffff;
}
+ context->ContextFlags |= flags & CONTEXT_FULL;
}
if (flags & CONTEXT_DEBUG_REGISTERS)
{
@@ -394,7 +400,7 @@
context->Dr6 = dbregs.dr6;
context->Dr7 = dbregs.dr7;
#endif
-
+ context->ContextFlags |= CONTEXT_DEBUG_REGISTERS;
#endif
}
if (flags & CONTEXT_FLOATING_POINT)
@@ -403,6 +409,7 @@
/* correct structure (the same as fsave/frstor) */
if (ptrace( PTRACE_GETFPREGS, pid, (caddr_t) &context->FloatSave, 0 ) == -1) goto error;
context->FloatSave.Cr0NpxState = 0; /* FIXME */
+ context->ContextFlags |= CONTEXT_FLOATING_POINT;
}
return;
error:
@@ -494,7 +501,7 @@
/* copy a context structure according to the flags */
-static void copy_context( CONTEXT *to, const CONTEXT *from, int flags )
+static void copy_context( CONTEXT *to, const CONTEXT *from, unsigned int flags )
{
if (flags & CONTEXT_CONTROL)
{
@@ -527,6 +534,7 @@
}
/* we don't bother copying the debug registers, since they */
/* always need to be accessed by ptrace anyway */
+ to->ContextFlags |= flags & ~CONTEXT_DEBUG_REGISTERS;
}
/* retrieve the current instruction pointer of a thread */
@@ -574,6 +582,7 @@
/* retrieve the thread context */
void get_thread_context( struct thread *thread, CONTEXT *context, unsigned int flags )
{
+ context->ContextFlags |= CONTEXT_i386;
flags &= ~CONTEXT_i386; /* get rid of CPU id */
if (thread->context) /* thread is inside an exception event or suspended */