Hacker News new | ask | show | jobs
by wojciii 13 days ago
If you have no logging and no debugger .. you should run away. Fuck debugging something complex by blinking a led. This is a waste of your time.

I'm sure you can make Claude help you with this .. but still..logs are important. So is a good debugger and software support for it. It saves so much time in the end.

5 comments

Having done basically that a couple of weeks ago (with a scope to verify timing signals), its actually pretty common, specially when you are implementing protocols with hard timing requirements.

And in my case, I was actually troubleshooting the code that makes leds blink, with a bit-banged implementation on a deterministic processor.

>If you have no logging and no debugger .. you should run away.

That's a wrong mindset in embedded. In this field, your debugging toolbox should not stop at debugger(gdb) or logging(UART). It must include at least: LA/DMM/PSU/O-Scope.

Or its the right mindset, as no every one wants to do the same shit with bad tooling.

We are not the same, obviously.

Have you never experienced a bug that goes away from adding/removing a logging statement?

I recently restructure a logging module in a client’s project, and the resulting performance gains exposed all sort of race conditions.

Sometime all you get is an LED.

One time I had a register write that worked in release mode, but didn’t in debug. Ended up being an AVR timing requirement when configuring the oscillator or flash that expected the second write to happen at most N cycles after the first and debug mode just happened to add enough operations between the two lines of C to miss the window.
I had a bug triggered by adding a comment. :-(
Wow, how did that work?
Comments shouldn't affect code which executes at all, right?

So... please tell us more!

If you put a trailing backslash in a // comment you can comment out the next line inadvertently.

If you put a // comment in a multi-line macro you can comment out the rest of the macro, not just that line.

There are probably lots of other ways but I would guess it hinges on accidentally using a comment to remove or introduce code that is not apparent.

> This is a waste of your time.

This is the reality of highly constrained embedded systems. If you don't like that, I'd suggest moving to web dev where you have state of the art debugging.

That's kind of like saying "don't be a farmer--you have to go outside".