I tried out the refcount checker on gdb today. I'm using git head as of
a few minutes ago, with a newly-updated F15 system gcc.
I hacked cpychecker.py:
diff --git a/cpychecker.py b/cpychecker.py
index e120c53..4c24e3f 100644
--- a/cpychecker.py
+++ b/cpychecker.py
@@ -16,4 +16,4 @@
# <
http://www.gnu.org/licenses/>.
from libcpychecker import main
-main()
+main(verify_refcounting = True)
(Note that this patch causes test suite failures -- but I think that
can't be very important.)
I wrote this little script to run 'make' with the right options:
#!/bin/sh
here=/home/tromey/Space/Trunk/gcc-python-plugin/
make CFLAGS="-gdwarf-4 -g3 -fplugin=$here/python.so
-fplugin-arg-python-script=$here/cpychecker.py" "$@"
Then I ran it on gdb like:
/tmp/Makeit -k -C ~/gnu/archer/build/gdb -j2
I get many failures like this:
../../archer/gdb/armbsd-tdep.c: In function ‘armbsd_regset_from_core_section’:
../../archer/gdb/armbsd-tdep.c:127:3: error: Unhandled Python exception raised calling
'execute' method
Traceback (most recent call last):
File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/__init__.py",
line 49, in execute
self.show_possible_null_derefs)
File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/refcounts.py",
line 2020, in check_refcounts
limits=Limits(maxtrans=1024))
File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py",
line 1821, in iter_traces
f_new = facet_cls(curstate, fun=fun)
File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/refcounts.py",
line 224, in __init__
self.exception_rvalue = ConcreteValue(get_PyObjectPtr(),
File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/types.py", line
60, in get_PyObjectPtr
return get_global_typedef('PyObject').pointer
AttributeError: 'NoneType' object has no attribute 'pointer'
../../archer/gdb/armbsd-tdep.c: In function ‘armbsd_regset_from_core_section’:
../../archer/gdb/armbsd-tdep.c:127:3: error: Unhandled Python exception raised calling
'execute' method
Traceback (most recent call last):
File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/__init__.py",
line 49, in execute
self.show_possible_null_derefs)
File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/refcounts.py",
line 2020, in check_refcounts
limits=Limits(maxtrans=1024))
File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py",
line 1821, in iter_traces
f_new = facet_cls(curstate, fun=fun)
File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/refcounts.py",
line 224, in __init__
self.exception_rvalue = ConcreteValue(get_PyObjectPtr(),
File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/types.py", line
60, in get_PyObjectPtr
return get_global_typedef('PyObject').pointer
AttributeError: 'NoneType' object has no attribute 'pointer'
The problem here is that some files, like this one, do not use Python at
all, and don't include the Python headers. In this situation the plugin
dies when it fails to look up a Python type.
Tom