TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Debugging: When depth-first vs. breadth-first?

1 pointsby jesover 2 years ago
Hello -<p>[ I&#x27;m interested in general advice here, yet wish to give an example to set it up. ]<p>You have a complex software package that runs on Linux, macOS and Windows. Let&#x27;s say it also interfaces with a complex piece of hardware via PCIe.<p>When you test the software on Linux, you get output about, say, an I&#x2F;O page fault. There are some details, but you&#x27;re not an experienced kernel hacker, so progress is slow if you try to dig in on it.<p>Some of your colleagues suggest that you stay focused on debugging the problem on Linux. Others suggest running the same test case on macOS and Windows, to see what happens, and if that sheds any light on the problem.<p>I&#x27;m interested in your thoughts on which approach you would take, with whatever qualifiers you wish to add, and why.<p>The more general question here is when you have a bug roughly like the one described above, is your preference to stay with one particular set-up and dig for all the details you can (call this &quot;depth-first&quot; debugging, maybe) or do you prefer to go breadth-first (when you can) to try to narrow things down?

4 comments

iforgotpasswordover 2 years ago
While I do have some experience with kernel code, if there isn&#x27;t something jumping right at me after some hour of staring at code and maybe inserting some debug statements on a hunch, I might try the other OSes just as a sort of sanity check to see if the issue even exists at all, or if everything works flawlessly. Or maybe it will break in another way and I&#x27;ll suddenly have a lightbulb moment that helps me identifying the problem better. Could it be a hardware issue? Could it be that just my device is faulty? Just some revisions of it?<p>Generally I switch between approaches as I see fit, on a hunch you could say. There&#x27;s no point in banging your head against a wall in some dead end for two hours.
jstx1over 2 years ago
&gt; Some of your colleagues suggest that you stay focused on debugging the problem on Linux. Others suggest running the same test case on macOS and Windows, to see what happens, and if that sheds any light on the problem.<p>The latter option seems clearly better to me but I don&#x27;t know if that makes for general advice. It&#x27;s also easy to pick that option when the alternative isn&#x27;t specified at all (we don&#x27;t know what &quot;keep debugging on Linux&quot; means).
AnimalMuppetover 2 years ago
It depends.<p>Do I have a red-hot &quot;it&#x27;s probably this&quot; idea that I have some confidence in? If so, I probably chase that one in depth first, at least to the point of being able to confirm or disprove.<p>In the exact scenario you gave, I&#x27;d probably do breadth-first, because I don&#x27;t know if it&#x27;s OS-specific or not, and the possible causes are different depending on whether it&#x27;s Linux-only or not.
gjvcover 2 years ago
this nomenclature does not make things any clearer -- in fact, quite the opposite.