[lldb-dev] Call c/objc functions with the API
Jim Ingham
jingham at apple.com
Mon Feb 25 09:42:14 PST 2013
On Feb 23, 2013, at 2:42 AM, Jean-Daniel Dupas <devlists at shadowlab.org> wrote:
>
> Le 22 févr. 2013 à 22:56, Jim Ingham <jingham at apple.com> a écrit :
>
>>
>> On Feb 22, 2013, at 1:51 PM, Enrico Granata <egranata at apple.com> wrote:
>>
>>> CallMethod is right for C++, but for ObjC it would be CallSelector. I don’t think ObjC even has the notion of method in its lexicon.
>>
>> Yeah, the ObjC guys are pretty sloppy about their nomenclature (is it a method, is it a message...) And the selector defines the method, so I don't think you'd really need two calls.
>>
>>>
>>> Also, dealing with the arguments is going to be tricky.
>>> Problems I can see at a glance:
>>> - how do you deal with each SBValue while making the string? expression path? numeric value + a cast? neither way looks perfect at a glance
>>
>> I don't think you would make up a string. You would implement this lower down than that, where we are directly populating the "arguments structure" that we are going to call, a la the Clang Functions. And by the time we get there, we would have the method signature, so we'd know how to interpret the SBValues from the input arguments.
>>
>>> - for ObjC you need to also extract the “names of the arguments” (i.e. foo:arg1 bar:arg2 baz:arg3), while in C++ (arg1,arg2,arg3) is enough
>>
>> Again, you would be consing up a call to objc_msgSend with the arguments passed directly, so that would not be an issue.
>
> If you go that route, you will have to take care of all the special cases introduced by the ABI (i.e calling the right objc_msgSend variant depending the arguments type and the return type).
>
Yes but that's actually not terribly difficult, there aren't all that many variants of objc_msgSend, and the decisions among them are not that complex.
Jim
> -- Jean-Daniel
>
>
>
>
More information about the lldb-dev
mailing list