development of bitcoincore – Debugging Bitcoin Core with gdb – how to disable compiler optimizations

Bitcoin Core disables -O2 and enable -Og when --enable-debug It is established. -Og it is intended for purification; however, it removes some of the debug information and has errors. To disable it and improve the debugging experience, I suggest switching between L256 and L278 to:

CXXFLAGS = "- ggdb3 -ftrapv"

-ggdb3 it is more powerful than -g3, uses a dialect only of GDB, incompatible with LLDB for debugging. This will also get rid of -O2, except in libsecp256k1.

Edition: Sipa suggests a more elegant way without altering the autoconf files, which is to add arguments for the configuration.

./configure CXXFLAGS = "- O0 -ggdb3"

O0 is necessary in this case.