[gcc-python-plugin] cpychecker: cope with gcc.GimpleNop
by David Hugh Malcolm
commit fc3f5bb9afa64d7d6612520c4d59f56db0334b73
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Wed Mar 28 12:42:35 2012 -0400
cpychecker: cope with gcc.GimpleNop
docs/gimple.rst | 6 +++-
libcpychecker/absinterp.py | 2 +-
.../refcounts/cplusplus/empty-function/input.cc | 38 ++++++++++++++++++++
.../refcounts/cplusplus/empty-function/script.py | 22 +++++++++++
.../refcounts/cplusplus/empty-function/stdout.txt | 5 +++
5 files changed, 71 insertions(+), 2 deletions(-)
---
diff --git a/docs/gimple.rst b/docs/gimple.rst
index d1d33be..b68faa7 100644
--- a/docs/gimple.rst
+++ b/docs/gimple.rst
@@ -113,6 +113,8 @@ Subclass Meaning
LABEL:
+:py:class:`gcc.GimpleNop` The "do nothing" statement
+
:py:class:`gcc.GimplePhi` Used in the SSA passes::
LHS = PHI <ARG1, ..., ARGN>;
@@ -149,7 +151,6 @@ Subclass Meaning
:py:class:`gcc.GimpleEhMustNotThrow` Used in exception-handling
:py:class:`gcc.GimpleErrorMark` A dummy statement used for handling internal errors
:py:class:`gcc.GimpleGoto` An unconditional jump
-:py:class:`gcc.GimpleNop` The "do nothing" statement
:py:class:`gcc.GimpleOmpAtomicLoad` Used for implementing OpenMP
:py:class:`gcc.GimpleOmpAtomicStore` (ditto)
:py:class:`gcc.GimpleOmpContinue` (ditto)
@@ -371,7 +372,10 @@ Subclass Meaning
The kind of the expression, as an :py:class:`gcc.Tree` subclass (the type
itself, not an instance)
+.. py:class:: gcc.GimpleNop
+ Subclass of :py:class:`gcc.Gimple`, representing a "do-nothing" statement
+ (a.k.a. "no operation").
.. Here's a dump of the class hierarchy, from help(gcc):
.. Gimple
diff --git a/libcpychecker/absinterp.py b/libcpychecker/absinterp.py
index 729b50c..35c4103 100644
--- a/libcpychecker/absinterp.py
+++ b/libcpychecker/absinterp.py
@@ -2088,7 +2088,7 @@ class State(object):
if isinstance(stmt, gcc.GimpleCall):
return self._get_transitions_for_GimpleCall(stmt)
elif isinstance(stmt, (gcc.GimpleDebug, gcc.GimpleLabel,
- gcc.GimplePredict)):
+ gcc.GimplePredict, gcc.GimpleNop)):
return [Transition(self,
self.use_next_loc(),
None)]
diff --git a/tests/cpychecker/refcounts/cplusplus/empty-function/input.cc b/tests/cpychecker/refcounts/cplusplus/empty-function/input.cc
new file mode 100644
index 0000000..b393c4d
--- /dev/null
+++ b/tests/cpychecker/refcounts/cplusplus/empty-function/input.cc
@@ -0,0 +1,38 @@
+/*
+ Copyright 2012 David Malcolm <dmalcolm(a)redhat.com>
+ Copyright 2012 Red Hat, Inc.
+
+ This is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ Verify that the checker can cope with an empty C++ virtual function
+ (this contains a gcc.GimpleNop, in gcc-4.6 at least)
+ */
+#include <Python.h>
+
+class Test
+{
+public:
+ virtual void foo() {}
+};
+
+/*
+ PEP-7
+Local variables:
+c-basic-offset: 4
+indent-tabs-mode: nil
+End:
+*/
diff --git a/tests/cpychecker/refcounts/cplusplus/empty-function/script.py b/tests/cpychecker/refcounts/cplusplus/empty-function/script.py
new file mode 100644
index 0000000..fdd5ba3
--- /dev/null
+++ b/tests/cpychecker/refcounts/cplusplus/empty-function/script.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Copyright 2011 David Malcolm <dmalcolm(a)redhat.com>
+# Copyright 2011 Red Hat, Inc.
+#
+# This is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see
+# <http://www.gnu.org/licenses/>.
+
+from libcpychecker import main
+main(verify_refcounting=True,
+ dump_traces=True,
+ show_traces=False)
diff --git a/tests/cpychecker/refcounts/cplusplus/empty-function/stdout.txt b/tests/cpychecker/refcounts/cplusplus/empty-function/stdout.txt
new file mode 100644
index 0000000..238dde5
--- /dev/null
+++ b/tests/cpychecker/refcounts/cplusplus/empty-function/stdout.txt
@@ -0,0 +1,5 @@
+Trace 0:
+ Transitions:
+ 'returning'
+ Exception:
+ (struct PyObject *)0
12 years, 2 months
[gcc-python-plugin] misc/fedora: various fixes to mass-rebuild.py
by David Hugh Malcolm
commit 1c4f2b8b40c166005f5bf1141d2fdf3f13fe28e7
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Wed Mar 28 12:27:06 2012 -0400
misc/fedora: various fixes to mass-rebuild.py
Various fixes to mass-rebuild.py whilst attempting to fix the failures seen
analyzing C++ code:
* fix mass-rebuild.py so that it halts when a "mock" command fails (other
than the rebuild itself)
* override /usr/bin/c++ as well as /usr/bin/g++
* copy in gccutils.py from the working copy, as well as libcpychecker/*.py
misc/fedora/mass-rebuild.py | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/misc/fedora/mass-rebuild.py b/misc/fedora/mass-rebuild.py
index f9b49ab..b316fd1 100644
--- a/misc/fedora/mass-rebuild.py
+++ b/misc/fedora/mass-rebuild.py
@@ -77,7 +77,7 @@ def local_rebuild_of_srpm_in_mock(srpmpath, mockcfg):
Rebuild the given SRPM locally within mock, injecting the cpychecker
code in RPM form; gathering the results to a subdir within "LOGS"
"""
- def run_mock(commands, captureOut=False, captureErr=False):
+ def run_mock(commands, captureOut=False, captureErr=False, failOnError=True):
cmds = ['mock', '-r', mockcfg, '--disable-plugin=ccache'] + commands
print('--------------------------------------------------------------')
print(' '.join(cmds))
@@ -89,6 +89,13 @@ def local_rebuild_of_srpm_in_mock(srpmpath, mockcfg):
args['stderr'] = PIPE
p = Popen(cmds, **args)
out, err = p.communicate()
+ if p.returncode != 0 and failOnError:
+ msg = 'mock failed: return code %i' % p.returncode
+ if captureOut:
+ msg += 'stdout: %s' % out
+ if captureErr:
+ msg += 'stderr: %s' % err
+ raise RuntimeError(msg)
return out, err
resultdir = get_result_dir(srpmpath)
@@ -107,24 +114,28 @@ def local_rebuild_of_srpm_in_mock(srpmpath, mockcfg):
# Copy up latest version of the libcpychecker code from this working copy
# overriding the copy from the pre-built plugin:
if 1:
+ HACKED_PATH='/usr/lib/gcc/x86_64-redhat-linux/4.6.3/plugin/python2'
+ # FIXME: ^^ this will need changing
for module in glob.glob('../../libcpychecker/*.py'):
- HACKED_PATH='/usr/lib/gcc/x86_64-redhat-linux/4.6.2/plugin/python2/libcpychecker'
- # FIXME: ^^ this will need changing
- run_mock(['--copyin', module, HACKED_PATH])
+ run_mock(['--copyin', module, os.path.join(HACKED_PATH, 'libcpychecker')])
+ run_mock(['--copyin', '../../gccutils.py', HACKED_PATH])
# Override the real gcc/g++ with our fake ones, which add the necessary flags
# and then invokes the real one:
run_mock(['--chroot', 'mv /usr/bin/gcc /usr/bin/the-real-gcc'])
run_mock(['--chroot', 'mv /usr/bin/g++ /usr/bin/the-real-g++'])
+ run_mock(['--chroot', 'mv /usr/bin/c++ /usr/bin/the-real-c++'])
run_mock(['--copyin', 'fake-gcc.py', '/usr/bin/gcc'])
run_mock(['--copyin', 'fake-g++.py', '/usr/bin/g++'])
+ run_mock(['--copyin', 'fake-g++.py', '/usr/bin/c++'])
# Rebuild src.rpm, using the script:
run_mock(['--rebuild', srpmpath,
'--no-clean',
- ])
+ ],
+ failOnError=False)
# Extract build logs:
shutil.copy('/var/lib/mock/%s/result/build.log' % mockcfg,
12 years, 2 months
[gcc-python-plugin] fix comment in Makefile
by David Hugh Malcolm
commit db571a0e9ab333585f5e9b5ec47d7231c5be5450
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Wed Mar 28 12:00:42 2012 -0400
fix comment in Makefile
Makefile | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/Makefile b/Makefile
index cd177ce..ba0a48a 100644
--- a/Makefile
+++ b/Makefile
@@ -194,7 +194,8 @@ docs/passes.svg: plugin generate-passes-svg.py
$(srcdir)./gcc-with-python generate-passes-svg.py test.c
# Utility target, to help me to make releases
-# - creates a tag in git, and pushes it
+# - creates a tag in git (but does not push it; see "Notes to self on
+# making a release" below)
# - creates a tarball
#
# The following assumes that VERSION has been set e.g.
12 years, 2 months
[gcc-python-plugin] cpychecker: fix tracebacks seen when running the checker on C++ methods
by David Hugh Malcolm
commit 7156805d1a3be3d8f6f951846ce1356606d90c9f
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Tue Mar 27 17:11:40 2012 -0400
cpychecker: fix tracebacks seen when running the checker on C++ methods
gccutils.py | 2 +-
libcpychecker/refcounts.py | 9 +++-
.../cpychecker/refcounts/cplusplus/method/input.cc | 52 ++++++++++++++++
.../refcounts/cplusplus/method/metadata.ini | 3 +
.../refcounts/cplusplus/method/script.py | 22 +++++++
.../refcounts/cplusplus/method/stderr.txt | 12 ++++
.../refcounts/cplusplus/method/stdout.txt | 64 ++++++++++++++++++++
7 files changed, 162 insertions(+), 2 deletions(-)
---
diff --git a/gccutils.py b/gccutils.py
index 6b49c16..43304c5 100644
--- a/gccutils.py
+++ b/gccutils.py
@@ -78,7 +78,7 @@ def get_nonnull_arguments(funtype):
Compare with gcc/tree-vrp.c: nonnull_arg_p
"""
- check_isinstance(funtype, gcc.FunctionType)
+ check_isinstance(funtype, (gcc.FunctionType, gcc.MethodType))
if 'nonnull' in funtype.attributes:
result = []
nonnull = funtype.attributes['nonnull']
diff --git a/libcpychecker/refcounts.py b/libcpychecker/refcounts.py
index 716b45b..41fac1d 100644
--- a/libcpychecker/refcounts.py
+++ b/libcpychecker/refcounts.py
@@ -66,7 +66,14 @@ def type_is_pyobjptr_subclass(t):
if not isinstance(t.dereference, gcc.RecordType):
return False
- fields = t.dereference.fields
+ # Obtain the fields of the struct/class
+ # For C++ "fields" will also contain a gcc.TypeDecl for the
+ # type itself, and for any nested types (e.g. typedefs), so filter them
+ # out. This avoids an infinite recursion for classes with no data, where
+ # the initial decl of the type otherwise would make it appear that there's
+ # a nested copy of the struct inside itself.
+ fields = [field for field in t.dereference.fields
+ if isinstance(field, gcc.FieldDecl)]
if len(fields) == 0:
# Opaque struct: there's nothing we can do.
diff --git a/tests/cpychecker/refcounts/cplusplus/method/input.cc b/tests/cpychecker/refcounts/cplusplus/method/input.cc
new file mode 100644
index 0000000..449b956
--- /dev/null
+++ b/tests/cpychecker/refcounts/cplusplus/method/input.cc
@@ -0,0 +1,52 @@
+/*
+ Copyright 2012 David Malcolm <dmalcolm(a)redhat.com>
+ Copyright 2012 Red Hat, Inc.
+
+ This is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+/* Verify that the checker will run on a C++ method */
+#include <Python.h>
+
+class Foo
+{
+public:
+ PyObject * test(int i);
+};
+
+PyObject *
+Foo::test(int i)
+{
+ if (i) {
+ /*
+ Verify that C++ frontend can locate globals
+ for types ("PyDict_Type") and exceptions (PyExc_MemoryError)
+ */
+ return PyDict_New();
+ } else {
+ /* Verify that bugs are reported:
+ this code is missing a Py_INCREF on Py_None */
+ return Py_None;
+ }
+}
+
+
+/*
+ PEP-7
+Local variables:
+c-basic-offset: 4
+indent-tabs-mode: nil
+End:
+*/
diff --git a/tests/cpychecker/refcounts/cplusplus/method/metadata.ini b/tests/cpychecker/refcounts/cplusplus/method/metadata.ini
new file mode 100644
index 0000000..0d5711c
--- /dev/null
+++ b/tests/cpychecker/refcounts/cplusplus/method/metadata.ini
@@ -0,0 +1,3 @@
+[ExpectedBehavior]
+# We expect only compilation *warnings*, so we expect a 0 exit code
+exitcode = 0
diff --git a/tests/cpychecker/refcounts/cplusplus/method/script.py b/tests/cpychecker/refcounts/cplusplus/method/script.py
new file mode 100644
index 0000000..fdd5ba3
--- /dev/null
+++ b/tests/cpychecker/refcounts/cplusplus/method/script.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Copyright 2011 David Malcolm <dmalcolm(a)redhat.com>
+# Copyright 2011 Red Hat, Inc.
+#
+# This is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see
+# <http://www.gnu.org/licenses/>.
+
+from libcpychecker import main
+main(verify_refcounting=True,
+ dump_traces=True,
+ show_traces=False)
diff --git a/tests/cpychecker/refcounts/cplusplus/method/stderr.txt b/tests/cpychecker/refcounts/cplusplus/method/stderr.txt
new file mode 100644
index 0000000..f750265
--- /dev/null
+++ b/tests/cpychecker/refcounts/cplusplus/method/stderr.txt
@@ -0,0 +1,12 @@
+tests/cpychecker/refcounts/cplusplus/method/input.cc: In member function 'PyObject* Foo::test(int)':
+tests/cpychecker/refcounts/cplusplus/method/input.cc:43:1: warning: ob_refcnt of return value is 1 too low [enabled by default]
+tests/cpychecker/refcounts/cplusplus/method/input.cc:43:1: note: was expecting final ob_refcnt to be N + 1 (for some unknown N)
+tests/cpychecker/refcounts/cplusplus/method/input.cc:43:1: note: due to object being referenced by: return value
+tests/cpychecker/refcounts/cplusplus/method/input.cc:43:1: note: but final ob_refcnt is N + 0
+tests/cpychecker/refcounts/cplusplus/method/input.cc:32:5: note: when considering value == (int)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:30 at: if (i) {
+tests/cpychecker/refcounts/cplusplus/method/input.cc:32:5: note: taking False path at: if (i) {
+tests/cpychecker/refcounts/cplusplus/method/input.cc:41:16: note: reaching: return Py_None;
+tests/cpychecker/refcounts/cplusplus/method/input.cc:32:5: note: ob_refcnt is now refs: 0 + N where N >= 1
+tests/cpychecker/refcounts/cplusplus/method/input.cc:43:1: note: returning
+tests/cpychecker/refcounts/cplusplus/method/input.cc:43:1: note: consider using "Py_RETURN_NONE;"
+tests/cpychecker/refcounts/cplusplus/method/input.cc:31:1: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/cplusplus/method/input.cc.test-refcount-errors.html'
diff --git a/tests/cpychecker/refcounts/cplusplus/method/stdout.txt b/tests/cpychecker/refcounts/cplusplus/method/stdout.txt
new file mode 100644
index 0000000..7aad49c
--- /dev/null
+++ b/tests/cpychecker/refcounts/cplusplus/method/stdout.txt
@@ -0,0 +1,64 @@
+Trace 0:
+ Transitions:
+ 'when considering range: -0x80000000 <= value <= -1'
+ 'taking True path'
+ 'when PyDict_New() succeeds'
+ 'returning'
+ Return value:
+ repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37)))
+ str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37)) from tests/cpychecker/refcounts/cplusplus/method/input.cc:37
+ r->ob_refcnt: refs: 1 + N where N >= 0
+ r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))
+ Exception:
+ (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:31
+
+Trace 1:
+ Transitions:
+ 'when considering range: -0x80000000 <= value <= -1'
+ 'taking True path'
+ 'when PyDict_New() fails'
+ 'returning'
+ Return value:
+ repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), value=0)
+ str(): (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:37
+ Exception:
+ (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/cplusplus/method/input.cc:37
+
+Trace 2:
+ Transitions:
+ 'when considering value == (int)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:30'
+ 'taking False path'
+ 'returning'
+ Return value:
+ repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=41), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))
+ str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/cplusplus/method/input.cc:41
+ r->ob_refcnt: refs: 0 + N where N >= 1
+ r->ob_type: None
+ Exception:
+ (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:31
+
+Trace 3:
+ Transitions:
+ 'when considering range: 1 <= value <= 0x7fffffff'
+ 'taking True path'
+ 'when PyDict_New() succeeds'
+ 'returning'
+ Return value:
+ repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37)))
+ str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37)) from tests/cpychecker/refcounts/cplusplus/method/input.cc:37
+ r->ob_refcnt: refs: 1 + N where N >= 0
+ r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))
+ Exception:
+ (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:31
+
+Trace 4:
+ Transitions:
+ 'when considering range: 1 <= value <= 0x7fffffff'
+ 'taking True path'
+ 'when PyDict_New() fails'
+ 'returning'
+ Return value:
+ repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), value=0)
+ str(): (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:37
+ Exception:
+ (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/cplusplus/method/input.cc:37
12 years, 2 months
[gcc-python-plugin] cpychecker: move tests/cpychecker/refcounts/cplusplus -> tests/cpychecker/refcounts/cplusplus/simple
by David Hugh Malcolm
commit ca8b7921798189e47b45ac7e105f378e463e2625
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Tue Mar 27 16:32:19 2012 -0400
cpychecker: move tests/cpychecker/refcounts/cplusplus -> tests/cpychecker/refcounts/cplusplus/simple
.../refcounts/cplusplus/{ => simple}/input.cc | 0
.../refcounts/cplusplus/{ => simple}/metadata.ini | 0
.../refcounts/cplusplus/{ => simple}/script.py | 0
.../refcounts/cplusplus/simple/stderr.txt | 12 ++++++
.../refcounts/cplusplus/{ => simple}/stdout.txt | 36 ++++++++++----------
tests/cpychecker/refcounts/cplusplus/stderr.txt | 12 ------
6 files changed, 30 insertions(+), 30 deletions(-)
---
diff --git a/tests/cpychecker/refcounts/cplusplus/input.cc b/tests/cpychecker/refcounts/cplusplus/simple/input.cc
similarity index 100%
rename from tests/cpychecker/refcounts/cplusplus/input.cc
rename to tests/cpychecker/refcounts/cplusplus/simple/input.cc
diff --git a/tests/cpychecker/refcounts/cplusplus/metadata.ini b/tests/cpychecker/refcounts/cplusplus/simple/metadata.ini
similarity index 100%
rename from tests/cpychecker/refcounts/cplusplus/metadata.ini
rename to tests/cpychecker/refcounts/cplusplus/simple/metadata.ini
diff --git a/tests/cpychecker/refcounts/cplusplus/script.py b/tests/cpychecker/refcounts/cplusplus/simple/script.py
similarity index 100%
rename from tests/cpychecker/refcounts/cplusplus/script.py
rename to tests/cpychecker/refcounts/cplusplus/simple/script.py
diff --git a/tests/cpychecker/refcounts/cplusplus/simple/stderr.txt b/tests/cpychecker/refcounts/cplusplus/simple/stderr.txt
new file mode 100644
index 0000000..95ec022
--- /dev/null
+++ b/tests/cpychecker/refcounts/cplusplus/simple/stderr.txt
@@ -0,0 +1,12 @@
+tests/cpychecker/refcounts/cplusplus/simple/input.cc: In function 'PyObject* test(int)':
+tests/cpychecker/refcounts/cplusplus/simple/input.cc:38:1: warning: ob_refcnt of return value is 1 too low [enabled by default]
+tests/cpychecker/refcounts/cplusplus/simple/input.cc:38:1: note: was expecting final ob_refcnt to be N + 1 (for some unknown N)
+tests/cpychecker/refcounts/cplusplus/simple/input.cc:38:1: note: due to object being referenced by: return value
+tests/cpychecker/refcounts/cplusplus/simple/input.cc:38:1: note: but final ob_refcnt is N + 0
+tests/cpychecker/refcounts/cplusplus/simple/input.cc:27:5: note: when considering value == (int)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:25 at: if (i) {
+tests/cpychecker/refcounts/cplusplus/simple/input.cc:27:5: note: taking False path at: if (i) {
+tests/cpychecker/refcounts/cplusplus/simple/input.cc:36:16: note: reaching: return Py_None;
+tests/cpychecker/refcounts/cplusplus/simple/input.cc:27:5: note: ob_refcnt is now refs: 0 + N where N >= 1
+tests/cpychecker/refcounts/cplusplus/simple/input.cc:38:1: note: returning
+tests/cpychecker/refcounts/cplusplus/simple/input.cc:38:1: note: consider using "Py_RETURN_NONE;"
+tests/cpychecker/refcounts/cplusplus/simple/input.cc:26:1: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/cplusplus/simple/input.cc.test-refcount-errors.html'
diff --git a/tests/cpychecker/refcounts/cplusplus/stdout.txt b/tests/cpychecker/refcounts/cplusplus/simple/stdout.txt
similarity index 56%
rename from tests/cpychecker/refcounts/cplusplus/stdout.txt
rename to tests/cpychecker/refcounts/cplusplus/simple/stdout.txt
index 6a462cb..7a531fb 100644
--- a/tests/cpychecker/refcounts/cplusplus/stdout.txt
+++ b/tests/cpychecker/refcounts/cplusplus/simple/stdout.txt
@@ -5,12 +5,12 @@ Trace 0:
'when PyDict_New() succeeds'
'returning'
Return value:
- repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/input.cc', line=32), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/input.cc', line=32)))
- str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/input.cc', line=32)) from tests/cpychecker/refcounts/cplusplus/input.cc:32
+ repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32)))
+ str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32)) from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32
r->ob_refcnt: refs: 1 + N where N >= 0
- r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/input.cc', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))
+ r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))
Exception:
- (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/input.cc:26
+ (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:26
Trace 1:
Transitions:
@@ -19,23 +19,23 @@ Trace 1:
'when PyDict_New() fails'
'returning'
Return value:
- repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/input.cc', line=32), value=0)
- str(): (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/input.cc:32
+ repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), value=0)
+ str(): (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32
Exception:
- (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/cplusplus/input.cc:32
+ (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32
Trace 2:
Transitions:
- 'when considering value == (int)0 from tests/cpychecker/refcounts/cplusplus/input.cc:25'
+ 'when considering value == (int)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:25'
'taking False path'
'returning'
Return value:
- repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/input.cc', line=36), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))
- str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/cplusplus/input.cc:36
+ repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=36), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))
+ str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/cplusplus/simple/input.cc:36
r->ob_refcnt: refs: 0 + N where N >= 1
r->ob_type: None
Exception:
- (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/input.cc:26
+ (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:26
Trace 3:
Transitions:
@@ -44,12 +44,12 @@ Trace 3:
'when PyDict_New() succeeds'
'returning'
Return value:
- repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/input.cc', line=32), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/input.cc', line=32)))
- str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/input.cc', line=32)) from tests/cpychecker/refcounts/cplusplus/input.cc:32
+ repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32)))
+ str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32)) from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32
r->ob_refcnt: refs: 1 + N where N >= 0
- r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/input.cc', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))
+ r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))
Exception:
- (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/input.cc:26
+ (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:26
Trace 4:
Transitions:
@@ -58,7 +58,7 @@ Trace 4:
'when PyDict_New() fails'
'returning'
Return value:
- repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/input.cc', line=32), value=0)
- str(): (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/input.cc:32
+ repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), value=0)
+ str(): (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32
Exception:
- (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/cplusplus/input.cc:32
+ (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32
12 years, 2 months
[gcc-python-plugin] cpychecker: avoid a traceback with GCC 4.7 on temporaries
by David Hugh Malcolm
commit 98d050a4691c4c6739341511d8a404adf0adfe6e
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Tue Mar 27 15:07:21 2012 -0400
cpychecker: avoid a traceback with GCC 4.7 on temporaries
libcpychecker/compat.py | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/libcpychecker/compat.py b/libcpychecker/compat.py
index b7f5677..ee08793 100644
--- a/libcpychecker/compat.py
+++ b/libcpychecker/compat.py
@@ -57,10 +57,11 @@ if hasattr(gcc, 'PLUGIN_FINISH_DECL'):
decl = args[0]
if isinstance(decl, gcc.VarDecl):
- if decl.name.startswith('PyExc_'):
- global_exceptions[decl.name] = decl
- if decl.name.endswith('_Type'):
- global_typeobjs[decl.name] = decl
+ if decl.name:
+ if decl.name.startswith('PyExc_'):
+ global_exceptions[decl.name] = decl
+ if decl.name.endswith('_Type'):
+ global_typeobjs[decl.name] = decl
def _get_exception_decl_by_name(exc_name):
return global_exceptions[exc_name]
12 years, 2 months
[gcc-python-plugin] docs: add more ideas for scripts
by David Hugh Malcolm
commit a3f9d7533acf7421e91daa26517df0006f1f1394
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Tue Mar 27 12:33:40 2012 -0400
docs: add more ideas for scripts
docs/getting-involved.rst | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/docs/getting-involved.rst b/docs/getting-involved.rst
index 8f27441..47656fe 100644
--- a/docs/getting-involved.rst
+++ b/docs/getting-involved.rst
@@ -127,6 +127,19 @@ internals), but you can always ask on the mailing list if you need help.
very difficult: how does untainting work? what about pointers and memory
regions? is it just too low-level?)
+* implement something akin to PyPy's pygame-based viewer, for viewing control
+ flow graphs and tree structures: an OpenGL-based GUI giving a fast,
+ responsive UI for navigating the data - zooming, panning, search, etc. (very
+ useful, and fairly easy)
+
+* `generation of pxd files for Cython
+ <http://comments.gmane.org/gmane.comp.python.cython.user/5970>`_
+ (useful for Cython, ought to be fairly easy)
+
+* reverse-engineering a .py or .pyx file from a .c file: turning legacy C
+ Python extension modules back into Python or Cython sources (useful but
+ difficult)
+
Tour of the C code
------------------
12 years, 2 months
[gcc-python-plugin] fix gcc-python-docs
by David Hugh Malcolm
commit 8b55a9f845ef9d78bf43d423682ae82c11fd5eeb
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Tue Mar 27 12:18:24 2012 -0400
fix gcc-python-docs
gcc-python-docs | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/gcc-python-docs b/gcc-python-docs
index e08e731..5c7e80a 100755
--- a/gcc-python-docs
+++ b/gcc-python-docs
@@ -17,5 +17,5 @@
# <http://www.gnu.org/licenses/>.
# Invoke "show-docs.py", with a dummy source file
-./gcc-with-python show-docs.py test.c
+./gcc-with-python examples/show-docs.py test.c
12 years, 2 months