Re: Debugging: Am I a dreamer. . . ?



Chris H wrote:
In message <m1d4o7remo.fsf@xxxxxxxxx>, Hao Wang <doitmy@xxxxxxxxx> writes
Tomás Ó hÉilidhe <toe@xxxxxxxxxxx> writes:

I've been programming in C for the best part of a decade now but it's
only within the last year that I've really started doing embedded
systems programming.

When I did C programming for a personal computer, I commonly debugged
my code simply by putting in printf statements around the place to
check variable values, and also by using the instrument that lets you
check the values of variables at runtime when you're stepping through
the code.


If you really programming in C for years, you know that using printf
or debugger to remove bugs, only gives the design more bugs. Embedded
solutions stay away bugs by careful design (in both IC/HW/BSP/SW).

I wasn't going to mention that as it usually causes a bun fight bit since you have...

You should never debug using printf.

This is why there are simulators, debuggers and Emulators. Even for PC's I can recall Borland had a system where you could debug one PC from another. For embedded using printf should have dies out over a decade ago.


What's wrong with debugging using printf? I don't mean specifically "printf", which you should normally avoid in a small embedded system, but the general idea of putting out extra information while the program runs is a very useful debugging technique. Simulators, debuggers, and emulators are all important for development and debugging, but sometimes it is easier to send out signals to show what is happening. Of course such things involve changes to your code, and changes to the run-time characteristics of your system - but that's often perfectly acceptable during development and debugging. It is not a good idea to rely on printf-style debugging as your *only* method of debugging - but equally it is a waste to arbitrarily exclude it from your toolbox.

.



Relevant Pages

  • Re: Development engineering
    ... Yeah, debugging skill #1 is diagnosis -- fixes are easier, more often ... The skills of, say: finding bugs; ... the deucedest ones in my experience), distributed programming (...runs ... that debugging -- if I took a week to learn it, ...
    (comp.lang.python)
  • Re: Priority Queue confusion
    ... Using Macros ... 90% probability of 90% bugs being generated at run time. ... Programming is programming, there's no reason ... Using anything can definitely cause problems in debugging. ...
    (comp.programming)
  • Re: Debugging: Am I a dreamer. . . ?
    ... systems programming. ... You know the PIC16F684 chip that costs less than a dollar, ... Many chips have in-circuit debugging features, ... debugging that you can twiddle with in software instead of a printf is ...
    (comp.arch.embedded)
  • Re: Printing from kernel
    ... >area where it's unsafe to print, probably holding a lock that's needed ... Instead of messages from kernel I see the first letter ... >No. printf() is widely used in the kernel. ... It is used not only for debugging by myself, part of this output is my ...
    (freebsd-hackers)
  • Re: Debugging: Am I a dreamer. . . ?
    ... What's wrong with debugging using printf? ... "printf", which you should normally avoid in a small embedded system, ... runs is a very useful debugging technique. ... software UART for debugging output. ...
    (comp.arch.embedded)