[Lldb-commits] [PATCH] D67790: prepare_binding_Python: print readable errors if SWIG fails

Lawrence D'Anna via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 19 21:16:46 PDT 2019


lawrence_danna created this revision.
lawrence_danna added reviewers: JDevlieghere, jasonmolenda.
Herald added a project: LLDB.

When swig fails, all the errors are squished onto one line with `\n` quoting.
It's very hard to read.   This will print them out in a more reasonable format.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67790

Files:
  lldb/scripts/Python/prepare_binding_Python.py


Index: lldb/scripts/Python/prepare_binding_Python.py
===================================================================
--- lldb/scripts/Python/prepare_binding_Python.py
+++ lldb/scripts/Python/prepare_binding_Python.py
@@ -231,11 +231,13 @@
     swig_stdout, swig_stderr = process.communicate()
     return_code = process.returncode
     if return_code != 0:
+        swig_stdout = swig_stdout.decode('utf8', errors='replace').rstrip()
+        swig_stderr = swig_stderr.decode('utf8', errors='replace').rstrip()
+        swig_stdout = re.sub(r'^(?=.)', 'stdout: ', swig_stdout, flags=re.MULTILINE)
+        swig_stderr = re.sub(r'^(?=.)', 'stderr: ', swig_stderr, flags=re.MULTILINE)
         logging.error(
-            "swig failed with error code %d: stdout=%s, stderr=%s",
-            return_code,
-            swig_stdout,
-            swig_stderr)
+            "swig failed with error code %d\n%s%s",
+            return_code, swig_stdout, swig_stderr)
         logging.error(
             "command line:\n%s", ' '.join(command))
         sys.exit(return_code)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67790.220940.patch
Type: text/x-patch
Size: 1071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190920/d9e2b98a/attachment.bin>


More information about the lldb-commits mailing list