Debugger: Improve command help support.

For incorrect argument count, display full help for the command.
For help command itself, allow an argument to specify a command.
This commit is contained in:
Robert Moore 2012-08-17 13:43:02 -07:00
parent 54e0432053
commit 12664756d8
7 changed files with 243 additions and 101 deletions

View File

@ -138,9 +138,19 @@ static void
AcpiDbSingleThread (
void);
static void
AcpiDbDisplayCommandInfo (
char *Command,
BOOLEAN DisplayAll);
static void
AcpiDbDisplayHelp (
void);
char *Command);
static BOOLEAN
AcpiDbMatchCommandHelp (
char *Command,
const ACPI_DB_COMMAND_HELP *Help);
/*
@ -217,7 +227,7 @@ enum AcpiExDebuggerCommands
/* Second parameter is the required argument count */
static const COMMAND_INFO AcpiGbl_DbCommands[] =
static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] =
{
{"<NOT FOUND>", 0},
{"<NULL>", 0},
@ -269,7 +279,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] =
{"RESULTS", 0},
{"SET", 3},
{"SLEEP", 1},
{"STATS", 0},
{"STATS", 1},
{"STOP", 0},
{"TABLES", 0},
{"TEMPLATE", 1},
@ -282,100 +292,228 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] =
{NULL, 0}
};
/*
* Help for all debugger commands. First argument is the number of lines
* of help to output for the command.
*/
static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] =
{
{0, "\nGeneral-Purpose Commands:", "\n"},
{1, " Allocations", "Display list of current memory allocations\n"},
{2, " Dump <Address>|<Namepath>", "\n"},
{0, " [Byte|Word|Dword|Qword]", "Display ACPI objects or memory\n"},
{1, " EnableAcpi", "Enable ACPI (hardware) mode\n"},
{1, " Handlers", "Info about global handlers\n"},
{1, " Help [Command]", "This help screen or individual command\n"},
{1, " History", "Display command history buffer\n"},
{1, " Level <DebugLevel>] [console]", "Get/Set debug level for file or console\n"},
{1, " Locks", "Current status of internal mutexes\n"},
{1, " Osi [Install|Remove <name>]", "Display or modify global _OSI list\n"},
{1, " Quit or Exit", "Exit this command\n"},
{9, " Stats [Allocations|Memory|Misc|", "\n"},
{1, " Objects|Sizes|Stack|Tables]", "Display namespace and memory statistics\n"},
{1, " Allocations", "Display list of current memory allocations\n"},
{1, " Memory", "Dump internal memory lists\n"},
{1, " Misc", "Namespace search and mutex stats\n"},
{1, " Objects", "Summary of namespace objects\n"},
{1, " Sizes", "Sizes for each of the internal objects\n"},
{1, " Stack", "Display CPU stack usage\n"},
{1, " Tables", "Info about current ACPI table(s)\n"},
{1, " Tables", "Display info about loaded ACPI tables\n"},
{1, " Unload <Namepath>", "Unload an ACPI table via namespace object\n"},
{1, " ! <CommandNumber>", "Execute command from history buffer\n"},
{1, " !!", "Execute last command again\n"},
{0, "\nNamespace Access Commands:", "\n"},
{1, " Businfo", "Display system bus info\n"},
{1, " Disassemble <Method>", "Disassemble a control method\n"},
{1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"},
{1, " Find <AcpiName> (? is wildcard)", "Find ACPI name(s) with wildcards\n"},
{1, " Gpe <GpeNum> <GpeBlock>", "Simulate a GPE\n"},
{1, " Gpes", "Display info on all GPEs\n"},
{1, " Integrity", "Validate namespace integrity\n"},
{1, " Methods", "Display list of loaded control methods\n"},
{1, " Namespace [Object] [Depth]", "Display loaded namespace tree/subtree\n"},
{1, " Notify <Object> <Value>", "Send a notification on Object\n"},
{1, " Objects <ObjectType>", "Display all objects of the given type\n"},
{1, " Owner <OwnerId> [Depth]", "Display loaded namespace by object owner\n"},
{1, " Predefined", "Check all predefined names\n"},
{1, " Prefix [<NamePath>]", "Set or Get current execution prefix\n"},
{1, " References <Addr>", "Find all references to object at addr\n"},
{1, " Resources <DeviceName | *>", "Display Device resources (* = all devices)\n"},
{1, " Set N <NamedObject> <Value>", "Set value for named integer\n"},
{1, " Sleep <SleepState>", "Simulate sleep/wake sequence\n"},
{1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"},
{1, " Terminate", "Delete namespace and all internal objects\n"},
{1, " Type <Object>", "Display object type\n"},
{0, "\nControl Method Execution Commands:","\n"},
{1, " Arguments (or Args)", "Display method arguments\n"},
{1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\n"},
{1, " Call", "Run to next control method invocation\n"},
{1, " Debug <Namepath> [Arguments]", "Single Step a control method\n"},
{5, " Execute <Namepath> [Arguments]", "Execute control method\n"},
{1, " Hex Integer", "Integer method argument\n"},
{1, " \"Ascii String\"", "String method argument\n"},
{1, " (Byte List)", "Buffer method argument\n"},
{1, " [Package Element List]", "Package method argument\n"},
{1, " Go", "Allow method to run to completion\n"},
{1, " Information", "Display info about the current method\n"},
{1, " Into", "Step into (not over) a method call\n"},
{1, " List [# of Aml Opcodes]", "Display method ASL statements\n"},
{1, " Locals", "Display method local variables\n"},
{1, " Results", "Display method result stack\n"},
{1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"},
{1, " Stop", "Terminate control method\n"},
{1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"},
{1, " Trace <method name>", "Trace method execution\n"},
{1, " Tree", "Display control method calling tree\n"},
{1, " <Enter>", "Single step next AML opcode (over calls)\n"},
{0, "\nFile I/O Commands:", "\n"},
{1, " Close", "Close debug output file\n"},
{1, " Load <Input Filename>", "Load ACPI table from a file\n"},
{1, " Open <Output Filename>", "Open a file for debug output\n"},
{0, NULL, NULL}
};
/*******************************************************************************
*
* FUNCTION: AcpiDbMatchCommandHelp
*
* PARAMETERS: Command - Command string to match
* Help - Help table entry to attempt match
*
* RETURN: TRUE if command matched, FALSE otherwise
*
* DESCRIPTION: Attempt to match a command in the help table in order to
* print help information for a single command.
*
******************************************************************************/
static BOOLEAN
AcpiDbMatchCommandHelp (
char *Command,
const ACPI_DB_COMMAND_HELP *Help)
{
char *Invocation = Help->Invocation;
UINT32 LineCount;
/* Valid commands in the help table begin with a couple of spaces */
if (*Invocation != ' ')
{
return (FALSE);
}
while (*Invocation == ' ')
{
Invocation++;
}
/* Match command name (full command or substring) */
while ((*Command) && (*Invocation) && (*Invocation != ' '))
{
if (ACPI_TOLOWER (*Command) != ACPI_TOLOWER (*Invocation))
{
return (FALSE);
}
Invocation++;
Command++;
}
/* Print the appropriate number of help lines */
LineCount = Help->LineCount;
while (LineCount)
{
AcpiOsPrintf ("%-38s : %s", Help->Invocation, Help->Description);
Help++;
LineCount--;
}
return (TRUE);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDisplayCommandInfo
*
* PARAMETERS: Command - Command string to match
* DisplayAll - Display all matching commands, or just
* the first one (substring match)
*
* RETURN: None
*
* DESCRIPTION: Display help information for a Debugger command.
*
******************************************************************************/
static void
AcpiDbDisplayCommandInfo (
char *Command,
BOOLEAN DisplayAll)
{
const ACPI_DB_COMMAND_HELP *Next;
BOOLEAN Matched;
Next = AcpiGbl_DbCommandHelp;
while (Next->Invocation)
{
Matched = AcpiDbMatchCommandHelp (Command, Next);
if (!DisplayAll && Matched)
{
return;
}
Next++;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDisplayHelp
*
* PARAMETERS: None
* PARAMETERS: Command - Optional command string to display help.
* if not specified, all debugger command
* help strings are displayed
*
* RETURN: None
*
* DESCRIPTION: Print a usage message.
* DESCRIPTION: Display help for a single debugger command, or all of them.
*
******************************************************************************/
static void
AcpiDbDisplayHelp (
void)
char *Command)
{
const ACPI_DB_COMMAND_HELP *Next = AcpiGbl_DbCommandHelp;
AcpiOsPrintf ("\nGeneral-Purpose Commands:\n");
AcpiOsPrintf (" Allocations Display list of current memory allocations\n");
AcpiOsPrintf (" Dump <Address>|<Namepath>\n");
AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n");
AcpiOsPrintf (" EnableAcpi Enable ACPI (hardware) mode\n");
AcpiOsPrintf (" Handlers Info about global handlers\n");
AcpiOsPrintf (" Help This help screen\n");
AcpiOsPrintf (" History Display command history buffer\n");
AcpiOsPrintf (" Level [<DebugLevel>] [console] Get/Set debug level for file or console\n");
AcpiOsPrintf (" Locks Current status of internal mutexes\n");
AcpiOsPrintf (" Osi [Install|Remove <name>] Display or modify global _OSI list\n");
AcpiOsPrintf (" Quit or Exit Exit this command\n");
AcpiOsPrintf (" Stats [Allocations|Memory|Misc|\n");
AcpiOsPrintf (" Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n");
AcpiOsPrintf (" Allocations Display list of current memory allocations\n");
AcpiOsPrintf (" Memory Dump internal memory lists\n");
AcpiOsPrintf (" Misc Namespace search and mutex stats\n");
AcpiOsPrintf (" Objects Summary of namespace objects\n");
AcpiOsPrintf (" Sizes Sizes for each of the internal objects\n");
AcpiOsPrintf (" Stack Display CPU stack usage\n");
AcpiOsPrintf (" Tables Info about current ACPI table(s)\n");
AcpiOsPrintf (" Tables Display info about loaded ACPI tables\n");
AcpiOsPrintf (" Unload <Namepath> Unload an ACPI table via namespace object\n");
AcpiOsPrintf (" ! <CommandNumber> Execute command from history buffer\n");
AcpiOsPrintf (" !! Execute last command again\n");
AcpiOsPrintf ("\nNamespace Access Commands:\n");
AcpiOsPrintf (" Businfo Display system bus info\n");
AcpiOsPrintf (" Disassemble <Method> Disassemble a control method\n");
AcpiOsPrintf (" Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n");
AcpiOsPrintf (" Find <AcpiName> (? is wildcard) Find ACPI name(s) with wildcards\n");
AcpiOsPrintf (" Gpe <GpeNum> <GpeBlock> Simulate a GPE\n");
AcpiOsPrintf (" Gpes Display info on all GPEs\n");
AcpiOsPrintf (" Integrity Validate namespace integrity\n");
AcpiOsPrintf (" Methods Display list of loaded control methods\n");
AcpiOsPrintf (" Namespace [Object] [Depth] Display loaded namespace tree/subtree\n");
AcpiOsPrintf (" Notify <Object> <Value> Send a notification on Object\n");
AcpiOsPrintf (" Objects <ObjectType> Display all objects of the given type\n");
AcpiOsPrintf (" Owner <OwnerId> [Depth] Display loaded namespace by object owner\n");
AcpiOsPrintf (" Predefined Check all predefined names\n");
AcpiOsPrintf (" Prefix [<NamePath>] Set or Get current execution prefix\n");
AcpiOsPrintf (" References <Addr> Find all references to object at addr\n");
AcpiOsPrintf (" Resources <DeviceName | *> Display Device resources (* = all devices)\n");
AcpiOsPrintf (" Set N <NamedObject> <Value> Set value for named integer\n");
AcpiOsPrintf (" Sleep <SleepState> Simulate sleep/wake sequence\n");
AcpiOsPrintf (" Template <Object> Format/dump a Buffer/ResourceTemplate\n");
AcpiOsPrintf (" Terminate Delete namespace and all internal objects\n");
AcpiOsPrintf (" Type <Object> Display object type\n");
if (!Command)
{
/* No argument to help, display help for all commands */
AcpiOsPrintf ("\nControl Method Execution Commands:\n");
AcpiOsPrintf (" Arguments (or Args) Display method arguments\n");
AcpiOsPrintf (" Breakpoint <AmlOffset> Set an AML execution breakpoint\n");
AcpiOsPrintf (" Call Run to next control method invocation\n");
AcpiOsPrintf (" Debug <Namepath> [Arguments] Single Step a control method\n");
AcpiOsPrintf (" Execute <Namepath> [Arguments] Execute control method\n");
AcpiOsPrintf (" Hex Integer Integer method argument\n");
AcpiOsPrintf (" \"Ascii String\" String method argument\n");
AcpiOsPrintf (" (Byte List) Buffer method argument\n");
AcpiOsPrintf (" [Package Element List] Package method argument\n");
AcpiOsPrintf (" Go Allow method to run to completion\n");
AcpiOsPrintf (" Information Display info about the current method\n");
AcpiOsPrintf (" Into Step into (not over) a method call\n");
AcpiOsPrintf (" List [# of Aml Opcodes] Display method ASL statements\n");
AcpiOsPrintf (" Locals Display method local variables\n");
AcpiOsPrintf (" Results Display method result stack\n");
AcpiOsPrintf (" Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n");
AcpiOsPrintf (" Stop Terminate control method\n");
AcpiOsPrintf (" Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n");
AcpiOsPrintf (" Trace <method name> Trace method execution\n");
AcpiOsPrintf (" Tree Display control method calling tree\n");
AcpiOsPrintf (" <Enter> Single step next AML opcode (over calls)\n");
while (Next->Invocation)
{
AcpiOsPrintf ("%-38s%s", Next->Invocation, Next->Description);
Next++;
}
}
else
{
/* Display help for all commands that match the subtring */
AcpiOsPrintf ("\nFile I/O Commands:\n");
AcpiOsPrintf (" Close Close debug output file\n");
AcpiOsPrintf (" Load <Input Filename> Load ACPI table from a file\n");
AcpiOsPrintf (" Open <Output Filename> Open a file for debug output\n");
AcpiDbDisplayCommandInfo (Command, TRUE);
}
}
@ -673,6 +811,7 @@ AcpiDbCommandDispatch (
ParamCount, AcpiGbl_DbCommands[CommandIndex].Name,
AcpiGbl_DbCommands[CommandIndex].MinArgs);
AcpiDbDisplayCommandInfo (AcpiGbl_DbCommands[CommandIndex].Name, FALSE);
return (AE_CTRL_TRUE);
}
@ -776,7 +915,7 @@ AcpiDbCommandDispatch (
case CMD_HELP:
case CMD_HELP2:
AcpiDbDisplayHelp ();
AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
break;
case CMD_HISTORY:

View File

@ -474,7 +474,7 @@ AcpiDbWalkForExecute (
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
ACPI_EXECUTE_WALK *Info = (ACPI_EXECUTE_WALK *) Context;
ACPI_DB_EXECUTE_WALK *Info = (ACPI_DB_EXECUTE_WALK *) Context;
ACPI_BUFFER ReturnObj;
ACPI_STATUS Status;
char *Pathname;
@ -574,7 +574,7 @@ void
AcpiDbBatchExecute (
char *CountArg)
{
ACPI_EXECUTE_WALK Info;
ACPI_DB_EXECUTE_WALK Info;
Info.Count = 0;

View File

@ -174,7 +174,7 @@ AcpiDbBusWalk (
* Arguments for the Objects command
* These object types map directly to the ACPI_TYPES
*/
static ARGUMENT_INFO AcpiDbObjectTypes [] =
static ACPI_DB_ARGUMENT_INFO AcpiDbObjectTypes [] =
{
{"ANY"},
{"INTEGERS"},

View File

@ -151,7 +151,7 @@ AcpiDbListInfo (
/*
* Statistics subcommands
*/
static ARGUMENT_INFO AcpiDbStatTypes [] =
static ACPI_DB_ARGUMENT_INFO AcpiDbStatTypes [] =
{
{"ALLOCATIONS"},
{"OBJECTS"},
@ -470,12 +470,6 @@ AcpiDbDisplayStatistics (
UINT32 Temp;
if (!TypeArg)
{
AcpiOsPrintf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n");
return (AE_OK);
}
AcpiUtStrupr (TypeArg);
Temp = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes);
if (Temp == (UINT32) -1)

View File

@ -157,7 +157,7 @@ static char *Converter = "0123456789ABCDEF";
ACPI_OBJECT_TYPE
AcpiDbMatchArgument (
char *UserArgument,
ARGUMENT_INFO *Arguments)
ACPI_DB_ARGUMENT_INFO *Arguments)
{
UINT32 i;

View File

@ -119,25 +119,33 @@
#define ACPI_DEBUG_BUFFER_SIZE 0x4000 /* 16K buffer for return objects */
typedef struct CommandInfo
typedef struct acpi_db_command_info
{
char *Name; /* Command Name */
UINT8 MinArgs; /* Minimum arguments required */
} COMMAND_INFO;
} ACPI_DB_COMMAND_INFO;
typedef struct ArgumentInfo
typedef struct acpi_db_command_help
{
UINT8 LineCount; /* Number of help lines */
char *Invocation; /* Command Invocation */
char *Description; /* Command Description */
} ACPI_DB_COMMAND_HELP;
typedef struct acpi_db_argument_info
{
char *Name; /* Argument Name */
} ARGUMENT_INFO;
} ACPI_DB_ARGUMENT_INFO;
typedef struct acpi_execute_walk
typedef struct acpi_db_execute_walk
{
UINT32 Count;
UINT32 MaxCount;
} ACPI_EXECUTE_WALK;
} ACPI_DB_EXECUTE_WALK;
#define PARAM_LIST(pl) pl
@ -376,7 +384,7 @@ AcpiDbGetCacheInfo (
ACPI_OBJECT_TYPE
AcpiDbMatchArgument (
char *UserArgument,
ARGUMENT_INFO *Arguments);
ACPI_DB_ARGUMENT_INFO *Arguments);
void
AcpiDbCloseDebugFile (

View File

@ -269,6 +269,10 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"ACPI_CONVERSION_TABLE", SRC_TYPE_STRUCT},
{"ACPI_CPU_FLAGS", SRC_TYPE_SIMPLE},
{"ACPI_CREATE_FIELD_INFO", SRC_TYPE_STRUCT},
{"ACPI_DB_ARGUMENT_INFO", SRC_TYPE_STRUCT},
{"ACPI_DB_COMMAND_HELP", SRC_TYPE_STRUCT},
{"ACPI_DB_COMMAND_INFO", SRC_TYPE_STRUCT},
{"ACPI_DB_EXECUTE_WALK", SRC_TYPE_STRUCT},
{"ACPI_DB_METHOD_INFO", SRC_TYPE_STRUCT},
{"ACPI_DEBUG_MEM_BLOCK", SRC_TYPE_STRUCT},
{"ACPI_DEBUG_MEM_HEADER", SRC_TYPE_STRUCT},
@ -289,7 +293,6 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"ACPI_EXDUMP_INFO", SRC_TYPE_STRUCT},
{"ACPI_EXECUTE_OP", SRC_TYPE_SIMPLE},
{"ACPI_EXECUTE_TYPE", SRC_TYPE_SIMPLE},
{"ACPI_EXECUTE_WALK", SRC_TYPE_STRUCT},
{"ACPI_EXTERNAL_LIST", SRC_TYPE_STRUCT},
{"ACPI_EXTERNAL_FILE", SRC_TYPE_STRUCT},
{"ACPI_FADT_INFO", SRC_TYPE_STRUCT},
@ -527,7 +530,6 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"AML_RESOURCE_VENDOR_SMALL", SRC_TYPE_STRUCT},
{"APIC_HEADER", SRC_TYPE_STRUCT},
{"ARGUMENT_INFO", SRC_TYPE_STRUCT},
{"AE_DEBUG_REGIONS", SRC_TYPE_STRUCT},
{"AE_REGION", SRC_TYPE_STRUCT},
{"AE_TABLE_DESC", SRC_TYPE_STRUCT},
@ -543,7 +545,6 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"ASL_RESERVED_INFO", SRC_TYPE_STRUCT},
{"ASL_RESOURCE_NODE", SRC_TYPE_STRUCT},
{"ASL_WALK_CALLBACK", SRC_TYPE_SIMPLE},
{"COMMAND_INFO", SRC_TYPE_STRUCT},
{"UINT64_OVERLAY", SRC_TYPE_UNION},
{"UINT64_STRUCT", SRC_TYPE_STRUCT},