[lldb-dev] lldb batch mode
jingham at apple.com
Mon Apr 23 11:14:04 PDT 2012
The lldb command line tool doesn't have a batch mode. Feel free to file a bug on this (or just add it yourself...) We haven't gotten around to this yet because most of the sort of thing you would do with more complex gdb scripts, we envisioned doing in Python instead.
What you want to do would be quite easy in Python. For instance, examples/python/disass.py has a quick example of launching a process & stopping at a breakpoint. That does pretty much what you want, you just want to catch any stop state bug eStateExited, enumerate the threads - there's an iterator for that in the process, so you can just do:
for t in process:
and then get the backtrace for the thread. There's a routine in test/lldbutils.py (print_stacktrace) that does a fairly fancy job of this, and of course you can always get the command interpreter from the debugger object and call HandleCommand to run an lldb command-line command... The data for the command comes back in the result object so you can print it to stdout, or some log file or whatever you want to do with it.
lldb's Python API's do have documentation that you can access in Python, or just look at the files in include/lldb/API, the C++ -> Python translation is pretty straight-forward.
has some info on how to load the lldb module into stand-alone Python, which is probably what you want to do.
Hope this helps.
On Apr 20, 2012, at 10:55 PM, Greg Hazel wrote:
> I'd like to run my process in lldb automatically, and print a backtrace if an error occurs but exit normally otherwise. This sort of thing can be achieved (sloppily) with gdb using something like this:
> echo -e "run\nthread apply all bt" > foo.gdb
> gdb -batch -x foo.gdb my_process
> Is something like this possible? I'd be willing to write some Python if needed.
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
More information about the lldb-dev