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.

342 lines
6.5 KiB

  1. #define MYASSERT(_cond) \
  2. ((_cond) ? 0 : MyDbgPrintf("ASSERTION FAILED\n"))
  3. typedef int bool;
  4. //
  5. // Debugger Extension Primitives
  6. //
  7. bool
  8. dbgextReadMemory(
  9. UINT_PTR uOffset,
  10. void * pvBuffer,
  11. UINT cb,
  12. char *pszDescription
  13. );
  14. bool
  15. dbgextReadUINT(
  16. UINT_PTR uOffset,
  17. UINT *pu,
  18. char *pszDescription
  19. );
  20. bool
  21. dbgextReadUINT_PTR(
  22. UINT_PTR uOffset,
  23. UINT_PTR *pu,
  24. char *pszDescription
  25. );
  26. bool
  27. dbgextReadSZ(
  28. UINT_PTR uOffset,
  29. char *szBuf,
  30. UINT cbMax,
  31. char *pszDescription
  32. );
  33. bool
  34. dbgextWriteMemory(
  35. UINT_PTR uOffset,
  36. void * pvBuffer,
  37. UINT cb,
  38. char *pszDescription
  39. );
  40. bool
  41. dbgextWriteUINT_PTR(
  42. UINT_PTR uOffset,
  43. UINT_PTR u,
  44. char *pszDescription
  45. );
  46. UINT_PTR
  47. dbgextGetExpression(
  48. const char *pcszExpression
  49. );
  50. #if 0 // Not sure what this one is about...
  51. void
  52. dbgextGetSymbol(
  53. void *offset,
  54. UCHAR *pchBuffer,
  55. UINT *pDisplacement
  56. );
  57. #endif // 0
  58. void
  59. dbgextDumpDLlist(
  60. UINT_PTR uOffset,
  61. UINT uContainingOffset,
  62. char *pszDescription
  63. );
  64. typedef
  65. void
  66. (__cdecl *MYPWINDBG_OUTPUT_ROUTINE)(
  67. const char * lpFormat,
  68. ...
  69. );
  70. extern MYPWINDBG_OUTPUT_ROUTINE g_pfnDbgPrintf;
  71. #define MyDbgPrintf g_pfnDbgPrintf
  72. //
  73. // User Commands Parsing Support and Structures
  74. //
  75. typedef struct
  76. {
  77. //TOKEN tokCmd;
  78. UINT uParam;
  79. UINT uFlags;
  80. } COMMAND;
  81. struct _TYPE_INFO;
  82. typedef
  83. void
  84. (*PFN_SPECIALIZED_DUMP)(
  85. struct _TYPE_INFO *pType,
  86. UINT_PTR uAddr,
  87. char *szFieldSpec,
  88. UINT uFlags
  89. );
  90. #define fDUMP_ONE_LINE_SUMMARY (0x1)
  91. typedef struct
  92. {
  93. char *szName;
  94. UINT Mask;
  95. UINT Value;
  96. } BITFIELD_INFO;
  97. typedef struct _TYPE_INFO
  98. {
  99. const char * szName;
  100. const char * szShortName;
  101. UINT uTypeID;
  102. UINT uFlags; // One or more fTYPEINFO_ flags.
  103. UINT cbSize;
  104. struct _STRUCT_FIELD_INFO *rgFields;
  105. UINT uNextOffset;
  106. // If this type is a list element, this is the offset
  107. // in bytes to the next pointer.
  108. // Only valid if uFlags contains fTYPEINFO_ISLIST
  109. BITFIELD_INFO *rgBitFieldInfo;
  110. //
  111. // If this type is a bitfield, this this points
  112. // to an array of BITFIELD_INFO structs, giving
  113. // the set of valid bitfield constants that can
  114. // be held in this bitfield.
  115. //
  116. // Note -- only one of rgFields and rgBitField info
  117. // should be non-null (both can be null).
  118. //
  119. PFN_SPECIALIZED_DUMP pfnSpecializedDump;
  120. //
  121. // If nonzero, use this function instead of the standard
  122. // structure dumping routine.
  123. //
  124. UINT_PTR uCachedAddress; // Set to the address of this type that
  125. // was most recently referenced.
  126. } TYPE_INFO;
  127. #define fTYPEINFO_ISLIST (0x1<<0)
  128. #define fTYPEINFO_ISBITFIELD (0x1<<1)
  129. #define TYPEISLIST(_pType) ((_pType)->uFlags & fTYPEINFO_ISLIST)
  130. #define TYPEISBITFIELD(_pType) ((_pType)->uFlags & fTYPEINFO_ISBITFIELD)
  131. //
  132. // STRUCT_FIELD_INFO contains information about a particular field of a struct.
  133. //
  134. typedef struct _STRUCT_FIELD_INFO
  135. {
  136. const char *szFieldName;
  137. UINT uFieldOffset; // Offset in bytes from start of containing structure.
  138. UINT uFieldSize;
  139. UINT uFlags; // one or more fFI_* flags define below
  140. TYPE_INFO *pBaseType;
  141. } STRUCT_FIELD_INFO;
  142. #define fFI_PTR (0x1<<0) // Field is a pointer
  143. #define fFI_LIST (0x1<<1) // Field is a pointer to 1st element of a list
  144. #define fFI_ARRAY (0x1<<2) // Field is an array (pointer to array if
  145. // fFI_PTR is set).
  146. #define fFI_OPAQUE (0x1<<3) // Treat object as opaque, of size uObjectSize.
  147. // If set then fLIST must not be set.
  148. #define FIELD_IS_EMBEDDED_TYPE(_pFI) \
  149. ( !((_pFI)->uFlags & (fFI_PTR|fFI_OPAQUE|fFI_ARRAY)) \
  150. && ((_pFI)->pBaseType))
  151. //
  152. // true iff the field is itself a valid type
  153. //
  154. #define FIELD_IS_PTR_TO_TYPE(_pFI) \
  155. ( ((_pFI)->uFlags & fFI_PTR) \
  156. && !((_pFI)->uFlags & (fFI_OPAQUE|fFI_ARRAY)) \
  157. && ((_pFI)->pBaseType))
  158. //
  159. // true iff the field is pointer to a valid type
  160. //
  161. #define FIELD_SIZE(type, field) sizeof(((type *)0)->field)
  162. //
  163. // Information about a global variable.
  164. //
  165. typedef struct
  166. {
  167. const char *szName; // of variable.
  168. const char *szShortName;
  169. TYPE_INFO *pBaseType; // could be null (unspecified).
  170. UINT uFlags;
  171. UINT cbSize;
  172. UINT_PTR uAddr; // Address in debuggee's address space.
  173. } GLOBALVAR_INFO;
  174. typedef
  175. UINT_PTR
  176. (*PFN_RESOLVE_ADDRESS)(
  177. TYPE_INFO *pType
  178. );
  179. typedef struct
  180. {
  181. TYPE_INFO **pTypes;
  182. GLOBALVAR_INFO *pGlobals;
  183. PFN_RESOLVE_ADDRESS pfnResolveAddress;
  184. } NAMESPACE;
  185. void
  186. DumpObjects(TYPE_INFO *pType, UINT_PTR uAddr, UINT cObjects, UINT uFlags);
  187. #define fMATCH_SUBSTRING (0x1<<0)
  188. #define fMATCH_PREFIX (0x1<<1)
  189. #define fMATCH_SUFFIX (0x1<<2)
  190. void
  191. DumpStructure(
  192. TYPE_INFO *pType,
  193. UINT_PTR uAddr,
  194. char *szFieldSpec,
  195. UINT uFlags
  196. );
  197. bool
  198. DumpMemory(
  199. UINT_PTR uAddr,
  200. UINT cb,
  201. UINT uFlags,
  202. const char *pszDescription
  203. );
  204. typedef bool (*PFNMATCHINGFUNCTION) (
  205. const char *szPattern,
  206. const char *szString
  207. );
  208. bool
  209. MatchPrefix(const char *szPattern, const char *szString);
  210. bool
  211. MatchSuffix(const char *szPattern, const char *szString);
  212. bool
  213. MatchSubstring(const char *szPattern, const char *szString);
  214. bool
  215. MatchExactly(const char *szPattern, const char *szString);
  216. bool
  217. MatchAlways(const char *szPattern, const char *szString);
  218. typedef ULONG (*PFNNODEFUNC)(
  219. UINT_PTR uNodeAddr,
  220. UINT uIndex,
  221. void *pvContext
  222. );
  223. //
  224. // PFNNODEFUNC is the prototype of the func passed into WalkList
  225. //
  226. UINT
  227. WalkList(
  228. UINT_PTR uStartAddress,
  229. UINT uNextOffset,
  230. UINT uStartIndex,
  231. UINT uEndIndex,
  232. void *pvContext,
  233. PFNNODEFUNC pFunc,
  234. char *pszDescription
  235. );
  236. //
  237. // Visit each node in the list in turn,
  238. // reading just the next pointers. It calls pFunc for each list node
  239. // between uStartIndex and uEndIndex. It terminates under the first of
  240. // the following conditions:
  241. // * Null pointer
  242. // * ReadMemoryError
  243. // * Read past uEndIndex
  244. // * pFunc returns FALSE
  245. //
  246. void
  247. WalkDLlist(
  248. UINT_PTR uOffsetHeadList,
  249. UINT_PTR uOffsetStartLink, OPTIONAL
  250. void *pvContext,
  251. PFNNODEFUNC pFunc,
  252. UINT MaxToWalk,
  253. char *pszDescription
  254. );
  255. ULONG
  256. NodeFunc_DumpAddress (
  257. UINT_PTR uNodeAddr,
  258. UINT uIndex,
  259. void *pvContext
  260. );
  261. //
  262. // This is a sample node function -- simply dumps the specfied address.
  263. //
  264. void
  265. DumpBitFields(
  266. ULONG Flags,
  267. BITFIELD_INFO rgBitFieldInfo[]
  268. );
  269. // Dump bitfield info.
  270. //