diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2013-02-01 19:39:04 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2013-02-01 19:39:04 +0000 |
commit | 8a92335bfca80cc9b4cd217505ea0dcbfdefbf07 (patch) | |
tree | 1a2727b6fdead4c6894d9cdefc072b0d04fcd1bc | |
parent | 17f2157dcc39cd6c5786ba70dd130e858728f1ac (diff) | |
download | gdb-8a92335bfca80cc9b4cd217505ea0dcbfdefbf07.zip gdb-8a92335bfca80cc9b4cd217505ea0dcbfdefbf07.tar.gz gdb-8a92335bfca80cc9b4cd217505ea0dcbfdefbf07.tar.bz2 |
gdb/
* elfread.c (elf_symfile_read): Limit separate debug info additions to
files with no separate debug info.
* objfiles.c (add_separate_debug_objfile): Add gdb_assert calls.
* symfile.c (read_symbols): Call find_separate_debug_file_in_section
only for files with no separate debug info.
gdb/testsuite/
* gdb.base/gnu-debugdata.exp): Create ${binfile}.debug,
${binfile}.mini_debuginfo-debuglink, add -k to xz, use now
${binfile}.mini_debuginfo-debuglink and
${binfile}.mini_debuginfo-debuglink.xz.
-rw-r--r-- | gdb/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/elfread.c | 14 | ||||
-rw-r--r-- | gdb/objfiles.c | 3 | ||||
-rw-r--r-- | gdb/symfile.c | 7 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/gnu-debugdata.exp | 22 |
6 files changed, 55 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e4cbe05..c95c1b3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2013-02-01 Jan Kratochvil <jan.kratochvil@redhat.com> + + * elfread.c (elf_symfile_read): Limit separate debug info additions to + files with no separate debug info. + * objfiles.c (add_separate_debug_objfile): Add gdb_assert calls. + * symfile.c (read_symbols): Call find_separate_debug_file_in_section + only for files with no separate debug info. + 2013-01-31 Tom Tromey <tromey@redhat.com> * jit.c (jit_program_space_data): Rename from jit_inferior_data; diff --git a/gdb/elfread.c b/gdb/elfread.c index 9d630cd..6ca659f9 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1431,8 +1431,18 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags) /* If the file has its own symbol tables it has no separate debug info. `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to SYMTABS/PSYMTABS. `.gnu_debuglink' may no longer be present with - `.note.gnu.build-id'. */ - else if (!objfile_has_partial_symbols (objfile)) + `.note.gnu.build-id'. + + .gnu_debugdata is !objfile_has_partial_symbols because it contains only + .symtab, not .debug_* section. But if we already added .gnu_debugdata as + an objfile via find_separate_debug_file_in_section there was no separate + debug info available. Therefore do not attempt to search for another one, + objfile->separate_debug_objfile->separate_debug_objfile GDB guarantees to + be NULL and we would possibly violate it. */ + + else if (!objfile_has_partial_symbols (objfile) + && objfile->separate_debug_objfile == NULL + && objfile->separate_debug_objfile_backlink == NULL) { char *debugfile; diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 5232c8f..5829699 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -476,6 +476,9 @@ add_separate_debug_objfile (struct objfile *objfile, struct objfile *parent) /* Must not be already in a list. */ gdb_assert (objfile->separate_debug_objfile_backlink == NULL); gdb_assert (objfile->separate_debug_objfile_link == NULL); + gdb_assert (objfile->separate_debug_objfile == NULL); + gdb_assert (parent->separate_debug_objfile_backlink == NULL); + gdb_assert (parent->separate_debug_objfile_link == NULL); objfile->separate_debug_objfile_backlink = parent; objfile->separate_debug_objfile_link = parent->separate_debug_objfile; diff --git a/gdb/symfile.c b/gdb/symfile.c index 63bf329..6f968b7 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -823,7 +823,12 @@ static void read_symbols (struct objfile *objfile, int add_flags) { (*objfile->sf->sym_read) (objfile, add_flags); - if (!objfile_has_partial_symbols (objfile)) + + /* find_separate_debug_file_in_section should be called only if there is + single binary with no existing separate debug info file. */ + if (!objfile_has_partial_symbols (objfile) + && objfile->separate_debug_objfile == NULL + && objfile->separate_debug_objfile_backlink == NULL) { bfd *abfd = find_separate_debug_file_in_section (objfile); struct cleanup *cleanup = make_cleanup_bfd_unref (abfd); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 47fed77..8fc13fe 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2013-02-01 Jan Kratochvil <jan.kratochvil@redhat.com> + + * gdb.base/gnu-debugdata.exp): Create ${binfile}.debug, + ${binfile}.mini_debuginfo-debuglink, add -k to xz, use now + ${binfile}.mini_debuginfo-debuglink and + ${binfile}.mini_debuginfo-debuglink.xz. + 2013-02-01 Tom Tromey <tromey@redhat.com> * gdb.dwarf2/method-ptr.exp: Use correct form for non-string diff --git a/gdb/testsuite/gdb.base/gnu-debugdata.exp b/gdb/testsuite/gdb.base/gnu-debugdata.exp index f34e4e8..55aa3c6 100644 --- a/gdb/testsuite/gdb.base/gnu-debugdata.exp +++ b/gdb/testsuite/gdb.base/gnu-debugdata.exp @@ -127,14 +127,30 @@ if {[run "strip" [transform strip] \ return -1 } +# Separate full debug info into ${binfile}.debug. +remote_file host delete ${binfile}.debug +if {[run "copydebug" [transform objcopy] \ + "--only-keep-debug ${binfile} ${binfile}.debug"]} { + return -1 +} + +# Add the .gnu_debuglink section to the .gnu_debugdata file. +# .gnu_debuglink is normally not present in the .gnu_debugdata section but in +# some files there may be PT_NOTE with NT_GNU_BUILD_ID and GDB could look up +# the .debug file from it. +if {[run "addlink" [transform objcopy] \ + "--add-gnu-debuglink=${binfile}.debug ${binfile}.mini_debuginfo ${binfile}.mini_debuginfo-debuglink"]} { + return -1 +} + # Inject the compressed data into the .gnu_debugdata section of the # original binary. -remote_file host delete ${binfile}.mini_debuginfo.xz -if {[run "xz" "xz" "${binfile}.mini_debuginfo"]} { +remote_file host delete ${binfile}.mini_debuginfo-debuglink.xz +if {[run "xz" "xz" "-k ${binfile}.mini_debuginfo-debuglink"]} { return -1 } remote_file host delete ${binfile}.test -if {[run "objcopy 2" [transform objcopy] "--add-section .gnu_debugdata=${binfile}.mini_debuginfo.xz ${binfile}.strip ${binfile}.test"]} { +if {[run "objcopy 2" [transform objcopy] "--add-section .gnu_debugdata=${binfile}.mini_debuginfo-debuglink.xz ${binfile}.strip ${binfile}.test"]} { return -1 } |