Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How GDB deals with big (>1 Gb) debug files?

Tags:

c++

debugging

gdb

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!

like image 785
Viktor Malyi Avatar asked Apr 07 '15 11:04

Viktor Malyi


People also ask

How does GDB debugger works?

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.

Does GDB slow down?

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.

Does GDB use dwarf?

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.

Can I debug C++ with GDB?

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.


1 Answers

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.

like image 172
ks1322 Avatar answered Oct 30 '22 18:10

ks1322