Visual Studio debugger tips & tricks (for C/C++ projects)

前端 未结 7 1132
梦谈多话
梦谈多话 2021-02-02 16:22

I\'m interested in tips and tricks regarding debugging a C/C++ project in Visual Studio\'s debugger. I recently found out that if you have a pointer to a certain data type, let\

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-02 16:43

    • Some debugging / watch related tips:

      Use the following in the Watch window to find out what GetLastError() would return:

      @ERR,hr

    • If you use Visual Studio 2003 or earlier, use this watch expression to find out the length of your std::vector v:

      v._Mylast-v._Myfirst

      You can also list the e.g. first 5 entries with this expression:

      v._Myfirst,5

      This doesn't work when using STLport, and the method obsoleted in VS >= 2005 with the new expression visualizers.

    • If you want to see the return value of a function, look at the eax register (just enter eax in the watch window). You can even change the returned value. If it's a pointer to a string or array, you can also enter eax in the Memory window to see the underlying string.

提交回复
热议问题