7 ms·
If you can't debug with just print statements, you're doing it wrong :)
by amelius 10y ago
If you can't debug with just print statements, you're doing it wrong :)
- AceJohnny2 10y agoIt's funny but, in the embedded world, it's scary how archaic things are. For example, just a few hours ago I convinced a colleague to try using the debugger. Our hardware has had a functional JTAG-based debugging toolchain for years, but people still haven't picked up on it. I'm the new guy who spearheaded it in the team -_-
- david-given 10y agoBack when I was working on embedded, I typically wouldn't even bother looking at the debugger. They never helped. The general workflow, when presented with a new system, was something like: (a) Board would arrive. Admire it for a bit. (b) Look suspiciously at the supplied CD. Gingerly insert it into computer. Oh, look, a Windows install.exe. Insert it into the Windows computer next to mine (with its screen and keyboard slaved to mine with x2vnc, which is great). Install. (c) Load the terrifying, buggy, proprietary IDE. Close it again. (This was in the pre-Eclipse days. You really had no idea what you were going to get here.) (d) Search through the vast pile of useless guff which it had installed for the embedded copy of gcc. Find it. Also find the BSP libraries, and link scripts. (e) Realise it's a terrifying, buggy, proprietary-patched version of gcc where the source package doesn't match the binary. (f) Attempt to find whatever terrifying, buggy, proprietary tool actually downloads images onto the board. (g) From the command line, write a tiny makefile which uses everything found in (c) plus (f) plus the terrifyingly misspelt quote documentation unquote (supplied in a PDF on the CD) and attempt to produce and run a 'Hello world' image. Download and run it. (h) Assuming (g) worked, bolt it on to our existing gcc-and-make based built automation and actually start work. Any debugger was usually so tightly integrated to the IDE, which was always set up to assume a particular project layout which didn't match our source layout, that it was usually more trouble than it was worth; particular as our product had a lot of JIT stuff in it, which a source debugger couldn't help with much anyway. The very best boards had an on-board monitor which gave you a Commodore PET-style assembler debugger. One even had hardware watch and breakpoints! The ability to single step through stuff, via a serial terminal, with no prior setup required, was amazing. It was sufficiently robust that even when the board really crashed badly it would drop into the monitor and you could examine what had gone wrong. I have a particular hatred for the debuggers which required a slave task running on the board itself. (a) sucks to be you if you were running a different OS; (b) oddly enough, if your app crashed and scribbled all over memory, it tended to stop working... </rant> Edit: Oh, I forgot to say --- this was mostly before JTAG was ubiquitous, so debugging options were either a terrible, proprietary serial monitor or a terrifyingly expensive ICE unit. JTAG did come along later, and it was miraculous; you could even single-step through interrupt handlers with it! But it wasn't standardised and each board typically had its own interface, which wasn't supplied, plus its own software. Then not long after I got out of the game. ...I'm having flashbacks now. Downloading Java images onto an M-Core development board at 100-200 bytes per second with a 1 in 10 chance of a failed download for every megabyte. You think I'm exaggerating. I'm not. I still have the CPU from that board somewhere; I ripped it off once we were finished to make sure that nobody would ever have to use it again.
- AceJohnny2 10y agoThere there... This is why I have a stash of whiskey at my desk ;) (though honestly I haven't touched it in a while. Impairs debugging, really)
- jpm_sd 10y agoThat's funny, at my old job we actually called whiskey "debugging fluid"
- planteen 10y agoFortunately, most new design starts in the embedded world these days are ARM SoCs. Most (not all) ARM chips use a standard 20 pin JTAG connector. The Segger J-Link supports a large number of parts for debugging. The BSPs are still as scary as they ever were, though.
- swah 10y agoIn the embedded world the quote from Mickens "I HAVE NO TOOLS BECAUSE I'VE DESTROYED MY TOOLS WITH MY TOOLS" happens much more frequently :)
- AceJohnny2 10y agoI used that quote just yesterday >_>
- toomanybeersies 10y agoFor my 200 and 300 level embedded software papers, I was essentially stuck with using flashing leds and printf to debug code. For my 400 level embedded systems design paper (which was actually a hardware design paper, we weren't graded on the code), we built boards that we could program and debug with JTAG. I was stuck on a pain point for hours until one of the tutors showed me how to use GDB with the boards via JTAG. It took me literally 5 minutes to fix the problem. Being able to step through the code line by line allowed me to see exactly where it was breaking, and why it was breaking. If I'm ever doing embedded development again (unlikely as I'm now employed as a web developer), I don't think I'll be able to function at all without a proper debugging environment.
- AceJohnny2 10y ago> I was essentially stuck with using flashing leds and printf to debug code. Should be enough for anyone. Some people used flashing LEDs to dump an entire firmware! ;) http://hackaday.com/2008/05/27/porting-chdk-to-new-cameras/ http://hackaday.com/2008/05/27/porting-chdk-to-new-cameras/
- the8472 10y agoyou can do that too, just use hot code replace to put print statements into the running code. you don't even have to suspend threads for that
- ktRolster 10y ago"My primary debugging tool is Console.Writeline(). To be honest, I think that's true of a lot of programmers." --Anders Hejlsberg If Anders Hejlsberg does it, there's no shame in it.
- planteen 10y agoWith prints and a backtrace function, you can make up for a most debugger usage. But for tracking down heap corruption, a debugger with memory breakpoints is the bees knees.
- RX14 10y agoThere's no shame in it but that doesn't mean that it's the best or most efficient way of doing things. I've found that stepping through code in a debugger at a human pace, and getting to really understand what's happening when a bug occurs is invaluable.
- MichaelBurge 10y agoOne problem with this, is that your code often ends up in a state where only step-through debugging works anymore. It might become too complex to reason about just looking at the code, from the types alone, or by printing data. Same problem happens with other methods too: If you develop solely with unit and integration tests, it might actually be quite difficult to get a step-through debugger set up to debug your application. I worked at a company where I was the only one who used a step-through debugger, and some uses of compile-time metaprogramming would frequently break the debugger. And if you use multiple techniques as appropriate(unit tests, printf or equivalent, step-through debugging), it's generally easy to use any of them as appropriate.
- greglindahl 10y agoLike every other tool in programming, different people have different preferences and experiences. Symbolic debuggers have always ended up being a waste of my time, but I don't try to extrapolate from there to everyone else's preferences.
- reddit_clone 10y ago
- oldmanjay 10y agoYou smile, but that's a harmful load of shit in a world that has an ever-increasing hunger for software that doesn't suck
- overgard 10y agoJust because a thing is sufficient doesn't make it efficient or pleasant.
- superuser2 10y agoThis is just like the anti-car people. "People ought to be restricted to slow and unpleasant methods of transportation because they should not want to leave their immediate vicinities." There's a grain of truth in both cases - there's no energy efficiency like not needing to move around at all, and there's no memory/CPU/cost efficiency like not having sophisticated functionality in the first place. But once you are used to the functionality that comes from heavyweight tools, "do without - it's better for you" is frustrating at best and more likely engenders hostility for the person saying it.
- fredsir 10y agoThat is som lousy anti-car people you have been talking to, it sounds like.