[PATCH 5/7] [python] API for macros: gdb.Objfile symtabs method.

Tom Tromey tromey@redhat.com
Tue Aug 30 17:34:00 GMT 2011


>>>>> "matt" == matt rice <ratmice@gmail.com> writes:

matt> 2011-08-23  Matt Rice  <ratmice@gmail.com>
matt> 	* python/py-symtab.h: New file.  Make symtab_to_symtab_object public.
matt> 	* python/py-objfile.c (objfpy_symtabs): New method.
matt> 	(objfile_object_methods): Ditto.

A couple notes on this.

matt> +static PyObject *
matt> +objfpy_symtabs (PyObject *self, PyObject *ignore)
matt> +{
matt> +  objfile_object *obj = (objfile_object *) self;
matt> +  struct symtab *symtabs;
matt> +  PyObject *list;
matt> +  PyObject *py_symtab;
matt> +
matt> +  if (! obj->objfile)
matt> +    return Py_None;

You need Py_RETURN_NONE.

I think most of our objects will throw an exception if you try to
operate on them when they are in the 'invalid' state; if that is true
then I think this should conform.

matt> +  while(symtabs)

Missing space.

matt> +  { "symtabs", objfpy_symtabs, METH_NOARGS,
matt> +    "symtabs () -> List.\n\
matt> +A List containing the object file's valid symtabs." },

I don't mind this method per se, but I think people will find it
confusing, as it only returns full symtabs -- but there is no direct way
for the Python programmer to cause symtab expansion.

matt> +PyObject *
matt> +symtab_to_symtab_object (struct symtab *symtab);

In addition to what Phil said, the norm is not to split declarations
after the type -- only definitions.

Tom



More information about the Gdb-patches mailing list