Debugging Tools

There are various debugging tools that a programmer could use to find out what is going wrong in the codebase. Some provides great visualisation of the data suggested by Hunt et al.

Compilers

When debugging, the warning flags or messages provided by compilers, transpiler or REPL should be the first choice on noticing potential bugs that could exist in the codebase. It is going to help in eliminating most of the deterministic bugs.

  • C compiler with verbose warning flags (-Wall -Wextra -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wwrite-strings -Wno-unused-parameter -Wfloat-equal -pedantic -ansi) 1
  • C++ compiler with verbose warning flags (-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Werror -Wno-unused) 1
  • Rustc/Cargo for Rust programming language

Static Code Analysis Tools

Static code analysis tools could be used to check security vulnerabilities and ensure code quality of the software before it compiled into binary. It will find all possible (if the flag is set so) questionable styles, that could to lead to disastrous consequences, and lint it to the developers.

  • Coverity
  • Cppcheck

Iterative Debuggers

Iterative debuggers are useful tool in debugging a program by analysing their information in binary or sometimes ELF files in Linux environment. These debuggers could let you set breakpoints in between the sequence of the control flow. Some have even great ability to visualise the data that you’re set to inspect.

  • GDB# especially with -g3 option for more verbose debugging information.
  • LLDB
  • MSVC
  • UDB
  • Data Display Debugger (DDD), a graphical front-end for multiple debuggers such as GDB#, DBX, WDB, Ladebug, JDB, XDB, the Perl debugger, bashdb, remake, and pydb.

Time-Travel Debuggers

To-do: what is time-travel debuggers and why does it help?

  • GDB# (??)
  • rr
  • LiveRecorder
  • UDB

Sanitisers

Sanitisers are tools that could help in inspecting various aspect of the program, such as memory address, thread information, undefined behaviour etc. by reading the debugging symbols, which could be produced by compilers using the option -fsanitize={address|thread|undefined|leak}.

  • AddressSanitizer (ASan)
  • ThreadSanitizer (TSan)
  • UndefinedBehaviourSanitizer (UBSan)
  • LeakSanitizer (LSan)

Dynamic Program Analysers

Dynamic Program Analyzers could be used to detect various defects such as memory leaks and synchronisation errors or do some profiling regard to the program.

  • Valgrind
  • Callgrind
  • Helgrind

Call Tracers and Domain Specific Diagnostic Tools

To-do: elaborate more

  • Strace
  • WireShark (networking profiling and diagnosis)
  • SQL analysis

ELF Reader

To-do: Is the following classification true to the programs?

  • readelf to read information from ELF files.
  • strip to remove symbols such as debug symbols from the object files.
  • objcopy, like strip but allows more fine tune symbols removal.

Unclassified/Others

  • debuginfod for remote debugging.
  • SystemTap as a scripting language to debug live running kernel.
  • Simply print out the value of the variable using print function or GUI popup
  • paper-and-pencil
  • external plotting programs like gnuplot
Links to this page
  • Locate a Bug
  • Bug Classification

    Syntax warnings, which is technically allowed by compilers but involved potential questionable practices. Using extensive flags could make the warnings more verbose.

  • Assertions

    In C and C++, the keywords assert and _assert are usually viewed as a Debugging Tools. However, as recommended by Hunt et al., if you ever feel that #something can’t happen, it is a great opportunity to ensure it won’t by using assertions. Even though assertions can add overhead to the program, turning them off when building the binary is a bad idea since it assumes tests alone would find every bug in the codebase which is not the case.

#debugging #c #cpp #rust