summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/scripts/Python
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadbcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/scripts/Python')
-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
7 files changed, 544 insertions, 337 deletions
diff --git a/lldb/scripts/Python/android/host_art_bt.py b/lldb/scripts/Python/android/host_art_bt.py
index 0893662869f..e359829fe5b 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 6d51a4b5958..2b01c2a35b6 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 56323d6679a..cb911eed047 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 d4b4962cc31..b84dbb819f9 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 28fc3e5bc7f..1688af4cb6b 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 72986a0bf8f..d1d6131e472 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 f3e358af143..6e24b9da8d3 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:
OpenPOWER on IntegriCloud