Let $f,g$ be entire functions, then the argument principle teaches us that 


$$\frac{1}{2\pi i}\int\_{\mathbb{C}} g(z) \frac{f'(z)}{f(z)} dz$$
is equal to $g$ evaluated at the zeros of $f.$


Now, let us assume that $f: \mathbb{C} \rightarrow \mathbb{C}^{2 \times 2}$ is matrix-valued and holomorphic. 


If $f$ is diagonal, then it follows from the above theorem that 
$$\operatorname{tr}\left(\frac{1}{2\pi i}\int\_{\mathbb{C}} g(z) Df(z)f(z)^{-1} dz\right)$$
is precisely $g$ evaluated at the singular points of $f$, i.e. the points $z$ for which $\operatorname{det}(f(z))=0$ times $2-\text{rank}(f(z))$ at those points.


I ask: If $f$ is now not assumed to be diagonal, but only self-adjoint, does this statement hold true, i.e.
$$\operatorname{tr}\left(\frac{1}{2\pi i}\int\_{\mathbb{C}} g(z) Df(z)f(z)^{-1} dz\right)=\sum\_{z \in \mathbb{C}; \operatorname{det}(f(z))=0} g(z) \text{rank}(2-f(z)).$$


An obvious approach would be to use that $f$ is diagonalizable and the properties of the trace, but in this case the unitary transform also depends on $z$, so a bit more care seems to be needed.



Argument principle for matrices
You can write instead
$$\frac1{2i\pi}\int\_Cg(z){\rm tr}(f'(z)f(z)^{-1})dz.$$
Now use the formula
$${\rm tr}(f'(z)f(z)^{-1})=\frac1{\det f(z)}\,(\det f(z))'.$$
And conclude with the formula of residues.


Remark that the formula tells us that what matters is the algebraic multiplicities of the zeroes of $\det f$, rather than the dimension of the kernels of $f(z)$.


