Provide source files for useful debug packages
Debug packages are fairly useless currently because the soucre files needed for stepping through code etc are not packaged with them. This patch adds the needed source files to the debug package and adjusts the debug info to look at the /usr/src/debug/ directory for them rather than the build location. This requires using the "debugedit" program which is provided as part of the RPM sources. Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
37a89e2fac
commit
8b0d59b83a
1 changed files with 21 additions and 2 deletions
|
@ -32,7 +32,12 @@ tidy_modify+=('tidy_strip')
|
||||||
|
|
||||||
|
|
||||||
build_id() {
|
build_id() {
|
||||||
LANG=C readelf -n $1 | sed -n '/Build ID/ { s/.*: //p; q; }'
|
LANG=C readelf -n "$1" | sed -n '/Build ID/ { s/.*: //p; q; }'
|
||||||
|
}
|
||||||
|
|
||||||
|
source_files() {
|
||||||
|
LANG=C readelf "$1" --debug-dump | \
|
||||||
|
awk '/DW_AT_name +:/{name=$8}/DW_AT_comp_dir +:/{print $8 "/" name}'
|
||||||
}
|
}
|
||||||
|
|
||||||
strip_file() {
|
strip_file() {
|
||||||
|
@ -50,6 +55,18 @@ strip_file() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# copy source files to debug directory
|
||||||
|
local f t
|
||||||
|
while read -r f; do
|
||||||
|
t=${f/"$srcdir"/$dbgsrc}
|
||||||
|
mkdir -p "${t%/*}"
|
||||||
|
cp -- "$f" "$t"
|
||||||
|
done < <(source_files "$binary")
|
||||||
|
|
||||||
|
# adjust debug symbols to point at sources
|
||||||
|
debugedit -b "${srcdir}" -d /usr/src/debug/ -i "$binary" &> /dev/null
|
||||||
|
|
||||||
|
# copy debug symbols to debug directory
|
||||||
mkdir -p "$dbgdir/${binary%/*}"
|
mkdir -p "$dbgdir/${binary%/*}"
|
||||||
objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
|
objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
|
||||||
objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary"
|
objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary"
|
||||||
|
@ -88,8 +105,10 @@ tidy_strip() {
|
||||||
[[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
|
[[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
|
||||||
|
|
||||||
if check_option "debug" "y"; then
|
if check_option "debug" "y"; then
|
||||||
|
|
||||||
dbgdir="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@/usr/lib/debug"
|
dbgdir="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@/usr/lib/debug"
|
||||||
mkdir -p "$dbgdir"
|
dbgsrc="$pkgdirbase/$pkgbase-@DEBUGSUFFIX@/usr/src/debug"
|
||||||
|
mkdir -p "$dbgdir" "$dbgsrc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local binary strip_flags
|
local binary strip_flags
|
||||||
|
|
Loading…
Add table
Reference in a new issue