Don't use hack for trap frames anymore, read TempEsp and TempSegSs for kernel-mode traps during debugging.

svn path=/trunk/; revision=14790
This commit is contained in:
Alex Ionescu 2005-04-23 20:02:39 +00:00
parent 5673eb73b9
commit 88d6fe5cb4
3 changed files with 21 additions and 51 deletions

View file

@ -27,8 +27,8 @@
#define KTRAP_FRAME_DEBUGEIP (0x4)
#define KTRAP_FRAME_DEBUGARGMARK (0x8)
#define KTRAP_FRAME_DEBUGPOINTER (0xC)
#define KTRAP_FRAME_TEMPCS (0x10)
#define KTRAP_FRAME_TEMPEIP (0x14)
#define KTRAP_FRAME_TEMPSS (0x10)
#define KTRAP_FRAME_TEMPESP (0x14)
#define KTRAP_FRAME_DR0 (0x18)
#define KTRAP_FRAME_DR1 (0x1C)
#define KTRAP_FRAME_DR2 (0x20)
@ -117,8 +117,8 @@ typedef struct _KTRAP_FRAME
PVOID DebugEip;
PVOID DebugArgMark;
PVOID DebugPointer;
PVOID TempCs;
PVOID TempEip;
PVOID TempSegSs;
PVOID TempEsp;
ULONG Dr0;
ULONG Dr1;
ULONG Dr2;

View file

@ -374,6 +374,19 @@ KdbpCmdRegs(ULONG Argc, PCHAR Argv[])
if (Argv[0][0] == 'r') /* regs */
{
ULONG Esp;
USHORT Ss;
if (!(Tf->Cs & 1))
{
Esp = (ULONG)Tf->TempEsp;
Ss = (USHORT)((ULONG)Tf->TempSegSs & 0xFFFF);
}
else
{
Esp = Tf->Esp;
Ss = Tf->Ss;
}
KdbpPrint("CS:EIP 0x%04x:0x%08x\n"
"SS:ESP 0x%04x:0x%08x\n"
" EAX 0x%08x EBX 0x%08x\n"
@ -381,7 +394,7 @@ KdbpCmdRegs(ULONG Argc, PCHAR Argv[])
" ESI 0x%08x EDI 0x%08x\n"
" EBP 0x%08x\n",
Tf->Cs & 0xFFFF, Tf->Eip,
Tf->Ss, Tf->Esp,
Ss, Esp,
Tf->Eax, Tf->Ebx,
Tf->Ecx, Tf->Edx,
Tf->Esi, Tf->Edi,

View file

@ -76,29 +76,6 @@ _KiTrapRet:
popl %edi
popl %esi
popl %ebx
#ifdef KDBG
/*
* Cleanup the stack which was used to setup a trapframe with SS:ESP when called
* from kmode.
*/
movw 0xC(%esp), %bp /* Get CS from trapframe */
cmpw $KERNEL_CS, %bp
jne 0f
/* Copy EBP, CS:EIP and EFLAGS from the trapframe back onto the top of our stack. */
movl 0x00(%esp), %ebp /* EBP */
movl %ebp, 0x24(%esp)
movl 0x08(%esp), %ebp /* EIP */
movl %ebp, 0x2C(%esp)
movl 0x0C(%esp), %ebp /* CS */
movl %ebp, 0x30(%esp)
movl 0x10(%esp), %ebp /* EFLAGS */
movl %ebp, 0x34(%esp)
addl $0x24, %esp
0:
#endif /* DBG */
popl %ebp
addl $0x4, %esp /* Ignore error code */
@ -106,27 +83,6 @@ _KiTrapRet:
.globl _KiTrapProlog
_KiTrapProlog:
#ifdef KDBG
/*
* If we were called from kmode we start setting up a new trapframe (with SS:ESP at the end)
*/
movw 0x14(%esp), %bx /* Get old CS */
cmpw $KERNEL_CS, %bx
jne 0f
leal 0x1C(%esp), %ebp
pushl %ss /* Old SS */
pushl %ebp /* Old ESP */
pushl 0x20(%esp) /* Old EFLAGS */
pushl 0x20(%esp) /* Old CS */
pushl 0x20(%esp) /* Old EIP */
pushl 0x20(%esp) /* ErrorCode */
pushl 0x20(%esp) /* Ebp */
pushl 0x20(%esp) /* Ebx */
pushl 0x20(%esp) /* Esi */
0:
#endif /* DBG */
pushl %edi
pushl %fs
@ -191,8 +147,9 @@ _KiTrapProlog:
pushl %eax /* Dr1 */
movl %dr0, %eax
pushl %eax /* Dr0 */
pushl $0 /* XXX: TempESP */
pushl $0 /* XXX: TempCS */
leal 0x64(%esp), %eax
pushl %eax /* XXX: TempESP */
pushl %ss /* XXX: TempSS */
pushl $0 /* XXX: DebugPointer */
pushl $0 /* XXX: DebugArgMark */
movl 0x60(%esp), %ebx