Re: [PATCH] Delegate to target_ops->beneath to read cache lines

Pedro Alves
2013-11-29T13:47:49Z

On 11/29/2013 01:28 PM, Yao Qi wrote:
> The endless recursion I saw yesterday is that both current_target.to_xfer_partial
> and current_target.beneath->to_xfer_partial are core_xfer_partial. Looks
> like it delegates to "itself", and causes an endless recursion, so I use
> current_target.beneath instead of &current_target. I may mess up
> something then.

Not really. to_xfer_partial is not INHERITed in update_current_target.
current_target.to_xfer_partial is set to current_xfer_partial, which
always delegates to current_target.beneath.

Even it is was inherited, I don't think we'd recurse forever,
because although the callback would be the same, the target_ops
instances are not. It's just that core_xfer_partial would end
up unnecessarily being called twice, before reaching the the exec target:

current_target.to_xfer_partial
==> core_xfer_partial (squashed target, returns 0, try beneath)

current_target.beneath->to_xfer_partial
==> core_xfer_partial (corelow target, returns 0, try beneath)

current_target.beneath->beneath->to_xfer_partial
==> exec_xfer_partial (exec target, returns != 0)

(This is all less clear than it should be; I think
Tromey's target delegation method patch should set us
in the direction of making these things a little clearer.)

--
Pedro Alves