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.

420 lines
10 KiB

  1. /*++
  2. Copyright (c) 1995-1997 Microsoft Corporation
  3. Module Name :
  4. dbgwmif.cxx
  5. Abstract:
  6. This module contains the NTSD Debugger extensions for the
  7. W3SVC DLL(WAMINFO and WAM_DICTATOR data structure)
  8. Author:
  9. Lei Jin ( leijin ) 16-09-1997
  10. Environment:
  11. Debugger Mode - inside NT command line debuggers
  12. Project:
  13. Internet Server Debugging DLL
  14. Functions Exported:
  15. Revision History:
  16. --*/
  17. /************************************************************
  18. * Include Headers
  19. ************************************************************/
  20. #include "inetdbgp.h"
  21. #include "wamexec.hxx"
  22. // include stddef.h for macro offsetof.
  23. #include "stddef.h"
  24. /************************************************************
  25. * Definitions of Variables & Macros
  26. ************************************************************/
  27. /************************************************************
  28. * Functions
  29. ************************************************************/
  30. CHAR * szWamInfoState[] =
  31. {
  32. "WIS_START",
  33. "WIS_RUNNING",
  34. "WIS_REPAIR",
  35. "WIS_PAUSE",
  36. "WIS_CPUPAUSE",
  37. "WIS_ERROR",
  38. "WIS_SHUTDOWN",
  39. "WIS_END",
  40. "WIS_MAX_STATE"
  41. };
  42. VOID
  43. DumpWamDictator(
  44. BOOL fDumpDyingList = FALSE
  45. );
  46. VOID
  47. DumpWamInfo(
  48. CWamInfo *pWamInfoOriginal,
  49. CWamInfo *pWamInfo
  50. );
  51. VOID
  52. DumpWamInfoOutProc(
  53. CWamInfoOutProc *pOriginal,
  54. CWamInfoOutProc *pWamInfoOutProc
  55. );
  56. VOID
  57. DumpOOPList(
  58. LIST_ENTRY * pListHead
  59. );
  60. VOID
  61. DumpDyingList(
  62. LIST_ENTRY * pListHead
  63. );
  64. DECLARE_API( waminfo )
  65. /*++
  66. Routine Description:
  67. This function is called as an NTSD extension to format and dump
  68. an object attributes structure.
  69. Arguments:
  70. hCurrentProcess - Supplies a handle to the current process (at the
  71. time the extension was called).
  72. hCurrentThread - Supplies a handle to the current thread (at the
  73. time the extension was called).
  74. CurrentPc - Supplies the current pc at the time the extension is
  75. called.
  76. lpExtensionApis - Supplies the address of the functions callable
  77. by this extension.
  78. lpArgumentString - Supplies the asciiz string that describes the
  79. ansi string to be dumped.
  80. Return Value:
  81. None.
  82. --*/
  83. {
  84. INIT_API();
  85. while (*lpArgumentString == ' ')
  86. lpArgumentString++;
  87. if ( !*lpArgumentString )
  88. {
  89. PrintUsage( "waminfo" );
  90. return;
  91. }
  92. if ( *lpArgumentString == '-' )
  93. {
  94. lpArgumentString++;
  95. switch ( *lpArgumentString ) {
  96. case 'g':
  97. {
  98. lpArgumentString++;
  99. if (*lpArgumentString == '1')
  100. {
  101. DumpWamDictator(TRUE);
  102. }
  103. else
  104. {
  105. DumpWamDictator(FALSE);
  106. }
  107. break;
  108. }
  109. case 'd':
  110. {
  111. CWamInfo * pWamInfo = NULL;
  112. DEFINE_CPP_VAR(CWamInfo, WamInfo);
  113. // Arguments: -d <WamInfoAddr>
  114. pWamInfo = ((CWamInfo * )GetExpression( lpArgumentString + 2));
  115. if ( !pWamInfo )
  116. {
  117. dprintf( "inetdbg: Unable to evaluate "
  118. "WaminfoAddr \"%s\"\n",
  119. lpArgumentString );
  120. break;
  121. }
  122. move(WamInfo, pWamInfo);
  123. DumpWamInfo(pWamInfo, GET_CPP_VAR_PTR( CWamInfo, WamInfo));
  124. break;
  125. }
  126. case 'l':
  127. {
  128. LIST_ENTRY * pListEntry;
  129. // Arguments: -l <OOPListHeadAddr>
  130. pListEntry = ((LIST_ENTRY * )GetExpression( lpArgumentString + 2));
  131. if ( !pListEntry )
  132. {
  133. dprintf( "inetdbg: Unable to evaluate "
  134. "OOPListHead \"%s\"\n",
  135. lpArgumentString );
  136. }
  137. else
  138. {
  139. DumpOOPList(pListEntry);
  140. }
  141. break;
  142. }
  143. default:
  144. case 'h':
  145. {
  146. PrintUsage( "waminfo" );
  147. break;
  148. }
  149. } // switch
  150. return;
  151. }
  152. } // DECLARE_API( atq )
  153. VOID
  154. DumpWamDictator
  155. (
  156. BOOL fDumpDyingList
  157. )
  158. {
  159. DEFINE_CPP_VAR(WAM_DICTATOR, WamDictator);
  160. WAM_DICTATOR ** ppWamDictator = NULL;
  161. WAM_DICTATOR * pWamDictatorDebuggee = NULL;
  162. WAM_DICTATOR * pWamDictator = NULL;
  163. ppWamDictator = (WAM_DICTATOR **) GetExpression( "w3svc!g_pWamDictator");
  164. if (!ppWamDictator)
  165. {
  166. dprintf("Unable to get w3svc!g_pWamDictator to dump the Wam Dictator info\n");
  167. return;
  168. }
  169. //
  170. // From the pointer to pointer to WAM_DICTATOR,
  171. // obtain the pointer to the WAM_DICTATOR
  172. //
  173. moveBlock( pWamDictatorDebuggee, ppWamDictator, sizeof(WAM_DICTATOR * ));
  174. if (!pWamDictatorDebuggee)
  175. {
  176. dprintf("Unable to get w3svc!g_pWamDictator to dump the Wam Dictator info.\n");
  177. return;
  178. }
  179. moveBlock(WamDictator, pWamDictatorDebuggee, sizeof(WAM_DICTATOR));
  180. pWamDictator = GET_CPP_VAR_PTR(WAM_DICTATOR, WamDictator);
  181. dprintf("g_pWamDictator ===> %08p\n"
  182. "\tm_pMetabase = %08p m_fCleanupInProgress = %8s\n"
  183. "\tm_hW3SVC = %08p m_dwScheduledId = %08x\n"
  184. "\tm_cRef = %08x m_fShutdownInProgress = %8s\n"
  185. "\tm_DyingListHead.Flink = %08p\n"
  186. "\tm_DyingListHead.Blink = %08p\n"
  187. "\n\n"
  188. ,
  189. pWamDictatorDebuggee,
  190. pWamDictator->m_pMetabase, BoolValue(pWamDictator->m_fCleanupInProgress),
  191. pWamDictator->m_hW3Svc, pWamDictator->m_dwScheduledId,
  192. pWamDictator->m_cRef, BoolValue(pWamDictator->m_fShutdownInProgress),
  193. pWamDictator->m_DyingListHead.Flink,
  194. pWamDictator->m_DyingListHead.Blink
  195. );
  196. if (fDumpDyingList)
  197. {
  198. DumpDyingList((LIST_ENTRY *)((CHAR *)pWamDictatorDebuggee + offsetof(WAM_DICTATOR, m_DyingListHead)));
  199. }
  200. return;
  201. }
  202. VOID
  203. DumpWamInfo
  204. (
  205. CWamInfo *pWamInfoOriginal,
  206. CWamInfo *pWamInfo
  207. )
  208. {
  209. dprintf("CWamInfo ===> %08p\n"
  210. "\tm_pIWam = %08p m_pProcessEntry = %08p\n"
  211. "\tm_cRef = %08x\n"
  212. "\tm_cTotalRequests = %08x m_fEnableTryExcept = %8s\n"
  213. "\tm_fInProcess = %8s m_fShutdown = %8s\n"
  214. "\tp_m_strApplicationPath = %08p\n"
  215. "\tp_m_WamClsid = %08p\n"
  216. "\tm_dwState = %12s\n"
  217. "\tm_dwIWamGipCookie = %08x\n"
  218. "\n\n",
  219. pWamInfoOriginal,
  220. pWamInfo->m_pIWam, pWamInfo->m_pProcessEntry,
  221. pWamInfo->m_cRef,
  222. pWamInfo->m_cTotalRequests,
  223. BoolValue(pWamInfo->m_fEnableTryExcept),
  224. BoolValue(pWamInfo->m_fInProcess),
  225. BoolValue(pWamInfo->m_fShuttingDown),
  226. pWamInfo->m_strApplicationPath.m_pb,
  227. (DWORD *)pWamInfoOriginal + offsetof(CWamInfo, m_clsidWam),
  228. szWamInfoState[pWamInfo->m_dwState],
  229. pWamInfo->m_dwIWamGipCookie
  230. );
  231. if (pWamInfo->m_fInProcess == FALSE)
  232. {
  233. CWamInfoOutProc * pWamInfoOutProc = NULL;
  234. DEFINE_CPP_VAR(CWamInfoOutProc, WamInfoOutProc);
  235. move(WamInfoOutProc, pWamInfoOriginal);
  236. DumpWamInfoOutProc((CWamInfoOutProc*)pWamInfoOriginal, GET_CPP_VAR_PTR( CWamInfoOutProc, WamInfoOutProc));
  237. }
  238. return;
  239. }
  240. VOID
  241. DumpWamInfoOutProc
  242. (
  243. CWamInfoOutProc *pOriginal,
  244. CWamInfoOutProc *pWamInfoOutProc
  245. )
  246. {
  247. dprintf("\tm_pCurrentListHead = %08p m_fInRepair = %8s\n"
  248. "\tm_hPermitOOPEvent = %08p m_rgOOPWamReqListHead = %08p\n"
  249. "\tm_dwThreshold = %08x m_dwWamVersion = %08x\n"
  250. "\tm_cList = %08x m_pwServerInstance = %08p\n"
  251. "\tm_idScheduled = %08x m_fJobEnabled = %08s\n"
  252. "\n\n",
  253. pWamInfoOutProc->m_pCurrentListHead,
  254. BoolValue(pWamInfoOutProc->m_fInRepair),
  255. pWamInfoOutProc->m_hPermitOOPEvent,
  256. pWamInfoOutProc->m_rgRecoverListHead.Flink,
  257. pWamInfoOutProc->m_dwThreshold, pWamInfoOutProc->m_dwWamVersion,
  258. pWamInfoOutProc->m_cRecoverList,
  259. pWamInfoOutProc->m_pwsiInstance,
  260. pWamInfoOutProc->m_idScheduled,
  261. BoolValue(pWamInfoOutProc->m_fJobEnabled)
  262. );
  263. return;
  264. }
  265. VOID
  266. DumpOOPList
  267. (
  268. LIST_ENTRY * pListHead
  269. )
  270. {
  271. LIST_ENTRY oopListHead;
  272. LIST_ENTRY* poopListHead = NULL;
  273. LIST_ENTRY* pEntry = NULL;
  274. WAM_REQUEST* pWamRequest = NULL;
  275. INT iCount;
  276. DEFINE_CPP_VAR(WAM_REQUEST, WamRequest);
  277. // move the list header into memory
  278. move(oopListHead, pListHead);
  279. poopListHead = GET_CPP_VAR_PTR(LIST_ENTRY, oopListHead);
  280. for (iCount = 0, pEntry = poopListHead->Flink; pEntry != pListHead; iCount++)
  281. {
  282. if (CheckControlC())
  283. {
  284. return;
  285. }
  286. pWamRequest = CONTAINING_RECORD( pEntry, WAM_REQUEST, m_leOOP);
  287. if (pWamRequest == NULL)
  288. {
  289. dprintf("pWamRequest is NULL, link list breaks\n");
  290. return;
  291. }
  292. dprintf("[%d] WamRequest %08p \n", iCount, pWamRequest);
  293. move(pEntry, &pEntry->Flink);
  294. }
  295. dprintf("End of OOP WamRequest link list\n\n");
  296. return;
  297. }
  298. VOID
  299. DumpDyingList
  300. (
  301. LIST_ENTRY* pListHead
  302. )
  303. {
  304. LIST_ENTRY DyingListHead;
  305. LIST_ENTRY* pDyingListHead = NULL;
  306. LIST_ENTRY* pEntry = NULL;
  307. CWamInfo* pWamInfo = NULL;
  308. INT iCount;
  309. dprintf("Dying List head %08p\n", pListHead);
  310. // move the list header into memory
  311. move(DyingListHead, pListHead);
  312. pDyingListHead = GET_CPP_VAR_PTR(LIST_ENTRY, DyingListHead);
  313. for (iCount = 0, pEntry = pDyingListHead->Flink; pEntry != pListHead; iCount++)
  314. {
  315. if (CheckControlC())
  316. {
  317. return;
  318. }
  319. pWamInfo = CONTAINING_RECORD( pEntry, CWamInfo, ListEntry);
  320. if (pWamInfo == NULL)
  321. {
  322. dprintf("pWamInfo is NULL, link list breaks\n");
  323. return;
  324. }
  325. dprintf("[%d] WamInfo %08p \n", iCount, pWamInfo);
  326. move(pEntry, &pEntry->Flink);
  327. }
  328. dprintf("End of WamInfo Dying link list\n\n");
  329. return;
  330. }