Write Programs for Debugging

You will find it easier to debug your programs if you follow these guidelines:

  1. Do not do any hand-tuning for performance until you have all the logic in place and fully debugged.
  2. Use meaningful names for loop counter variables and other temporary variables. This helps you quickly relate the variable names, when they appear in Stack frame or other Variables views, to the code to which they apply.
  3. Use lvalues as array indices, rather than expressions that have a side effect, if you want to be able to determine what the value of an array index is at a given point. For example, statements such as a[i++]=b[j++]; make it more difficult for you to observe the effect of the statement on the affected variables and arrays. Instead, try using a compound statement:
    a[i]=b[j];
    i++;
    j++;
  4. Break complex function calls into several simpler ones, as long as breaking up the call does not cause one function call's side effects to change the result of another function call. This makes it easier to step into or over the individual functions inolved, without having to switch to or open a disassembly view.



Debug Optimized Code