This is the mail archive of the gdb-patches@sourceware.org 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: [RFA] PR python/18565 - make Frame.function work for inline frames


On Mon, Jul 25, 2016 at 12:04 PM, Pedro Alves <palves@redhat.com> wrote:
>>
>> The reason I suggested that way is that the exception may be thrown out in
>> find_frame_funname after the memory is allocated for funname, so we need
>> xfree in CATCH, and also need xfree afterwards.
>
> I disagree.  In general, I think that up until the called function does a normal

What do you disagree on?

> return, the memory for output parameters is owned by the called function.
> A normal return then transfers ownership of the output parameters' memory
> to the caller.

Yes, so we need xfree after find_frame_funname on normal return.  That is
what I suggested.

We need to free the memory referenced by output parameter when exception
is thrown too.  The point in question is that who is responsible to free the
memory referenced by output parameter.  In Tom's patch, they are freed in
the caller in normal return, so it is reasonable to free them in the caller in
exception return as well, because it is not specified that find_frame_funname
frees the memory on exception.

>
> So I think that it's find_frame_funname that should be responsible for making
> sure that memory for output parameters is cleaned up on exception, or be
> written in a way that never throws after the memory allocation, which it may be
> already, but I haven't checked in detail.
>

If you think it is find_frame_funname's responsibility to free memory on
exception, that is fine.  We should document this behaviour for
find_frame_funname and guarantee that  find_frame_funname behaves
that way.  However, we are not sure current find_frame_funname behaves that
way, because exception may be thrown in cp_remove_params.

-- 
Yao (齐尧)


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