Source code of Windows XP (NT5)
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.

157 lines
4.2 KiB

  1. typedef enum // tokens: * . ? [ ] / help dt dg L number <identifier>
  2. {
  3. tokSTAR, // *
  4. tokDOT, // .
  5. tokQUESTION, // ?
  6. tokLBRAC, // [
  7. tokRBRAC, // ]
  8. tokSLASH, // /
  9. tokKEYWORD, // alnum strings which match one of the known keys.
  10. tokNUMBER, // 0xcbde 129
  11. tokIDENTIFIER // non-keyword and non-number alnum
  12. } eTOKTYPE;
  13. typedef struct
  14. {
  15. eTOKTYPE eTok;
  16. UINT uID; // Tok-specific ID:
  17. // IDENTIFIER: a unique number across all identifiers.
  18. // NUMBER: the number
  19. // KEYWORD: eKEYWORD
  20. // Other tokens: uID is unused.
  21. char *szStr; // String containg original chars that made up this token.
  22. // Note: a string of pure hex digits which is followed
  23. // by a non-alnum char is assumed to be a number --
  24. // later if it turns out to be more likely that it is
  25. // an identifier, it is converted to an identifier.
  26. // Same deal with a keyword -- if it turns out based
  27. // on context to be most likely an identifier or part
  28. // of an identifier, it will be converted to an
  29. // identifier.
  30. } TOKEN;
  31. typedef enum
  32. {
  33. keywordNULL, // Invalid keyword, use for sentinels.
  34. keywordHELP, // help
  35. keywordDUMP_TYPE, // dt
  36. keywordDUMP_GLOBALS, // dg
  37. keywordL // L
  38. } eKEYWORD;
  39. //
  40. // Following is not used currently...
  41. //
  42. typedef enum
  43. {
  44. phraseCMD,
  45. phraseIDENTIFIER, // with optional wildcards
  46. phraseINDEX, // [2], [*], [1-3], etc.
  47. phraseDOT, // .
  48. phraseNUMBER, // 0x8908 abcd
  49. phraseOBJ_COUNT, // L 2
  50. phraseFLAG // /xyz
  51. } ePHRASE;
  52. typedef enum
  53. {
  54. cmdDUMP_TYPE,
  55. cmdDUMP_GLOBALS,
  56. cmdHELP
  57. }ePRIMARY_COMMAND;
  58. struct _DBGCOMMAND;
  59. typedef void (*PFN_SPECIAL_COMMAND_HANDLER)(struct _DBGCOMMAND *pCmd);
  60. typedef struct _DBGCOMMAND
  61. {
  62. NAMESPACE *pNameSpace; // Name space applicable for this command.
  63. ePRIMARY_COMMAND ePrimaryCmd; // DumpGlobals, DumpType, help
  64. UINT uFlags; // One or more fCMDFLAG_*
  65. TOKEN *ptokObject; // eg <type>
  66. TOKEN *ptokSubObject; // eg <field>
  67. UINT uVectorIndexStart; // if[0]
  68. UINT uVectorIndexEnd; // if[0]
  69. UINT uObjectAddress; // <address>
  70. UINT uObjectCount; // L 10
  71. void *pvContext; // private context.
  72. //PFN_SPECIAL_COMMAND_HANDLER pfnSpecialHandler;
  73. } DBGCOMMAND;
  74. #define fCMDFLAG_HAS_VECTOR_INDEX (0x1<<0)
  75. #define fCMDFLAG_HAS_SUBOBJECT (0x1<<1)
  76. #define fCMDFLAG_HAS_OBJECT_ADDRESS (0x1<<2)
  77. #define fCMDFLAG_HAS_OBJECT_COUNT (0x1<<3)
  78. #define fCMDFLAG_OBJECT_STAR_PREFIX (0x1<<4)
  79. #define fCMDFLAG_OBJECT_STAR_SUFFIX (0x1<<5)
  80. #define fCMDFLAG_SUBOBJECT_STAR_PREFIX (0x1<<6)
  81. #define fCMDFLAG_SUBOBJECT_STAR_SUFFIX (0x1<<7)
  82. #define CMD_SET_FLAG(_pCmd, _f) ((_pCmd)->uFlags |= (_f))
  83. #define CMD_CLEAR_FLAG(_pCmd, _f) ((_pCmd)->uFlags &= ~(_f))
  84. #define CMD_IS_FLAG_SET(_pCmd, _f) ((_pCmd)->uFlags & (_f))
  85. DBGCOMMAND *
  86. Parse(
  87. IN const char *szInput,
  88. IN NAMESPACE *
  89. );
  90. void
  91. FreeCommand(
  92. DBGCOMMAND *pCommand
  93. );
  94. void
  95. DumpCommand(
  96. DBGCOMMAND *pCommand
  97. );
  98. #if 0
  99. //!aac dt <type> . <field> <address> L <count> <flags>
  100. //!aac dt <type> [index] . <field> L <count> <flags>
  101. //!aac dg <name> . <field>
  102. //
  103. //!aac dt if[*].*handle* 0x324890 L 5
  104. 0. Break up sentance into tokens:
  105. keywords: * . L dg dt ? help [ ] /
  106. identifier: contiguous non-keyword alnum
  107. number: interpreted as hex with optional 0x.
  108. 1st pass: combine "[*]", "*word*", "/xyz" into single entities
  109. 1. Parse primary command: literal text
  110. 2. Parse primary object: [*]literal_text[*]
  111. 3. Parse index "[...]"
  112. 4. Parse field "."
  113. 5. Parse address (hex number)
  114. 6. Parse object count L <count>
  115. #endif // 0
  116. void
  117. DoCommand(DBGCOMMAND *pCmd, PFN_SPECIAL_COMMAND_HANDLER pfnHandler);
  118. void
  119. DoDumpType(DBGCOMMAND *pCmd);
  120. void
  121. DoDumpGlobals(DBGCOMMAND *pCmd);
  122. void
  123. DoHelp(DBGCOMMAND *pCmd);