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.

400 lines
9.6 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. DumpSup.c
  5. Abstract:
  6. This module implements a collection of data structure dump routines
  7. for debugging the Rx file system
  8. Author:
  9. Gary Kimura [GaryKi] 18-Jan-1990
  10. Revision History:
  11. --*/
  12. // ----------------------joejoe-----------found-------------#include "RxProcs.h"
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. //
  16. // The Bug check file id for this module
  17. //
  18. #define BugCheckFileId (RDBSS_BUG_CHECK_DUMPSUP)
  19. //
  20. // The local debug trace level
  21. //
  22. #define Dbg (yaya)
  23. #ifdef RDBSSDBG
  24. VOID RxDump(IN PVOID Ptr);
  25. VOID RxDumpDataHeader();
  26. VOID RxDumpVcb(IN PVCB Ptr);
  27. VOID RxDumpFcb(IN PFCB Ptr);
  28. VOID RxDumpFobx(IN PFOBX Ptr);
  29. ULONG RxDumpCurrentColumn;
  30. #define DumpNewLine() { \
  31. DbgPrint("\n"); \
  32. RxDumpCurrentColumn = 1; \
  33. }
  34. #define DumpLabel(Label,Width) { \
  35. ULONG i, LastPeriod=0; \
  36. CHAR _Str[20]; \
  37. for(i=0;i<2;i++) { _Str[i] = UCHAR_SP;} \
  38. for(i=0;i<strlen(#Label);i++) {if (#Label[i] == '.') LastPeriod = i;} \
  39. strncpy(&_Str[2],&#Label[LastPeriod],Width); \
  40. for(i=strlen(_Str);i<Width;i++) {_Str[i] = UCHAR_SP;} \
  41. _Str[Width] = '\0'; \
  42. DbgPrint("%s", _Str); \
  43. }
  44. #define DumpField(Field) { \
  45. if ((RxDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
  46. RxDumpCurrentColumn += 18 + 9 + 9; \
  47. DumpLabel(Field,18); \
  48. DbgPrint(":%8lx", Ptr->Field); \
  49. DbgPrint(" "); \
  50. }
  51. #define DumpListEntry(Links) { \
  52. if ((RxDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
  53. RxDumpCurrentColumn += 18 + 9 + 9; \
  54. DumpLabel(Links,18); \
  55. DbgPrint(":%8lx", Ptr->Links.Flink); \
  56. DbgPrint(":%8lx", Ptr->Links.Blink); \
  57. }
  58. #define DumpName(Field,Width) { \
  59. ULONG i; \
  60. CHAR _String[256]; \
  61. if ((RxDumpCurrentColumn + 18 + Width) > 80) {DumpNewLine();} \
  62. RxDumpCurrentColumn += 18 + Width; \
  63. DumpLabel(Field,18); \
  64. for(i=0;i<Width;i++) {_String[i] = (CHAR) Ptr->Field[i];} \
  65. _String[Width] = '\0'; \
  66. DbgPrint("%s", _String); \
  67. }
  68. #define TestForNull(Name) { \
  69. if (Ptr == NULL) { \
  70. DbgPrint("%s - Cannot dump a NULL pointer\n", Name); \
  71. return; \
  72. } \
  73. }
  74. VOID
  75. RxDump (
  76. IN PVOID Ptr
  77. )
  78. /*++
  79. Routine Description:
  80. This routine determines the type of internal record reference by ptr and
  81. calls the appropriate dump routine.
  82. Arguments:
  83. Ptr - Supplies the pointer to the record to be dumped
  84. Return Value:
  85. None
  86. --*/
  87. {
  88. TestForNull("RxDump");
  89. switch (NodeType(Ptr)) {
  90. case RDBSS_NTC_DATA_HEADER:
  91. RxDumpDataHeader();
  92. break;
  93. case RDBSS_NTC_VCB:
  94. RxDumpVcb(Ptr);
  95. break;
  96. case RDBSS_NTC_FCB:
  97. case RDBSS_NTC_DCB:
  98. case RDBSS_NTC_ROOT_DCB:
  99. RxDumpFcb(Ptr);
  100. break;
  101. case RDBSS_NTC_FOBX:
  102. RxDumpFobx(Ptr);
  103. break;
  104. default :
  105. DbgPrint("RxDump - Unknown Node type code %8lx\n", *((PNODE_TYPE_CODE)(Ptr)));
  106. break;
  107. }
  108. return;
  109. }
  110. VOID
  111. RxDumpDataHeader (
  112. )
  113. /*++
  114. Routine Description:
  115. Dump the top data structures and all Device structures
  116. Arguments:
  117. None
  118. Return Value:
  119. None
  120. --*/
  121. {
  122. PRDBSS_DATA Ptr;
  123. PLIST_ENTRY Links;
  124. Ptr = &RxData;
  125. TestForNull("RxDumpDataHeader");
  126. DumpNewLine();
  127. DbgPrint("RxData@ %lx", (Ptr));
  128. DumpNewLine();
  129. DumpField (NodeTypeCode);
  130. DumpField (NodeByteSize);
  131. DumpListEntry (VcbQueue);
  132. DumpField (DriverObject);
  133. DumpField (OurProcess);
  134. DumpNewLine();
  135. for (Links = Ptr->VcbQueue.Flink;
  136. Links != &Ptr->VcbQueue;
  137. Links = Links->Flink) {
  138. RxDumpVcb(CONTAINING_RECORD(Links, VCB, VcbLinks));
  139. }
  140. return;
  141. }
  142. VOID
  143. RxDumpVcb (
  144. IN PVCB Ptr
  145. )
  146. /*++
  147. Routine Description:
  148. Dump an Device structure, its Fcb queue amd direct access queue.
  149. Arguments:
  150. Ptr - Supplies the Device record to be dumped
  151. Return Value:
  152. None
  153. --*/
  154. {
  155. TestForNull("RxDumpVcb");
  156. DumpNewLine();
  157. DbgPrint("Vcb@ %lx", (Ptr));
  158. DumpNewLine();
  159. DumpField (NodeTypeCode);
  160. DumpField (NodeByteSize);
  161. DumpListEntry (VcbLinks);
  162. DumpField (TargetDeviceObject);
  163. DumpField (Vpb);
  164. DumpField (VcbState);
  165. DumpField (VcbCondition);
  166. DumpField (RootDcb);
  167. DumpField (DirectAccessOpenCount);
  168. DumpField (OpenFileCount);
  169. DumpField (ReadOnlyCount);
  170. DumpField (AllocationSupport);
  171. DumpField (AllocationSupport.RootDirectoryLbo);
  172. DumpField (AllocationSupport.RootDirectorySize);
  173. DumpField (AllocationSupport.FileAreaLbo);
  174. DumpField (AllocationSupport.NumberOfClusters);
  175. DumpField (AllocationSupport.NumberOfFreeClusters);
  176. DumpField (AllocationSupport.RxIndexBitSize);
  177. DumpField (AllocationSupport.LogOfBytesPerSector);
  178. DumpField (AllocationSupport.LogOfBytesPerCluster);
  179. DumpField (DirtyRxMcb);
  180. DumpField (FreeClusterBitMap);
  181. DumpField (VirtualVolumeFile);
  182. DumpField (SectionObjectPointers.DataSectionObject);
  183. DumpField (SectionObjectPointers.SharedCacheMap);
  184. DumpField (SectionObjectPointers.ImageSectionObject);
  185. DumpField (ClusterHint);
  186. DumpNewLine();
  187. RxDumpFcb(Ptr->RootDcb);
  188. return;
  189. }
  190. VOID
  191. RxDumpFcb (
  192. IN PFCB Ptr
  193. )
  194. /*++
  195. Routine Description:
  196. Dump an Fcb structure, its various queues
  197. Arguments:
  198. Ptr - Supplies the Fcb record to be dumped
  199. Return Value:
  200. None
  201. --*/
  202. {
  203. PLIST_ENTRY Links;
  204. TestForNull("RxDumpFcb");
  205. DumpNewLine();
  206. if (NodeType(Ptr) == RDBSS_NTC_FCB) {DbgPrint("Fcb@ %lx", (Ptr));}
  207. else if (NodeType(Ptr) == RDBSS_NTC_DCB) {DbgPrint("Dcb@ %lx", (Ptr));}
  208. else if (NodeType(Ptr) == RDBSS_NTC_ROOT_DCB) {DbgPrint("RootDcb@ %lx", (Ptr));}
  209. else {DbgPrint("NonFcb NodeType @ %lx", (Ptr));}
  210. DumpNewLine();
  211. DumpField (Header.NodeTypeCode);
  212. DumpField (Header.NodeByteSize);
  213. DumpListEntry (ParentDcbLinks);
  214. DumpField (ParentDcb);
  215. DumpField (Vcb);
  216. DumpField (FcbState);
  217. DumpField (FcbCondition);
  218. DumpField (UncleanCount);
  219. DumpField (OpenCount);
  220. DumpField (DirentOffsetWithinDirectory);
  221. DumpField (DirentRxFlags);
  222. DumpField (FullFileName.Length);
  223. DumpField (FullFileName.Buffer);
  224. DumpName (FullFileName.Buffer, 32);
  225. DumpField (ShortName.Name.Oem.Length);
  226. DumpField (ShortName.Name.Oem.Buffer);
  227. // DumpField (NonPagedFcb);
  228. DumpField (NonPaged);
  229. DumpField (Header.AllocationSize.LowPart);
  230. DumpField (NonPaged->SectionObjectPointers.DataSectionObject);
  231. DumpField (NonPaged->SectionObjectPointers.SharedCacheMap);
  232. DumpField (NonPaged->SectionObjectPointers.ImageSectionObject);
  233. if ((Ptr->Header.NodeTypeCode == RDBSS_NTC_DCB) ||
  234. (Ptr->Header.NodeTypeCode == RDBSS_NTC_ROOT_DCB)) {
  235. DumpListEntry (Specific.Dcb.ParentDcbQueue);
  236. DumpField (Specific.Dcb.DirectoryFileOpenCount);
  237. DumpField (Specific.Dcb.DirectoryFile);
  238. } else if (Ptr->Header.NodeTypeCode == RDBSS_NTC_FCB) {
  239. DumpField (Header.FileSize.LowPart);
  240. } else {
  241. DumpNewLine();
  242. DbgPrint("Illegal Node type code");
  243. }
  244. DumpNewLine();
  245. if ((Ptr->Header.NodeTypeCode == RDBSS_NTC_DCB) ||
  246. (Ptr->Header.NodeTypeCode == RDBSS_NTC_ROOT_DCB)) {
  247. for (Links = Ptr->Specific.Dcb.ParentDcbQueue.Flink;
  248. Links != &Ptr->Specific.Dcb.ParentDcbQueue;
  249. Links = Links->Flink) {
  250. RxDumpFcb(CONTAINING_RECORD(Links, FCB, ParentDcbLinks));
  251. }
  252. }
  253. return;
  254. }
  255. VOID
  256. RxDumpFobx (
  257. IN PFOBX Ptr
  258. )
  259. /*++
  260. Routine Description:
  261. Dump a Fobx structure
  262. Arguments:
  263. Ptr - Supplies the Fobx record to be dumped
  264. Return Value:
  265. None
  266. --*/
  267. {
  268. TestForNull("RxDumpFobx");
  269. DumpNewLine();
  270. DbgPrint("Fobx@ %lx", (Ptr));
  271. DumpNewLine();
  272. DumpField (NodeTypeCode);
  273. DumpField (NodeByteSize);
  274. DumpField (UnicodeQueryTemplate.Length);
  275. DumpName (UnicodeQueryTemplate.Buffer, 32);
  276. DumpNewLine();
  277. return;
  278. }
  279. #endif // RDBSSDBG