[lldb-dev] Call c/objc functions with the API

Enrico Granata egranata at apple.com
Fri Feb 22 13:51:39 PST 2013


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.

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
- 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

Of course, there are ways around these issues, but I am not sure this is useful enough to warrant the work required to get it right.

The data formatters need a much more constrained subset of this functionality, so they implement their own wrapper.
Any special subset should be trivial to implement, the general case looks tricky.

Enrico Granata
✉ egranata@.com
✆ 27683

On Feb 22, 2013, at 12:14 PM, Jim Ingham <jingham at apple.com> wrote:

> I'm not arguing for this, but you could do a fairly straightforward API like:
> 
> SBValue
> SBValue::CallMethod(const char *methodName, SBValueList arguments);
> 
> This would only work if the SBValue was a C++ or ObjC object.  In the ObjC case "methodName" would be the selector, and the value list would have to be in parameter order.  
> 
> I can see this being useful, though probably under the covers it would take some work to get it right...
> 
> Jim
> 
> On Feb 22, 2013, at 11:51 AM, Filipe Cabecinhas <filcab+lldb-dev at gmail.com> wrote:
> 
>> I also don't think it should be in the SB layer. There's lots of stuff to deal with (arguments and their types, variable arguments selectors/functions, etc). I think creating an expression is better (maybe we can use clang so one doesn't have to generate an expression string?).
>> 
>> Regards,
>> 
>>  filipe
>> 
>> 
>> On Fri, Feb 22, 2013 at 10:23 AM, Enrico Granata <egranata at apple.com> wrote:
>> Currently, no.
>> You would have to craft your own expression and run it.
>> 
>> The C++ data formatters have their own helper functions to do so. You can refer to lldb_private::formatters::ExtractValueFromObjCExpression for an example.
>> 
>> I am not sure if this kind of API belongs in the SB layer. Ideas?
>> 
>> Enrico Granata
>> ✉ egranata@.com
>> ✆ 27683
>> 
>> On Feb 22, 2013, at 5:29 AM, Carlo Kok <ck at remobjects.com> wrote:
>> 
>>> Does the api expose any way to execute an objc selector a given value (SBValue)?  (for example I have an NSException instance in an SBValue, and want to call "name" on it).
>>> 
>>> 
>>> What about global (c) functions?
>>> 
>>> 
>>> If not the api, how can I do the equivalent with the underlying api?
>>> 
>>> 
>>> Thanks,
>>> --
>>> 
>>> Carlo Kok
>>> 
>>> 
>>> _______________________________________________
>>> lldb-dev mailing list
>>> lldb-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>> 
>> 
>> _______________________________________________
>> lldb-dev mailing list
>> lldb-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>> 
>> 
>> _______________________________________________
>> lldb-dev mailing list
>> lldb-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20130222/8f385fa2/attachment.html>


More information about the lldb-dev mailing list