I'm trying to write a DTrace script that will show me the parameter passed to -[NSURLConnection sendSynchronousRequest:returningResponse:error:]
and I can't find a struct that works for extracting the string out of the passed in NSString
parameter. This question has an answer that works for OS X applications, but it does not work for my application which is using the iOS simulator.
Although I'm looking for a solution to this specific example, I'm much more interested in learning the best way to define / discover the underlying memory structure for any given Objective-C object. As you can see from the OS X test app I wrote, an NSString
parameter does not always have the raw string data in the same place. In the case where it's __NSCFString
is appears to be located (length prefixed) at 16 bytes in. In the case where it's a __NSCFConstant
string it's somewhere else that's not immediately obvious looking at the raw memory dump.
If there are structs defined in system headers that will show me what I'm looking for that would be good first step but I'm thinking that LLDB ought to be able to show me useful hints as well.