This is the mail archive of the 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: [patch] python(+solib error): save/restore error state

On Fri, Oct 8, 2010 at 12:11 PM, Jan Kratochvil
<> wrote:
> @@ -768,6 +782,13 @@ source_python_script_for_objfile (struct objfile *objfile,
> ? ? ?clear the error indicator. ?*/
> ? PyRun_SimpleFile (stream, file);
> + ?if (PyErr_Occurred ())
> + ? ?{
> + ? ? ?gdbpy_print_stack ();
> + ? ? ?error (_("Error reading python script %s for object file %s"), file,
> + ? ? ? ? ? ?objfile->name);
> + ? ?}
> +
> ? do_cleanups (cleanups);
> ? gdbpy_current_objfile = NULL;
> ?}

Hi.  Most of the patch seems great, but it raises a question that I
think needs to be answered.

The comment above this code says:

  /* Note: If an exception occurs python will print the traceback and
     clear the error indicator.  */

ISTM that either this comment is wrong or the above patch is wrong, or
some combination thereof.

Also, if there is a problem here, then presumably source_python_script
has the same problem, but I don't see it addressed in this patch.

Plus if PyRun_SimpleFile can leave an outstanding error, we should
research whether PyRun_SimpleString has the same problem.  I see
python.c checks the result of PyRun_SimpleString and calls
gdbpy_print_stack if there's an error.  Except that the python docs
say there is no way to get the error.


The docs for PyRun_SimpleFile suggest the same, there is no way to get
the error.

So, am I misreading the python docs or do we need the above patch?
(and then if not, do we need the calls to gdbpy_print_stack after the
calls to PyRun_SimpleString? Some experiments are in order - off to do
some ...

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