From 4c0e839be3f334a5ae82948d1261996935821f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sat, 7 Apr 2012 18:56:13 +0000 Subject: [PATCH] Add a gdb wrapper script that sets LD_LIBRARY_PATH and helps locate the actual binary. git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@583 185d5e19-27fe-0310-9dcf-9bff6b9f3609 --- configure.ac | 1 + pamgdb.in | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 pamgdb.in diff --git a/configure.ac b/configure.ac index 1cadc92..ae969f3 100644 --- a/configure.ac +++ b/configure.ac @@ -126,4 +126,5 @@ AC_CONFIG_FILES([ modules/pam_unix/Makefile t/Makefile ]) +AC_CONFIG_FILES([pamgdb],[chmod +x pamgdb]) AC_OUTPUT diff --git a/pamgdb.in b/pamgdb.in new file mode 100644 index 0000000..123801a --- /dev/null +++ b/pamgdb.in @@ -0,0 +1,41 @@ +#!/bin/sh +# +# $Id$ +# + +srcdir="@abs_top_srcdir@" +builddir="@abs_top_builddir@" + +# Make sure we get the right version of libpam +pam_libdir="${builddir}/lib/.libs" +LD_LIBRARY_PATH="${pam_libdir}:${LD_LIBRARY_PATH}" +LD_LIBRARY_PATH="${LD_LIBRARY_PATH%:}" +export LD_LIBRARY_PATH + +# DWIM, assuming that the first positional argument is the name of the +# program to debug rather than a gdb option. +prog="$1" +if expr "${prog}" : ".*/.*" >/dev/null ; then + # The first argument is an absolute or relative path. There + # is a good chance that it points to the wrapper script + # generated by libtool rather than the actual binary. + altprog="${prog%/*}/.libs/${prog##*/}" + if [ -x "${altprog}" ] ; then + shift + set "${altprog}" "$@" + fi +elif expr "${prog}" : "[a-z.-][a-z.-]*" >/dev/null ; then + # The first argument is just the name of the program. Look for + # it in the build directory. + for libdir in $(find "${builddir}" -type d -name .libs -print) ; do + altprog="${libdir}/${prog}" + if [ -x "${altprog}" ] ; then + shift + set "${altprog}" "$@" + break + fi + done +fi + +# Let's go! +exec gdb "$@"