[Lldb-commits] [lldb] r263183 - Fix SBDebugger.GetOutputFileHandle() on OS X.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 10 17:57:46 PST 2016

Author: jingham
Date: Thu Mar 10 19:57:45 2016
New Revision: 263183

URL: http://llvm.org/viewvc/llvm-project?rev=263183&view=rev
Fix SBDebugger.GetOutputFileHandle() on OS X.

The swig typemaps had some magic for output File *'s on OS X that made:


actually work.  That was protected by a "#ifdef __MACOSX__", but the corresponding define
got lost going from the Darwin shell scripts to the python scripts for running
swig, so the code was elided.  I need to pass the define to SWIG, but only when
targetting Darwin.

So I added a target-platform argument to prepare_bindings, and if that 
is Darwin, I pass -D__APPLE__ to swig, and that activates this code again, and
GetOutputFileHandle works again.  Note, I only pass that argument for the Xcode
build.  I'm sure it is possible to do that for cmake, but my cmake-foo is weak.

I should have been able to write a test for this by creating a debugger, setting the 
output file handle to something file, writing to it, getting the output file handle 
and reading it.  But SetOutputFileHandle doesn't seem to work from Python, so I'd 
have to write a pexpect test to test this, which I'd rather not do.


Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=263183&r1=263182&r2=263183&view=diff
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Mar 10 19:57:45 2016
@@ -6258,7 +6258,7 @@
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/bash;
-			shellScript = "/usr/bin/python $SRCROOT/scripts/prepare_bindings.py --find-swig --framework --src-root $SRCROOT --target-dir $TARGET_BUILD_DIR --config-build-dir $CONFIGURATION_BUILD_DIR";
+			shellScript = "/usr/bin/python $SRCROOT/scripts/prepare_bindings.py --find-swig --framework --src-root $SRCROOT --target-dir $TARGET_BUILD_DIR --config-build-dir $CONFIGURATION_BUILD_DIR --target-platform Darwin";
 		4959511A1A1ACE9500F6F8FC /* Install Clang compiler headers */ = {
 			isa = PBXShellScriptBuildPhase;

Modified: lldb/trunk/scripts/Python/prepare_binding_Python.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/prepare_binding_Python.py?rev=263183&r1=263182&r2=263183&view=diff
--- lldb/trunk/scripts/Python/prepare_binding_Python.py (original)
+++ lldb/trunk/scripts/Python/prepare_binding_Python.py Thu Mar 10 19:57:45 2016
@@ -16,7 +16,7 @@ import re
 import shutil
 import subprocess
 import sys
+import platform
 class SwigSettings(object):
     """Provides a single object to represent swig files and settings."""
@@ -205,6 +205,8 @@ def do_swig_rebuild(options, dependency_
         "-I\"%s\"" % os.path.normcase("./."),
+    if options.target_platform == "Darwin":
+        command.append("-D__APPLE__")
     if options.generate_dependency_file:
         command.append("-MMD -MF \"%s\"" % temp_dep_file_path)

Modified: lldb/trunk/scripts/Python/python-typemaps.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-typemaps.swig?rev=263183&r1=263182&r2=263183&view=diff
--- lldb/trunk/scripts/Python/python-typemaps.swig (original)
+++ lldb/trunk/scripts/Python/python-typemaps.swig Thu Mar 10 19:57:45 2016
@@ -534,7 +534,7 @@
 %typemap(out) FILE * {
    char mode[4] = {0};
-#ifdef __MACOSX__
+#ifdef __APPLE__
    int i = 0;
    short flags = $1->_flags;

Modified: lldb/trunk/scripts/prepare_bindings.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/prepare_bindings.py?rev=263183&r1=263182&r2=263183&view=diff
--- lldb/trunk/scripts/prepare_bindings.py (original)
+++ lldb/trunk/scripts/prepare_bindings.py Thu Mar 10 19:57:45 2016
@@ -152,6 +152,11 @@ def process_args(args):
             "Specifies the build dir where the language binding "
             "should be placed"))
+    parser.add_argument(
+        "--target-platform",
+        help=(
+            "Specifies the platform we are building for."
+            "Should be the same as what platform.system() returns."))
     # Process args.
     options = parser.parse_args(args)

More information about the lldb-commits mailing list