mirror of
https://github.com/reactos/reactos.git
synced 2025-06-25 17:09:43 +00:00
- Commit a fix for KDBG's attach to process problem.
See issue #1263 for more details. svn path=/trunk/; revision=27348
This commit is contained in:
parent
57f28d6036
commit
ffce5f4f66
1 changed files with 34 additions and 12 deletions
|
@ -168,6 +168,29 @@ KdbpKdbTrapFrameToTrapFrame(PKDB_KTRAP_FRAME KdbTrapFrame, PKTRAP_FRAME TrapFram
|
||||||
/* FIXME: copy v86 registers if TrapFrame is a V86 trapframe */
|
/* FIXME: copy v86 registers if TrapFrame is a V86 trapframe */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC VOID
|
||||||
|
KdbpKdbTrapFrameFromKernelStack(PVOID KernelStack,
|
||||||
|
PKDB_KTRAP_FRAME KdbTrapFrame)
|
||||||
|
{
|
||||||
|
ULONG_PTR *StackPtr;
|
||||||
|
|
||||||
|
RtlZeroMemory(KdbTrapFrame, sizeof(KDB_KTRAP_FRAME));
|
||||||
|
StackPtr = (ULONG_PTR *) KernelStack;
|
||||||
|
KdbTrapFrame->Tf.Ebp = StackPtr[3];
|
||||||
|
KdbTrapFrame->Tf.Edi = StackPtr[4];
|
||||||
|
KdbTrapFrame->Tf.Esi = StackPtr[5];
|
||||||
|
KdbTrapFrame->Tf.Ebx = StackPtr[6];
|
||||||
|
KdbTrapFrame->Tf.Eip = StackPtr[7];
|
||||||
|
KdbTrapFrame->Tf.HardwareEsp = (ULONG) (StackPtr + 8);
|
||||||
|
KdbTrapFrame->Tf.HardwareSegSs = KGDT_R0_DATA;
|
||||||
|
KdbTrapFrame->Tf.SegCs = KGDT_R0_CODE;
|
||||||
|
KdbTrapFrame->Tf.SegDs = KGDT_R0_DATA;
|
||||||
|
KdbTrapFrame->Tf.SegEs = KGDT_R0_DATA;
|
||||||
|
KdbTrapFrame->Tf.SegGs = KGDT_R0_DATA;
|
||||||
|
|
||||||
|
/* FIXME: what about the other registers??? */
|
||||||
|
}
|
||||||
|
|
||||||
/*!\brief Overwrites the instruction at \a Address with \a NewInst and stores
|
/*!\brief Overwrites the instruction at \a Address with \a NewInst and stores
|
||||||
* the old instruction in *OldInst.
|
* the old instruction in *OldInst.
|
||||||
*
|
*
|
||||||
|
@ -1040,7 +1063,8 @@ KdbpAttachToThread(
|
||||||
if (KdbCurrentThread != KdbOriginalThread)
|
if (KdbCurrentThread != KdbOriginalThread)
|
||||||
{
|
{
|
||||||
ASSERT(KdbCurrentTrapFrame == &KdbThreadTrapFrame);
|
ASSERT(KdbCurrentTrapFrame == &KdbThreadTrapFrame);
|
||||||
KdbpKdbTrapFrameToTrapFrame(KdbCurrentTrapFrame, KdbCurrentThread->Tcb.TrapFrame);
|
/* Actually, we can't save the context, there's no guarantee that there
|
||||||
|
* was a trap frame */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1050,12 +1074,13 @@ KdbpAttachToThread(
|
||||||
/* Switch to the thread's context */
|
/* Switch to the thread's context */
|
||||||
if (Thread != KdbOriginalThread)
|
if (Thread != KdbOriginalThread)
|
||||||
{
|
{
|
||||||
if (Thread->Tcb.TrapFrame == NULL)
|
/* The thread we're attaching to isn't the thread on which we entered
|
||||||
{
|
* kdb and so the thread we're attaching to is not running. There
|
||||||
KdbpPrint("Threads TrapFrame is NULL! Cannot attach.\n");
|
* is no guarantee that it actually has a trap frame. So we have to
|
||||||
return FALSE;
|
* peek directly at the registers which were saved on the stack when the
|
||||||
}
|
* thread was preempted in the scheduler */
|
||||||
KdbpTrapFrameToKdbTrapFrame(Thread->Tcb.TrapFrame, &KdbThreadTrapFrame);
|
KdbpKdbTrapFrameFromKernelStack(Thread->Tcb.KernelStack,
|
||||||
|
&KdbThreadTrapFrame);
|
||||||
KdbCurrentTrapFrame = &KdbThreadTrapFrame;
|
KdbCurrentTrapFrame = &KdbThreadTrapFrame;
|
||||||
}
|
}
|
||||||
else /* Switching back to original thread */
|
else /* Switching back to original thread */
|
||||||
|
@ -1529,11 +1554,8 @@ KdbEnterDebuggerException(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save the current thread's trapframe */
|
/* We can't update the current thread's trapframe 'cause it might not
|
||||||
if (KdbCurrentTrapFrame == &KdbThreadTrapFrame)
|
have one */
|
||||||
{
|
|
||||||
KdbpKdbTrapFrameToTrapFrame(KdbCurrentTrapFrame, KdbCurrentThread->Tcb.TrapFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Detach from attached process */
|
/* Detach from attached process */
|
||||||
if (KdbCurrentProcess != KdbOriginalProcess)
|
if (KdbCurrentProcess != KdbOriginalProcess)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue