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: [PATCH] Destroy allocated values when exiting GDB


On Monday, April 01 2019, Pedro Alves wrote:

> On 03/29/2019 09:43 PM, Sergio Durigan Junior wrote:
>
>> 
>> diff --git a/gdb/top.c b/gdb/top.c
>> index b10b0649e9..ffbe8e517f 100644
>> --- a/gdb/top.c
>> +++ b/gdb/top.c
>> @@ -1672,6 +1672,9 @@ quit_force (int *exit_arg, int from_tty)
>>      }
>>    END_CATCH
>>  
>> +  /* Destroy any values currently allocated.  */
>> +  finalize_values ();
>
> I think that someone reading this without context may not realize
> why we need to do that.  How about extending the comment, like:
>
>   /* Destroy any values currently allocated now instead of leaving it
>      to global destructors, because that may be too late.  For
>      example, the destructors of xmethod values call into the Python
>      runtime, which is finalized via a final cleanup.  */

Done.

>> diff --git a/gdb/value.h b/gdb/value.h
>> index d3905cc354..7853950ca3 100644
>> --- a/gdb/value.h
>> +++ b/gdb/value.h
>> @@ -1189,4 +1189,8 @@ extern struct value *call_xmethod (struct value *method,
>>  extern int value_union_variant (struct type *union_type,
>>  				const gdb_byte *contents);
>>  
>> +/* Destroy the values currently allocated.  This is mostly called when
>> +   GDB is exiting (e.g., on quit_force).  */
>
> s/mostly//

Done.

>> +extern void finalize_values ();
>> +
>>  #endif /* !defined (VALUE_H) */
>
> LGTM with those changes.

Thanks for the review.  Pushed:

9d1447e09d4aa673826039321163b5a684e8e043

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


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