13

I'm trying to determine whether there are any downsides to building release binaries with debug symbols left in. For our release builds, we compile with -O3 at the moment and if there are any crashes, the cores are next to useless.

So, what I would like to do is modify the build to leave in debug symbols, i.e. -O3 -g, but there is resistance to this as the feeling is that there could be some impact (aside from size of binary). I know that the size issue can be fixed by stripping out the symbols, but is there anything else subtle that I'm missing?

Nim
  • 33,299
  • 2
  • 62
  • 101

2 Answers2

25

Separate symbols from binary.

g++ -ggdb -o target obj1.o obj2.o ...
strip target --only-keep-debug -o target.dbg
strip target

Then in gdb, use symbol-file target.dbg

EDIT: On the actual question:

The downsides are:

  • Easier reverse engineering (if that worries you)
  • Larger binaries

Execution speed is not affected - Debug symbols are simply added to the binary in a separate section, they may affect your virtual address space size but nothing else.

Erik
  • 88,732
  • 13
  • 198
  • 189
  • 1
    Whoa, nice, I did not knew this was possible! – speeder Apr 06 '11 at 16:17
  • thanks, I know this is possible, the question was more are there any issues with building optimized builds with them in the first place (i.e. pre the stripping step). – Nim Apr 06 '11 at 16:27
0

It affects size, and thus caching and memory too.

If you read information about compiler options, you will see that it says that sometimes unrolling loops for example make the code SLOWER because of the increased size breaking caching and causing more memory fetches.

speeder
  • 6,197
  • 5
  • 34
  • 51