Vector Deleting Destructor

Today one guy in my team asked a question regarding the behavior of delete[] operator in C++ – how does the program know it needs to call CBar::~CBar instead of CFoo::~CFoo? Note that the vector deleting destructor is a feature in Microsoft C++ Compiler, not required by the C++ standard. #define _CRTDBG_MAP_ALLOC #include <malloc.h> #include <crtdbg.h> class CFoo { public:   virtual ~CFoo() = 0; }; class CBar…

0

Postmortem Debugging – Better Late Than Never

If there is a consistent repro, I would definitely prefer Early Debugging. However in the real life postmortem debugging seems to be unavoidable.  There are three concepts I wish to clarify before digging into the details: AeDebug is a set of registry keys which specify the behavior when unhandled exception happened in an user mode application. \\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug \\HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows…

0

CRT Startup

In my previous blog Early Debugging, we’ve demonstrated how early can you get using a user mode debugger. Normally we don’t want to be such early, there are some other places we would want to start with: OEP (Original Entry Point) of the EXE module. WinDBG has a predefined Pseudo-Register called $exentry which makes it a lot…

0

What is Autos Window?

The developers in Microsoft have done a great job by bringing a great number of nice features, however, some of these features are poorly documented or even not documented at all. Autos Window in the Visual Studio Debugger is one of the best example of the gaps between implementation and documentation. I’m sure you have seen this window…

0

Did you know…

Have you ever seen the following window before? It was once very popular in the good old days, but has been abandoned in recent years (another good example being the pixel fonts). People just keep getting busier in the blooming new era. Windows 7 Shift + Right Click on a file icon would give you additional…

0

Debugging Tips for Multi-Threaded Application

Multi-threaded applications are error-prone and hard to debug, so it’s worth a dedicated topic. I will try to maintain a list of tips for debugging multi-threaded application using Visual Studio and WinDBG. Below is a trivial multi-threaded application which will be used as an example: #define WIN32_LEAN_AND_MEAN #include <Windows.h> DWORD WINAPI ThreadProc(LPVOID lpParameter) {   return 0; // add breakpoint here} int __cdecl main() {   HANDLE hThread = CreateThread(NULL, 4096, ThreadProc, NULL, 0, NULL);   if(hThread)   {…

0

Visual Studio Debugger or WinDBG?

Microsoft has provided a number of debuggers. Visual Studio Debugger would be the most widely known one, while there is a less known tool set called Debugging Tools for Windows which is available for free. Even inside Microsoft, there were questions around why having so many debuggers, and which one to use. A quick answer is,…

0