diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py
index 765af26686a99727fad20d66aa25f0e0e2140e34..96e1a9cd9d2dc61271b81f9a5cccc42c53884e86 100644
--- a/share/qtcreator/debugger/lldbbridge.py
+++ b/share/qtcreator/debugger/lldbbridge.py
@@ -48,12 +48,13 @@ from misctypes import *
 from boosttypes import *
 from creatortypes import *
 
-
-proc = subprocess.Popen(args=[sys.argv[1], '-P'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+lldbCmd = 'lldb'
+if len(sys.argv) > 1:
+    lldbCmd = sys.argv[1]
+proc = subprocess.Popen(args=[lldbCmd, '-P'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 (path, error) = proc.communicate()
-
 if error.startswith('lldb: invalid option -- P'):
-    sys.stdout.write('msg=\'Could not run "%s -P". Trying to find lldb.so from Xcode.\'\n' % sys.argv[1])
+    sys.stdout.write('msg=\'Could not run "%s -P". Trying to find lldb.so from Xcode.\'\n' % lldbCmd)
     proc = subprocess.Popen(args=['xcode-select', '--print-path'],
         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (path, error) = proc.communicate()
@@ -65,7 +66,6 @@ if error.startswith('lldb: invalid option -- P'):
         path = path.strip() + '/../SharedFrameworks/LLDB.framework/Versions/A/Resources/Python/'
         sys.stdout.write('msg=\'Using fallback at %s\'\n' % path)
 
-#sys.path.append(path)
 sys.path.insert(1, path.strip())
 
 import lldb
@@ -1729,9 +1729,9 @@ def testit():
     db.reportVariables()
     #db.report("DUMPER=%s" % qqDumpers)
 
-
-if len(sys.argv) > 2:
-    testit()
-else:
-    doit()
+if __name__ == "__main__":
+    if len(sys.argv) > 2:
+        testit()
+    else:
+        doit()