Debugging.pas 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973
  1. {
  2. File: CarbonCore/Debugging.h
  3. Contains: Macros to handle exceptions and assertions.
  4. The contents of this header file are deprecated.
  5. Copyright: © 1989-2011 by Apple Inc. All rights reserved.
  6. }
  7. {
  8. Modified for use with Free Pascal
  9. Version 308
  10. Please report any bugs to <[email protected]>
  11. }
  12. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  13. {$mode macpas}
  14. {$modeswitch cblocks}
  15. {$packenum 1}
  16. {$macro on}
  17. {$inline on}
  18. {$calling mwpascal}
  19. unit Debugging;
  20. interface
  21. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  22. {$setc GAP_INTERFACES_VERSION := $0308}
  23. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  24. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  25. {$endc}
  26. {$ifc defined CPUPOWERPC and defined CPUI386}
  27. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  28. {$endc}
  29. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  30. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  31. {$endc}
  32. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  33. {$setc __ppc__ := 1}
  34. {$elsec}
  35. {$setc __ppc__ := 0}
  36. {$endc}
  37. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  38. {$setc __ppc64__ := 1}
  39. {$elsec}
  40. {$setc __ppc64__ := 0}
  41. {$endc}
  42. {$ifc not defined __i386__ and defined CPUI386}
  43. {$setc __i386__ := 1}
  44. {$elsec}
  45. {$setc __i386__ := 0}
  46. {$endc}
  47. {$ifc not defined __x86_64__ and defined CPUX86_64}
  48. {$setc __x86_64__ := 1}
  49. {$elsec}
  50. {$setc __x86_64__ := 0}
  51. {$endc}
  52. {$ifc not defined __arm__ and defined CPUARM}
  53. {$setc __arm__ := 1}
  54. {$elsec}
  55. {$setc __arm__ := 0}
  56. {$endc}
  57. {$ifc not defined __arm64__ and defined CPUAARCH64}
  58. {$setc __arm64__ := 1}
  59. {$elsec}
  60. {$setc __arm64__ := 0}
  61. {$endc}
  62. {$ifc defined cpu64}
  63. {$setc __LP64__ := 1}
  64. {$elsec}
  65. {$setc __LP64__ := 0}
  66. {$endc}
  67. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  68. {$error Conflicting definitions for __ppc__ and __i386__}
  69. {$endc}
  70. {$ifc defined __ppc__ and __ppc__}
  71. {$setc TARGET_CPU_PPC := TRUE}
  72. {$setc TARGET_CPU_PPC64 := FALSE}
  73. {$setc TARGET_CPU_X86 := FALSE}
  74. {$setc TARGET_CPU_X86_64 := FALSE}
  75. {$setc TARGET_CPU_ARM := FALSE}
  76. {$setc TARGET_CPU_ARM64 := FALSE}
  77. {$setc TARGET_OS_MAC := TRUE}
  78. {$setc TARGET_OS_IPHONE := FALSE}
  79. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  80. {$setc TARGET_OS_EMBEDDED := FALSE}
  81. {$elifc defined __ppc64__ and __ppc64__}
  82. {$setc TARGET_CPU_PPC := FALSE}
  83. {$setc TARGET_CPU_PPC64 := TRUE}
  84. {$setc TARGET_CPU_X86 := FALSE}
  85. {$setc TARGET_CPU_X86_64 := FALSE}
  86. {$setc TARGET_CPU_ARM := FALSE}
  87. {$setc TARGET_CPU_ARM64 := FALSE}
  88. {$setc TARGET_OS_MAC := TRUE}
  89. {$setc TARGET_OS_IPHONE := FALSE}
  90. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  91. {$setc TARGET_OS_EMBEDDED := FALSE}
  92. {$elifc defined __i386__ and __i386__}
  93. {$setc TARGET_CPU_PPC := FALSE}
  94. {$setc TARGET_CPU_PPC64 := FALSE}
  95. {$setc TARGET_CPU_X86 := TRUE}
  96. {$setc TARGET_CPU_X86_64 := FALSE}
  97. {$setc TARGET_CPU_ARM := FALSE}
  98. {$setc TARGET_CPU_ARM64 := FALSE}
  99. {$ifc defined iphonesim}
  100. {$setc TARGET_OS_MAC := FALSE}
  101. {$setc TARGET_OS_IPHONE := TRUE}
  102. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  103. {$elsec}
  104. {$setc TARGET_OS_MAC := TRUE}
  105. {$setc TARGET_OS_IPHONE := FALSE}
  106. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  107. {$endc}
  108. {$setc TARGET_OS_EMBEDDED := FALSE}
  109. {$elifc defined __x86_64__ and __x86_64__}
  110. {$setc TARGET_CPU_PPC := FALSE}
  111. {$setc TARGET_CPU_PPC64 := FALSE}
  112. {$setc TARGET_CPU_X86 := FALSE}
  113. {$setc TARGET_CPU_X86_64 := TRUE}
  114. {$setc TARGET_CPU_ARM := FALSE}
  115. {$setc TARGET_CPU_ARM64 := FALSE}
  116. {$ifc defined iphonesim}
  117. {$setc TARGET_OS_MAC := FALSE}
  118. {$setc TARGET_OS_IPHONE := TRUE}
  119. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  120. {$elsec}
  121. {$setc TARGET_OS_MAC := TRUE}
  122. {$setc TARGET_OS_IPHONE := FALSE}
  123. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  124. {$endc}
  125. {$setc TARGET_OS_EMBEDDED := FALSE}
  126. {$elifc defined __arm__ and __arm__}
  127. {$setc TARGET_CPU_PPC := FALSE}
  128. {$setc TARGET_CPU_PPC64 := FALSE}
  129. {$setc TARGET_CPU_X86 := FALSE}
  130. {$setc TARGET_CPU_X86_64 := FALSE}
  131. {$setc TARGET_CPU_ARM := TRUE}
  132. {$setc TARGET_CPU_ARM64 := FALSE}
  133. {$setc TARGET_OS_MAC := FALSE}
  134. {$setc TARGET_OS_IPHONE := TRUE}
  135. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  136. {$setc TARGET_OS_EMBEDDED := TRUE}
  137. {$elifc defined __arm64__ and __arm64__}
  138. {$setc TARGET_CPU_PPC := FALSE}
  139. {$setc TARGET_CPU_PPC64 := FALSE}
  140. {$setc TARGET_CPU_X86 := FALSE}
  141. {$setc TARGET_CPU_X86_64 := FALSE}
  142. {$setc TARGET_CPU_ARM := FALSE}
  143. {$setc TARGET_CPU_ARM64 := TRUE}
  144. {$ifc defined ios}
  145. {$setc TARGET_OS_MAC := FALSE}
  146. {$setc TARGET_OS_IPHONE := TRUE}
  147. {$setc TARGET_OS_EMBEDDED := TRUE}
  148. {$elsec}
  149. {$setc TARGET_OS_MAC := TRUE}
  150. {$setc TARGET_OS_IPHONE := FALSE}
  151. {$setc TARGET_OS_EMBEDDED := FALSE}
  152. {$endc}
  153. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  154. {$elsec}
  155. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  156. {$endc}
  157. {$ifc defined __LP64__ and __LP64__ }
  158. {$setc TARGET_CPU_64 := TRUE}
  159. {$elsec}
  160. {$setc TARGET_CPU_64 := FALSE}
  161. {$endc}
  162. {$ifc defined FPC_BIG_ENDIAN}
  163. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  164. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  165. {$elifc defined FPC_LITTLE_ENDIAN}
  166. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  167. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  168. {$elsec}
  169. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  170. {$endc}
  171. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  172. {$setc CALL_NOT_IN_CARBON := FALSE}
  173. {$setc OLDROUTINENAMES := FALSE}
  174. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  175. {$setc OPAQUE_UPP_TYPES := TRUE}
  176. {$setc OTCARBONAPPLICATION := TRUE}
  177. {$setc OTKERNEL := FALSE}
  178. {$setc PM_USE_SESSION_APIS := TRUE}
  179. {$setc TARGET_API_MAC_CARBON := TRUE}
  180. {$setc TARGET_API_MAC_OS8 := FALSE}
  181. {$setc TARGET_API_MAC_OSX := TRUE}
  182. {$setc TARGET_CARBON := TRUE}
  183. {$setc TARGET_CPU_68K := FALSE}
  184. {$setc TARGET_CPU_MIPS := FALSE}
  185. {$setc TARGET_CPU_SPARC := FALSE}
  186. {$setc TARGET_OS_UNIX := FALSE}
  187. {$setc TARGET_OS_WIN32 := FALSE}
  188. {$setc TARGET_RT_MAC_68881 := FALSE}
  189. {$setc TARGET_RT_MAC_CFM := FALSE}
  190. {$setc TARGET_RT_MAC_MACHO := TRUE}
  191. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  192. {$setc TYPE_BOOL := FALSE}
  193. {$setc TYPE_EXTENDED := FALSE}
  194. {$setc TYPE_LONGLONG := TRUE}
  195. uses MacTypes;
  196. {$endc} {not MACOSALLINCLUDE}
  197. {$ifc TARGET_OS_MAC}
  198. {$ALIGN POWER}
  199. {
  200. This file supplies standard debugging routines and macros to Carbon and
  201. Classic Mac OS programs. Other C programs which wish to use the
  202. exception handling and assertion macros should include AssertMacros.h
  203. instead of this file.
  204. To activate debugger breaks, #define DEBUG to 1 (one) before including this
  205. file. Five further levels of debugging are available, selected by #defining
  206. one of the following conditionals to 1 after DEBUG is defined to 1.
  207. DEBUG_INTERNAL the default; asserts include file and line number
  208. information
  209. DEBUG_EXTERNAL used for code which must ship to developers outside
  210. your organization; no file or line number
  211. information is included in asserts
  212. DEBUG_BREAK_ONLY where an assertion string would normally be sent to
  213. the debugger; call Debugger() instead.
  214. PRODUCTION used for shipping code; no debugger breaks are
  215. emitted
  216. PERFORMANCE same as PRODUCTION
  217. #defining DEBUG to 0 is equivalent to #defining PRODUCTION 1 when
  218. DEBUG is 1. (No code for debugger breaks is emitted in either case.)
  219. #defining DEBUG to 1 without specifying a level is equivalent to #defining
  220. DEBUG_INTERNAL 1.
  221. In addition, these macros should also be #defined (they are described in detail below):
  222. kComponentSignatureString
  223. COMPONENT_SIGNATURE
  224. }
  225. {
  226. * Before including this file, #define kComponentSignatureString to a C-string
  227. * containing the name of your client and #define COMPONENT_SIGNATURE to your
  228. * client's unique signature (i.e., your program's registered creator type).
  229. * For example:
  230. *
  231. * #define kComponentSignatureString "SurfWriter"
  232. * #define COMPONENT_SIGNATURE 'WAVE'
  233. *
  234. * If you don't define kComponentSignatureString and COMPONENT_SIGNATURE, the
  235. * default kComponentSignatureString and COMPONENT_SIGNATURE values will be
  236. * used by the DEBUGASSERTMSG macros below.
  237. }
  238. {
  239. * The DEBUGLEVEL's
  240. }
  241. const
  242. DEBUG_LEVEL_PRODUCTION = 0;
  243. const
  244. DEBUG_LEVEL_BREAK_ONLY = 1;
  245. const
  246. DEBUG_LEVEL_EXTERNAL = 3;
  247. const
  248. DEBUG_LEVEL_INTERNAL = 4;
  249. DEBUGFULL = DEBUG_LEVEL_INTERNAL;
  250. {
  251. * define DEBUGLEVEL
  252. }
  253. {
  254. * The options parameter to DebugAssert and DEBUGASSERTMSG is currently reserved (must be zero).
  255. }
  256. const
  257. DEBUG_NO_OPTIONS = 0;
  258. {
  259. * DEBUGASSERTMSG()
  260. *
  261. * Summary:
  262. * All error reporting is routed through this macro, which calls the system
  263. * routine DebugAssert(). If you wish to use your own assertion break
  264. * routine, you can override DEBUGASSERTMSG by defining it before including
  265. * this file.
  266. *
  267. * Parameters:
  268. *
  269. * componentSignature:
  270. * The unique signature of component causing the assertion.
  271. *
  272. * options:
  273. * reserved.
  274. *
  275. * assertionString:
  276. * A pointer to a string constant containing the assertion.
  277. * This must be a string constant (and not a string variable or
  278. * NULL) because the Proeprocessor concatenates it with other
  279. * string constants
  280. *
  281. * exceptionLabelString:
  282. * A pointer to a string containing the exceptionLabel, or NULL.
  283. *
  284. * errorString:
  285. * A pointer to the error string, or NULL. DEBUGASSERTMSG macros
  286. * must not attempt to concatenate this string with constant
  287. * character strings.
  288. *
  289. * fileName:
  290. * A pointer to the fileName or pathname (generated by the
  291. * preprocessor __FILE__ identifier), or NULL.
  292. *
  293. * lineNumber:
  294. * The line number in the file (generated by the preprocessor
  295. * __LINE__ identifier), or 0 (zero).
  296. *
  297. * value:
  298. * A value associated with the assertion, or NULL.
  299. }
  300. {
  301. * Define the three inputs to AssertMacros.h
  302. }
  303. {
  304. * Include AssertMacros.h where all of the check, verify, and require macros are defined
  305. }
  306. {
  307. * The following check, verify, and require macros assert that TaskLevel is 0.
  308. }
  309. {
  310. * You can use DPRINTF as a dprintf which goes away in production builds.
  311. * DPRINTF is not supported by Carbon because dprintf
  312. * is not supported by Carbon.
  313. *
  314. * To use it, double-parenthesize the argument - i.e., use:
  315. *
  316. * DPRINTF(("formatString %d", 5 ));
  317. *
  318. * This is sadly necessary because a macro can not have a variable number
  319. * of arguments.
  320. *
  321. * DPRINTF is defined only if it is not already defined to
  322. * prevent conflicts with developer code.
  323. }
  324. {
  325. * kBlessedBusErrorBait is an address that will never be mapped by
  326. * Mac OS 8 or 9. It is close to the middle of the 64K range from 0x68F10000
  327. * to 0x68F1FFFF that is unmapped and cannot be accessed without causing an
  328. * exception. Thus, it's a good value to use for filling uninitialized
  329. * pointers, etc.
  330. *
  331. * Mac OS X programs should NOT use kBlessedBusErrorBait and should use
  332. * zero (0) instead, since by default, page 0 is read and write protected
  333. * for user code.
  334. }
  335. const
  336. kBlessedBusErrorBait = $68F168F1;
  337. {
  338. * DebugAssert()
  339. *
  340. * Summary:
  341. * DebugAssert is the system routine that the DEBUGASSERTMSG macro
  342. * calls (by default) to display assertion messsages. The output
  343. * from DebugAssert can be redirected by installing a
  344. * DebugAssertOutputHandler with InstallDebugAssertOutputHandler.
  345. *
  346. * Mac OS X threading:
  347. * Thread safe
  348. * This call is thread safe if no debug components are registered,
  349. * and may be thread unsafe if there are debug components being
  350. * installed or removed.
  351. *
  352. * Parameters:
  353. *
  354. * componentSignature:
  355. * The unique signature of component causing the assertion.
  356. *
  357. * options:
  358. * reserved.
  359. *
  360. * assertionString:
  361. * A pointer to a string containing the assertion, or NULL.
  362. *
  363. * exceptionLabelString:
  364. * A pointer to a string containing the exceptionLabel, or NULL.
  365. *
  366. * errorString:
  367. * A pointer to the error string, or NULL.
  368. *
  369. * fileName:
  370. * A pointer to the fileName or pathname (generated by the
  371. * preprocessor __FILE__ identifier), or NULL.
  372. *
  373. * lineNumber:
  374. * The line number in the file (generated by the preprocessor
  375. * __LINE__ identifier), or 0 (zero).
  376. *
  377. * value:
  378. * A value associated with the assertion, or NULL.
  379. *
  380. * Availability:
  381. * Mac OS X: in version 10.0 and later in CoreServices.framework
  382. * CarbonLib: in CarbonLib 1.0 and later
  383. * Non-Carbon CFM: in DebugLib 1.0 and later
  384. }
  385. procedure DebugAssert( componentSignature: OSType; options: UInt32; assertionString: ConstCStringPtr; exceptionLabelString: ConstCStringPtr; errorString: ConstCStringPtr; fileName: ConstCStringPtr; lineNumber: SIGNEDLONG; value: UnivPtr ); external name '_DebugAssert';
  386. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  387. {
  388. * TaskLevel masks
  389. }
  390. const
  391. k68kInterruptLevelMask = $00000007; { 68K interrupt levels 0 through 7 }
  392. kInVBLTaskMask = $00000010; { VBLs are executing }
  393. kInDeferredTaskMask = $00000020; { Deferred tasks are executing }
  394. kInSecondaryIntHandlerMask = $00000040; { Secondary interrupt handlers are executing }
  395. kInNestedInterruptMask = $00000080; { The system is handling an interrupt }
  396. {
  397. * TaskLevel()
  398. *
  399. * Summary:
  400. * TaskLevel returns 0 if we're (probably) running at non-interrupt
  401. * time. There's no way to make this perfect, but this is as close
  402. * as we can get. If TaskLevel doesn't return 0, then one of the
  403. * TaskLevel masks can be used to learn more. Mac OS X has no
  404. * concept of "TaskLevel"; and so it will always return the value 0.
  405. *
  406. * Mac OS X threading:
  407. * Thread safe
  408. *
  409. * Result:
  410. * The current task level.
  411. *
  412. * Availability:
  413. * Mac OS X: in version 10.0 and later in CoreServices.framework
  414. * CarbonLib: in CarbonLib 1.0 and later
  415. * Non-Carbon CFM: in DebugLib 1.0 and later
  416. }
  417. function TaskLevel: UInt32; external name '_TaskLevel';
  418. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  419. {
  420. * Constants used by the DebugComponent functions
  421. }
  422. const
  423. kComponentDebugOption = 0; { optionSelectorNum to turn breaks for component On or Off}
  424. const
  425. kGetDebugOption = 1; { get current debug option setting}
  426. kSetDebugOption = 2; { set debug option}
  427. {
  428. * DebugComponentCallbackProcPtr
  429. *
  430. * Discussion:
  431. * DebugComponentCallback is the callback into a component that
  432. * registers with DebugLib. It is called to get the debug option
  433. * setting, or to turn a debug option on or off.
  434. *
  435. * Parameters:
  436. *
  437. * optionSelectorNum:
  438. * The component debug option to set.
  439. *
  440. * command:
  441. * The command the DebugComponentCallbackProc must handle:
  442. * kGetDebugOption - get current debug option setting
  443. * kSetDebugOption - set debug option
  444. *
  445. * optionSetting:
  446. * A pointer to a Boolean where the DebugComponentCallbackProc
  447. * must return the option setting: the current setting if command
  448. * is kGetDebugOption; the new debug option if command is
  449. * kSetDebugOption
  450. }
  451. type
  452. DebugComponentCallbackProcPtr = procedure( optionSelectorNum: SInt32; command: UInt32; var optionSetting: Boolean );
  453. DebugComponentCallbackUPP = DebugComponentCallbackProcPtr;
  454. {
  455. * NewDebugComponent()
  456. *
  457. * Summary:
  458. * NewDebugComponent registers a component with DebugLib.
  459. *
  460. * Mac OS X threading:
  461. * Not thread safe
  462. *
  463. * Parameters:
  464. *
  465. * componentSignature:
  466. * The unique signature of component.
  467. *
  468. * componentName:
  469. * The displayable string naming the component.
  470. *
  471. * componentCallback:
  472. * The callback into component for working with options.
  473. *
  474. * Result:
  475. * An operating system result code: noErr, memFullErr,
  476. * debuggingExecutionContextErr, debuggingDuplicateSignatureErr, or
  477. * debuggingInvalidNameErr.
  478. *
  479. * Availability:
  480. * Mac OS X: in version 10.0 and later in CoreServices.framework
  481. * CarbonLib: in CarbonLib 1.0 and later
  482. * Non-Carbon CFM: in DebugLib 1.0 and later
  483. }
  484. function NewDebugComponent( componentSignature: OSType; const (*var*) componentName: Str255; componentCallback: DebugComponentCallbackUPP ): OSStatus; external name '_NewDebugComponent';
  485. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  486. {
  487. * NewDebugOption()
  488. *
  489. * Summary:
  490. * NewDebugOption registers a debug option with DebugLib.
  491. *
  492. * Mac OS X threading:
  493. * Not thread safe
  494. *
  495. * Parameters:
  496. *
  497. * componentSignature:
  498. * The signature of component to register a debug option for.
  499. *
  500. * optionSelectorNum:
  501. * The selector number of this debug option.
  502. *
  503. * optionName:
  504. * The displayable string naming this debug option.
  505. *
  506. * Result:
  507. * An operating system result code: noErr, memFullErr,
  508. * debuggingExecutionContextErr, debuggingDuplicateOptionErr,
  509. * debuggingInvalidSignatureErr, debuggingInvalidNameErr, or
  510. * debuggingNoCallbackErr.
  511. *
  512. * Availability:
  513. * Mac OS X: in version 10.0 and later in CoreServices.framework
  514. * CarbonLib: in CarbonLib 1.0 and later
  515. * Non-Carbon CFM: in DebugLib 1.0 and later
  516. }
  517. function NewDebugOption( componentSignature: OSType; optionSelectorNum: SInt32; const (*var*) optionName: Str255 ): OSStatus; external name '_NewDebugOption';
  518. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  519. {
  520. * DisposeDebugComponent()
  521. *
  522. * Summary:
  523. * DisposeDebugComponent removes a component registration and all
  524. * related debug options from DebugLib.
  525. *
  526. * Mac OS X threading:
  527. * Not thread safe
  528. *
  529. * Parameters:
  530. *
  531. * componentSignature:
  532. * The unique signature of a component.
  533. *
  534. * Result:
  535. * An operating system result code: noErr,
  536. * debuggingExecutionContextErr, or debuggingInvalidSignatureErr.
  537. *
  538. * Availability:
  539. * Mac OS X: in version 10.0 and later in CoreServices.framework
  540. * CarbonLib: in CarbonLib 1.0 and later
  541. * Non-Carbon CFM: in DebugLib 1.0 and later
  542. }
  543. function DisposeDebugComponent( componentSignature: OSType ): OSStatus; external name '_DisposeDebugComponent';
  544. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  545. {
  546. * GetDebugComponentInfo()
  547. *
  548. * Summary:
  549. * GetDebugComponentInfo returns a component registered with
  550. * DebugLib.
  551. *
  552. * Mac OS X threading:
  553. * Not thread safe
  554. *
  555. * Parameters:
  556. *
  557. * itemIndex:
  558. * The index into the list of registered components (1-based).
  559. *
  560. * componentSignature:
  561. * A pointer to an OSType where the unique signature of a
  562. * component is returned.
  563. *
  564. * componentName:
  565. * A pointer to an Str255 where the displayable string naming a
  566. * component is returned.
  567. *
  568. * Result:
  569. * An operating system result code: noErr or debuggingNoMatchErr.
  570. *
  571. * Availability:
  572. * Mac OS X: in version 10.0 and later in CoreServices.framework
  573. * CarbonLib: in CarbonLib 1.0 and later
  574. * Non-Carbon CFM: in DebugLib 1.0 and later
  575. }
  576. function GetDebugComponentInfo( itemIndex: UInt32; var componentSignature: OSType; var componentName: Str255 ): OSStatus; external name '_GetDebugComponentInfo';
  577. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  578. {
  579. * GetDebugOptionInfo()
  580. *
  581. * Summary:
  582. * GetDebugOptionInfo returns a debug option registered with
  583. * DebugLib.
  584. *
  585. * Mac OS X threading:
  586. * Not thread safe
  587. *
  588. * Parameters:
  589. *
  590. * itemIndex:
  591. * The index into the list of registered debug options (0-based);
  592. * 0 = kComponentDebugOption.
  593. *
  594. * componentSignature:
  595. * The unique signature of a component.
  596. *
  597. * optionSelectorNum:
  598. * A pointer to an SInt32 where the selector number of this debug
  599. * option is returned.
  600. *
  601. * optionName:
  602. * A pointer to an Str255 where the displayable string naming this
  603. * debug option is returned.
  604. *
  605. * optionSetting:
  606. * A pointer to an Boolean where the current debug option setting
  607. * is returned.
  608. *
  609. * Result:
  610. * An operating system result code: noErr,
  611. * debuggingInvalidSignatureErr, or debuggingNoMatchErr.
  612. *
  613. * Availability:
  614. * Mac OS X: in version 10.0 and later in CoreServices.framework
  615. * CarbonLib: in CarbonLib 1.0 and later
  616. * Non-Carbon CFM: in DebugLib 1.0 and later
  617. }
  618. function GetDebugOptionInfo( itemIndex: UInt32; componentSignature: OSType; var optionSelectorNum: SInt32; var optionName: Str255; var optionSetting: Boolean ): OSStatus; external name '_GetDebugOptionInfo';
  619. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  620. {
  621. * SetDebugOptionValue()
  622. *
  623. * Summary:
  624. * SetDebugOptionValue sets a debug option registered with DebugLib.
  625. *
  626. * Mac OS X threading:
  627. * Not thread safe
  628. *
  629. * Parameters:
  630. *
  631. * componentSignature:
  632. * The unique signature of a component.
  633. *
  634. * optionSelectorNum:
  635. * The selector number of this debug option.
  636. *
  637. * newOptionSetting:
  638. * The new debug option setting.
  639. *
  640. * Result:
  641. * An operating system result code: noErr,
  642. * debuggingInvalidSignatureErr, or debuggingInvalidOptionErr.
  643. *
  644. * Availability:
  645. * Mac OS X: in version 10.0 and later in CoreServices.framework
  646. * CarbonLib: in CarbonLib 1.0 and later
  647. * Non-Carbon CFM: in DebugLib 1.0 and later
  648. }
  649. function SetDebugOptionValue( componentSignature: OSType; optionSelectorNum: SInt32; newOptionSetting: Boolean ): OSStatus; external name '_SetDebugOptionValue';
  650. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  651. {
  652. * DebugAssertOutputHandlerProcPtr
  653. *
  654. * Discussion:
  655. * DebugAssertOutputHandler is the callback that registers with
  656. * DebugLib to handle the output from DebugAssert. The
  657. * "componentSignature" through "value" parameters are the raw
  658. * values passed to DebugAssert when an exception occurs.
  659. *
  660. * Parameters:
  661. *
  662. * componentSignature:
  663. * The unique signature of component causing the assertion.
  664. *
  665. * options:
  666. * reserved.
  667. *
  668. * assertionString:
  669. * A pointer to a string containing the assertion, or NULL.
  670. *
  671. * exceptionLabelString:
  672. * A pointer to a string containing the exceptionLabel, or NULL.
  673. *
  674. * errorString:
  675. * A pointer to the error string, or NULL.
  676. *
  677. * fileName:
  678. * A pointer to the fileName or pathname (generated by the
  679. * preprocessor __FILE__ identifier), or NULL.
  680. *
  681. * lineNumber:
  682. * The line number in the file (generated by the preprocessor
  683. * __LINE__ identifier), or 0 (zero).
  684. *
  685. * value:
  686. * A value associated with the assertion, or NULL.
  687. *
  688. * outputMsg:
  689. * The string DebugAssert build which would normally be passed to
  690. * DebugStr if a DebugAssertOutputHandler isn't installed.
  691. }
  692. type
  693. DebugAssertOutputHandlerProcPtr = procedure( componentSignature: OSType; options: UInt32; assertionString: ConstCStringPtr; exceptionLabelString: ConstCStringPtr; errorString: ConstCStringPtr; fileName: ConstCStringPtr; lineNumber: SIGNEDLONG; value: UnivPtr; const (*var*) outputMsg: Str255 );
  694. DebugAssertOutputHandlerUPP = DebugAssertOutputHandlerProcPtr;
  695. {
  696. * InstallDebugAssertOutputHandler()
  697. *
  698. * Summary:
  699. * InstallDebugAssertOutputHandler installs a
  700. * DebugAssertOutputHandler which DebugAssert calls instead of
  701. * DebugStr.
  702. *
  703. * Parameters:
  704. *
  705. * handler:
  706. * The DebugAssertOutputHandler to install or NULL to switch back
  707. * to the default handler (DebugStr).
  708. *
  709. * Availability:
  710. * Mac OS X: in version 10.0 and later in CoreServices.framework
  711. * CarbonLib: in CarbonLib 1.0 and later
  712. * Non-Carbon CFM: in DebugLib 1.0 and later
  713. }
  714. procedure InstallDebugAssertOutputHandler( handler: DebugAssertOutputHandlerUPP ); external name '_InstallDebugAssertOutputHandler';
  715. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  716. {
  717. * dprintf()
  718. *
  719. * Summary:
  720. * printf takes a variable argument list and 'prints' that to the
  721. * debugging output handler. Calling dprintf() from anything but C
  722. * or C++ is tricky.
  723. *
  724. * Parameters:
  725. *
  726. * format:
  727. * The format string.
  728. *
  729. * ...:
  730. * The arguments to the format string.
  731. *
  732. * Availability:
  733. * Mac OS X: not available
  734. * CarbonLib: not available
  735. * Non-Carbon CFM: in DebugLib 1.1 and later
  736. }
  737. {
  738. * vdprintf()
  739. *
  740. * Summary:
  741. * vdprintf takes a va_args list and 'prints' that to the debugging
  742. * output handler.
  743. *
  744. * Parameters:
  745. *
  746. * format:
  747. * The format string.
  748. *
  749. * va_args_list:
  750. * The va_args list.
  751. *
  752. * Availability:
  753. * Mac OS X: not available
  754. * CarbonLib: not available
  755. * Non-Carbon CFM: in DebugLib 1.1 and later
  756. }
  757. {
  758. * GetMacOSStatusErrorString()
  759. *
  760. * Summary:
  761. * Returns a const char* string which corresponds to the textual
  762. * constant for the given OSStatus code.
  763. *
  764. * Discussion:
  765. * This function returns a text string which corresponds to the
  766. * given OSStatus code, based on the errors in MacErrors.h. For
  767. * example, GetMacOSStatusErrorString( -43 ) returns "fnfErr", which
  768. * is the text representation for the error constant -43. This
  769. * function is useful if you want to get or print out ( for
  770. * debugging purposes only ) a useful description for a given
  771. * OSStatus error. If no string is available for the given
  772. * constant, then the empty string "" is returned. Some error values
  773. * have multiple meanings; in those cases the multiple meanings are
  774. * all returned seperated by '/'es.
  775. *
  776. * Mac OS X threading:
  777. * Thread safe
  778. *
  779. * Parameters:
  780. *
  781. * err:
  782. * The OSStatus to return a text string for.
  783. *
  784. * Result:
  785. * A const char* string corresponding to the given OSStatus
  786. *
  787. * Availability:
  788. * Mac OS X: in version 10.4 and later in CoreServices.framework
  789. * CarbonLib: not available
  790. * Non-Carbon CFM: not available
  791. }
  792. function GetMacOSStatusErrorString( err: OSStatus ): CStringPtr; external name '_GetMacOSStatusErrorString';
  793. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  794. {
  795. * GetMacOSStatusCommentString()
  796. *
  797. * Summary:
  798. * Returns a const char* string which corresponds to the descriptive
  799. * string for the given OSStatus code.
  800. *
  801. * Discussion:
  802. * This function returns a text string which corresponds to a
  803. * comment for the given OSStatus code, based on the errors in
  804. * MacErrors.h. For example, GetMacOSStatusConstantString( -43 )
  805. * returns "File not found", which is the text representation for
  806. * the error constant -43. This function is useful if you want to
  807. * get or print out ( for debugging purposes only ) a useful
  808. * description for a given OSStatus error. If no string is
  809. * available for the given constant, then the empty string "" is
  810. * returned. If no string is available for the given constant, then
  811. * the empty string "" is returned. Some error values have multiple
  812. * meanings; in those cases the multiple meanings are all returned
  813. * seperated by '/'es.
  814. *
  815. * Mac OS X threading:
  816. * Thread safe
  817. *
  818. * Parameters:
  819. *
  820. * err:
  821. * The OSStatus to return a text string for.
  822. *
  823. * Result:
  824. * A const char* string corresponding to the given OSStatus
  825. *
  826. * Availability:
  827. * Mac OS X: in version 10.4 and later in CoreServices.framework
  828. * CarbonLib: not available
  829. * Non-Carbon CFM: not available
  830. }
  831. function GetMacOSStatusCommentString( err: OSStatus ): CStringPtr; external name '_GetMacOSStatusCommentString';
  832. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  833. {
  834. pascal < threadsafe, exportset=fw_CarbonCore_XMerlot >
  835. Boolean IsDebuggerAttachedToProcess ( );
  836. }
  837. {
  838. * NewDebugComponentCallbackUPP()
  839. *
  840. * Availability:
  841. * Mac OS X: in version 10.0 and later in CoreServices.framework
  842. * CarbonLib: in CarbonLib 1.0 and later
  843. * Non-Carbon CFM: available as macro/inline
  844. }
  845. function NewDebugComponentCallbackUPP( userRoutine: DebugComponentCallbackProcPtr ): DebugComponentCallbackUPP; external name '_NewDebugComponentCallbackUPP';
  846. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  847. {
  848. * NewDebugAssertOutputHandlerUPP()
  849. *
  850. * Availability:
  851. * Mac OS X: in version 10.0 and later in CoreServices.framework
  852. * CarbonLib: in CarbonLib 1.0 and later
  853. * Non-Carbon CFM: available as macro/inline
  854. }
  855. function NewDebugAssertOutputHandlerUPP( userRoutine: DebugAssertOutputHandlerProcPtr ): DebugAssertOutputHandlerUPP; external name '_NewDebugAssertOutputHandlerUPP';
  856. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  857. {
  858. * DisposeDebugComponentCallbackUPP()
  859. *
  860. * Availability:
  861. * Mac OS X: in version 10.0 and later in CoreServices.framework
  862. * CarbonLib: in CarbonLib 1.0 and later
  863. * Non-Carbon CFM: available as macro/inline
  864. }
  865. procedure DisposeDebugComponentCallbackUPP( userUPP: DebugComponentCallbackUPP ); external name '_DisposeDebugComponentCallbackUPP';
  866. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  867. {
  868. * DisposeDebugAssertOutputHandlerUPP()
  869. *
  870. * Availability:
  871. * Mac OS X: in version 10.0 and later in CoreServices.framework
  872. * CarbonLib: in CarbonLib 1.0 and later
  873. * Non-Carbon CFM: available as macro/inline
  874. }
  875. procedure DisposeDebugAssertOutputHandlerUPP( userUPP: DebugAssertOutputHandlerUPP ); external name '_DisposeDebugAssertOutputHandlerUPP';
  876. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  877. {
  878. * InvokeDebugComponentCallbackUPP()
  879. *
  880. * Availability:
  881. * Mac OS X: in version 10.0 and later in CoreServices.framework
  882. * CarbonLib: in CarbonLib 1.0 and later
  883. * Non-Carbon CFM: available as macro/inline
  884. }
  885. procedure InvokeDebugComponentCallbackUPP( optionSelectorNum: SInt32; command: UInt32; var optionSetting: Boolean; userUPP: DebugComponentCallbackUPP ); external name '_InvokeDebugComponentCallbackUPP';
  886. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  887. {
  888. * InvokeDebugAssertOutputHandlerUPP()
  889. *
  890. * Availability:
  891. * Mac OS X: in version 10.0 and later in CoreServices.framework
  892. * CarbonLib: in CarbonLib 1.0 and later
  893. * Non-Carbon CFM: available as macro/inline
  894. }
  895. procedure InvokeDebugAssertOutputHandlerUPP( componentSignature: OSType; options: UInt32; assertionString: ConstCStringPtr; exceptionLabelString: ConstCStringPtr; errorString: ConstCStringPtr; fileName: ConstCStringPtr; lineNumber: SIGNEDLONG; value: UnivPtr; const (*var*) outputMsg: Str255; userUPP: DebugAssertOutputHandlerUPP ); external name '_InvokeDebugAssertOutputHandlerUPP';
  896. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  897. {$endc} {TARGET_OS_MAC}
  898. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  899. end.
  900. {$endc} {not MACOSALLINCLUDE}