aboutsummaryrefslogtreecommitdiff
path: root/lldb/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/scripts')
-rw-r--r--lldb/scripts/Python/android/host_art_bt.py391
-rw-r--r--lldb/scripts/Python/finishSwigPythonLLDB.py262
-rw-r--r--lldb/scripts/Python/modify-python-lldb.py118
-rw-r--r--lldb/scripts/Python/modules/readline/readline.cpp71
-rw-r--r--lldb/scripts/Python/prepare_binding_Python.py4
-rwxr-xr-xlldb/scripts/Python/remote-build.py34
-rw-r--r--lldb/scripts/Python/use_lldb_suite.py1
-rwxr-xr-xlldb/scripts/Xcode/build-llvm.py271
-rw-r--r--lldb/scripts/Xcode/lldbbuild.py107
-rw-r--r--lldb/scripts/Xcode/package-clang-headers.py14
-rwxr-xr-xlldb/scripts/buildbot.py122
-rw-r--r--lldb/scripts/finishSwigWrapperClasses.py84
-rw-r--r--lldb/scripts/install_custom_python.py65
-rw-r--r--lldb/scripts/swig_bot.py6
-rw-r--r--lldb/scripts/swig_bot_lib/client.py27
-rw-r--r--lldb/scripts/swig_bot_lib/local.py10
-rw-r--r--lldb/scripts/swig_bot_lib/remote.py4
-rw-r--r--lldb/scripts/swig_bot_lib/server.py6
-rw-r--r--lldb/scripts/use_lldb_suite.py1
-rw-r--r--lldb/scripts/utilsArgsParse.py8
-rw-r--r--lldb/scripts/utilsDebug.py25
-rw-r--r--lldb/scripts/utilsOsType.py17
-rwxr-xr-xlldb/scripts/verify_api.py67
23 files changed, 1109 insertions, 606 deletions
diff --git a/lldb/scripts/Python/android/host_art_bt.py b/lldb/scripts/Python/android/host_art_bt.py
index 0893662..e359829 100644
--- a/lldb/scripts/Python/android/host_art_bt.py
+++ b/lldb/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/lldb/scripts/Python/finishSwigPythonLLDB.py b/lldb/scripts/Python/finishSwigPythonLLDB.py
index 6d51a4b..2b01c2a 100644
--- a/lldb/scripts/Python/finishSwigPythonLLDB.py
+++ b/lldb/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 = ""
@@ -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 = ""
@@ -395,7 +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)
+ bOk, strErrMsg = make_symlink(
+ vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget)
return (bOk, strErrMsg)
@@ -408,8 +460,14 @@ def make_symlink_liblldb(vDictArgs, vstrFrameworkPythonDir, vstrLiblldbFileName,
# 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()")
+
+
+def make_symlink_darwin_debug(
+ vDictArgs,
+ vstrFrameworkPythonDir,
+ vstrDarwinDebugFileName):
+ dbg = utilsDebug.CDebugFnVerbose(
+ "Python script make_symlink_darwin_debug()")
bOk = True
strErrMsg = ""
strTarget = vstrDarwinDebugFileName
@@ -421,7 +479,8 @@ def make_symlink_darwin_debug(vDictArgs, vstrFrameworkPythonDir, vstrDarwinDebug
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 +493,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 +519,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 +534,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
@@ -498,6 +566,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 +574,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 +603,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 +624,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 +639,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 +664,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 +684,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 +705,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 = ""
@@ -658,8 +746,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 +762,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 +775,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 +825,8 @@ def get_liblldb_dir(vDictArgs):
--------------------------------------------------------------------------
"""
+
+
def main(vDictArgs):
dbg = utilsDebug.CDebugFnVerbose("Python script main()")
bOk = True
@@ -748,7 +844,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 +854,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,52 +871,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", "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)
+ 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)
@@ -834,4 +981,3 @@ def main(vDictArgs):
# function directly
if __name__ == "__main__":
print("Script cannot be called directly, called by finishSwigWrapperClasses.py")
-
diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py
index 56323d6..cb911ee 100644
--- a/lldb/scripts/Python/modify-python-lldb.py
+++ b/lldb/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/lldb/scripts/Python/modules/readline/readline.cpp b/lldb/scripts/Python/modules/readline/readline.cpp
index d4b4962..b84dbb8 100644
--- a/lldb/scripts/Python/modules/readline/readline.cpp
+++ b/lldb/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/lldb/scripts/Python/prepare_binding_Python.py b/lldb/scripts/Python/prepare_binding_Python.py
index 28fc3e5..1688af4 100644
--- a/lldb/scripts/Python/prepare_binding_Python.py
+++ b/lldb/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
@@ -213,7 +215,7 @@ def do_swig_rebuild(options, dependency_file, config_build_dir, settings):
"-outdir", "\"%s\"" % config_build_dir,
"-o", "\"%s\"" % settings.output_file,
"\"%s\"" % settings.input_file
- ])
+ ])
logging.info("running swig with: %s", command)
# Execute swig
diff --git a/lldb/scripts/Python/remote-build.py b/lldb/scripts/Python/remote-build.py
index 72986a0..d1d6131 100755
--- a/lldb/scripts/Python/remote-build.py
+++ b/lldb/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/lldb/scripts/Python/use_lldb_suite.py b/lldb/scripts/Python/use_lldb_suite.py
index f3e358a..6e24b9d 100644
--- a/lldb/scripts/Python/use_lldb_suite.py
+++ b/lldb/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:
diff --git a/lldb/scripts/Xcode/build-llvm.py b/lldb/scripts/Xcode/build-llvm.py
index e7b91bc..ff474c27 100755
--- a/lldb/scripts/Xcode/build-llvm.py
+++ b/lldb/scripts/Xcode/build-llvm.py
@@ -13,64 +13,72 @@ from lldbbuild import *
#### SETTINGS ####
-def LLVM_HASH_INCLUDES_DIFFS ():
+
+def LLVM_HASH_INCLUDES_DIFFS():
return False
# The use of "x = "..."; return x" here is important because tooling looks for
# it with regexps. Only change how this works if you know what you are doing.
-def LLVM_REF ():
+
+def LLVM_REF():
llvm_ref = "master"
return llvm_ref
-def CLANG_REF ():
+
+def CLANG_REF():
clang_ref = "master"
return clang_ref
# For use with Xcode-style builds
-def XCODE_REPOSITORIES ():
+
+def XCODE_REPOSITORIES():
return [
- { 'name': "llvm",
- 'vcs': VCS.git,
- 'root': llvm_source_path(),
- 'url': "http://llvm.org/git/llvm.git",
- 'ref': LLVM_REF() },
-
- { 'name': "clang",
- 'vcs': VCS.git,
- 'root': clang_source_path(),
- 'url': "http://llvm.org/git/clang.git",
- 'ref': CLANG_REF() },
-
- { 'name': "ninja",
- 'vcs': VCS.git,
- 'root': ninja_source_path(),
- 'url': "https://github.com/ninja-build/ninja.git",
- 'ref': "master" }
+ {'name': "llvm",
+ 'vcs': VCS.git,
+ 'root': llvm_source_path(),
+ 'url': "http://llvm.org/git/llvm.git",
+ 'ref': LLVM_REF()},
+
+ {'name': "clang",
+ 'vcs': VCS.git,
+ 'root': clang_source_path(),
+ 'url': "http://llvm.org/git/clang.git",
+ 'ref': CLANG_REF()},
+
+ {'name': "ninja",
+ 'vcs': VCS.git,
+ 'root': ninja_source_path(),
+ 'url': "https://github.com/ninja-build/ninja.git",
+ 'ref': "master"}
]
-def get_c_compiler ():
+
+def get_c_compiler():
return subprocess.check_output([
'xcrun',
'--sdk', 'macosx',
'-find', 'clang'
- ]).rstrip()
+ ]).rstrip()
+
-def get_cxx_compiler ():
+def get_cxx_compiler():
return subprocess.check_output([
'xcrun',
'--sdk', 'macosx',
'-find', 'clang++'
- ]).rstrip()
+ ]).rstrip()
# CFLAGS="-isysroot $(xcrun --sdk macosx --show-sdk-path) -mmacosx-version-min=${DARWIN_DEPLOYMENT_VERSION_OSX}" \
# LDFLAGS="-mmacosx-version-min=${DARWIN_DEPLOYMENT_VERSION_OSX}" \
-def get_deployment_target ():
+
+def get_deployment_target():
return os.environ.get('MACOSX_DEPLOYMENT_TARGET', None)
-def get_c_flags ():
+
+def get_c_flags():
cflags = ''
# sdk_path = subprocess.check_output([
# 'xcrun',
@@ -78,19 +86,21 @@ def get_c_flags ():
# '--show-sdk-path']).rstrip()
# cflags += '-isysroot {}'.format(sdk_path)
- deployment_target = get_deployment_target()
+ deployment_target = get_deployment_target()
if deployment_target:
# cflags += ' -mmacosx-version-min={}'.format(deployment_target)
pass
return cflags
-def get_cxx_flags ():
+
+def get_cxx_flags():
return get_c_flags()
-def get_common_linker_flags ():
+
+def get_common_linker_flags():
linker_flags = ""
- deployment_target = get_deployment_target()
+ deployment_target = get_deployment_target()
if deployment_target:
# if len(linker_flags) > 0:
# linker_flags += ' '
@@ -99,50 +109,62 @@ def get_common_linker_flags ():
return linker_flags
-def get_exe_linker_flags ():
+
+def get_exe_linker_flags():
return get_common_linker_flags()
-def get_shared_linker_flags ():
+
+def get_shared_linker_flags():
return get_common_linker_flags()
-def CMAKE_FLAGS ():
+
+def CMAKE_FLAGS():
return {
"Debug": [
"-DCMAKE_BUILD_TYPE=RelWithDebInfo",
"-DLLVM_ENABLE_ASSERTIONS=ON",
- ],
+ ],
"DebugClang": [
"-DCMAKE_BUILD_TYPE=Debug",
"-DLLVM_ENABLE_ASSERTIONS=ON",
- ],
+ ],
"Release": [
"-DCMAKE_BUILD_TYPE=Release",
"-DLLVM_ENABLE_ASSERTIONS=ON",
- ],
+ ],
"BuildAndIntegration": [
"-DCMAKE_BUILD_TYPE=Release",
"-DLLVM_ENABLE_ASSERTIONS=OFF",
- ],
+ ],
}
-def CMAKE_ENVIRONMENT ():
+
+def CMAKE_ENVIRONMENT():
return {
}
#### COLLECTING ALL ARCHIVES ####
-def collect_archives_in_path (path):
+
+def collect_archives_in_path(path):
files = os.listdir(path)
# Only use libclang and libLLVM archives, and exclude libclang_rt
regexp = "^lib(clang[^_]|LLVM|gtest).*$"
- return [os.path.join(path, file) for file in files if file.endswith(".a") and re.match(regexp, file)]
+ return [
+ os.path.join(
+ path,
+ file) for file in files if file.endswith(".a") and re.match(
+ regexp,
+ file)]
-def archive_list ():
+
+def archive_list():
paths = library_paths()
archive_lists = [collect_archives_in_path(path) for path in paths]
return [archive for archive_list in archive_lists for archive in archive_list]
-def write_archives_txt ():
+
+def write_archives_txt():
f = open(archives_txt(), 'w')
for archive in archive_list():
f.write(archive + "\n")
@@ -150,70 +172,92 @@ def write_archives_txt ():
#### COLLECTING REPOSITORY MD5S ####
-def source_control_status (spec):
+
+def source_control_status(spec):
vcs_for_spec = vcs(spec)
if LLVM_HASH_INCLUDES_DIFFS():
return vcs_for_spec.status() + vcs_for_spec.diff()
else:
return vcs_for_spec.status()
-def source_control_status_for_specs (specs):
+
+def source_control_status_for_specs(specs):
statuses = [source_control_status(spec) for spec in specs]
return "".join(statuses)
-def all_source_control_status ():
+
+def all_source_control_status():
return source_control_status_for_specs(XCODE_REPOSITORIES())
-def md5 (string):
+
+def md5(string):
m = hashlib.md5()
m.update(string)
return m.hexdigest()
-def all_source_control_status_md5 ():
+
+def all_source_control_status_md5():
return md5(all_source_control_status())
#### CHECKING OUT AND BUILDING LLVM ####
+
def apply_patches(spec):
files = os.listdir(os.path.join(lldb_source_path(), 'scripts'))
- patches = [f for f in files if fnmatch.fnmatch(f, spec['name'] + '.*.diff')]
+ patches = [
+ f for f in files if fnmatch.fnmatch(
+ f, spec['name'] + '.*.diff')]
for p in patches:
- run_in_directory(["patch", "-p0", "-i", os.path.join(lldb_source_path(), 'scripts', p)], spec['root'])
+ run_in_directory(["patch",
+ "-p0",
+ "-i",
+ os.path.join(lldb_source_path(),
+ 'scripts',
+ p)],
+ spec['root'])
+
def check_out_if_needed(spec):
if not os.path.isdir(spec['root']):
vcs(spec).check_out()
apply_patches(spec)
-def all_check_out_if_needed ():
- map (check_out_if_needed, XCODE_REPOSITORIES())
-def should_build_llvm ():
+def all_check_out_if_needed():
+ map(check_out_if_needed, XCODE_REPOSITORIES())
+
+
+def should_build_llvm():
if build_type() == BuildType.Xcode:
# TODO use md5 sums
return True
-def do_symlink (source_path, link_path):
+
+def do_symlink(source_path, link_path):
print "Symlinking " + source_path + " to " + link_path
if not os.path.exists(link_path):
os.symlink(source_path, link_path)
-def setup_source_symlink (repo):
+
+def setup_source_symlink(repo):
source_path = repo["root"]
link_path = os.path.join(lldb_source_path(), os.path.basename(source_path))
do_symlink(source_path, link_path)
-def setup_source_symlinks ():
+
+def setup_source_symlinks():
map(setup_source_symlink, XCODE_REPOSITORIES())
-def setup_build_symlink ():
+
+def setup_build_symlink():
# We don't use the build symlinks in llvm.org Xcode-based builds.
if build_type() != BuildType.Xcode:
source_path = package_build_path()
link_path = expected_package_build_path()
do_symlink(source_path, link_path)
-def should_run_cmake (cmake_build_dir):
+
+def should_run_cmake(cmake_build_dir):
# We need to run cmake if our llvm build directory doesn't yet exist.
if not os.path.exists(cmake_build_dir):
return True
@@ -224,14 +268,17 @@ def should_run_cmake (cmake_build_dir):
ninja_path = os.path.join(cmake_build_dir, "build.ninja")
return not os.path.exists(ninja_path)
-def cmake_environment ():
+
+def cmake_environment():
cmake_env = join_dicts(os.environ, CMAKE_ENVIRONMENT())
return cmake_env
+
def is_executable(path):
return os.path.isfile(path) and os.access(path, os.X_OK)
-def find_executable_in_paths (program, paths_to_check):
+
+def find_executable_in_paths(program, paths_to_check):
program_dir, program_name = os.path.split(program)
if program_dir:
if is_executable(program):
@@ -244,14 +291,16 @@ def find_executable_in_paths (program, paths_to_check):
return executable_file
return None
-def find_cmake ():
+
+def find_cmake():
# First check the system PATH env var for cmake
- cmake_binary = find_executable_in_paths("cmake", os.environ["PATH"].split(os.pathsep))
+ cmake_binary = find_executable_in_paths(
+ "cmake", os.environ["PATH"].split(os.pathsep))
if cmake_binary:
# We found it there, use it.
return cmake_binary
- # Check a few more common spots. Xcode launched from Finder
+ # Check a few more common spots. Xcode launched from Finder
# will have the default environment, and may not have
# all the normal places present.
extra_cmake_dirs = [
@@ -263,18 +312,18 @@ def find_cmake ():
if platform.system() == "Darwin":
# Add locations where an official CMake.app package may be installed.
extra_cmake_dirs.extend([
- os.path.join(
- os.path.expanduser("~"),
- "Applications",
- "CMake.app",
- "Contents",
- "bin"),
- os.path.join(
- os.sep,
- "Applications",
- "CMake.app",
- "Contents",
- "bin")])
+ os.path.join(
+ os.path.expanduser("~"),
+ "Applications",
+ "CMake.app",
+ "Contents",
+ "bin"),
+ os.path.join(
+ os.sep,
+ "Applications",
+ "CMake.app",
+ "Contents",
+ "bin")])
cmake_binary = find_executable_in_paths("cmake", extra_cmake_dirs)
if cmake_binary:
@@ -285,38 +334,42 @@ def find_cmake ():
raise Exception(
"could not find cmake in PATH ({}) or in any of these locations ({}), "
"please install cmake or add a link to it in one of those locations".format(
- os.environ["PATH"],
- extra_cmake_dirs))
+ os.environ["PATH"], extra_cmake_dirs))
-def cmake_flags ():
+
+def cmake_flags():
cmake_flags = CMAKE_FLAGS()[lldb_configuration()]
- cmake_flags += [
- "-GNinja",
- "-DCMAKE_C_COMPILER={}".format(get_c_compiler()),
- "-DCMAKE_CXX_COMPILER={}".format(get_cxx_compiler()),
- "-DCMAKE_INSTALL_PREFIX={}".format(expected_package_build_path_for("llvm")),
- "-DCMAKE_C_FLAGS={}".format(get_c_flags()),
- "-DCMAKE_CXX_FLAGS={}".format(get_cxx_flags()),
- "-DCMAKE_EXE_LINKER_FLAGS={}".format(get_exe_linker_flags()),
- "-DCMAKE_SHARED_LINKER_FLAGS={}".format(get_shared_linker_flags())
- ]
+ cmake_flags += ["-GNinja",
+ "-DCMAKE_C_COMPILER={}".format(get_c_compiler()),
+ "-DCMAKE_CXX_COMPILER={}".format(get_cxx_compiler()),
+ "-DCMAKE_INSTALL_PREFIX={}".format(expected_package_build_path_for("llvm")),
+ "-DCMAKE_C_FLAGS={}".format(get_c_flags()),
+ "-DCMAKE_CXX_FLAGS={}".format(get_cxx_flags()),
+ "-DCMAKE_EXE_LINKER_FLAGS={}".format(get_exe_linker_flags()),
+ "-DCMAKE_SHARED_LINKER_FLAGS={}".format(get_shared_linker_flags())]
deployment_target = get_deployment_target()
if deployment_target:
- cmake_flags.append("-DCMAKE_OSX_DEPLOYMENT_TARGET={}".format(deployment_target))
+ cmake_flags.append(
+ "-DCMAKE_OSX_DEPLOYMENT_TARGET={}".format(deployment_target))
return cmake_flags
-def run_cmake (cmake_build_dir, ninja_binary_path):
+
+def run_cmake(cmake_build_dir, ninja_binary_path):
cmake_binary = find_cmake()
print "found cmake binary: using \"{}\"".format(cmake_binary)
command_line = [cmake_binary] + cmake_flags() + [
- "-DCMAKE_MAKE_PROGRAM={}".format(ninja_binary_path),
- llvm_source_path()]
+ "-DCMAKE_MAKE_PROGRAM={}".format(ninja_binary_path),
+ llvm_source_path()]
print "running cmake like so: ({}) in dir ({})".format(command_line, cmake_build_dir)
- subprocess.check_call(command_line, cwd=cmake_build_dir, env=cmake_environment())
+ subprocess.check_call(
+ command_line,
+ cwd=cmake_build_dir,
+ env=cmake_environment())
+
-def create_directories_as_needed (path):
+def create_directories_as_needed(path):
try:
os.makedirs(path)
except OSError as error:
@@ -325,16 +378,19 @@ def create_directories_as_needed (path):
if error.errno != errno.EEXIST:
raise error
-def run_cmake_if_needed (ninja_binary_path):
+
+def run_cmake_if_needed(ninja_binary_path):
cmake_build_dir = package_build_path()
if should_run_cmake(cmake_build_dir):
# Create the build directory as needed
- create_directories_as_needed (cmake_build_dir)
+ create_directories_as_needed(cmake_build_dir)
run_cmake(cmake_build_dir, ninja_binary_path)
-def build_ninja_if_needed ():
+
+def build_ninja_if_needed():
# First check if ninja is in our path. If so, there's nothing to do.
- ninja_binary_path = find_executable_in_paths("ninja", os.environ["PATH"].split(os.pathsep))
+ ninja_binary_path = find_executable_in_paths(
+ "ninja", os.environ["PATH"].split(os.pathsep))
if ninja_binary_path:
# It's on the path. cmake will find it. We're good.
print "found ninja here: \"{}\"".format(ninja_binary_path)
@@ -347,20 +403,29 @@ def build_ninja_if_needed ():
# Build ninja
command_line = ["python", "configure.py", "--bootstrap"]
print "building ninja like so: ({}) in dir ({})".format(command_line, ninja_build_dir)
- subprocess.check_call(command_line, cwd=ninja_build_dir, env=os.environ)
+ subprocess.check_call(
+ command_line,
+ cwd=ninja_build_dir,
+ env=os.environ)
return ninja_binary_path
-def join_dicts (dict1, dict2):
+
+def join_dicts(dict1, dict2):
d = dict1.copy()
d.update(dict2)
return d
-def build_llvm (ninja_binary_path):
+
+def build_llvm(ninja_binary_path):
cmake_build_dir = package_build_path()
- subprocess.check_call([ninja_binary_path], cwd=cmake_build_dir, env=cmake_environment())
+ subprocess.check_call(
+ [ninja_binary_path],
+ cwd=cmake_build_dir,
+ env=cmake_environment())
+
-def build_llvm_if_needed ():
+def build_llvm_if_needed():
if should_build_llvm():
ninja_binary_path = build_ninja_if_needed()
run_cmake_if_needed(ninja_binary_path)
diff --git a/lldb/scripts/Xcode/lldbbuild.py b/lldb/scripts/Xcode/lldbbuild.py
index bb43315..9c087aa 100644
--- a/lldb/scripts/Xcode/lldbbuild.py
+++ b/lldb/scripts/Xcode/lldbbuild.py
@@ -3,7 +3,8 @@ import subprocess
#### UTILITIES ####
-def enum (*sequential, **named):
+
+def enum(*sequential, **named):
enums = dict(zip(sequential, range(len(sequential))), **named)
return type('Enum', (), enums)
@@ -11,42 +12,53 @@ def enum (*sequential, **named):
#### INTERFACE TO THE XCODEPROJ ####
-def lldb_source_path ():
+
+def lldb_source_path():
return os.environ.get('SRCROOT')
-def expected_llvm_build_path ():
+
+def expected_llvm_build_path():
if build_type() == BuildType.Xcode:
return package_build_path()
else:
- return os.path.join(os.environ.get('LLDB_PATH_TO_LLVM_BUILD'), package_build_dir_name("llvm"))
+ return os.path.join(
+ os.environ.get('LLDB_PATH_TO_LLVM_BUILD'),
+ package_build_dir_name("llvm"))
+
-def archives_txt ():
+def archives_txt():
return os.path.join(expected_package_build_path(), "archives.txt")
-def expected_package_build_path ():
+
+def expected_package_build_path():
return os.path.abspath(os.path.join(expected_llvm_build_path(), ".."))
-def architecture ():
+
+def architecture():
platform_name = os.environ.get('RC_PLATFORM_NAME')
if not platform_name:
platform_name = os.environ.get('PLATFORM_NAME')
platform_arch = os.environ.get('ARCHS').split()[-1]
return platform_name + "-" + platform_arch
-def lldb_configuration ():
+
+def lldb_configuration():
return os.environ.get('CONFIGURATION')
-def llvm_configuration ():
+
+def llvm_configuration():
return os.environ.get('LLVM_CONFIGURATION')
-def llvm_build_dirtree ():
+
+def llvm_build_dirtree():
return os.environ.get('LLVM_BUILD_DIRTREE')
# Edit the code below when adding build styles.
BuildType = enum('Xcode') # (Debug,DebugClang,Release)
-def build_type ():
+
+def build_type():
return BuildType.Xcode
#### VCS UTILITIES ####
@@ -54,31 +66,48 @@ def build_type ():
VCS = enum('git',
'svn')
+
def run_in_directory(args, path):
return subprocess.check_output(args, cwd=path)
+
class Git:
- def __init__ (self, spec):
+
+ def __init__(self, spec):
self.spec = spec
- def status (self):
+
+ def status(self):
return run_in_directory(["git", "branch", "-v"], self.spec['root'])
- def diff (self):
+
+ def diff(self):
return run_in_directory(["git", "diff"], self.spec['root'])
- def check_out (self):
- run_in_directory(["git", "clone", "--depth=1", self.spec['url'], self.spec['root']], lldb_source_path())
+
+ def check_out(self):
+ run_in_directory(["git",
+ "clone",
+ "--depth=1",
+ self.spec['url'],
+ self.spec['root']],
+ lldb_source_path())
run_in_directory(["git", "fetch", "--all"], self.spec['root'])
- run_in_directory(["git", "checkout", self.spec['ref']], self.spec['root'])
+ run_in_directory(["git", "checkout", self.spec[
+ 'ref']], self.spec['root'])
+
class SVN:
- def __init__ (self, spec):
+
+ def __init__(self, spec):
self.spec = spec
- def status (self):
+
+ def status(self):
return run_in_directory(["svn", "info"], self.spec['root'])
- def diff (self):
+
+ def diff(self):
return run_in_directory(["svn", "diff"], self.spec['root'])
# TODO implement check_out
-def vcs (spec):
+
+def vcs(spec):
if spec['vcs'] == VCS.git:
return Git(spec)
elif spec['vcs'] == VCS.svn:
@@ -88,47 +117,59 @@ def vcs (spec):
#### SOURCE PATHS ####
-def llvm_source_path ():
+
+def llvm_source_path():
if build_type() == BuildType.Xcode:
return os.path.join(lldb_source_path(), "llvm")
-def clang_source_path ():
+
+def clang_source_path():
if build_type() == BuildType.Xcode:
return os.path.join(llvm_source_path(), "tools", "clang")
-def ninja_source_path ():
+
+def ninja_source_path():
if build_type() == BuildType.Xcode:
return os.path.join(lldb_source_path(), "ninja")
#### BUILD PATHS ####
-def packages ():
+
+def packages():
return ["llvm"]
-def package_build_dir_name (package):
+
+def package_build_dir_name(package):
return package + "-" + architecture()
-def expected_package_build_path_for (package):
+
+def expected_package_build_path_for(package):
if build_type() == BuildType.Xcode:
if package != "llvm":
- raise("On Xcode build, we only support the llvm package: requested {}".format(package))
+ raise "On Xcode build, we only support the llvm package: requested {}"
return package_build_path()
- return os.path.join(expected_package_build_path(), package_build_dir_name(package))
+ return os.path.join(
+ expected_package_build_path(),
+ package_build_dir_name(package))
-def expected_package_build_paths ():
+
+def expected_package_build_paths():
return [expected_package_build_path_for(package) for package in packages()]
-def library_path (build_path):
+
+def library_path(build_path):
return build_path + "/lib"
-def library_paths ():
+
+def library_paths():
if build_type() == BuildType.Xcode:
package_build_paths = [package_build_path()]
else:
package_build_paths = expected_package_build_paths()
return [library_path(build_path) for build_path in package_build_paths]
-def package_build_path ():
+
+def package_build_path():
return os.path.join(
llvm_build_dirtree(),
os.environ["LLVM_CONFIGURATION"],
diff --git a/lldb/scripts/Xcode/package-clang-headers.py b/lldb/scripts/Xcode/package-clang-headers.py
index 55ecc90..37f9991 100644
--- a/lldb/scripts/Xcode/package-clang-headers.py
+++ b/lldb/scripts/Xcode/package-clang-headers.py
@@ -17,24 +17,24 @@ import sys
import lldbbuild
if len(sys.argv) != 3:
- print "usage: " + sys.argv[0] + " TARGET_DIR LLVM_BUILD_DIR"
- sys.exit(1)
+ print "usage: " + sys.argv[0] + " TARGET_DIR LLVM_BUILD_DIR"
+ sys.exit(1)
target_dir = sys.argv[1]
llvm_build_dir = lldbbuild.expected_package_build_path_for("llvm")
if not os.path.isdir(target_dir):
print target_dir + " doesn't exist"
- sys.exit(1)
+ sys.exit(1)
if not os.path.isdir(llvm_build_dir):
- llvm_build_dir = re.sub ("-macosx-", "-iphoneos-", llvm_build_dir)
+ llvm_build_dir = re.sub("-macosx-", "-iphoneos-", llvm_build_dir)
if not os.path.isdir(llvm_build_dir):
- llvm_build_dir = re.sub ("-iphoneos-", "-appletvos-", llvm_build_dir)
+ llvm_build_dir = re.sub("-iphoneos-", "-appletvos-", llvm_build_dir)
if not os.path.isdir(llvm_build_dir):
- llvm_build_dir = re.sub ("-appletvos-", "-watchos-", llvm_build_dir)
+ llvm_build_dir = re.sub("-appletvos-", "-watchos-", llvm_build_dir)
if not os.path.isdir(llvm_build_dir):
print llvm_build_dir + " doesn't exist"
@@ -59,7 +59,7 @@ for subdir in os.listdir(clang_dir):
version_dir = os.path.join(clang_dir, subdir)
break
-if version_dir == None:
+if version_dir is None:
print "Couldn't find a subdirectory of the form #(.#)... in " + clang_dir
sys.exit(1)
diff --git a/lldb/scripts/buildbot.py b/lldb/scripts/buildbot.py
index 0c04d9c..29c383c 100755
--- a/lldb/scripts/buildbot.py
+++ b/lldb/scripts/buildbot.py
@@ -7,7 +7,9 @@ import shutil
import subprocess
import sys
+
class BuildError(Exception):
+
def __init__(self,
string=None,
path=None,
@@ -15,23 +17,28 @@ class BuildError(Exception):
self.m_string = string
self.m_path = path
self.m_inferior_error = inferior_error
+
def __str__(self):
if self.m_path and self.m_string:
- return "Build error: %s (referring to %s)" % (self.m_string, self.m_path)
+ return "Build error: %s (referring to %s)" % (
+ self.m_string, self.m_path)
if self.m_path:
return "Build error (referring to %s)" % (self.m_path)
if self.m_string:
return "Build error: %s" % (self.m_string)
return "Build error"
+
class LLDBBuildBot:
- def __init__(self,
- build_directory_path,
- log_path,
- lldb_repository_url="http://llvm.org/svn/llvm-project/lldb/trunk",
- llvm_repository_url="http://llvm.org/svn/llvm-project/llvm/trunk",
- clang_repository_url="http://llvm.org/svn/llvm-project/cfe/trunk",
- revision=None):
+
+ def __init__(
+ self,
+ build_directory_path,
+ log_path,
+ lldb_repository_url="http://llvm.org/svn/llvm-project/lldb/trunk",
+ llvm_repository_url="http://llvm.org/svn/llvm-project/llvm/trunk",
+ clang_repository_url="http://llvm.org/svn/llvm-project/cfe/trunk",
+ revision=None):
self.m_build_directory_path = os.path.abspath(build_directory_path)
self.m_log_path = os.path.abspath(log_path)
self.m_lldb_repository_url = lldb_repository_url
@@ -39,34 +46,44 @@ class LLDBBuildBot:
self.m_clang_repository_url = clang_repository_url
self.m_revision = revision
self.m_log_stream = None
+
def Setup(self):
if os.path.exists(self.m_build_directory_path):
- raise BuildError(string="Build directory exists", path=self.m_build_directory_path)
+ raise BuildError(
+ string="Build directory exists",
+ path=self.m_build_directory_path)
if os.path.exists(self.m_log_path):
raise BuildError(string="Log file exists", path=self.m_log_path)
self.m_log_stream = open(self.m_log_path, 'w')
os.mkdir(self.m_build_directory_path)
+
def Checkout(self):
os.chdir(self.m_build_directory_path)
-
+
cmdline_prefix = []
-
- if self.m_revision != None:
+
+ if self.m_revision is not None:
cmdline_prefix = ["svn", "-r %s" % (self.m_revision), "co"]
else:
cmdline_prefix = ["svn", "co"]
- returncode = subprocess.call(cmdline_prefix + [self.m_lldb_repository_url, "lldb"],
- stdout=self.m_log_stream,
- stderr=self.m_log_stream)
+ returncode = subprocess.call(
+ cmdline_prefix + [
+ self.m_lldb_repository_url,
+ "lldb"],
+ stdout=self.m_log_stream,
+ stderr=self.m_log_stream)
if returncode != 0:
raise BuildError(string="Couldn't checkout LLDB")
os.chdir("lldb")
- returncode = subprocess.call(cmdline_prefix + [self.m_llvm_repository_url, "llvm.checkout"],
- stdout=self.m_log_stream,
- stderr=self.m_log_stream)
+ returncode = subprocess.call(
+ cmdline_prefix + [
+ self.m_llvm_repository_url,
+ "llvm.checkout"],
+ stdout=self.m_log_stream,
+ stderr=self.m_log_stream)
if returncode != 0:
raise BuildError(string="Couldn't checkout LLVM")
@@ -75,25 +92,32 @@ class LLDBBuildBot:
os.chdir("llvm/tools")
- returncode = subprocess.call(cmdline_prefix + [self.m_clang_repository_url, "clang"],
- stdout=self.m_log_stream,
- stderr=self.m_log_stream)
+ returncode = subprocess.call(
+ cmdline_prefix + [
+ self.m_clang_repository_url,
+ "clang"],
+ stdout=self.m_log_stream,
+ stderr=self.m_log_stream)
if returncode != 0:
raise BuildError(string="Couldn't checkout Clang")
+
def Build(self):
os.chdir(self.m_build_directory_path)
os.chdir("lldb/llvm")
- returncode = subprocess.call(["./configure", "--disable-optimized", "--enable-assertions", "--enable-targets=x86,x86_64,arm"],
- stdout=self.m_log_stream,
+ returncode = subprocess.call(["./configure",
+ "--disable-optimized",
+ "--enable-assertions",
+ "--enable-targets=x86,x86_64,arm"],
+ stdout=self.m_log_stream,
stderr=self.m_log_stream)
if returncode != 0:
raise BuildError(string="Couldn't configure LLVM/Clang")
- returncode = subprocess.call(["make"],
- stdout=self.m_log_stream,
+ returncode = subprocess.call(["make"],
+ stdout=self.m_log_stream,
stderr=self.m_log_stream)
if returncode != 0:
@@ -102,41 +126,61 @@ class LLDBBuildBot:
os.chdir(self.m_build_directory_path)
os.chdir("lldb")
- returncode = subprocess.call(["xcodebuild",
- "-project", "lldb.xcodeproj",
- "-target", "lldb-tool",
- "-configuration", "Debug",
+ returncode = subprocess.call(["xcodebuild",
+ "-project", "lldb.xcodeproj",
+ "-target", "lldb-tool",
+ "-configuration", "Debug",
"-arch", "x86_64",
"LLVM_CONFIGURATION=Debug+Asserts",
"OBJROOT=build"],
- stdout=self.m_log_stream,
- stderr=self.m_log_stream)
+ stdout=self.m_log_stream,
+ stderr=self.m_log_stream)
if returncode != 0:
raise BuildError(string="Couldn't build LLDB")
+
def Test(self):
os.chdir(self.m_build_directory_path)
os.chdir("lldb/test")
-
- returncode = subprocess.call(["./dotest.py", "-t"],
- stdout=self.m_log_stream,
+
+ returncode = subprocess.call(["./dotest.py", "-t"],
+ stdout=self.m_log_stream,
stderr=self.m_log_stream)
+
def Takedown(self):
os.chdir("/tmp")
self.m_log_stream.close()
shutil.rmtree(self.m_build_directory_path)
+
def Run(self):
self.Setup()
self.Checkout()
self.Build()
- #self.Test()
+ # self.Test()
self.Takedown()
+
def GetArgParser():
- parser = argparse.ArgumentParser(description="Try to build LLDB/LLVM/Clang and run the full test suite.")
- parser.add_argument("--build-path", "-b", required=True, help="A (nonexistent) path to put temporary build products into", metavar="path")
- parser.add_argument("--log-file", "-l", required=True, help="The name of a (nonexistent) log file", metavar="file")
- parser.add_argument("--revision", "-r", required=False, help="The LLVM revision to use", metavar="N")
+ parser = argparse.ArgumentParser(
+ description="Try to build LLDB/LLVM/Clang and run the full test suite.")
+ parser.add_argument(
+ "--build-path",
+ "-b",
+ required=True,
+ help="A (nonexistent) path to put temporary build products into",
+ metavar="path")
+ parser.add_argument(
+ "--log-file",
+ "-l",
+ required=True,
+ help="The name of a (nonexistent) log file",
+ metavar="file")
+ parser.add_argument(
+ "--revision",
+ "-r",
+ required=False,
+ help="The LLVM revision to use",
+ metavar="N")
return parser
parser = GetArgParser()
diff --git a/lldb/scripts/finishSwigWrapperClasses.py b/lldb/scripts/finishSwigWrapperClasses.py
index cce160d..4607624 100644
--- a/lldb/scripts/finishSwigWrapperClasses.py
+++ b/lldb/scripts/finishSwigWrapperClasses.py
@@ -34,10 +34,12 @@ import utilsOsType # Determine the OS type this script is running on
import utilsDebug # Debug Python scripts
# Instantiations:
-gbDbgVerbose = False # True = Turn on script function tracing, False = off.
+# True = Turn on script function tracing, False = off.
+gbDbgVerbose = False
gbDbgFlag = False # Global debug mode flag, set by input parameter
- # --dbgFlag. True = operate in debug mode.
-gbMakeFileFlag = False # True = yes called from makefile system, False = not.
+# --dbgFlag. True = operate in debug mode.
+# True = yes called from makefile system, False = not.
+gbMakeFileFlag = False
# User facing text:
strMsgErrorNoMain = "Program called by another Python script not allowed"
@@ -84,7 +86,7 @@ Usage:\n\
finishSwigWrapperClasses.py --srcRoot=ADirPath --targetDir=ADirPath\n\
--cfgBldDir=ADirPath --prefix=ADirPath --lldbLibDir=ADirPath -m -d\n\
\n\
-" #TAG_PROGRAM_HELP_INFO
+" # TAG_PROGRAM_HELP_INFO
#++---------------------------------------------------------------------------
# Details: Exit the program on success. Called on program successfully done
@@ -94,6 +96,8 @@ Usage:\n\
# Returns: None.
# Throws: None.
#--
+
+
def program_exit_success(vnResult, vMsg):
strMsg = ""
@@ -111,6 +115,8 @@ def program_exit_success(vnResult, vMsg):
# Returns: None.
# Throws: None.
#--
+
+
def program_exit_on_failure(vnResult, vMsg):
print(("%s%s (%d)" % (strExitMsgError, vMsg, vnResult)))
sys.exit(vnResult)
@@ -124,6 +130,8 @@ def program_exit_on_failure(vnResult, vMsg):
# Returns: None.
# Throws: None.
#--
+
+
def program_exit(vnResult, vMsg):
if vnResult >= 0:
program_exit_success(vnResult, vMsg)
@@ -136,6 +144,8 @@ def program_exit(vnResult, vMsg):
# Returns: None.
# Throws: None.
#--
+
+
def print_out_input_parameters(vDictArgs):
for arg, val in list(vDictArgs.items()):
strEqs = ""
@@ -153,24 +163,32 @@ def print_out_input_parameters(vDictArgs):
# Dict - Map of arguments names to argument values
# Throws: None.
#--
+
+
def validate_arguments(vArgv):
dbg = utilsDebug.CDebugFnVerbose("validate_arguments()")
strMsg = ""
dictArgs = {}
nResult = 0
- strListArgs = "hdm" # Format "hiox:" = -h -i -o -x <arg>
- listLongArgs = ["srcRoot=", "targetDir=", "cfgBldDir=", "prefix=", "cmakeBuildConfiguration=",
- "lldbLibDir=", "argsFile"]
- dictArgReq = { "-h": "o", # o = optional, m = mandatory
- "-d": "o",
- "-m": "o",
- "--srcRoot": "m",
- "--targetDir": "m",
- "--cfgBldDir": "o",
- "--prefix": "o",
- "--cmakeBuildConfiguration": "o",
- "--lldbLibDir": "o",
- "--argsFile": "o" }
+ strListArgs = "hdm" # Format "hiox:" = -h -i -o -x <arg>
+ listLongArgs = [
+ "srcRoot=",
+ "targetDir=",
+ "cfgBldDir=",
+ "prefix=",
+ "cmakeBuildConfiguration=",
+ "lldbLibDir=",
+ "argsFile"]
+ dictArgReq = {"-h": "o", # o = optional, m = mandatory
+ "-d": "o",
+ "-m": "o",
+ "--srcRoot": "m",
+ "--targetDir": "m",
+ "--cfgBldDir": "o",
+ "--prefix": "o",
+ "--cmakeBuildConfiguration": "o",
+ "--lldbLibDir": "o",
+ "--argsFile": "o"}
# Check for mandatory parameters
nResult, dictArgs, strMsg = utilsArgsParse.parse(vArgv, strListArgs,
@@ -196,18 +214,24 @@ def validate_arguments(vArgv):
# Str - Error message.
# Throws: None.
#--
+
+
def run_post_process(vStrScriptLang, vstrFinishFileName, vDictArgs):
dbg = utilsDebug.CDebugFnVerbose("run_post_process()")
nResult = 0
strStatusMsg = ""
strScriptFile = vstrFinishFileName % vStrScriptLang
- strScriptFileDir = os.path.normpath(os.path.join(vDictArgs["--srcRoot"], "scripts", vStrScriptLang))
+ strScriptFileDir = os.path.normpath(
+ os.path.join(
+ vDictArgs["--srcRoot"],
+ "scripts",
+ vStrScriptLang))
strScriptFilePath = os.path.join(strScriptFileDir, strScriptFile)
# Check for the existence of the script file
strPath = os.path.normcase(strScriptFilePath)
bOk = os.path.exists(strPath)
- if bOk == False:
+ if not bOk:
strDir = os.path.normcase(strScriptFileDir)
strStatusMsg = strScriptNotFound % (strScriptFile, strDir)
return (-9, strStatusMsg)
@@ -221,7 +245,7 @@ def run_post_process(vStrScriptLang, vstrFinishFileName, vDictArgs):
sys.path.append(strDir)
# Execute the specific language script
- dictArgs = vDictArgs # Remove any args not required before passing on
+ dictArgs = vDictArgs # Remove any args not required before passing on
strModuleName = strScriptFile[: strScriptFile.__len__() - 3]
module = __import__(strModuleName)
nResult, strStatusMsg = module.main(dictArgs)
@@ -242,17 +266,23 @@ def run_post_process(vStrScriptLang, vstrFinishFileName, vDictArgs):
# Str - Error message.
# Throws: None.
#--
+
+
def run_post_process_for_each_script_supported(vDictArgs):
- dbg = utilsDebug.CDebugFnVerbose("run_post_process_for_each_script_supported()")
+ dbg = utilsDebug.CDebugFnVerbose(
+ "run_post_process_for_each_script_supported()")
nResult = 0
strStatusMsg = ""
- strScriptDir = os.path.normpath(os.path.join(vDictArgs["--srcRoot"], "scripts"))
+ strScriptDir = os.path.normpath(
+ os.path.join(
+ vDictArgs["--srcRoot"],
+ "scripts"))
strFinishFileName = "finishSwig%sLLDB.py"
# Check for the existence of the scripts folder
strScriptsDir = os.path.normcase(strScriptDir)
bOk = os.path.exists(strScriptsDir)
- if bOk == False:
+ if not bOk:
return (-8, strScriptDirNotFound)
# Look for any script language directories to build for
@@ -263,8 +293,8 @@ def run_post_process_for_each_script_supported(vDictArgs):
# __pycache__ is a magic directory in Python 3 that holds .pyc files
if scriptLang != "__pycache__" and scriptLang != "swig_bot_lib":
dbg.dump_text("Executing language script for \'%s\'" % scriptLang)
- nResult, strStatusMsg = run_post_process(scriptLang, strFinishFileName,
- vDictArgs)
+ nResult, strStatusMsg = run_post_process(
+ scriptLang, strFinishFileName, vDictArgs)
if nResult < 0:
break
@@ -283,6 +313,8 @@ def run_post_process_for_each_script_supported(vDictArgs):
# Returns: None
# Throws: None.
#--
+
+
def main(vArgv):
dbg = utilsDebug.CDebugFnVerbose("main()")
bOk = False
@@ -317,7 +349,7 @@ def main(vArgv):
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
-#TAG_PROGRAM_HELP_INFO
+# TAG_PROGRAM_HELP_INFO
""" Details: Program main entry point.
--------------------------------------------------------------------------
diff --git a/lldb/scripts/install_custom_python.py b/lldb/scripts/install_custom_python.py
index 5a8f48a..b67f063 100644
--- a/lldb/scripts/install_custom_python.py
+++ b/lldb/scripts/install_custom_python.py
@@ -26,24 +26,33 @@ import os
import shutil
import sys
+
def copy_one_file(dest_dir, source_dir, filename):
source_path = os.path.join(source_dir, filename)
dest_path = os.path.join(dest_dir, filename)
print 'Copying file %s ==> %s...' % (source_path, dest_path)
shutil.copyfile(source_path, dest_path)
-def copy_named_files(dest_dir, source_dir, files, extensions, copy_debug_suffix_also):
+
+def copy_named_files(
+ dest_dir,
+ source_dir,
+ files,
+ extensions,
+ copy_debug_suffix_also):
for (file, ext) in itertools.product(files, extensions):
copy_one_file(dest_dir, source_dir, file + '.' + ext)
if copy_debug_suffix_also:
copy_one_file(dest_dir, source_dir, file + '_d.' + ext)
+
def copy_subdirectory(dest_dir, source_dir, subdir):
dest_dir = os.path.join(dest_dir, subdir)
source_dir = os.path.join(source_dir, subdir)
print 'Copying directory %s ==> %s...' % (source_dir, dest_dir)
shutil.copytree(source_dir, dest_dir)
+
def copy_distro(dest_dir, dest_subdir, source_dir, source_prefix):
dest_dir = os.path.join(dest_dir, dest_subdir)
@@ -54,11 +63,19 @@ def copy_distro(dest_dir, dest_subdir, source_dir, source_prefix):
if source_prefix:
PCbuild_dir = os.path.join(PCbuild_dir, source_prefix)
# First copy the files that go into the root of the new distribution. This
- # includes the Python executables, python27(_d).dll, and relevant PDB files.
+ # includes the Python executables, python27(_d).dll, and relevant PDB
+ # files.
print 'Copying Python executables...'
- copy_named_files(dest_dir, PCbuild_dir, ['w9xpopen'], ['exe', 'pdb'], False)
- copy_named_files(dest_dir, PCbuild_dir, ['python_d', 'pythonw_d'], ['exe'], False)
- copy_named_files(dest_dir, PCbuild_dir, ['python', 'pythonw'], ['exe', 'pdb'], False)
+ copy_named_files(
+ dest_dir, PCbuild_dir, ['w9xpopen'], [
+ 'exe', 'pdb'], False)
+ copy_named_files(
+ dest_dir, PCbuild_dir, [
+ 'python_d', 'pythonw_d'], ['exe'], False)
+ copy_named_files(
+ dest_dir, PCbuild_dir, [
+ 'python', 'pythonw'], [
+ 'exe', 'pdb'], False)
copy_named_files(dest_dir, PCbuild_dir, ['python27'], ['dll', 'pdb'], True)
# Next copy everything in the Include directory.
@@ -83,8 +100,17 @@ def copy_distro(dest_dir, dest_subdir, source_dir, source_prefix):
copy_subdirectory(tools_dest_dir, tools_source_dir, 'versioncheck')
copy_subdirectory(tools_dest_dir, tools_source_dir, 'webchecker')
- pyd_names = ['_ctypes', '_ctypes_test', '_elementtree', '_multiprocessing', '_socket',
- '_testcapi', 'pyexpat', 'select', 'unicodedata', 'winsound']
+ pyd_names = [
+ '_ctypes',
+ '_ctypes_test',
+ '_elementtree',
+ '_multiprocessing',
+ '_socket',
+ '_testcapi',
+ 'pyexpat',
+ 'select',
+ 'unicodedata',
+ 'winsound']
# Copy builtin extension modules (pyd files)
dlls_dir = os.path.join(dest_dir, 'DLLs')
@@ -100,11 +126,26 @@ def copy_distro(dest_dir, dest_subdir, source_dir, source_prefix):
copy_named_files(libs_dir, PCbuild_dir, ['python27'], ['lib'], True)
-parser = argparse.ArgumentParser(description='Install a custom Python distribution')
-parser.add_argument('--source', required=True, help='The root of the source tree where Python is built.')
-parser.add_argument('--dest', required=True, help='The location to install the Python distributions.')
-parser.add_argument('--overwrite', default=False, action='store_true', help='If the destination directory already exists, destroys its contents first.')
-parser.add_argument('--silent', default=False, action='store_true', help='If --overwite was specified, suppress confirmation before deleting a directory tree.')
+parser = argparse.ArgumentParser(
+ description='Install a custom Python distribution')
+parser.add_argument(
+ '--source',
+ required=True,
+ help='The root of the source tree where Python is built.')
+parser.add_argument(
+ '--dest',
+ required=True,
+ help='The location to install the Python distributions.')
+parser.add_argument(
+ '--overwrite',
+ default=False,
+ action='store_true',
+ help='If the destination directory already exists, destroys its contents first.')
+parser.add_argument(
+ '--silent',
+ default=False,
+ action='store_true',
+ help='If --overwite was specified, suppress confirmation before deleting a directory tree.')
args = parser.parse_args()
diff --git a/lldb/scripts/swig_bot.py b/lldb/scripts/swig_bot.py
index 95f4eb8..888fc10 100644
--- a/lldb/scripts/swig_bot.py
+++ b/lldb/scripts/swig_bot.py
@@ -18,6 +18,7 @@ import use_lldb_suite
from swig_bot_lib import client
from swig_bot_lib import server
+
def process_args(args):
parser = argparse.ArgumentParser(
description='Run swig-bot client or server.')
@@ -54,11 +55,13 @@ def process_args(args):
return options
+
def run_client(options):
logging.info("Running swig_bot in client mode")
client.finalize_subparser_options(options)
client.run(options)
+
def run_server(options):
logging.info("Running swig_bot in server mode")
server.finalize_subparser_options(options)
@@ -68,7 +71,8 @@ if __name__ == "__main__":
options = process_args(sys.argv[1:])
try:
if options.func is None:
- logging.error("Unknown mode specified. Expected client or server.")
+ logging.error(
+ "Unknown mode specified. Expected client or server.")
sys.exit(-1)
else:
options.func(options)
diff --git a/lldb/scripts/swig_bot_lib/client.py b/lldb/scripts/swig_bot_lib/client.py
index 9bf55b4..d9f0fb4 100644
--- a/lldb/scripts/swig_bot_lib/client.py
+++ b/lldb/scripts/swig_bot_lib/client.py
@@ -30,6 +30,7 @@ from . import remote
default_ip = "127.0.0.1"
default_port = 8537
+
def add_subparser_args(parser):
"""Returns options processed from the provided command line.
@@ -41,9 +42,11 @@ def add_subparser_args(parser):
# searches for a copy of swig located on the physical machine. If
# used with 1 argument, the argument is the path to a swig executable.
class FindLocalSwigAction(argparse.Action):
+
def __init__(self, option_strings, dest, **kwargs):
super(FindLocalSwigAction, self).__init__(
option_strings, dest, nargs='?', **kwargs)
+
def __call__(self, parser, namespace, values, option_string=None):
swig_exe = None
if values is None:
@@ -58,18 +61,20 @@ def add_subparser_args(parser):
# of the form `ip_address[:port]`. If the port is unspecified, the
# default port is used.
class RemoteIpAction(argparse.Action):
+
def __init__(self, option_strings, dest, **kwargs):
super(RemoteIpAction, self).__init__(
option_strings, dest, nargs='?', **kwargs)
+
def __call__(self, parser, namespace, values, option_string=None):
ip_port = None
if values is None:
ip_port = (default_ip, default_port)
else:
result = values.split(':')
- if len(result)==1:
+ if len(result) == 1:
ip_port = (result[0], default_port)
- elif len(result)==2:
+ elif len(result) == 2:
ip_port = (result[0], int(result[1]))
else:
raise ValueError("Invalid connection string")
@@ -108,6 +113,7 @@ def add_subparser_args(parser):
action="append",
help="Specifies the language to generate bindings for")
+
def finalize_subparser_options(options):
if options.languages is None:
options.languages = ['python']
@@ -118,6 +124,7 @@ def finalize_subparser_options(options):
return options
+
def establish_remote_connection(ip_port):
logging.debug("Creating socket...")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -127,6 +134,7 @@ def establish_remote_connection(ip_port):
logging.info("Connection established...")
return s
+
def transmit_request(connection, packed_input):
logging.info("Sending {} bytes of compressed data."
.format(len(packed_input)))
@@ -138,27 +146,28 @@ def transmit_request(connection, packed_input):
response = sockutil.recvall(connection, response_len)
return response
+
def handle_response(options, connection, response):
logging.debug("Received {} byte response.".format(len(response)))
logging.debug("Creating output directory {}"
- .format(options.target_dir))
+ .format(options.target_dir))
os.makedirs(options.target_dir, exist_ok=True)
logging.info("Unpacking response archive into {}"
- .format(options.target_dir))
+ .format(options.target_dir))
local.unpack_archive(options.target_dir, response)
response_file_path = os.path.normpath(
os.path.join(options.target_dir, "swig_output.json"))
if not os.path.isfile(response_file_path):
logging.error("Response file '{}' does not exist."
- .format(response_file_path))
+ .format(response_file_path))
return
try:
response = remote.deserialize_response_status(
io.open(response_file_path))
if response[0] != 0:
logging.error("An error occurred during generation. Status={}"
- .format(response[0]))
+ .format(response[0]))
logging.error(response[1])
else:
logging.info("SWIG generation successful.")
@@ -167,6 +176,7 @@ def handle_response(options, connection, response):
finally:
os.unlink(response_file_path)
+
def run(options):
if options.remote is None:
logging.info("swig bot client using local swig installation at '{}'"
@@ -193,7 +203,8 @@ def run(options):
("scripts/Python", ".swig"),
("scripts/interface", ".i")]
zip_data = io.BytesIO()
- packed_input = local.pack_archive(zip_data, options.src_root, inputs)
+ packed_input = local.pack_archive(
+ zip_data, options.src_root, inputs)
logging.info("(null) -> config.json")
packed_input.writestr("config.json", config)
packed_input.close()
@@ -202,4 +213,4 @@ def run(options):
handle_response(options, connection, response)
finally:
if connection is not None:
- connection.close() \ No newline at end of file
+ connection.close()
diff --git a/lldb/scripts/swig_bot_lib/local.py b/lldb/scripts/swig_bot_lib/local.py
index 7cca0b3..b26ea2f 100644
--- a/lldb/scripts/swig_bot_lib/local.py
+++ b/lldb/scripts/swig_bot_lib/local.py
@@ -26,12 +26,14 @@ import use_lldb_suite
# Package imports
from lldbsuite.support import fs
+
class LocalConfig(object):
src_root = None
target_dir = None
languages = None
swig_executable = None
+
def pack_archive(bytes_io, src_root, filters):
logging.info("Creating input file package...")
zip_file = None
@@ -53,9 +55,9 @@ def pack_archive(bytes_io, src_root, filters):
candidates = [os.path.normpath(os.path.join(full_path, f))
for f in os.listdir(full_path)]
actual = filter(
- lambda f : os.path.isfile(f) and os.path.splitext(f)[1] == ext,
+ lambda f: os.path.isfile(f) and os.path.splitext(f)[1] == ext,
candidates)
- return (subfolder, map(lambda f : os.path.basename(f), actual))
+ return (subfolder, map(lambda f: os.path.basename(f), actual))
archive_entries = map(filter_func, filters)
else:
for (root, dirs, files) in os.walk(src_root):
@@ -77,6 +79,7 @@ def pack_archive(bytes_io, src_root, filters):
return zip_file
+
def unpack_archive(folder, archive_bytes):
zip_data = io.BytesIO(archive_bytes)
logging.debug("Opening zip archive...")
@@ -84,6 +87,7 @@ def unpack_archive(folder, archive_bytes):
zip_file.extractall(folder)
zip_file.close()
+
def generate(options):
include_folder = os.path.join(options.src_root, "include")
in_file = os.path.join(options.src_root, "scripts", "lldb.swig")
@@ -128,4 +132,4 @@ def generate(options):
logging.error("An error occurred executing swig. returncode={}"
.format(e.returncode))
logging.error(e.output)
- return (e.returncode, e.output) \ No newline at end of file
+ return (e.returncode, e.output)
diff --git a/lldb/scripts/swig_bot_lib/remote.py b/lldb/scripts/swig_bot_lib/remote.py
index 590a873d..712a5e2 100644
--- a/lldb/scripts/swig_bot_lib/remote.py
+++ b/lldb/scripts/swig_bot_lib/remote.py
@@ -20,19 +20,23 @@ import sys
# LLDB modules
import use_lldb_suite
+
def generate_config(languages):
config = {"languages": languages}
return json.dumps(config)
+
def parse_config(json_reader):
json_data = json_reader.read()
options_dict = json.loads(json_data)
return options_dict
+
def serialize_response_status(status):
status = {"retcode": status[0], "output": status[1]}
return json.dumps(status)
+
def deserialize_response_status(json_reader):
json_data = json_reader.read()
response_dict = json.loads(json_data)
diff --git a/lldb/scripts/swig_bot_lib/server.py b/lldb/scripts/swig_bot_lib/server.py
index cc25cee..57fb8d9 100644
--- a/lldb/scripts/swig_bot_lib/server.py
+++ b/lldb/scripts/swig_bot_lib/server.py
@@ -33,6 +33,7 @@ from . import remote
default_port = 8537
+
def add_subparser_args(parser):
parser.add_argument(
"--port",
@@ -46,9 +47,11 @@ def add_subparser_args(parser):
default=fs.find_executable("swig"),
dest="swig_executable")
+
def finalize_subparser_options(options):
pass
+
def initialize_listening_socket(options):
logging.debug("Creating socket...")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -60,6 +63,7 @@ def initialize_listening_socket(options):
s.listen()
return s
+
def accept_once(sock, options):
logging.debug("Waiting for connection...")
while True:
@@ -122,6 +126,7 @@ def accept_once(sock, options):
.format(pack_location))
shutil.rmtree(pack_location)
+
def accept_loop(sock, options):
while True:
try:
@@ -131,6 +136,7 @@ def accept_loop(sock, options):
logging.error("An error occurred while processing the connection.")
logging.error(error)
+
def run(options):
print(options)
sock = initialize_listening_socket(options)
diff --git a/lldb/scripts/use_lldb_suite.py b/lldb/scripts/use_lldb_suite.py
index f3e358a..6e24b9d 100644
--- a/lldb/scripts/use_lldb_suite.py
+++ b/lldb/scripts/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:
diff --git a/lldb/scripts/utilsArgsParse.py b/lldb/scripts/utilsArgsParse.py
index e762edc..4486661 100644
--- a/lldb/scripts/utilsArgsParse.py
+++ b/lldb/scripts/utilsArgsParse.py
@@ -17,7 +17,7 @@
"""
# Python modules:
-import getopt # Parse command line arguments
+import getopt # Parse command line arguments
# Third party modules:
@@ -54,6 +54,8 @@ strMsgArgFileNotImplemented = "Sorry the --argFile is not implemented"
# Str - Error message.
# Throws: None.
#--
+
+
def parse(vArgv, vstrListArgs, vListLongArgs, vDictArgReq, vstrHelpInfo):
dictArgs = {}
dictDummy = {}
@@ -127,8 +129,8 @@ def parse(vArgv, vstrListArgs, vListLongArgs, vDictArgReq, vstrHelpInfo):
return (-1, dictDummy, strMsg)
# Debug only
- #print countMandatoryOpts
- #print countMandatory
+ # print countMandatoryOpts
+ # print countMandatory
# Do we have the exact number of mandatory arguments
if (countMandatoryOpts > 0) and (countMandatory != countMandatoryOpts):
diff --git a/lldb/scripts/utilsDebug.py b/lldb/scripts/utilsDebug.py
index 4b5eb7f..8003891 100644
--- a/lldb/scripts/utilsDebug.py
+++ b/lldb/scripts/utilsDebug.py
@@ -28,9 +28,11 @@ import sys
# Authors: Illya Rudkin 28/11/2013.
# Changes: None.
#--
+
+
class CDebugFnVerbose(object):
# Public static properties:
- bVerboseOn = False # True = turn on function tracing, False = turn off.
+ bVerboseOn = False # True = turn on function tracing, False = turn off.
# Public:
#++------------------------------------------------------------------------
@@ -51,10 +53,13 @@ class CDebugFnVerbose(object):
# Throws: None.
#--
def dump_object(self, vstrText, vObject):
- if CDebugFnVerbose.bVerboseOn == False:
+ if not CDebugFnVerbose.bVerboseOn:
return
- sys.stdout.write("%d%s> Dp: %s" % (CDebugFnVerbose.__nLevel, self.__get_dots(),
- vstrText))
+ sys.stdout.write(
+ "%d%s> Dp: %s" %
+ (CDebugFnVerbose.__nLevel,
+ self.__get_dots(),
+ vstrText))
print(vObject)
#++------------------------------------------------------------------------
@@ -65,7 +70,7 @@ class CDebugFnVerbose(object):
# Throws: None.
#--
def dump_text(self, vstrText):
- if CDebugFnVerbose.bVerboseOn == False:
+ if not CDebugFnVerbose.bVerboseOn:
return
print(("%d%s> Dp: %s" % (CDebugFnVerbose.__nLevel, self.__get_dots(),
vstrText)))
@@ -94,8 +99,8 @@ class CDebugFnVerbose(object):
#--
def __indent_back(self):
if CDebugFnVerbose.bVerboseOn:
- print(("%d%s< fn: %s" % (CDebugFnVerbose.__nLevel, self.__get_dots(),
- self.__strFnName)))
+ print(("%d%s< fn: %s" % (CDebugFnVerbose.__nLevel,
+ self.__get_dots(), self.__strFnName)))
CDebugFnVerbose.__nLevel -= 1
#++------------------------------------------------------------------------
@@ -110,11 +115,11 @@ class CDebugFnVerbose(object):
CDebugFnVerbose.__nLevel += 1
self.__strFnName = vstrFnName
if CDebugFnVerbose.bVerboseOn:
- print(("%d%s> fn: %s" % (CDebugFnVerbose.__nLevel, self.__get_dots(),
- self.__strFnName)))
+ print(("%d%s> fn: %s" % (CDebugFnVerbose.__nLevel,
+ self.__get_dots(), self.__strFnName)))
# Private statics attributes:
- __nLevel = 0 # Indentation level counter
+ __nLevel = 0 # Indentation level counter
# Private attributes:
__strFnName = ""
diff --git a/lldb/scripts/utilsOsType.py b/lldb/scripts/utilsOsType.py
index a2f0563..fe3552e 100644
--- a/lldb/scripts/utilsOsType.py
+++ b/lldb/scripts/utilsOsType.py
@@ -28,6 +28,7 @@ import sys # Provide system information
#--
if sys.version_info.major >= 3:
from enum import Enum
+
class EnumOsType(Enum):
Unknown = 0
Darwin = 1
@@ -43,13 +44,15 @@ else:
"Linux",
"NetBSD",
"Windows"]
+
class __metaclass__(type):
-#++---------------------------------------------------------------------------
-# Details: Fn acts as an enumeration.
-# Args: vName - (R) Enumeration to match.
-# Returns: Int - Matching enumeration/index.
-# Throws: None.
-#--
+ #++----------------------------------------------------------------
+ # Details: Fn acts as an enumeration.
+ # Args: vName - (R) Enumeration to match.
+ # Returns: Int - Matching enumeration/index.
+ # Throws: None.
+ #--
+
def __getattr__(cls, vName):
return cls.values.index(vName)
@@ -72,6 +75,8 @@ else:
# Returns: EnumOsType - The OS type being used ATM.
# Throws: None.
#--
+
+
def determine_os_type():
eOSType = EnumOsType.Unknown
diff --git a/lldb/scripts/verify_api.py b/lldb/scripts/verify_api.py
index e636cdd..630247d 100755
--- a/lldb/scripts/verify_api.py
+++ b/lldb/scripts/verify_api.py
@@ -7,8 +7,10 @@ import os.path
import re
import sys
-def extract_exe_symbol_names (arch, exe_path, match_str):
- command = 'dsymutil --arch %s -s "%s" | grep "%s" | colrm 1 69' % (arch, exe_path, match_str)
+
+def extract_exe_symbol_names(arch, exe_path, match_str):
+ command = 'dsymutil --arch %s -s "%s" | grep "%s" | colrm 1 69' % (
+ arch, exe_path, match_str)
(command_exit_status, command_output) = commands.getstatusoutput(command)
if command_exit_status == 0:
if command_output:
@@ -19,27 +21,55 @@ def extract_exe_symbol_names (arch, exe_path, match_str):
print 'error: command failed with exit status %i\n command: %s' % (command_exit_status, command)
return list()
+
def verify_api(all_args):
'''Verify the API in the specified library is valid given one or more binaries.'''
usage = "usage: verify_api --library <path> [ --library <path> ...] executable1 [executable2 ...]"
- description='''Verify the API in the specified library is valid given one or more binaries.
-
+ description = '''Verify the API in the specified library is valid given one or more binaries.
+
Example:
-
+
verify_api.py --library ~/Documents/src/lldb/build/Debug/LLDB.framework/LLDB --arch x86_64 /Applications/Xcode.app/Contents/PlugIns/DebuggerLLDB.ideplugin/Contents/MacOS/DebuggerLLDB --api-regex lldb
'''
- parser = optparse.OptionParser(description=description, prog='verify_api',usage=usage)
- parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='display verbose debug info', default=False)
- parser.add_option('-a', '--arch', type='string', action='append', dest='archs', help='architecure to use when checking the api')
- parser.add_option('-r', '--api-regex', type='string', dest='api_regex_str', help='Exclude any undefined symbols that do not match this regular expression when searching for missing APIs.')
- parser.add_option('-l', '--library', type='string', action='append', dest='libraries', help='Specify one or more libraries that will contain all needed APIs for the executables.')
+ parser = optparse.OptionParser(
+ description=description,
+ prog='verify_api',
+ usage=usage)
+ parser.add_option(
+ '-v',
+ '--verbose',
+ action='store_true',
+ dest='verbose',
+ help='display verbose debug info',
+ default=False)
+ parser.add_option(
+ '-a',
+ '--arch',
+ type='string',
+ action='append',
+ dest='archs',
+ help='architecure to use when checking the api')
+ parser.add_option(
+ '-r',
+ '--api-regex',
+ type='string',
+ dest='api_regex_str',
+ help='Exclude any undefined symbols that do not match this regular expression when searching for missing APIs.')
+ parser.add_option(
+ '-l',
+ '--library',
+ type='string',
+ action='append',
+ dest='libraries',
+ help='Specify one or more libraries that will contain all needed APIs for the executables.')
(options, args) = parser.parse_args(all_args)
-
+
api_external_symbols = list()
if options.archs:
for arch in options.archs:
for library in options.libraries:
- external_symbols = extract_exe_symbol_names(arch, library, "( SECT EXT)");
+ external_symbols = extract_exe_symbol_names(
+ arch, library, "( SECT EXT)")
if external_symbols:
for external_symbol in external_symbols:
api_external_symbols.append(external_symbol)
@@ -52,16 +82,17 @@ def verify_api(all_args):
print "API symbols:"
for (i, external_symbol) in enumerate(api_external_symbols):
print "[%u] %s" % (i, external_symbol)
-
+
api_regex = None
if options.api_regex_str:
api_regex = re.compile(options.api_regex_str)
-
- for arch in options.archs:
+
+ for arch in options.archs:
for exe_path in args:
print 'Verifying (%s) "%s"...' % (arch, exe_path)
exe_errors = 0
- undefined_symbols = extract_exe_symbol_names(arch, exe_path, "( UNDF EXT)");
+ undefined_symbols = extract_exe_symbol_names(
+ arch, exe_path, "( UNDF EXT)")
for undefined_symbol in undefined_symbols:
if api_regex:
match = api_regex.search(undefined_symbol)
@@ -79,6 +110,6 @@ def verify_api(all_args):
print 'error: missing %u API symbols from %s' % (exe_errors, options.libraries)
else:
print 'success'
-
+
if __name__ == '__main__':
- verify_api(sys.argv[1:]) \ No newline at end of file
+ verify_api(sys.argv[1:])