- Cleanup kdb_cli's code: be consistent in used types, don't use unsigned vars and then check if it's below 0, don't use inline assembly if there are reactos intrinsics for this.

svn path=/trunk/; revision=30845
This commit is contained in:
Aleksey Bragin 2007-11-28 22:50:55 +00:00
parent decb224735
commit b77f5b196a
2 changed files with 21 additions and 22 deletions

View file

@ -40,5 +40,6 @@ extern inline int islower(int c);
extern inline int isdigit(int c); extern inline int isdigit(int c);
extern inline int isxdigit(int c); extern inline int isxdigit(int c);
extern inline int isprint(int c); extern inline int isprint(int c);
extern inline int isalpha(int c);
#endif #endif

View file

@ -483,8 +483,8 @@ KdbpCmdRegs(ULONG Argc, PCHAR Argv[])
else if (Argv[0][0] == 'c') /* cregs */ else if (Argv[0][0] == 'c') /* cregs */
{ {
ULONG Cr0, Cr2, Cr3, Cr4; ULONG Cr0, Cr2, Cr3, Cr4;
KDESCRIPTOR Gdtr, Ldtr, Idtr; KDESCRIPTOR Gdtr = {0}, Ldtr = {0}, Idtr = {0};
ULONG Tr; ULONG Tr = 0;
STATIC CONST PCHAR Cr0Bits[32] = { " PE", " MP", " EM", " TS", " ET", " NE", NULL, NULL, STATIC CONST PCHAR Cr0Bits[32] = { " PE", " MP", " EM", " TS", " ET", " NE", NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
" WP", NULL, " AM", NULL, NULL, NULL, NULL, NULL, " WP", NULL, " AM", NULL, NULL, NULL, NULL, NULL,
@ -500,12 +500,12 @@ KdbpCmdRegs(ULONG Argc, PCHAR Argv[])
Cr4 = KdbCurrentTrapFrame->Cr4; Cr4 = KdbCurrentTrapFrame->Cr4;
/* Get descriptor table regs */ /* Get descriptor table regs */
asm volatile("sgdt %0" : : "m"(Gdtr.Limit)); Ke386GetGlobalDescriptorTable(*(PKDESCRIPTOR)&Gdtr.Limit);
asm volatile("sldt %0" : : "m"(Ldtr.Limit)); Ke386GetLocalDescriptorTable(Ldtr.Limit);
asm volatile("sidt %0" : : "m"(Idtr.Limit)); Ke386GetInterruptDescriptorTable(*(PKDESCRIPTOR)&Idtr.Limit);
/* Get the task register */ /* Get the task register */
asm volatile("str %0" : "=g"(Tr)); Ke386GetTr(Tr);
/* Display the control registers */ /* Display the control registers */
KdbpPrint("CR0 0x%08x ", Cr0); KdbpPrint("CR0 0x%08x ", Cr0);
@ -842,7 +842,8 @@ KdbpCmdBreakPoint(ULONG Argc, PCHAR Argv[])
KDB_BREAKPOINT_TYPE Type; KDB_BREAKPOINT_TYPE Type;
UCHAR Size = 0; UCHAR Size = 0;
KDB_ACCESS_TYPE AccessType = 0; KDB_ACCESS_TYPE AccessType = 0;
UINT AddressArgIndex, ConditionArgIndex, i; ULONG AddressArgIndex, i;
LONG ConditionArgIndex;
BOOLEAN Global = TRUE; BOOLEAN Global = TRUE;
if (Argv[0][2] == 'x') /* software breakpoint */ if (Argv[0][2] == 'x') /* software breakpoint */
@ -1188,8 +1189,8 @@ KdbpCmdProc(ULONG Argc, PCHAR Argv[])
{ {
return TRUE; return TRUE;
} }
KdbpPrint("Attached to process 0x%08x, thread 0x%08x.\n", (UINT)ul, KdbpPrint("Attached to process 0x%08x, thread 0x%08x.\n", (ULONG)ul,
(UINT)KdbCurrentThread->Cid.UniqueThread); (ULONG)KdbCurrentThread->Cid.UniqueThread);
} }
else else
{ {
@ -1289,10 +1290,7 @@ KdbpCmdMod(ULONG Argc, PCHAR Argv[])
STATIC BOOLEAN STATIC BOOLEAN
KdbpCmdGdtLdtIdt(ULONG Argc, PCHAR Argv[]) KdbpCmdGdtLdtIdt(ULONG Argc, PCHAR Argv[])
{ {
struct __attribute__((packed)) { KDESCRIPTOR Reg = {0};
USHORT Limit;
ULONG Base;
} Reg;
ULONG SegDesc[2]; ULONG SegDesc[2];
ULONG SegBase; ULONG SegBase;
ULONG SegLimit; ULONG SegLimit;
@ -1305,7 +1303,7 @@ KdbpCmdGdtLdtIdt(ULONG Argc, PCHAR Argv[])
if (Argv[0][0] == 'i') if (Argv[0][0] == 'i')
{ {
/* Read IDTR */ /* Read IDTR */
asm volatile("sidt %0" : : "m"(Reg)); Ke386GetInterruptDescriptorTable(*(PKDESCRIPTOR)&Reg.Limit);
if (Reg.Limit < 7) if (Reg.Limit < 7)
{ {
@ -1362,14 +1360,14 @@ KdbpCmdGdtLdtIdt(ULONG Argc, PCHAR Argv[])
if (Argv[0][0] == 'g') if (Argv[0][0] == 'g')
{ {
/* Read GDTR */ /* Read GDTR */
asm volatile("sgdt %0" : : "m"(Reg)); Ke386GetGlobalDescriptorTable(*(PKDESCRIPTOR)&Reg.Limit);
i = 8; i = 8;
} }
else else
{ {
ASSERT(Argv[0][0] == 'l'); ASSERT(Argv[0][0] == 'l');
/* Read LDTR */ /* Read LDTR */
asm volatile("sldt %0" : : "m"(Reg)); Ke386GetLocalDescriptorTable(Reg.Limit);
i = 0; i = 0;
ul = 1 << 2; ul = 1 << 2;
} }
@ -1567,7 +1565,7 @@ KdbpCmdBugCheck(ULONG Argc, PCHAR Argv[])
STATIC BOOLEAN STATIC BOOLEAN
KdbpCmdSet(ULONG Argc, PCHAR Argv[]) KdbpCmdSet(ULONG Argc, PCHAR Argv[])
{ {
ULONG l; LONG l;
BOOLEAN First; BOOLEAN First;
PCHAR pend = 0; PCHAR pend = 0;
KDB_ENTER_CONDITION ConditionFirst = KdbDoNotEnter; KDB_ENTER_CONDITION ConditionFirst = KdbDoNotEnter;
@ -1765,9 +1763,9 @@ KdbpPrint(
STATIC BOOLEAN TerminalReportsSize = TRUE; STATIC BOOLEAN TerminalReportsSize = TRUE;
CHAR c = '\0'; CHAR c = '\0';
PCHAR p, p2; PCHAR p, p2;
UINT Length; ULONG Length;
UINT i, j; ULONG i, j;
INT RowsPrintedByTerminal; LONG RowsPrintedByTerminal;
ULONG ScanCode; ULONG ScanCode;
va_list ap; va_list ap;
@ -2210,7 +2208,7 @@ KdbpReadCommand(
* \retval TRUE Don't continue execution. * \retval TRUE Don't continue execution.
* \retval FALSE Continue execution (leave KDB) * \retval FALSE Continue execution (leave KDB)
*/ */
STATIC BOOL STATIC BOOLEAN
KdbpDoCommand( KdbpDoCommand(
IN PCHAR Command) IN PCHAR Command)
{ {
@ -2390,7 +2388,7 @@ KdbpCliInit()
HANDLE hFile = NULL; HANDLE hFile = NULL;
INT FileSize; INT FileSize;
PCHAR FileBuffer; PCHAR FileBuffer;
ULONG OldEflags; ULONG OldEflags = 0;
/* Initialize the object attributes */ /* Initialize the object attributes */
RtlInitUnicodeString(&FileName, L"\\SystemRoot\\system32\\drivers\\etc\\KDBinit"); RtlInitUnicodeString(&FileName, L"\\SystemRoot\\system32\\drivers\\etc\\KDBinit");