mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:25:39 +00:00
[KDBG] If no parameters are given to the 'filter' command, display the list of available debug filter components.
This commit is contained in:
parent
548393c6e7
commit
40c57de728
1 changed files with 226 additions and 202 deletions
|
@ -135,91 +135,12 @@ extern volatile ULONG KdbDmesgTotalWritten;
|
||||||
|
|
||||||
STRING KdbPromptString = RTL_CONSTANT_STRING("kdb:> ");
|
STRING KdbPromptString = RTL_CONSTANT_STRING("kdb:> ");
|
||||||
|
|
||||||
static const struct
|
//
|
||||||
{
|
// Debug Filter Component Table
|
||||||
PCHAR Name;
|
//
|
||||||
PCHAR Syntax;
|
|
||||||
PCHAR Help;
|
|
||||||
BOOLEAN (*Fn)(ULONG Argc, PCHAR Argv[]);
|
|
||||||
} KdbDebuggerCommands[] = {
|
|
||||||
/* Data */
|
|
||||||
{ NULL, NULL, "Data", NULL },
|
|
||||||
{ "?", "? expression", "Evaluate expression.", KdbpCmdEvalExpression },
|
|
||||||
{ "disasm", "disasm [address] [L count]", "Disassemble count instructions at address.", KdbpCmdDisassembleX },
|
|
||||||
{ "x", "x [address] [L count]", "Display count dwords, starting at address.", KdbpCmdDisassembleX },
|
|
||||||
{ "regs", "regs", "Display general purpose registers.", KdbpCmdRegs },
|
|
||||||
{ "cregs", "cregs", "Display control, descriptor table and task segment registers.", KdbpCmdRegs },
|
|
||||||
{ "sregs", "sregs", "Display status registers.", KdbpCmdRegs },
|
|
||||||
{ "dregs", "dregs", "Display debug registers.", KdbpCmdRegs },
|
|
||||||
{ "bt", "bt [*frameaddr|thread id]", "Prints current backtrace or from given frame address.", KdbpCmdBackTrace },
|
|
||||||
#ifdef __ROS_DWARF__
|
|
||||||
{ "dt", "dt [mod] [type] [addr]", "Print a struct. The address is optional.", KdbpCmdPrintStruct },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flow control */
|
|
||||||
{ NULL, NULL, "Flow control", NULL },
|
|
||||||
{ "cont", "cont", "Continue execution (leave debugger).", KdbpCmdContinue },
|
|
||||||
{ "step", "step [count]", "Execute single instructions, stepping into interrupts.", KdbpCmdStep },
|
|
||||||
{ "next", "next [count]", "Execute single instructions, skipping calls and reps.", KdbpCmdStep },
|
|
||||||
{ "bl", "bl", "List breakpoints.", KdbpCmdBreakPointList },
|
|
||||||
{ "be", "be [breakpoint]", "Enable breakpoint.", KdbpCmdEnableDisableClearBreakPoint },
|
|
||||||
{ "bd", "bd [breakpoint]", "Disable breakpoint.", KdbpCmdEnableDisableClearBreakPoint },
|
|
||||||
{ "bc", "bc [breakpoint]", "Clear breakpoint.", KdbpCmdEnableDisableClearBreakPoint },
|
|
||||||
{ "bpx", "bpx [address] [IF condition]", "Set software execution breakpoint at address.", KdbpCmdBreakPoint },
|
|
||||||
{ "bpm", "bpm [r|w|rw|x] [byte|word|dword] [address] [IF condition]", "Set memory breakpoint at address.", KdbpCmdBreakPoint },
|
|
||||||
|
|
||||||
/* Process/Thread */
|
|
||||||
{ NULL, NULL, "Process/Thread", NULL },
|
|
||||||
{ "thread", "thread [list[ pid]|[attach ]tid]", "List threads in current or specified process, display thread with given id or attach to thread.", KdbpCmdThread },
|
|
||||||
{ "proc", "proc [list|[attach ]pid]", "List processes, display process with given id or attach to process.", KdbpCmdProc },
|
|
||||||
|
|
||||||
/* System information */
|
|
||||||
{ NULL, NULL, "System info", NULL },
|
|
||||||
{ "mod", "mod [address]", "List all modules or the one containing address.", KdbpCmdMod },
|
|
||||||
{ "gdt", "gdt", "Display the global descriptor table.", KdbpCmdGdtLdtIdt },
|
|
||||||
{ "ldt", "ldt", "Display the local descriptor table.", KdbpCmdGdtLdtIdt },
|
|
||||||
{ "idt", "idt", "Display the interrupt descriptor table.", KdbpCmdGdtLdtIdt },
|
|
||||||
{ "pcr", "pcr", "Display the processor control region.", KdbpCmdPcr },
|
|
||||||
{ "tss", "tss [selector|*descaddr]", "Display the current task state segment, or the one specified by its selector number or descriptor address.", KdbpCmdTss },
|
|
||||||
|
|
||||||
/* Others */
|
|
||||||
{ NULL, NULL, "Others", NULL },
|
|
||||||
{ "bugcheck", "bugcheck", "Bugchecks the system.", KdbpCmdBugCheck },
|
|
||||||
{ "reboot", "reboot", "Reboots the system.", KdbpCmdReboot},
|
|
||||||
{ "filter", "filter [error|warning|trace|info|level]+|-[componentname|default]", "Enable/disable debug channels.", KdbpCmdFilter },
|
|
||||||
{ "set", "set [var] [value]", "Sets var to value or displays value of var.", KdbpCmdSet },
|
|
||||||
{ "dmesg", "dmesg", "Display debug messages on screen, with navigation on pages.", KdbpCmdDmesg },
|
|
||||||
{ "kmsg", "kmsg", "Kernel dmesg. Alias for dmesg.", KdbpCmdDmesg },
|
|
||||||
{ "help", "help", "Display help screen.", KdbpCmdHelp },
|
|
||||||
{ "!pool", "!pool [Address [Flags]]", "Display information about pool allocations.", ExpKdbgExtPool },
|
|
||||||
{ "!poolused", "!poolused [Flags [Tag]]", "Display pool usage.", ExpKdbgExtPoolUsed },
|
|
||||||
{ "!poolfind", "!poolfind Tag [Pool]", "Search for pool tag allocations.", ExpKdbgExtPoolFind },
|
|
||||||
{ "!filecache", "!filecache", "Display cache usage.", ExpKdbgExtFileCache },
|
|
||||||
{ "!defwrites", "!defwrites", "Display cache write values.", ExpKdbgExtDefWrites },
|
|
||||||
{ "!irpfind", "!irpfind [Pool [startaddress [criteria data]]]", "Lists IRPs potentially matching criteria.", ExpKdbgExtIrpFind },
|
|
||||||
{ "!handle", "!handle [Handle]", "Displays info about handles.", ExpKdbgExtHandle },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
|
||||||
|
|
||||||
/*!\brief Transform a component name to an integer
|
|
||||||
*
|
|
||||||
* \param ComponentName The name of the component.
|
|
||||||
* \param ComponentId Receives the component id on success.
|
|
||||||
*
|
|
||||||
* \retval TRUE Success.
|
|
||||||
* \retval FALSE Failure.
|
|
||||||
*/
|
|
||||||
static BOOLEAN
|
|
||||||
KdbpGetComponentId(
|
|
||||||
IN PCCH ComponentName,
|
|
||||||
OUT PULONG ComponentId)
|
|
||||||
{
|
|
||||||
ULONG i;
|
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
PCCH Name;
|
PCSTR Name;
|
||||||
ULONG Id;
|
ULONG Id;
|
||||||
}
|
}
|
||||||
ComponentTable[] =
|
ComponentTable[] =
|
||||||
|
@ -328,9 +249,9 @@ KdbpGetComponentId(
|
||||||
{ "VERIFIER", DPFLTR_VERIFIER_ID },
|
{ "VERIFIER", DPFLTR_VERIFIER_ID },
|
||||||
{ "VDS", DPFLTR_VDS_ID },
|
{ "VDS", DPFLTR_VDS_ID },
|
||||||
{ "VDSBAS", DPFLTR_VDSBAS_ID },
|
{ "VDSBAS", DPFLTR_VDSBAS_ID },
|
||||||
{ "VDSDYN", DPFLTR_VDSDYN_ID },
|
{ "VDSDYN", DPFLTR_VDSDYN_ID }, // Specified in Vista+
|
||||||
{ "VDSDYNDR", DPFLTR_VDSDYNDR_ID },
|
{ "VDSDYNDR", DPFLTR_VDSDYNDR_ID },
|
||||||
{ "VDSLDR", DPFLTR_VDSLDR_ID },
|
{ "VDSLDR", DPFLTR_VDSLDR_ID }, // Specified in Vista+
|
||||||
{ "VDSUTIL", DPFLTR_VDSUTIL_ID },
|
{ "VDSUTIL", DPFLTR_VDSUTIL_ID },
|
||||||
{ "DFRGIFC", DPFLTR_DFRGIFC_ID },
|
{ "DFRGIFC", DPFLTR_DFRGIFC_ID },
|
||||||
{ "MM", DPFLTR_MM_ID },
|
{ "MM", DPFLTR_MM_ID },
|
||||||
|
@ -382,17 +303,75 @@ KdbpGetComponentId(
|
||||||
{ "DRIVEEXTENDER", DPFLTR_DRIVEEXTENDER_ID },
|
{ "DRIVEEXTENDER", DPFLTR_DRIVEEXTENDER_ID },
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i = 0; i < sizeof(ComponentTable) / sizeof(ComponentTable[0]); i++)
|
//
|
||||||
|
// Command Table
|
||||||
|
//
|
||||||
|
static const struct
|
||||||
{
|
{
|
||||||
if (_stricmp(ComponentName, ComponentTable[i].Name) == 0)
|
PCHAR Name;
|
||||||
{
|
PCHAR Syntax;
|
||||||
*ComponentId = ComponentTable[i].Id;
|
PCHAR Help;
|
||||||
return TRUE;
|
BOOLEAN (*Fn)(ULONG Argc, PCHAR Argv[]);
|
||||||
}
|
} KdbDebuggerCommands[] = {
|
||||||
}
|
/* Data */
|
||||||
|
{ NULL, NULL, "Data", NULL },
|
||||||
|
{ "?", "? expression", "Evaluate expression.", KdbpCmdEvalExpression },
|
||||||
|
{ "disasm", "disasm [address] [L count]", "Disassemble count instructions at address.", KdbpCmdDisassembleX },
|
||||||
|
{ "x", "x [address] [L count]", "Display count dwords, starting at address.", KdbpCmdDisassembleX },
|
||||||
|
{ "regs", "regs", "Display general purpose registers.", KdbpCmdRegs },
|
||||||
|
{ "cregs", "cregs", "Display control, descriptor table and task segment registers.", KdbpCmdRegs },
|
||||||
|
{ "sregs", "sregs", "Display status registers.", KdbpCmdRegs },
|
||||||
|
{ "dregs", "dregs", "Display debug registers.", KdbpCmdRegs },
|
||||||
|
{ "bt", "bt [*frameaddr|thread id]", "Prints current backtrace or from given frame address.", KdbpCmdBackTrace },
|
||||||
|
#ifdef __ROS_DWARF__
|
||||||
|
{ "dt", "dt [mod] [type] [addr]", "Print a struct. The address is optional.", KdbpCmdPrintStruct },
|
||||||
|
#endif
|
||||||
|
|
||||||
return FALSE;
|
/* Flow control */
|
||||||
}
|
{ NULL, NULL, "Flow control", NULL },
|
||||||
|
{ "cont", "cont", "Continue execution (leave debugger).", KdbpCmdContinue },
|
||||||
|
{ "step", "step [count]", "Execute single instructions, stepping into interrupts.", KdbpCmdStep },
|
||||||
|
{ "next", "next [count]", "Execute single instructions, skipping calls and reps.", KdbpCmdStep },
|
||||||
|
{ "bl", "bl", "List breakpoints.", KdbpCmdBreakPointList },
|
||||||
|
{ "be", "be [breakpoint]", "Enable breakpoint.", KdbpCmdEnableDisableClearBreakPoint },
|
||||||
|
{ "bd", "bd [breakpoint]", "Disable breakpoint.", KdbpCmdEnableDisableClearBreakPoint },
|
||||||
|
{ "bc", "bc [breakpoint]", "Clear breakpoint.", KdbpCmdEnableDisableClearBreakPoint },
|
||||||
|
{ "bpx", "bpx [address] [IF condition]", "Set software execution breakpoint at address.", KdbpCmdBreakPoint },
|
||||||
|
{ "bpm", "bpm [r|w|rw|x] [byte|word|dword] [address] [IF condition]", "Set memory breakpoint at address.", KdbpCmdBreakPoint },
|
||||||
|
|
||||||
|
/* Process/Thread */
|
||||||
|
{ NULL, NULL, "Process/Thread", NULL },
|
||||||
|
{ "thread", "thread [list[ pid]|[attach ]tid]", "List threads in current or specified process, display thread with given id or attach to thread.", KdbpCmdThread },
|
||||||
|
{ "proc", "proc [list|[attach ]pid]", "List processes, display process with given id or attach to process.", KdbpCmdProc },
|
||||||
|
|
||||||
|
/* System information */
|
||||||
|
{ NULL, NULL, "System info", NULL },
|
||||||
|
{ "mod", "mod [address]", "List all modules or the one containing address.", KdbpCmdMod },
|
||||||
|
{ "gdt", "gdt", "Display the global descriptor table.", KdbpCmdGdtLdtIdt },
|
||||||
|
{ "ldt", "ldt", "Display the local descriptor table.", KdbpCmdGdtLdtIdt },
|
||||||
|
{ "idt", "idt", "Display the interrupt descriptor table.", KdbpCmdGdtLdtIdt },
|
||||||
|
{ "pcr", "pcr", "Display the processor control region.", KdbpCmdPcr },
|
||||||
|
{ "tss", "tss [selector|*descaddr]", "Display the current task state segment, or the one specified by its selector number or descriptor address.", KdbpCmdTss },
|
||||||
|
|
||||||
|
/* Others */
|
||||||
|
{ NULL, NULL, "Others", NULL },
|
||||||
|
{ "bugcheck", "bugcheck", "Bugchecks the system.", KdbpCmdBugCheck },
|
||||||
|
{ "reboot", "reboot", "Reboots the system.", KdbpCmdReboot},
|
||||||
|
{ "filter", "filter [error|warning|trace|info|level]+|-[componentname|default]", "Enable/disable debug channels.", KdbpCmdFilter },
|
||||||
|
{ "set", "set [var] [value]", "Sets var to value or displays value of var.", KdbpCmdSet },
|
||||||
|
{ "dmesg", "dmesg", "Display debug messages on screen, with navigation on pages.", KdbpCmdDmesg },
|
||||||
|
{ "kmsg", "kmsg", "Kernel dmesg. Alias for dmesg.", KdbpCmdDmesg },
|
||||||
|
{ "help", "help", "Display help screen.", KdbpCmdHelp },
|
||||||
|
{ "!pool", "!pool [Address [Flags]]", "Display information about pool allocations.", ExpKdbgExtPool },
|
||||||
|
{ "!poolused", "!poolused [Flags [Tag]]", "Display pool usage.", ExpKdbgExtPoolUsed },
|
||||||
|
{ "!poolfind", "!poolfind Tag [Pool]", "Search for pool tag allocations.", ExpKdbgExtPoolFind },
|
||||||
|
{ "!filecache", "!filecache", "Display cache usage.", ExpKdbgExtFileCache },
|
||||||
|
{ "!defwrites", "!defwrites", "Display cache write values.", ExpKdbgExtDefWrites },
|
||||||
|
{ "!irpfind", "!irpfind [Pool [startaddress [criteria data]]]", "Lists IRPs potentially matching criteria.", ExpKdbgExtIrpFind },
|
||||||
|
{ "!handle", "!handle [Handle]", "Displays info about handles.", ExpKdbgExtHandle },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
/*!\brief Evaluates an expression...
|
/*!\brief Evaluates an expression...
|
||||||
*
|
*
|
||||||
|
@ -647,7 +626,34 @@ end:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!\brief Display list of active debug channels
|
/*!\brief Retrieves the component ID corresponding to a given component name.
|
||||||
|
*
|
||||||
|
* \param ComponentName The name of the component.
|
||||||
|
* \param ComponentId Receives the component id on success.
|
||||||
|
*
|
||||||
|
* \retval TRUE Success.
|
||||||
|
* \retval FALSE Failure.
|
||||||
|
*/
|
||||||
|
static BOOLEAN
|
||||||
|
KdbpGetComponentId(
|
||||||
|
IN PCSTR ComponentName,
|
||||||
|
OUT PULONG ComponentId)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(ComponentTable) / sizeof(ComponentTable[0]); i++)
|
||||||
|
{
|
||||||
|
if (_stricmp(ComponentName, ComponentTable[i].Name) == 0)
|
||||||
|
{
|
||||||
|
*ComponentId = ComponentTable[i].Id;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!\brief Displays the list of active debug channels, or enable/disable debug channels.
|
||||||
*/
|
*/
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
KdbpCmdFilter(
|
KdbpCmdFilter(
|
||||||
|
@ -657,11 +663,11 @@ KdbpCmdFilter(
|
||||||
ULONG i, j, ComponentId, Level;
|
ULONG i, j, ComponentId, Level;
|
||||||
ULONG set = DPFLTR_MASK, clear = DPFLTR_MASK;
|
ULONG set = DPFLTR_MASK, clear = DPFLTR_MASK;
|
||||||
PCHAR pend;
|
PCHAR pend;
|
||||||
LPCSTR opt, p;
|
PCSTR opt, p;
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
LPCSTR Name;
|
PCSTR Name;
|
||||||
ULONG Level;
|
ULONG Level;
|
||||||
}
|
}
|
||||||
debug_classes[] =
|
debug_classes[] =
|
||||||
|
@ -672,11 +678,29 @@ KdbpCmdFilter(
|
||||||
{ "info", 1 << DPFLTR_INFO_LEVEL },
|
{ "info", 1 << DPFLTR_INFO_LEVEL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (Argc <= 1)
|
||||||
|
{
|
||||||
|
/* Display the list of available debug filter components */
|
||||||
|
KdbpPrint("REMARKS:\n"
|
||||||
|
"- The 'WIN2000' system-wide debug filter component is used for DbgPrint()\n"
|
||||||
|
" messages without Component ID and Level.\n"
|
||||||
|
"- The 'DEFAULT' debug filter component is used for DbgPrint() messages with\n"
|
||||||
|
" an unknown Component ID.\n\n");
|
||||||
|
KdbpPrint("The list of debug filter components currently available on your system is:\n\n");
|
||||||
|
KdbpPrint(" Component Name Component ID\n"
|
||||||
|
"================ ==============\n");
|
||||||
|
for (i = 0; i < sizeof(ComponentTable) / sizeof(ComponentTable[0]); i++)
|
||||||
|
{
|
||||||
|
KdbpPrint("%16s 0x%08lx\n", ComponentTable[i].Name, ComponentTable[i].Id);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 1; i < Argc; i++)
|
for (i = 1; i < Argc; i++)
|
||||||
{
|
{
|
||||||
opt = Argv[i];
|
opt = Argv[i];
|
||||||
p = opt + strcspn(opt, "+-");
|
p = opt + strcspn(opt, "+-");
|
||||||
if (!p[0]) p = opt; /* assume it's a debug channel name */
|
if (!p[0]) p = opt; /* Assume it's a debug channel name */
|
||||||
|
|
||||||
if (p > opt)
|
if (p > opt)
|
||||||
{
|
{
|
||||||
|
@ -685,7 +709,7 @@ KdbpCmdFilter(
|
||||||
SIZE_T len = strlen(debug_classes[j].Name);
|
SIZE_T len = strlen(debug_classes[j].Name);
|
||||||
if (len != (p - opt))
|
if (len != (p - opt))
|
||||||
continue;
|
continue;
|
||||||
if (_strnicmp(opt, debug_classes[j].Name, len) == 0) /* found it */
|
if (_strnicmp(opt, debug_classes[j].Name, len) == 0) /* Found it */
|
||||||
{
|
{
|
||||||
if (*p == '+')
|
if (*p == '+')
|
||||||
set |= debug_classes[j].Level;
|
set |= debug_classes[j].Level;
|
||||||
|
@ -3521,7 +3545,7 @@ BOOLEAN
|
||||||
KdbpInvokeCliCallbacks(
|
KdbpInvokeCliCallbacks(
|
||||||
IN PCHAR Command,
|
IN PCHAR Command,
|
||||||
IN ULONG Argc,
|
IN ULONG Argc,
|
||||||
IN PCH Argv[])
|
IN PCHAR Argv[])
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
|
@ -3559,7 +3583,7 @@ KdbpDoCommand(
|
||||||
PCHAR p;
|
PCHAR p;
|
||||||
ULONG Argc;
|
ULONG Argc;
|
||||||
// FIXME: for what do we need a 1024 characters command line and 256 tokens?
|
// FIXME: for what do we need a 1024 characters command line and 256 tokens?
|
||||||
static PCH Argv[256];
|
static PCHAR Argv[256];
|
||||||
static CHAR OrigCommand[1024];
|
static CHAR OrigCommand[1024];
|
||||||
|
|
||||||
RtlStringCbCopyA(OrigCommand, sizeof(OrigCommand), Command);
|
RtlStringCbCopyA(OrigCommand, sizeof(OrigCommand), Command);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue