1

Is there a way to instruct C++ Builder's linker to output DWARF debug information (64-bit C++ apps) in standalone file rather than inject it directly into executable? I.e. the option similar to "Place debug information in separate TDS file" (which does not work for DWARF debug format).

If there is no such option - is there a way to strip info from already compiled executable?

Alex
  • 5,477
  • 2
  • 36
  • 56

2 Answers2

2

To place debug info in separate file follow below steps

// Build    
$ clang -O2 -g -o hello.full hello.c

// Package hello.stripped is run as "hello" in production environment
$ strip -o hello.stripped hello.full

// Extract debug info to separate file
$ objcopy --only-keep-debug hello.full hello.debug

// Create a section which contains a reference to debug file 
$ objcopy --strip-debug --add-gnu-debuglink=hello.debug hello.full hello

// Debug - GDB automatically reads hello.debug
$ gdb hello
. . .
Reading symbols from ./hello...
Reading symbols from /homes/syrajendra/hello.debug...done.
(gdb)

// Core from hello.stripped
$ gdb --core core-file --exec hello
Rajendra
  • 1,662
  • 2
  • 10
  • 11
1

Assuming you are on a platform with GNU Binutils you can use objcopy to extract the DWARF information to a separate file as a post-compilation step. If you like you can then use strip to remove the debugging information from the executable binary.

Electron
  • 1,390
  • 10
  • 8