[PATCH] D36347: Add new script to launch lldb and set breakpoints for diagnostics all diagnostics seen.

Greg Clayton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 20 08:29:33 PDT 2017


clayborg added a comment.

Please do convert to python. Just know that you can use "lldb -P" to get the python path that is needed in order to do "import lldb" in the python script. So you can try doing a "import lldb", and if that fails, catch the exception, run "lldb -P", add that path to the python path:

  try:
      # Just try for LLDB in case the lldb module is already in the python search
      # paths
      import lldb
  except ImportError:
      # We failed to import lldb automatically. Run lldb with the -P option so
      # it tells us the python path we should use.
      lldb_py_dirs = list()
      (status, output) = commands.getstatusoutput("lldb -P")
      dir = os.path.realpath(output)
      if status == 0 and os.path.isdir(dir):
          lldb_py_dirs.append(dir)
      success = False
      for lldb_py_dir in lldb_py_dirs:
          if os.path.exists(lldb_py_dir):
              if not (sys.path.__contains__(lldb_py_dir)):
                  sys.path.append(lldb_py_dir)
                  try:
                      import lldb
                  except ImportError:
                      pass
                  else:
                      success = True
                      break
      if not success:
          print("error: couldn't locate the 'lldb' module, please set "
                "PYTHONPATH correctly")
          sys.exit(1)


https://reviews.llvm.org/D36347





More information about the cfe-commits mailing list