gcc-python-plugin is a plugin for GCC 4.6 onwards which embeds the CPython interpreter within GCC, allowing you to write new compiler warnings in Python, generate code visualizations, etc.
Tarball releases are available at: https://fedorahosted.org/releases/g/c/gcc-python-plugin/ Prebuilt-documentation can be seen at: http://readthedocs.org/docs/gcc-python-plugin/en/latest/index.html Project homepage: https://fedorahosted.org/gcc-python-plugin/ High level summary of the changes since the initial announcement: - new contributors - lots of bug fixes and compatibility fixes (e.g. for Python 3): the selftest suite now works for me with all eight different combinations of: - optimized vs debug builds of Python - Python 2.7 vs Python 3.2 - i686 and x86_64 building against gcc-4.6.1 (also tested with gcc-4.6.0) - new example scripts; see: http://readthedocs.org/docs/gcc-python-plugin/en/latest/examples.html - if PLUGIN_PYTHONPATH is defined at build time, hardcode the value into the plugin's sys.path, allowing multiple builds to be independently packaged - more documentation - work-in-progress on detecting reference-count errors in C Python extension code. Although this usage example can now detect errors, it isn't yet ready for general use. It can generate HTML visualizations of those errors; see http://dmalcolm.livejournal.com/6560.html for examples. - numerous other improvements (see below) - new dependency: the "six" module is required at both build time and run-time, to smooth over Python 2 vs Python 3 differences: http://pypi.python.org/pypi/six/ I've also packaged the plugin in RPM form for Fedora 16 onwards; see: https://fedoraproject.org/wiki/Features/GccPythonPlugin Enjoy! Dave Detailed change notes follow Version 0.5 =========== David Malcolm (7): Override all locale information with LC_ALL=C when running selftests Revamp support for options in selftests Add note about ccache Improvements to the example scripts Split up examples within the docs Fix gcc.Pass.__repr__ Version 0.4 =========== David Malcolm (10): add explicit BR on gmp-devel (rhbz#725569) Make the test suites be locale-independent Suppress buffering of output in Python 3 run-test-suite.py: support excluding tests from a run Python 3 fixes to testcpychecker.py Add 'str_no_uid' attribute to gcc.Tree and gcc.Gimple; use it to fix a selftest Fix segfault seen on i686 due to erroneous implementation of 'pointer' attribute of gcc.TypeDecl Selftest fixes and exclusions for 32-bit builds Fix the test for 32/64-bit in selftests so that it works with both Python 2 and 3 Version 0.3 =========== David Malcolm (3): If PLUGIN_PYTHONPATH is defined at build time, hardcode it into the plugin's sys.path Python 3 fixes Add the beginnings of a manpage for gcc-with-python Version 0.2 =========== Alexandre Lissy (2): fix: permerror() misusage Using Freedesktop standard for image viewing David Malcolm (98): Introduce gcc.Parameter and gcc.get_parameters() Introduce a compatibility header file Document the 'basic_blocks' attribute of gcc.Cfg Fix a mismatch between gccutils.pformat() and the API docs Add note about debugging Move the debugging information to be more prominent, and reword Automatically supply the correct header search directory for selftests that #include <Python.h> Set up various things in sys, including sys.path Cope with calls to function pointers in the arg checker Remove stray import Fix issue with PyArg_ParseTuple("K") seen compiling gdb Fix erroneous error messages for the various "s" and "z" format codes Format codes "U" and "S" can support several different argument types Add a way of turning of const-correctness for "const char*" checking Fix breakage of the various "es" and "et" format codes introduced in last commit Implement verification of the "O&" format code (converter callback, followed by appropriate arg) Use newlines and indentation to try to make the PyArg_ error messages more readable Add the example from my blog post ( http://dmalcolm.livejournal.com/6364.html ) Remove redundant (and non-functioning) selftest for "O&" format code Add 'local_decls', 'start', 'end', 'funcdef_no' to gcc.Function Add 'arguments' and 'result' to gcc.FunctionDecl Fix typos in docs Add 'operand' to gcc.Unary; check that the keywords table to PyArg_ has a NULL terminator Add 'location' to more tcc types; fill out more documentation Start building out examples of C syntax vs how it's seen by the Python API Fix the behavior of the various "#" format codes. Add Alexandre Lissy to contributors The various "e" codes can accept NULL as the encoding Add support for PyNumberMethods; use this to support int() on gcc.IntegerCst Introduce gcc.Option, wrapping GCC's command-line options Add gcc.warning() and gcc.error() Implement gcc.Option.is_enabled; allow -Wno-format to work, adding related workaround to gcc.warning() Explicitly set -Wno-format in the selftest that requires it If pygments is available, use it to colorize the source code in graphviz visualizations. Add line numbers. Add (disabled) option to generate CFGs as .svg rather than .png Minor tweaks to dot generation Support edge connections to individual statements in CFG renderings (via graphviz 'port=') Add an optional name to CFG renderings, along with other tweaks Work-in-progress on refcount checker Disable the checker by default again (accidentally enabled in last commit) Disable non-functioning tests for C stdio checker Remove the now-redundant SSA support from location-tracking Move generic interp code from refcounts.py to absinterp.py Eliminate superfluous StateEdge class, adding 'src' field to Transition Add test coverage for gcc.inform(); clarify docs (the output is to stderr) CFG renderer: cope with pygments styles that have a "bold" prefix Implement gcc.Tree.__hash__ Add a high-level overview of the insides of GCC Add "operand" field to gcc.MemRef; document gcc.MemRef, along with gcc.FieldDecl, gcc.ComponentReference Add a Table class to gccutils, to make it easier to generate tabular data Make gccutils.Table's output be a valid .rst table Expose more of the pass machinery, and use this to include the full pass tree within the docs Fix broken image link for cfg docs Add more information on the different representations Finish the table of gcc.PROP_ flags Add gcc.get_gcc_version() and gcc.get_plugin_gcc_version() Add a note about the GCC version to the pass documentation Add an autogenerated SVG diagram of GCC's passes Syntax-highlight Gimple within CFG dumps Rewrite of state tracking within libcpychecker (work-in-progress) Eliminate the DataState class, merging it all into State Report erroneous refcounts returned from functions, and errors Highlight new and changing values in State Graph visualizations Fix lookup of ob_refcnt on PyObject* for instances that were never modified Suggest the use of Py_RETURN_NONE when detecting _Py_NoneStruct.ob_refcnt is too low Detect reference leaks for values that aren't the return value Ensure that the checker can cope with calls to functions it doesn't know about Fix the folding of gcc.GimpleCond where we can know the value of the boolean Remove dead code Set ob_size in PyList_New Set up ob_type on objects within the analyser Add "dump_traces" option to check_refcounts, to make it easier to write selftests Avoid hardware dependent results in the tests/plugin/parameters selftest Improvements to error reporting Add support for stolen references Report on where objects were allocated when reporting on an ob_refcnt problem Generate HTML reports on errors (in addition to text on stderr) Try to make the plugin compile against gcc 4.5 libcpychecker cleanups Warn when a function returns NULL without setting the per-thread exception state Beginning implementing Py_DECREF Warn about code that accesses deallocated memory Warn about functions that return pointers to deallocated memory Don't analyse traces with loops, as a primitive means of ensuring that the analysis terminates Improve error handling within the checker Rigidly distinguish between l-values and r-values in cpychecker Add 'array' and 'index' fields to gcc.ArrayRef minor docs tweak Support arrays, and more pointer handling Fix the build (and many selftests) against Python 3; tweak exception handling Better support for building against debug builds of Python Comment out the "Other callback events" section for now Add explicit requirements section to the documentation Clean the docs during a 'make clean' Minor tweak to Makefile Tom Tromey (2): make html from top-level expose 'inform' function