[lldb-dev] [RFC} [Patch] SBFunction::ExecuteFunction

Carlo Kok ck at remobjects.com
Tue Sep 23 01:02:32 PDT 2014


On Sat, 20 Sep 2014 00:16:12 +0200, Greg Clayton <gclayton at apple.com>  
wrote:

> I just spoke with Jim Ingham and he change my mind. If, every time you  
> stop, you want to call a function, this feature could come in handy.
>
> Behind the curtains it should:
> - install a ClangFunction down in the host and leave it there so it can  
> be called (we do this internally with a few functions)
> - allow it to be called with a SBValueList. All arguments will need to  
> manually be supplied (the "this", and ObjC "cmd" and "selector"  
> arguments, etc)
> - it should be able to be uninstalled from the target

That gives a patch like the attached patch.

What I changed:
  * Target has a method to get & cache a selector
  * SBFunction has an ExecuteFunction api

+    lldb::SBValue ExecuteFunction(lldb::SBFrame &frame,
+                                  lldb::SBValueList arguments,
+                                  lldb::SBStream &errors,
+                                  lldb::SBExpressionOptions options,
+                                  bool reusable);

  * SBTypeMemberFunction has an ExecuteFunction api:
+    lldb::SBValue ExecuteFunction(lldb::SBFrame &frame,
+                                  lldb::SBValue self,
+                                  lldb::SBValueList arguments,
+                                  lldb::SBStream &errors,
+                                  lldb::SBExpressionOptions options,
+                                  bool reusable);

Atm, it only supports ObjC methods and it prepares the selector for you,  
just requiring a "Self" valu and optional arguments, the reason I did this  
is because it's rather tricky to get a selector and wrap it in an SBValue  
 from the calling side, and lldb itself allows for easier caching.

In ClangFunction I added GetCanonicalType() to the result & parameter  
types. This at least lets me use it with a selector like:

typedef int MyInteger;

+(MyInteger)MyFunction;

as it turns that into int instead of MyInteger. I'm still looking for a  
way to tell ClangFunction about the type aliases lldb knows about though  
(it's fully aware of MyInteger, it just fails on it when used from  
ClangFunction).

Feedback and ideas for the typedef issue appreciated.

-- 
Carlo Kok
RemObjects Software
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lldb-execute-function-patch.patch
Type: application/octet-stream
Size: 18543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140923/1e55947f/attachment.obj>


More information about the lldb-dev mailing list