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.

441 lines
10 KiB

  1. /*++
  2. Copyright (c) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. help.c
  5. Abstract:
  6. Help for http.sys Kernel Debugger Extensions.
  7. Author:
  8. Keith Moore (keithmo) 17-Jun-1998
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. //
  15. // The following structure defines the text displayed in response
  16. // to the "!help" command. This text may also be displayed if invalid
  17. // arguments are passed to a command.
  18. //
  19. typedef struct _HELP_MAP {
  20. //
  21. // This is the name of the command.
  22. //
  23. PSTR Command;
  24. //
  25. // This is a "one-liner" displayed when the user executes "!help".
  26. //
  27. PSTR OneLiner;
  28. //
  29. // This is the full help text displayed when the user executes
  30. // "!help <cmd>".
  31. //
  32. PSTR FullHelp;
  33. } HELP_MAP, *PHELP_MAP;
  34. HELP_MAP HelpMaps[] =
  35. {
  36. {
  37. "help",
  38. "Dump this list or help for specific command",
  39. "help [<cmd>] - Dump help for command\n"
  40. " If no <cmd> is given, a list of all available commands is displayed\n"
  41. },
  42. {
  43. "ds",
  44. "Dump stack with symbols",
  45. "!ds [-v] <addr> - Dump symbols on stack\n"
  46. " -v == print valid symbols only\n"
  47. " default addr == current stack pointer\n"
  48. },
  49. {
  50. "ref",
  51. "Dump reference trace log",
  52. "!ref <addr> [context [flags]] - Dump reference trace log at <addr>\n"
  53. " context - if != 0, print only traces with matching context\n"
  54. " flags - if == 1, print process, thread, caller, callers caller\n"
  55. "!ref -l - Dump all reftrace action codes\n"
  56. },
  57. {
  58. "tref",
  59. "Dump reference trace log, by thread",
  60. "!tref <addr> [thread [flags]] - Dump reference trace log at <addr>, by thread\n"
  61. " thread - if != 0, print only traces with matching thread\n"
  62. " flags - if == 1, print process, thread, caller, callers caller\n"
  63. },
  64. {
  65. "ownref",
  66. "Dump owner reference trace log",
  67. "!ownref [-o ] [ -r ] [ -v] <addr> [context] - Dump owner reference trace log at <addr>\n"
  68. // " -g == list *all* owner reftrace logs (g_OwnerRefTraceLogGlobalListHead)\n"
  69. " -v == Verbose\n"
  70. " -O == list all Owners of current reftraced object (verbosity =-v)\n"
  71. " -o == dump REF_OWNER at <addr>\n"
  72. " -r == list Reftraces (dump reftrace log)\n"
  73. " context - if non-zero, print only traces with matching owner\n"
  74. },
  75. {
  76. "thrdpool",
  77. "Dump UL_THREAD_POOL",
  78. "!thrdpool <addr> - Dump UL_THREAD_POOL at <addr>\n"
  79. " default addr == http!g_UlThreadPool\n"
  80. },
  81. {
  82. "endp",
  83. "Dump UL_ENDPOINT",
  84. "!endp [-v | -c] * - Dump all UL_ENDPOINTs\n"
  85. "!endp [-v | -c] <addr> - Dump UL_ENDPOINT at <addr>\n"
  86. " -c == connections: briefly print all active and idle connections\n"
  87. " -v == verbose: verbosely print all active and idle connections\n"
  88. },
  89. {
  90. "ulconn",
  91. "Dump UL_CONNECTION",
  92. "!ulconn <addr> - Dump UL_CONNECTION at <addr>\n"
  93. },
  94. {
  95. "ulreq",
  96. "Dump UL_HTTP_REQUEST",
  97. "!ulreq <addr> - Dump UL_HTTP_REQUEST at <addr>\n"
  98. },
  99. {
  100. "buff",
  101. "Dump UL_RECEIVE_BUFFER",
  102. "!buff <addr> - Dump UL_RECEIVE_BUFFER at <addr>\n"
  103. },
  104. {
  105. "httpconn",
  106. "Dump HTTP_CONNECTION",
  107. "!httpconn <addr> - Dump HTTP_CONNECTION at <addr>\n"
  108. },
  109. {
  110. "httpreq",
  111. "Dump HTTP_REQUEST",
  112. "!httpreq <addr> - Dump HTTP_REQUEST at <addr>\n"
  113. },
  114. {
  115. "httpres",
  116. "Dump UL_INTERNAL_HTTP_RESPONSE",
  117. "!httpres <addr> - Dump UL_INTERNAL_HTTP_RESPONSE at <addr>\n"
  118. },
  119. {
  120. "file",
  121. "Dump UL_FILE_CACHE_ENTRY",
  122. "!file <addr> - Dump UL_FILE_CACHE_ENTRY at <addr>\n"
  123. },
  124. {
  125. "glob",
  126. "Dump critical UL global data",
  127. "!glob - Dump critical UL global data\n"
  128. },
  129. {
  130. "uriglob",
  131. "Dump URI Cache global data",
  132. "!uriglob - Dump URI Cache global data\n"
  133. },
  134. {
  135. "uri",
  136. "Dump UL_URI_CACHE_ENTRY",
  137. "!uri <addr> - Dump UL_URI_CACHE_ENTRY at <addr>\n"
  138. "!uri * - Dump all UL_URI_CACHE_ENTRYs\n"
  139. },
  140. {
  141. "resource",
  142. "Dump all resources",
  143. "!resource [-v] - Dump all (locked) resources\n"
  144. " -v == Dump all resources (including unlocked)\n"
  145. },
  146. {
  147. "reqbuff",
  148. "Dump UL_REQUEST_BUFFER",
  149. "!reqbuff <addr> - Dump UL_REQUEST_BUFFER at <addr>\n"
  150. },
  151. {
  152. "irplog",
  153. "Dump the IRP trace log",
  154. "!irplog [<ctx> [flags [StartingIndex]]] - Dump the IRP trace log\n"
  155. " If <ctx> is specified, only log entries with matching context are dumped\n"
  156. " flags - TBD\n"
  157. " StartingIndex - TBD\n"
  158. },
  159. {
  160. "timelog",
  161. "Dump the timing trace log",
  162. "!timelog [<ctx>] - Dump the timing trace log\n"
  163. " If <ctx> is specified, only log entries with matching conn id are dumped\n"
  164. },
  165. {
  166. "replog",
  167. "Dump the replenish trace log",
  168. "!replog [<ctx>] - Dump the replenish trace log\n"
  169. " If <ctx> is specified, only log entries with matching endpoint are dumped\n"
  170. },
  171. {
  172. "fqlog",
  173. "Dump the filter queue trace log",
  174. "!fqlog [<ctx>] - Dump the filter queue trace log\n"
  175. " If <ctx> is specified, only log entries with matching connection are dumped\n"
  176. },
  177. {
  178. "opaqueid",
  179. "Dump the Opaque ID table",
  180. "!opaqueid - Dump the Opaque ID table\n"
  181. },
  182. {
  183. "mdl",
  184. "Dump MDL",
  185. "!mdl <addr> [<len>] - Dump MDL at <addr>\n"
  186. " If <len> specified, at most <len> raw bytes are dumped from the MDL\n"
  187. " If <len> not specified, no raw data is dumped\n"
  188. },
  189. {
  190. "apool",
  191. "Dump UL_APP_POOL_OBJECT",
  192. "!apool <addr> - Dump UL_APP_POOL_OBJECT at <addr>\n"
  193. "!apool * - Dump all UL_APP_POOL_OBJECTs\n"
  194. },
  195. {
  196. "proc",
  197. "Dump UL_APP_POOL_PROCESS",
  198. "!proc <addr> - Dump UL_APP_POOL_PROCESS at <addr>\n"
  199. },
  200. {
  201. "cgroup",
  202. "Dump UL_CONFIG_GROUP_OBJECT",
  203. "!cgroup <addr> - Dump UL_CONFIG_GROUP_OBJECT at <addr>\n"
  204. },
  205. {
  206. "cgentry",
  207. "Dump UL_CG_URL_TREE_ENTRY",
  208. "!cgentry <addr> - Dump UL_CG_URL_TREE_ENTRY at <addr>\n"
  209. },
  210. {
  211. "cghead",
  212. "Dump UL_CG_HEADER_ENTRY",
  213. "!cghead <addr> - Dump UL_CG_HEADER_ENTRY at <addr>\n"
  214. },
  215. {
  216. "cgtree",
  217. "Dump UL_CG_URL_TREE at <addr> or g_pSites",
  218. "!cgtree [<addr>] - Dump UL_CG_URL_TREE at <addr> or g_pSites\n"
  219. },
  220. {
  221. "kqueue",
  222. "Dump KQUEUE",
  223. "!kqueue <addr> <f> - Dump KQUEUE at <addr>, flags <f>\n"
  224. " f == 0 - Only dump the KQUEUE header data\n"
  225. " f == 1 - Dump the IRPs queued on the KQUEUE\n"
  226. },
  227. {
  228. "procirps",
  229. "BUGBUG - This extension is broken in Whistler!",
  230. "!procirps <addr> - Dump all IRPs issued by process @ <addr>\n"
  231. },
  232. {
  233. "filter",
  234. "Dumps a UL_FILTER_CHANNEL at <addr> or g_pFilterChannel",
  235. "!filter [<addr>] - Dump a UL_FILTER_CHANNEL.\n"
  236. },
  237. {
  238. "fproc",
  239. "Dumps a UL_FILTER_PROCESS at <addr>\n",
  240. "!fproc <addr> - Dump a UL_FILTER_PROCESS.\n"
  241. },
  242. {
  243. "ulhash",
  244. "Dump URI Cache Hash Table",
  245. "!ulhash - Dump URI Cache Hash Table\n"
  246. }
  247. };
  248. #define NUM_HELP_MAPS DIM(HelpMaps)
  249. PSTR
  250. FindHelpForCommand(
  251. IN PCSTR CommandName
  252. )
  253. {
  254. PHELP_MAP helpMap;
  255. ULONG i;
  256. for( i = NUM_HELP_MAPS, helpMap = HelpMaps ; i > 0 ; i--, helpMap++ ) {
  257. if( _stricmp( helpMap->Command, CommandName ) == 0 ) {
  258. return helpMap->FullHelp;
  259. }
  260. }
  261. return NULL;
  262. } // FindHelpForCommand
  263. //
  264. // Public functions.
  265. //
  266. VOID
  267. PrintUsage(
  268. IN PCSTR CommandName
  269. )
  270. {
  271. PSTR cmdHelp;
  272. PHELP_MAP helpMap;
  273. ULONG i;
  274. ULONG maxLength;
  275. ULONG length;
  276. if (CommandName == NULL)
  277. {
  278. //
  279. // We'll display the one-liners for each command. Start by
  280. // scanning the commands to find the longest length. This makes the
  281. // output much prettier without having to manually tweak the
  282. // columns.
  283. //
  284. maxLength = 0;
  285. for (i = NUM_HELP_MAPS, helpMap = HelpMaps ; i > 0 ; i--, helpMap++)
  286. {
  287. length = (ULONG)strlen( helpMap->Command );
  288. if (length > maxLength)
  289. {
  290. maxLength = length;
  291. }
  292. }
  293. //
  294. // Now actually display the one-liners.
  295. //
  296. for (i = NUM_HELP_MAPS, helpMap = HelpMaps ; i > 0 ; i--, helpMap++)
  297. {
  298. dprintf(
  299. "!%-*s - %s\n",
  300. maxLength,
  301. helpMap->Command,
  302. helpMap->OneLiner
  303. );
  304. }
  305. }
  306. else
  307. {
  308. //
  309. // Find a specific command and display the full help.
  310. //
  311. cmdHelp = FindHelpForCommand( CommandName );
  312. if (cmdHelp == NULL)
  313. {
  314. dprintf( "unrecognized command %s\n", CommandName );
  315. }
  316. else
  317. {
  318. dprintf( "%s", cmdHelp );
  319. }
  320. }
  321. } // PrintUsage()
  322. DECLARE_API( help )
  323. /*++
  324. Routine Description:
  325. Displays help for the UL.SYS Kernel Debugger Extensions.
  326. Arguments:
  327. None.
  328. Return Value:
  329. None.
  330. --*/
  331. {
  332. SNAPSHOT_EXTENSION_DATA();
  333. while (*args == ' ' || *args == '\t')
  334. {
  335. args++;
  336. }
  337. if (!strcmp( args, "?" ))
  338. {
  339. args = "help";
  340. }
  341. if (*args == '\0')
  342. {
  343. args = NULL;
  344. }
  345. PrintUsage( args );
  346. } // help