When do two matrices have the same exponential?

Here is a rather cheap answer to this question. Let $E_\lambda$ denote the eigenspace of $\lambda \in \mathrm{spec}(A)$. Let $F_\lambda$ denote the eigenspace of $\lambda \in \mathrm{spec}(B)$. Then $\exp(iA) =\exp(iB)$ if and only if, for every $\lambda_0 \in \mathbb{R}$, we have $$\bigoplus_{\lambda \in \mathrm{spec}(A) \cap (\lambda_0 + 2 \pi \mathbb{Z})} E_\lambda = \bigoplus_{\lambda \in \mathrm{spec}(B) \cap (\lambda_0 + 2 \pi \mathbb{Z})} F_\lambda.$$

Roughly speaking, the condition is that $A$ and $B$ should have the same eigenspaces, after identifying the eigenvalues whose exponentials are equal.