I didn't found any info how to build the gdb itself with debugging symbols.
Like every other software.
Let's try to be a bit more helpful here: like most other software using an Autoconf configure script, pass the required flags in the CFLAGS and CXXFLAGS variables (since GDB is a mix of C and C++, you need both). For example: $ path/to/configure CFLAGS="-g3 -O0" CXXFLAGS="-g3 -O0"