[PATCH] Replace deprecated_target_wait_hook by an observer
Patrick Monnerat
patrick@monnerat.net
Thu Aug 26 10:53:07 GMT 2021
On 8/26/21 4:41 AM, Simon Marchi wrote:
> On 2021-08-25 12:19 p.m., Andrew Burgess wrote:
>> * Patrick Monnerat <patrick@monnerat.net> [2021-08-25 15:30:28 +0200]:
>>
>>> On 8/24/21 6:14 PM, Andrew Burgess wrote:
>>>> * Patrick Monnerat via Gdb-patches <gdb-patches@sourceware.org> [2021-08-22 18:42:56 +0200]:
>>>>
>>>>> +DEFINE_OBSERVABLE (waiting_for_target);
>>>> Given we already have events 'target_changed' and 'target_resumed', I
>>>> wonder if it would be more consistent to name this event 'target_wait'?
>>>>
>>> Yes, it's possible. Here are the two reasons why I did not name this
>>> observer 'target_wait':
>>>
>>> 1) Because the observer is not supposed to wait by itself, I fear it will be
>>> a source of confusion.
>>>
>>> 2) As a good old C programmer, I still have some reluctance naming an object
>>> as a global procedure. Not being declared in the same namespace though!
>>>
>>> Comments are welcome!
>> How about 'target_waiting' then? This seems more inline with the
>> existing naming, seems to indicate that the target _is_ waiting, not
>> the that observer _should_ wait (so avoiding #1), and is a new name
>> (so avoiding #2).
> Oh, I have always seen it as the caller waiting for the target to
> produce some event (in a context where everything was blocking / not
> async... nowadays, with async, I always find using the term "wait" for
> "fetch an event" confusing). So the event would be
> "target_waited_on". Another way (it's not our current style so I
> wouldn't choose that) would be to name all events "on something". So
> "on_target_wait".
>
> Regardless, since we are debating this, I would suggest splitting the
> observer in two actuall:
>
> - target_pre_wait (or target_wait_pre or whatever)
> - target_post_wait (or target_wait_post or whatever)
>
> I think it's better to keep 1 observable == 1 event, rather than
> having two events in one with a boolean to differentiate.
If it is not a luxury to have 2 observers for such a function, I think
it's the best solution/naming.
>
>>> That would make sense, but in case we have an exception, event_ptid is not
>>> known. How would you handle it? pass it as null_ptid?
>> Yeah I guess that would make sense.
> I think that's ok, I don't think target_ops::wait implementations ever
> return null_ptid (although I haven't checked, it's just from memory).
>
An updated patch follows.
Patrick
More information about the Gdb-patches
mailing list