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.

765 lines
24 KiB

  1. /*************************************************************************
  2. msodebug.h
  3. Owner: rickp
  4. Copyright (c) 1994 Microsoft Corporation
  5. Standard debugging definitions for the shared Office libraries.
  6. Includes asserts, tracing, and other cool stuff like that.
  7. *************************************************************************/
  8. #if !defined(MSODEBUG_H)
  9. #define MSODEBUG_H
  10. #if !defined(MSOSTD_H)
  11. #include <msostd.h>
  12. #endif
  13. #if MAC && !defined(__TYPES__)
  14. #include <macos\types.h>
  15. #endif
  16. #if defined(__cplusplus)
  17. extern "C" {
  18. #endif
  19. /*************************************************************************
  20. Random useful macros
  21. *************************************************************************/
  22. #if DEBUG
  23. #define Debug(e) e
  24. #define DebugOnly(e) e
  25. #define DebugElse(s, t) s
  26. #else
  27. #define Debug(e)
  28. #define DebugOnly(e)
  29. #define DebugElse(s, t) t
  30. #endif
  31. /****************************************************************************
  32. This enum contains the Debug "Messages" that are sent to the FDebugMessage
  33. Method
  34. ****************************************************************** JIMMUR **/
  35. enum
  36. {
  37. msodmWriteBe = 1, /* write out the BE record for this object */
  38. /* Here begin drawing only debug messages */
  39. msodmDgvRcvOfHsp = 2001,
  40. /* Ask a DGV for the bounding rectangle (if any) of an HSP.
  41. Assumes lParam is really a pointer to an MSODGDB, looks at the
  42. hsp field thereof and fills out the rcv field. */
  43. msodmDgsWriteBePvAnchor,
  44. /* Write out the BE record for a host allocated pvAnchor. */
  45. msodmDgsWriteBePvClient,
  46. /* Write out the BE record for any host allocated client data. */
  47. msodmDgvsAfterMouseInsert,
  48. /* Passed to IMsoDrawingViewSite after a shape is interactively
  49. inserted with the mouse. lParam is really the inserted HSP. */
  50. msodmDgvsAfterMarquee,
  51. /* Passed to IMsoDrawingViewSite after one drags out a rectangle
  52. with the pointer tool selecting zero or more shapes. */
  53. msodmIsNotMso96,
  54. /* Returns FALSE if the specified object is implemented by MSO96.DLL.
  55. Allows sleazy up-casts, for example, from IMsoDrawingView *
  56. to DGV *. */
  57. msodmGetHdesShape,
  58. /* Ask a DGVs for its m_hdesShape (in *(MSOHDES *)lParam). Returns
  59. FALSE if it filled out an HDES. */
  60. msodmGetHdesSelection,
  61. /* Ask a DGVs for its m_hdesSelection (in *(MSOHDES *)lParam).
  62. Returns FALSE if it filled out an HDES. */
  63. msodmDguiWriteBeForDgc,
  64. /* Ask a DGUI to write BEs for a DGC it allocated. */
  65. msodmDgsWriteBeTxid,
  66. /* Write out the BE record for the attached text of a shape. */
  67. msodmDgsWriteBePvAnchorUndo,
  68. /* Write out the BE record for a host anchor in the undo stack. */
  69. msodmDgvsDragDrop,
  70. /* Let the host know that I just did a drag-drop from this window. */
  71. };
  72. enum
  73. {
  74. msodmbtDoNotWriteObj = 0, // Do Not write out the object
  75. msodmbtWriteObj, // Do write out the object and
  76. // embedded pointers
  77. };
  78. enum
  79. {
  80. msocchBt = 20, // Maximum size of a Bt description String
  81. };
  82. /* Some debug messages need more arguments than fit through
  83. the arguments to FDebugMethod. For these there are various
  84. MSODMBfoo structs, usually defined near the objects they're passed
  85. to. */
  86. /****************************************************************************
  87. Interface debug routine
  88. ****************************************************************** JIMMUR **/
  89. #if DEBUG
  90. #define MSODEBUGMETHOD MSOMETHOD_(BOOL, FDebugMessage) (THIS_ HMSOINST hinst, \
  91. UINT message, WPARAM wParam, LPARAM lParam) PURE;
  92. #define MSODEBUGMETHODIMP MSOMETHODIMP_(BOOL) FDebugMessage (HMSOINST hinst, \
  93. UINT message, WPARAM wParam, LPARAM lParam); \
  94. static BOOL FCheckObject(LPVOID pv, int cb);
  95. #define MSOMACDEBUGMETHODIMP MSOMACPUB MSOMETHODIMP_(BOOL) FDebugMessage (HMSOINST hinst, \
  96. UINT message, WPARAM wParam, LPARAM lParam); \
  97. static BOOL FCheckObject(LPVOID pv, int cb);
  98. #define DEBUGMETHOD(cn,bt) STDMETHODIMP_(BOOL) cn::FDebugMessage \
  99. (HMSOINST hinst, UINT message, WPARAM wParam, LPARAM lParam) \
  100. { \
  101. if (msodmWriteBE == message) \
  102. { \
  103. return MsoFSaveBe(hinst,lParam,(void*)this,sizeof(cn),bt); \
  104. } \
  105. return FALSE; \
  106. }
  107. #else
  108. #define MSODEBUGMETHOD MSOMETHOD_(BOOL, FDebugMessage) (THIS_ HMSOINST hinst, \
  109. UINT message, WPARAM wParam, LPARAM lParam) PURE;
  110. #define MSODEBUGMETHODIMP MSOMETHODIMP_(BOOL) FDebugMessage (HMSOINST hinst, \
  111. UINT message, WPARAM wParam, LPARAM lParam);
  112. #define MSOMACDEBUGMETHODIMP MSOMACPUB MSOMETHODIMP_(BOOL) FDebugMessage (HMSOINST hinst, \
  113. UINT message, WPARAM wParam, LPARAM lParam);
  114. #define DEBUGMETHOD(cn,bt) STDMETHODIMP_(BOOL) cn::FDebugMessage (HMSOINST, \
  115. UINT, WPARAM, LPARAM) { return TRUE; }
  116. #endif
  117. /*************************************************************************
  118. Enabling/disabling debug options
  119. *************************************************************************/
  120. enum
  121. {
  122. msodcAsserts = 0, /* asserts enabled */
  123. msodcPushAsserts = 1, /* push asserts enabled */
  124. msodcMemoryFill = 2, /* memory fills enabled */
  125. msodcMemoryFillCheck = 3, /* check memory fills */
  126. msodcTrace = 4, /* trace output */
  127. msodcHeap = 5, /* heap checking */
  128. msodcMemLeakCheck = 6,
  129. msodcMemTrace = 7, /* memory allocation trace */
  130. msodcGdiNoBatch = 8, /* don't batch GDI calls */
  131. msodcShakeMem = 9, /* shake memory on allocations */
  132. msodcReports = 10, /* report output enabled */
  133. msodcMsgTrace = 11, /* WLM message trace - MAC only */
  134. msodcWlmValidate = 12, /* WLM parameter validation - MAC only */
  135. msodcGdiNoExcep = 13, /* Don't call GetObjectType for debug */
  136. msodcDisplaySlowTests = 14, /* Do slow (O(n^2) and worse) Drawing debug checks */
  137. msodcDisplayAbortOften = 15, /* Check for aborting redraw really often. */
  138. msodcDisplayAbortNever = 16, /* Don't abort redraw */
  139. msodcPurgedMaxSmall = 17,
  140. msodcSpare18 = 18, /* USE ME */
  141. msodcSpare19 = 19, /* USE ME */
  142. msodcSpare20 = 20, /* USE ME */
  143. msodcSpare21 = 21, /* USE ME */
  144. msodcSpare22 = 22, /* USE ME */
  145. msodcMax = 23,
  146. };
  147. /* Enables/disables various office debug checks. dc is the check to
  148. change, fEnabled is TRUE if the check should be enabled, FALSE
  149. if disabled */
  150. #if DEBUG
  151. extern MSOPUBDATA BYTE msovmpdcfDisabled[msodcMax];
  152. MSOAPI_(BOOL) MsoEnableDebugCheck(int dc, BOOL fEnabled);
  153. #if MAC && !OFFICE_BUILD
  154. // LATER: work-around linker bug that causes bad toc for exported data
  155. MSOAPI_(BOOL) MsoFGetDebugCheck(int dc);
  156. #else
  157. #define MsoFGetDebugCheck(dc) (!msovmpdcfDisabled[(dc)])
  158. #endif
  159. #else
  160. #define MsoEnableDebugCheck(dc, fEnabled) (FALSE)
  161. #define MsoFGetDebugCheck(dc) (FALSE)
  162. #endif
  163. /* Assert Output types */
  164. enum
  165. {
  166. msoiasoAssert,
  167. msoiasoTrace,
  168. msoiasoReport,
  169. msoiasoMax
  170. };
  171. /* Returns the current debug output settings. Note that these are
  172. macros referencing a DLL global variable. */
  173. #define MsoFAssertsEnabled() (MsoFGetDebugCheck(msodcAsserts))
  174. #define MsoFTraceEnabled() (MsoFGetDebugCheck(msodcTrace))
  175. #define MsoFReportsEnabled() (MsoFGetDebugCheck(msodcReports))
  176. enum
  177. {
  178. msoaoDebugger = 0x01, /* output to debugger */
  179. msoaoFile = 0x02, /* output goes to file */
  180. msoaoMsgBox = 0x04, /* output displayed in message box (no Traces) */
  181. msoaoPort = 0x08, /* output sent to serial port */
  182. msoaoMappedFile = 0x10, /* output recorded in memory mapped file */
  183. msoaoDebugBreak = 0x20, /* msoaoDebugger breaks into the debugger */
  184. msoaoAppend = 0x8000, /* output appended to existing file */
  185. };
  186. /* Sets the destination of assert output */
  187. #if DEBUG
  188. MSOAPI_(int) MsoSetAssertOutput(int iaso, int ao);
  189. #else
  190. #define MsoSetAssertOutput(iaso, ao) (0)
  191. #endif
  192. /* Returns the current assert output destination. */
  193. #if DEBUG
  194. MSOAPI_(int) MsoGetAssertOutput(int iaso);
  195. #else
  196. #define MsoGetAssertOutput(iaso) (0)
  197. #endif
  198. /* Sets the name of the file that the assert information gets written
  199. to, if file output is enabled using msoaoFile */
  200. #if DEBUG
  201. MSOAPI_(void) MsoSetAssertOutputFile(int iaso, const CHAR* szFile);
  202. #else
  203. #define MsoSetAssertOutputFile(iaso, szFile) (0)
  204. #endif
  205. /* Returns the current name of the file that we're writing assert
  206. output to. The name is saved in the buffer szFile, which must be
  207. cchMax characters long. Returns the actual length of the string
  208. returned. */
  209. #if DEBUG
  210. MSOAPIXX_(int) MsoGetAssertOutputFile(int iaso, CHAR* szFile, int cchMax);
  211. #else
  212. #define MsoGetAssertOutputFile(iaso, szFile, cchMax) (0)
  213. #endif
  214. /*************************************************************************
  215. Debugger breaks
  216. *************************************************************************/
  217. /* Breaks into the debugger. Works (more or less) on all supported
  218. systems. */
  219. #if X86
  220. #define MsoDebugBreakInline() {__asm int 3}
  221. #elif MAC
  222. #define MsoDebugBreakInline() Debugger()
  223. #else
  224. #define MsoDebugBreakInline() \
  225. { \
  226. __try { DebugBreak(); } \
  227. __except(EXCEPTION_EXECUTE_HANDLER) { OutputDebugStringA("DebugBreak"); } \
  228. }
  229. #endif
  230. /* A version of debug break that you can actually call, instead of the
  231. above inline weirdness we use in most cases. Can therefore be used in
  232. expressions. Returns 0 */
  233. #if DEBUG
  234. MSOAPI_(int) MsoDebugBreak(void);
  235. #else
  236. #define MsoDebugBreak() (0)
  237. #endif
  238. /*************************************************************************
  239. Assertion failures
  240. *************************************************************************/
  241. #if !defined(MSO_NO_ASSERTS)
  242. /* Displays the assert message, including flushing any assert stack.
  243. szFile and li are the filename and line number of the failure,
  244. and szMsg is an optional message to display with the assert.
  245. Returns FALSE if the caller should break into the debugger. */
  246. #if DEBUG
  247. MSOAPI_(BOOL) MsoFAssert(const CHAR* szFile, int li, const CHAR* szMsg);
  248. #else
  249. #define MsoFAssert(szFile, li, szMsg) (TRUE)
  250. #endif
  251. /* Same as MsoFAssert above, except an optional title string can be
  252. displayed. */
  253. #if DEBUG
  254. MSOAPI_(BOOL) MsoFAssertTitle(const CHAR* szTitle,
  255. const CHAR* szFile, int li, const CHAR* szMsg);
  256. #else
  257. #define MsoFAssertTitle(szTitle, szFile, li, szMsg) (TRUE)
  258. #endif
  259. /* Same as MsoFAssertTitle above, except you can pass in your own
  260. MessageBox flags */
  261. #if DEBUG
  262. MSOAPIXX_(BOOL) MsoFAssertTitleMb(const CHAR* szTitle,
  263. const CHAR* szFile, int li, const CHAR* szMsg, UINT mb);
  264. #else
  265. #define MsoFAssertTitleMb(szTitle, szFile, li, szMsg, mb) (TRUE)
  266. #endif
  267. /* Same as MsoFAssertTitleMb above, except you can pass in your own
  268. assert output type */
  269. #if DEBUG
  270. MSOAPI_(BOOL) MsoFAssertTitleAsoMb(int iaso, const CHAR* szTitle,
  271. const CHAR* szFile, int li, const CHAR* szMsg, UINT mb);
  272. #else
  273. #define MsoFAssertTitleAsoMb(iaso, szTitle, szFile, li, szMsg, mb) (TRUE)
  274. #endif
  275. /* To save space used by debug strings, you must declare the assert data
  276. in any file that uses asserts */
  277. #if DEBUG
  278. #define AssertData static const CHAR vszAssertFile[] = __FILE__;
  279. #else
  280. #define AssertData
  281. #endif
  282. /* The actual guts of the assert. if the flag f is FALSE, then we kick
  283. of the assertion failure, displaying the optional message szMsg along
  284. with the filename and line number of the failure */
  285. #if !DEBUG
  286. #define AssertMsg(f, szMsg)
  287. #define AssertMsgInline(f, szMsg)
  288. #define AssertMsgTemplate(f, szMsg)
  289. #else
  290. #define AssertMsg(f, szMsg) \
  291. do { \
  292. if (MsoFAssertsEnabled() && !(f) && \
  293. !MsoFAssert(vszAssertFile, __LINE__, (const CHAR*)(szMsg))) \
  294. MsoDebugBreakInline(); \
  295. } while (0)
  296. #define AssertMsgInline(f, szMsg) \
  297. do { \
  298. if (MsoFAssertsEnabled() && !(f) && \
  299. !MsoFAssert(__FILE__, __LINE__, (const CHAR*)(szMsg))) \
  300. MsoDebugBreakInline(); \
  301. } while (0)
  302. // Template inlines don't like the inline __asm for some reason
  303. #define AssertMsgTemplate(f, szMsg) \
  304. do { \
  305. if (MsoFAssertsEnabled() && !(f) && \
  306. !MsoFAssert(__FILE__, __LINE__, (const CHAR*)(szMsg))) \
  307. MsoDebugBreak(); \
  308. } while (0)
  309. #endif
  310. /* Tells if the Office is currently displaying an alert message box */
  311. #if !DEBUG
  312. #define MsoFInAssert() (FALSE)
  313. #else
  314. MSOAPI_(BOOL) MsoFInAssert(void);
  315. #endif
  316. /* Random compatability versions of the assert macros */
  317. #if 0
  318. #define VSZASSERT AssertData
  319. #if MSO_ASSERT_EXP
  320. #define Assert(f) AssertMsg((f), #f)
  321. #define AssertInline(f) AssertMsgInline((f), #f)
  322. #define AssertTemplate(f) AssertMsgTemplate((f), #f)
  323. #else
  324. #define Assert(f) AssertMsg((f), NULL)
  325. #define AssertInline(f) AssertMsgInline((f), NULL)
  326. #define AssertTemplate(f) AssertMsgTemplate((f), NULL)
  327. #endif
  328. #define AssertExp(f) AssertMsg((f), #f)
  329. #define AssertSz(f, szMsg) AssertMsg((f), szMsg)
  330. #endif
  331. /*************************************************************************
  332. Verification failures
  333. *************************************************************************/
  334. /* Like Assert, except the test is still made in the ship version
  335. of the application. Especially useful for tests that have
  336. required side-effects. */
  337. #if !DEBUG
  338. #define VerifyMsg(f, szMsg) (f)
  339. #define VerifyMsgInline(f, szMsg) (f)
  340. #else
  341. #define VerifyMsg(f, szMsg) \
  342. do { \
  343. if (!(f) && MsoFAssertsEnabled() && \
  344. !MsoFAssert(vszAssertFile, __LINE__, (const CHAR*)(szMsg))) \
  345. MsoDebugBreakInline(); \
  346. } while (0)
  347. #define VerifyMsgInline(f, szMsg) \
  348. do { \
  349. if (!(f) && MsoFAssertsEnabled() && \
  350. !MsoFAssert(__FILE__, __LINE__, (const CHAR*)(szMsg))) \
  351. MsoDebugBreakInline(); \
  352. } while (0)
  353. #endif
  354. #if MSO_ASSERT_EXP
  355. #define Verify(f) VerifyMsg((f), #f)
  356. #else
  357. #define Verify(f) VerifyMsg((f), NULL)
  358. #endif
  359. #define VerifyExp(f) VerifyMsg((f), #f)
  360. #if 0
  361. #define SideAssert(f) Verify(f)
  362. #endif
  363. #define AssertDo(f) Verify(f)
  364. /*************************************************************************
  365. Untested notifications
  366. *************************************************************************/
  367. #if !DEBUG
  368. #define UntestedMsg(szMsg)
  369. #else
  370. #define UntestedMsg(szMsg) \
  371. do { \
  372. if (MsoFAssertsEnabled() && \
  373. !MsoFAssertTitle("Untested", vszAssertFile, __LINE__, (const CHAR*)(szMsg))) \
  374. MsoDebugBreakInline(); \
  375. } while (0)
  376. #endif
  377. #define Untested() UntestedMsg(NULL)
  378. /*************************************************************************
  379. Unreached notifications
  380. *************************************************************************/
  381. #if !DEBUG
  382. #define UnreachedMsg(szMsg)
  383. #else
  384. #define UnreachedMsg(szMsg) \
  385. do { \
  386. if (MsoFAssertsEnabled() && \
  387. !MsoFAssertTitle("Unreached", vszAssertFile, __LINE__, (const CHAR*)(szMsg))) \
  388. MsoDebugBreakInline(); \
  389. } while (0)
  390. #endif
  391. #define Unreached() UnreachedMsg(NULL)
  392. /*************************************************************************
  393. PushAsserts
  394. *************************************************************************/
  395. /* Like Assert, except the message is not immediately displayed.
  396. Instead, the message is saved on a LIFO stack, which is dumped
  397. to the screen when an Assert eventually occurs. This can be
  398. useful for displaying additional information about the type of
  399. failure inside a nested validation routine.
  400. Yeah, I know, this is a bad idea, but I had the code, so I
  401. might as well use it. */
  402. #if !DEBUG
  403. #define MsoFPushAssert(szFile, li, szMsg) (0)
  404. #define PushAssertMsg(f, szMsg) (1)
  405. #else
  406. MSOAPIXX_(BOOL) MsoFPushAssert(const CHAR* szFile, int li, const CHAR* szMsg);
  407. #define PushAssertMsg(f, szMsg) \
  408. ((f) || (!MsoFPushAssert(vszAssertFile, __LINE__, szMsg) && MsoDebugBreak()))
  409. #endif
  410. #if MSO_ASSERT_EXP
  411. #define PushAssert(f) PushAssertMsg((f), #f)
  412. #else
  413. #define PushAssert(f) PushAssertMsg((f), NULL)
  414. #endif
  415. #define PushAssertExp(f) PushAssertMsg((f), #f)
  416. /*************************************************************************
  417. Scratch GDI Objects
  418. *************************************************************************/
  419. /* Routines to ensure only single access to global scratch GDI objects */
  420. #if !DEBUG
  421. #define MsoUseScratchObj(hobj, szObjName)
  422. #define MsoReleaseScratchObj(hobj, szObjName)
  423. #define UseScratchDC(hdc)
  424. #define ReleaseScratchDC(hdc)
  425. #define UseScratchRgn(hrgn)
  426. #define ReleaseScratchRgn(hrgn)
  427. #else
  428. /* mask that contains unused bits in the handle */
  429. #if MAC
  430. #define msohInUse (0x00000003)
  431. #define MsoFObjInUse(hobj) (((int)(hobj)&msohInUse)==0)
  432. #else
  433. #define msohInUse (0xffffffff)
  434. // REVIEW: any handle bits we can rely on to make this test more correct?
  435. #define MsoFObjInUse(hobj) (GetObjectType(hobj) != 0)
  436. #endif
  437. #define MsoUseScratchObj(hobj, szObjName) \
  438. do { \
  439. if (MsoFObjInUse(hobj) && MsoFAssertsEnabled() && \
  440. !MsoFAssert(vszAssertFile, __LINE__, "Scratch " szObjName " " #hobj " already in use")) \
  441. MsoDebugBreakInline(); \
  442. *(int*)&(hobj) ^= msohInUse; \
  443. } while (0)
  444. #define MsoReleaseScratchObj(hobj, szObjName) \
  445. do { \
  446. if (!MsoFObjInUse(hobj) && MsoFAssertsEnabled() && \
  447. !MsoFAssert(vszAssertFile, __LINE__, "Scratch " szObjName " " #hobj " not in use")) \
  448. MsoDebugBreakInline(); \
  449. *(int*)&(hobj) ^= msohInUse; \
  450. } while (0)
  451. #define UseScratchDC(hdc) MsoUseScratchObj(hdc, "DC")
  452. #define ReleaseScratchDC(hdc) MsoReleaseScratchObj(hdc, "DC")
  453. #define UseScratchRgn(hrgn) MsoUseScratchObj(hrgn, "region")
  454. #define ReleaseScratchRgn(hrgn) MsoReleaseScratchObj(hrgn, "region")
  455. #endif
  456. /*************************************************************************
  457. Reports
  458. *************************************************************************/
  459. #if DEBUG
  460. MSOAPI_(BOOL) MsoFReport(const CHAR* szFile, int li, const CHAR* szMsg);
  461. #define ReportMsg(f, szMsg) \
  462. do { \
  463. if (MsoFReportsEnabled() && !(f) && \
  464. !MsoFReport(vszAssertFile, __LINE__, (const CHAR*)(szMsg))) \
  465. MsoDebugBreakInline(); \
  466. } while (0)
  467. #else
  468. #define MsoFReport(szFile, li, szMsg) (TRUE)
  469. #define ReportMsg(f, szMsg)
  470. #endif
  471. #endif // MSO_NO_ASSERTS
  472. /*************************************************************************
  473. Inline Assert stubs - these should only happen for people who
  474. define MSO_NO_ASSERTS and don't define the asserts we need.
  475. They don't get asserts.
  476. *************************************************************************/
  477. #ifndef AssertMsgInline
  478. #define AssertMsgInline(f, szMsg)
  479. #endif
  480. #ifndef AssertMsgTemplate
  481. #define AssertMsgTemplate(f, szMsg)
  482. #endif
  483. #ifndef AssertInline
  484. #define AssertInline(f)
  485. #endif
  486. #ifndef AssertTemplate
  487. #define AssertTemplate(f)
  488. #endif
  489. /*************************************************************************
  490. Tracing
  491. *************************************************************************/
  492. /* Displays the string sz in the debug output location */
  493. #if DEBUG
  494. MSOAPI_(void) MsoTraceSz(const CHAR* szMsg, ...);
  495. MSOAPI_(void) MsoTraceVa(const CHAR* szMsg, va_list va);
  496. #elif __cplusplus
  497. __inline void __cdecl MsoTraceSz(const CHAR*,...) {}
  498. #define MsoTraceVa(szMsg, va)
  499. #else
  500. __inline void __cdecl MsoTraceSz(const CHAR* szMsg,...) {}
  501. #define MsoTraceVa(szMsg, va)
  502. #endif
  503. /*************************************************************************
  504. Debug fills
  505. *************************************************************************/
  506. enum
  507. {
  508. msomfSentinel, /* sentinel fill value */
  509. msomfFree, /* free fill value */
  510. msomfNew, /* new fill value */
  511. msomfMax
  512. };
  513. /* Fills the memory pointed to by pv with the fill value lFill. The
  514. area is assumed to be cb bytes in length. Does nothing in the
  515. non-debug build */
  516. #if DEBUG
  517. MSOAPI_(void) MsoDebugFillValue(void* pv, int cb, DWORD lFill);
  518. #else
  519. #define MsoDebugFillValue(pv, cb, lFill)
  520. #endif
  521. /* In the debug version, used to fill the area of memory pointed to by
  522. pv with a the standard fill value specified by mf. The memory is
  523. assumed to be cb bytes long. */
  524. #if DEBUG
  525. MSOAPI_(void) MsoDebugFill(void* pv, int cb, int mf);
  526. #else
  527. #define MsoDebugFill(pv, cb, mf)
  528. #endif
  529. /* Checks the area given by pv and cb are filled with the debug fill
  530. value lFill. */
  531. #if DEBUG
  532. MSOAPI_(BOOL) MsoFCheckDebugFillValue(void* pv, int cb, DWORD lFill);
  533. #else
  534. #define MsoFCheckDebugFillValue(pv, cb, lFill) (TRUE)
  535. #endif
  536. /* Checks the area given by pv and cb are filled with the debug fill
  537. of type mf. */
  538. #if DEBUG
  539. MSOAPI_(BOOL) MsoFCheckDebugFill(void* pv, int cb, int mf);
  540. #else
  541. #define MsoFCheckDebugFill(pv, cb, mf) (TRUE)
  542. #endif
  543. /* Returns the fill value corresponding to the given fill value type mf. */
  544. #if DEBUG
  545. MSOAPI_(DWORD) MsoLGetDebugFillValue(int mf);
  546. #else
  547. #define MsoLGetDebugFillValue(mf) ((DWORD)0)
  548. #endif
  549. /* Sets the fill value to lFill for the given memory fill type mf.
  550. Returns the previous fill value. */
  551. #if DEBUG
  552. MSOAPI_(DWORD) MsoSetDebugFillValue(int mf, DWORD lFill);
  553. #else
  554. #define MsoSetDebugFillValue(mf, lFill) ((DWORD)0)
  555. #endif
  556. #define MsoDebugFillLocal(l) MsoDebugFill(&(l), sizeof(l), msomfFree)
  557. /*************************************************************************
  558. Debug APIs
  559. *************************************************************************/
  560. enum
  561. {
  562. msodbSaveBe = 1,
  563. msodbValidate = 2,
  564. };
  565. /*************************************************************************
  566. Standard debugging UI for controlling Office debug options from
  567. within the app.
  568. *************************************************************************/
  569. /* Debug options for the Debug Options dialog box */
  570. typedef struct MSODBO
  571. {
  572. int aoEnabled; // assert outputs
  573. char szOut[128]; // assert output file (for msoaoFile)
  574. DWORD mpmflFill[msomfMax]; // memory fill values
  575. BOOL mpdcfEnabled[msodcMax]; // debug checks enabled
  576. /* TODO rickp(peteren): I moved mpdcfEnabled to the end
  577. so's you could avoid full builds after adding new options.
  578. That OK? */
  579. } MSODBO;
  580. enum
  581. {
  582. msodboGetDefaults = 1, /* return default debug options */
  583. msodboShowDialog = 2, /* show default debug options dialog */
  584. msodboSetOptions = 3 /* set debug options */
  585. };
  586. /* Displays the Office standard debug dialog box with owner hwndParent;
  587. for msdboGetDefaults, returns the current debug settings in pdbo; for
  588. msdboShowDialog, displays the dialog box using the settings passed
  589. in pdbo, and returns the new values (if the user hits OK); for
  590. msdboSetOptions, sets the current debug settings to values in pdbo.
  591. Returns FALSE if the user canceled the dialog. */
  592. #if DEBUG
  593. MSOAPI_(BOOL) MsoFDebugOptionsDlg(HWND hwndParent, MSODBO* pdbo, int dbo);
  594. #else
  595. #define MsoFDebugOptionsDlg(hwndParent, pdbo, dbo) (0)
  596. #endif
  597. /* Puts up the debug dialog box that displays all the cool and
  598. interesting version information for all the modules linked into
  599. the running application. The owning window is hwndParent, and
  600. additional DLL instances can be displayed by passing an array
  601. of instance handles in rghinst, with size chinst. */
  602. #if DEBUG
  603. MSOAPI_(void) MsoModuleVersionDlg(HWND hwndParent, const HINSTANCE* rghinst,
  604. int chinst);
  605. #else
  606. #define MsoModuleVersionDlg(hwndParent, rghinst, chinst)
  607. #endif
  608. /*************************************************************************
  609. Debug Monitors
  610. *************************************************************************/
  611. /* Monitor notifcations */
  612. enum
  613. {
  614. msonmAlloc=0x1000, // memory allocation
  615. msonmFree, // memory freed
  616. msonmRealloc, // memory reallocation
  617. msonmStartTrace, // start trace
  618. msonmEndTrace, // end trace
  619. msonmSbMic,
  620. msonmSbMac,
  621. msonmSbCbFree,
  622. msonmSbCbTotal,
  623. };
  624. #if DEBUG
  625. MSOAPIXX_(LRESULT) MsoNotifyMonitor(int nm, ...);
  626. MSOAPIXX_(HWND) MsoGetMonitor(void);
  627. MSOAPIXX_(BOOL) MsoFAddMonitor(HWND hwnd);
  628. MSOAPIXX_(BOOL) MsoFRemoveMonitor(HWND hwnd);
  629. MSOAPIXX_(BOOL) MsoFMonitorProcess(HWND hwnd);
  630. MSOAPIXX_(HWND) MsoGetMonitoredProcess(void);
  631. MSOAPIXX_(LRESULT) MsoAskMonitoredProcess(int nm, LPARAM lParam);
  632. #elif __cplusplus
  633. __inline void __cdecl MsoNotifyMonitor(int,...) {}
  634. #else
  635. __inline void __cdecl MsoNotifyMonitor(int nm,...) {}
  636. #endif
  637. #if defined(__cplusplus)
  638. }
  639. #endif
  640. #endif // MSODEBUG_H