gdb: No symbol "i" in current context

It has probably been optimised out of your compiled code as you only use feature_mask[i] within the loop.

Did you specify an optimization level when you called your compiler? If you were using gcc, then just omit any -O options and try again.


I encountered this issue recently. I compiled GCC 5.1 and then used it to compile a C++11 codebase. And, although I could step through the program's code in gdb, I couldn't print the value of any variable, I kept getting “No symbol "xyz" in current context” errors, for every variable.

I was using gdb 7.4, but the latest version available at the time was 7.9. I downloaded the latest version of gdb and compiled it (using GCC 5.1) and when using gdb 7.9 I was able to successfully inspect variable values again.

I guess the debug information of GCC 5.1 is incompatible with gdb 7.4.

Tags:

C

Debugging

Gdb