The program you're thinking of is texdef, by Martin Sharrer. It can be found here, but should already be included with your TeX distribution.
To find out how a macro is defined, you can type latexdef <macro> or texdef -t latex <macro> (if the first one doesn't work), where <macro> is the name of the command you are interested in (without the initial \!).
If you want to know the definition when certain packages or classes are loaded, you can tell latexdef using -p [<options]<package> flag and -c [<options>]<class> respectively (article is used if no class is specified).
To find out how TheSolution is defined if hyperref is loaded with the draft option (which actually makes no difference), you would for instance type
latexdef -c exam -p [draft]hyperref -E TheSolution
I added -E because TheSolution is an environment, so the definition of endTheSolution is also shown. If TheSolution had been a (dimension, skip, count, token sequence, …) register I would instead have ve added -v to see its value.
To figure out in which file a macro is defined you can -f, and you can then find out where this file is located using kpsewhich <filename>. If latexdef says that a macro is defined by LaTeX then it can probably be found in latex.ltx, in fontmath.ltx, or in one of the other files in the same directory.
There are many more options, which you can see by running texdef -h or by looking at the documentation.
clsfile. For example, here https://ctan.org/tex-archive/macros/latex/contrib/exam you find the class. Of course, if you have it in your machine, you can open it. – Sigur Nov 29 '18 at 19:03\show\thesolution(to the terminal) or\meaning\thesolution(to the document) or (better) read the source file for the exam class – David Carlisle Nov 29 '18 at 19:04\meaningdoes the job. Thank you all – Hafid Boukhoulda Nov 29 '18 at 19:16\texttt{\meaning<macro name>}then, because otherwise backslashes won't be typeset correctly (unless you're usingfontenc). – Circumscribe Nov 29 '18 at 19:19\showand\meaningcan actually also be found in the answers to that question, as well as the fabuloustexdefcommand line tool (which I highly recommend if you plan to do this often). – Circumscribe Nov 29 '18 at 19:26