How to generate gcc debug symbol outside the build target?
2013-04-24 15:30
246 查看
You need to use objcopy to separate
the debug information:
I use the bash script below to separate the debug information into files with a .debug extension in a .debug directory. This way I can tar the libraries and executables in one tar file and the .debug directories in another. If I want to add the debug info later
on I simply extract the debug tar file and voila I have symbolic debug information.
This is the bash script:
the debug information:
objcopy --only-keep-debug "${tostripfile}" "${debugdir}/${debugfile}" strip --strip-debug --strip-unneeded "${tostripfile}" objcopy --add-gnu-debuglink="${debugdir}/${debugfile}" "${tostripfile}"
I use the bash script below to separate the debug information into files with a .debug extension in a .debug directory. This way I can tar the libraries and executables in one tar file and the .debug directories in another. If I want to add the debug info later
on I simply extract the debug tar file and voila I have symbolic debug information.
This is the bash script:
#!/bin/bash
scriptdir=`dirname ${0}`
scriptdir=`(cd ${scriptdir}; pwd)`
scriptname=`basename ${0}`
set -e
function errorexit()
{
errorcode=${1}
shift
echo $@
exit ${errorcode}
}
function usage()
{
echo "USAGE ${scriptname} <tostrip>"
}
tostripdir=`dirname "$1"`
tostripfile=`basename "$1"`
if [ -z ${tostripfile} ] ; then
usage
errorexit 0 "tostrip must be specified"
fi
cd "${tostripdir}"
debugdir=.debug
debugfile="${tostripfile}.debug"
if [ ! -d "${debugdir}" ] ; then
echo "creating dir ${tostripdir}/${debugdir}"
mkdir -p "${debugdir}"
fi
echo "stripping ${tostripfile}, putting debug info into ${debugfile}"
objcopy --only-keep-debug "${tostripfile}" "${debugdir}/${debugfile}" strip --strip-debug --strip-unneeded "${tostripfile}" objcopy --add-gnu-debuglink="${debugdir}/${debugfile}" "${tostripfile}"
chmod -x "${debugdir}/${debugfile}"
相关文章推荐
- How to generate gcc debug symbol outside the build target?
- How to Enable Trace or Debug for APIs executed as SQL Script Outside of the Applications ?
- How to Enable Trace or Debug for APIs executed as SQL Script Outside of the Applications ?
- How to Enable Trace or Debug for APIs executed as SQL Script Outside of the Applications ?
- How to build the GCC-4.3.3 in MinGW?
- How to Enable Trace or Debug for APIs executed as SQL Script Outside of the Applications ?
- How to generate DLL files by GCC in the MinGW?
- The Linux GCC HOWTO中译版V0.2
- How to use GCC to build DLL by DEF file in MinGW?
- How_to_build_an_ARM/DSP_Hello_World_program_on_the_DaVinci_EVM
- [MSDN] How to Debug a Release Build
- How to generate an GL debug log file
- How to build parport related driver upon parport module in the kernel
- How to Integrate the Zend Debug with Zend Eclipse-PHP (PDT) and XAMPP
- How to generate links to the android Classes' reference in javadoc?
- How To Build GCC 4.8.2 ARM Cross-Compiler
- [Angular 2] How To Debug An Angular 2 Application - Debugging via Augury or the Console
- How to use the xsd generator generate the class
- How to debug the exception
- How to Build an High Availability MQTT Cluster for the Internet of Things