On Wed, 2011-10-26 at 08:34 -0600, Tom Tromey wrote:
>>>>> "David" == David Malcolm
<dmalcolm(a)redhat.com> writes:
...
David> The patch isn't ready as-is, but hopefully gives an
idea of what's
David> possible, and takes another bite out of the big wall of false positives
David> that the checker currently emits.
The patch seems pretty close to me.
I looked at this this morning, before I read your mail, and came up with
nearly the same thing :)
:)
If you want, we can make a branch in archer.git for this sort of
thing.
Then once you think the plugin is really ready, we can push it all
upstream into gdb. Let me know; I can give you write access or set up
the branch or whatever.
I was going to say "sure", but I'm a bit nervous about this - I don't
want to get into the business of actually fixing gdb's bugs.
I want to provide the tools to let developers easily identify various
categories of bugs that were hard to spot before - but I don't want to
actually have to do the work of fixing those bugs - if that makes sense.
(I don't want to end up having to fix every reference-counting bug in
every package on PyPI)
So I'd be happy to put these additions into a branch, but I'm hoping my
direct code contributions to gdb for this will be a relatively small
patch to python-internal.h
(Hope this doesn't come across wrong)
David> + #define CPYCHECKER_RETURNS_BORROWED_REF() \
David> + __attribute__((cpychecker_returns_borrowed_ref))
The gdb style is to use object-like, not function-like, macros for this
kind of thing.
By "object-like", do you mean without parentheses?
E.g., from src/include/ansidecl.h:
#if (GCC_VERSION < 2007)
# define __attribute__(x)
#endif
[...]
#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif /* ATTRIBUTE_UNUSED */
Should it have an ATTRIBUTE_ prefix, perhaps? Not sure. (but that's
heading into bikeshed territory; more important to actually get it
working)
David> +#else
David> + #define CPYCHECKER_RETURNS_BORROWED_REF()
David> + #error (This should have been defined)
David> +#endif
I think having a #error here is wrong.
It is ok not to use the plugin ;-)
Good catch - in case this wasn't obvious, I meant to remove this when I
copied and pasted from the code in the automated test case.
(Am working on more of these custom attributes for cpychecker)
Thanks!
Dave