• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Displaying Custom Data Types in Debugger
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Displaying Custom Data Types in Debugger


  • Subject: Re: Displaying Custom Data Types in Debugger
  • From: Michael Rice <email@hidden>
  • Date: Tue, 19 Jul 2005 18:43:54 -0500

On Jul 19, 2005, at 3:35 PM, Jim Ingham wrote:


On Jul 18, 2005, at 6:43 PM, Michael Rice wrote:



On Jul 18, 2005, at 6:44 PM, Jim Ingham wrote:




On Jul 18, 2005, at 4:33 PM, Michael Rice wrote:





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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40apple.com


This email sent to email@hidden




The data formatter code is running in the target program, so you should be able to use the debugger on it too... Just make sure you build your data formatter with debug info.


You can use the Shared Libraries list (Debugger->Tools->Shared Libraries) to make sure your bundle got loaded.

Then if in the console you do:

(gdb) break MyObjectToCString

When Xcode calls your introspection function gdb will break there. It might complain a bit about hitting a breakpoint while running code in the inferior or something like that. But you will anyway be able to debug the introspection function, make sure it's getting reasonable behavior, and make sure it's setting the output data correctly...

Jim




Jim -

Thanks for the info. I've progressed a little bit. I've verified that my data formatter function is getting called (I've been able to step into it in the debugger). It returns a string, allocated using _pbxgdb_plugin_functions->message(), but the string itself is not displayed in the Summary column, only the address of the string. If I open the Expressions view and add '(char*)0x1621fb0', where 0x1621fb0 is the address displayed in the Summary column, and then double click the item in the Expressions view, it displays the string I'm returning from my data formatter.

My data formatter function is defined as:
char* MyObjectToCString(MyObject*, int ID);

and my formatter spec is:
{(char *)MyObjectToCString(&$VAR, $ID)}

I'm using C++ linkage for my formatter function and the debugger is able to resolve my function fine.

Any ideas how I can get the debugger to display the string instead of the address?

Michael


I think you need to use:

{(char *)MyObjectToCString(&$VAR, $ID)}:s

For any expression that you use as a data formatter, you have the option to display the VALUE of that expression, or the SUMMARY field of that expression. In this case, the value of an expression of type "char *" is it's pointer address, and it's summary is the actual string value.

The default is to use the value. So you need to specify that you want to use the summary, instead. You do that by putting :s after the expression...

Jim

Awesome, that did the trick.

Thanks for the excellent help.
Michael
_______________________________________________
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


References: 
 >Displaying Custom Data Types in Debugger (From: Michael Rice <email@hidden>)
 >Re: Displaying Custom Data Types in Debugger (From: Chris Espinosa <email@hidden>)
 >Re: Displaying Custom Data Types in Debugger (From: Michael Rice <email@hidden>)
 >Re: Displaying Custom Data Types in Debugger (From: Chris Espinosa <email@hidden>)
 >Re: Displaying Custom Data Types in Debugger (From: Graham Westlake <email@hidden>)
 >Re: Displaying Custom Data Types in Debugger (From: Michael Rice <email@hidden>)
 >Re: Displaying Custom Data Types in Debugger (From: Jim Ingham <email@hidden>)
 >Re: Displaying Custom Data Types in Debugger (From: Michael Rice <email@hidden>)
 >Re: Displaying Custom Data Types in Debugger (From: Jim Ingham <email@hidden>)

  • Prev by Date: Re: "Program exited with status value:45. mi_cmd_stack_list_frames_lite: No stack." Eh?
  • Next by Date: Re: "Program exited with status value:45. mi_cmd_stack_list_frames_lite: No stack." Eh?
  • Previous by thread: Re: Displaying Custom Data Types in Debugger
  • Next by thread: Re: Per-architecture SDK
  • Index(es):
    • Date
    • Thread