Only whitespace changes, no logic

svn path=/trunk/; revision=18455
This commit is contained in:
Gé van Geldorp 2005-10-14 19:28:18 +00:00
parent 2af4ba6dcb
commit 7daa792a3e

View file

@ -94,9 +94,6 @@
#define BUFMAX 1000
static BOOLEAN GspInitialized;
#if 0
static PKINTERRUPT GspInterrupt;
#endif
static BOOLEAN GspRemoteDebug;
@ -151,7 +148,8 @@ static CPU_REGISTER GspRegisters[NUMREGS] =
};
static PCHAR GspThreadStates[DeferredReady+1] =
{ "Initialized",
{
"Initialized",
"Ready",
"Running",
"Standby",
@ -165,10 +163,20 @@ static PCHAR GspThreadStates[DeferredReady+1] =
LONG
HexValue(CHAR ch)
{
if ((ch >= '0') && (ch <= '9')) return (ch - '0');
if ((ch >= 'a') && (ch <= 'f')) return (ch - 'a' + 10);
if ((ch >= 'A') && (ch <= 'F')) return (ch - 'A' + 10);
return (-1);
if ((ch >= '0') && (ch <= '9'))
{
return (ch - '0');
}
if ((ch >= 'a') && (ch <= 'f'))
{
return (ch - 'a' + 10);
}
if ((ch >= 'A') && (ch <= 'F'))
{
return (ch - 'A' + 10);
}
return -1;
}
static CHAR GspInBuffer[BUFMAX];
@ -185,7 +193,8 @@ GdbGetChar(VOID)
{
UCHAR Value;
while (!KdPortGetByteEx (&GdbPortInfo, &Value));
while (!KdPortGetByteEx(&GdbPortInfo, &Value))
;
return Value;
}
@ -204,7 +213,8 @@ GspGetPacket()
while (TRUE)
{
/* wait around for the start character, ignore all other characters */
while ((ch = GdbGetChar ()) != '$');
while ((ch = GdbGetChar ()) != '$')
;
retry:
Checksum = 0;
@ -216,9 +226,13 @@ GspGetPacket()
{
ch = GdbGetChar();
if (ch == '$')
{
goto retry;
}
if (ch == '#')
{
break;
}
Checksum = Checksum + ch;
Buffer[Count] = ch;
Count = Count + 1;
@ -329,19 +343,21 @@ GspMem2Hex (PCHAR Address,
for (i = 0; i < (ULONG) Count; i++)
{
if (MayFault)
{
GspAccessLocation = Address;
}
ch = *Address;
GspAccessLocation = NULL;
if (MayFault && GspMemoryError)
{
return (Buffer);
return Buffer;
}
*Buffer++ = HexChars[(ch >> 4) & 0xf];
*Buffer++ = HexChars[ch & 0xf];
Address++;
}
*Buffer = 0;
return (Buffer);
return Buffer;
}
@ -395,12 +411,12 @@ GspHex2Mem (PCHAR Buffer,
MmSetPageProtect(NULL, page, oldprot);
if (GspMemoryError)
{
return (Buffer);
return Buffer;
}
}
}
return (Buffer);
return Buffer;
}
@ -427,11 +443,6 @@ GspComputeSignal (NTSTATUS ExceptionCode)
case STATUS_ILLEGAL_INSTRUCTION:
SigVal = 4; /* Invalid opcode */
break;
#if 0
case STATUS_FLT_INVALID_OPERATION:
SigVal = 8;
break;
#endif
case STATUS_STACK_OVERFLOW:
case STATUS_DATATYPE_MISALIGNMENT:
case STATUS_ACCESS_VIOLATION:
@ -473,7 +484,7 @@ GspHex2Long (PCHAR *Address,
(*Address)++;
}
return (NumChars);
return NumChars;
}
@ -500,7 +511,6 @@ GspLong2Hex (PCHAR *Address,
static LONG
GspGetEspFromTrapFrame(PKTRAP_FRAME TrapFrame)
{
return KeGetPreviousMode() == KernelMode
? (LONG) &TrapFrame->Esp : (LONG)TrapFrame->Esp;
}
@ -559,15 +569,21 @@ GspSetRegistersInTrapFrame(PCHAR Address,
DWORD i;
if (!TrapFrame)
{
return;
}
Buffer = Address;
for (i = 0; i < NUMREGS; i++)
{
if (GspRegisters[i].SetInContext)
{
p = (PULONG) ((ULONG_PTR) Context + GspRegisters[i].OffsetInContext);
}
else
{
p = (PULONG) ((ULONG_PTR) TrapFrame + GspRegisters[i].OffsetInTF);
}
Value = 0;
Buffer = GspHex2Mem(Buffer, (PCHAR) &Value, GspRegisters[i].Size, FALSE);
*p = Value;
@ -585,12 +601,18 @@ GspSetSingleRegisterInTrapFrame(PCHAR Address,
PULONG p;
if (!TrapFrame)
{
return;
}
if (GspRegisters[Number].SetInContext)
{
p = (PULONG) ((ULONG_PTR) Context + GspRegisters[Number].OffsetInContext);
}
else
{
p = (PULONG) ((ULONG_PTR) TrapFrame + GspRegisters[Number].OffsetInTF);
}
Value = 0;
GspHex2Mem(Address, (PCHAR) &Value, GspRegisters[Number].Size, FALSE);
*p = Value;
@ -663,13 +685,21 @@ GspSetThread(PCHAR Request)
GspOutBuffer[0] = 'O';
GspOutBuffer[1] = 'K';
if (GspDbgThread)
if (NULL != GspDbgThread)
{
ObDereferenceObject(GspDbgThread);
}
if (ThreadInfo == PsGetCurrentThread())
{
GspDbgThread = NULL;
ObDereferenceObject(ThreadInfo);
}
else
{
GspDbgThread = ThreadInfo;
}
}
else
{
GspOutBuffer[0] = 'E';
@ -808,19 +838,14 @@ GspQuery(PCHAR Request)
(int) Proc->UniqueProcessId,
(int) ThreadInfo->Cid.UniqueThread);
}
strcpy(Buffer + strlen(Buffer), GspThreadStates[ThreadInfo->Tcb.State]);
strcpy(Buffer + strlen(Buffer),
GspThreadStates[ThreadInfo->Tcb.State]);
ObDereferenceObject(ThreadInfo);
GspMem2Hex(Buffer, &GspOutBuffer[0], strlen(Buffer), FALSE);
}
}
#if 0
else if (strncmp (Request, "Offsets", 7) == 0)
{
strcpy (GspOutBuffer, "Text=0;Data=0;Bss=0");
}
#endif
}
VOID
@ -1061,11 +1086,10 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
}
else
{
/* Don't switch threads */
/* Always use the current thread when entering the exception handler */
/* Make sure we're debugging the current thread. */
if (NULL != GspDbgThread)
{
DPRINT1("Internal error: entering stub with non-NULL GspDbgThread\n");
ObDereferenceObject(GspDbgThread);
GspDbgThread = NULL;
}
@ -1159,20 +1183,24 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
LONG Register;
if ((GspHex2Long(&ptr, &Register)) && (*ptr++ == '='))
{
if ((Register >= 0) && (Register < NUMREGS))
{
if (GspDbgThread)
{
GspSetSingleRegisterInTrapFrame(ptr, Register,
Context, GspDbgThread->Tcb.TrapFrame);
Context,
GspDbgThread->Tcb.TrapFrame);
}
else
{
GspSetSingleRegisterInTrapFrame (ptr, Register, Context, TrapFrame);
GspSetSingleRegisterInTrapFrame(ptr, Register,
Context, TrapFrame);
}
strcpy(GspOutBuffer, "OK");
break;
}
}
strcpy(GspOutBuffer, "E01");
break;
@ -1181,9 +1209,9 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
/* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
case 'm':
/* TRY TO READ %x,%x. IF SUCCEED, SET PTR = 0 */
if (GspHex2Long (&ptr, &Address))
if (*(ptr++) == ',')
if (GspHex2Long (&ptr, &Length))
if (GspHex2Long(&ptr, &Address) &&
*(ptr++) == ',' &&
GspHex2Long(&ptr, &Length))
{
ptr = 0;
GspMemoryError = FALSE;
@ -1196,16 +1224,19 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
}
if (ptr)
{
strcpy(GspOutBuffer, "E01");
}
break;
/* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
case 'M':
/* TRY TO READ '%x,%x:'. IF SUCCEED, SET PTR = 0 */
if (GspHex2Long(&ptr, &Address))
if (*(ptr++) == ',')
if (GspHex2Long (&ptr, &Length))
if (*(ptr++) == ':')
{
if (*(ptr++) == ',' &&
GspHex2Long(&ptr, &Length) &&
*(ptr++) == ':')
{
GspMemoryError = FALSE;
GspHex2Mem(ptr, (PCHAR) Address, Length, TRUE);
@ -1222,8 +1253,12 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
ptr = NULL;
}
if (ptr)
}
if (NULL != ptr)
{
strcpy(GspOutBuffer, "E02");
}
break;
/* cAA..AA Continue at address AA..AA(optional) */
@ -1237,7 +1272,9 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
/* try to read optional parameter, pc unchanged if no parm */
if (GspHex2Long (&ptr, &Address))
{
Context->Eip = Address;
}
NewPC = Context->Eip;
@ -1246,7 +1283,9 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
/* set the trace bit if we're Stepping */
if (Stepping)
{
Context->EFlags |= 0x100;
}
#if defined(__GNUC__)
asm volatile ("movl %%db6, %0\n" : "=r" (dr6_) : );
@ -1279,6 +1318,12 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
#error Unknown compiler for inline assembler
#endif
if (NULL != GspDbgThread)
{
ObDereferenceObject(GspDbgThread);
GspDbgThread = NULL;
}
return kdContinue;
break;
}
@ -1356,6 +1401,12 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
ASSERT(0);
}
if (NULL != GspDbgThread)
{
ObDereferenceObject(GspDbgThread);
GspDbgThread = NULL;
}
return kdContinue;
}
@ -1377,11 +1428,15 @@ GspBreakIn(PKINTERRUPT Interrupt,
while (KdPortGetByteEx(&GdbPortInfo, &Value))
{
if (Value == 0x03)
{
DoBreakIn = TRUE;
}
}
if (!DoBreakIn)
{
return TRUE;
}
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
@ -1398,51 +1453,22 @@ GspBreakIn(PKINTERRUPT Interrupt,
return TRUE;
}
extern ULONG KdpPortIrq;
VOID
STDCALL
KdpGdbDebugPrint(PCH Message, ULONG Length)
{
}
extern LIST_ENTRY ModuleListHead;
VOID
KdGdbListModules()
{
PLIST_ENTRY CurrentEntry;
PLDR_DATA_TABLE_ENTRY Current;
ULONG ModuleCount;
DPRINT1("\n");
ModuleCount = 0;
CurrentEntry = ModuleListHead.Flink;
while (CurrentEntry != (&ModuleListHead))
{
Current = CONTAINING_RECORD (CurrentEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderModuleList);
DbgPrint ("Module %wZ Base 0x%.08x Length 0x%.08x\n",
&Current->BaseDllName, Current->DllBase, Current->SizeOfImage);
ModuleCount++;
CurrentEntry = CurrentEntry->Flink;
}
DbgPrint ("%d modules listed\n", ModuleCount);
}
/* Initialize the GDB stub */
VOID
STDCALL
KdpGdbStubInit(PKD_DISPATCH_TABLE WrapperTable,
ULONG BootPhase)
{
if (!KdDebuggerEnabled || !KdpDebugMode.Gdb) return;
if (!KdDebuggerEnabled || !KdpDebugMode.Gdb)
{
return;
}
if (BootPhase == 0)
{