diff --git a/reactos/ntoskrnl/dbg/kdb.c b/reactos/ntoskrnl/dbg/kdb.c
index 78514880b67..f52cacf145b 100644
--- a/reactos/ntoskrnl/dbg/kdb.c
+++ b/reactos/ntoskrnl/dbg/kdb.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: kdb.c,v 1.12 2003/12/14 18:03:59 hbirr Exp $
+/* $Id: kdb.c,v 1.13 2003/12/23 05:04:58 arty Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/dbg/kdb.c
@@ -42,6 +42,9 @@
/* GLOBALS *******************************************************************/
+int isalpha( int );
+VOID
+PsDumpThreads(BOOLEAN System);
ULONG
DbgContCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
ULONG
@@ -55,6 +58,12 @@ DbgBugCheckCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
ULONG
DbgBackTraceCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
ULONG
+DbgAddrCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
+ULONG
+DbgXCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
+ULONG
+DbgThreadListCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
+ULONG
DbgProcessListCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
ULONG
DbgProcessHelpCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
@@ -78,7 +87,10 @@ struct
{"cregs", "cregs", "Display control registers", DbgCRegsCommand},
{"bugcheck", "bugcheck", "Bugcheck the system", DbgBugCheckCommand},
{"bt", "bt [*frame-address]|[thread-id]","Do a backtrace", DbgBackTraceCommand},
+ {"addr", "addr
", "Displays symbol info", DbgAddrCommand},
+ {"x", "x ", "Displays for ", DbgXCommand},
{"plist", "plist", "Display processes in the system", DbgProcessListCommand},
+ {"tlist", "tlist [sys]", "Display threads in the system", DbgThreadListCommand},
{"sfiles", "sfiles", "Show files that print debug prints", DbgShowFilesCommand},
{"efile", "efile ", "Enable debug prints from file", DbgEnableFileCommand},
{"dfile", "dfile ", "Disable debug prints from file", DbgDisableFileCommand},
@@ -181,7 +193,10 @@ KdbGetCommand(PCH Buffer)
for (;;)
{
- while ((Key = KdbTryGetCharKeyboard()) == -1);
+ if (KdDebugState & KD_DEBUG_KDSERIAL)
+ while ((Key = KdbTryGetCharSerial()) == -1);
+ else
+ while ((Key = KdbTryGetCharKeyboard()) == -1);
if (Key == '\r' || Key == '\n')
{
@@ -219,6 +234,17 @@ DbgProcessHelpCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
return(1);
}
+ULONG
+DbgThreadListCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
+{
+ BOOL System = FALSE;
+ if (Argc == 2 && (!strcmp(Argv[1], "sys") || !strcmp(Argv[1], "SYS")))
+ System = TRUE;
+
+ PsDumpThreads(System);
+ return(1);
+}
+
ULONG
DbgProcessListCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
{
@@ -274,6 +300,46 @@ DbgPrintBackTrace(PULONG Frame, ULONG StackBase, ULONG StackLimit)
}
}
+ULONG
+DbgAddrCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME tf)
+{
+ PVOID Addr;
+
+ if (Argc == 2)
+ {
+ Addr = (PVOID)strtoul(Argv[1], NULL, 0);
+ KdbPrintAddress(Addr);
+ }
+
+ return(1);
+}
+
+ULONG
+DbgXCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME tf)
+{
+ PDWORD Addr = 0;
+ DWORD Items = 1;
+ DWORD i = 0;
+
+ if (Argc >= 2)
+ Addr = (PDWORD)strtoul(Argv[1], NULL, 0);
+ if (Argc >= 3)
+ Items = (DWORD)strtoul(Argv[2], NULL, 0);
+
+ if( !Addr ) return(1);
+
+ for( i = 0; i < Items; i++ )
+ {
+ if( (i % 4) == 0 ) {
+ if( i ) DbgPrint("\n");
+ DbgPrint("%08x:", (int)(&Addr[i]));
+ }
+ DbgPrint( "%08x ", Addr[i] );
+ }
+
+ return(1);
+}
+
ULONG
DbgBackTraceCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
{
diff --git a/reactos/ntoskrnl/dbg/kdb.h b/reactos/ntoskrnl/dbg/kdb.h
index fed6cbc9d7f..f75711822e1 100644
--- a/reactos/ntoskrnl/dbg/kdb.h
+++ b/reactos/ntoskrnl/dbg/kdb.h
@@ -10,6 +10,8 @@ LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
ULONG
KdbTryGetCharKeyboard(VOID);
+ULONG
+KdbTryGetCharSerial(VOID);
VOID
KdbEnter(VOID);
VOID
diff --git a/reactos/ntoskrnl/dbg/kdb_stabs.c b/reactos/ntoskrnl/dbg/kdb_stabs.c
index 213bf52dc09..d4f9e843fec 100644
--- a/reactos/ntoskrnl/dbg/kdb_stabs.c
+++ b/reactos/ntoskrnl/dbg/kdb_stabs.c
@@ -545,6 +545,7 @@ LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
Status = LdrpGetLineNumber(SymbolInfo, RelativeAddress, LineNumber);
if (!NT_SUCCESS(Status))
{
+ DPRINT("LdrpGetLineNumber failed (%08x)\n", Status);
return Status;
}
@@ -820,6 +821,8 @@ KdbUnloadDriver(PMODULE_OBJECT ModuleObject)
KdbLdrUnloadModuleSymbols(&ModuleObject->TextSection->SymbolInfo);
}
+/* Length here is the length of the loaded module, not the file name. */
+
VOID
KdbProcessSymbolFile(PVOID ModuleLoadBase, PCHAR FileName, ULONG Length)
{
@@ -833,8 +836,8 @@ KdbProcessSymbolFile(PVOID ModuleLoadBase, PCHAR FileName, ULONG Length)
DPRINT("Module %s is a symbol file\n", FileName);
- strncpy(TmpBaseName, FileName, Length);
- TmpBaseName[Length] = '\0';
+ strncpy(TmpBaseName, FileName, MAX_PATH-1);
+ TmpBaseName[MAX_PATH-1] = '\0';
DPRINT("base: %s (Length %d)\n", TmpBaseName, Length);
diff --git a/reactos/ntoskrnl/kd/kdebug.c b/reactos/ntoskrnl/kd/kdebug.c
index 9e14b939fdb..2f8b5aca1d9 100644
--- a/reactos/ntoskrnl/kd/kdebug.c
+++ b/reactos/ntoskrnl/kd/kdebug.c
@@ -1,4 +1,4 @@
-/* $Id: kdebug.c,v 1.47 2003/10/12 17:05:45 hbirr Exp $
+/* $Id: kdebug.c,v 1.48 2003/12/23 05:04:59 arty Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -154,6 +154,12 @@ KdInitSystem(ULONG Reserved,
}
}
}
+ else if (!_strnicmp(p2, "KDSERIAL", 8))
+ {
+ p2 += 8;
+ KdDebuggerEnabled = TRUE;
+ KdDebugState |= KD_DEBUG_SERIAL | KD_DEBUG_KDSERIAL;
+ }
else if (!_strnicmp(p2, "DEBUG", 5))
{
p2 += 5;