Watch windows are important, they show us our data in various forms and generally enable us to debug effectively, sometimes however they need help.

Setup a simple windows console project and use the following code:

struct s_test_level1
 
  {
 
      int m_count;
 
      char* m_string;
 
      float m_value;
 
  
 
      void print(void)
 
      {
 
          if (m_string)
 
          {
 
              printf("%s %d %f\n",m_string, m_count, m_value);
 
          }
 
      }
 
  };
 
  
 
  static const int k_num_elements= 32;
 
  struct s_test_level2
 
  {
 
      s_test_level1 m_elements[k_num_elements];
 
  };
 
  
 
  int _tmain(int argc, _TCHAR* argv[])
 
  {
 
      s_test_level2 test;
 
  
 
      memset(&test,0,sizeof(test));
 
  
 
      test.m_elements[0].m_string= "my foo";
 
      test.m_elements[0].m_count= strlen(test.m_elements[0].m_string);
 
      test.m_elements[0].m_value=3.14159265358f; // everyone loves Pi
 
  
 
      test.m_elements[0].print();
 
  
 
      return 0; // <<= breakpoint here
 
  }
 
  

now run the program putting a breakpoint on indicated line. Open up a watch window and drop test into it opening up the m_elements array, you should see something like

This is a really simple but even now we see some details we don’t always need… lets reformat it.

open up the file

VS2010 PC: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\autoexp.dat
VS2008 PC: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\autoexp.dat
Xbox360: C:\Program Files (x86)\Microsoft Xbox 360 SDK\bin\win32\autoexp.dat for 360

search for “[AutoExpand]” and add the line

s_test_level1=<m_count,d>, <m_string,s>, <m_value,f>f

save that file and re run the test program…. you should now see

a much easier to read version of the same data.

All the original information is still available should you need it but this new format is much easier to quickly consume.

This form of watch window help is somewhat limited however, you can only interpret existing data, remove superfluous detail, do some VERY rudimentary math and generally make things cleaner and easier to consume; see the next post for MORE.

All of the help required to use autoexp.dat is within the file itself. Note that the “[Visualizer]” section is currently not available for xbox 360 targets but is VERY powerful for other targets.

enjoy and feel free to ask questions.