GCC. Generate limited debug info

1.1k Views Asked by At

Is there a way to force gcc to generate only subset of full debug info that will be sufficient for addr2line utility? Or any way to strip unneeded? I've tried

$ objcopy --only-keep-debug --remove-section=.debug_loc --remove-section=.debug_aranges --remove-section=.debug_frame my-elf-file

Is there anything that may be stripped in addition?

1

There are 1 best solutions below

1
On BEST ANSWER

You want -g1. This produces minimal debug info for backtraces. From the manual:

Level 1 produces minimal information, enough for making backtraces in parts of the program that you don't plan to debug. This includes descriptions of functions and external variables, and line number tables, but no information about local variables.

You can also strip some of the debug info after the fact. One way to do this is described in the gdb "MiniDebugInfo" documentation.