Binary serarch for two step bug

I talked about debugging as binary search in
https://droid7c2.wordpress.com/2009/02/10/debugging-as-binary-searchdebugging-as-binary-search/

What if the problem happens in two steps. For example, if your program goes south by performing action1 first, then action2?

The OK-NG chart would be like this.

    ----------OK------------------------------------- NG---------
                |<--action1-->|                |<--action2-->|

Now you have to divide this into two. One for looking into action1.

    -----------------------------------------OK------ NG---------
                |<--action1-->|                |<--action2-->|

We know that “OK” here is not actually OK because something is already caused by performing action1. But for the sake of binary search, we call it OK. Then you divide between OK and NG until you find what was really NG in action 2.

And the other for action2. This time you do not touch action 2, and look into action 1. We know that things were OK before action 1, and NG after action 1. You reduce the amount of code in action 1, and see when the symptom seen in action 2 happens or not.

    ----------OK---------------NG-------------------- NG---------
                |<--action1-->|                |<--action2-->|

You can start digging in either one of those two. However, do not forget that you have two OK-NG chart now. Otherwise, you might forget the other one and waste time.

Advertisements