otonchev/pylangc
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Simple Python-based Static Code Analyzer for C programs based on GLib/GStreamer.
The tool takes advantage of the GObject-Introspection annotations built on top
of GTK-Doc comment blocks. Note that this tool is proof-of-concept only.
To be able to run it, you should install pylangparser first:
https://github.com/otonchev/pylangparser/wiki
To run it, just type:
python c_code_analyzer.py
Example:
If run for the following C program:
void b()
{
GstElement *parent;
parent = gst_element_get_parent (el);
do_something_with_pad (pad);
if (FALSE)
gst_object_unref (parent);
gst_element_get_parent (el);
}
the script will output:
INFO: found function definition:
[['void'],
[['b']],
[[['GstElement'], [[['*'], ['parent']]]]],
[[[['parent'], ['='], [['gst_element_get_parent'], [['el']]]]],
[[['do_something_with_pad'], [['pad']]]],
[['if'], [['FALSE']], [[['gst_object_unref'], [['parent']]]]],
[[['gst_element_get_parent'], [['el']]]]]]
calling function gst_element_get_parent
allocating variable: parent
calling function do_something_with_pad
calling function gst_object_unref
freeing variable: parent
leaking memory
WARNING: function returned, non freed allocations: ['parent', '<NO_NAME>']