1
I ran the configure script with the --enable-debug flag, then ran make. I am running unit tests:
gdb --args src/test/test_bitcoin --log_level=all --run_test=script_standard_tests
I'm trying to step through the execution of the source files using gdb, but I am still getting <optimized out> for many variables, and it skips lines here and there. I thought that the --enable-debug flag would turn off optimization, but am I mistaken? I'm wondering if the optimization is always on for the tests or if there is a way to turn them off.
Nice workaround, thanks. I'm still getting
<optimized out>, though, I must be missing something. – JBaczuk – 2018-11-21T16:24:24.323Now it is showing all variables. I must've not recompiled the file correctly. – JBaczuk – 2018-11-21T16:39:46.033
Glad that I could help! :) – MCCCS – 2018-11-21T16:40:10.530
If you want to avoid all "<compiled out>"s, you need to compile with "-O0" to disable all optimizations. – Pieter Wuille – 2018-11-21T17:49:00.193
2Also there is no need to modify configure.ac, you can override things on the command line by using
./configure CXXFLAGS="-O0 -ggdb3" .... – Pieter Wuille – 2018-11-21T17:51:11.583@PieterWuille the manual (https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html) says O0 is default in GCC, but agree about the second, will edit soon.
– MCCCS – 2018-11-21T17:51:14.6971@MCCCS But
--enable-debugwill pass-Ogwhich overrides the-O0default. – Pieter Wuille – 2018-11-21T18:00:13.750Why doesn't
--enable-debuguse-O0? – JBaczuk – 2018-11-21T19:33:51.780