www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/02/18/11:48:31

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,TW_BJ,TW_CP,TW_CV,TW_DB,TW_GP,TW_JC,TW_KG,TW_YG
X-Spam-Check-By: sourceware.org
Message-ID: <4F3FD634.7060503@dronecode.org.uk>
Date: Sat, 18 Feb 2012 16:47:48 +0000
From: Jon TURNEY <jon DOT turney AT dronecode DOT org DOT uk>
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: add -debuginfo packages
References: <6910a60908041158p10fa632cvc2f21524e33b74ce AT mail DOT gmail DOT com> <4A8DDEE8 DOT 2050606 AT users DOT sourceforge DOT net>
In-Reply-To: <4A8DDEE8.2050606@users.sourceforge.net>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------080005030007050706010906
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On 21/08/2009 00:40, Yaakov (Cygwin/X) wrote:
> On 04/08/2009 13:58, Reini Urban wrote:
>> Rather than stripping our exe's and dll's I suggest to strip the debug
>> info into
>> seperate /usr/lib/debug/path/file.dbg and package them seperately in -debuginfo
>> packages such as with fedora.

FWIW, attached is the patch I've been using to do this, based on Reini's
patch, updated to address some of your concerns.

This can, as you suggested, strip the symbols to a location outside of ${D}
and create a single debuginfo package containing those symbols for each cygport.

I know that support for these packages in upset and setup has been rejected by
cgf, but it's still useful to me to keep the debuginfo for the packaged builds
of Xwin around.

> 1) Right now, cygport default CFLAGS="-O2 -pipe".  Adding -g is easy enough,
> but how will -O2 affect the debug info?  (We really don't want to use -O0 for
> distro packages, do we?)

The debug info can correctly reflect optimizations that have taken place (e.g.
variables that have been optimized out or source lines that have been become
interleaved)

> 2) I know that on Linux, -fomit-frame-pointer breaks debugging on x86 (but not
> on amd64 or other arches).  Some packages add this themselves for
> optimization, and some outright need it for their asm code (ffmpeg comes to
> mind).  We then have a question of performance vs. debugging, so if you can
> only have one, which takes priority?
> 
> 3) Is using /usr/lib/debug feasible?  I've only ever seen .dbg files placed in
> the same directory as the .exe/.dll.

gdb seems to know to look in /usr/lib/debug/<pathname> for the symbols for
<pathname>.

--------------080005030007050706010906
Content-Type: text/plain;
 name="0001-Add-the-ability-to-preseve-debug-information-in-a-se.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0001-Add-the-ability-to-preseve-debug-information-in-a-se.pa";
 filename*1="tch"

From de7c4824c7d839ff4deacf0772c27de46a753b56 Mon Sep 17 00:00:00 2001
From: Jon TURNEY <jon DOT turney AT dronecode DOT org DOT uk>
Date: Wed, 11 Jan 2012 14:45:09 +0000
Subject: [PATCH] Add the ability to preseve debug information in a separate
 debuginfo archive

based on a patch by Reini Urban
http://cygwin.com/ml/cygwin/2009-08/msg00124.html

If _CYGPORT_RESTRICT_debug_ is defined, instead of stripping executable files,
split the debug info into .dbg files placed into /usr/lib/debug, and then
assemble those files into a debuginfo archive.

Signed-off-by: Jon TURNEY <jon DOT turney AT dronecode DOT org DOT uk>
---
 bin/cygport.in           |    5 ++++-
 lib/pkg_pkg.cygpart      |   14 +++++++++++++-
 lib/src_postinst.cygpart |   29 +++++++++++++++++++++++++++--
 lib/src_prep.cygpart     |    2 +-
 4 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/bin/cygport.in b/bin/cygport.in
index a3625bb..2b754a5 100755
--- a/bin/cygport.in
+++ b/bin/cygport.in
@@ -460,6 +460,7 @@ declare -r logdir="${workdir}/log";
 declare -r patchdir="${workdir}/patch";
 declare -r spkgdir="${workdir}/spkg";
 declare -r distdir="${workdir}/dist";
+declare -r dbgdir="${workdir}/dbg";
 
 SRC_DIR=${SRC_DIR:-${ORIG_PN:-${PN}}-${PV}};
 if [ "x${SRC_DIR}" = "x." ]
