[lldb-dev] Calling const char* functions from within lldb

Carlo Kok ck at remobjects.com
Tue Mar 5 10:43:59 PST 2013


Op 5-3-2013 19:25, Sean Callanan schreef:
> Carlo,
>
> you can see an example of ClangFunctions at work in
> AppleObjCRuntime::GetObjectDescription, although it doesn’t provide a
> good example of the following wrinkle:
>
> If you make a value object with your string, the string value will not
> be in target memory and calling the function will result in a crash.
> You need to manually call Process::AllocateMemory and put your string in
> there, and then create a value with type char* containing the pointer to
> your string.
>
> As Greg says, though, if you are trying to do run ClangFunctions
> piecemeal to replicate the action of an expression, then you are not
> going to win vs. just parsing the expression and running it.
>


Thanks for the helpful comments (both of you). For this particular 
expression I wanted to get the 'name' property on an NSException so I 
can show both the Name and class for an exception message in the IDE, 
which works now:
https://dl.dropbox.com/u/29927944/ShareX/2013-03/2013-03-05_19-39-40.png

I call the sel_registerName with allocateMemory to get a selector, cache 
the selector name (per process), releasememroy to release that, and 
after that just call msgSend. As Greg said there's no convenient 
"ClangJITCode" class yet I can use for this.


for the "Watches" support though, I don't think there is a good way to 
do it yet, except maybe converting the Pascal input to Objc on the fly 
and calling evaluate expression api. I can't require my users to enter 
watches in with a c syntax.

Thanks,
--
Carlo Kok



More information about the lldb-dev mailing list