Re: Data Formatters - XCode 2.0
Re: Data Formatters - XCode 2.0
- Subject: Re: Data Formatters - XCode 2.0
- From: Jim Ingham <email@hidden>
- Date: Tue, 24 May 2005 13:59:56 -0700
On May 24, 2005, at 1:16 PM, Chris Friesen wrote:
On May 24, 2005, at 8:45 AM, Wade Girard wrote:
I am trying to make a Data formatter plugin for one of our data
types. It is a string class that we use, similar to a C++ string.
The plugin is being called, but is apparently not working correctly.
As an example I am also trying to do it using a C++ string. I KNOW
THAT I CAN SIMPLY TYPE {$VAR.c_str()}:s IN THE SUMMARY FIELD FOR A
C++ STRING!!! Please don't tell me to try this.
Our string type also has a c_str() method, but is returning
unicode and can't be displayed properly this way.
So, after all that, here is what I am trying to do, assuming I am
using a C++ string
//==========PLIST SNIPPET==========
<key>string</key>
<dict>
<key>SummaryString</key>
<string>{(char *)string_summary($VAR, $ID)}:s</string>
</dict>
//==========PLIST SNIPPET==========
//==========CODE SNIPPET==========
char* string_summary(const string &str, int identifier)
{
char *result = NULL;
if ( NULL != _pbxgdb_plugin_functions )
{
// if I replace str in the formatter with s1, this string
IS displayed
std::string s1 = "This is a c++ string";
result = _pbxgdb_plugin_functions->message(identifier, "<%
s>", str.c_str());
}
return result;
}
//==========CODE SNIPPET==========
I had to change the function declaration to compile with gcc 4.0
and ensure gdb loaded the symbols for the data formatter. (I would
give data formatter functions more unique names to avoid
collisions.) I ended up with:
#include <iostream>
#include <string>
#import "/Developer/Applications/Xcode.app/Contents/PlugIns/
GDBMIDebugging.xcplugin/Contents/Headers/DataFormatterPlugin.h"
_pbxgdb_plugin_function_list *_pbxgdb_plugin_functions = NULL;
char* string_summary(std::string str, int identifier)
{
char *result = NULL;
if ( NULL != _pbxgdb_plugin_functions )
{
// if I replace str in the formatter with s1, this string
IS displayed
std::string s1 = "This is a c++ string";
result = _pbxgdb_plugin_functions->message(identifier, "<%
s>", str.c_str());
}
return result;
}
Note, you probably don't want to do this, because then the
string_summary is going to try to pass the string by value, which is
easy for small classes (it just copies the fields into registers) but
can get gnarly. It is much better to write the function to take a
pointer, and then to dereference $VAR in the SummaryString.
Jim
When I run in the debugger, all I get in the summary field is "out
of scope", but the variable name is not grayed. If I replace str
with s1, then the string "This is a C++ string" will always be
displayed.
When running Xcode 2.0 you need to tell gdb to load the symbols for
your data formatter so the functions can be called. Use the menu
Debug->Tools->Shared Libraries... filter on the name of your data
formatter bundle and change the 'Starting Level' to 'All'.
Cheers,
ChrisF
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden