Comments by "Vitaly L" (@vitalyl1327) on "I Do Not Use A Debugger | Prime Reacts" video.
-
@thebluriam these days most of the systems are very complex and contain multiple parts, some are software, some purely hardware, and there is very little tools available for simulating such systems. Try to find a decent mixed signal simulator that will simultaneously let you debug software running on an MCU and debug how an anaolog circuit will respond to this software behaviour, all in properly simulated time.
So, until we have such simulators, the only real way to debug such systems will be to run them physically, in real time, and then collect as much data as you can while they run - pass all the trace data through available pins if you have any, even blink LEDs and record slow-motion video (I did it a few times, was quite fun), use analog channels to log more data... What is not possible in such scenarios is to pause system at any moment you like and inspect it with a debugger.
And these are systems this world runs on - dozens to hundreds of MCUs in any modern car, MCUs running a lift in your building, MCUs in medical equipment in your hospital, etc.
It means, if we want to sustain the very foundations of our civilisation, we should not train programmers who might eventually end up supporting such systems with an emphasis on interactive debugging. Much better to teach everyone debugging the hard way, and only then tell them that there's such a thing as a debugger that can be handy if your system is not time-sensitive and if all the usual debugging methods failed.
Not the other way around. So, my point is, the hard methods should always be the default, interactive debugging as only a last resort. We'll have better developers this way.
6
-
5
-
5
-
3
-
3
-
2
-
@nitsujism You need to maintain FPS for a human user. It's not going to break the logic of you're running at 0.001FPS instead - the rest of the system will behave the same way, user himself is an understanding part.
For audio - again, it's quite easy to bag the data and to test on historic data, so real-time is not always required. Delay line is trivial to simulate.
As for logging, of course it'll be extremely dumb to use io steams, to use any kind of system calls, etc. All the proper logging frameworks use lock-free communication from real-time threads to non-realtime logger threads, with potentially quite large buffers accumulating the logged data. I'm in no way advocating for just sprinkling printfs here and there, it'd be barbaric.
As for segfaults, quite often simply running a debug build can make your segfault go away (or to mainfest somewhere else). Valgrind, or address sanitiser, or just a more elaborate logging would be far more precise in locating where exactly your data got corrupted (which can be very far away from where the segfault happened). Debuggers only delay finding the root cause of the problem by diverting your attention to unrelated code paths.
2
-
@daniilpintjuk4473 That's not always possible. Either your code is heavily concurrent, or you're wasting the hardware capacity. Having said that, yes, you must always do your best to avoid concurrency where it's not needed. E.g., a single FSM with predictable timing is better than an interrupt-driven system, as you can always reason about the worst case timing and make sure it meets the hard real-time requirements. No way to do it with concurrency present. Yet, there's a form of concurrency that's even harder to debug and that's pretty much unavoidable in any modern system - multiple communicating devices, e.g., a number of MCUs communicating, each can be perfectly single-threaded and sequential, but their interaction still only makes sense in real-time and cannot be paused.
2
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
@xybersurfer I ask them how they'll debug a hypothetical problem (or a real one, if I have time to give them a real environment set up with some deliberately broken code). If they reach for a debugger as a first tool, I'm getting suspicious immediately. A few more questions usually prove I'm right, and they are cavalier, cowboy coders who avoid any systematic, slow, steady approaches.
If they're trying to add logging (or, if it's already there, to use it properly), if they're reaching for an address sanitiser, for Valgrind, or try to instrument the code (even with simple preprocessor macros, if setting up Clang toolchain is an overkill) - I'm pleased, this person clearly knows how to systematically narrow down problems and how to find optimal solutions.
Yes, debuggers can be useful if you need to inspect some black box code (or otherwise code that's impractical to instrument and modify in any way), which is often the case with third party dependencies. But it's again just a case against third party dependencies in general. Having to depend on an OS, a compiler and a system library is already too much (and yes, there were cases where it was better to avoid even these dependencies, running on a bare metal instead).
1
-
1
-
1
-
1
-
1
-
@nitsujism games? real-time? Lol. There's nothing real-time there. Nothing bad will happen if you skip a frame or two. Nothing will crash if you pause rendering altogether and inspect. It's a soft real-time at most, nothing interesting. Audio processing - yes, can be hard real-time, but essentially it's just a stream in, stream out, no complex feedback, so you can just bag all the input and process it at any pace you like.
Now, try a proper hard real-time system. Like, automotive, or industrial control, where there's a physical component that won't wait for your code to catch up.
And, no, I have no pity for people who fix segfaults with debuggers. They're beyond salvation. They cannot even use memory sanitisers properly.
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
If you're working with a low-level language and rely on debugger to catch your mistakes, I don't want you anywhere near any mission-critical code. Not in automotive, not in medical robotics, not in aerospace, not in industrial automation. Your way is guaranteed to introduce a lot more bugs than it's possible to tolerate.
Firstly, debuggers do not show you where the problem is. They let you see where the problem manifested. Especially if it's a memory-related problem, you can see its effects far away from the real cause. Then you'll find some hackish workaround and trot away happily, thinking you fixed the bug.
The real developers never rely on debuggers. We'd rather stick to MISRA-C harsh rules, use all possible static analysis tools we can find, build extensive testing infrastructure, build zero-overhead logging wherever it's possible. Debuggers will never replace any of this, and will never be of any real added value when you should do all the above anyway.
1
-
1
-
1