Getting the address of a function


I’m trying to create an LLDB command that sets an internal breakpoint for a function, and then executes some code, but I’m having come difficulties…

I’ve seen the expression command, which does something close to what I want to do after the breakpoint, but I have some doubts. I want the code to be able to return from the function where it’s called, but the “target->EvaluateExpression” doesn’t let the code return from it (while I would like to execute code with something like “if (condition) return NULL; more code…”). Is there a way to compile arbitrary code (with return statements) and execute it?

Is there a way to get a clang FunctionDecl from an Address obtained from a BreakpointLocation?

My final purpose is to be able to redefine functions on-the-fly (with caveats for inlined functions, etc). The only way I saw that could work was this one… Did I miss another easier way?