Get an Animator state inside an AnimationEvent callback of the last frame

I would like to write a method that traces debug info about animator state. Its purpose is to detect which state called AnimationEvent callback. But I have a problem with the last frame. When I bind callback to the last frame and request current state info of Animator by GetCurrentAnimatorStateInfo() inside this callback I’m getting the next state.

Here on the picture OnAnimationEvent() is bound to the last frame:

It seems Animator performs transition before executing the last event. Does anyone know how to get actual state for this case? Or maybe anybody knows how to detect which state executed callback in runtime for Debug purposes?

Finally I’ve found a simple solution that is suitable for me. I’ve changed callback signature to accept AnimationEvent as argument instead of int. The great thing is serialization of old signature mapped to the new one automatically and I don’t need to remember all motions where I used the callback and setup its parameters again in the Animation window.
Here is my callback that logs the necessary info. Also I’m using int from AnimationEvent instead of direct passing:

public void OnAnimationEvent ( AnimationEvent evt )
    Debug.LogFormat( "I'm called by animator of {0} in clip {1}",
        GetComponent<Animator>(), );

    Debug.Log( "I'm using int parameter: " + evt.intParameter );

AnimationEvent also contains animatorStateInfo that can be used to detect the state too.

If it’s applicable, you can use StateMachineBehaviors.

Those act just like the Monobehaviors, except they can only be attached to “AnimatorState”, in mechanim.
They provide all the callbacks you need.