Run the application under an interpreter or high-level debugger. Generate a snapshot of a set of variable values each time a statement in a specified procedure is executed.
Determine the values of a set of variables.
Were any of these variables modified since the last time the dump was made?
Do all of these variables have reasonable values?
You can generate a lot of data if the statement is executed frequently.
If the problem is caused by stack or heap corruption, running under an interpreter or high-level debugger may cause the symptom to change or disappear. This happens because the values on the stack and heap will be different.
Dump only selected elements of arrays, such as the first and last element of each row or column, or the diagonal elements.
Call a function that dumps a specific number of words starting at a base address. Call it with the address of the last local variable declared in the function. Print each word in several formats (character, numeric).
For languages that keep most of their data in global variables, dump the entire global area.
Use the basic tactic when one of the following conditions is true:
No high-level debugger is available.
It isn’t feasible to run the application interactively.
C++: Dump the data members of the object currently referenced by this, and recursively dump all data members of objects pointed to or referenced by that object.
Java: Dump the data members of the object currently referenced by this, and recursively dump all data members of objects referenced by that object. Use reflection to implement this facility.
C: There is no way to get the names or addresses of all global variables without explicitly listing them.
Fortran: Dump the contents of blank COMMON, or of all COMMON blocks.