Because Core Foundation types are opaque, it is difficult to inspect the Core Foundation objects created by your code using traditional means. However, String Services 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 15 shows the information printed by both functions in a debugger.
Listing 15 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)