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.

2590 lines
72 KiB

  1. /*** amldebug.c - AML Debugger functions
  2. *
  3. * This module contains all the debug functions.
  4. *
  5. * Copyright (c) 1996,1997 Microsoft Corporation
  6. * Author: Michael Tsang (MikeTs)
  7. * Created 08/14/96
  8. *
  9. * MODIFICATION HISTORY
  10. */
  11. #include "pch.h"
  12. #include "unasm.h"
  13. #include <stdio.h>
  14. #include <stdarg.h>
  15. #ifdef DEBUGGER
  16. /*** Local function prototypes
  17. */
  18. LONG LOCAL DebugHelp(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  19. ULONG dwNonSWArgs);
  20. LONG LOCAL DebugExpr(PSZ pszArg, PULONG_PTR puipValue, BOOLEAN *pfPhysical,
  21. PPNSOBJ ppns, PULONG pdwOffset);
  22. BOOLEAN LOCAL IsNumber(PSZ pszStr, ULONG dwBase, PULONG_PTR puipValue);
  23. LONG LOCAL DumpData(ULONG_PTR uipAddr, ULONG dwfUnitSize, ULONG dwLen,
  24. BOOLEAN fPhysical);
  25. LONG LOCAL DebugDumpData(PCMDARG pArg, PSZ pszArg, ULONG dwfDataSize);
  26. LONG LOCAL DebugD(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  27. LONG LOCAL DebugDB(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  28. LONG LOCAL DebugDW(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  29. LONG LOCAL DebugDD(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  30. LONG LOCAL DebugDA(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  31. #ifdef DEBUG
  32. LONG LOCAL DebugDC(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  33. #endif
  34. LONG LOCAL DebugEditMem(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  35. ULONG dwNonSWArgs);
  36. LONG LOCAL InPort(ULONG dwPort, ULONG dwSize, PULONG pdwData);
  37. LONG LOCAL DebugInPort(PSZ pszArg, ULONG dwSize);
  38. LONG LOCAL DebugI(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  39. LONG LOCAL DebugIW(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  40. LONG LOCAL DebugID(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  41. LONG LOCAL DebugQuit(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  42. ULONG dwNonSWArgs);
  43. LONG LOCAL DebugNotify(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  44. ULONG dwNonSWArgs);
  45. LONG LOCAL OutPort(ULONG dwPort, ULONG dwSize, ULONG dwData);
  46. LONG LOCAL DebugOutPort(PSZ pszArg, ULONG dwSize);
  47. LONG LOCAL DebugO(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  48. LONG LOCAL DebugOW(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  49. LONG LOCAL DebugOD(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs);
  50. VOID LOCAL PrintSymbol(PUCHAR pb);
  51. LONG LOCAL DebugTrace(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  52. ULONG dwNonSWArgs);
  53. LONG LOCAL DebugStep(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  54. ULONG dwNonSWArgs);
  55. LONG LOCAL DebugSetLogSize(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  56. ULONG dwNonSWArgs);
  57. LONG LOCAL DebugRunMethod(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  58. ULONG dwNonSWArgs);
  59. VOID EXPORT RunMethodCallBack(PNSOBJ pns, NTSTATUS rc, POBJDATA pdata,
  60. PVOID pvContext);
  61. VOID LOCAL AddObjSymbol(PUCHAR pbOp, PNSOBJ pnsObj);
  62. BOOLEAN LOCAL FindObjSymbol(PUCHAR pbOp, PPNSOBJ ppns, PULONG pdwOffset);
  63. BOOLEAN LOCAL CheckAndEnableDebugSpew(BOOLEAN fEnable);
  64. /*** Exported data
  65. */
  66. DBGR gDebugger = {0};
  67. /*** Local data
  68. */
  69. ULONG dwCmdArg = 0;
  70. CMDARG ArgsHelp[] =
  71. {
  72. NULL, AT_ACTION, 0, NULL, 0, DebugHelp,
  73. NULL, AT_END, 0, NULL, 0, NULL
  74. };
  75. CMDARG ArgsD[] =
  76. {
  77. "l", AT_NUM, AF_SEP, &dwCmdArg, 16, DebugD,
  78. NULL, AT_ACTION, 0, NULL, 0, DebugD,
  79. NULL, AT_END, 0, NULL, 0, NULL
  80. };
  81. CMDARG ArgsDB[] =
  82. {
  83. "l", AT_NUM, AF_SEP, &dwCmdArg, 16, DebugDB,
  84. NULL, AT_ACTION, 0, NULL, 0, DebugDB,
  85. NULL, AT_END, 0, NULL, 0, NULL
  86. };
  87. CMDARG ArgsDW[] =
  88. {
  89. "l", AT_NUM, AF_SEP, &dwCmdArg, 16, DebugDW,
  90. NULL, AT_ACTION, 0, NULL, 0, DebugDW,
  91. NULL, AT_END, 0, NULL, 0, NULL
  92. };
  93. CMDARG ArgsDD[] =
  94. {
  95. "l", AT_NUM, AF_SEP, &dwCmdArg, 16, DebugDD,
  96. NULL, AT_ACTION, 0, NULL, 0, DebugDD,
  97. NULL, AT_END, 0, NULL, 0, NULL
  98. };
  99. CMDARG ArgsDA[] =
  100. {
  101. "l", AT_NUM, AF_SEP, &dwCmdArg, 16, DebugDA,
  102. NULL, AT_ACTION, 0, NULL, 0, DebugDA,
  103. NULL, AT_END, 0, NULL, 0, NULL
  104. };
  105. CMDARG ArgsEditMem[] =
  106. {
  107. NULL, AT_ACTION, 0, NULL, 0, DebugEditMem,
  108. NULL, AT_END, 0, NULL, 0, NULL
  109. };
  110. CMDARG ArgsI[] =
  111. {
  112. NULL, AT_NUM, 0, &dwCmdArg, 16, DebugI,
  113. NULL, AT_END, 0, NULL, 0, NULL
  114. };
  115. CMDARG ArgsIW[] =
  116. {
  117. NULL, AT_NUM, 0, &dwCmdArg, 16, DebugIW,
  118. NULL, AT_END, 0, NULL, 0, NULL
  119. };
  120. CMDARG ArgsID[] =
  121. {
  122. NULL, AT_NUM, 0, &dwCmdArg, 16, DebugID,
  123. NULL, AT_END, 0, NULL, 0, NULL
  124. };
  125. CMDARG ArgsNotify[] =
  126. {
  127. NULL, AT_ACTION, 0, NULL, 0, DebugNotify,
  128. NULL, AT_END, 0, NULL, 0, NULL
  129. };
  130. CMDARG ArgsO[] =
  131. {
  132. NULL, AT_NUM, 0, &dwCmdArg, 16, DebugO,
  133. NULL, AT_END, 0, NULL, 0, NULL
  134. };
  135. CMDARG ArgsOW[] =
  136. {
  137. NULL, AT_NUM, 0, &dwCmdArg, 16, DebugOW,
  138. NULL, AT_END, 0, NULL, 0, NULL
  139. };
  140. CMDARG ArgsOD[] =
  141. {
  142. NULL, AT_NUM, 0, &dwCmdArg, 16, DebugOD,
  143. NULL, AT_END, 0, NULL, 0, NULL
  144. };
  145. CMDARG ArgsRunMethod[] =
  146. {
  147. NULL, AT_ACTION, 0, NULL, 0, DebugRunMethod,
  148. NULL, AT_END, 0, NULL, 0, NULL
  149. };
  150. #ifdef TRACING
  151. CMDARG ArgsSetTrace[] =
  152. {
  153. "trigon", AT_ENABLE, 0, &gDebugger.dwfDebugger, DBGF_TRIGGER_MODE, NULL,
  154. "trigoff", AT_DISABLE, 0, &gDebugger.dwfDebugger, DBGF_TRIGGER_MODE, NULL,
  155. "level", AT_NUM, AF_SEP, &giTraceLevel, 0, NULL,
  156. "add", AT_STRING, AF_SEP, &gpszTrigPts, 0, AddTraceTrigPts,
  157. "zap", AT_STRING, AF_SEP, &gpszTrigPts, 0, ZapTraceTrigPts,
  158. NULL, AT_END, 0, NULL, 0, NULL
  159. };
  160. #endif
  161. DBGCMD DbgCmds[] =
  162. {
  163. "?", 0, ArgsHelp, DebugHelp,
  164. "d", 0, ArgsD, DebugD,
  165. "db", 0, ArgsDB, DebugDB,
  166. "dw", 0, ArgsDW, DebugDW,
  167. "dd", 0, ArgsDD, DebugDD,
  168. "da", 0, ArgsDA, DebugDA,
  169. #ifdef DEBUG
  170. "dc", 0, NULL, DebugDC,
  171. #endif
  172. "e", 0, ArgsEditMem, DebugEditMem,
  173. "g", CMDF_QUIT, NULL, NULL,
  174. "i", 0, ArgsI, DebugI,
  175. "iw", 0, ArgsIW, DebugIW,
  176. "id", 0, ArgsID, DebugID,
  177. "notify", 0, ArgsNotify, DebugNotify,
  178. "o", 0, ArgsO, DebugO,
  179. "ow", 0, ArgsOW, DebugOW,
  180. "od", 0, ArgsOD, DebugOD,
  181. "p", 0, NULL, DebugStep,
  182. "q", 0, NULL, DebugQuit,
  183. "run", 0, ArgsRunMethod, DebugRunMethod,
  184. "t", 0, NULL, DebugTrace,
  185. #ifdef TRACING
  186. "trace", 0, ArgsSetTrace, SetTrace,
  187. #endif
  188. NULL, 0, NULL, NULL
  189. };
  190. /***EP AMLIDebugger - AMLI Debugger
  191. *
  192. * ENTRY
  193. * fCallFromVxD - debugger is invoked by the VxD .. command.
  194. *
  195. * EXIT
  196. * None
  197. */
  198. VOID STDCALL AMLIDebugger(BOOLEAN fCallFromVxD)
  199. {
  200. if (!(gDebugger.dwfDebugger & DBGF_IN_KDSHELL))
  201. {
  202. if (fCallFromVxD)
  203. {
  204. gDebugger.dwfDebugger |= DBGF_IN_VXDMODE;
  205. }
  206. else
  207. {
  208. gDebugger.dwfDebugger &= ~DBGF_IN_VXDMODE;
  209. }
  210. gDebugger.dwfDebugger |= DBGF_IN_DEBUGGER;
  211. Debugger(DbgCmds, "\n" MODNAME "(? for help)-> ");
  212. gDebugger.dwfDebugger &= ~(DBGF_IN_DEBUGGER | DBGF_IN_VXDMODE);
  213. }
  214. else
  215. {
  216. PRINTF("\nRe-entering AML debugger is not allowed.\n"
  217. "Type 'g' to go back to the AML debugger.\n");
  218. }
  219. } //AMLIDebugger
  220. /***LP DebugHelp - help
  221. *
  222. * ENTRY
  223. * pArg -> argument type entry
  224. * pszArg -> argument string
  225. * dwArgNum - argument number
  226. * dwNonSWArgs - number of non-switch arguments
  227. *
  228. * EXIT-SUCCESS
  229. * returns DBGERR_NONE
  230. * EXIT-FAILURE
  231. * returns negative error code
  232. */
  233. LONG LOCAL DebugHelp(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  234. ULONG dwNonSWArgs)
  235. {
  236. LONG rc = DBGERR_NONE;
  237. DEREF(pArg);
  238. DEREF(dwNonSWArgs);
  239. //
  240. // User typed ? <cmd>
  241. //
  242. if (pszArg != NULL)
  243. {
  244. if (STRCMP(pszArg, "?") == 0)
  245. {
  246. PRINTF("\nHelp:\n");
  247. PRINTF("Usage: ? [<Cmd>]\n");
  248. PRINTF("<Cmd> - command to get help on\n");
  249. }
  250. else if (STRCMP(pszArg, "bc") == 0)
  251. {
  252. PRINTF("\nClear Breakpoints:\n");
  253. PRINTF("Usage: bc <bp list> | *\n");
  254. PRINTF("<bp list> - list of breakpoint numbers\n");
  255. PRINTF("* - all breakpoints\n");
  256. }
  257. else if (STRCMP(pszArg, "bd") == 0)
  258. {
  259. PRINTF("\nDisable Breakpoints:\n");
  260. PRINTF("Usage: bd <bp list> | *\n");
  261. PRINTF("<bp list> - list of breakpoint numbers\n");
  262. PRINTF("* - all breakpoints\n");
  263. }
  264. else if (STRCMP(pszArg, "be") == 0)
  265. {
  266. PRINTF("\nEnable Breakpoints:\n");
  267. PRINTF("Usage: be <bp list> | *\n");
  268. PRINTF("<bp list> - list of breakpoint numbers\n");
  269. PRINTF("* - all breakpoints\n");
  270. }
  271. else if (STRCMP(pszArg, "bl") == 0)
  272. {
  273. PRINTF("\nList All Breakpoints:\n");
  274. PRINTF("Usage: bl\n");
  275. }
  276. else if (STRCMP(pszArg, "bp") == 0)
  277. {
  278. PRINTF("\nSet BreakPoints:\n");
  279. PRINTF("Usage: bp <MethodName> | <CodeAddr> ...\n");
  280. PRINTF("<MethodName> - full path of method name to have breakpoint set at\n");
  281. PRINTF("<CodeAddr> - address of AML code to have breakpoint set at\n");
  282. }
  283. else if (STRCMP(pszArg, "cl") == 0)
  284. {
  285. PRINTF("\nClear Event Log:\n");
  286. PRINTF("Usage: cl\n");
  287. }
  288. else if (STRCMP(pszArg, "d") == 0)
  289. {
  290. PRINTF("\nDump Data:\n");
  291. PRINTF("Usage: d [[l=<Len>] <Addr> | <MethodName>]\n");
  292. PRINTF("<Len> - length of address range in hex\n");
  293. PRINTF("<Addr> - data address (physical address if prefixed by \"%%\")\n");
  294. PRINTF("<MethodName> - full path of method name\n");
  295. }
  296. else if (STRCMP(pszArg, "db") == 0)
  297. {
  298. PRINTF("\nDump Data Bytes:\n");
  299. PRINTF("Usage: db [[l=<Len>] <Addr> | <MethodName>]\n");
  300. PRINTF("<Len> - length of address range in hex\n");
  301. PRINTF("<Addr> - data address (physical address if prefixed by \"%%\")\n");
  302. PRINTF("<MethodName> - full path of method name\n");
  303. }
  304. else if (STRCMP(pszArg, "dw") == 0)
  305. {
  306. PRINTF("\nDump Data Words:\n");
  307. PRINTF("Usage: dw [[l=<Len>] <Addr> | <MethodName>]\n");
  308. PRINTF("<Len> - length of address range in hex\n");
  309. PRINTF("<Addr> - data address (physical address if prefixed by \"%%\")\n");
  310. PRINTF("<MethodName> - full path of method name\n");
  311. }
  312. else if (STRCMP(pszArg, "dd") == 0)
  313. {
  314. PRINTF("\nDump Data DWords:\n");
  315. PRINTF("Usage: dd [[l=<Len>] <Addr> | <MethodName>]\n");
  316. PRINTF("<Len> - length of address rangein hex\n");
  317. PRINTF("<Addr> - data address (physical address if prefixed by \"%%\")\n");
  318. PRINTF("<MethodName> - full path of method name\n");
  319. }
  320. else if (STRCMP(pszArg, "da") == 0)
  321. {
  322. PRINTF("\nDump Data String:\n");
  323. PRINTF("Usage: da [[l=<Len>] <Addr> | <MethodName>]\n");
  324. PRINTF("<Len> - length of address range in hex\n");
  325. PRINTF("<Addr> - data address (physical address if prefixed by \"%%\")\n");
  326. PRINTF("<MethodName> - full path of method name\n");
  327. }
  328. #ifdef DEBUG
  329. else if (STRCMP(pszArg, "dc") == 0)
  330. {
  331. PRINTF("\nDump Memory Object Count Table:\n");
  332. PRINTF("Usage: dc\n");
  333. }
  334. else if (STRCMP(pszArg, "dh") == 0)
  335. {
  336. PRINTF("\nDump Heap:\n");
  337. PRINTF("Usage: dh [<Addr>]\n");
  338. PRINTF("<Addr> - address of the heap block, global heap if missing\n");
  339. }
  340. #endif
  341. else if (STRCMP(pszArg, "dl") == 0)
  342. {
  343. PRINTF("\nDump Event Log:\n");
  344. PRINTF("Usage: dl\n");
  345. }
  346. else if (STRCMP(pszArg, "ds") == 0)
  347. {
  348. PRINTF("\nDump Stack:\n");
  349. #ifdef DEBUG
  350. PRINTF("Usage: ds [/v] [<Addr>]\n");
  351. PRINTF("v - enable versbos mode\n");
  352. #else
  353. PRINTF("Usage: ds [<Addr>]\n");
  354. #endif
  355. PRINTF("<Addr> - address of the context block, use current context if missing\n");
  356. }
  357. else if (STRCMP(pszArg, "dns") == 0)
  358. {
  359. PRINTF("\nDump Name Space Object:\n");
  360. PRINTF("Usage: dns [[/s] [<NameStr> | <Addr>]]\n");
  361. PRINTF("s - recursively dump the name space subtree\n");
  362. PRINTF("<NameStr> - name space path (dump whole name space if absent)\n");
  363. PRINTF("<Addr> - specify address of the name space object\n");
  364. }
  365. else if (STRCMP(pszArg, "do") == 0)
  366. {
  367. PRINTF("\nDump Data Object:\n");
  368. PRINTF("Usage: do <Addr>\n");
  369. PRINTF("<Addr> - address of the data object\n");
  370. }
  371. else if (STRCMP(pszArg, "e") == 0)
  372. {
  373. PRINTF("\nEdit Memory:\n");
  374. PRINTF("Usage: e [<Addr> [<DataList>]]\n");
  375. PRINTF("<Addr> - memory address (physical address if prefixed by \"%%\")\n");
  376. PRINTF("<DataList> - list of data separated by spaces, "
  377. "data can be a byte or a string\n");
  378. }
  379. else if (STRCMP(pszArg, "find") == 0)
  380. {
  381. PRINTF("\nFind NameSpace Object:\n");
  382. PRINTF("Usage: find <NameSeg>\n");
  383. PRINTF("<NameSeg> - Name of the NameSpace object without path\n");
  384. }
  385. else if (STRCMP(pszArg, "g") == 0)
  386. {
  387. PRINTF("\nQuit debugger, continue normal execution.\n");
  388. }
  389. else if (STRCMP(pszArg, "i") == 0)
  390. {
  391. PRINTF("\nRead Data From a Byte Port:\n");
  392. PRINTF("Usage: i <Port>\n");
  393. PRINTF("<Port> - port address\n");
  394. }
  395. else if (STRCMP(pszArg, "iw") == 0)
  396. {
  397. PRINTF("\nRead Data From a Word Port:\n");
  398. PRINTF("Usage: iw <Port>\n");
  399. PRINTF("<Port> - port address\n");
  400. }
  401. else if (STRCMP(pszArg, "id") == 0)
  402. {
  403. PRINTF("\nRead Data From a DWord Port:\n");
  404. PRINTF("Usage: id <Port>\n");
  405. PRINTF("<Port> - port address\n");
  406. }
  407. else if (STRCMP(pszArg, "lc") == 0)
  408. {
  409. PRINTF("\nList All Contexts:\n");
  410. PRINTF("Usage: lc\n");
  411. }
  412. else if (STRCMP(pszArg, "ln") == 0)
  413. {
  414. PRINTF("\nDisplay Nearest Method Name:\n");
  415. PRINTF("Usage: ln [<MethodName> | <CodeAddr>]\n");
  416. PRINTF("<MethodName> - full path of method name\n");
  417. PRINTF("<CodeAddr> - address of AML code\n");
  418. }
  419. else if (STRCMP(pszArg, "notify") == 0)
  420. {
  421. PRINTF("\nNotify a NameSpace Object:\n");
  422. PRINTF("Usage: notify <Obj> <Value>\n");
  423. PRINTF("<Obj> - full NameSpace path of object or its address\n");
  424. PRINTF("<Value> - notification value\n");
  425. }
  426. else if (STRCMP(pszArg, "o") == 0)
  427. {
  428. PRINTF("\nWrite Data to a Byte Port:\n");
  429. PRINTF("Usage: o <Port> <Byte>\n");
  430. PRINTF("<Port> - port address\n");
  431. PRINTF("<Byte> - data to be written\n");
  432. }
  433. else if (STRCMP(pszArg, "ow") == 0)
  434. {
  435. PRINTF("\nWrite Data to a Word Port:\n");
  436. PRINTF("Usage: ow <Port> <Word>\n");
  437. PRINTF("<Port> - port address\n");
  438. PRINTF("<Word> - data to be written\n");
  439. }
  440. else if (STRCMP(pszArg, "od") == 0)
  441. {
  442. PRINTF("\nWrite Data to a DWord Port:\n");
  443. PRINTF("Usage: o <Port> <DWord>\n");
  444. PRINTF("<Port> - port address\n");
  445. PRINTF("<DWord> - data to be written\n");
  446. }
  447. else if (STRCMP(pszArg, "p") == 0)
  448. {
  449. PRINTF("\nStep over AML Code\n");
  450. PRINTF("Usage: p\n");
  451. }
  452. else if (STRCMP(pszArg, "q") == 0)
  453. {
  454. PRINTF("\nQuit to kernel debugger:\n");
  455. PRINTF("Usage: q\n");
  456. }
  457. else if (STRCMP(pszArg, "r") == 0)
  458. {
  459. PRINTF("\nDisplay Context Information:\n");
  460. PRINTF("Usage: r\n");
  461. }
  462. else if (STRCMP(pszArg, "run") == 0)
  463. {
  464. PRINTF("\nRun a Method:\n");
  465. PRINTF("Usage: run <MethodName> | <CodeAddr> [<ArgList>]\n");
  466. PRINTF("<MethodName> - full path of method name\n");
  467. PRINTF("<CodeAddr> - address of method\n");
  468. PRINTF("<ArgList> - list of integer arguments\n");
  469. }
  470. else if (STRCMP(pszArg, "set") == 0)
  471. {
  472. PRINTF("\nSet Debugger Options:\n");
  473. PRINTF("Usage: set [traceon | traceoff] [nesttraceon | nesttraceoff] [spewon | spewoff]\n"
  474. " [lbrkon | lbrkoff] [errbrkon | errbrkoff] [verboseon | verboseoff]\n"
  475. " [logon | logoff] [logmuton | logmutoff] [logsize=<MaxNumEvents>]\n");
  476. PRINTF("traceon - turn on AML tracing\n");
  477. PRINTF("traceoff - turn off AML tracing\n");
  478. PRINTF("nesttraceon - turn on nest tracing (only valid with traceon)\n");
  479. PRINTF("nesttraceoff - turn off nest tracing (only valid with traceon)\n");
  480. PRINTF("spewon - turn on debug spew\n");
  481. PRINTF("spewoff - turn off debug spew\n");
  482. PRINTF("lbrkon - enable load DDB completion break\n");
  483. PRINTF("lbrkoff - disable load DDB completion break\n");
  484. PRINTF("errbrkon - enable break on error\n");
  485. PRINTF("errbrkoff - disable break on error\n");
  486. PRINTF("verboseon - enable verbose mode\n");
  487. PRINTF("verboseoff - disable verbose mode\n");
  488. PRINTF("logon - enable event logging\n");
  489. PRINTF("logoff - disable event logging\n");
  490. PRINTF("logmuton - enable mutex event logging\n");
  491. PRINTF("logmutoff - disable mutex event logging\n");
  492. }
  493. else if (STRCMP(pszArg, "t") == 0)
  494. {
  495. PRINTF("\nTrace Into AML Code:\n");
  496. PRINTF("Usage: t\n");
  497. }
  498. #ifdef TRACING
  499. else if (STRCMP(pszArg, "trace") == 0)
  500. {
  501. PRINTF("\nInterpreter Trace Mode:\n");
  502. PRINTF("Usage: trace [trigon] [trigoff] [level=<n>] [add=<TrigPtStr>] [zap=<TrigPtList>]\n");
  503. PRINTF("trigon - turn on trace trigger mode\n");
  504. PRINTF("trigoff - turn off trace trigger mode\n");
  505. PRINTF("level - set trace level to <n>\n");
  506. PRINTF("add - add trace trigger points\n");
  507. PRINTF("<TrigPtStr> - list of trigger point strings separated by commas\n");
  508. PRINTF("zap - zap trace trigger points\n");
  509. PRINTF("<TrigPtList> - list of trigger point numbers separated by commas\n");
  510. }
  511. #endif
  512. else if (STRCMP(pszArg, "u") == 0)
  513. {
  514. PRINTF("\nUnassemble AML code:\n");
  515. PRINTF("Usage: u [<MethodName> | <CodeAddr>]\n");
  516. PRINTF("<MethodName> - full path of method name\n");
  517. PRINTF("<CodeAddr> - address of AML code\n");
  518. }
  519. else
  520. {
  521. DBG_ERROR(("invalid help command - %s", pszArg));
  522. rc = DBGERR_INVALID_CMD;
  523. }
  524. }
  525. //
  526. // User typed just a "?" without any arguments
  527. //
  528. else if (dwArgNum == 0)
  529. {
  530. PRINTF("\n");
  531. PRINTF("Help - ? [<Cmd>]\n");
  532. PRINTF("Clear Breakpoints - bc <bp list> | *\n");
  533. PRINTF("Disable Breakpoints - bd <bp list> | *\n");
  534. PRINTF("Enable Breakpoints - be <bp list> | *\n");
  535. PRINTF("List Breakpoints - bl\n");
  536. PRINTF("Set Breakpoints - bp <MethodName> | <CodeAddr> ...\n");
  537. PRINTF("Clear Event Log - cl\n");
  538. PRINTF("Dump Data - d [[l=<Len>] <Addr>]\n");
  539. PRINTF("Dump Data Bytes - db [[l=<Len>] <Addr>]\n");
  540. PRINTF("Dump Data Words - dw [[l=<Len>] <Addr>]\n");
  541. PRINTF("Dump Data DWords - dd [[l=<Len>] <Addr>]\n");
  542. PRINTF("Dump Data String - da [[l=<Len>] <Addr>]\n");
  543. PRINTF("Dump Event Log - dl\n");
  544. #ifdef DEBUG
  545. PRINTF("Dump Object Count Table - dc\n");
  546. PRINTF("Dump Heap - dh [<Addr>]\n");
  547. PRINTF("Dump Stack - ds [/v] [<Addr>]\n");
  548. #else
  549. PRINTF("Dump Stack - ds [<Addr>]\n");
  550. #endif
  551. PRINTF("Dump Name Space Object - dns [[/s] [<NameStr> | <Addr>]]\n");
  552. PRINTF("Dump Data Object - do <Addr>\n");
  553. PRINTF("Edit Memory - e [<Addr> [<DataList>]]\n");
  554. PRINTF("Find NameSpace Object - find <NameSeg>\n");
  555. PRINTF("Continue Execution - g\n");
  556. PRINTF("Read Byte from Port - i <Port>\n");
  557. PRINTF("Read Word from Port - iw <Port>\n");
  558. PRINTF("Read DWord from Port - id <Port>\n");
  559. PRINTF("List All Contexts - lc\n");
  560. PRINTF("Display Nearest Method - ln [<MethodName> | <CodeAddr>]\n");
  561. PRINTF("Notify NameSpace Object - notify <Obj> <Value>\n");
  562. PRINTF("Write Byte to Port - o <Port> <Byte>\n");
  563. PRINTF("Write Word to Port - ow <Port> <Word>\n");
  564. PRINTF("Write DWord to Port - od <Port> <DWord>\n");
  565. PRINTF("Step Over AML Code - p\n");
  566. PRINTF("Quit to Kernel Debugger - q\n");
  567. PRINTF("Display Context Info. - r\n");
  568. PRINTF("Run Method - run <MethodName> | <CodeAddr> [<ArgList>]\n");
  569. PRINTF("Set Debugger Options - set [traceon | traceoff] [nesttraceon | nesttraceoff]\n"
  570. " [spewon | spewoff] [lbrkon | lbrkoff] \n"
  571. " [errbrkon | errbrkoff] [verboseon | verboseoff] \n"
  572. " [logon | logoff] [logmuton | logmutoff] \n");
  573. PRINTF("Trace Into AML Code - t\n");
  574. #ifdef TRACING
  575. PRINTF("Interpreter Trace Mode - trace [trigon] [trigoff] [level=<n>]\n"
  576. " [add=<TrigPtStr] [zap=<TrigPtList>]\n");
  577. #endif
  578. PRINTF("Unassemble AML code - u [<MethodName> | <CodeAddr>]\n");
  579. }
  580. return rc;
  581. } //DebugHelp
  582. /***LP DebugExpr - Parse debugger expression
  583. *
  584. * ENTRY
  585. * pszArg -> expression argument
  586. * puipValue -> to hold the result of expression
  587. * pfPhysical -> set to TRUE if the expression is a physical address
  588. * (NULL if don't allow physical address)
  589. * ppns -> to hold the pointer of the nearest pns object
  590. * pdwOffset -> to hold the offset of the address to the nearest pns object
  591. *
  592. * EXIT-SUCCESS
  593. * returns DBGERR_NONE
  594. * EXIT-FAILURE
  595. * returns DBGERR_CMD_FAILED
  596. */
  597. LONG LOCAL DebugExpr(PSZ pszArg, PULONG_PTR puipValue, BOOLEAN *pfPhysical,
  598. PPNSOBJ ppns, PULONG pdwOffset)
  599. {
  600. LONG rc = DBGERR_NONE;
  601. PNSOBJ pns = NULL;
  602. ULONG dwOffset = 0;
  603. if (pfPhysical != NULL)
  604. *pfPhysical = FALSE;
  605. if ((pfPhysical != NULL) && (pszArg[0] == '%') && (pszArg[1] == '%'))
  606. {
  607. if (IsNumber(&pszArg[2], 16, puipValue))
  608. {
  609. *pfPhysical = TRUE;
  610. }
  611. else
  612. {
  613. DBG_ERROR(("invalid physical address - %s", pszArg));
  614. rc = DBGERR_INVALID_CMD;
  615. }
  616. }
  617. else if (!IsNumber(pszArg, 16, puipValue))
  618. {
  619. STRUPR(pszArg);
  620. if ((GetNameSpaceObject(pszArg, NULL, &pns, NSF_LOCAL_SCOPE) ==
  621. STATUS_SUCCESS) &&
  622. (pns->ObjData.dwDataType == OBJTYPE_METHOD))
  623. {
  624. *puipValue = (ULONG_PTR)
  625. (((PMETHODOBJ)pns->ObjData.pbDataBuff)->abCodeBuff);
  626. }
  627. else
  628. {
  629. DBG_ERROR(("object not found or object is not a method - %s",
  630. pszArg));
  631. rc = DBGERR_INVALID_CMD;
  632. }
  633. }
  634. else if (FindObjSymbol((PUCHAR)*puipValue, &pns, &dwOffset))
  635. {
  636. if ((pns->ObjData.dwDataType != OBJTYPE_METHOD) ||
  637. (dwOffset >= pns->ObjData.dwDataLen -
  638. FIELD_OFFSET(METHODOBJ, abCodeBuff)))
  639. {
  640. pns = NULL;
  641. dwOffset = 0;
  642. }
  643. }
  644. if (rc == DBGERR_NONE)
  645. {
  646. if (ppns != NULL)
  647. *ppns = pns;
  648. if (pdwOffset != NULL)
  649. *pdwOffset = dwOffset;
  650. }
  651. return rc;
  652. } //DebugExpr
  653. /***LP IsNumber - Check if string is a number, if so return the number
  654. *
  655. * ENTRY
  656. * pszStr -> string
  657. * dwBase - base
  658. * puipValue -> to hold the number
  659. *
  660. * EXIT-SUCCESS
  661. * returns TRUE - the string is a number
  662. * EXIT-FAILURE
  663. * returns FALSE - the string is not a number
  664. */
  665. BOOLEAN LOCAL IsNumber(PSZ pszStr, ULONG dwBase, PULONG_PTR puipValue)
  666. {
  667. BOOLEAN rc;
  668. PSZ psz;
  669. *puipValue = (ULONG_PTR)STRTOUL(pszStr, &psz, dwBase);
  670. if ((psz != pszStr) && (*psz == '\0'))
  671. rc = TRUE;
  672. else
  673. rc = FALSE;
  674. return rc;
  675. } //IsNumber
  676. /***LP DumpData - Dump data
  677. *
  678. * ENTRY
  679. * uipAddr - data address
  680. * dwfUnitSize - DBGF_DUMPDATA_MASK flags
  681. * dwLen - length of data range
  682. * fPhysical - TRUE if uipAddr is a physical address
  683. *
  684. * EXIT-SUCCESS
  685. * returns DBGERR_NONE
  686. * EXIT-FAILURE
  687. * returns negative error code
  688. */
  689. LONG LOCAL DumpData(ULONG_PTR uipAddr, ULONG dwfUnitSize, ULONG dwLen,
  690. BOOLEAN fPhysical)
  691. {
  692. LONG rc = DBGERR_NONE;
  693. PUCHAR pbData = NULL;
  694. PSZ pszPrefix = "";
  695. gDebugger.dwfDebugger &= ~(DBGF_DUMPDATA_MASK | DBGF_DUMPDATA_PHYADDR);
  696. gDebugger.dwfDebugger |= dwfUnitSize;
  697. if (fPhysical)
  698. {
  699. gDebugger.dwfDebugger |= DBGF_DUMPDATA_PHYADDR;
  700. pszPrefix = "%%";
  701. if (MapUnmapPhysMem(NULL, uipAddr, dwLen, (PULONG_PTR)&pbData) !=
  702. STATUS_SUCCESS)
  703. {
  704. DBG_ERROR(("Failed to map physical address %x", uipAddr));
  705. rc = DBGERR_CMD_FAILED;
  706. }
  707. }
  708. else
  709. pbData = (PUCHAR)uipAddr;
  710. if (ASSERTRANGE(pbData, dwLen))
  711. {
  712. if (dwfUnitSize == DBGF_DUMPDATA_STRING)
  713. {
  714. gDebugger.uipDumpDataAddr = uipAddr;
  715. PRINTF("%s%08x: ", pszPrefix, uipAddr);
  716. while ((dwLen > 0) && (*pbData != '\0'))
  717. {
  718. PRINTF("%c",
  719. ((*pbData >= ' ') && (*pbData <= '~'))? *pbData: '.');
  720. pbData++;
  721. dwLen--;
  722. }
  723. PRINTF("\n");
  724. }
  725. else
  726. {
  727. PUCHAR pbEnd = pbData + dwLen;
  728. ULONG dwDataSize = DATASIZE(dwfUnitSize);
  729. int i;
  730. for (i = 0; pbData < pbEnd;)
  731. {
  732. if (i == 0)
  733. PRINTF("%s%08x: ", pszPrefix, uipAddr);
  734. else if ((i == 8) && (dwDataSize == sizeof(UCHAR)))
  735. PRINTF("-");
  736. else
  737. PRINTF(" ");
  738. switch (dwDataSize)
  739. {
  740. case sizeof(UCHAR):
  741. PRINTF("%02x", *pbData);
  742. break;
  743. case sizeof(USHORT):
  744. PRINTF("%04x", *((PUSHORT)pbData));
  745. break;
  746. case sizeof(ULONG):
  747. PRINTF("%08x", *((PULONG)pbData));
  748. }
  749. pbData += dwDataSize;
  750. uipAddr += (ULONG_PTR)dwDataSize;
  751. i += (int)dwDataSize;
  752. if (i == 0x10)
  753. {
  754. if (dwDataSize == sizeof(UCHAR))
  755. {
  756. UCHAR b;
  757. PRINTF(" ");
  758. for (i = 0x10; i > 0; --i)
  759. {
  760. b = *(pbData - i);
  761. PRINTF("%c", ((b >= ' ') && (b <= '~'))? b: '.');
  762. }
  763. }
  764. i = 0;
  765. PRINTF("\n");
  766. }
  767. }
  768. gDebugger.uipDumpDataAddr = uipAddr;
  769. }
  770. }
  771. else
  772. {
  773. DBG_ERROR(("invalid address %08x", uipAddr));
  774. rc = DBGERR_INVALID_CMD;
  775. }
  776. if (fPhysical && (pbData != NULL))
  777. {
  778. MapUnmapPhysMem(NULL, (ULONG_PTR)pbData, dwLen, NULL);
  779. }
  780. return rc;
  781. } //DumpData
  782. /***LP DebugDumpData - Dump data to debugger
  783. *
  784. * ENTRY
  785. * pArg -> argument type entry
  786. * pszArg -> argument string
  787. * dwfDataSize - data size flags
  788. *
  789. * EXIT-SUCCESS
  790. * returns DBGERR_NONE
  791. * EXIT-FAILURE
  792. * returns negative error code
  793. */
  794. LONG LOCAL DebugDumpData(PCMDARG pArg, PSZ pszArg, ULONG dwfDataSize)
  795. {
  796. LONG rc = DBGERR_NONE;
  797. static BOOLEAN fProcessed = FALSE;
  798. #define DEF_LEN 0x80
  799. static ULONG dwLen = DEF_LEN;
  800. if (pszArg != NULL)
  801. {
  802. if ((pArg != NULL) && (pArg->dwArgType == AT_NUM))
  803. {
  804. dwLen = dwCmdArg;
  805. }
  806. else
  807. {
  808. ULONG_PTR uipAddr;
  809. BOOLEAN fPhysical;
  810. if (((rc = DebugExpr(pszArg, &uipAddr, &fPhysical, NULL, NULL)) ==
  811. DBGERR_NONE) &&
  812. ((rc = DumpData(uipAddr, dwfDataSize, dwLen, fPhysical)) ==
  813. DBGERR_NONE))
  814. {
  815. fProcessed = TRUE;
  816. }
  817. }
  818. }
  819. else
  820. {
  821. if (fProcessed)
  822. fProcessed = FALSE;
  823. else
  824. {
  825. rc = DumpData(gDebugger.uipDumpDataAddr, dwfDataSize, dwLen,
  826. (BOOLEAN)((gDebugger.dwfDebugger &
  827. DBGF_DUMPDATA_PHYADDR) != 0));
  828. }
  829. dwLen = DEF_LEN;
  830. }
  831. return rc;
  832. } //DebugDumpData
  833. /***LP DebugD - Dump data
  834. *
  835. * ENTRY
  836. * pArg -> argument type entry
  837. * pszArg -> argument string
  838. * dwArgNum - argument number
  839. * dwNonSWArgs - number of non-switch arguments
  840. *
  841. * EXIT-SUCCESS
  842. * returns DBGERR_NONE
  843. * EXIT-FAILURE
  844. * returns negative error code
  845. */
  846. LONG LOCAL DebugD(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  847. {
  848. LONG rc;
  849. DEREF(dwArgNum);
  850. DEREF(dwNonSWArgs);
  851. rc = DebugDumpData(pArg, pszArg,
  852. gDebugger.dwfDebugger & DBGF_DUMPDATA_MASK);
  853. return rc;
  854. } //DebugD
  855. /***LP DebugDB - Dump data bytes
  856. *
  857. * ENTRY
  858. * pArg -> argument type entry
  859. * pszArg -> argument string
  860. * dwArgNum - argument number
  861. * dwNonSWArgs - number of non-switch arguments
  862. *
  863. * EXIT-SUCCESS
  864. * returns DBGERR_NONE
  865. * EXIT-FAILURE
  866. * returns negative error code
  867. */
  868. LONG LOCAL DebugDB(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  869. {
  870. LONG rc;
  871. DEREF(dwArgNum);
  872. DEREF(dwNonSWArgs);
  873. rc = DebugDumpData(pArg, pszArg, DBGF_DUMPDATA_BYTE);
  874. return rc;
  875. } //DebugDB
  876. /***LP DebugDW - Dump data words
  877. *
  878. * ENTRY
  879. * pArg -> argument type entry
  880. * pszArg -> argument string
  881. * dwArgNum - argument number
  882. * dwNonSWArgs - number of non-switch arguments
  883. *
  884. * EXIT-SUCCESS
  885. * returns DBGERR_NONE
  886. * EXIT-FAILURE
  887. * returns negative error code
  888. */
  889. LONG LOCAL DebugDW(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  890. {
  891. LONG rc;
  892. DEREF(dwArgNum);
  893. DEREF(dwNonSWArgs);
  894. rc = DebugDumpData(pArg, pszArg, DBGF_DUMPDATA_WORD);
  895. return rc;
  896. } //DebugDW
  897. /***LP DebugDD - Dump data dwords
  898. *
  899. * ENTRY
  900. * pArg -> argument type entry
  901. * pszArg -> argument string
  902. * dwArgNum - argument number
  903. * dwNonSWArgs - number of non-switch arguments
  904. *
  905. * EXIT-SUCCESS
  906. * returns DBGERR_NONE
  907. * EXIT-FAILURE
  908. * returns negative error code
  909. */
  910. LONG LOCAL DebugDD(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  911. {
  912. LONG rc;
  913. DEREF(dwArgNum);
  914. DEREF(dwNonSWArgs);
  915. rc = DebugDumpData(pArg, pszArg, DBGF_DUMPDATA_DWORD);
  916. return rc;
  917. } //DebugDD
  918. /***LP DebugDA - Dump data string
  919. *
  920. * ENTRY
  921. * pArg -> argument type entry
  922. * pszArg -> argument string
  923. * dwArgNum - argument number
  924. * dwNonSWArgs - number of non-switch arguments
  925. *
  926. * EXIT-SUCCESS
  927. * returns DBGERR_NONE
  928. * EXIT-FAILURE
  929. * returns negative error code
  930. */
  931. LONG LOCAL DebugDA(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  932. {
  933. LONG rc;
  934. DEREF(dwArgNum);
  935. DEREF(dwNonSWArgs);
  936. rc = DebugDumpData(pArg, pszArg, DBGF_DUMPDATA_STRING);
  937. return rc;
  938. } //DebugDA
  939. #ifdef DEBUG
  940. /***LP DebugDC - Dump memory object count table
  941. *
  942. * ENTRY
  943. * pArg -> argument type entry
  944. * pszArg -> argument string
  945. * dwArgNum - argument number
  946. * dwNonSWArgs - number of non-switch arguments
  947. *
  948. * EXIT-SUCCESS
  949. * returns DBGERR_NONE
  950. * EXIT-FAILURE
  951. * returns negative error code
  952. */
  953. LONG LOCAL DebugDC(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  954. {
  955. LONG rc;
  956. DEREF(pArg);
  957. DEREF(dwArgNum);
  958. DEREF(dwNonSWArgs);
  959. if (pszArg == NULL)
  960. {
  961. DumpMemObjCounts();
  962. rc = DBGERR_NONE;
  963. }
  964. else
  965. {
  966. DBG_ERROR(("invalid dump object count command"));
  967. rc = DBGERR_INVALID_CMD;
  968. }
  969. return rc;
  970. } //DebugDC
  971. #endif
  972. /***LP DebugEditMem - Edit memory
  973. *
  974. * ENTRY
  975. * pArg -> argument type entry
  976. * pszArg -> argument string
  977. * dwfDataSize - data size flags
  978. *
  979. * EXIT-SUCCESS
  980. * returns DBGERR_NONE
  981. * EXIT-FAILURE
  982. * returns negative error code
  983. */
  984. LONG LOCAL DebugEditMem(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  985. ULONG dwNonSWArgs)
  986. {
  987. LONG rc = DBGERR_NONE;
  988. static BOOLEAN fProcessed = FALSE;
  989. static BOOLEAN fPhysical = FALSE;
  990. static ULONG_PTR uipAddr = 0;
  991. DEREF(pArg);
  992. DEREF(dwArgNum);
  993. DEREF(dwNonSWArgs);
  994. if (pszArg != NULL)
  995. {
  996. ULONG_PTR uipData;
  997. PUCHAR pbMemAddr;
  998. if (dwArgNum == 1)
  999. {
  1000. if (pszArg[0] == '%')
  1001. {
  1002. if (IsNumber(&pszArg[2], 16, &uipData))
  1003. {
  1004. fPhysical = TRUE;
  1005. uipAddr = uipData;
  1006. }
  1007. else
  1008. {
  1009. DBG_ERROR(("invalid physical address - %s", pszArg));
  1010. rc = DBGERR_INVALID_CMD;
  1011. }
  1012. }
  1013. else if (IsNumber(pszArg, 16, &uipData))
  1014. {
  1015. uipAddr = uipData;
  1016. }
  1017. else
  1018. {
  1019. DBG_ERROR(("invalid address - %s", pszArg));
  1020. rc = DBGERR_INVALID_CMD;
  1021. }
  1022. }
  1023. else if (IsNumber(pszArg, 16, &uipData))
  1024. {
  1025. if (uipData <= MAX_BYTE)
  1026. {
  1027. if (fPhysical)
  1028. {
  1029. if (MapUnmapPhysMem(NULL, uipAddr, 1,
  1030. (PULONG_PTR)&pbMemAddr) !=
  1031. STATUS_SUCCESS)
  1032. {
  1033. DBG_ERROR(("Failed to map physical address %p",
  1034. uipAddr));
  1035. rc = DBGERR_CMD_FAILED;
  1036. }
  1037. }
  1038. else
  1039. pbMemAddr = (PUCHAR)uipAddr;
  1040. if (ASSERTRANGE(pbMemAddr, 1))
  1041. {
  1042. *pbMemAddr = (UCHAR)uipData;
  1043. uipAddr++;
  1044. }
  1045. else
  1046. {
  1047. DBG_ERROR(("invalid address - %s", uipAddr));
  1048. rc = DBGERR_INVALID_CMD;
  1049. }
  1050. if (fPhysical)
  1051. {
  1052. MapUnmapPhysMem(NULL, (ULONG_PTR)pbMemAddr, 1, NULL);
  1053. }
  1054. }
  1055. else
  1056. {
  1057. DBG_ERROR(("data must be a byte value - %s", pszArg));
  1058. rc = DBGERR_INVALID_CMD;
  1059. }
  1060. }
  1061. else if ((pszArg[0] == '"') && (pszArg[STRLEN(pszArg) - 1] == '"'))
  1062. {
  1063. int i, icLen;
  1064. icLen = STRLEN(pszArg);
  1065. if (fPhysical)
  1066. {
  1067. if (MapUnmapPhysMem(NULL, uipAddr, icLen,
  1068. (PULONG_PTR)&pbMemAddr) != STATUS_SUCCESS)
  1069. {
  1070. DBG_ERROR(("Failed to map physical address %p", uipAddr));
  1071. rc = DBGERR_CMD_FAILED;
  1072. }
  1073. }
  1074. else
  1075. pbMemAddr = (PUCHAR)uipAddr;
  1076. if (ASSERTRANGE(pbMemAddr, icLen))
  1077. {
  1078. for (i = 1; i < icLen - 1; ++i)
  1079. {
  1080. *pbMemAddr = pszArg[i];
  1081. pbMemAddr++;
  1082. uipAddr++;
  1083. }
  1084. }
  1085. else
  1086. {
  1087. DBG_ERROR(("invalid address - %s", uipAddr));
  1088. rc = DBGERR_INVALID_CMD;
  1089. }
  1090. if (fPhysical)
  1091. {
  1092. MapUnmapPhysMem(NULL, (ULONG_PTR)pbMemAddr, icLen, NULL);
  1093. }
  1094. }
  1095. else
  1096. {
  1097. DBG_ERROR(("invalid data - %s", pszArg));
  1098. rc = DBGERR_INVALID_CMD;
  1099. }
  1100. if ((rc == DBGERR_NONE) && (dwArgNum > 1))
  1101. fProcessed = TRUE;
  1102. }
  1103. else
  1104. {
  1105. if (fProcessed)
  1106. fProcessed = FALSE;
  1107. else
  1108. {
  1109. DBG_ERROR(("invalid EditMemory command"));
  1110. rc = DBGERR_INVALID_CMD;
  1111. }
  1112. fPhysical = FALSE;
  1113. }
  1114. return rc;
  1115. } //DebugEditMem
  1116. /***LP InPort - Read from an I/O port
  1117. *
  1118. * dwPort - port address
  1119. * dwSize - port size
  1120. * pdwData -> to hold data read
  1121. *
  1122. * EXIT-SUCCESS
  1123. * returns DBGERR_NONE
  1124. * EXIT-FAILURE
  1125. * returns negative error code
  1126. */
  1127. LONG LOCAL InPort(ULONG dwPort, ULONG dwSize, PULONG pdwData)
  1128. {
  1129. LONG rc = DBGERR_NONE;
  1130. PHYSICAL_ADDRESS phyaddr = {0, 0}, XlatedAddr;
  1131. ULONG dwAddrSpace;
  1132. phyaddr.LowPart = dwPort;
  1133. dwAddrSpace = 1;
  1134. if (HalTranslateBusAddress(Internal, 0, phyaddr, &dwAddrSpace, &XlatedAddr))
  1135. {
  1136. dwPort = XlatedAddr.LowPart;
  1137. *pdwData = ReadSystemIO(dwPort, dwSize, 0xffffffff);
  1138. }
  1139. else
  1140. {
  1141. DBG_ERROR(("failed to translate port address"));
  1142. rc = DBGERR_CMD_FAILED;
  1143. }
  1144. return rc;
  1145. } //InPort
  1146. /***LP DebugInPort - Port input
  1147. *
  1148. * ENTRY
  1149. * pszArg -> argument string
  1150. * dwSize - port size
  1151. *
  1152. * EXIT-SUCCESS
  1153. * returns DBGERR_NONE
  1154. * EXIT-FAILURE
  1155. * returns negative error code
  1156. */
  1157. LONG LOCAL DebugInPort(PSZ pszArg, ULONG dwSize)
  1158. {
  1159. LONG rc = DBGERR_NONE;
  1160. static BOOLEAN fProcessed = FALSE;
  1161. if (pszArg != NULL)
  1162. {
  1163. ULONG_PTR uipPort;
  1164. if (fProcessed || !IsNumber(pszArg, 16, &uipPort))
  1165. {
  1166. DBG_ERROR(("invalid inport command"));
  1167. rc = DBGERR_INVALID_CMD;
  1168. }
  1169. else
  1170. {
  1171. ULONG dwData;
  1172. if ((rc = InPort((ULONG)uipPort, dwSize, &dwData)) == DBGERR_NONE)
  1173. {
  1174. PRINTF("%04x: ", (ULONG)uipPort);
  1175. switch (dwSize)
  1176. {
  1177. case sizeof(UCHAR):
  1178. PRINTF("%02x", (UCHAR)dwData);
  1179. break;
  1180. case sizeof(USHORT):
  1181. PRINTF("%04x", (USHORT)dwData);
  1182. break;
  1183. case sizeof(ULONG):
  1184. PRINTF("%08x", dwData);
  1185. }
  1186. PRINTF("\n");
  1187. }
  1188. }
  1189. if (rc == DBGERR_NONE)
  1190. fProcessed = TRUE;
  1191. }
  1192. else
  1193. {
  1194. if (fProcessed)
  1195. fProcessed = FALSE;
  1196. else
  1197. {
  1198. DBG_ERROR(("invalid inport command"));
  1199. rc = DBGERR_INVALID_CMD;
  1200. }
  1201. }
  1202. return rc;
  1203. } //DebugInPort
  1204. /***LP DebugI - Byte port input
  1205. *
  1206. * ENTRY
  1207. * pArg -> argument type entry
  1208. * pszArg -> argument string
  1209. * dwArgNum - argument number
  1210. * dwNonSWArgs - number of non-switch arguments
  1211. *
  1212. * EXIT-SUCCESS
  1213. * returns DBGERR_NONE
  1214. * EXIT-FAILURE
  1215. * returns negative error code
  1216. */
  1217. LONG LOCAL DebugI(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  1218. {
  1219. LONG rc;
  1220. DEREF(pArg);
  1221. DEREF(dwArgNum);
  1222. DEREF(dwNonSWArgs);
  1223. rc = DebugInPort(pszArg, sizeof(UCHAR));
  1224. return rc;
  1225. } //DebugI
  1226. /***LP DebugIW - Word port input
  1227. *
  1228. * ENTRY
  1229. * pArg -> argument type entry
  1230. * pszArg -> argument string
  1231. * dwArgNum - argument number
  1232. * dwNonSWArgs - number of non-switch arguments
  1233. *
  1234. * EXIT-SUCCESS
  1235. * returns DBGERR_NONE
  1236. * EXIT-FAILURE
  1237. * returns negative error code
  1238. */
  1239. LONG LOCAL DebugIW(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  1240. {
  1241. LONG rc;
  1242. DEREF(pArg);
  1243. DEREF(dwArgNum);
  1244. DEREF(dwNonSWArgs);
  1245. rc = DebugInPort(pszArg, sizeof(USHORT));
  1246. return rc;
  1247. } //DebugIW
  1248. /***LP DebugID - DWord port input
  1249. *
  1250. * ENTRY
  1251. * pArg -> argument type entry
  1252. * pszArg -> argument string
  1253. * dwArgNum - argument number
  1254. * dwNonSWArgs - number of non-switch arguments
  1255. *
  1256. * EXIT-SUCCESS
  1257. * returns DBGERR_NONE
  1258. * EXIT-FAILURE
  1259. * returns negative error code
  1260. */
  1261. LONG LOCAL DebugID(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  1262. {
  1263. LONG rc;
  1264. DEREF(pArg);
  1265. DEREF(dwArgNum);
  1266. DEREF(dwNonSWArgs);
  1267. rc = DebugInPort(pszArg, sizeof(ULONG));
  1268. return rc;
  1269. } //DebugID
  1270. /***LP DebugQuit - Quit to kernel debugger
  1271. *
  1272. * ENTRY
  1273. * pArg -> argument type entry
  1274. * pszArg -> argument string
  1275. * dwArgNum - argument number
  1276. * dwNonSWArgs - number of non-switch arguments
  1277. *
  1278. * EXIT-SUCCESS
  1279. * returns DBGERR_NONE
  1280. * EXIT-FAILURE
  1281. * returns negative error code
  1282. */
  1283. LONG LOCAL DebugQuit(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1284. ULONG dwNonSWArgs)
  1285. {
  1286. LONG rc;
  1287. DEREF(pArg);
  1288. DEREF(dwArgNum);
  1289. DEREF(dwNonSWArgs);
  1290. if (pszArg == NULL)
  1291. {
  1292. if (gDebugger.dwfDebugger & DBGF_IN_VXDMODE)
  1293. {
  1294. rc = DBGERR_QUIT;
  1295. }
  1296. else
  1297. {
  1298. PRINTF("\nShell to Kernel Debugger.\n"
  1299. "Type 'g' to go back to the AML debugger.\n\n");
  1300. gDebugger.dwfDebugger |= DBGF_IN_KDSHELL;
  1301. KdBreakPoint();
  1302. gDebugger.dwfDebugger &= ~DBGF_IN_KDSHELL;
  1303. rc = DBGERR_NONE;
  1304. }
  1305. }
  1306. else
  1307. {
  1308. DBG_ERROR(("invalid Quit command"));
  1309. rc = DBGERR_INVALID_CMD;
  1310. }
  1311. return rc;
  1312. } //DebugQuit
  1313. /***LP DummyCallBack - Callback that does absolutely nothing
  1314. *
  1315. * ENTRY
  1316. * pv - not used
  1317. *
  1318. * EXIT
  1319. * None
  1320. */
  1321. VOID LOCAL DummyCallBack(PVOID pv)
  1322. {
  1323. DEREF(pv);
  1324. } //DummyCallBack
  1325. /***LP DebugNotify - Notify object
  1326. *
  1327. * ENTRY
  1328. * pArg -> argument type entry
  1329. * pszArg -> argument string
  1330. * dwArgNum - argument number
  1331. * dwNonSWArgs - number of non-switch arguments
  1332. *
  1333. * EXIT-SUCCESS
  1334. * returns DBGERR_NONE
  1335. * EXIT-FAILURE
  1336. * returns negative error code
  1337. */
  1338. LONG LOCAL DebugNotify(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1339. ULONG dwNonSWArgs)
  1340. {
  1341. LONG rc = DBGERR_NONE;
  1342. static PNSOBJ pns = NULL;
  1343. static ULONG_PTR uipValue = 0;
  1344. DEREF(pArg);
  1345. if (pszArg != NULL)
  1346. {
  1347. switch (dwArgNum)
  1348. {
  1349. case 1:
  1350. if (!IsNumber(pszArg, 16, (PULONG_PTR)&pns))
  1351. {
  1352. STRUPR(pszArg);
  1353. if (GetNameSpaceObject(pszArg, NULL, &pns, NSF_LOCAL_SCOPE)
  1354. != STATUS_SUCCESS)
  1355. {
  1356. DBG_ERROR(("object not found - %s", pszArg));
  1357. rc = DBGERR_INVALID_CMD;
  1358. }
  1359. }
  1360. break;
  1361. case 2:
  1362. if (!IsNumber(pszArg, 16, &uipValue))
  1363. {
  1364. DBG_ERROR(("invalid notification value - %s", pszArg));
  1365. rc = DBGERR_INVALID_CMD;
  1366. }
  1367. break;
  1368. default:
  1369. DBG_ERROR(("invalid notify command"));
  1370. rc = DBGERR_INVALID_CMD;
  1371. }
  1372. }
  1373. else
  1374. {
  1375. if (dwNonSWArgs != 2)
  1376. {
  1377. DBG_ERROR(("invalid notify command"));
  1378. rc = DBGERR_INVALID_CMD;
  1379. }
  1380. else if (!ASSERTRANGE(pns, sizeof(NSOBJ)))
  1381. {
  1382. DBG_ERROR(("invalid object"));
  1383. rc = DBGERR_INVALID_CMD;
  1384. }
  1385. else
  1386. {
  1387. PRINTF("Queuing: Notify(%s, %x) ...\n",
  1388. GetObjectPath(pns), uipValue);
  1389. ((PFNNH)ghNotify.pfnHandler)(EVTYPE_NOTIFY, (ULONG)uipValue, pns,
  1390. (ULONG)ghNotify.uipParam,
  1391. DummyCallBack, NULL);
  1392. }
  1393. }
  1394. return rc;
  1395. } //DebugNotify
  1396. /***LP OutPort - Write to an I/O port
  1397. *
  1398. * dwPort - port address
  1399. * dwSize - port size
  1400. * dwData - data to be written
  1401. *
  1402. * EXIT-SUCCESS
  1403. * returns DBGERR_NONE
  1404. * EXIT-FAILURE
  1405. * returns negative error code
  1406. */
  1407. LONG LOCAL OutPort(ULONG dwPort, ULONG dwSize, ULONG dwData)
  1408. {
  1409. LONG rc = DBGERR_NONE;
  1410. PHYSICAL_ADDRESS phyaddr = {0, 0}, XlatedAddr;
  1411. ULONG dwAddrSpace;
  1412. phyaddr.LowPart = dwPort;
  1413. dwAddrSpace = 1;
  1414. if (HalTranslateBusAddress(Internal, 0, phyaddr, &dwAddrSpace, &XlatedAddr))
  1415. {
  1416. dwPort = XlatedAddr.LowPart;
  1417. WriteSystemIO(dwPort, dwSize, dwData);
  1418. }
  1419. else
  1420. {
  1421. DBG_ERROR(("failed to translate port address"));
  1422. rc = DBGERR_CMD_FAILED;
  1423. }
  1424. return rc;
  1425. } //OutPort
  1426. /***LP DebugOutPort - Port output
  1427. *
  1428. * ENTRY
  1429. * pszArg -> argument string
  1430. * dwSize - port size
  1431. *
  1432. * EXIT-SUCCESS
  1433. * returns DBGERR_NONE
  1434. * EXIT-FAILURE
  1435. * returns negative error code
  1436. */
  1437. LONG LOCAL DebugOutPort(PSZ pszArg, ULONG dwSize)
  1438. {
  1439. LONG rc = DBGERR_NONE;
  1440. static int icArgs = 0;
  1441. static ULONG dwPort = 0;
  1442. if (pszArg != NULL)
  1443. {
  1444. ULONG_PTR uipData;
  1445. icArgs++;
  1446. if ((icArgs > 2) || !IsNumber(pszArg, 16, &uipData))
  1447. {
  1448. DBG_ERROR(("invalid outport command"));
  1449. rc = DBGERR_INVALID_CMD;
  1450. }
  1451. else if (icArgs == 1)
  1452. {
  1453. dwPort = (ULONG)uipData;
  1454. }
  1455. else
  1456. {
  1457. OutPort(dwPort, dwSize, (ULONG)uipData);
  1458. }
  1459. if (rc != DBGERR_NONE)
  1460. icArgs = 0;
  1461. }
  1462. else
  1463. {
  1464. if (icArgs != 2)
  1465. {
  1466. DBG_ERROR(("invalid outport command"));
  1467. rc = DBGERR_INVALID_CMD;
  1468. }
  1469. icArgs = 0;
  1470. }
  1471. return rc;
  1472. } //DebugOutPort
  1473. /***LP DebugO - Byte port output
  1474. *
  1475. * ENTRY
  1476. * pArg -> argument type entry
  1477. * pszArg -> argument string
  1478. * dwArgNum - argument number
  1479. * dwNonSWArgs - number of non-switch arguments
  1480. *
  1481. * EXIT-SUCCESS
  1482. * returns DBGERR_NONE
  1483. * EXIT-FAILURE
  1484. * returns negative error code
  1485. */
  1486. LONG LOCAL DebugO(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  1487. {
  1488. LONG rc;
  1489. DEREF(pArg);
  1490. DEREF(dwArgNum);
  1491. DEREF(dwNonSWArgs);
  1492. rc = DebugOutPort(pszArg, sizeof(UCHAR));
  1493. return rc;
  1494. } //DebugO
  1495. /***LP DebugOW - Word port output
  1496. *
  1497. * ENTRY
  1498. * pArg -> argument type entry
  1499. * pszArg -> argument string
  1500. * dwArgNum - argument number
  1501. * dwNonSWArgs - number of non-switch arguments
  1502. *
  1503. * EXIT-SUCCESS
  1504. * returns DBGERR_NONE
  1505. * EXIT-FAILURE
  1506. * returns negative error code
  1507. */
  1508. LONG LOCAL DebugOW(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  1509. {
  1510. LONG rc;
  1511. DEREF(pArg);
  1512. DEREF(dwArgNum);
  1513. DEREF(dwNonSWArgs);
  1514. rc = DebugOutPort(pszArg, sizeof(USHORT));
  1515. return rc;
  1516. } //DebugOW
  1517. /***LP DebugOD - DWord port output
  1518. *
  1519. * ENTRY
  1520. * pArg -> argument type entry
  1521. * pszArg -> argument string
  1522. * dwArgNum - argument number
  1523. * dwNonSWArgs - number of non-switch arguments
  1524. *
  1525. * EXIT-SUCCESS
  1526. * returns DBGERR_NONE
  1527. * EXIT-FAILURE
  1528. * returns negative error code
  1529. */
  1530. LONG LOCAL DebugOD(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum, ULONG dwNonSWArgs)
  1531. {
  1532. LONG rc;
  1533. DEREF(pArg);
  1534. DEREF(dwArgNum);
  1535. DEREF(dwNonSWArgs);
  1536. rc = DebugOutPort(pszArg, sizeof(ULONG));
  1537. return rc;
  1538. } //DebugOD
  1539. /***LP DebugStep - Trace and step over an AML instruction
  1540. *
  1541. * ENTRY
  1542. * pArg -> argument type entry
  1543. * pszArg -> argument string
  1544. * dwArgNum - argument number
  1545. * dwNonSWArgs - number of non-switch arguments
  1546. *
  1547. * EXIT-SUCCESS
  1548. * returns DBGERR_NONE
  1549. * EXIT-FAILURE
  1550. * returns negative error code
  1551. */
  1552. LONG LOCAL DebugStep(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1553. ULONG dwNonSWArgs)
  1554. {
  1555. LONG rc = DBGERR_NONE;
  1556. DEREF(pArg);
  1557. DEREF(dwArgNum);
  1558. DEREF(dwNonSWArgs);
  1559. if (pszArg == NULL)
  1560. {
  1561. gDebugger.dwfDebugger |= DBGF_STEP_OVER;
  1562. rc = DBGERR_QUIT;
  1563. }
  1564. else
  1565. {
  1566. DBG_ERROR(("invalid step command"));
  1567. rc = DBGERR_INVALID_CMD;
  1568. }
  1569. return rc;
  1570. } //DebugStep
  1571. /***LP DebugSetLogSize - Set EventLog size
  1572. *
  1573. * ENTRY
  1574. * pArg -> argument type entry
  1575. * pszArg -> argument string
  1576. * dwArgNum - argument number
  1577. * dwNonSWArgs - number of non-switch arguments
  1578. *
  1579. * EXIT-SUCCESS
  1580. * returns DBGERR_NONE
  1581. * EXIT-FAILURE
  1582. * returns negative error code
  1583. */
  1584. LONG LOCAL DebugSetLogSize(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1585. ULONG dwNonSWArgs)
  1586. {
  1587. LONG rc = DBGERR_NONE;
  1588. DEREF(pArg);
  1589. DEREF(pszArg);
  1590. DEREF(dwArgNum);
  1591. DEREF(dwNonSWArgs);
  1592. if (!SetLogSize(dwCmdArg))
  1593. {
  1594. DBG_ERROR(("failed to set EventLog size to %d", dwCmdArg));
  1595. rc = DBGERR_CMD_FAILED;
  1596. }
  1597. return rc;
  1598. } //DebugSetLogSize
  1599. /***LP SetLogSize - Set EventLog size
  1600. *
  1601. * ENTRY
  1602. * dwLogSize - EventLog size
  1603. *
  1604. * EXIT-SUCCESS
  1605. * returns TRUE
  1606. * EXIT-FAILURE
  1607. * returns FALSE
  1608. */
  1609. BOOLEAN LOCAL SetLogSize(ULONG dwLogSize)
  1610. {
  1611. BOOLEAN rc = FALSE;
  1612. if (gDebugger.pEventLog != NULL)
  1613. {
  1614. MFREE(gDebugger.pEventLog);
  1615. gDebugger.pEventLog = NULL;
  1616. gDebugger.dwLogSize = 0;
  1617. gDebugger.dwLogIndex = 0;
  1618. }
  1619. if ((gDebugger.pEventLog = MALLOC_LOCKED(sizeof(EVENTLOG)*dwLogSize,
  1620. 'GOLE')) != NULL)
  1621. {
  1622. gDebugger.dwLogSize = dwLogSize;
  1623. gDebugger.dwLogIndex = 0;
  1624. MEMZERO(gDebugger.pEventLog, sizeof(EVENTLOG)*dwLogSize);
  1625. rc = TRUE;
  1626. }
  1627. return rc;
  1628. } //SetLogSize
  1629. /***LP DebugTrace - Single-step an AML instruction
  1630. *
  1631. * ENTRY
  1632. * pArg -> argument type entry
  1633. * pszArg -> argument string
  1634. * dwArgNum - argument number
  1635. * dwNonSWArgs - number of non-switch arguments
  1636. *
  1637. * EXIT-SUCCESS
  1638. * returns DBGERR_NONE
  1639. * EXIT-FAILURE
  1640. * returns negative error code
  1641. */
  1642. LONG LOCAL DebugTrace(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1643. ULONG dwNonSWArgs)
  1644. {
  1645. LONG rc;
  1646. DEREF(pArg);
  1647. DEREF(dwArgNum);
  1648. DEREF(dwNonSWArgs);
  1649. if (pszArg == NULL)
  1650. {
  1651. gDebugger.dwfDebugger |= DBGF_SINGLE_STEP;
  1652. rc = DBGERR_QUIT;
  1653. }
  1654. else
  1655. {
  1656. DBG_ERROR(("invalid trace command"));
  1657. rc = DBGERR_INVALID_CMD;
  1658. }
  1659. return rc;
  1660. } //DebugTrace
  1661. BOOLEAN fRunningMethod = FALSE;
  1662. /***LP DebugRunMethod - Run Method
  1663. *
  1664. * ENTRY
  1665. * pArg -> argument type entry
  1666. * pszArg -> argument string
  1667. * dwArgNum - argument number
  1668. * dwNonSWArgs - number of non-switch arguments
  1669. *
  1670. * EXIT-SUCCESS
  1671. * returns DBGERR_NONE
  1672. * EXIT-FAILURE
  1673. * returns negative error code
  1674. */
  1675. LONG LOCAL DebugRunMethod(PCMDARG pArg, PSZ pszArg, ULONG dwArgNum,
  1676. ULONG dwNonSWArgs)
  1677. {
  1678. LONG rc = DBGERR_NONE;
  1679. static int icArgs = -1;
  1680. static PNSOBJ pns = NULL;
  1681. static OBJDATA Args[MAX_NUM_ARGS] = {0};
  1682. static OBJDATA Result;
  1683. DEREF(pArg);
  1684. DEREF(dwArgNum);
  1685. DEREF(dwNonSWArgs);
  1686. if (fRunningMethod)
  1687. {
  1688. DBG_ERROR(("Cannot run method while previous method is still pending"));
  1689. rc = DBGERR_CMD_FAILED;
  1690. }
  1691. else if (pszArg != NULL)
  1692. {
  1693. if (icArgs == -1)
  1694. {
  1695. PUCHAR pbAddr;
  1696. if ((rc = DebugExpr(pszArg, (PULONG_PTR)&pbAddr, NULL, &pns, NULL))
  1697. == DBGERR_NONE)
  1698. {
  1699. if (pns != NULL)
  1700. {
  1701. pns = GetBaseObject(pns);
  1702. icArgs = 0;
  1703. }
  1704. else
  1705. {
  1706. DBG_ERROR(("invalid method or method not found"));
  1707. rc = DBGERR_CMD_FAILED;
  1708. }
  1709. }
  1710. }
  1711. else if (icArgs < MAX_NUM_ARGS)
  1712. {
  1713. MEMZERO(&Args[icArgs], sizeof(OBJDATA));
  1714. if (IsNumber(pszArg, 0, &Args[icArgs].uipDataValue))
  1715. {
  1716. Args[icArgs].dwDataType = OBJTYPE_INTDATA;
  1717. icArgs++;
  1718. }
  1719. else
  1720. {
  1721. DBG_ERROR(("invalid argument %s (can only be integer)",
  1722. pszArg));
  1723. rc = DBGERR_INVALID_CMD;
  1724. }
  1725. }
  1726. else
  1727. {
  1728. DBG_ERROR(("too many arguments"));
  1729. rc = DBGERR_INVALID_CMD;
  1730. }
  1731. }
  1732. else if (icArgs >= 0)
  1733. {
  1734. NTSTATUS rcAMLI;
  1735. MEMZERO(&Result, sizeof(OBJDATA));
  1736. fRunningMethod = TRUE;
  1737. if ((rcAMLI = AsyncEvalObject(pns, &Result, icArgs, Args,
  1738. RunMethodCallBack, NULL, TRUE)) !=
  1739. AMLISTA_PENDING)
  1740. {
  1741. RunMethodCallBack(pns, rcAMLI, &Result, NULL);
  1742. if (rcAMLI != STATUS_SUCCESS)
  1743. {
  1744. rc = DBGERR_CMD_FAILED;
  1745. }
  1746. }
  1747. else
  1748. {
  1749. PRINTF("\n%s returned PENDING\n", GetObjectPath(pns));
  1750. }
  1751. icArgs = -1;
  1752. }
  1753. else
  1754. {
  1755. DBG_ERROR(("invalid run command"));
  1756. rc = DBGERR_CMD_FAILED;
  1757. }
  1758. if (rc != DBGERR_NONE)
  1759. {
  1760. icArgs = -1;
  1761. }
  1762. return rc;
  1763. } //DebugRunMethod
  1764. /***LP RunMethodCallBack - RunMethod completion callback
  1765. *
  1766. * ENTRY
  1767. * pns -> method object
  1768. * rc - execution status code
  1769. * pdata -> result data
  1770. * pvContext -> context data
  1771. *
  1772. * EXIT
  1773. * None
  1774. */
  1775. VOID EXPORT RunMethodCallBack(PNSOBJ pns, NTSTATUS rc, POBJDATA pdata,
  1776. PVOID pvContext)
  1777. {
  1778. DEREF(pvContext);
  1779. if (rc == STATUS_SUCCESS)
  1780. {
  1781. PRINTF("\n%s completed successfully with object data:\n",
  1782. GetObjectPath(pns));
  1783. DumpObject(pdata, NULL, 0);
  1784. }
  1785. else
  1786. {
  1787. PSZ pszErr;
  1788. AMLIGetLastError(&pszErr);
  1789. PRINTF("\n%s failed with the following error:\n%s\n",
  1790. GetObjectPath(pns), pszErr);
  1791. }
  1792. fRunningMethod = FALSE;
  1793. } //RunMethodCallBack
  1794. /***LP AddObjSymbol - Add object to symbol table
  1795. *
  1796. * ENTRY
  1797. * pbOp -> code address
  1798. * pnsObj -> object
  1799. *
  1800. * EXIT
  1801. * None
  1802. */
  1803. VOID LOCAL AddObjSymbol(PUCHAR pbOp, PNSOBJ pnsObj)
  1804. {
  1805. POBJSYM pos, p;
  1806. if ((pos = NEWSYOBJ(sizeof(OBJSYM))) == NULL)
  1807. {
  1808. AMLI_ERROR(("AddObjSymbol: failed to allocate symbol buffer"));
  1809. }
  1810. else
  1811. {
  1812. MEMZERO(pos, sizeof(OBJSYM));
  1813. pos->pbOp = pbOp;
  1814. pos->pnsObj = pnsObj;
  1815. if (gDebugger.posSymbolList == NULL)
  1816. {
  1817. gDebugger.posSymbolList = pos;
  1818. }
  1819. else if (pbOp < gDebugger.posSymbolList->pbOp)
  1820. {
  1821. pos->posNext = gDebugger.posSymbolList;
  1822. gDebugger.posSymbolList->posPrev = pos;
  1823. gDebugger.posSymbolList = pos;
  1824. }
  1825. else
  1826. {
  1827. for (p = gDebugger.posSymbolList; p != NULL; p = p->posNext)
  1828. {
  1829. if (pbOp < p->pbOp)
  1830. {
  1831. pos->posNext = p;
  1832. pos->posPrev = p->posPrev;
  1833. p->posPrev->posNext = pos;
  1834. p->posPrev = pos;
  1835. break;
  1836. }
  1837. else if (p->posNext == NULL)
  1838. {
  1839. pos->posPrev = p;
  1840. p->posNext = pos;
  1841. break;
  1842. }
  1843. }
  1844. }
  1845. }
  1846. } //AddObjSymbol
  1847. /***LP FreeSymList - Free all object symbols
  1848. *
  1849. * ENTRY
  1850. * None
  1851. *
  1852. * EXIT
  1853. * None
  1854. */
  1855. VOID LOCAL FreeSymList(VOID)
  1856. {
  1857. POBJSYM pos, posNext;
  1858. for (pos = gDebugger.posSymbolList; pos != NULL; pos = posNext)
  1859. {
  1860. posNext = pos->posNext;
  1861. FREESYOBJ(pos);
  1862. }
  1863. } //FreeSymList
  1864. /***LP FindObjSymbol - Find nearest object with given address
  1865. *
  1866. * ENTRY
  1867. * pbOp - address
  1868. * ppns -> to hold the nearest object
  1869. * pdwOffset - to hold offset from the nearest object
  1870. *
  1871. * EXIT-SUCCESS
  1872. * returns TRUE - found a nearest object
  1873. * EXIT-FAILURE
  1874. * returns FALSE - cannot found nearest object
  1875. */
  1876. BOOLEAN LOCAL FindObjSymbol(PUCHAR pbOp, PPNSOBJ ppns, PULONG pdwOffset)
  1877. {
  1878. BOOLEAN rc = FALSE;
  1879. POBJSYM pos;
  1880. for (pos = gDebugger.posSymbolList; pos != NULL; pos = pos->posNext)
  1881. {
  1882. if (pbOp <= pos->pbOp)
  1883. {
  1884. if ((pbOp < pos->pbOp) && (pos->posPrev != NULL))
  1885. pos = pos->posPrev;
  1886. if (pbOp >= pos->pbOp)
  1887. {
  1888. *ppns = pos->pnsObj;
  1889. *pdwOffset = (ULONG)(pbOp - pos->pbOp);
  1890. rc = TRUE;
  1891. }
  1892. break;
  1893. }
  1894. }
  1895. return rc;
  1896. } //FindObjSymbol
  1897. /***LP CheckBP - Check given address is in the breakpoint list
  1898. *
  1899. * ENTRY
  1900. * pbOp - address
  1901. *
  1902. * EXIT-SUCCESS
  1903. * returns breakpoint number
  1904. * EXIT-FAILURE
  1905. * returns -1
  1906. */
  1907. int LOCAL CheckBP(PUCHAR pbOp)
  1908. {
  1909. int i;
  1910. for (i = 0; i < MAX_BRK_PTS; ++i)
  1911. {
  1912. if (pbOp == gDebugger.BrkPts[i].pbBrkPt)
  1913. {
  1914. break;
  1915. }
  1916. }
  1917. if ((i == MAX_BRK_PTS) ||
  1918. !(gDebugger.BrkPts[i].dwfBrkPt & BPF_ENABLED))
  1919. {
  1920. i = -1;
  1921. }
  1922. return i;
  1923. } //CheckBP
  1924. /***LP PrintfBuffData - Print buffer data
  1925. *
  1926. * ENTRY
  1927. * pb -> buffer
  1928. * dwLen - length of buffer
  1929. *
  1930. * EXIT
  1931. * None
  1932. */
  1933. VOID LOCAL PrintBuffData(PUCHAR pb, ULONG dwLen)
  1934. {
  1935. TRACENAME("PRINTBUFFDATA")
  1936. int i, j;
  1937. ENTER(4, ("PrintBuffData(pb=%x,Len=%d)\n", pb, dwLen));
  1938. PRINTF("{");
  1939. for (i = j = 0; i < (int)dwLen; ++i)
  1940. {
  1941. if (j == 0)
  1942. PRINTF("\n\t0x%02x", pb[i]);
  1943. else
  1944. PRINTF(",0x%02x", pb[i]);
  1945. j++;
  1946. if (j >= 14)
  1947. j = 0;
  1948. }
  1949. PRINTF("}");
  1950. EXIT(4, ("PrintBuffData!\n"));
  1951. } //PrintBuffData
  1952. /***LP PrintIndent - Print indentation
  1953. *
  1954. * ENTRY
  1955. * pctxt -> CTXT
  1956. *
  1957. * EXIT
  1958. * None
  1959. */
  1960. VOID LOCAL PrintIndent(PCTXT pctxt)
  1961. {
  1962. TRACENAME("PRINTINDENT")
  1963. int i;
  1964. ENTER(4, ("PrintIndent(pctxt=%x,pbOp=%x)\n", pctxt, pctxt->pbOp));
  1965. PRINTF("\n%I64x: ", (ULONG64)pctxt->pbOp);
  1966. for (i = 0; i < gDebugger.iPrintLevel; ++i)
  1967. {
  1968. PRINTF("| ");
  1969. }
  1970. EXIT(4, ("PrintIndent!\n"));
  1971. } //PrintIndent
  1972. /***LP PrintObject - Print object content
  1973. *
  1974. * ENTRY
  1975. * pdata -> object
  1976. *
  1977. * EXIT
  1978. * None
  1979. */
  1980. VOID LOCAL PrintObject(POBJDATA pdata)
  1981. {
  1982. TRACENAME("PRINTOBJECT")
  1983. int i;
  1984. ENTER(4, ("PrintObject(pdata=%x)\n", pdata));
  1985. switch (pdata->dwDataType)
  1986. {
  1987. case OBJTYPE_INTDATA:
  1988. PRINTF("0x%p", pdata->uipDataValue);
  1989. break;
  1990. case OBJTYPE_STRDATA:
  1991. PRINTF("\"%s\"", pdata->pbDataBuff);
  1992. break;
  1993. case OBJTYPE_BUFFDATA:
  1994. PRINTF("Buffer(0x%x)", pdata->dwDataLen);
  1995. PrintBuffData(pdata->pbDataBuff, pdata->dwDataLen);
  1996. break;
  1997. case OBJTYPE_PKGDATA:
  1998. PRINTF("Package(%d){",
  1999. ((PPACKAGEOBJ)pdata->pbDataBuff)->dwcElements);
  2000. for (i = 0;
  2001. i < (int)((PPACKAGEOBJ)pdata->pbDataBuff)->dwcElements;
  2002. ++i)
  2003. {
  2004. PRINTF("\n\t");
  2005. PrintObject(&((PPACKAGEOBJ)pdata->pbDataBuff)->adata[i]);
  2006. if (i + 1 < (int)((PPACKAGEOBJ)pdata->pbDataBuff)->dwcElements)
  2007. PRINTF(",");
  2008. }
  2009. PRINTF("}");
  2010. break;
  2011. default:
  2012. PRINTF("<Obj=%p,Type=%s,Value=0x%p,Buff=%p,Len=%d>",
  2013. pdata, GetObjectTypeName(pdata->dwDataType),
  2014. pdata->uipDataValue, pdata->pbDataBuff, pdata->dwDataLen);
  2015. }
  2016. EXIT(4, ("PrintObject!\n"));
  2017. } //PrintObject
  2018. /***LP LogEvent - Log an event in the log buffer
  2019. *
  2020. * ENTRY
  2021. * dwEvent - event type
  2022. * uipData1 - log data 1
  2023. * uipData2 - log data 2
  2024. * uipData3 - log data 3
  2025. * uipData4 - log data 4
  2026. * uipData5 - log data 5
  2027. * uipData6 - log data 6
  2028. * uipData7 - log data 7
  2029. *
  2030. * EXIT
  2031. * None
  2032. */
  2033. VOID LOCAL LogEvent(ULONG dwEvent, ULONG_PTR uipData1, ULONG_PTR uipData2,
  2034. ULONG_PTR uipData3, ULONG_PTR uipData4, ULONG_PTR uipData5,
  2035. ULONG_PTR uipData6, ULONG_PTR uipData7)
  2036. {
  2037. if ((gDebugger.dwfDebugger & DBGF_LOGEVENT_ON) &&
  2038. (gDebugger.pEventLog != NULL))
  2039. {
  2040. ULONG i = gDebugger.dwLogIndex;
  2041. gDebugger.pEventLog[i].ullTime = KeQueryInterruptTime();
  2042. gDebugger.pEventLog[i].dwEvent = dwEvent;
  2043. gDebugger.pEventLog[i].uipData1 = uipData1;
  2044. gDebugger.pEventLog[i].uipData2 = uipData2;
  2045. gDebugger.pEventLog[i].uipData3 = uipData3;
  2046. gDebugger.pEventLog[i].uipData4 = uipData4;
  2047. gDebugger.pEventLog[i].uipData5 = uipData5;
  2048. gDebugger.pEventLog[i].uipData6 = uipData6;
  2049. gDebugger.pEventLog[i].uipData7 = uipData7;
  2050. gDebugger.dwLogIndex++;
  2051. if (gDebugger.dwLogIndex >= gDebugger.dwLogSize)
  2052. {
  2053. gDebugger.dwLogIndex = 0;
  2054. }
  2055. }
  2056. } //LogEvent;
  2057. /***LP LogSchedEvent - Log a scheduler event in the log buffer
  2058. *
  2059. * ENTRY
  2060. * dwEvent - event type
  2061. * uipData1 - log data 1
  2062. * uipData2 - log data 2
  2063. * uipData3 - log data 3
  2064. *
  2065. * EXIT
  2066. * None
  2067. */
  2068. VOID LOCAL LogSchedEvent(ULONG dwEvent, ULONG_PTR uipData1, ULONG_PTR uipData2,
  2069. ULONG_PTR uipData3)
  2070. {
  2071. if ((gDebugger.dwfDebugger & DBGF_LOGEVENT_ON) &&
  2072. (gDebugger.pEventLog != NULL))
  2073. {
  2074. ULONG i = gDebugger.dwLogIndex;
  2075. gDebugger.pEventLog[i].ullTime = KeQueryInterruptTime();
  2076. gDebugger.pEventLog[i].dwEvent = dwEvent;
  2077. gDebugger.pEventLog[i].uipData1 = (ULONG_PTR)KeGetCurrentThread();
  2078. gDebugger.pEventLog[i].uipData2 = (ULONG_PTR)gReadyQueue.pkthCurrent;
  2079. gDebugger.pEventLog[i].uipData3 = (ULONG_PTR)gReadyQueue.pctxtCurrent;
  2080. gDebugger.pEventLog[i].uipData4 = (ULONG_PTR)gReadyQueue.dwfCtxtQ;
  2081. gDebugger.pEventLog[i].uipData5 = uipData1;
  2082. gDebugger.pEventLog[i].uipData6 = uipData2;
  2083. gDebugger.pEventLog[i].uipData7 = uipData3;
  2084. gDebugger.dwLogIndex++;
  2085. if (gDebugger.dwLogIndex >= gDebugger.dwLogSize)
  2086. {
  2087. gDebugger.dwLogIndex = 0;
  2088. }
  2089. }
  2090. } //LogSchedEvent
  2091. /***LP LogError - Log error code and message
  2092. *
  2093. * ENTRY
  2094. * rcErr - error code
  2095. *
  2096. * EXIT
  2097. * None
  2098. */
  2099. VOID LOCAL LogError(NTSTATUS rcErr)
  2100. {
  2101. static struct _ErrMsg
  2102. {
  2103. NTSTATUS rcErr;
  2104. PSZ pszMsg;
  2105. } ErrMsgTable[] =
  2106. {
  2107. AMLIERR_NONE, "Success",
  2108. AMLIERR_OUT_OF_MEM, "Failed to allocate memory",
  2109. AMLIERR_INVALID_OPCODE, "Invalid AML Opcode",
  2110. AMLIERR_NAME_TOO_LONG, "Object name is too long",
  2111. AMLIERR_ASSERT_FAILED, "Assertion failure",
  2112. AMLIERR_INVALID_NAME, "Invalid object name",
  2113. AMLIERR_OBJ_NOT_FOUND, "Object not found",
  2114. AMLIERR_OBJ_ALREADY_EXIST, "Object already exist",
  2115. AMLIERR_INDEX_TOO_BIG, "Index is too big",
  2116. AMLIERR_ARG_NOT_EXIST, "Argument does not exist",
  2117. AMLIERR_FATAL, "Fatal error",
  2118. AMLIERR_INVALID_SUPERNAME, "Invalid SuperName",
  2119. AMLIERR_UNEXPECTED_ARGTYPE, "Unexpected argument type",
  2120. AMLIERR_UNEXPECTED_OBJTYPE, "Unexpected object type",
  2121. AMLIERR_UNEXPECTED_TARGETTYPE, "Unexpected target type",
  2122. AMLIERR_INCORRECT_NUMARG, "Incorrect number of arguments",
  2123. AMLIERR_FAILED_ADDR_XLATE, "Failed address translation",
  2124. AMLIERR_INVALID_EVENTTYPE, "Invalid event type",
  2125. AMLIERR_REGHANDLER_FAILED, "Failed to register event handler",
  2126. AMLIERR_HANDLER_EXIST, "Event handler already exist",
  2127. AMLIERR_INVALID_DATA, "Invalid data",
  2128. AMLIERR_INVALID_REGIONSPACE, "Invalid RegionSpace",
  2129. AMLIERR_INVALID_ACCSIZE, "Invalid AccessSize",
  2130. AMLIERR_INVALID_TABLE, "Invalid table",
  2131. AMLIERR_ACQUIREGL_FAILED, "Failed to acquire global lock",
  2132. AMLIERR_ALREADY_INITIALIZED, "AML Interpreter is already initialized",
  2133. AMLIERR_NOT_INITIALIZED, "AML Interpreter is not initialized",
  2134. AMLIERR_MUTEX_INVALID_LEVEL, "Invalid mutex sync level",
  2135. AMLIERR_MUTEX_NOT_OWNED, "Mutex object has no owner",
  2136. AMLIERR_MUTEX_NOT_OWNER, "Mutex object is owned by a different owner",
  2137. AMLIERR_RS_ACCESS, "RegionSpace handler error",
  2138. AMLIERR_STACK_OVERFLOW, "AML Stack overflow",
  2139. AMLIERR_INVALID_BUFFSIZE, "Invalid buffer size",
  2140. AMLIERR_BUFF_TOOSMALL, "Buffer is too small",
  2141. AMLIERR_NOTIFY_FAILED, "Notify handler failed",
  2142. 0, NULL
  2143. };
  2144. int i;
  2145. gDebugger.rcLastError = rcErr;
  2146. for (i = 0; ErrMsgTable[i].pszMsg != NULL; ++i)
  2147. {
  2148. if (rcErr == ErrMsgTable[i].rcErr)
  2149. {
  2150. sprintf(gDebugger.szLastError, MODNAME "_ERROR(%08x): %s",
  2151. rcErr, ErrMsgTable[i].pszMsg);
  2152. break;
  2153. }
  2154. }
  2155. ASSERT(ErrMsgTable[i].pszMsg != NULL);
  2156. } //LogError
  2157. /***LP CatError - Concat to error buffer
  2158. *
  2159. * ENTRY
  2160. * pszFormat -> message format string
  2161. * ... - variable parameters according to format string
  2162. *
  2163. * EXIT
  2164. * None
  2165. */
  2166. VOID LOCAL CatError(PSZ pszFormat, ...)
  2167. {
  2168. va_list marker;
  2169. STRCAT(gDebugger.szLastError, "\n");
  2170. va_start(marker, pszFormat);
  2171. if(_vsnprintf(&gDebugger.szLastError[STRLEN(gDebugger.szLastError)],
  2172. sizeof(gDebugger.szLastError) - STRLEN(gDebugger.szLastError),
  2173. pszFormat, marker) == -1)
  2174. {
  2175. gDebugger.szLastError[sizeof(gDebugger.szLastError) - 1] = '\0';
  2176. }
  2177. va_end(marker);
  2178. ConPrintf(gDebugger.szLastError);
  2179. ConPrintf("\n");
  2180. if (gDebugger.dwfDebugger & DBGF_ERRBREAK_ON)
  2181. {
  2182. AMLIDebugger(FALSE);
  2183. }
  2184. } //CatError
  2185. /***LP ConPrintf - Console printf
  2186. *
  2187. * ENTRY
  2188. * pszFormat -> format string
  2189. * ... - variable parameters according to format string
  2190. *
  2191. * EXIT
  2192. * None
  2193. */
  2194. VOID LOCAL ConPrintf(PSZ pszFormat, ...)
  2195. {
  2196. static char szBuff[1024];
  2197. va_list marker;
  2198. va_start(marker, pszFormat);
  2199. vsprintf(szBuff, pszFormat, marker);
  2200. va_end(marker);
  2201. if (gDebugger.hConMessage.pfnHandler != NULL) {
  2202. ((PFNCM)gDebugger.hConMessage.pfnHandler)(
  2203. szBuff,
  2204. gDebugger.hConMessage.uipParam
  2205. );
  2206. } else {
  2207. _PRINTF(szBuff);
  2208. }
  2209. } //ConPrintf
  2210. /***LP ConPrompt - Console prompted input
  2211. *
  2212. * ENTRY
  2213. * pszPrompt -> prompt string
  2214. * pszBuff -> input buffer
  2215. * dwcbBuff - buffer size
  2216. */
  2217. VOID LOCAL ConPrompt(PSZ pszPrompt, PSZ pszBuff, ULONG dwcbBuff)
  2218. {
  2219. if(gDebugger.dwfDebugger & ~DBGF_DEBUG_SPEW_ON)
  2220. {
  2221. CheckAndEnableDebugSpew(TRUE);
  2222. }
  2223. if (gDebugger.hConPrompt.pfnHandler != NULL)
  2224. {
  2225. ((PFNCP)gDebugger.hConPrompt.pfnHandler)(pszPrompt, pszBuff, dwcbBuff,
  2226. gDebugger.hConPrompt.uipParam);
  2227. }
  2228. else
  2229. {
  2230. DbgPrompt(pszPrompt, pszBuff, dwcbBuff);
  2231. }
  2232. } //ConPrompt
  2233. /***LP CheckAndEnableDebugSpew - Enable debug spew if it is not already turned on.
  2234. *
  2235. * ENTRY
  2236. * BOOLEAN fEnable - Enable iff TRUE.
  2237. *
  2238. * EXIT
  2239. * BOOLEAN - TRUE on success.
  2240. */
  2241. BOOLEAN LOCAL CheckAndEnableDebugSpew(BOOLEAN fEnable)
  2242. {
  2243. BOOLEAN bRet = FALSE;
  2244. if(KeGetCurrentIrql() < DISPATCH_LEVEL)
  2245. {
  2246. if(fEnable)
  2247. {
  2248. gDebugger.dwfDebugger |= DBGF_DEBUG_SPEW_ON;
  2249. DbgSetDebugFilterState( DPFLTR_AMLI_ID, -1, TRUE);
  2250. }
  2251. else
  2252. {
  2253. DbgSetDebugFilterState( DPFLTR_AMLI_ID, -1, FALSE);
  2254. gDebugger.dwfDebugger &= ~DBGF_DEBUG_SPEW_ON;
  2255. }
  2256. bRet = TRUE;
  2257. }
  2258. return bRet;
  2259. }
  2260. #endif //ifdef DEBUGGER
  2261. #ifdef DEBUG
  2262. /***LP DumpMemObjCounts - display memory object counts
  2263. *
  2264. * ENTRY
  2265. * None
  2266. *
  2267. * EXIT
  2268. * None
  2269. */
  2270. VOID LOCAL DumpMemObjCounts(VOID)
  2271. {
  2272. static char szFormat[] = "Number of %s = %d\n";
  2273. PRINTF("CurGlobalHeapSize=%d bytes\n", gdwGlobalHeapSize);
  2274. PRINTF("RefGlobalHeapSize=%d bytes\n", gdwGHeapSnapshot);
  2275. PRINTF("MaxLocalHeapSize =%d bytes\n", gdwLocalHeapMax);
  2276. PRINTF("MaxLocalStackSize=%d bytes\n", gdwLocalStackMax);
  2277. PRINTF(szFormat, "CtxtObj ", gdwcCTObjs);
  2278. PRINTF(szFormat, "HeapObj ", gdwcHPObjs);
  2279. PRINTF(szFormat, "SymbolObj ", gdwcSYObjs);
  2280. PRINTF(szFormat, "RSAccessObj ", gdwcRSObjs);
  2281. PRINTF(szFormat, "PassHookObj ", gdwcPHObjs);
  2282. PRINTF(szFormat, "DataObj ", gdwcODObjs);
  2283. PRINTF(szFormat, "NSObj ", gdwcNSObjs);
  2284. PRINTF(szFormat, "OwnerObj ", gdwcOOObjs);
  2285. PRINTF(szFormat, "BuffFieldObj ", gdwcBFObjs);
  2286. PRINTF(szFormat, "StrDataObj ", gdwcSDObjs);
  2287. PRINTF(szFormat, "BuffDataObj ", gdwcBDObjs);
  2288. PRINTF(szFormat, "PackageObj ", gdwcPKObjs);
  2289. PRINTF(szFormat, "FieldUnitObj ", gdwcFUObjs);
  2290. PRINTF(szFormat, "BankFieldObj ", gdwcKFObjs);
  2291. PRINTF(szFormat, "FieldObj ", gdwcFObjs);
  2292. PRINTF(szFormat, "IndexFieldObj", gdwcIFObjs);
  2293. PRINTF(szFormat, "OpRegion ", gdwcORObjs);
  2294. PRINTF(szFormat, "MutexObj ", gdwcMTObjs);
  2295. PRINTF(szFormat, "EventObj ", gdwcEVObjs);
  2296. PRINTF(szFormat, "MethodObj ", gdwcMEObjs);
  2297. PRINTF(szFormat, "PowerResObj ", gdwcPRObjs);
  2298. PRINTF(szFormat, "ProcessorObj ", gdwcPCObjs);
  2299. PRINTF(szFormat, "CtxtResObj ", gdwcCRObjs);
  2300. PRINTF(szFormat, "MiscObj ",
  2301. gdwcMemObjs - gdwcCTObjs - gdwcHPObjs - gdwcSYObjs - gdwcRSObjs -
  2302. gdwcPHObjs - gdwcCRObjs);
  2303. } //DumpMemObjCounts
  2304. #endif //ifdef DEBUG