.lldbinit and lldb-version-specific configuration

Hi all,

Do we have any existing way to handle conditionally making settings based on lldb version, within the .lldbinit system?

The specific case I have in mind is helping support side-by-side lldb installs (e.g. on debian/ubuntu) where, across lldb 3.4, 3.5 and 3.6, the python path to the correct lldb python module differs. Right now, the default behavior is that lldb 3.5 and 3.6 are picking up the older 3.4 lldb python library and choking due to the mismatch.

Thanks for any thoughts on this!


Check out CommandInterpreter::SourceInitFile. It looks like it uses the following algorithm:

You will have to import a python module and check the lldb version from python to do any conditional stuff that is based on the LLDB version. There is nothing in the command interpreter (no flow control or conditionals).


Ok. It might be possible to have a distribution bundle some kind of init that does this to manage side-by-side installations. I may bounce this idea around with Sylvestre and see if I can figure out how to make that work.

(lldb) script print lldb.SBDebugger.GetVersionString()

You should be able to use that in your script to do something like:

def __lldb_init_module (debugger, dict):
    version = lldb.SBDebugger.GetVersionString()
    if version contains '123':
        debugger.HandleCommand("do one thing")
  debugger.HandleCommand("do another")

Then you can save this somewhere and add a "command script import /path/to/initlldb.py" to your ~/.lldbinit file.


Thanks, Greg!