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.

440 lines
8.7 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 mailslot file system
  8. Author:
  9. Manny Weiser (mannyw) 9-Jan-1991
  10. Revision History:
  11. --*/
  12. #include "mailslot.h"
  13. #ifdef MSDBG
  14. VOID MsDumpDataQueue(IN ULONG Level, IN PDATA_QUEUE Ptr);
  15. VOID MsDumpDataEntry(IN PDATA_ENTRY Ptr);
  16. VOID MsDump(IN PVOID Ptr);
  17. VOID MsDumpVcb(IN PVCB Ptr);
  18. VOID MsDumpRootDcb(IN PROOT_DCB Ptr);
  19. VOID MsDumpFcb(IN PFCB Ptr);
  20. VOID MsDumpCcb(IN PCCB Ptr);
  21. VOID MsDumpRootDcbCcb(IN PROOT_DCB_CCB Ptr);
  22. ULONG MsDumpCurrentColumn;
  23. #define DumpNewLine() { \
  24. DbgPrint("\n"); \
  25. MsDumpCurrentColumn = 1; \
  26. }
  27. #define DumpLabel(Label,Width) { \
  28. ULONG i; \
  29. CHAR _Str[20]; \
  30. for(i=0;i<2;i++) { _Str[i] = ' ';} \
  31. strncpy(&_Str[2],#Label,Width); \
  32. for(i=strlen(_Str);i<Width;i++) {_Str[i] = ' ';} \
  33. _Str[Width] = '\0'; \
  34. DbgPrint("%s", _Str); \
  35. }
  36. #define DumpField(Field) { \
  37. if ((MsDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
  38. MsDumpCurrentColumn += 18 + 9 + 9; \
  39. DumpLabel(Field,18); \
  40. DbgPrint(":%8lx", Ptr->Field); \
  41. DbgPrint(" "); \
  42. }
  43. #define DumpHeader(Header) { \
  44. DumpField(Header.NodeTypeCode); \
  45. DumpField(Header.NodeByteSize); \
  46. DumpField(Header.NodeState); \
  47. DumpField(Header.ReferenceCount); \
  48. }
  49. #define DumpListEntry(Links) { \
  50. if ((MsDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
  51. MsDumpCurrentColumn += 18 + 9 + 9; \
  52. DumpLabel(Links,18); \
  53. DbgPrint(":%8lx", Ptr->Links.Flink); \
  54. DbgPrint(":%8lx", Ptr->Links.Blink); \
  55. }
  56. #define DumpName(Field,Width) { \
  57. ULONG i; \
  58. CHAR _String[256]; \
  59. if ((MsDumpCurrentColumn + 18 + Width) > 80) {DumpNewLine();} \
  60. MsDumpCurrentColumn += 18 + Width; \
  61. DumpLabel(Field,18); \
  62. for(i=0;i<Width;i++) {_String[i] = Ptr->Field[i];} \
  63. _String[Width] = '\0'; \
  64. DbgPrint("%s", _String); \
  65. }
  66. #define TestForNull(Name) { \
  67. if (Ptr == NULL) { \
  68. DbgPrint("%s - Cannot dump a NULL pointer\n", Name); \
  69. return; \
  70. } \
  71. }
  72. #ifdef ALLOC_PRAGMA
  73. #pragma alloc_text( PAGE, MsDump )
  74. #pragma alloc_text( PAGE, MsDumpCcb )
  75. #pragma alloc_text( PAGE, MsDumpDataEntry )
  76. #pragma alloc_text( PAGE, MsDumpDataQueue )
  77. #pragma alloc_text( PAGE, MsDumpFcb )
  78. #pragma alloc_text( PAGE, MsDumpRootDcb )
  79. #pragma alloc_text( PAGE, MsDumpRootDcbCcb )
  80. #pragma alloc_text( PAGE, MsDumpVcb )
  81. #endif
  82. VOID MsDumpDataQueue (
  83. IN ULONG Level,
  84. IN PDATA_QUEUE Ptr
  85. )
  86. {
  87. PLIST_ENTRY listEntry;
  88. PDATA_ENTRY dataEntry;
  89. PAGED_CODE();
  90. if ((Level != 0) && !(MsDebugTraceLevel & Level)) {
  91. return;
  92. }
  93. TestForNull ("MsDumpDataQueue");
  94. DumpNewLine ();
  95. DbgPrint ("DataQueue@ %08lx", (Ptr));
  96. DumpNewLine ();
  97. DumpField (QueueState);
  98. DumpField (BytesInQueue);
  99. DumpField (EntriesInQueue);
  100. DumpField (Quota);
  101. DumpField (QuotaUsed);
  102. DumpField (MaximumMessageSize);
  103. DumpField (DataEntryList.Flink);
  104. DumpField (DataEntryList.Blink);
  105. DumpNewLine ();
  106. for (listEntry = Ptr->DataEntryList.Flink;
  107. listEntry != &Ptr->DataEntryList;
  108. listEntry = listEntry->Flink) {
  109. dataEntry = CONTAINING_RECORD(listEntry, DATA_ENTRY, ListEntry);
  110. MsDumpDataEntry( dataEntry );
  111. }
  112. return;
  113. }
  114. VOID MsDumpDataEntry (
  115. IN PDATA_ENTRY Ptr
  116. )
  117. {
  118. PAGED_CODE();
  119. TestForNull ("MsDumpDataEntry");
  120. DumpNewLine ();
  121. DbgPrint ("DataEntry@ %08lx", (Ptr));
  122. DumpNewLine ();
  123. DumpField (From);
  124. DumpField (Irp);
  125. DumpField (DataSize);
  126. DumpField (DataPointer);
  127. DumpField (TimeoutWorkContext);
  128. DumpNewLine ();
  129. return;
  130. }
  131. VOID MsDump (
  132. IN PVOID Ptr
  133. )
  134. /*++
  135. Routine Description:
  136. This routine determines the type of internal record reference by ptr and
  137. calls the appropriate dump routine.
  138. Arguments:
  139. Ptr - Supplies the pointer to the record to be dumped
  140. Return Value:
  141. None
  142. --*/
  143. {
  144. PAGED_CODE();
  145. TestForNull("MsDump");
  146. //
  147. // We'll switch on the node type code
  148. //
  149. switch (NodeType(Ptr)) {
  150. case MSFS_NTC_VCB: MsDumpVcb(Ptr); break;
  151. case MSFS_NTC_ROOT_DCB: MsDumpRootDcb(Ptr); break;
  152. case MSFS_NTC_FCB: MsDumpFcb(Ptr); break;
  153. case MSFS_NTC_CCB: MsDumpCcb(Ptr); break;
  154. case MSFS_NTC_ROOT_DCB_CCB: MsDumpRootDcbCcb(Ptr); break;
  155. default :
  156. DbgPrint("MsDump - Unknown Node type code %8lx\n", *((PNODE_TYPE_CODE)(Ptr)));
  157. break;
  158. }
  159. return;
  160. }
  161. VOID MsDumpVcb (
  162. IN PVCB Ptr
  163. )
  164. /*++
  165. Routine Description:
  166. Dump an Vcb structure
  167. Arguments:
  168. Ptr - Supplies the Device record to be dumped
  169. Return Value:
  170. None
  171. --*/
  172. {
  173. PAGED_CODE();
  174. TestForNull ("MsDumpVcb");
  175. DumpNewLine ();
  176. DbgPrint ("Vcb@ %lx", (Ptr));
  177. DumpNewLine ();
  178. DumpHeader (Header);
  179. DumpField (RootDcb);
  180. DumpNewLine ();
  181. MsDump (Ptr->RootDcb);
  182. return;
  183. }
  184. VOID MsDumpRootDcb (
  185. IN PROOT_DCB Ptr
  186. )
  187. /*++
  188. Routine Description:
  189. Dump a root dcb structure
  190. Arguments:
  191. Ptr - Supplies the Root Dcb record to be dumped
  192. Return Value:
  193. None
  194. --*/
  195. {
  196. PLIST_ENTRY Links;
  197. PAGED_CODE();
  198. TestForNull ("MsDumpRootDcb");
  199. DumpNewLine ();
  200. DbgPrint ("RootDcb@ %lx", (Ptr));
  201. DumpNewLine ();
  202. DumpHeader (Header);
  203. DumpListEntry (ParentDcbLinks);
  204. DumpField (ParentDcb);
  205. DumpField (Vcb);
  206. DumpField (FileObject);
  207. DumpField (FullFileName.Length);
  208. DumpField (FullFileName.Buffer);
  209. DumpName (FullFileName.Buffer, 32);
  210. DumpField (LastFileName.Length);
  211. DumpField (LastFileName.Buffer);
  212. DumpListEntry (Specific.Dcb.NotifyFullQueue);
  213. DumpListEntry (Specific.Dcb.NotifyPartialQueue);
  214. DumpListEntry (Specific.Dcb.ParentDcbQueue);
  215. DumpField (CreatorProcess);
  216. DumpNewLine ();
  217. for (Links = Ptr->Specific.Dcb.ParentDcbQueue.Flink;
  218. Links != &Ptr->Specific.Dcb.ParentDcbQueue;
  219. Links = Links->Flink) {
  220. MsDump(CONTAINING_RECORD(Links, FCB, ParentDcbLinks));
  221. }
  222. return;
  223. }
  224. VOID MsDumpFcb (
  225. IN PFCB Ptr
  226. )
  227. /*++
  228. Routine Description:
  229. Dump an Fcb structure
  230. Arguments:
  231. Ptr - Supplies the Fcb record to be dumped
  232. Return Value:
  233. None
  234. --*/
  235. {
  236. PLIST_ENTRY Links;
  237. PAGED_CODE();
  238. TestForNull ("MsDumpFcb");
  239. DumpNewLine ();
  240. DbgPrint ("Fcb@ %lx", (Ptr));
  241. DumpNewLine ();
  242. DumpHeader (Header);
  243. DumpListEntry (ParentDcbLinks);
  244. DumpField (ParentDcb);
  245. DumpField (Vcb);
  246. DumpField (FileObject);
  247. DumpField (FullFileName.Length);
  248. DumpField (FullFileName.Buffer);
  249. DumpName (FullFileName.Buffer, 32);
  250. DumpField (LastFileName.Length);
  251. DumpField (LastFileName.Buffer);
  252. DumpListEntry (Specific.Fcb.CcbQueue);
  253. DumpField (CreatorProcess);
  254. DumpNewLine ();
  255. for (Links = Ptr->Specific.Fcb.CcbQueue.Flink;
  256. Links != &Ptr->Specific.Fcb.CcbQueue;
  257. Links = Links->Flink) {
  258. MsDump(CONTAINING_RECORD(Links, CCB, CcbLinks));
  259. }
  260. MsDumpDataQueue ( 0, &(Ptr->DataQueue) );
  261. return;
  262. }
  263. VOID MsDumpCcb (
  264. IN PCCB Ptr
  265. )
  266. /*++
  267. Routine Description:
  268. Dump a Ccb structure
  269. Arguments:
  270. Ptr - Supplies the Ccb record to be dumped
  271. Return Value:
  272. None
  273. --*/
  274. {
  275. PAGED_CODE();
  276. TestForNull ("MsDumpCcb");
  277. DumpNewLine ();
  278. DbgPrint ("Ccb@ %lx", (Ptr));
  279. DumpNewLine ();
  280. DumpHeader (Header);
  281. DumpField (Fcb);
  282. DumpField (FileObject);
  283. DumpNewLine ();
  284. return;
  285. }
  286. VOID MsDumpRootDcbCcb (
  287. IN PROOT_DCB_CCB Ptr
  288. )
  289. /*++
  290. Routine Description:
  291. Dump a Root Dcb Ccb structure
  292. Arguments:
  293. Ptr - Supplies the Root Dcb Ccb record to be dumped
  294. Return Value:
  295. None
  296. --*/
  297. {
  298. PAGED_CODE();
  299. TestForNull ("MsDumpRootDcbCcb");
  300. DumpNewLine ();
  301. DbgPrint ("RootDcbCcb@ %lx", (Ptr));
  302. DumpNewLine ();
  303. DumpHeader (Header);
  304. DumpField (IndexOfLastCcbReturned);
  305. DumpField (QueryTemplate);
  306. DumpNewLine ();
  307. return;
  308. }
  309. #endif // MSDBG