Skip to content

Debugging

FMXExpress edited this page Oct 15, 2020 · 1 revision

Debugging a source file

Debugging a source file can be done using the following steps:

  • Create (Ctrl+N) or open (Ctrl+O) a source file.
  • At Tools >> Compiler Options, select a compiler set that supports debugging (-g3).
  • Click Debug (F5) to compile and debug the currently visible file.
  • Place a breakpoint by clicking on a line number or use F4 to pause your program and inspect it.

Debugging a project

Debugging a project file can be done using the following steps:

  • Create (Ctrl+N) or open (Ctrl+O) a project.
  • At Project >> Project Options >> Compiler, select a compiler set that supports debugging (-g3).
  • Click Debug (F5) to compile and debug the project.
  • Place a breakpoint by clicking on a line number or use F4 to pause your program and inspect it

Tips

  • When changing compiler sets, make sure to rebuild before debugging. Embarcadero Dev-C++ will only suggest doing so if a source file is newer the executable, but not when the compiler changes!
  • Optimization (-Ox) will, among other effects, change the order of execution and can remove code that yields no net change. This can be quite annoying when walking through code line by line. Consider debugging without optimization or use -Og to fix this. http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Debugging-Optimized-Code.html
  • Adding debug information usually more than doubles compilation time. Consider disabling it to lower compilation times.
  • The strip flag (-s) will remove debugging information added by -g3. Consider disabling it.
  • Debugging information adds considerable size (an order of magnitude isn't out of the ordinary) to created programs. Consider disabling it to reduce file size.
Clone this wiki locally