[Lldb-commits] [PATCH] D17182: Adjust for Python-3.

Siva Chandra via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 11 18:27:47 PST 2016


sivachandra created this revision.
sivachandra added reviewers: zturner, tfiala, labath.
sivachandra added a subscriber: lldb-commits.

This does not yet give us a clean testsuite run but it does help with:
1. Actually building on linux
2. Run the testsuite with over 70% tests passing on linux.

http://reviews.llvm.org/D17182

Files:
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/plugins/builder_linux.py
  packages/Python/lldbsuite/test/plugins/builder_linux2.py
  scripts/Python/modules/readline/readline.cpp
  source/API/liblldb.exports

Index: source/API/liblldb.exports
===================================================================
--- source/API/liblldb.exports
+++ source/API/liblldb.exports
@@ -1,3 +1,4 @@
 _ZN4lldb*
 _ZNK4lldb*
 init_lld*
+PyInit__lld*
Index: scripts/Python/modules/readline/readline.cpp
===================================================================
--- scripts/Python/modules/readline/readline.cpp
+++ scripts/Python/modules/readline/readline.cpp
@@ -20,11 +20,6 @@
 // work around LLVM pr18841 to avoid seg faults in the stock Python
 // readline.so linked against GNU readline.
 
-static struct PyMethodDef moduleMethods[] =
-{
-    {nullptr, nullptr, 0, nullptr}
-};
-
 #ifndef LLDB_DISABLE_LIBEDIT
 PyDoc_STRVAR(
     moduleDocumentation,
@@ -35,9 +30,33 @@
     "Stub module meant to avoid linking GNU readline.");
 #endif
 
+#if PY_VERSION_HEX >= 0x03000000
+static struct PyModuleDef readline_module =
+{
+    PyModuleDef_HEAD_INIT, // m_base
+    "readline",            // m_name
+    moduleDocumentation,   // m_doc
+    -1,                    // m_size
+    nullptr,               // m_methods
+    nullptr,               // m_reload
+    nullptr,               // m_traverse
+    nullptr,               // m_clear
+    nullptr,               // m_free
+};
+#else
+static struct PyMethodDef moduleMethods[] =
+{
+    {nullptr, nullptr, 0, nullptr}
+};
+#endif
+
 #ifndef LLDB_DISABLE_LIBEDIT
 static char*
+#if PY_VERSION_HEX >= 0x03000000
+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;
@@ -67,10 +86,15 @@
 #ifndef LLDB_DISABLE_LIBEDIT
     PyOS_ReadlineFunctionPointer = simple_readline;
 #endif
+
+#if PY_VERSION_HEX >= 0x03000000
+    return PyModule_Create(&readline_module);
+#else
     Py_InitModule4(
         "readline",
         moduleMethods,
         moduleDocumentation,
         static_cast<PyObject *>(NULL),
         PYTHON_API_VERSION);
+#endif
 }
Index: packages/Python/lldbsuite/test/plugins/builder_linux2.py
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/plugins/builder_linux2.py
@@ -1,4 +0,0 @@
-from builder_base import *
-
-def buildDsym(sender=None, architecture=None, compiler=None, dictionary=None, clean=True):
-    return False
Index: packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -440,6 +440,10 @@
         return __import__("builder_freebsd")
     if sys.platform.startswith("netbsd"):
         return __import__("builder_netbsd")
+    if sys.platform.startswith("linux"):
+        # sys.platform with Python-3.x returns 'linux', but with
+        # Python-2.x it returns 'linux2'.
+        return __import__("builder_linux")
     return __import__("builder_" + sys.platform)
 
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17182.47761.patch
Type: text/x-patch
Size: 3000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160212/211f5357/attachment.bin>


More information about the lldb-commits mailing list