As I’m becoming a better programmer (my first year as a programmer) I’m also getting better at debugging, and it is one of my favorite things to do. Yes, I said it, I love debugging. But then again I love pretty much everything about programming. Anyway. One technique I’ve recently learned to appreciate is differential debugging.
Differential debugging is when you compare a working system or component to a non-working one, either an earlier version or a very similar system or component.
The two systems (I’ll just refer to them as systems, but this includes features and components) can be compared in a few different ways. You can for example, and this is what I have been doing since I haven’t had any log files to compare, step through the code and take notice of differences. If you use intellitrace (which I do, you have an excellent tool of recording the whole process and can even share it with other developers if they need to replicate the debugging).
When comparing a system with a previous non-defect version (defect or bug?) use the last working one, and if you don’t quite know when it was, skip a few versions back and work your way both forwards and backwards. If current version is 90 start for example at 50 (depending on approx. when you believe it was) and 89 and skip a set amount of versions at the time until you find the working one. You might even settle for a working version that isn’t the closest one, it depends on your problem.
The ideal situation is to have log files, as this allows you to use external tools to compare the two systems. The simplest way to compare could be something as easy as just using the compare-object command in PowerShell, but usually you would create scripts that lets you focus on things such as timestamps, error codes, thread id, assemblies loaded, paths used and so on. If you use Git you can use the git diff command to compare log files, or code files if you already kind of know where the problem lies. Code files however doesn’t provide error information, but at some point you will need to identify the changes made and git diff let’s you do that- and you can take a look at all files in a branch or tag or folder or… you get the picture. Be creative about how you compare, and use the tools you have and know.
And for what I know there might even be some other tools than shells and command lines that you can use as well. Let me know, I’m just starting to learn this 🙂
Let’s consider this blog post a work in progress, this is fairly new to me, so more will be added later 🙂