Developers can create a bundle which contains functions they write themselves to construct display strings. The bundle must also contain a file resource named CustomDataViews.plist, which is the plist containing format strings. Whenever a formatter string from the bundle's .plist is used, Xcode ensures that the bundle code is loaded into the process being debugged. The expressions in the format strings can contain calls to functions in the bundle. The functions you write should be as lightweight as possible because they will be evaluated after every step in the debugger. Additionally they should not modify any global state in the process. And they must be carefully written to avoid causing problems when presented with uninitialized variables. gdb can typically handle the case where a function called from an expression causes a crash, but it is good to be as prudent as possible.
A bundle to support custom data formatting must define the following symbol:
_pbxgdb_plugin_function_list *_pbxgdb_plugin_functions = NULL;
This must be defined as a global symbol in the bundle. The bundle is loaded using NSLINKMODULE_OPTION_PRIVATE, so this symbol (and any other globals) are not merged into the global symbol table of the program. When the bundle is loaded the loading code looks up this symbol by name and fills in a value. This allows the plugin to use utility functions which are already present in the debugging environment without requiring that the linker be informed of them. These functions are described below. (Note that bundle initializer functions are called before this value is filled in.)