This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug symtab/10334] New: separate debuginfo not loaded if some debug sections are present


We like to have executables with file/line debug info (but no type/variable
info) in production. However, GDB refuses to load separate (full) debug
info for such executables.

Test case:

cat t.cc

#include <map>

int bar()
{
   int *ip = 0;
   return ip[0]; // crash
}

int foo()
{
  return bar();
}

int main()
{
   std::map<int, int> a_map;

   a_map[0] = 1;
   return foo();
}

g++ -g t.cc -o a.out-full
g++ -g t.cc -o a.out-partial -Wl,--strip-debug-non-line   # This is a Gold option

objcopy --only-keep-debug a.out-full a.out.debug
objcopy --add-gnu-debuglink=a.out.debug a.out-partial

With above, a.out-partial is half the size of a.out-full, and contains
enough debug info for external tools (though not GDB) to reconstruct crash
stack trace with file and line numbers.

However, a.out-partial is "useless" with GDB:

gdb ./a.out-partial 
GNU gdb (GDB) 6.8.50.20090625-cvs
...
(gdb) r

Program received signal SIGSEGV, Segmentation fault.
0x000000000040036c in bar() ()
(gdb) bt
#0  0x000000000040036c in bar() ()
#1  0x0000000000400379 in foo() ()
#2  0x00000000004003ae in main ()
(gdb) q

In order to get GDB to load a.out.debug, I must first strip a.out-partial
completely:

objcopy --strip-all a.out-partial a.out-stripped

When I do that, a.out-stripped becomes usable under GDB:

gdb ./a.out-stripped 
GNU gdb (GDB) 6.8.50.20090625-cvs
...
(gdb) r

Program received signal SIGSEGV, Segmentation fault.
0x000000000040036c in bar () at t.cc:6
6          return ip[0]; // crash
(gdb) bt 
#0  0x000000000040036c in bar () at t.cc:6
#1  0x0000000000400379 in foo () at t.cc:11
#2  0x00000000004003ae in main () at t.cc:19
(gdb) q

-- 
           Summary: separate debuginfo not loaded if some debug sections are
                    present
           Product: gdb
           Version: 6.8
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: symtab
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: ppluzhnikov at google dot com
                CC: gdb-prs at sourceware dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=10334

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]