[pacman-dev] [PATCH] [RFC] Provide source files for useful debug packages
Allan McRae
allan at archlinux.org
Thu Sep 1 07:01:42 UTC 2016
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 at archlinux.org>
---
This is a first pass at making debug packages useful...
Some things I want comments on:
1) It feels dirty depending on an RPM tool for adjusting the paths
inside ELF binaries, but I don't see any other choice. Suggestions
welcome
2) Getting the list of src files from the binary involves an awk
that works... but I don't know how! Can someone better at awk
than me take a look and confirm I have not done something wrong
3) split packages... I need to figure out how to support these
as source files will overlap. My current idea is to order the
packaging by dependency chain so that e.g gcc-libs comes before
gcc which comes before gcc-fortran. Then gcc-debug will not include
files from gcc-libs-debug, and gcc-fortran-debug will not include
files in either of those. I hope that would remove most file
conflicts across packages.
scripts/libmakepkg/tidy/strip.sh.in | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in
index 1c7aacf..bd5c79a 100644
--- a/scripts/libmakepkg/tidy/strip.sh.in
+++ b/scripts/libmakepkg/tidy/strip.sh.in
@@ -35,6 +35,11 @@ build_id() {
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() {
local binary=$1; shift
@@ -50,6 +55,18 @@ strip_file() {
return
fi
+ # copy source files to debug directory
+ local f t
+ for f in $(source_files "$binary"); do
+ t=${f/$srcdir/$dbgsrc}
+ mkdir -p "${t%/*}"
+ cp "$f" "$t"
+ done
+
+ # 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%/*}"
objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary"
@@ -89,7 +106,8 @@ tidy_strip() {
if check_option "debug" "y"; then
dbgdir="$pkgdir- at DEBUGSUFFIX@/usr/lib/debug"
- mkdir -p "$dbgdir"
+ dbgsrc="$pkgdir- at DEBUGSUFFIX@/usr/src/debug"
+ mkdir -p "$dbgdir" "$dbgsrc"
fi
local binary strip_flags
--
2.9.3
More information about the pacman-dev
mailing list