Creating macro cross references

Is there any tool that allows me to analyze/see/display macro dependencies?

To be clear: After

\def\a{\b\c}
\def\b{\x\c}


I'd like to get that \a uses \b and \c and that \b uses \x and \c, best nicely displayed. And to make me entirely happy: the tool should also tell me that \a was defined in file X at line Y...

Slightly editing my answer to your other related question, Q: Loop over all tokens in the body of a macro.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\let\enddependency\relax
\let\test\relax
\newcommand\dependency[1]{The macro \string#1 contains these dependencies:%
\expandafter\dependencyaux#1\enddependency\par}
\def\dependencyaux#1#2\enddependency{%
\ifcat\relax\noexpand#1 \string#1\fi
\ifx\enddependency#2\else\dependencyaux#2\enddependency\fi%
}
\begin{document}
\def\a{ blah \b de-blah-blah \c}
\def\b{\x{\c}}
\dependency{\a}
\dependency{\b}
\end{document}