
Making a low level Linux debugger, part 3: our first program - asrp
https://blog.asrpo.com/making_a_low_level_debugger_part_3
======
pmarreck
I now feel like debuggers are a design smell. I've used them less and less (to
the point of not having to use them at all) as I've coded more test-first and
designed things to be smaller (lower logic depth, etc.) I mean, all a debugger
is, really, is a window into dynamic state, so if you control the, let's just
call it what it is, the "rampant dispersion of state" at all times, you end up
not needing a debugger (and producing fewer bugs) IMHO.

Now I'm sure that kernel-level stuff wasn't designed like this, and probably
won't be for some time (I'm hoping Rust changes that story, but not a low-
level coder), so debuggers may still be necessary- just making a point that it
seems possible to design in such a way that the need for one is drastically
reduced, if not eliminated. Or at least, that's how it seems to me in high-
level-language-land (things may differ at the assembly and C levels).

EDIT: I apologize for OT, probably not the ideal place to start a "are
debuggers really necessary if you design code correctly?" discussion, after
all this is part 3 of a series, my bad

~~~
_wmd
It seems you've mastered some dark art unknown to an entire industry, you
should totally write a book

Meanwhile I'll rely on the smelly old debugger to dig me out of threading
weirdness, memory corruption, resource leakages, other people's bugs, and to
provide a window into a combinatorially massive input-dependent state my
feeble mind simply can't fathom while writing tests for a tiny corner of a
typical system that in aggregate amounts to millions of LOC.

~~~
jjoonathan
Nah, gradparent is not a wizard, just someone who has spent a lot of time in a
single relatively simple environment that is mostly under their control. It's
a beautiful thing when it happens. Most aren't so lucky.

~~~
tropo
He is taking after Linus Torvalds, who resisted adding a kernel debugger for
many years. Linus used console spew, PC speaker beeps, and storing a hash of
file/line into the PC's time/date.

~~~
hackcasual
That's less not needing a debugger by design, more how challenging it is to
debug an operating system.

~~~
tropo
Those last two (speaker and clock) yes, but otherwise no. Linus Torvalds
really doesn't like using a debugger and he'd rather you didn't use one
either. His words:

[https://yarchive.net/comp/linux/debuggers.html](https://yarchive.net/comp/linux/debuggers.html)

~~~
Too
Wow. Lets add some sleep in the compiler also so people will think harder
about their code before compiling?

~~~
tropo
I think that is excessive, but it isn't entirely wrong.

I worked at a place with builds that took over 8 hours. We sure would think
hard about our code.

