On Wed, 2011-10-12 at 13:02 -0600, Tom Tromey wrote:
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.
Excellent! I'm still ironing out the bugs on compiling the plugin with
"itself" (i.e. with the checker). Getting the refcount-checker to
handle compiling gdb will be a worthwhile milestone.
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've been doing that too when working on the
refcount checker, and I run
into those failures as well. Some of the test cases enable the checker,
and some don't; by hacking up cpychecker like that it's likely to break
some of the ones that don't.
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" "$@"
Looks reasonable. I tend to use the "gcc-with-cpychecker" script:
$ make CC=../some-build-of-the-plugin/gcc-with-cpychecker
having hacked up that other build to force verify_refcounting to be
enabled.
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.
This makes a good test for the "facet"-based state handling: to only use
the CPython code where necessary.
I hope I've fixed this in 269f8f3f5237c892554b3e07398edc73470d433e:
http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=commitdiff;h=2...
Dave