TotalView : TotalView User Guide : PART VII Appendices : Appendix A More on Expressions
Appendix A More on Expressions
Calling Functions: Problems and Issues
Unfortunately, calling functions using expressions can cause problems, such as in these scenarios:
*What happens if the function has a side effect? For example, suppose you have entered these two expressions into the Data View: my_var[cntr] and my_var[++cntr]. If cntr equals 3, you’ll see the values of my_var[3] and my_var[4]. However, since cntr now equals 4, the first entry will no longer be correct.
*What happens when the function crashes (after all, you are debugging), doesn’t return, returns the wrong value, or hits a breakpoint?
*What do calling functions do to your debugging interaction if the expression 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 the Data View, TotalView avoids an infinite loop by evaluating items only once. This does mean that the information is accurate only 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, press the Halt button. But if a function alters memory values or starts or stops processes or threads that interfere with your debugging, restart your program. However, if an error occurs while using the Data View, pressing the Stop button pops the stack, leaving your program in the state it was in before you invoked the expression. However, changes made to heap variables will, of course, not be undone.