Given symmetric $A,B\in\Bbb R^{n\times n}$ what is a good description of collection of $X\in\Bbb R^{n\times n}$ such that $$XX'=I$$ $$AX=XB$$ holds?

Note: $X'$ means the transpose of $X$.

**(1)** Is there a test to see if there is no such $X$?

It is easy to see if we find one such $X$ we can ALL such $X$ from finding $U\in\Bbb R^{n\times n} $ such that $UU'=I$ and $UA=AU$ or $BU=UB$. 

**(2)** What if we have $\Bbb F_{p^r}$ instead of $\Bbb R$?