I have a problem debugging C++ application using remote GDB session that codebase is big, and therefore it contains (when compiled with "-O2', '-g', '-DNDEBUG'" flags) a big file with debug information (1.1 Gb).
Unfortunately, I can't just use partial symbol tables during debugging since all the time debugger skips the part of the application, and I'm unable to set breakpoints there and see the code while debugging.
As the solution for this issue, I execute following command after I've got connected to target:
symbol-file -readnow [path-to-file-with-debugging-info]
This expands full symbol tables. But in this case GDB simply runs out of memory hitting 13 Gb or even more RAM (while I have only 16 Gb available on my machine). This problem is already listed in GDB Wiki and known.
My question is how to deal with GDB in this case, when I need full symbol tables, but GDB requires an enorm amount of memory in order to expand it?
Thanks in advance!
How GDB Debugs? GDB allows you to do things like run the program up to a certain point then stop and print out the values of certain variables at that point, or step through the program one line at a time and print out the values of each variable after executing each line. GDB uses a simple command line interface.
GDB does software watchpointing by single-stepping your program and testing the variable's value each time, which is hundreds of times slower than normal execution.
Produce debugging information for use by GDB. This means to use the most expressive format available (DWARF, stabs, or the native format if neither of those are supported), including GDB extensions if at all possible.
You can use GDB as a C++ debugger if a program is written with the GNU compiler and the -g flag. By debugging with GDB, you can catch errors and solve them before they cause severe issues.
You can try to use gold linker with --compress-debug-sections=zlib
option. This will reduce the size of debug info. gdb can read compressed debug info since 7.0 version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With