This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [commit] [PATCH] Allow 64-bit enum values


Jan Kratochvil wrote:

> +2012-04-18  Siddhesh Poyarekar  <siddhesh@redhat.com>
> +
> +	* python/py-type.c (convert_field): New variable addrstring.  Use
> +	TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM.

> --- src/gdb/python/py-type.c	2012/02/17 19:24:26	1.36
> +++ src/gdb/python/py-type.c	2012/04/18 06:46:46	1.37
> @@ -167,11 +167,23 @@
>  
>    if (!field_is_static (&TYPE_FIELD (type, field)))
>      {
> -      arg = PyLong_FromLong (TYPE_FIELD_BITPOS (type, field));
> +      const char *attrstring;
> +
> +      if (TYPE_CODE (type) == TYPE_CODE_ENUM)
> +	{
> +	  arg = gdb_py_long_from_longest (TYPE_FIELD_ENUMVAL (type, field));
> +	  attrstring = "enumval";
> +	}
> +      else
> +	{
> +	  arg = PyLong_FromLong (TYPE_FIELD_BITPOS (type, field));
> +	  attrstring = "bitpos";
> +	}
> +
>        if (!arg)
>  	goto fail;
>  
> -      if (PyObject_SetAttrString (result, "bitpos", arg) < 0)
> +      if (PyObject_SetAttrString (result, attrstring, arg) < 0)
>  	goto failarg;
>      }

This causes a build failure for me due to:
py-type.c: In function 'convert_field':
py-type.c:186: warning: passing argument 2 of 'PyObject_SetAttrString' discards qualifiers from pointer target type

/usr/include/python2.4/object.h has
   PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, char *, PyObject *);

Maybe this depends on the Python version?

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]