All i wanted to say, it looks like to me that you need a more advanced debugging, like you need conditional statements in the debug code. You can do that with debugger, but this is an advanced use of debugger. So i recommended to use debug code instead, for which you don't have to know more than you already know. The additional benefit is that the debug code will be a part of your code, that you can switch on and off with conditional inclusion directives.
You seem to ask a wrong question, nothing can work differently when everything is the same. It is about finding out what is different in certain conditions, so you need conditional statements in the debug code, to see the values of the variables when certain conditions are true. Also don't make assumptions about what is wrong, this is a waste of your time, instead find out what really happens.
Debugging can be very interesting, you can use the power of the computer against its own power, to find out what is wrong. It can be done very creatively. But it is just a very different task from what you maybe have been taught that programming is about. You may have been taught that programming is writing a code, which also all people seem to think who know really nothing about programming. Now you may find that often most of the programming is tracing. It is like, no one wonders that one who does electronics, most of the time does measurements with oscilloscope or other measuring equipment. Programmer does debugging, both have the same aim, finding out what really happens.