Re: [PATCH v4 2/3] Forget watchpoint locations when inferior exits or is killed/detached

Pedro Alves
2016-06-24T19:10:55Z

On 06/17/2016 12:55 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
>
>> + /* Get rid of existing locations, which are no longer
>> + valid. New ones will be created in
>> + update_watchpoint, when the inferior is
>> + restarted. */
>> + b->loc = NULL;
>
> Use decref_bp_location or is it intended?
>

It's intended. The b->loc chain doesn't count for incr/decref.
It really holds weak references. The strong references are either
in the global location chain or the bpstat chains. So the next time
update_global_location_list is called, locations that are found
to not be referenced by any breakpoint are garbage collected then,
via decref_bp_location.

See how update_breakpoint_locations simply hoists old locations
out of the breakpoint, but doesn't decref them. [Used to clearer
before c2f4122d5cc2 ("Limit breakpoint re-set to the current
program space") though].

Thanks,
Pedro Alves