[PATCH 14/16] move async_client_callback and async_client_context into remote_state

Pedro Alves palves@redhat.com
Mon Jun 24 19:03:00 GMT 2013


On 06/24/2013 07:43 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
>>> static void
>>> remote_async_serial_handler (struct serial *scb, void *context)
>>> {
>>> +  struct remote_state *rs = context;
> 
> Pedro> Does this actually work?
> 
>>> +      serial_async (rs->remote_desc, remote_async_serial_handler, rs);
>>> +      rs->async_client_callback = callback;
>>> +      rs->async_client_context = context;
> 
> Pedro> Because I think CONTEXT is always NULL here.
> 
> Pedro> And it'd seem a wrong to me to store the remote state in the
> Pedro> meant for context passed in by the target_async's caller?
> 
> I think it should work.
> 
> There are two callbacks and two "context" values here.
> 
> In that second snippet, "callback" and "context" are the arguments to
> remote_async.  We stash those in the struct remote_state.
> 
> Then we call serial_async with remote_async_serial_handler as a callback
> and with the remote_state as the context.
> 
> When remote_async_serial_handler is called, we fetch the original
> callback and the original context from the remote_state, and call those.
> 
> We need this second callback layer because we want to add in the
> INF_REG_EVENT argument.

Ah, I see now.  Sorry for missing it.

> I hope that's clear and correct.

Thanks, it is.

-- 
Pedro Alves



More information about the Gdb-patches mailing list