What’s in a PDB file? Use the Debug Interface Access SDK

It’s easy to use C# code and MSDia140.dll from the Debug Interface Access SDK to examine what’s inside a PDB. A PDB is Program Database which is generated when an executable such as an EXE or DLL is built. It includes a lot of information about the file that is very useful for a debugger….

1

Examining a crash dump

A crash dump is very helpful for diagnosing a problem with software. It can contain enough information to recreate a debug session, almost as if you’re debugging the problem live on the repro machine. Last time I showed some code to create a crash dump with various settings. You can choose to include many different…

1

Wireless HeadPhone Adventures

I wanted to get wireless headphones to listen to music. At the office I have 3 desktops, with a range of power. The most powerful has 3 monitors connected. The next has 1, while a 3rd doesn’t have any (I Remote Desktop to it). I run various flavors of Windows Server 2012 and host many…

2

Debugger features help to find memory leaks

You can use the debugger $CALLSTACK and TracePoints to find memory leaks. Memory leaks are very tedious to find. Often they don’t affect an application at all except a gradual performance slowdown on a customer machine. Leaks can be found in old code bases that have multiple authors over years, with different programming styles and…

2

Use status events to log and analyze an application

Applications can get quite complex, with multiple components, assemblies, subsystems, etc. Understanding this complexity can be daunting. An old but still very effective way of analyzing code is to modify the code to output a string whenever that section of code gets executed. Remember the old Printf() from old C/C++ programs? Perhaps that code could…

0

Examine the layout of managed strings in memory

Suppose you wrote some C# code like this: var str1 = "ThisIsAString"; var str2 = "ThisIsAnotherString"; As you’d expect, each string is stored in the resulting built binary and also in memory when the binary is loaded, resulting in 2 separate strings. Now suppose you wrote this code instead: var str1 = "ThisIsAString"; var str2…

0

Advanced debugging: change your program execution without Edit and Continue

Last time (Improve your managed debugging skills: examining registers and memory) we examined some debugging techniques to understand the behavior of managed code.   It might take a long time or many manual steps to reproduce a particular software behavior in an application. Changing the instructions that are executed by the target program while it’s…

1

Improve your managed debugging skills: examining registers and memory

  I was helping a colleague and we were deep in the middle of a debug session, single stepping some code and we wanted to see a value in the debugger. The debugger showed either nothing, because the intermediate value has been optimized out, or a message like “cannot display value, possibly because it has…

1

Play around with .Net Dictionaries and STL maps

Last time (Adventures in interop code: explore string interop memory) we investigated sharing memory between native and managed code, or between processes.   Data structures are very useful: things like arrays, structures, lists, dictionaries, stacks, queues, etc. are used throughout programming.   In the early days of programming, if you wanted to use any of…

0

Adventures in interop code: explore string interop memory

  In Create an ActiveX control using ATL that you can use from Fox, Excel, VB6, VB.Net, I showed how to create a control (with which the user can interact) which can be hosted in many places.   Today’s sample creates a class in C++ that doesn’t necessarily have UI, and thus isn’t visually hosted,…

1