ping [PATCH] Make "backtrace" doesn't print python stack if init python dir get fail

Phil Muldoon pmuldoon@redhat.com
Mon Jun 16 18:51:00 GMT 2014


On 16/06/14 16:27, Programmingkid wrote:
> I am pinging this patch to be considered for the next release of gdb. It fixes the error message that is displayed with a backtrace.
>
> It is originally found here: http://www.sourceware.org/ml/gdb-patches/2013-11/msg00881.html
>
> 2013-11-28  Hui Zhu  <hui@codesourcery.com>
>
>     * python/py-framefilter.c(apply_frame_filter): Add check for
>     "gdb_python_module".
>
> --- a/gdb/python/py-framefilter.c
> +++ b/gdb/python/py-framefilter.c
> @@ -1506,7 +1506,10 @@ apply_frame_filter (struct frame_info *f
>       initialization error.  This return code will trigger a
>       default backtrace.  */
>
> - gdbpy_print_stack ();
> +      if (gdb_python_module != NULL)
> +        gdbpy_print_stack ();
> +      else
> +    PyErr_Clear ();
>        do_cleanups (cleanups);
>        return PY_BT_NO_FILTERS;
>      }
>

A quick note before we get into the patch.  Patch "pings" should go to
the gdb-patches list.  I've moved the discussion back over to that list.

This code branch is a fail-safe.  This conditional branch prints out a
standard backtrace if: 1) The frame-filters failed, and 2) Nothing has
yet been printed to the console. ("iterable" should never be NULL at
this point.)

Unfortunately, in the case of the frame-filters failing and it is not
due to the Python module failing, then this patch clears the error and no
error message is printed.  I don't think this is wise.

I think the gdb_python_module check should be performed far, far
earlier.  I noticed this piece of code in gdbpy_apply_frame_filter (in
py-framefilter.c):

if (!gdb_python_initialized)
   return EXT_LANG_BT_NO_FILTERS;

I am curious to the difference and why we need two different "Python
initialized" checks?  What's the difference between gdb_python_module
and gdb_python_initialized? That kind of sounds like another bug to
me.

While I do not object to this check being performed, it should be done
elsewhere (earlier) if necessary, and/or investigate why there are two
checks for (what seems like) the same issue.

Cheers

Phil








More information about the Gdb-patches mailing list