Changes to the GCC Python Plugin

GCC 4.8 compatibility

This release of the plugin adds support for gcc 4.8 (along with continued support for gcc 4.7 and gcc 4.6).


The source tree contains a new component: gcc-c-api. This provides a wrapper library libgcc-c-api.so that hides much of the details of GCC’s internals (such as the binary layout of structures, and the differences between GCC 4.6 through 4.8).

I plan for this to eventually be its own project, aiming at providing a stable API and ABI for working with GCC, once it has proven itself in the context of the python plugin.

The API provides an XML description of itself, which should greatly simplify the job of generating bindings for accessing GCC internals from other languages.

API improvements

Sane repr() implementations have been added to the following classes: gcc.CaseLabelExpr gcc.GimpleLabel gcc.BasicBlock gcc.SsaName gcc.ArrayRef gcc.ComponentRef gcc.PointerType gcc.IntegerType gcc.Location

gcc.Location instances can now be compared and sorted. They are ordered alphabetically by file, then by line number, then by column)

Other fixes

  • the Makefile has a “make install” target (at last)
  • prevent forkbomb when running with CC=gcc-with-cpychecker
  • fixed memory leak within gcc.Gimple.walk_tree()
  • ensure that the result of gcc.Cfg.basic_blocks can’t contain any None items (which used to sometimes happen when certain optimizations had occurred).
  • run-test-suite.py now has a –show option, giving more verbose information on what the test suite is doing
  • fix hashing and equality for gcc.Function and gcc.Gimple
  • fix gcc.IntegerCst.__hash__() and ensure it compares sanely against int
  • ensure that equivalent gcc.ComponentRef objects have the same hash and are equal
  • ensure there is a unique gcc.CallgraphEdge for each underlying edge, and a unique gcc.Cfg for each underlying control flow graph
  • add a “label” attribute to gcc.GimpleLabel
  • add gcc.GCC_VERSION

Internal improvements to gcc-with-cpychecker

  • fix exception on pointer comparisons
  • fix exception on int-to-float casts
  • fix traceback when analyzing a callsite that discards the LHS when an Outcome.returns() a value
  • fix two different exceptions when casting an integer value to a pointer
  • add example of refcounting bugs to “make demo”
  • fix a traceback seen on bogus uses of Py_XDECREF()