@@ -530,6 +531,8 @@ declare -r src_patchfile=${PF}.src.patch;
 declare -ar pkg_name=(${PKG_NAMES:-${PN}});
 declare -r  pkg_count=${#pkg_name[*]};
 
+declare -r dbgpath=/usr/lib/debug
+
 ################################################################################
 #
 # Command processing
@@ -593,7 +596,7 @@ do
 		package|pkg)
 			__stage Packaging;
 			__log_init ${pkglog};
-			(__pkg_binpkg && __pkg_pkgcheck && __pkg_srcpkg && __pkg_dist) 2>&1 | tee -a ${pkglog};
+			(__pkg_binpkg && __pkg_pkgcheck && __pkg_srcpkg && __pkg_dbgpkg && __pkg_dist) 2>&1 | tee -a ${pkglog};
 			_status=$?;
 			;;
 		diff|mkdiff|mkpatch)
diff --git a/lib/pkg_pkg.cygpart b/lib/pkg_pkg.cygpart
index e4df744..1cac55c 100644
--- a/lib/pkg_pkg.cygpart
+++ b/lib/pkg_pkg.cygpart
@@ -399,5 +399,17 @@ __pkg_dist() {
 	fi
 }
 
+__pkg_dbgpkg() {
+        if defined _CYGPORT_RESTRICT_debug_
+        then
+
+		echo;
+                __step "Creating debuginfo package";
+
+                cd ${dbgdir};
+                tar jcvf ${top}/${PF}-debuginfo.tar.bz2 * || error "Debuginfo package creation failed"
+        fi
+}
+
 # protect functions
-readonly -f __pkg_binpkg __pkg_diff __gpg_sign __pkg_srcpkg __pkg_dist
+readonly -f __pkg_dbgpkg __pkg_binpkg __pkg_diff __gpg_sign __pkg_srcpkg __pkg_dist
diff --git a/lib/src_postinst.cygpart b/lib/src_postinst.cygpart
index afc97b6..0582985 100644
--- a/lib/src_postinst.cygpart
+++ b/lib/src_postinst.cygpart
@@ -542,7 +542,13 @@ __prepstrip() {
 
 	cd ${D};
 
-	echo "Stripping executables:";
+	if defined _CYGPORT_RESTRICT_debug_
+	then
+	        echo "Creating debug files, stripping executables and adding debuglink:";
+	        rm -fr ${dbgdir}/*;
+	else
+		echo "Stripping executables:";
+	fi
 
 	# *.so: Apache2 modules, OCaml stublibs, Ruby modules
 	# *.oct: Octave modules
@@ -609,7 +615,26 @@ __prepstrip() {
 
 		echo "        ${exe}";
 		chmod 0755 ${exe};
-		${strip} ${exe};
+
+		# ensure this is actually a PE-COFF object
+		if ${OBJDUMP} -f ${exe} &>/dev/null
+		then
+                    if defined _CYGPORT_RESTRICT_debug_
+                    then
+                        pathname=$(dirname ${exe})
+                        dbg=$(basename ${exe%.*}).dbg
+                        mkdir -p ${dbgdir}${dbgpath}/${pathname}
+                        # objcopy requires the file we are debuglinking with exists, so make it here and then move it under ${dbgdir}
+                        # gdb has the intelligence to look in ${dbgpath}/${pathname}/ for the .dbg file, so we don't need to give the full path
+                        objcopy --only-keep-debug ${exe} ${dbg}
+                        objcopy --strip-debug ${exe}
+                        objcopy --add-gnu-debuglink=${dbg} ${exe}
+                        mv ${dbg} ${dbgdir}${dbgpath}/${pathname}/
+                    else
+		        ${strip} ${exe};
+                    fi
+		fi
+
 	done
 }
 
diff --git a/lib/src_prep.cygpart b/lib/src_prep.cygpart
index 5d64408..59d4f24 100644
--- a/lib/src_prep.cygpart
+++ b/lib/src_prep.cygpart
@@ -198,7 +198,7 @@ __gpg_verify() {
 
 __mkdirs() {
 	cd ${top};
-	mkdir -p ${srcdir} ${origsrcdir} ${B} ${D} ${T} ${configdir} ${logdir} ${distdir} ${patchdir} ${spkgdir};
+	mkdir -p ${srcdir} ${origsrcdir} ${B} ${D} ${T} ${configdir} ${logdir} ${distdir} ${patchdir} ${spkgdir} ${dbgdir};
 }
 
 cygpatch() {
-- 
1.7.5.1



--------------080005030007050706010906
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--------------080005030007050706010906--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019