[lldb-dev] How to use command regex in this situation?

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Mon May 16 14:31:29 PDT 2016


Regular expression commands are not multi-line commands. So your approach of doing:

(lldb) command regex jspatch 's/(.+)/p (id)[JPEngine evaluateScript:@"%1"]/'

won't work with:

jspatch 'var a = 10
var b = 20
a = a + b'

because this will get executed as:

(lldb) jspatch 'var a = 10
(lldb) var b = 20
(lldb) a = a + b'

You can run this as:

(lldb) jspatch 'var a = 10; var b = 20; a = a+b;'

Can't you? Or you might be able to put newlines in as escaped sequences:

(lldb) jspatch 'var a = 10\nvar b = 20\na = a+b'

The best thing you can probably do is write this as a python command. See http://lldb.llvm.org/python-reference.html in the section named "CREATE A NEW LLDB COMMAND USING A PYTHON FUNCTION". This will allow you to make a new command line command that calls into a python module and runs the code. You can use the builtin "raw_input" command to fetch as many lines as you need and then run the expression from python as needed.




> On May 12, 2016, at 4:04 AM, Karl Peng via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Actually I posted a question in stackoverflow?
> 
> Can any one  give me some suggestion?
> 
> Thanks
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev



More information about the lldb-dev mailing list