[gdb/contrib] Fix gdb/contrib/gdb-add-index.sh for dwz-m-ed execs
Atm gdb-add-index.exp fails with target board cc-with-dwz-m. Fix this by updating gdb/contrib/gdb-add-index.sh to handle a dwz-m-ed executable. Tested on x86_64-linux. gdb/ChangeLog: 2019-06-16 Tom de Vries <tdevries@suse.de> PR gdb/24445 * contrib/gdb-add-index.sh: Update to handle dwz-m-ed executable.
This commit is contained in:
parent
431b3eadc4
commit
2b9f6e89d6
|
@ -1,3 +1,8 @@
|
||||||
|
2019-06-16 Tom de Vries <tdevries@suse.de>
|
||||||
|
|
||||||
|
PR gdb/24445
|
||||||
|
* contrib/gdb-add-index.sh: Update to handle dwz-m-ed executable.
|
||||||
|
|
||||||
2019-06-16 Tom Tromey <tom@tromey.com>
|
2019-06-16 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* tui/tui-wingeneral.c (tui_unhighlight_win, tui_highlight_win)
|
* tui/tui-wingeneral.c (tui_unhighlight_win, tui_highlight_win)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
# If not, or you want others, pass the following in the environment
|
# If not, or you want others, pass the following in the environment
|
||||||
GDB=${GDB:=gdb}
|
GDB=${GDB:=gdb}
|
||||||
OBJCOPY=${OBJCOPY:=objcopy}
|
OBJCOPY=${OBJCOPY:=objcopy}
|
||||||
|
READELF=${READELF:=readelf}
|
||||||
|
|
||||||
myname="${0##*/}"
|
myname="${0##*/}"
|
||||||
|
|
||||||
|
@ -43,15 +44,44 @@ fi
|
||||||
|
|
||||||
dir="${file%/*}"
|
dir="${file%/*}"
|
||||||
test "$dir" = "$file" && dir="."
|
test "$dir" = "$file" && dir="."
|
||||||
index4="${file}.gdb-index"
|
|
||||||
index5="${file}.debug_names"
|
|
||||||
debugstr="${file}.debug_str"
|
|
||||||
debugstrmerge="${file}.debug_str.merge"
|
|
||||||
debugstrerr="${file}.debug_str.err"
|
|
||||||
|
|
||||||
rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr
|
dwz_file=""
|
||||||
|
if $READELF -S "$file" | grep -q " \.gnu_debugaltlink "; then
|
||||||
|
dwz_file=$($READELF --string-dump=.gnu_debugaltlink "$file" \
|
||||||
|
| grep -A1 "'\.gnu_debugaltlink':" \
|
||||||
|
| tail -n +2 \
|
||||||
|
| sed 's/.*]//')
|
||||||
|
dwz_file=$(echo $dwz_file)
|
||||||
|
if $READELF -S "$dwz_file" | grep -E -q " \.(gdb_index|debug_names) "; then
|
||||||
|
# Already has an index, skip it.
|
||||||
|
dwz_file=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
set_files ()
|
||||||
|
{
|
||||||
|
local file="$1"
|
||||||
|
|
||||||
|
index4="${file}.gdb-index"
|
||||||
|
index5="${file}.debug_names"
|
||||||
|
debugstr="${file}.debug_str"
|
||||||
|
debugstrmerge="${file}.debug_str.merge"
|
||||||
|
debugstrerr="${file}.debug_str.err"
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp_files=
|
||||||
|
for f in "$file" "$dwz_file"; do
|
||||||
|
if [ "$f" = "" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
set_files "$f"
|
||||||
|
tmp_files="$tmp_files $index4 $index5 $debugstr $debugstrmerge $debugstrerr"
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -f $tmp_files
|
||||||
|
|
||||||
# Ensure intermediate index file is removed when we exit.
|
# Ensure intermediate index file is removed when we exit.
|
||||||
trap "rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr" 0
|
trap "rm -f $tmp_files" 0
|
||||||
|
|
||||||
$GDB --batch -nx -iex 'set auto-load no' \
|
$GDB --batch -nx -iex 'set auto-load no' \
|
||||||
-ex "file $file" -ex "save gdb-index $dwarf5 $dir" || {
|
-ex "file $file" -ex "save gdb-index $dwarf5 $dir" || {
|
||||||
|
@ -67,50 +97,64 @@ $GDB --batch -nx -iex 'set auto-load no' \
|
||||||
# already stripped binary, it's a no-op.
|
# already stripped binary, it's a no-op.
|
||||||
status=0
|
status=0
|
||||||
|
|
||||||
if test -f "$index4" -a -f "$index5"; then
|
handle_file ()
|
||||||
echo "$myname: Both index types were created for $file" 1>&2
|
{
|
||||||
status=1
|
local file
|
||||||
elif test -f "$index4" -o -f "$index5"; then
|
file="$1"
|
||||||
if test -f "$index4"; then
|
|
||||||
index="$index4"
|
set_files "$file"
|
||||||
section=".gdb_index"
|
|
||||||
else
|
if test -f "$index4" -a -f "$index5"; then
|
||||||
index="$index5"
|
echo "$myname: Both index types were created for $file" 1>&2
|
||||||
section=".debug_names"
|
status=1
|
||||||
fi
|
elif test -f "$index4" -o -f "$index5"; then
|
||||||
debugstradd=false
|
if test -f "$index4"; then
|
||||||
debugstrupdate=false
|
index="$index4"
|
||||||
if test -s "$debugstr"; then
|
section=".gdb_index"
|
||||||
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
|
else
|
||||||
debugstrupdate=true
|
index="$index5"
|
||||||
cat >&2 $debugstrerr
|
section=".debug_names"
|
||||||
fi
|
fi
|
||||||
cat "$debugstr" >>"$debugstrmerge"
|
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
|
||||||
|
echo "$myname: [Was there no debuginfo? Was there already an index?]" \
|
||||||
|
1>&2
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
$OBJCOPY --add-section $section="$index" \
|
handle_file "$file"
|
||||||
--set-section-flags $section=readonly \
|
if [ "$dwz_file" != "" ]; then
|
||||||
$(if $debugstradd; then \
|
handle_file "$dwz_file"
|
||||||
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
|
|
||||||
echo "$myname: [Was there no debuginfo? Was there already an index?]" 1>&2
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $status
|
exit $status
|
||||||
|
|
Loading…
Reference in New Issue