5 ms·
Print debugging is a technique that will never go out of style. It works on any system, is used by programmers of any level of experience, is very quick to use
by jb1991 4y ago
Print debugging is a technique that will never go out of style. It works on any system, is used by programmers of any level of experience, is very quick to use and requires no tooling to understand. And sometimes, even if you do have other great tools at your disposal, it’s still the easiest way to track down a problem.
- taeric 4y agoI view it as "tracer bullets." I know it will make noise, but I'm planning to look at the pattern of the noise to see what I can reason out of it. Is it a complete answer? Of course not. Neither is trying to spin a wheel that you are truing. Produces a ton of output that is roughly in an expected pattern, and can be acted on.
- worik 4y agoWell yes, but I must quibble... > Print debugging.... It works on any system No it does not. It requires a console, and not all systems have a console.
- gpderetta 4y agoIt requires a way to get bytes out of the system. You can connect an external console to that.
- jb1991 4y agoWell, you're right, of course. Another obvious one is that print debugging doesn't work for your GPU kernels.
- pjmlp 4y agoWhich is why a GPU debugger with frame tracing is so much better option. By the way, there are actually ways to expose a print function on shader code, provided there is driver support. https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/master/docs/debug_printf.md https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob...
- evrimoztamur 4y agoWell, not every system has a framebuffer, but here's a Carmack tweet that comes to mind: "gl_FragColor.x = 1.0; is the printf of graphics debugging. Stone knives and bearskins." — https://mobile.twitter.com/id_aa_carmack/status/568861553245728768 https://mobile.twitter.com/id_aa_carmack/status/568861553245...
- emj 4y agoHe also seems to like a timing/GPU/CPU debugger called PIX from MS, I'm impressed. I wish they had started with the hands on, but the presenters in this video[0] all show why print debug will never be enough. Getting back to the OP, for me even IDE integrated debugging is worse than print debugs. You need to so much data to make it useful for me, which makes things like PIX, APM and other application tracers the thing I go for during debug. [0] https://www.youtube.com/watch?v=UH-o5cG_QWo https://www.youtube.com/watch?v=UH-o5cG_QWo
- evrimoztamur 4y agoAs a side note: While using wgpu-rs to do Rust game development, I grew very fond of RenderDoc (https://renderdoc.org/ https://renderdoc.org/). It has great Vulkan compatibility and it helped me greatly when building an object picking buffer by visualising everything from call trees to resource contents and metadata. I believe it should come in handy for any GPU-based project, not just 3D/2D graphics.
- Ferret7446 4y agoAny system that is capable of emitting any data, can emit bytes from print debugging. Could be log file, socket, or even pulses along a GPIO pin. If the system can't emit any data, well, you're kind of stuck anyway.
- bongobingo1 4y ago> If the system can't emit any data, well, you're kind of stuck anyway. It's also by all recognition, functioning perfectly :)
- scruple 4y agoHaving worked in embedded, debugging through an Oscilloscope is a cherished memory that I sometimes talk to junior colleagues about. Knowing these things are possible can sometimes help people find more novel ways to think about debugging their applications.
- worik 4y agoPulses on a GPIO pin are not print statements. A huge proportion of computing devices have no method of producing any out put, other than to some form of actuator, at all. "print statements" are useless in this class of device. Stretching the definition of "print statement" to recording pulses from a pin is, well, a stretch! Poor young programmers. If the only tool you have is a hemmer, every problem is a thumb.
- raverbashing 4y agoUnless you're debugging something so simple that it can only flash a led, you can have a serial console onto it You can print debug on an Arduino for example So, yes, it works on pretty much any system.
- adelrune 4y agoEven then, you could write a print function that writes morse code pattern to the led :p
- worik 4y ago> Even then, you could write a print function that writes morse code pattern to the led :p And you then have a different system. My point is consoles are not ubiquitous in computing. Computer systems that lack them are very common
- the__alchemist 4y agoDo you have an example of one that doesn't have one?
- worik 4y agoThis is in the realm of ignorant questions. It could well be that the majority of computer devices have none. E.g. the micro controller in my washing machine
- the__alchemist 4y agoWhy is it an ignorant question? The nicer ones let you use JTAG etc connections, and debug to console using ITM or RTT. (STM, nRF etc) Others allow debugging via serial.
- worik 4y ago> Why is it an ignorant question? The nicer ones let you use JTAG etc connections, and debug to console using ITM or RTT. (STM, nRF etc) Others allow debugging via serial. Because all those systems, even the very nicest, all over the palnet, very really have "JTAG etc connections," Those are things you attached to the system. You attach them in a complex error prone process, at the end of it you have a different system. A lot of (most?) computers do not have consoles. It is a common error amongst developers (who do not work in embedded systems) to assume there is a screen supporting text of some sort. It is an error
- the__alchemist 4y agoYou connect the debug probe to your MCU (pogo pins or w/e is convenient for the form factor), connect it to a PC over USB, and print to a terminal window in Windows, Linux etc. Or a serial-USB bridge if it doesn't support debug probes. If the MCU is so basic it doesn't support UART, bit-bang it with GPIO. Too easy!
- worik 4y ago
- ilyt 4y agoYou'd be hard pressed to find any. You can even get console over JTAG/SWD and near every microcontroller has it. Only when you get into realm of few cents per microcontroller then you don't have it
- jjav 4y ago> No it does not. It requires a console, and not all systems have a console. It does not. You just send the log output somewhere (often a different system). If you have a deployment with no logging infrastructure (either local for smaller setups or distributed for large scale), you have a major problem beyond just debugging visibility.
- worik 4y ago> You just send the log output somewhere How?
- defrost 4y agoVia network socket, serial port, parallel port, however the system in question communicates with the world. If it's an actual standalone deaf, dumb, and blind black box with zero world interaction then you should, at least, have a hardware probe and step debugging capabilities and you can always flash a sign of some kind on some bus or another.
- musicale 4y agoLogging - for debugging or for other purposes - is a very useful tool.
- whartung 4y agoAs a general rule I prefer print debugging. I’ll step in with a breakpoint when I have to but odds are I’ve gone through a round of prints first. I do not enjoy stepping through all of the context setting up the system to fail. I’ve not tried a debugger that can “back up”, that may well be a different experience. But I loathe stepping through code, walking on eggs, overstepping, “oops, thar she blows, start over”. Like Bugs Bunny on the piana. Rather just toss in some prints, let fly, sift through the wreckage. My builds are fast enough to make the turn around acceptable.