Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Debugging Utilities
Because Core Foundation types are opaque, it is difficult to inspect the Core Foundation objects created by your code using traditional means. However, Core Foundation implements a couple of functions that print descriptions of Core Foundation objects, either from your code or in any debugger that supports functions calls.
The first of these functions is CFShow
,
which takes a reference to any Core Foundation object (that is,
its sole parameter is typed as CFTypeRef
).
This function calls the CFDescription
function
on the object, causing it to return a reference to a CFString object
containing the description. The CFShow
function
then prints this description to the output device.
The second “inspection” function is CFShowStr
,
which takes a reference to a CFString object. This function displays
the attributes of a CFString object but not its contents.
Listing 1 shows the information printed by both functions in a debugger.
Listing 1 Calling the inspection functions in a debugger
(gdb) s |
stringGettingContentsAsCStringExample () at StringExample.c:105 |
105 str = CFStringCreateWithCString(NULL, "Hello World", CFStringGetSystemEncoding()); |
(gdb) n |
111 bytes = CFStringGetCStringPtr(str, CFStringGetSystemEncoding()); |
(gdb) call CFShow(str) |
Hello World |
$1 = 0 |
(gdb) call CFShowStr(str) |
Length 11 |
IsEightBit 1 |
HasLengthByte 1 |
HasNullByte 1 |
InlineContents 1 |
Allocator SystemDefault |
Mutable 0 |
Contents 0x4e7c0 |
$2 = 17 |
(gdb) |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-17