On printf debugging

Jan 9, 2020 |

  • Printf calls are SLOW. Writing 25 bytes over a 115200 baud serial line takes a whopping 2 milliseconds, not counting any string formatting. This may change the system behavior and hide the problem you are chasing. This also means that printf calls can’t be used in any time critical code, such as interrupt handlers.
  • Additional conditions and variables are often needed to focus the logging on relevant events. Writing extra debugging code is tedious work and sometimes developers forget to remove some of it. Moreover, if not 100% correct, this can give misleading information or even introduce new bugs.
  • Large amounts of text output is produced, which is often difficult to analyze manually. The human brain is great at pattern recognition, but only if the data is in visual form. Moreover, search function are not very useful when you don’t know exactly what you are looking for.