Have a debug checklist

Avoid debugging by gut feel or trial and error

make your own checklist

Atul Gawade's The Checklist Manifesto teaches us:

The first step to addressing both of those points is to actually have a checklist. For whatever reason, I've never seen anyone debug according to an explicit checklist, but I think it might be worthwhile. Here's my attempt at making one for myself.

my checklist

If things get really dire, I take a walk and think about something else and then, when I'm back at my desk, ask myself what do I actually know?

other advice

Another benefit of having a checklist is, if you need to enroll the help of a coworker or collaborator, you've got a list of things you've attempted and the results of those attempts. Plus, you've proof that you put effort and consideration into solving the problem on your own and therefore respect their time.

p.s. Julia Evans has a bunch of other debugging advice that you should check out.