aboutsummaryrefslogtreecommitdiff
path: root/scripts/Python
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Python')
-rw-r--r--scripts/Python/android/host_art_bt.py391
-rwxr-xr-xscripts/Python/finish-swig-Python-LLDB.sh2
-rw-r--r--scripts/Python/finishSwigPythonLLDB.py289
-rw-r--r--scripts/Python/modify-python-lldb.py118
-rw-r--r--scripts/Python/modules/CMakeLists.txt2
-rw-r--r--scripts/Python/modules/readline/readline.cpp71
-rw-r--r--scripts/Python/prepare_binding_Python.py62
-rwxr-xr-xscripts/Python/remote-build.py34
-rw-r--r--scripts/Python/use_lldb_suite.py1
9 files changed, 570 insertions, 400 deletions
diff --git a/scripts/Python/android/host_art_bt.py b/scripts/Python/android/host_art_bt.py
index 0893662869f2..e359829fe5bd 100644
--- a/scripts/Python/android/host_art_bt.py
+++ b/scripts/Python/android/host_art_bt.py
@@ -10,183 +10,228 @@ import re
import lldb
+
def host_art_bt(debugger, command, result, internal_dict):
- prettified_frames = []
- lldb_frame_index = 0
- art_frame_index = 0
- target = debugger.GetSelectedTarget()
- process = target.GetProcess()
- thread = process.GetSelectedThread()
- while lldb_frame_index < thread.GetNumFrames():
- frame = thread.GetFrameAtIndex(lldb_frame_index)
- if frame.GetModule() and re.match(r'JIT\(.*?\)', frame.GetModule().GetFileSpec().GetFilename()):
- # Compiled Java frame
-
- # Get function/filename/lineno from symbol context
- symbol = frame.GetSymbol()
- if not symbol:
- print 'No symbol info for compiled Java frame: ', frame
- sys.exit(1)
- line_entry = frame.GetLineEntry()
- prettified_frames.append({
- 'function': symbol.GetName(),
- 'file' : str(line_entry.GetFileSpec()) if line_entry else None,
- 'line' : line_entry.GetLine() if line_entry else -1
- })
-
- # Skip art frames
- while True:
- art_stack_visitor = frame.EvaluateExpression("""struct GetStackVisitor : public StackVisitor { GetStackVisitor(int depth_) : StackVisitor(Thread::Current(), NULL), depth(depth_) {} bool VisitFrame() { if (cur_depth_ == depth) { return false; } else { return true; } } int depth; }; GetStackVisitor visitor(""" + str(art_frame_index) + """); visitor.WalkStack(true); visitor""")
- art_method = frame.EvaluateExpression(art_stack_visitor.GetName() + """.GetMethod()""")
- if art_method.GetValueAsUnsigned() != 0:
- art_method_name = frame.EvaluateExpression("""art::PrettyMethod(""" + art_method.GetName() + """, true)""")
- art_method_name_data = frame.EvaluateExpression(art_method_name.GetName() + """.c_str()""").GetValueAsUnsigned()
- art_method_name_size = frame.EvaluateExpression(art_method_name.GetName() + """.length()""").GetValueAsUnsigned()
- error = lldb.SBError()
- art_method_name = process.ReadCStringFromMemory(art_method_name_data, art_method_name_size + 1, error)
- if not error.Success:
- print 'Failed to read method name'
- sys.exit(1)
- if art_method_name != symbol.GetName():
- print 'Function names in native symbol and art runtime stack do not match: ', symbol.GetName(), ' != ', art_method_name
- art_frame_index = art_frame_index + 1
- break
- art_frame_index = art_frame_index + 1
-
- # Skip native frames
- lldb_frame_index = lldb_frame_index + 1
- if lldb_frame_index < thread.GetNumFrames():
+ prettified_frames = []
+ lldb_frame_index = 0
+ art_frame_index = 0
+ target = debugger.GetSelectedTarget()
+ process = target.GetProcess()
+ thread = process.GetSelectedThread()
+ while lldb_frame_index < thread.GetNumFrames():
frame = thread.GetFrameAtIndex(lldb_frame_index)
- if frame.GetModule() and re.match(r'JIT\(.*?\)', frame.GetModule().GetFileSpec().GetFilename()):
- # Another compile Java frame
- # Don't skip; leave it to the next iteration
- continue
- elif frame.GetSymbol() and (frame.GetSymbol().GetName() == 'art_quick_invoke_stub' or frame.GetSymbol().GetName() == 'art_quick_invoke_static_stub'):
- # art_quick_invoke_stub / art_quick_invoke_static_stub
- # Skip until we get past the next ArtMethod::Invoke()
- while True:
+ if frame.GetModule() and re.match(r'JIT\(.*?\)',
+ frame.GetModule().GetFileSpec().GetFilename()):
+ # Compiled Java frame
+
+ # Get function/filename/lineno from symbol context
+ symbol = frame.GetSymbol()
+ if not symbol:
+ print 'No symbol info for compiled Java frame: ', frame
+ sys.exit(1)
+ line_entry = frame.GetLineEntry()
+ prettified_frames.append({
+ 'function': symbol.GetName(),
+ 'file': str(line_entry.GetFileSpec()) if line_entry else None,
+ 'line': line_entry.GetLine() if line_entry else -1
+ })
+
+ # Skip art frames
+ while True:
+ art_stack_visitor = frame.EvaluateExpression(
+ """struct GetStackVisitor : public StackVisitor { GetStackVisitor(int depth_) : StackVisitor(Thread::Current(), NULL), depth(depth_) {} bool VisitFrame() { if (cur_depth_ == depth) { return false; } else { return true; } } int depth; }; GetStackVisitor visitor(""" +
+ str(art_frame_index) +
+ """); visitor.WalkStack(true); visitor""")
+ art_method = frame.EvaluateExpression(
+ art_stack_visitor.GetName() + """.GetMethod()""")
+ if art_method.GetValueAsUnsigned() != 0:
+ art_method_name = frame.EvaluateExpression(
+ """art::PrettyMethod(""" + art_method.GetName() + """, true)""")
+ art_method_name_data = frame.EvaluateExpression(
+ art_method_name.GetName() + """.c_str()""").GetValueAsUnsigned()
+ art_method_name_size = frame.EvaluateExpression(
+ art_method_name.GetName() + """.length()""").GetValueAsUnsigned()
+ error = lldb.SBError()
+ art_method_name = process.ReadCStringFromMemory(
+ art_method_name_data, art_method_name_size + 1, error)
+ if not error.Success:
+ print 'Failed to read method name'
+ sys.exit(1)
+ if art_method_name != symbol.GetName():
+ print 'Function names in native symbol and art runtime stack do not match: ', symbol.GetName(), ' != ', art_method_name
+ art_frame_index = art_frame_index + 1
+ break
+ art_frame_index = art_frame_index + 1
+
+ # Skip native frames
lldb_frame_index = lldb_frame_index + 1
- if lldb_frame_index >= thread.GetNumFrames():
- print 'ArtMethod::Invoke not found below art_quick_invoke_stub/art_quick_invoke_static_stub'
- sys.exit(1)
- frame = thread.GetFrameAtIndex(lldb_frame_index)
- if frame.GetSymbol() and frame.GetSymbol().GetName() == 'art::mirror::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)':
- lldb_frame_index = lldb_frame_index + 1
- break
- else:
- print 'Invalid frame below compiled Java frame: ', frame
- elif frame.GetSymbol() and frame.GetSymbol().GetName() == 'art_quick_generic_jni_trampoline':
- # Interpreted JNI frame for x86_64
-
- # Skip art frames
- while True:
- art_stack_visitor = frame.EvaluateExpression("""struct GetStackVisitor : public StackVisitor { GetStackVisitor(int depth_) : StackVisitor(Thread::Current(), NULL), depth(depth_) {} bool VisitFrame() { if (cur_depth_ == depth) { return false; } else { return true; } } int depth; }; GetStackVisitor visitor(""" + str(art_frame_index) + """); visitor.WalkStack(true); visitor""")
- art_method = frame.EvaluateExpression(art_stack_visitor.GetName() + """.GetMethod()""")
- if art_method.GetValueAsUnsigned() != 0:
- # Get function/filename/lineno from ART runtime
- art_method_name = frame.EvaluateExpression("""art::PrettyMethod(""" + art_method.GetName() + """, true)""")
- art_method_name_data = frame.EvaluateExpression(art_method_name.GetName() + """.c_str()""").GetValueAsUnsigned()
- art_method_name_size = frame.EvaluateExpression(art_method_name.GetName() + """.length()""").GetValueAsUnsigned()
- error = lldb.SBError()
- function = process.ReadCStringFromMemory(art_method_name_data, art_method_name_size + 1, error)
-
- prettified_frames.append({
- 'function': function,
- 'file' : None,
- 'line' : -1
- })
-
- art_frame_index = art_frame_index + 1
- break
- art_frame_index = art_frame_index + 1
-
- # Skip native frames
- lldb_frame_index = lldb_frame_index + 1
- if lldb_frame_index < thread.GetNumFrames():
- frame = thread.GetFrameAtIndex(lldb_frame_index)
- if frame.GetSymbol() and (frame.GetSymbol().GetName() == 'art_quick_invoke_stub' or frame.GetSymbol().GetName() == 'art_quick_invoke_static_stub'):
- # art_quick_invoke_stub / art_quick_invoke_static_stub
- # Skip until we get past the next ArtMethod::Invoke()
- while True:
+ if lldb_frame_index < thread.GetNumFrames():
+ frame = thread.GetFrameAtIndex(lldb_frame_index)
+ if frame.GetModule() and re.match(
+ r'JIT\(.*?\)', frame.GetModule().GetFileSpec().GetFilename()):
+ # Another compile Java frame
+ # Don't skip; leave it to the next iteration
+ continue
+ elif frame.GetSymbol() and (frame.GetSymbol().GetName() == 'art_quick_invoke_stub' or frame.GetSymbol().GetName() == 'art_quick_invoke_static_stub'):
+ # art_quick_invoke_stub / art_quick_invoke_static_stub
+ # Skip until we get past the next ArtMethod::Invoke()
+ while True:
+ lldb_frame_index = lldb_frame_index + 1
+ if lldb_frame_index >= thread.GetNumFrames():
+ print 'ArtMethod::Invoke not found below art_quick_invoke_stub/art_quick_invoke_static_stub'
+ sys.exit(1)
+ frame = thread.GetFrameAtIndex(lldb_frame_index)
+ if frame.GetSymbol() and frame.GetSymbol().GetName(
+ ) == 'art::mirror::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)':
+ lldb_frame_index = lldb_frame_index + 1
+ break
+ else:
+ print 'Invalid frame below compiled Java frame: ', frame
+ elif frame.GetSymbol() and frame.GetSymbol().GetName() == 'art_quick_generic_jni_trampoline':
+ # Interpreted JNI frame for x86_64
+
+ # Skip art frames
+ while True:
+ art_stack_visitor = frame.EvaluateExpression(
+ """struct GetStackVisitor : public StackVisitor { GetStackVisitor(int depth_) : StackVisitor(Thread::Current(), NULL), depth(depth_) {} bool VisitFrame() { if (cur_depth_ == depth) { return false; } else { return true; } } int depth; }; GetStackVisitor visitor(""" +
+ str(art_frame_index) +
+ """); visitor.WalkStack(true); visitor""")
+ art_method = frame.EvaluateExpression(
+ art_stack_visitor.GetName() + """.GetMethod()""")
+ if art_method.GetValueAsUnsigned() != 0:
+ # Get function/filename/lineno from ART runtime
+ art_method_name = frame.EvaluateExpression(
+ """art::PrettyMethod(""" + art_method.GetName() + """, true)""")
+ art_method_name_data = frame.EvaluateExpression(
+ art_method_name.GetName() + """.c_str()""").GetValueAsUnsigned()
+ art_method_name_size = frame.EvaluateExpression(
+ art_method_name.GetName() + """.length()""").GetValueAsUnsigned()
+ error = lldb.SBError()
+ function = process.ReadCStringFromMemory(
+ art_method_name_data, art_method_name_size + 1, error)
+
+ prettified_frames.append({
+ 'function': function,
+ 'file': None,
+ 'line': -1
+ })
+
+ art_frame_index = art_frame_index + 1
+ break
+ art_frame_index = art_frame_index + 1
+
+ # Skip native frames
lldb_frame_index = lldb_frame_index + 1
- if lldb_frame_index >= thread.GetNumFrames():
- print 'ArtMethod::Invoke not found below art_quick_invoke_stub/art_quick_invoke_static_stub'
- sys.exit(1)
- frame = thread.GetFrameAtIndex(lldb_frame_index)
- if frame.GetSymbol() and frame.GetSymbol().GetName() == 'art::mirror::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)':
- lldb_frame_index = lldb_frame_index + 1
- break
+ if lldb_frame_index < thread.GetNumFrames():
+ frame = thread.GetFrameAtIndex(lldb_frame_index)
+ if frame.GetSymbol() and (frame.GetSymbol().GetName() ==
+ 'art_quick_invoke_stub' or frame.GetSymbol().GetName() == 'art_quick_invoke_static_stub'):
+ # art_quick_invoke_stub / art_quick_invoke_static_stub
+ # Skip until we get past the next ArtMethod::Invoke()
+ while True:
+ lldb_frame_index = lldb_frame_index + 1
+ if lldb_frame_index >= thread.GetNumFrames():
+ print 'ArtMethod::Invoke not found below art_quick_invoke_stub/art_quick_invoke_static_stub'
+ sys.exit(1)
+ frame = thread.GetFrameAtIndex(lldb_frame_index)
+ if frame.GetSymbol() and frame.GetSymbol().GetName(
+ ) == 'art::mirror::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)':
+ lldb_frame_index = lldb_frame_index + 1
+ break
+ else:
+ print 'Invalid frame below compiled Java frame: ', frame
+ elif frame.GetSymbol() and re.search(r'art::interpreter::', frame.GetSymbol().GetName()):
+ # Interpreted Java frame
+
+ while True:
+ lldb_frame_index = lldb_frame_index + 1
+ if lldb_frame_index >= thread.GetNumFrames():
+ print 'art::interpreter::Execute not found in interpreter frame'
+ sys.exit(1)
+ frame = thread.GetFrameAtIndex(lldb_frame_index)
+ if frame.GetSymbol() and frame.GetSymbol().GetName(
+ ) == 'art::interpreter::Execute(art::Thread*, art::MethodHelper&, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue)':
+ break
+
+ # Skip art frames
+ while True:
+ art_stack_visitor = frame.EvaluateExpression(
+ """struct GetStackVisitor : public StackVisitor { GetStackVisitor(int depth_) : StackVisitor(Thread::Current(), NULL), depth(depth_) {} bool VisitFrame() { if (cur_depth_ == depth) { return false; } else { return true; } } int depth; }; GetStackVisitor visitor(""" +
+ str(art_frame_index) +
+ """); visitor.WalkStack(true); visitor""")
+ art_method = frame.EvaluateExpression(
+ art_stack_visitor.GetName() + """.GetMethod()""")
+ if art_method.GetValueAsUnsigned() != 0:
+ # Get function/filename/lineno from ART runtime
+ art_method_name = frame.EvaluateExpression(
+ """art::PrettyMethod(""" + art_method.GetName() + """, true)""")
+ art_method_name_data = frame.EvaluateExpression(
+ art_method_name.GetName() + """.c_str()""").GetValueAsUnsigned()
+ art_method_name_size = frame.EvaluateExpression(
+ art_method_name.GetName() + """.length()""").GetValueAsUnsigned()
+ error = lldb.SBError()
+ function = process.ReadCStringFromMemory(
+ art_method_name_data, art_method_name_size + 1, error)
+
+ line = frame.EvaluateExpression(
+ art_stack_visitor.GetName() +
+ """.GetMethod()->GetLineNumFromDexPC(""" +
+ art_stack_visitor.GetName() +
+ """.GetDexPc(true))""").GetValueAsUnsigned()
+
+ file_name = frame.EvaluateExpression(
+ art_method.GetName() + """->GetDeclaringClassSourceFile()""")
+ file_name_data = file_name.GetValueAsUnsigned()
+ file_name_size = frame.EvaluateExpression(
+ """(size_t)strlen(""" + file_name.GetName() + """)""").GetValueAsUnsigned()
+ error = lldb.SBError()
+ file_name = process.ReadCStringFromMemory(
+ file_name_data, file_name_size + 1, error)
+ if not error.Success():
+ print 'Failed to read source file name'
+ sys.exit(1)
+
+ prettified_frames.append({
+ 'function': function,
+ 'file': file_name,
+ 'line': line
+ })
+
+ art_frame_index = art_frame_index + 1
+ break
+ art_frame_index = art_frame_index + 1
+
+ # Skip native frames
+ while True:
+ lldb_frame_index = lldb_frame_index + 1
+ if lldb_frame_index >= thread.GetNumFrames():
+ print 'Can not get past interpreter native frames'
+ sys.exit(1)
+ frame = thread.GetFrameAtIndex(lldb_frame_index)
+ if frame.GetSymbol() and not re.search(
+ r'art::interpreter::', frame.GetSymbol().GetName()):
+ break
else:
- print 'Invalid frame below compiled Java frame: ', frame
- elif frame.GetSymbol() and re.search(r'art::interpreter::', frame.GetSymbol().GetName()):
- # Interpreted Java frame
-
- while True:
- lldb_frame_index = lldb_frame_index + 1
- if lldb_frame_index >= thread.GetNumFrames():
- print 'art::interpreter::Execute not found in interpreter frame'
- sys.exit(1)
- frame = thread.GetFrameAtIndex(lldb_frame_index)
- if frame.GetSymbol() and frame.GetSymbol().GetName() == 'art::interpreter::Execute(art::Thread*, art::MethodHelper&, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue)':
- break
-
- # Skip art frames
- while True:
- art_stack_visitor = frame.EvaluateExpression("""struct GetStackVisitor : public StackVisitor { GetStackVisitor(int depth_) : StackVisitor(Thread::Current(), NULL), depth(depth_) {} bool VisitFrame() { if (cur_depth_ == depth) { return false; } else { return true; } } int depth; }; GetStackVisitor visitor(""" + str(art_frame_index) + """); visitor.WalkStack(true); visitor""")
- art_method = frame.EvaluateExpression(art_stack_visitor.GetName() + """.GetMethod()""")
- if art_method.GetValueAsUnsigned() != 0:
- # Get function/filename/lineno from ART runtime
- art_method_name = frame.EvaluateExpression("""art::PrettyMethod(""" + art_method.GetName() + """, true)""")
- art_method_name_data = frame.EvaluateExpression(art_method_name.GetName() + """.c_str()""").GetValueAsUnsigned()
- art_method_name_size = frame.EvaluateExpression(art_method_name.GetName() + """.length()""").GetValueAsUnsigned()
- error = lldb.SBError()
- function = process.ReadCStringFromMemory(art_method_name_data, art_method_name_size + 1, error)
-
- line = frame.EvaluateExpression(art_stack_visitor.GetName() + """.GetMethod()->GetLineNumFromDexPC(""" + art_stack_visitor.GetName() + """.GetDexPc(true))""").GetValueAsUnsigned()
-
- file_name = frame.EvaluateExpression(art_method.GetName() + """->GetDeclaringClassSourceFile()""")
- file_name_data = file_name.GetValueAsUnsigned()
- file_name_size = frame.EvaluateExpression("""(size_t)strlen(""" + file_name.GetName() + """)""").GetValueAsUnsigned()
- error = lldb.SBError()
- file_name = process.ReadCStringFromMemory(file_name_data, file_name_size + 1, error)
- if not error.Success():
- print 'Failed to read source file name'
- sys.exit(1)
-
- prettified_frames.append({
- 'function': function,
- 'file' : file_name,
- 'line' : line
- })
-
- art_frame_index = art_frame_index + 1
- break
- art_frame_index = art_frame_index + 1
-
- # Skip native frames
- while True:
- lldb_frame_index = lldb_frame_index + 1
- if lldb_frame_index >= thread.GetNumFrames():
- print 'Can not get past interpreter native frames'
- sys.exit(1)
- frame = thread.GetFrameAtIndex(lldb_frame_index)
- if frame.GetSymbol() and not re.search(r'art::interpreter::', frame.GetSymbol().GetName()):
- break
- else:
- # Other frames. Add them as-is.
- frame = thread.GetFrameAtIndex(lldb_frame_index)
- lldb_frame_index = lldb_frame_index + 1
- if frame.GetModule():
- module_name = frame.GetModule().GetFileSpec().GetFilename()
- if not module_name in ['libartd.so', 'dalvikvm32', 'dalvikvm64', 'libc.so.6']:
- prettified_frames.append({
- 'function': frame.GetSymbol().GetName() if frame.GetSymbol() else None,
- 'file' : str(frame.GetLineEntry().GetFileSpec()) if frame.GetLineEntry() else None,
- 'line' : frame.GetLineEntry().GetLine() if frame.GetLineEntry() else -1
- })
-
- for prettified_frame in prettified_frames:
- print prettified_frame['function'], prettified_frame['file'], prettified_frame['line']
+ # Other frames. Add them as-is.
+ frame = thread.GetFrameAtIndex(lldb_frame_index)
+ lldb_frame_index = lldb_frame_index + 1
+ if frame.GetModule():
+ module_name = frame.GetModule().GetFileSpec().GetFilename()
+ if not module_name in [
+ 'libartd.so',
+ 'dalvikvm32',
+ 'dalvikvm64',
+ 'libc.so.6']:
+ prettified_frames.append({
+ 'function': frame.GetSymbol().GetName() if frame.GetSymbol() else None,
+ 'file': str(frame.GetLineEntry().GetFileSpec()) if frame.GetLineEntry() else None,
+ 'line': frame.GetLineEntry().GetLine() if frame.GetLineEntry() else -1
+ })
+
+ for prettified_frame in prettified_frames:
+ print prettified_frame['function'], prettified_frame['file'], prettified_frame['line']
+
def __lldb_init_module(debugger, internal_dict):
- debugger.HandleCommand('command script add -f host_art_bt.host_art_bt host_art_bt')
+ debugger.HandleCommand(
+ 'command script add -f host_art_bt.host_art_bt host_art_bt')
diff --git a/scripts/Python/finish-swig-Python-LLDB.sh b/scripts/Python/finish-swig-Python-LLDB.sh
index 92b99181c7cc..31bc2b349daf 100755
--- a/scripts/Python/finish-swig-Python-LLDB.sh
+++ b/scripts/Python/finish-swig-Python-LLDB.sh
@@ -179,7 +179,6 @@ then
echo "Creating symlink for darwin-debug"
fi
cd "${framework_python_dir}"
- ln -s "../../../../bin/lldb-launcher" darwin-debug
else
if [ $Debug -eq 1 ]
then
@@ -273,6 +272,7 @@ create_python_package "/runtime" ""
# lldb/formatters
# having these files copied here ensures that lldb/formatters is a valid package itself
package_files="${SRC_ROOT}/examples/summaries/cocoa/cache.py
+${SRC_ROOT}/examples/summaries/synth.py
${SRC_ROOT}/examples/summaries/cocoa/metrics.py
${SRC_ROOT}/examples/summaries/cocoa/attrib_fromdict.py
${SRC_ROOT}/examples/summaries/cocoa/Logger.py"
diff --git a/scripts/Python/finishSwigPythonLLDB.py b/scripts/Python/finishSwigPythonLLDB.py
index 4d733a164361..91e3a41f9ed3 100644
--- a/scripts/Python/finishSwigPythonLLDB.py
+++ b/scripts/Python/finishSwigPythonLLDB.py
@@ -73,6 +73,7 @@ strErrMsgUnexpected = "Unexpected error: %s"
strMsgCopySixPy = "Copying six.py from '%s' to '%s'"
strErrMsgCopySixPyFailed = "Unable to copy '%s' to '%s'"
+
def is_debug_interpreter():
return hasattr(sys, 'gettotalrefcount')
@@ -84,8 +85,11 @@ def is_debug_interpreter():
# Str - Error description on task failure.
# Throws: None.
#--
+
+
def macosx_copy_file_for_heap(vDictArgs, vstrFrameworkPythonDir):
- dbg = utilsDebug.CDebugFnVerbose("Python script macosx_copy_file_for_heap()")
+ dbg = utilsDebug.CDebugFnVerbose(
+ "Python script macosx_copy_file_for_heap()")
bOk = True
strMsg = ""
@@ -101,9 +105,21 @@ def macosx_copy_file_for_heap(vDictArgs, vstrFrameworkPythonDir):
os.makedirs(strHeapDir)
strRoot = os.path.normpath(vDictArgs["--srcRoot"])
- strSrc = os.path.join(strRoot, "examples", "darwin", "heap_find", "heap", "heap_find.cpp")
+ strSrc = os.path.join(
+ strRoot,
+ "examples",
+ "darwin",
+ "heap_find",
+ "heap",
+ "heap_find.cpp")
shutil.copy(strSrc, strHeapDir)
- strSrc = os.path.join(strRoot, "examples", "darwin", "heap_find", "heap", "Makefile")
+ strSrc = os.path.join(
+ strRoot,
+ "examples",
+ "darwin",
+ "heap_find",
+ "heap",
+ "Makefile")
shutil.copy(strSrc, strHeapDir)
return (bOk, strMsg)
@@ -118,7 +134,13 @@ def macosx_copy_file_for_heap(vDictArgs, vstrFrameworkPythonDir):
# Str - Error description on task failure.
# Throws: None.
#--
-def create_py_pkg(vDictArgs, vstrFrameworkPythonDir, vstrPkgDir, vListPkgFiles):
+
+
+def create_py_pkg(
+ vDictArgs,
+ vstrFrameworkPythonDir,
+ vstrPkgDir,
+ vListPkgFiles):
dbg = utilsDebug.CDebugFnVerbose("Python script create_py_pkg()")
dbg.dump_object("Package file(s):", vListPkgFiles)
bDbg = "-d" in vDictArgs
@@ -161,7 +183,7 @@ def create_py_pkg(vDictArgs, vstrFrameworkPythonDir, vstrPkgDir, vListPkgFiles):
strBaseName = os.path.basename(strPkgFile)
nPos = strBaseName.find(".")
if nPos != -1:
- strBaseName = strBaseName[0 : nPos]
+ strBaseName = strBaseName[0: nPos]
strPyScript += "%s\"%s\"" % (strDelimiter, strBaseName)
strDelimiter = ","
strPyScript += "]\n"
@@ -186,8 +208,14 @@ def create_py_pkg(vDictArgs, vstrFrameworkPythonDir, vstrPkgDir, vListPkgFiles):
# Str - Error description on task failure.
# Throws: None.
#--
-def copy_lldbpy_file_to_lldb_pkg_dir(vDictArgs, vstrFrameworkPythonDir, vstrCfgBldDir):
- dbg = utilsDebug.CDebugFnVerbose("Python script copy_lldbpy_file_to_lldb_pkg_dir()")
+
+
+def copy_lldbpy_file_to_lldb_pkg_dir(
+ vDictArgs,
+ vstrFrameworkPythonDir,
+ vstrCfgBldDir):
+ dbg = utilsDebug.CDebugFnVerbose(
+ "Python script copy_lldbpy_file_to_lldb_pkg_dir()")
bOk = True
bDbg = "-d" in vDictArgs
strMsg = ""
@@ -207,7 +235,8 @@ def copy_lldbpy_file_to_lldb_pkg_dir(vDictArgs, vstrFrameworkPythonDir, vstrCfgB
shutil.copyfile(strSrc, strDst)
except IOError as e:
bOk = False
- strMsg = "I/O error(%d): %s %s" % (e.errno, e.strerror, strErrMsgCpLldbpy)
+ strMsg = "I/O error(%d): %s %s" % (e.errno,
+ e.strerror, strErrMsgCpLldbpy)
if e.errno == 2:
strMsg += " Src:'%s' Dst:'%s'" % (strSrc, strDst)
except:
@@ -224,6 +253,8 @@ def copy_lldbpy_file_to_lldb_pkg_dir(vDictArgs, vstrFrameworkPythonDir, vstrCfgB
# Str - Error description on task failure.
# Throws: None.
#--
+
+
def make_symlink_windows(vstrSrcPath, vstrTargetPath):
print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
@@ -238,13 +269,16 @@ def make_symlink_windows(vstrSrcPath, vstrTargetPath):
# re-create the link. This can happen if you run this script once (creating a link)
# and then delete the source file (so that a brand new file gets created the next time
# you compile and link), and then re-run this script, so that both the target hardlink
- # and the source file exist, but the target refers to an old copy of the source.
- if (target_stat.st_ino == src_stat.st_ino) and (target_stat.st_dev == src_stat.st_dev):
+ # and the source file exist, but the target refers to an old copy of
+ # the source.
+ if (target_stat.st_ino == src_stat.st_ino) and (
+ target_stat.st_dev == src_stat.st_dev):
return (bOk, strErrMsg)
os.remove(vstrTargetPath)
except:
- # If the target file don't exist, ignore this exception, we will link it shortly.
+ # If the target file don't exist, ignore this exception, we will link
+ # it shortly.
pass
try:
@@ -256,8 +290,10 @@ def make_symlink_windows(vstrSrcPath, vstrTargetPath):
except Exception as e:
if e.errno != 17:
bOk = False
- strErrMsg = "WinError(%d): %s %s" % (e.errno, e.strerror, strErrMsgMakeSymlink)
- strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
+ strErrMsg = "WinError(%d): %s %s" % (
+ e.errno, e.strerror, strErrMsgMakeSymlink)
+ strErrMsg += " Src:'%s' Target:'%s'" % (
+ vstrSrcPath, vstrTargetPath)
return (bOk, strErrMsg)
@@ -269,8 +305,11 @@ def make_symlink_windows(vstrSrcPath, vstrTargetPath):
# Str - Error description on task failure.
# Throws: None.
#--
+
+
def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
- dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_other_platforms()")
+ dbg = utilsDebug.CDebugFnVerbose(
+ "Python script make_symlink_other_platforms()")
bOk = True
strErrMsg = ""
@@ -278,7 +317,8 @@ def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
os.symlink(vstrSrcPath, vstrTargetPath)
except OSError as e:
bOk = False
- strErrMsg = "OSError(%d): %s %s" % (e.errno, e.strerror, strErrMsgMakeSymlink)
+ strErrMsg = "OSError(%d): %s %s" % (
+ e.errno, e.strerror, strErrMsgMakeSymlink)
strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
except:
bOk = False
@@ -286,6 +326,7 @@ def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
return (bOk, strErrMsg)
+
def make_symlink_native(vDictArgs, strSrc, strTarget):
eOSType = utilsOsType.determine_os_type()
bDbg = "-d" in vDictArgs
@@ -323,7 +364,13 @@ def make_symlink_native(vDictArgs, strSrc, strTarget):
# Str - Error description on task failure.
# Throws: None.
#--
-def make_symlink(vDictArgs, vstrFrameworkPythonDir, vstrSrcFile, vstrTargetFile):
+
+
+def make_symlink(
+ vDictArgs,
+ vstrFrameworkPythonDir,
+ vstrSrcFile,
+ vstrTargetFile):
dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink()")
bOk = True
strErrMsg = ""
@@ -336,7 +383,7 @@ def make_symlink(vDictArgs, vstrFrameworkPythonDir, vstrSrcFile, vstrTargetFile)
bMakeFileCalled = "-m" in vDictArgs
eOSType = utilsOsType.determine_os_type()
if not bMakeFileCalled:
- return (bOk, strErrMsg)
+ strBuildDir = os.path.join("..", "..", "..")
else:
# Resolve vstrSrcFile path relatively the build directory
if eOSType == utilsOsType.EnumOsType.Windows:
@@ -347,7 +394,7 @@ def make_symlink(vDictArgs, vstrFrameworkPythonDir, vstrSrcFile, vstrTargetFile)
# On a UNIX style platform the vstrFrameworkPythonDir looks like:
# llvm/build/lib/python2.7/site-packages/lldb
strBuildDir = os.path.join("..", "..", "..", "..")
- strSrc = os.path.normcase(os.path.join(strBuildDir, vstrSrcFile))
+ strSrc = os.path.normcase(os.path.join(strBuildDir, vstrSrcFile))
return make_symlink_native(vDictArgs, strSrc, strTarget)
@@ -363,7 +410,11 @@ def make_symlink(vDictArgs, vstrFrameworkPythonDir, vstrSrcFile, vstrTargetFile)
# Str - Error description on task failure.
# Throws: None.
#--
-def make_symlink_liblldb(vDictArgs, vstrFrameworkPythonDir, vstrLiblldbFileName, vstrLldbLibDir):
+def make_symlink_liblldb(
+ vDictArgs,
+ vstrFrameworkPythonDir,
+ vstrLiblldbFileName,
+ vstrLldbLibDir):
dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_liblldb()")
bOk = True
strErrMsg = ""
@@ -383,7 +434,7 @@ def make_symlink_liblldb(vDictArgs, vstrFrameworkPythonDir, vstrLiblldbFileName,
bMakeFileCalled = "-m" in vDictArgs
if not bMakeFileCalled:
- strSrc = os.path.join(vstrLldbLibDir, "LLDB")
+ strSrc = "LLDB"
else:
strLibFileExtn = ""
if eOSType == utilsOsType.EnumOsType.Windows:
@@ -395,33 +446,8 @@ def make_symlink_liblldb(vDictArgs, vstrFrameworkPythonDir, vstrLiblldbFileName,
strLibFileExtn = ".so"
strSrc = os.path.join(vstrLldbLibDir, "liblldb" + strLibFileExtn)
- bOk, strErrMsg = make_symlink(vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget)
-
- return (bOk, strErrMsg)
-
-#++---------------------------------------------------------------------------
-# Details: Make the symbolic link to the darwin-debug.
-# Args: vDictArgs - (R) Program input parameters.
-# vstrFrameworkPythonDir - (R) Python framework directory.
-# vstrDarwinDebugFileName - (R) File name for darwin-debug.
-# Returns: Bool - True = function success, False = failure.
-# Str - Error description on task failure.
-# Throws: None.
-#--
-def make_symlink_darwin_debug(vDictArgs, vstrFrameworkPythonDir, vstrDarwinDebugFileName):
- dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_darwin_debug()")
- bOk = True
- strErrMsg = ""
- strTarget = vstrDarwinDebugFileName
- strSrc = ""
-
- bMakeFileCalled = "-m" in vDictArgs
- if not bMakeFileCalled:
- return (bOk, strErrMsg)
- else:
- strSrc = os.path.join("bin", "lldb-launcher")
-
- bOk, strErrMsg = make_symlink(vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget)
+ bOk, strErrMsg = make_symlink(
+ vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget)
return (bOk, strErrMsg)
@@ -434,8 +460,14 @@ def make_symlink_darwin_debug(vDictArgs, vstrFrameworkPythonDir, vstrDarwinDebug
# Str - Error description on task failure.
# Throws: None.
#--
-def make_symlink_lldb_argdumper(vDictArgs, vstrFrameworkPythonDir, vstrArgdumperFileName):
- dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_lldb_argdumper()")
+
+
+def make_symlink_lldb_argdumper(
+ vDictArgs,
+ vstrFrameworkPythonDir,
+ vstrArgdumperFileName):
+ dbg = utilsDebug.CDebugFnVerbose(
+ "Python script make_symlink_lldb_argdumper()")
bOk = True
strErrMsg = ""
strTarget = vstrArgdumperFileName
@@ -454,7 +486,8 @@ def make_symlink_lldb_argdumper(vDictArgs, vstrFrameworkPythonDir, vstrArgdumper
strExeFileExtn = ".exe"
strSrc = os.path.join("bin", "lldb-argdumper" + strExeFileExtn)
- bOk, strErrMsg = make_symlink(vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget)
+ bOk, strErrMsg = make_symlink(
+ vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget)
return (bOk, strErrMsg)
@@ -468,6 +501,8 @@ def make_symlink_lldb_argdumper(vDictArgs, vstrFrameworkPythonDir, vstrArgdumper
# strErrMsg - Error description on task failure.
# Throws: None.
#--
+
+
def create_symlinks(vDictArgs, vstrFrameworkPythonDir, vstrLldbLibDir):
dbg = utilsDebug.CDebugFnVerbose("Python script create_symlinks()")
bOk = True
@@ -482,13 +517,6 @@ def create_symlinks(vDictArgs, vstrFrameworkPythonDir, vstrLldbLibDir):
strLibLldbFileName,
vstrLldbLibDir)
- # Make symlink for darwin-debug on Darwin
- strDarwinDebugFileName = "darwin-debug"
- if bOk and eOSType == utilsOsType.EnumOsType.Darwin:
- bOk, strErrMsg = make_symlink_darwin_debug(vDictArgs,
- vstrFrameworkPythonDir,
- strDarwinDebugFileName)
-
# Make symlink for lldb-argdumper
strArgdumperFileName = "lldb-argdumper"
if bOk:
@@ -498,6 +526,7 @@ def create_symlinks(vDictArgs, vstrFrameworkPythonDir, vstrLldbLibDir):
return (bOk, strErrMsg)
+
def copy_six(vDictArgs, vstrFrameworkPythonDir):
dbg = utilsDebug.CDebugFnVerbose("Python script copy_six()")
bDbg = "-d" in vDictArgs
@@ -505,7 +534,13 @@ def copy_six(vDictArgs, vstrFrameworkPythonDir):
strMsg = ""
site_packages_dir = os.path.dirname(vstrFrameworkPythonDir)
six_module_filename = "six.py"
- src_file = os.path.join(vDictArgs['--srcRoot'], "third_party", "Python", "module", "six", six_module_filename)
+ src_file = os.path.join(
+ vDictArgs['--srcRoot'],
+ "third_party",
+ "Python",
+ "module",
+ "six",
+ six_module_filename)
src_file = os.path.normpath(src_file)
target = os.path.join(site_packages_dir, six_module_filename)
@@ -528,8 +563,11 @@ def copy_six(vDictArgs, vstrFrameworkPythonDir):
# Str - Error description on task failure.
# Throws: None.
#--
+
+
def find_or_create_python_dir(vDictArgs, vstrFrameworkPythonDir):
- dbg = utilsDebug.CDebugFnVerbose("Python script find_or_create_python_dir()")
+ dbg = utilsDebug.CDebugFnVerbose(
+ "Python script find_or_create_python_dir()")
bOk = True
strMsg = ""
bDbg = "-d" in vDictArgs
@@ -546,8 +584,8 @@ def find_or_create_python_dir(vDictArgs, vstrFrameworkPythonDir):
os.makedirs(vstrFrameworkPythonDir)
except OSError as exception:
bOk = False
- strMsg = strErrMsgCreateFrmWkPyDirFailed % (vstrFrameworkPythonDir,
- os.strerror(exception.errno))
+ strMsg = strErrMsgCreateFrmWkPyDirFailed % (
+ vstrFrameworkPythonDir, os.strerror(exception.errno))
return (bOk, strMsg)
@@ -561,6 +599,8 @@ def find_or_create_python_dir(vDictArgs, vstrFrameworkPythonDir):
# strErrMsg - Error description on task failure.
# Throws: None.
#--
+
+
def get_config_build_dir(vDictArgs, vstrFrameworkPythonDir):
dbg = utilsDebug.CDebugFnVerbose("Python script get_config_build_dir()")
bOk = True
@@ -584,8 +624,11 @@ def get_config_build_dir(vDictArgs, vstrFrameworkPythonDir):
# strErrMsg - Error description on task failure.
# Throws: None.
#--
+
+
def get_framework_python_dir_windows(vDictArgs):
- dbg = utilsDebug.CDebugFnVerbose("Python script get_framework_python_dir_windows()")
+ dbg = utilsDebug.CDebugFnVerbose(
+ "Python script get_framework_python_dir_windows()")
bOk = True
strWkDir = ""
strErrMsg = ""
@@ -601,7 +644,9 @@ def get_framework_python_dir_windows(vDictArgs):
bHaveArgCmakeBuildConfiguration = "--cmakeBuildConfiguration" in vDictArgs
if bHaveArgCmakeBuildConfiguration:
- strPythonInstallDir = os.path.join(strPythonInstallDir, vDictArgs["--cmakeBuildConfiguration"])
+ strPythonInstallDir = os.path.join(
+ strPythonInstallDir,
+ vDictArgs["--cmakeBuildConfiguration"])
if strPythonInstallDir.__len__() != 0:
strWkDir = get_python_lib(True, False, strPythonInstallDir)
@@ -620,8 +665,11 @@ def get_framework_python_dir_windows(vDictArgs):
# strErrMsg - Error description on task failure.
# Throws: None.
#--
+
+
def get_framework_python_dir_other_platforms(vDictArgs):
- dbg = utilsDebug.CDebugFnVerbose("Python script get_framework_python_dir_other_platform()")
+ dbg = utilsDebug.CDebugFnVerbose(
+ "Python script get_framework_python_dir_other_platform()")
bOk = True
strWkDir = ""
strErrMsg = ""
@@ -636,7 +684,7 @@ def get_framework_python_dir_other_platforms(vDictArgs):
# We are being built by XCode, so all the lldb Python files can go
# into the LLDB.framework/Resources/Python subdirectory.
strWkDir = vDictArgs["--targetDir"]
- strWkDir += os.path.join(strWkDir, "LLDB.framework")
+ strWkDir = os.path.join(strWkDir, "LLDB.framework")
if os.path.exists(strWkDir):
if bDbg:
print((strMsgFoundLldbFrameWkDir % strWkDir))
@@ -658,8 +706,11 @@ def get_framework_python_dir_other_platforms(vDictArgs):
# strErrMsg - Error description on task failure.
# Throws: None.
#--
+
+
def get_framework_python_dir(vDictArgs):
- dbg = utilsDebug.CDebugFnVerbose("Python script get_framework_python_dir()")
+ dbg = utilsDebug.CDebugFnVerbose(
+ "Python script get_framework_python_dir()")
bOk = True
strWkDir = ""
strErrMsg = ""
@@ -671,7 +722,8 @@ def get_framework_python_dir(vDictArgs):
elif eOSType == utilsOsType.EnumOsType.Windows:
bOk, strWkDir, strErrMsg = get_framework_python_dir_windows(vDictArgs)
else:
- bOk, strWkDir, strErrMsg = get_framework_python_dir_other_platforms(vDictArgs)
+ bOk, strWkDir, strErrMsg = get_framework_python_dir_other_platforms(
+ vDictArgs)
return (bOk, strWkDir, strErrMsg)
@@ -683,6 +735,8 @@ def get_framework_python_dir(vDictArgs):
# strErrMsg - Error description on task failure.
# Throws: None.
#--
+
+
def get_liblldb_dir(vDictArgs):
dbg = utilsDebug.CDebugFnVerbose("Python script get_liblldb_dir()")
bOk = True
@@ -731,6 +785,8 @@ def get_liblldb_dir(vDictArgs):
--------------------------------------------------------------------------
"""
+
+
def main(vDictArgs):
dbg = utilsDebug.CDebugFnVerbose("Python script main()")
bOk = True
@@ -748,7 +804,8 @@ def main(vDictArgs):
bOk, strFrameworkPythonDir, strMsg = get_framework_python_dir(vDictArgs)
if bOk:
- bOk, strCfgBldDir, strMsg = get_config_build_dir(vDictArgs, strFrameworkPythonDir)
+ bOk, strCfgBldDir, strMsg = get_config_build_dir(
+ vDictArgs, strFrameworkPythonDir)
if bOk and bDbg:
print((strMsgPyFileLocatedHere % strFrameworkPythonDir))
print((strMsgConfigBuildDir % strCfgBldDir))
@@ -757,10 +814,12 @@ def main(vDictArgs):
bOk, strLldbLibDir, strMsg = get_liblldb_dir(vDictArgs)
if bOk:
- bOk, strMsg = find_or_create_python_dir(vDictArgs, strFrameworkPythonDir)
+ bOk, strMsg = find_or_create_python_dir(
+ vDictArgs, strFrameworkPythonDir)
if bOk:
- bOk, strMsg = create_symlinks(vDictArgs, strFrameworkPythonDir, strLldbLibDir)
+ bOk, strMsg = create_symlinks(
+ vDictArgs, strFrameworkPythonDir, strLldbLibDir)
if bOk:
bOk, strMsg = copy_six(vDictArgs, strFrameworkPythonDir)
@@ -772,51 +831,100 @@ def main(vDictArgs):
strRoot = os.path.normpath(vDictArgs["--srcRoot"])
if bOk:
# lldb
- listPkgFiles = [os.path.join(strRoot, "source", "Interpreter", "embedded_interpreter.py")]
- bOk, strMsg = create_py_pkg(vDictArgs, strFrameworkPythonDir, "", listPkgFiles)
+ listPkgFiles = [
+ os.path.join(
+ strRoot,
+ "source",
+ "Interpreter",
+ "embedded_interpreter.py")]
+ bOk, strMsg = create_py_pkg(
+ vDictArgs, strFrameworkPythonDir, "", listPkgFiles)
if bOk:
# lldb/formatters/cpp
- listPkgFiles = [os.path.join(strRoot, "examples", "synthetic", "gnu_libstdcpp.py"),
- os.path.join(strRoot, "examples", "synthetic", "libcxx.py")]
- bOk, strMsg = create_py_pkg(vDictArgs, strFrameworkPythonDir, "/formatters/cpp", listPkgFiles)
+ listPkgFiles = [
+ os.path.join(
+ strRoot,
+ "examples",
+ "synthetic",
+ "gnu_libstdcpp.py"),
+ os.path.join(
+ strRoot,
+ "examples",
+ "synthetic",
+ "libcxx.py")]
+ bOk, strMsg = create_py_pkg(
+ vDictArgs, strFrameworkPythonDir, "/formatters/cpp", listPkgFiles)
if bOk:
# Make an empty __init__.py in lldb/runtime as this is required for
# Python to recognize lldb.runtime as a valid package (and hence,
# lldb.runtime.objc as a valid contained package)
listPkgFiles = []
- bOk, strMsg = create_py_pkg(vDictArgs, strFrameworkPythonDir, "/runtime", listPkgFiles)
+ bOk, strMsg = create_py_pkg(
+ vDictArgs, strFrameworkPythonDir, "/runtime", listPkgFiles)
if bOk:
# lldb/formatters
# Having these files copied here ensure that lldb/formatters is a
# valid package itself
- listPkgFiles = [os.path.join(strRoot, "examples", "summaries", "cocoa", "cache.py"),
- os.path.join(strRoot, "examples", "summaries", "cocoa", "metrics.py"),
- os.path.join(strRoot, "examples", "summaries", "cocoa", "attrib_fromdict.py"),
- os.path.join(strRoot, "examples", "summaries", "cocoa", "Logger.py")]
- bOk, strMsg = create_py_pkg(vDictArgs, strFrameworkPythonDir, "/formatters", listPkgFiles)
+ listPkgFiles = [
+ os.path.join(
+ strRoot, "examples", "summaries", "cocoa", "cache.py"), os.path.join(
+ strRoot, "examples", "summaries", "synth.py"), os.path.join(
+ strRoot, "examples", "summaries", "cocoa", "metrics.py"), os.path.join(
+ strRoot, "examples", "summaries", "cocoa", "attrib_fromdict.py"), os.path.join(
+ strRoot, "examples", "summaries", "cocoa", "Logger.py")]
+ bOk, strMsg = create_py_pkg(
+ vDictArgs, strFrameworkPythonDir, "/formatters", listPkgFiles)
if bOk:
# lldb/utils
- listPkgFiles = [os.path.join(strRoot, "examples", "python", "symbolication.py")]
- bOk, strMsg = create_py_pkg(vDictArgs, strFrameworkPythonDir, "/utils", listPkgFiles)
+ listPkgFiles = [
+ os.path.join(
+ strRoot,
+ "examples",
+ "python",
+ "symbolication.py")]
+ bOk, strMsg = create_py_pkg(
+ vDictArgs, strFrameworkPythonDir, "/utils", listPkgFiles)
if bOk and (eOSType == utilsOsType.EnumOsType.Darwin):
# lldb/macosx
- listPkgFiles = [os.path.join(strRoot, "examples", "python", "crashlog.py"),
- os.path.join(strRoot, "examples", "darwin", "heap_find", "heap.py")]
- bOk, strMsg = create_py_pkg(vDictArgs, strFrameworkPythonDir, "/macosx", listPkgFiles)
+ listPkgFiles = [
+ os.path.join(
+ strRoot,
+ "examples",
+ "python",
+ "crashlog.py"),
+ os.path.join(
+ strRoot,
+ "examples",
+ "darwin",
+ "heap_find",
+ "heap.py")]
+ bOk, strMsg = create_py_pkg(
+ vDictArgs, strFrameworkPythonDir, "/macosx", listPkgFiles)
if bOk and (eOSType == utilsOsType.EnumOsType.Darwin):
# lldb/diagnose
- listPkgFiles = [os.path.join(strRoot, "examples", "python", "diagnose_unwind.py"),
- os.path.join(strRoot, "examples", "python", "diagnose_nsstring.py")]
- bOk, strMsg = create_py_pkg(vDictArgs, strFrameworkPythonDir, "/diagnose", listPkgFiles)
+ listPkgFiles = [
+ os.path.join(
+ strRoot,
+ "examples",
+ "python",
+ "diagnose_unwind.py"),
+ os.path.join(
+ strRoot,
+ "examples",
+ "python",
+ "diagnose_nsstring.py")]
+ bOk, strMsg = create_py_pkg(
+ vDictArgs, strFrameworkPythonDir, "/diagnose", listPkgFiles)
if bOk:
- bOk, strMsg = macosx_copy_file_for_heap(vDictArgs, strFrameworkPythonDir)
+ bOk, strMsg = macosx_copy_file_for_heap(
+ vDictArgs, strFrameworkPythonDir)
if bOk:
return (0, strMsg)
@@ -833,4 +941,3 @@ def main(vDictArgs):
# function directly
if __name__ == "__main__":
print("Script cannot be called directly, called by finishSwigWrapperClasses.py")
-
diff --git a/scripts/Python/modify-python-lldb.py b/scripts/Python/modify-python-lldb.py
index 56323d6679a1..cb911eed047f 100644
--- a/scripts/Python/modify-python-lldb.py
+++ b/scripts/Python/modify-python-lldb.py
@@ -22,7 +22,8 @@
#
# System modules
-import sys, re
+import sys
+import re
if sys.version_info.major >= 3:
import io as StringIO
else:
@@ -45,7 +46,7 @@ else:
#
# Version string
-#
+#
version_line = "swig_version = %s"
#
@@ -60,6 +61,7 @@ doxygen_comment_start = re.compile("^\s*(/// ?)")
# When bracketed by the lines, the CLEANUP_DOCSTRING state (see below) is ON.
toggle_docstring_cleanup_line = ' """'
+
def char_to_str_xform(line):
"""This transforms the 'char', i.e, 'char *' to 'str', Python string."""
line = line.replace(' char', ' str')
@@ -74,7 +76,9 @@ def char_to_str_xform(line):
#
TWO_SPACES = ' ' * 2
EIGHT_SPACES = ' ' * 8
-one_liner_docstring_pattern = re.compile('^(%s|%s)""".*"""$' % (TWO_SPACES, EIGHT_SPACES))
+one_liner_docstring_pattern = re.compile(
+ '^(%s|%s)""".*"""$' %
+ (TWO_SPACES, EIGHT_SPACES))
#
# lldb_helpers and lldb_iter() should appear before our first SB* class definition.
@@ -226,47 +230,48 @@ symbol_in_section_iter_def = '''
#
# This dictionary defines a mapping from classname to (getsize, getelem) tuple.
#
-d = { 'SBBreakpoint': ('GetNumLocations', 'GetLocationAtIndex'),
- 'SBCompileUnit': ('GetNumLineEntries', 'GetLineEntryAtIndex'),
- 'SBDebugger': ('GetNumTargets', 'GetTargetAtIndex'),
- 'SBModule': ('GetNumSymbols', 'GetSymbolAtIndex'),
- 'SBProcess': ('GetNumThreads', 'GetThreadAtIndex'),
- 'SBSection': ('GetNumSubSections', 'GetSubSectionAtIndex'),
- 'SBThread': ('GetNumFrames', 'GetFrameAtIndex'),
-
- 'SBInstructionList': ('GetSize', 'GetInstructionAtIndex'),
- 'SBStringList': ('GetSize', 'GetStringAtIndex',),
- 'SBSymbolContextList': ('GetSize', 'GetContextAtIndex'),
- 'SBTypeList': ('GetSize', 'GetTypeAtIndex'),
- 'SBValueList': ('GetSize', 'GetValueAtIndex'),
-
- 'SBType': ('GetNumberChildren', 'GetChildAtIndex'),
- 'SBValue': ('GetNumChildren', 'GetChildAtIndex'),
-
- # SBTarget needs special processing, see below.
- 'SBTarget': {'module': ('GetNumModules', 'GetModuleAtIndex'),
- 'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex'),
- 'watchpoint': ('GetNumWatchpoints', 'GetWatchpointAtIndex')
- },
-
- # SBModule has an additional section_iter(), see below.
- 'SBModule-section': ('GetNumSections', 'GetSectionAtIndex'),
- # And compile_unit_iter().
- 'SBModule-compile-unit': ('GetNumCompileUnits', 'GetCompileUnitAtIndex'),
- # As well as symbol_in_section_iter().
- 'SBModule-symbol-in-section': symbol_in_section_iter_def
- }
+d = {'SBBreakpoint': ('GetNumLocations', 'GetLocationAtIndex'),
+ 'SBCompileUnit': ('GetNumLineEntries', 'GetLineEntryAtIndex'),
+ 'SBDebugger': ('GetNumTargets', 'GetTargetAtIndex'),
+ 'SBModule': ('GetNumSymbols', 'GetSymbolAtIndex'),
+ 'SBProcess': ('GetNumThreads', 'GetThreadAtIndex'),
+ 'SBSection': ('GetNumSubSections', 'GetSubSectionAtIndex'),
+ 'SBThread': ('GetNumFrames', 'GetFrameAtIndex'),
+
+ 'SBInstructionList': ('GetSize', 'GetInstructionAtIndex'),
+ 'SBStringList': ('GetSize', 'GetStringAtIndex',),
+ 'SBSymbolContextList': ('GetSize', 'GetContextAtIndex'),
+ 'SBTypeList': ('GetSize', 'GetTypeAtIndex'),
+ 'SBValueList': ('GetSize', 'GetValueAtIndex'),
+
+ 'SBType': ('GetNumberChildren', 'GetChildAtIndex'),
+ 'SBValue': ('GetNumChildren', 'GetChildAtIndex'),
+
+ # SBTarget needs special processing, see below.
+ 'SBTarget': {'module': ('GetNumModules', 'GetModuleAtIndex'),
+ 'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex'),
+ 'watchpoint': ('GetNumWatchpoints', 'GetWatchpointAtIndex')
+ },
+
+ # SBModule has an additional section_iter(), see below.
+ 'SBModule-section': ('GetNumSections', 'GetSectionAtIndex'),
+ # And compile_unit_iter().
+ 'SBModule-compile-unit': ('GetNumCompileUnits', 'GetCompileUnitAtIndex'),
+ # As well as symbol_in_section_iter().
+ 'SBModule-symbol-in-section': symbol_in_section_iter_def
+ }
#
# This dictionary defines a mapping from classname to equality method name(s).
#
-e = { 'SBAddress': ['GetFileAddress', 'GetModule'],
- 'SBBreakpoint': ['GetID'],
- 'SBWatchpoint': ['GetID'],
- 'SBFileSpec': ['GetFilename', 'GetDirectory'],
- 'SBModule': ['GetFileSpec', 'GetUUIDString'],
- 'SBType': ['GetByteSize', 'GetName']
- }
+e = {'SBAddress': ['GetFileAddress', 'GetModule'],
+ 'SBBreakpoint': ['GetID'],
+ 'SBWatchpoint': ['GetID'],
+ 'SBFileSpec': ['GetFilename', 'GetDirectory'],
+ 'SBModule': ['GetFileSpec', 'GetUUIDString'],
+ 'SBType': ['GetByteSize', 'GetName']
+ }
+
def list_to_frag(list):
"""Transform a list to equality program fragment.
@@ -284,30 +289,37 @@ def list_to_frag(list):
frag.write("self.{0}() == other.{0}()".format(list[i]))
return frag.getvalue()
+
class NewContent(StringIO.StringIO):
"""Simple facade to keep track of the previous line to be committed."""
+
def __init__(self):
StringIO.StringIO.__init__(self)
self.prev_line = None
+
def add_line(self, a_line):
"""Add a line to the content, if there is a previous line, commit it."""
- if self.prev_line != None:
+ if self.prev_line is not None:
self.write(self.prev_line + "\n")
self.prev_line = a_line
+
def del_line(self):
"""Forget about the previous line, do not commit it."""
self.prev_line = None
+
def del_blank_line(self):
"""Forget about the previous line if it is a blank line."""
- if self.prev_line != None and not self.prev_line.strip():
+ if self.prev_line is not None and not self.prev_line.strip():
self.prev_line = None
+
def finish(self):
"""Call this when you're finished with populating content."""
- if self.prev_line != None:
+ if self.prev_line is not None:
self.write(self.prev_line + "\n")
self.prev_line = None
-# The new content will have the iteration protocol defined for our lldb objects.
+# The new content will have the iteration protocol defined for our lldb
+# objects.
new_content = NewContent()
with open(output_name, 'r') as f_in:
@@ -333,7 +345,7 @@ DEFINING_EQUALITY = 4
CLEANUP_DOCSTRING = 8
# The lldb_iter_def only needs to be inserted once.
-lldb_iter_defined = False;
+lldb_iter_defined = False
# Our FSM begins its life in the NORMAL state, and transitions to the
# DEFINING_ITERATOR and/or DEFINING_EQUALITY state whenever it encounters the
@@ -361,7 +373,7 @@ for line in content.splitlines():
#
# If ' """' is the sole line, prepare to transition to the
# CLEANUP_DOCSTRING state or out of it.
-
+
if line == toggle_docstring_cleanup_line:
if state & CLEANUP_DOCSTRING:
# Special handling of the trailing blank line right before the '"""'
@@ -379,7 +391,8 @@ for line in content.splitlines():
v = match.group(1)
swig_version_tuple = tuple(map(int, (v.split("."))))
elif not line.startswith('#'):
- # This is the first non-comment line after the header. Inject the version
+ # This is the first non-comment line after the header. Inject the
+ # version
new_line = version_line % str(swig_version_tuple)
new_content.add_line(new_line)
state = NORMAL
@@ -424,11 +437,13 @@ for line in content.splitlines():
new_content.add_line(eq_def % (cls, list_to_frag(e[cls])))
new_content.add_line(ne_def)
- # SBModule has extra SBSection, SBCompileUnit iterators and symbol_in_section_iter()!
+ # SBModule has extra SBSection, SBCompileUnit iterators and
+ # symbol_in_section_iter()!
if cls == "SBModule":
- new_content.add_line(section_iter % d[cls+'-section'])
- new_content.add_line(compile_unit_iter % d[cls+'-compile-unit'])
- new_content.add_line(d[cls+'-symbol-in-section'])
+ new_content.add_line(section_iter % d[cls + '-section'])
+ new_content.add_line(compile_unit_iter %
+ d[cls + '-compile-unit'])
+ new_content.add_line(d[cls + '-symbol-in-section'])
# This special purpose iterator is for SBValue only!!!
if cls == "SBValue":
@@ -483,4 +498,3 @@ target = SBTarget()
process = SBProcess()
thread = SBThread()
frame = SBFrame()''')
-
diff --git a/scripts/Python/modules/CMakeLists.txt b/scripts/Python/modules/CMakeLists.txt
index 396d447ff267..f2269c342005 100644
--- a/scripts/Python/modules/CMakeLists.txt
+++ b/scripts/Python/modules/CMakeLists.txt
@@ -6,6 +6,6 @@ if (CXX_SUPPORTS_NO_MACRO_REDEFINED)
endif ()
# build the Python readline suppression module only on Linux
-if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT __ANDROID_NDK__)
+if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "GNU" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "kFreeBSD")
add_subdirectory(readline)
endif()
diff --git a/scripts/Python/modules/readline/readline.cpp b/scripts/Python/modules/readline/readline.cpp
index d4b4962cc313..b84dbb819f99 100644
--- a/scripts/Python/modules/readline/readline.cpp
+++ b/scripts/Python/modules/readline/readline.cpp
@@ -21,18 +21,15 @@
// readline.so linked against GNU readline.
#ifndef LLDB_DISABLE_LIBEDIT
-PyDoc_STRVAR(
- moduleDocumentation,
- "Simple readline module implementation based on libedit.");
+PyDoc_STRVAR(moduleDocumentation,
+ "Simple readline module implementation based on libedit.");
#else
-PyDoc_STRVAR(
- moduleDocumentation,
- "Stub module meant to avoid linking GNU readline.");
+PyDoc_STRVAR(moduleDocumentation,
+ "Stub module meant to avoid linking GNU readline.");
#endif
#if PY_MAJOR_VERSION >= 3
-static struct PyModuleDef readline_module =
-{
+static struct PyModuleDef readline_module = {
PyModuleDef_HEAD_INIT, // m_base
"readline", // m_name
moduleDocumentation, // m_doc
@@ -44,57 +41,47 @@ static struct PyModuleDef readline_module =
nullptr, // m_free
};
#else
-static struct PyMethodDef moduleMethods[] =
-{
- {nullptr, nullptr, 0, nullptr}
-};
+static struct PyMethodDef moduleMethods[] = {{nullptr, nullptr, 0, nullptr}};
#endif
#ifndef LLDB_DISABLE_LIBEDIT
-static char*
+static char *
#if PY_MAJOR_VERSION >= 3
simple_readline(FILE *stdin, FILE *stdout, const char *prompt)
#else
simple_readline(FILE *stdin, FILE *stdout, char *prompt)
#endif
{
- rl_instream = stdin;
- rl_outstream = stdout;
- char* line = readline(prompt);
- if (!line)
- {
- char* ret = (char*)PyMem_Malloc(1);
- if (ret != NULL)
- *ret = '\0';
- return ret;
- }
- if (*line)
- add_history(line);
- int n = strlen(line);
- char* ret = (char*)PyMem_Malloc(n + 2);
- strncpy(ret, line, n);
- free(line);
- ret[n] = '\n';
- ret[n+1] = '\0';
+ rl_instream = stdin;
+ rl_outstream = stdout;
+ char *line = readline(prompt);
+ if (!line) {
+ char *ret = (char *)PyMem_Malloc(1);
+ if (ret != NULL)
+ *ret = '\0';
return ret;
+ }
+ if (*line)
+ add_history(line);
+ int n = strlen(line);
+ char *ret = (char *)PyMem_Malloc(n + 2);
+ strncpy(ret, line, n);
+ free(line);
+ ret[n] = '\n';
+ ret[n + 1] = '\0';
+ return ret;
}
#endif
-PyMODINIT_FUNC
-initreadline(void)
-{
+PyMODINIT_FUNC initreadline(void) {
#ifndef LLDB_DISABLE_LIBEDIT
- PyOS_ReadlineFunctionPointer = simple_readline;
+ PyOS_ReadlineFunctionPointer = simple_readline;
#endif
#if PY_MAJOR_VERSION >= 3
- return PyModule_Create(&readline_module);
+ return PyModule_Create(&readline_module);
#else
- Py_InitModule4(
- "readline",
- moduleMethods,
- moduleDocumentation,
- static_cast<PyObject *>(NULL),
- PYTHON_API_VERSION);
+ Py_InitModule4("readline", moduleMethods, moduleDocumentation,
+ static_cast<PyObject *>(NULL), PYTHON_API_VERSION);
#endif
}
diff --git a/scripts/Python/prepare_binding_Python.py b/scripts/Python/prepare_binding_Python.py
index 28fc3e5bc7fc..cf64d49504f3 100644
--- a/scripts/Python/prepare_binding_Python.py
+++ b/scripts/Python/prepare_binding_Python.py
@@ -18,8 +18,10 @@ import subprocess
import sys
import platform
+
class SwigSettings(object):
"""Provides a single object to represent swig files and settings."""
+
def __init__(self):
self.extensions_file = None
self.header_files = None
@@ -194,34 +196,37 @@ def do_swig_rebuild(options, dependency_file, config_build_dir, settings):
temp_dep_file_path = dependency_file + ".tmp"
# Build the SWIG args list
- command = [
- options.swig_executable,
- "-c++",
- "-shadow",
- "-python",
- "-threads",
- "-I\"%s\"" % os.path.normcase(
- os.path.join(options.src_root, "include")),
- "-I\"%s\"" % os.path.normcase("./."),
- "-D__STDC_LIMIT_MACROS",
- "-D__STDC_CONSTANT_MACROS"]
- if options.target_platform == "Darwin":
- command.append("-D__APPLE__")
- if options.generate_dependency_file:
- command.append("-MMD -MF \"%s\"" % temp_dep_file_path)
- command.extend([
- "-outdir", "\"%s\"" % config_build_dir,
- "-o", "\"%s\"" % settings.output_file,
- "\"%s\"" % settings.input_file
- ])
- logging.info("running swig with: %s", command)
+ is_darwin = options.target_platform == "Darwin"
+ gen_deps = options.generate_dependency_file
+ darwin_extras = ["-D__APPLE__"] if is_darwin else []
+ deps_args = ["-MMD", "-MF", temp_dep_file_path] if gen_deps else []
+ command = ([
+ options.swig_executable,
+ "-c++",
+ "-shadow",
+ "-python",
+ "-threads",
+ "-I" + os.path.normpath(os.path.join(options.src_root, "include")),
+ "-I" + os.path.curdir,
+ "-D__STDC_LIMIT_MACROS",
+ "-D__STDC_CONSTANT_MACROS"
+ ]
+ + darwin_extras
+ + deps_args
+ + [
+ "-outdir", config_build_dir,
+ "-o", settings.output_file,
+ settings.input_file
+ ]
+ )
+ logging.info("running swig with: %r", command)
# Execute swig
process = subprocess.Popen(
- ' '.join(command),
+ command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
- shell=True)
+ )
# Wait for SWIG process to terminate
swig_stdout, swig_stderr = process.communicate()
return_code = process.returncode
@@ -262,15 +267,15 @@ def run_python_script(script_and_args):
@param script_and_args the python script to execute, along with
the command line arguments to pass to it.
"""
- command_line = "%s %s" % (sys.executable, script_and_args)
- process = subprocess.Popen(command_line, shell=True)
+ command = [sys.executable] + script_and_args
+ process = subprocess.Popen(command)
script_stdout, script_stderr = process.communicate()
return_code = process.returncode
if return_code != 0:
- logging.error("failed to run '%s': %s", command_line, script_stderr)
+ logging.error("failed to run %r: %r", command, script_stderr)
sys.exit(return_code)
else:
- logging.info("ran script '%s'", command_line)
+ logging.info("ran script %r'", command)
if script_stdout is not None:
logging.info("output: %s", script_stdout)
@@ -292,8 +297,7 @@ def do_modify_python_lldb(options, config_build_dir):
logging.error("failed to find python script: '%s'", script_path)
sys.exit(-11)
- script_invocation = "%s %s" % (script_path, config_build_dir)
- run_python_script(script_invocation)
+ run_python_script([script_path, config_build_dir])
def get_python_module_path(options):
diff --git a/scripts/Python/remote-build.py b/scripts/Python/remote-build.py
index 72986a0bf8fe..d1d6131e472b 100755
--- a/scripts/Python/remote-build.py
+++ b/scripts/Python/remote-build.py
@@ -14,6 +14,7 @@ import subprocess
_COMMON_SYNC_OPTS = "-avzh --delete"
_COMMON_EXCLUDE_OPTS = "--exclude=DerivedData --exclude=.svn --exclude=.git --exclude=llvm-build/Release+Asserts"
+
def normalize_configuration(config_text):
if not config_text:
return "debug"
@@ -24,6 +25,7 @@ def normalize_configuration(config_text):
else:
raise Exception("unknown configuration specified: %s" % config_text)
+
def parse_args():
DEFAULT_REMOTE_ROOT_DIR = "/mnt/ssd/work/macosx.sync"
DEFAULT_REMOTE_HOSTNAME = "tfiala2.mtv.corp.google.com"
@@ -33,9 +35,13 @@ def parse_args():
parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
parser.add_argument(
- "--configuration", "-c",
+ "--configuration",
+ "-c",
help="specify configuration (Debug, Release)",
- default=normalize_configuration(os.environ.get('CONFIGURATION', 'Debug')))
+ default=normalize_configuration(
+ os.environ.get(
+ 'CONFIGURATION',
+ 'Debug')))
parser.add_argument(
"--debug", "-d",
action="store_true",
@@ -60,11 +66,16 @@ def parse_args():
"--user", "-u", help="specify the user name for the remote system",
default=getpass.getuser())
parser.add_argument(
- "--xcode-action", "-x", help="$(ACTION) from Xcode", nargs='?', default=None)
+ "--xcode-action",
+ "-x",
+ help="$(ACTION) from Xcode",
+ nargs='?',
+ default=None)
command_line_args = sys.argv[1:]
if os.path.exists(OPTIONS_FILENAME):
- # Prepend the file so that command line args override the file contents.
+ # Prepend the file so that command line args override the file
+ # contents.
command_line_args.insert(0, "@%s" % OPTIONS_FILENAME)
return parser.parse_args(command_line_args)
@@ -102,7 +113,8 @@ def init_with_args(args):
"local lldb root needs to be called 'lldb' but was {} instead"
.format(os.path.basename(args.local_lldb_dir)))
- args.lldb_dir_relative_regex = re.compile("%s/llvm/tools/lldb/" % args.remote_dir)
+ args.lldb_dir_relative_regex = re.compile(
+ "%s/llvm/tools/lldb/" % args.remote_dir)
args.llvm_dir_relative_regex = re.compile("%s/" % args.remote_dir)
print("Xcode action:", args.xcode_action)
@@ -118,6 +130,7 @@ def init_with_args(args):
return True
+
def sync_llvm(args):
commandline = ["rsync"]
commandline.extend(_COMMON_SYNC_OPTS.split())
@@ -138,9 +151,8 @@ def sync_lldb(args):
commandline.extend(_COMMON_EXCLUDE_OPTS.split())
commandline.append("--exclude=/lldb/llvm")
commandline.extend(["-e", "ssh -p {}".format(args.port)])
- commandline.extend([
- args.local_lldb_dir,
- "%s@%s:%s/llvm/tools" % (args.user, args.remote_address, args.remote_dir)])
+ commandline.extend([args.local_lldb_dir, "%s@%s:%s/llvm/tools" %
+ (args.user, args.remote_address, args.remote_dir)])
if args.debug:
print("going to execute lldb sync: {}".format(commandline))
return subprocess.call(commandline)
@@ -174,7 +186,7 @@ def build_cmake_command(args):
"-DCMAKE_BUILD_TYPE=%s" % build_type_name,
"-Wno-dev",
os.path.join("..", "llvm")
- ]
+ ]
return command_line
@@ -187,7 +199,7 @@ def maybe_configure(args):
"cd", args.remote_dir, "&&",
"mkdir", "-p", args.remote_build_dir, "&&",
"cd", args.remote_build_dir, "&&"
- ]
+ ]
commandline.extend(build_cmake_command(args))
if args.debug:
@@ -243,7 +255,7 @@ def run_remote_build_command(args, build_command_list):
print(display_line, file=sys.stderr)
proc_retval = proc.poll()
- if proc_retval != None:
+ if proc_retval is not None:
# Process stopped. Drain output before finishing up.
# Drain stdout.
diff --git a/scripts/Python/use_lldb_suite.py b/scripts/Python/use_lldb_suite.py
index f3e358af143b..6e24b9da8d34 100644
--- a/scripts/Python/use_lldb_suite.py
+++ b/scripts/Python/use_lldb_suite.py
@@ -2,6 +2,7 @@ import inspect
import os
import sys
+
def find_lldb_root():
lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
while True: