Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
4.3 KiB

  1. /*** debugger.c - Debugger functions
  2. *
  3. * This module contains all the debug functions.
  4. *
  5. * Copyright (c) 1996,1997 Microsoft Corporation
  6. * Author: Michael Tsang (MikeTs)
  7. * Created 09/18/96
  8. *
  9. * MODIFICATION HISTORY
  10. */
  11. #include "pch.h"
  12. #ifdef DEBUGGER
  13. /*** Miscellaneous Constants
  14. */
  15. #define MAX_CMDLINE_LEN 255
  16. /*** Local function prototypes
  17. */
  18. LONG LOCAL DbgExecuteCmd(PDBGCMD pDbgCmds, PSZ pszCmd);
  19. BOOLEAN LOCAL IsCommandInAMLIExtension(PSZ pszCmd);
  20. /*** Local data
  21. */
  22. PSZ pszTokenSeps = " \t\n";
  23. /***LP Debugger - generic debugger entry point
  24. *
  25. * ENTRY
  26. * pDbgCmds -> debugger command table
  27. * pszPrompt -> prompt string
  28. *
  29. * EXIT
  30. * None
  31. */
  32. VOID LOCAL Debugger(PDBGCMD pDbgCmds, PSZ pszPrompt)
  33. {
  34. char szCmdLine[MAX_CMDLINE_LEN + 1];
  35. char Buffer[MAX_CMDLINE_LEN + 1];
  36. PSZ psz;
  37. for (;;)
  38. {
  39. ConPrompt(pszPrompt, szCmdLine, sizeof(szCmdLine));
  40. STRCPY(Buffer, szCmdLine);
  41. if((psz = STRTOK(szCmdLine, pszTokenSeps)) != NULL)
  42. {
  43. if(IsCommandInAMLIExtension(psz))
  44. {
  45. char Command[MAX_CMDLINE_LEN + (10 * sizeof(char))] = {0};
  46. char Name[] = "ACPI";
  47. STRCPY(Command, "!AMLI ");
  48. STRCAT(Command, Buffer);
  49. STRCAT(Command, " ; g");
  50. DbgCommandString(Name, Command);
  51. }
  52. else if (DbgExecuteCmd(pDbgCmds, psz) == DBGERR_QUIT)
  53. break;
  54. }
  55. }
  56. } //Debugger
  57. /***LP DbgExecuteCmd - execute a debugger command
  58. *
  59. * ENTRY
  60. * pDbgCmds -> debugger command table
  61. * pszCmd -> command string
  62. *
  63. * EXIT-SUCCESS
  64. * returns DBGERR_NONE or DBGERR_QUIT
  65. * EXIT-FAILURE
  66. * returns negative error code
  67. */
  68. LONG LOCAL DbgExecuteCmd(PDBGCMD pDbgCmds, PSZ pszCmd)
  69. {
  70. LONG rc = DBGERR_NONE;
  71. int i;
  72. ULONG dwNumArgs = 0, dwNonSWArgs = 0;
  73. for (i = 0; pDbgCmds[i].pszCmd != NULL; i++)
  74. {
  75. if (STRCMP(pszCmd, pDbgCmds[i].pszCmd) == 0)
  76. {
  77. if (pDbgCmds[i].dwfCmd & CMDF_QUIT)
  78. {
  79. rc = DBGERR_QUIT;
  80. }
  81. else if ((pDbgCmds[i].pArgTable == NULL) ||
  82. ((rc = DbgParseArgs(pDbgCmds[i].pArgTable, &dwNumArgs,
  83. &dwNonSWArgs, pszTokenSeps)) ==
  84. ARGERR_NONE))
  85. {
  86. if (pDbgCmds[i].pfnCmd != NULL)
  87. rc = pDbgCmds[i].pfnCmd(NULL, NULL, dwNumArgs, dwNonSWArgs);
  88. }
  89. else
  90. rc = DBGERR_PARSE_ARGS;
  91. break;
  92. }
  93. }
  94. if (pDbgCmds[i].pszCmd == NULL)
  95. {
  96. DBG_ERROR(("invalid command - %s", pszCmd));
  97. rc = DBGERR_INVALID_CMD;
  98. }
  99. return rc;
  100. } //DbgExecuteCmd
  101. BOOLEAN LOCAL IsCommandInAMLIExtension(PSZ pszCmd)
  102. {
  103. BOOLEAN bRet = FALSE;
  104. ULONG i = 0;
  105. static PSZ CommandsInAMLIExtension[] = { "bc",
  106. "bd",
  107. "be",
  108. "bl",
  109. "bp",
  110. "cl",
  111. "dh",
  112. "dl",
  113. "dns",
  114. "do",
  115. "ds",
  116. "find",
  117. "lc",
  118. "ln",
  119. "r",
  120. "set",
  121. "u"
  122. };
  123. ULONG NumCommands = (sizeof(CommandsInAMLIExtension)/sizeof(PSZ));
  124. for(i = 0; i < NumCommands; i++)
  125. {
  126. if(STRCMPI(CommandsInAMLIExtension[i], pszCmd) == 0)
  127. {
  128. bRet = TRUE;
  129. break;
  130. }
  131. }
  132. return bRet;
  133. }
  134. #endif //ifdef DEBUGGER