Check the PlugΒΆ

Sometimes a bug is difficult to find due to a strong assumption you have made about the system. For example, the system libraries are bug free, or that the compiler generates correct code. While these example would be very rare, it is not uncommon to assume that a new bug is in the new code, and not a bug in previously reliable code that is unmasked by new code. Some times, one should take a step back and re-validate your basic assumptions to see if they still hold.

Here are some tips for how to check the plug.

  • Use GDB to print as many variables as possible before the bug occurs - All GDB Content

  • Check the basic functionality: a change that broke a more complex scenario may have also broken basic functionality. This is where it is helpful to have a test suite that you can run each time you make changes.

  • OS/161 - KASSERT can be used to check the invariants in OS/161 code and assert() can be used to check the invariants in most other C programs. These stop the program if a particular assumption becomes false.