aboutsummaryrefslogtreecommitdiff
path: root/gdb/contrib
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2017-12-08 22:44:10 +0000
committerPedro Alves <palves@redhat.com>2017-12-08 23:33:27 +0000
commit437afbb81e3a04cbd933fc534a50c686eaa63b19 (patch)
tree9389ec170eff92880790a69075e48eccb3afdccc /gdb/contrib
parent6432ec65a8822246db5bcede0c6bd3ed0e464a0b (diff)
downloadbinutils-437afbb81e3a04cbd933fc534a50c686eaa63b19.zip
binutils-437afbb81e3a04cbd933fc534a50c686eaa63b19.tar.gz
binutils-437afbb81e3a04cbd933fc534a50c686eaa63b19.tar.bz2
DWARF-5: .debug_names index producer
This adds a new "-dwarf-5" switch to "save gdb-index" that makes it generate index files with DWARF-5 .debug_names/.debug_str sections instead of GDB's own .gdb_index. We should probably add a command line option to contrib/gdb-add-index.sh (incl. cc-with-tweaks.sh) for the new -dwarf-5 GDB option, and a new target board to make it more convenient to exercise this. To be done later. gdb/ChangeLog 2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> * contrib/gdb-add-index.sh (index): Rename to ... (index4): ... here. (index5, debugstr, debugstrmerge, debugstrerr): New variables. Support also .debug_names and .debug_str. * dwarf2read.c: Include cmath, set, list. (INDEX_SUFFIX): Rename to ... (INDEX4_SUFFIX): ... here. (INDEX5_SUFFIX, DEBUG_STR_SUFFIX): New. (file_write(FILE *, const void *, size_t)): New. (file_write(FILE *, const std::vector<Elem, Alloc> &)): New. (data_buf::append_unsigned_leb128, data_buf::empty): New. (data_buf::file_write): Use ::file_write. (data_buf::c_str, dwarf5_djb_hash, debug_names) (check_dwarf64_offsets): New. (psyms_seen_size, write_gdbindex): New from write_psymtabs_to_index code. (dwarf5_gdb_augmentation, write_debug_names, assert_file_size) (enum dw_index_kind): New. (write_psymtabs_to_index): New parameter index_kind. Support filename_str and out_file_str. Move code to write_gdbindex, possibly call write_debug_names. (save_gdb_index_command): New parameter -dwarf-5. (_initialize_dwarf2_read): Document the new parameter -dwarf-5. gdb/doc/ChangeLog 2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.texinfo (Index Files): Document .debug_names and -dwarf-5. -- gdb/contrib/gdb-add-index.sh | 53 ++ gdb/doc/gdb.texinfo | 24 + gdb/dwarf2read.c | 919 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 935 insertions(+), 61 deletions(-)
Diffstat (limited to 'gdb/contrib')
-rwxr-xr-xgdb/contrib/gdb-add-index.sh53
1 files changed, 47 insertions, 6 deletions
diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh
index 0cd4ce3..02b17f0 100755
--- a/gdb/contrib/gdb-add-index.sh
+++ b/gdb/contrib/gdb-add-index.sh
@@ -37,11 +37,15 @@ fi
dir="${file%/*}"
test "$dir" = "$file" && dir="."
-index="${file}.gdb-index"
+index4="${file}.gdb-index"
+index5="${file}.debug_names"
+debugstr="${file}.debug_str"
+debugstrmerge="${file}.debug_str.merge"
+debugstrerr="${file}.debug_str.err"
-rm -f $index
+rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr
# Ensure intermediate index file is removed when we exit.
-trap "rm -f $index" 0
+trap "rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr" 0
$GDB --batch -nx -iex 'set auto-load no' \
-ex "file $file" -ex "save gdb-index $dir" || {
@@ -57,9 +61,46 @@ $GDB --batch -nx -iex 'set auto-load no' \
# already stripped binary, it's a no-op.
status=0
-if test -f "$index"; then
- $OBJCOPY --add-section .gdb_index="$index" \
- --set-section-flags .gdb_index=readonly "$file" "$file"
+if test -f "$index4" -a -f "$index5"; then
+ echo "$myname: Both index types were created for $file" 1>&2
+ status=1
+elif test -f "$index4" -o -f "$index5"; then
+ if test -f "$index4"; then
+ index="$index4"
+ section=".gdb_index"
+ else
+ index="$index5"
+ section=".debug_names"
+ fi
+ debugstradd=false
+ debugstrupdate=false
+ if test -s "$debugstr"; then
+ if ! $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$file" /dev/null \
+ 2>$debugstrerr; then
+ cat >&2 $debugstrerr
+ exit 1
+ fi
+ if grep -q "can't dump section '.debug_str' - it does not exist" \
+ $debugstrerr; then
+ debugstradd=true
+ else
+ debugstrupdate=true
+ cat >&2 $debugstrerr
+ fi
+ cat "$debugstr" >>"$debugstrmerge"
+ fi
+
+ $OBJCOPY --add-section $section="$index" \
+ --set-section-flags $section=readonly \
+ $(if $debugstradd; then \
+ echo --add-section .debug_str="$debugstrmerge"; \
+ echo --set-section-flags .debug_str=readonly; \
+ fi; \
+ if $debugstrupdate; then \
+ echo --update-section .debug_str="$debugstrmerge"; \
+ fi) \
+ "$file" "$file"
+
status=$?
else
echo "$myname: No index was created for $file" 1>&2