[PATCH v2] gcov: Runtime configurable destination output

H.J. Lu hjl.tools@gmail.com
Fri Jun 3 15:00:00 GMT 2016


On Mon, May 23, 2016 at 11:16 AM, Aaron Conole <aconole@redhat.com> wrote:
> Nathan Sidwell <nathan@acm.org> writes:
>
>> On 05/19/16 14:40, Aaron Conole wrote:
>>> Nathan Sidwell <nathan@acm.org> writes:
>>
>>>>> +FILE *__gcov_error_file = NULL;
>>>>
>>>> Unless I'm missing something, isn't this only accessed from this file?
>>>> (So could be static with a non-underbarred name)
>>>
>>> Ack.
>>
>> I have a vague memory that perhaps the __gcov_error_file is seen from
>> other dynamic objects, and one of them gets to open/close it?  I think
>> the closing function needs to reset it to NULL though?  (In case it's
>> reactivated before the process exits)
>
> This is being introduced here, so the actual variable won't be seen,
> however you're correct - the APIs could still be called.
>
> I think there does exist a possibility that it can get re-activated
> before the process exits. So, I've changed it to have a proper block
> cope and to reset gcov_error_file to NULL.
>
>>>> And this protection here, makes me wonder what happens if one is
>>>> IN_GCOV_TOOL. Does it pay attention to GCOV_ERROR_FILE?  That would
>>>> seem incorrect, and thus the above should be changed so that stderr is
>>>> unconditionally used when IN_GCOV_TOOL?
>>>
>>> You are correct.  I will fix it.
>>
>> thanks.
>>
>>>>> +static void
>>>>> +gcov_error_exit(void)
>>>>> +{
>>>>> +  if (__gcov_error_file && __gcov_error_file != stderr)
>>>>> +    {
>>>>
>>>> Braces are not needed here.
>>
>> Unless of course my speculation about setting it to NULL is right.
>
> It is - I've fixed it, and will post the v3 patch shortly.
>
> Thank you for your help, Nathan!
>

It breaks profiledbootstrap:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71400

-- 
H.J.



More information about the Gcc-patches mailing list