Calling Functions: Problems and Issues
Unfortunately, calling functions in the expression system can cause problems. Some of these problems are:
*What happens if the function has a side effect For example, suppose you have entered my_var[cntr] in one row in an Expression List Window, followed by my_var[++cntr] in another. If cntr equals 3, you’ll be seeing the values of my_var[3] and my_var[4]. However, since cntr now equals 4, the first entry is no longer correct.
*What happens when the function crashes (after all you are trying to debug problems), doesn’t return, returns the wrong value, or hits a breakpoint?
*What does calling functions do to your debugging interaction if evaluation takes an excessive amount of time?
*What happens if a function creates processes and threads? Or worse, kills them?
In general, there are some protections in the code. For example, if you’re displaying items in an Expression List Window, TotalView avoids being in an infinite loop by only evaluating items once. This does mean that the information is only accurate at the time at which TotalView made the evaluation.
In most other cases, you’re basically on your own. If there’s a problem, you’ll get an error message. If something takes too long, you can press the Halt button. But if a function alters memory values or starts or stops processes or threads and you can’t live with it, you’ll need to restart your program. However, if an error occurs while using the Evaluate Window, pressing the Stop button pops the stack, leaving your program in the state it was in before you used the Evaluate command. However, changes made to heap variables will, of course, not be undone.