lldb: allow lldbbridge.py to be directly imported in python

Change-Id: Ib0bcb4dd708e89cebe12407a3f8e375c79664a74
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Fawzi Mohamed
2013-10-31 10:06:14 +01:00
parent fe0bddbd63
commit ac17b73c20

View File

@@ -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:
if __name__ == "__main__":
if len(sys.argv) > 2:
testit()
else:
else:
doit()