Category Archives: Debugging

Debugging Reference Count – Part 1

I recently dealt with a large memory leak that turned out to be a delicate reference count issue. It is a common debugging scenario, and I’ll be sharing here some suggestions about it. First I had to isolate the leaking … Continue reading

Posted in Debugging, VC++ | Leave a comment

The Case of the ‘X’ That Didn’t Kill the App

One of our MFC apps recently had a weird bug: occasionally debug builds would result in a binary where the ‘X’ corner button killed the app window but not the app – it would just keep idle indefinitely until killed … Continue reading

Posted in Debugging, VC++ | 1 Comment

Child Breakpoints in Visual Studio

You often see in the breakpoints window that certain breakpoints are expandable: These are called child breakpoints, and are a strong contender to the title of most poorly documented feature of VS.  According to MSDN, child breakpoints occur – …when … Continue reading

Posted in Debugging, Visual Studio | 1 Comment

‘Frames below may be incorrect’, or: Stack Walking Requires Symbols

Here’s the symptom – you stop and inspect a stack: Note the message at the second line: Frames below may be incorrect and/or missing. No symbols loaded for XXXXX.dll. Chances are you read it once years ago and ignored it … Continue reading

Posted in Debugging, Visual Studio | 5 Comments

Debugging Memory Leaks, part 3.5: Hacks with Hooks

Alan rightfully comments that setting a conditional breakpoint at _heap_alloc_dbg  significantly slows down the application. If run time is an issue for you even in debug builds and re-compilation is not an issue, here’s an alternative trick: use an allocation … Continue reading

Posted in Debugging, VC++ | 1 Comment

Debugging Memory Leaks, Part 3: Breaking on Allocations of Given Size

When battling memory leaks, you often start from the output of _CrtMemDumpAllObjectsSince or _CrtDumpMemoryLeaks (called for you if you use MFC) – something similar to: C:\myfile.cpp(20): {130} normal block at 0x00780E80, 68 bytes long. Data: < > CD CD CD … Continue reading

Posted in Debugging, VC++ | 3 Comments

Checking Memory Corruption with _CrtCheckMemory – From the Debugger

Edit: In VS2015+ versions this trick is still useful but is a bit different.

Posted in Debugging, VC++, Visual Studio | 2 Comments

/d1reportAllClassLayout – Dumping Object Memory Layout

Roman just posted a nice investigation he did, mostly using the g++ switch -fdump-class-hierarchy – which dumps to stdout a graphical representation of generated classes layout. VC++ has no official similar switch, but deep inside  its undocumented pile of goodies … Continue reading

Posted in Debugging, VC++ | 3 Comments

Setting Breakpoints on All Class Methods

In a recent video John Robbins (probably the world’s leading debugging expert) made a public request of his audience: write a VS addin that enables setting function breakpoints by partial name matches. That is, let the user type C*::M* in … Continue reading

Posted in Debugging, VC++, Visual Studio | 2 Comments

Visualizing MFC Containers in autoexp.dat

MFC containers are more or less officially deprecated in favor of STL. Even so, when navigating in legacy code the need often arises to watch CArrays, CLists, CMaps and the like. autoexp.dat provides only STL visualizers out of the box, … Continue reading

Posted in Codeproject, Debugging, Visual Studio | 7 Comments