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: [python][patch] Inferior and Thread information support.

>>>>> "Phil" == Phil Muldoon <> writes:

Phil> +  cleanup = ensure_python_env (python_gdbarch, python_language);
Phil> +
Phil> +  thread_obj = create_thread_object (tp);
Phil> +  if (!thread_obj)
Phil> +    {
Phil> +      warning (_("Cannot create Python InferiorThread object."));
Phil> +      gdbpy_print_stack ();
Phil> +      do_cleanups (cleanup);

Tom> I don't think there is any need for a warning here.
Tom> The exception should suffice.

Phil> OK
Actually I meant that you should remove the call to warning but leave in
the gdbpy_print_stack.

Phil> +      buffer = xmalloc (length);
Phil> +      make_cleanup (xfree, buffer);
Phil> +
Phil> +      read_memory (addr, buffer, length);
Phil> +    }
Phil> +  GDB_PY_HANDLE_EXCEPTION (except);

Tom> GDB_PY_HANDLE_EXCEPTION returns from the function; this will leave the
Tom> cleanups dangling.  You have to run the cleanups before the return.

Phil> OK

The new code looks like this:

Phil> +  if (except.reason < 0)
Phil> +    {
Phil> +      do_cleanups (cleanups);
Phil> +      return PyErr_Format (PyExc_RuntimeError, "%s", except.message);
Phil> +    }

... but this does the wrong thing for RETURN_QUIT.
Instead I think you should do

if (except.reason < 0)
    do_cleanups ...;

This is a little redundant but it will do the right thing -- and will
continue to do so if we ever split the different kinds of gdb
exceptions into different Python exceptions.

This patch is ok with those changes.  Thanks for persevering.


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