ANN: gcc-python-plugin 0.10
by David Malcolm
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 for C/C++ in Python, generate code visualizations, etc. It
comes with "cpychecker": a tool for static analysis tool of CPython
extensions.
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/
What's new in v0.10:
* support for the to-be-released Python 3.3 (tested against latest
release candidate)
* better support for analysis of C++ code: the API provides support
for walking the namespace tree, and the cpychecker code now supports
methods, references, "this", destructors, etc
* lots of bug fixes: the cpychecker code has been hardened by running
it on all of the Python C extension code in Fedora 17, and in the
process many internal bugs have been found and fixed - along with
hundreds of bugs in the code being tested:
http://fedoraproject.org/wiki/Features/StaticAnalysisOfPythonRefcounts
* similarly, Daniele Varrazzo used the checker extensively on psycopg,
the popular Python interface to PostgreSQL, and using it was able to
find and fix numerous subtle errors:
http://initd.org/psycopg/articles/2012/03/29/psycopg-245-released/
* an experimental new HTML visualization for error reports:
http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-19/example/ex...
Thanks to Buck Golemon, Daniele Varrazzo, David Narvaez, Eevee, Jason
Mueller, Kevin Pyle, Matt Rice and Tom Tromey for their contributions to
this release.
Enjoy!
Dave
11 years, 7 months
build system
by Philip Herron
Hey
I have quite a lot of experience with gcc python plugin now since my
google summer of code projects. And i feel the build system isn't
really ideal in a few ways one of the main problems I find has been.
The Makefile uses your systems $CC which on ubuntu is defaulted to cc
which in turn goes to your systems base install of gcc. This is fine,
but if you install your own gcc this is a little annoying. Personally
i think since it requires GCC why not simple use the gcc within your
PATH so its easier to keep track of since its very easy to
accidentally build with the wrong gcc and then have problems trying to
use it since gcc wont let your plugin pass the version checks. So that
it shouldn't be a problem. Then sometimes people with different
versions of python installed might use different python-config's.
I am considering rewriting the build system in autoconf etc. But i
would like to hear some opinions if this is worth it or not. I
personally feel it could be a more ideal solution. And you could use a
make install based on something like:
gcc --print-file-name="plugin" and put it in that path might be
interesting. Though there could be some problems with installing
outside of a root user. So maybe a /usr/local/lib install might be
fine.
--Phil
11 years, 8 months
TYPE_METHODS
by Philip Herron
Hey
Just wondering whats the best way to post a patch, for C++. You see
classes as TYPEDECLS, and in essence it just looks like a struct, but
if you check TYPE_METHODS you get to see associated methods which
would make it a class. So i just added to:
generate-tree-c.py: L458
if tree_type.SYM in ('RECORD_TYPE', 'UNION_TYPE', 'QUAL_UNION_TYPE'):
add_simple_getter('fields',
'gcc_tree_list_from_chain(TYPE_FIELDS(self->t))',
"The fields of this type")
add_simple_getter('methods',
'gcc_tree_list_from_chain(TYPE_METHODS(self->t))',
"The TYPE_METHODS")
--Phil
11 years, 8 months
c++
by Philip Herron
Hey
I have been noticing that when i run the plugin over c++ code say this
just silly example:
class CRectangle
{
int x, y;
public:
void set_values_joe (int, int);
int area (void);
} rect;
typedef struct testjoe
{
int a;
float b;
} ttttt ;
namespace Example {
struct Coord {
int x;
int y;
};
class Widget {
public:
void set_location(const struct Coord& coord);
};
};
I use gcc.get_global_namespace () then iterate over x.namespaces i get
access to the example namespace but i dont get access to the struct or
the class rect. And when i use gcc.get_translation_units (): i have to
use if u.block: so i dont get to iterate over block.vars. So i went
and used gcc.get_variables (): But i only get access to the class
rect. And i still dont get access to that struct.
Not quite sure i might test it on another gcc and see what happens.
--Phil
11 years, 8 months
Create data flow graph from Gimple SSA
by Amin Farmahini
Hi All,
The Gimple representation of GCC provides some data flow analysis for each
basic block in the SSA (Static Single Assignment) form. One could see the
data dependencies (which I think are called flow-dependence edges) in
gimple form. I would like to take Gimple as input and generate a data flow
graph for basic blocks. The example shown on the website shows how to
generate control flom graph using "show-ssa.py." However, it does not
visualize the data dependencies in each basic block. I need to visualize
the data dependence in order to analyze the data flow in each basic block
in form of a data flow graph. By data flow graphs I mean graphs in which
nodes in the graph represent operations like addition and multiplication,
and edges represent data dependence between nodes. I was wondering if there
is already such a plugin? Or it would be great if you could provide some
advice on how to write such a pass.
Thanks,
Amin
11 years, 8 months