Added "addr" "x" and "tlist" commands to kdbg.

addr  -- Displays address info from kdb_stabs.
x     -- Dumps memory.
tlist -- List threads.  Helps with bt, because normally, you don't know
         what the thread ids are or the stack addresses.
kdb_stabs.c: Fixed bug: length of module vs length of name.
kdb_serial.c: Added /KDSERIAL option allowing the user to type commands
              to the serial port.

svn path=/trunk/; revision=7188
This commit is contained in:
Art Yerkes 2003-12-23 05:04:59 +00:00
parent 6876cc7caf
commit 0ce3d6f67c
4 changed files with 82 additions and 5 deletions

View file

@ -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 <address>", "Displays symbol info", DbgAddrCommand},
{"x", "x <addr> <words>", "Displays <addr> for <words>", 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 <filename>", "Enable debug prints from file", DbgEnableFileCommand},
{"dfile", "dfile <filename>", "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)
{

View file

@ -10,6 +10,8 @@ LdrGetAddressInformation(IN PIMAGE_SYMBOL_INFO SymbolInfo,
ULONG
KdbTryGetCharKeyboard(VOID);
ULONG
KdbTryGetCharSerial(VOID);
VOID
KdbEnter(VOID);
VOID

View file

@ -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);

View file

@ -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;