Adding more decl attribute code
by Philip Herron
Hey
I just been needing to get access to certain attributes of functions
like DECL_EXTERNAL or DECL_STATIC etc would e quite nice to have. And
i see i add in:
// generate-tree-c.py
add_simple_getter('external',
'gcc_python_make_wrapper_tree(DECL_EXTERNAL(self->t))',
"The decl_external value")
But these attributes return an unsigned char:1 so just a simple True
and False. I dont know what function i should be using to wrap a
simple value for this i feel quite lost in the code.
--Phil
11 years, 9 months
make install
by Philip Herron
Hey
Just wondering maybe i am completely missing something but i dont see
a make install rule. Just would be kind of usefull if you could
install the python code and the plugin some way instead of having to
always develop and run my python code within the gcc-python dir.
--Phil
11 years, 10 months
fixlet for cfg_to_dot
by Tom Tromey
cfg_to_dot has its argument names reversed. This doesn't affect
anything, since it also reverses them in the call to CfgPrettyPrinter.
However, it is confusing.
I verified this by looking at all the calls to cfg_to_dot in the tree.
This then showed that there is a one-argument call in
test.py:my_pass_execution_callback:
dot = cfg_to_dot(fun.cfg)
So, I defaulted the 'name' argument to cfg_to_dot.
Tom
>From 123798567dec2478bc18db4d58b713d64873071b Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey(a)redhat.com>
Date: Tue, 19 Jun 2012 10:07:47 -0600
Subject: [PATCH] two fixes for cfg_to_dot
First, reverse the argument names. This just fixes some confusion.
Second, default the 'name' argument. This fixes a one-argument call
in test.py.
---
gccutils.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gccutils.py b/gccutils.py
index 8e18077..496bfc5 100644
--- a/gccutils.py
+++ b/gccutils.py
@@ -533,8 +533,8 @@ class TreePrettyPrinter(DotPrettyPrinter):
result += '}\n'
return result
-def cfg_to_dot(name, cfg):
- pp = CfgPrettyPrinter(name, cfg)
+def cfg_to_dot(cfg, name = None):
+ pp = CfgPrettyPrinter(cfg, name)
return pp.to_dot()
--
1.7.7.6
11 years, 10 months
identifiers
by Philip Herron
Hey
I am working on my gsoc on pxd generation and i was wondering in places like:
PyObject * gcc_Function_repr(struct PyGccFunction * self)
You get the identifiers for things using IDENTIFIER_POINTER and then
format things into
result = gcc_python_string_from_format("gcc.Function('%s')",
name);
In my code i have to write code to get the identifier out of this
format which to me seems a little awkward if we were to make available
the identifiers non-formatted would be quite nice. Even just a
supporting python code parsing them out for you would this kind of
code be useful to the plugin or leaving things as is the preferred
method.
--Phil
11 years, 10 months
[ANN] Gentoo Packages
by David Narvaez
Hi,
I finally managed to complete my first goal in cooperating with this
plugin, by packaging it on Gentoo (meaning I'm about 6 months behind
my schedule....). You can add the dMaggot overlay from layman which
provides packages for 0.9 and live (git) builds. I currently have
tested the builds in amd64 and x86 against GCC 4.6. I'll try to expand
my test base to make sure these build in other setups.
Notice that the live ebuild does not build at the moment. This is
because I don't patch sources when building from git, so it currently
lacks man pages Makefile target and the documentation patches to make
it compatible with Python 3, but I expect these to be merged into the
code at some point soon which should make the ebuild work again.
If using Portage with test FEATURES, you get to run the tests, but I
haven't disabled those that are known to fail so it will most likely
break the build.
Feel free to ask any questions or post any comments here or by
personal e-mail. Thanks.
David E. Narváez
11 years, 10 months
cpychecker and gmpy2
by Case Van Horsen
Hi,
I compiled gmpy2 (a wrapper for GMP, MPFR, and MPC) with
gcc-with-cpychecker. It found several reference counting bugs and a
few missing checks for NULL return values.
I am seeing an AssertionError in absinterp.py. It occurs repeatedly.
The first instance is:
In file included from src/gmpy2.c:452:0:
src/gmpy_mpz.c: In function ‘Pyxmpz_digits’:
src/gmpy_mpz.c:188:5: error: Unhandled Python exception raised calling
'execute' method
Traceback (most recent call last):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/__init__.py",
line 66, in execute
self._check_refcounts(fun)
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/__init__.py",
line 70, in _check_refcounts
self.show_possible_null_derefs)
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/refcounts.py",
line 3198, in check_refcounts
limits=limits)
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2896, in iter_traces
depth + 1):
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2860, in iter_traces
transitions = curstate.get_transitions()
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2007, in get_transitions
return self._get_transitions_for_stmt(stmt)
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2023, in _get_transitions_for_stmt
return self._get_transitions_for_GimpleCall(stmt)
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2187, in _get_transitions_for_GimpleCall
return meth(stmt, *args)
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/refcounts.py",
line 1392, in impl_PyErr_SetString
t_next = self.state.mktrans_nop(stmt, 'PyErr_SetString')
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 2085, in mktrans_nop
newstate.loc = self.loc.next_loc()
File "/usr/lib/gcc/x86_64-redhat-linux/4.7.0/plugin/python2/libcpychecker/absinterp.py",
line 1113, in next_loc
assert len(self.bb.succs) == 1
AssertionError
Line 188 is a call to this macro:
#define PARSE_ONE_MPZ_OPT_CLONG(var, msg) \
if (self && CHECK_MPZANY(self)) { \
if (PyTuple_GET_SIZE(args) == 1) { \
*var = clong_From_Integer(PyTuple_GET_ITEM(args, 0)); \
if (*var == -1 && PyErr_Occurred()) { \
PyErr_SetString(PyExc_TypeError, msg); \
return NULL; \
} \
} \
else if (PyTuple_GET_SIZE(args) > 1) { \
PyErr_SetString(PyExc_TypeError, msg); \
return NULL; \
} \
Py_INCREF(self); \
} \
else { \
if (PyTuple_GET_SIZE(args) == 2) { \
*var = clong_From_Integer(PyTuple_GET_ITEM(args, 1)); \
if (*var == -1 && PyErr_Occurred()) { \
PyErr_SetString(PyExc_TypeError, msg); \
return NULL; \
} \
self = PyTuple_GET_ITEM(args, 0); \
if (CHECK_MPZANY(self)) { \
Py_INCREF((PyObject*)self); \
} \
else { \
self =
(PyObject*)Pympz_From_Integer(PyTuple_GET_ITEM(args, 0)); \
} \
} \
else if (PyTuple_GET_SIZE(args) == 1) { \
self = PyTuple_GET_ITEM(args, 0); \
if (CHECK_MPZANY(self)) { \
Py_INCREF((PyObject*)self); \
} \
else { \
self =
(PyObject*)Pympz_From_Integer(PyTuple_GET_ITEM(args, 0)); \
} \
} \
else { \
PyErr_SetString(PyExc_TypeError, msg); \
return NULL; \
} \
if (!self) { \
PyErr_SetString(PyExc_TypeError, msg); \
return NULL; \
} \
}
Interestingly, this is the second invocation of this macro in
gmpy2_mpz.c The previous invocation occurs on line 175 and doesn't
generate an exception.
Please let me know if you need more information.
casevh
11 years, 10 months
NamespaceDecl declarations/namespaces
by Matt Rice
this patch allows you to loop over gdb.NamespaceDecl's from the
global_namespace,
and get at declarations, and some various things needed along the way.
I wasn't quite sure on where to put the functions i added to gcc-python-tree.c
or if they are named inappropriately.
one strange thing i suppose is the alias_of/unalias duality,
in gccint it says:
Do not attempt to use `cp_namespace_decls' for a namespace which is
an alias. Instead, follow `DECL_NAMESPACE_ALIAS' links until you
reach an ordinary, non-alias, namespace, and call
`cp_namespace_decls' there.
alias_of calls DECL_NAMESPACE_ALIAS once, and returns None if not an alias
while unalias does the looping, and returns self if not an alias.
turns out DECL_NAMESPACE_ALIAS seems to always return the same alias
as looping over it.
rather than the actual alias (in alias of alias cases),
thus the looping doesn't seem to be doing much,
but I kept both around for the None vs Self behaviour.
if this behaves differently on various gcc's i'll have to do something
about the test.
though, now that I think about it maybe I should get rid of alias_of,
and turn it into is_alias returning a BOOL, let me know what you prefer.
couldn't think of a better name than unalias, but didn't particularly like it.
11 years, 10 months
Man Pages for gcc-with-python
by David Narvaez
Hi,
I see that the .spec file to create RPMs references man pages for
gcc-with-python. How do I generate those man pages from the Makefile?
Thanks in advance.
David E. Narvaez
11 years, 10 months