I am developing a tool to dump data from variables. I need to dump the variable name, and also the values.
My solution: Store variable name as a string, and print th
People often want programs to self-introspect (or "reflect" in current jargon). But most programming languages offer little (e.g., Java) or none (C) capability to reflect on all the details of a program (variable names, function names, types, expression structures, etc.).
There's a way to do this for all languages: step outside the language, and use a tool that is designed to extract that information from the language. A class of tool that can do this is called a program transformation system.
See this SO answer for a discussion of how to "get variable names" and print values using a program transformation system: Trace changes to variables automatically