On Jul 18, 2005, at 6:50 AM, Graham Westlake wrote: On 16 Jul 2005, at 21:40, Chris Espinosa wrote: You write a simple .c file that #includes " /Developer/Applications/Xcode.app/Contents/PlugIns/GDBMIDebugging.xcplugin/Contents/Headers/DataFormatterPlugin.h", and a function that returns a char * given a pointer to your Unicode string. Compile that into a plugin that's structured like the CarbonDataFormatter.bundle, and put in the plist the _expression_ that calls your function.
Because to return a char * from your Unicode string you probably have to allocate memory temporarily, you use the ID passed in the _expression_ and pass it to the _pbxgdb_allocator(size, ID) function to allocate space for the char *. Xcode will free this memory when your variable goes out of scope.
I've followed these instructions while attempting to write a plugin to display the contents of a C++ class, but I'm not having much luck - GDB crashes when I try to view my variable.
One necessary change I've made is to compile my plugin code as C++; is this likely to be causing a problem? I've tried declaring the formatting function as extern "C" but it hasn't helped. Also, how is my C++ variable passed to the formatting function?
I'm trying to do the same. I have an instance of a C++ class that I need to display as a string. I've declared my interface function in a .cpp file as:
char* MyObjectToCString(MyObject* data, int ID);
and the custom data format (in my bundle's CustomDataViews.plist) as:
{MyObjectToCString($VAR, $ID)}
All I see in the debugger is {MyObjectToCString($VAR, $ID)}, which I'm taking to mean that it can't find my interface function. I've tried defining the interface function in an 'extern "C"' block, but that didn't help. I used 'otool' to look inside the CarbonDataFormatters and it shows that there are mangled names in there, so I don't think it's required to use "C" linkage.
Michael |