Python pretty-printing [5/6]

Tom Tromey tromey@redhat.com
Thu Apr 9 15:44:00 GMT 2009


>>>>> "Thiago" == Thiago Jung Bauermann <bauerman@br.ibm.com> writes:

Thiago> I found one potential problem, which could cause the function to return
Thiago> NULL without an exception being set (it's not the case I thought of
Thiago> before, I think): suppose there's no objfile Python object when this
Thiago> function is called, to the ALL_OBJFILES loop will skip all objs, then
Thiago> the gdb module has no pretty_printers attribute, or the pretty_printers
Thiago> value is not a list object. In that case, the function will return NULL
Thiago> without a Python exception being set. Can it happen?

Yes, I see it now:

  /* Fetch the global pretty printer dictionary.  */
  if (! PyObject_HasAttrString (gdb_module, "pretty_printers"))
    goto done;

That is the bad branch.  Thanks.

Also, I think here:

    PyObject *objf = objfile_to_objfile_object (obj);
    if (!objf)
      continue;

... we need to clear the python error.

I will make the needed changes.

Thiago> Also, I noticed that the function may return Py_None if no
Thiago> pretty-printer is found, and the callers even expect that. The function
Thiago> comment needs to be fixed then:

Thanks.

Tom



More information about the Gdb-patches mailing list