1997-10-20 15:53:51 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-05-02 15:07:49 +00:00
|
|
|
# @configure_input@
|
|
|
|
#
|
1997-10-20 15:53:51 +00:00
|
|
|
# Copyright (C) 1997 Free Software Foundation, Inc.
|
|
|
|
#
|
|
|
|
# Author: Ovidiu Predescu <ovidiu@net-community.com>
|
|
|
|
# Date: October 1997
|
|
|
|
#
|
|
|
|
# This file is part of the GNUstep Makefile Package.
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public
|
|
|
|
# License along with this library; see the file COPYING.LIB.
|
|
|
|
# If not, write to the Free Software Foundation,
|
2005-05-22 03:20:14 +00:00
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1997-10-20 15:53:51 +00:00
|
|
|
|
|
|
|
# Execute gdb for the application passed as argument. The application is
|
|
|
|
# searched through the GNUstep directories if a complete or relative path name
|
|
|
|
# is not specified. The arguments passed after the application name are passed
|
|
|
|
# unmodified to the application.
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
2003-12-26 16:58:22 +00:00
|
|
|
echo usage: `basename "$0"` [--library-combo=...] [--gdb=...] application [arguments...]
|
2003-05-14 15:10:22 +00:00
|
|
|
echo `basename "$0"` --help for help
|
1997-10-20 15:53:51 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
1998-12-07 16:23:04 +00:00
|
|
|
if [ -z "$EXEEXT" ]; then
|
1998-12-07 16:54:26 +00:00
|
|
|
EXEEXT=@EXEEXT@
|
1998-12-07 16:23:04 +00:00
|
|
|
fi
|
1998-09-03 14:35:49 +00:00
|
|
|
if [ -z "$LIBRARY_COMBO" ]; then
|
1998-08-20 17:48:46 +00:00
|
|
|
LIBRARY_COMBO=@ac_cv_library_combo@
|
|
|
|
fi
|
1999-10-24 03:16:19 +00:00
|
|
|
if [ -z "$GDB" ]; then
|
|
|
|
GDB=gdb
|
|
|
|
fi
|
1997-10-20 15:53:51 +00:00
|
|
|
|
2003-12-26 16:58:22 +00:00
|
|
|
# Read command line arguments now
|
|
|
|
while [ x"$1" != x ]; do
|
|
|
|
case "$1" in
|
|
|
|
--help)
|
|
|
|
echo usage: `basename "$0"` [--library-combo=...] [--gbd=...] application [arguments...]
|
|
|
|
echo
|
|
|
|
echo [--library-combo=...] specifies a GNUstep backend to use.
|
|
|
|
echo It overrides the default LIBRARY_COMBO environment variable.
|
|
|
|
echo --library-combo=gnu for GNUstep
|
|
|
|
echo --library-combo=nx for NeXT OPENSTEP
|
|
|
|
echo --library-combo=apple for Apple OSX
|
|
|
|
echo
|
|
|
|
echo [--gdb=...] specifies the debugger to use.
|
|
|
|
echo It overrides the default GDB environment variable. If the --gdb=...
|
|
|
|
echo flag is not used, and the GDB variable is not set, then the program
|
|
|
|
echo called \"gdb\" is invoked.
|
|
|
|
echo
|
|
|
|
echo application is the complete or relative name of the application
|
|
|
|
echo program with the .app or .debug extension, like Edit.debug.
|
|
|
|
echo
|
|
|
|
echo [arguments...] are the arguments to the application.
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--library-combo=*)
|
|
|
|
LIBRARY_COMBO=`echo "$1" | sed 's/--library-combo=//'`
|
|
|
|
shift;;
|
|
|
|
|
|
|
|
--gdb=*)
|
|
|
|
GDB=`echo "$1" | sed 's/--gdb=//'`
|
|
|
|
shift;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
app="$1";
|
|
|
|
shift;;
|
|
|
|
esac
|
|
|
|
done
|
1997-10-20 15:53:51 +00:00
|
|
|
|
1997-11-14 19:45:02 +00:00
|
|
|
if [ "$LIBRARY_COMBO" = nx ]; then
|
2001-04-13 19:49:16 +00:00
|
|
|
LIBRARY_COMBO=nx-nx-nx
|
|
|
|
elif [ "$LIBRARY_COMBO" = gnu ]; then
|
|
|
|
LIBRARY_COMBO=gnu-gnu-gnu
|
|
|
|
elif [ "$LIBRARY_COMBO" = fd ]; then
|
|
|
|
LIBRARY_COMBO=gnu-fd
|
2002-12-30 16:29:55 +00:00
|
|
|
elif [ "$LIBRARY_COMBO" = apple ]; then
|
|
|
|
LIBRARY_COMBO=apple-apple-apple
|
1997-11-14 19:45:02 +00:00
|
|
|
fi
|
|
|
|
|
1997-10-20 15:53:51 +00:00
|
|
|
# Remove leading slashes at the end of the application name
|
2003-05-14 15:10:22 +00:00
|
|
|
app="`echo \"$app\" | sed 's%/*$%%'`"
|
1997-10-20 15:53:51 +00:00
|
|
|
|
2003-05-14 15:10:22 +00:00
|
|
|
case "$app" in
|
1997-10-20 15:53:51 +00:00
|
|
|
/*) # An absolute path.
|
2003-05-14 15:10:22 +00:00
|
|
|
full_appname="$app";;
|
1997-10-20 15:53:51 +00:00
|
|
|
*/*) # A relative path
|
2003-05-14 15:10:22 +00:00
|
|
|
full_appname="`(cd \"$app\"; pwd)`";;
|
1997-10-20 15:53:51 +00:00
|
|
|
*) # A path that should be searched into the GNUstep paths
|
2003-05-14 15:10:22 +00:00
|
|
|
if [ -n "$GNUSTEP_PATHLIST" ]; then
|
|
|
|
SPATH="$GNUSTEP_PATHLIST"
|
1999-06-02 03:16:12 +00:00
|
|
|
else
|
2003-05-14 15:10:22 +00:00
|
|
|
SPATH="$PATH"
|
1999-06-02 03:16:12 +00:00
|
|
|
fi
|
2003-05-14 15:10:22 +00:00
|
|
|
SPATH=".:$SPATH"
|
1997-10-20 15:53:51 +00:00
|
|
|
IFS=:
|
|
|
|
for dir in $SPATH; do
|
2003-05-14 15:10:22 +00:00
|
|
|
if [ -d "$dir/Applications/$app" ]; then
|
|
|
|
full_appname="`(cd \"$dir/Applications/$app\"; pwd)`"
|
1997-10-20 15:53:51 +00:00
|
|
|
break;
|
|
|
|
fi
|
2003-05-14 15:10:22 +00:00
|
|
|
if [ -d "$dir/$app" ]; then
|
|
|
|
full_appname="`(cd \"$dir/$app\"; pwd)`"
|
1999-06-11 21:10:35 +00:00
|
|
|
break;
|
|
|
|
fi
|
1997-10-20 15:53:51 +00:00
|
|
|
done;;
|
|
|
|
esac
|
|
|
|
|
2003-07-21 09:40:04 +00:00
|
|
|
# Search for a core file in the current directory.
|
|
|
|
corearg=
|
|
|
|
corefiles="core*"
|
|
|
|
for corefile in $corefiles; do
|
|
|
|
if [ -f "$corefile" ]; then
|
|
|
|
echo -e "Core image ($corefile) has been found in working directory. Use it (y/n)? ";
|
|
|
|
# Need an argument here for Solaris
|
|
|
|
read REPLY;
|
|
|
|
if [ $REPLY = y ]; then
|
|
|
|
echo -e "Using it.";
|
|
|
|
corearg="--core=$corefile";
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
echo -e "Ignoring it.";
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
unset corefile
|
|
|
|
unset corefiles
|
1999-10-16 05:20:52 +00:00
|
|
|
|
1997-10-20 15:53:51 +00:00
|
|
|
if [ -z "$full_appname" ]; then
|
|
|
|
echo "Can't find the required application: $app!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2005-10-12 20:45:14 +00:00
|
|
|
if [ -z "$GNUSTEP_MAKEFILES" ]; then
|
|
|
|
GNUSTEP_MAKEFILES = $GNUSTEP_SYSTEM_ROOT/Library/Makefiles
|
|
|
|
fi
|
|
|
|
|
2001-01-16 03:17:45 +00:00
|
|
|
if [ -z "$GNUSTEP_FLATTENED" ]; then
|
|
|
|
#
|
|
|
|
# Determine the host information
|
|
|
|
#
|
|
|
|
if [ -z "$GNUSTEP_HOST" ]; then
|
2005-10-12 20:45:14 +00:00
|
|
|
GNUSTEP_HOST=`$GNUSTEP_MAKEFILES/config.guess`
|
|
|
|
GNUSTEP_HOST=`$GNUSTEP_MAKEFILES/config.sub $GNUSTEP_HOST`
|
2001-01-16 03:17:45 +00:00
|
|
|
export GNUSTEP_HOST
|
|
|
|
fi
|
|
|
|
if [ -z "$GNUSTEP_HOST_CPU" ]; then
|
2005-10-12 20:45:14 +00:00
|
|
|
GNUSTEP_HOST_CPU=`$GNUSTEP_MAKEFILES/cpu.sh $GNUSTEP_HOST`
|
|
|
|
GNUSTEP_HOST_CPU=`$GNUSTEP_MAKEFILES/clean_cpu.sh $GNUSTEP_HOST_CPU`
|
2001-01-16 03:17:45 +00:00
|
|
|
export GNUSTEP_HOST_CPU
|
|
|
|
fi
|
|
|
|
if [ -z "$GNUSTEP_HOST_VENDOR" ]; then
|
2005-10-12 20:45:14 +00:00
|
|
|
GNUSTEP_HOST_VENDOR=`$GNUSTEP_MAKEFILES/vendor.sh $GNUSTEP_HOST`
|
|
|
|
GNUSTEP_HOST_VENDOR=`$GNUSTEP_MAKEFILES/clean_vendor.sh $GNUSTEP_HOST_VENDOR`
|
2001-01-16 03:17:45 +00:00
|
|
|
export GNUSTEP_HOST_VENDOR
|
|
|
|
fi
|
|
|
|
if [ -z "$GNUSTEP_HOST_OS" ]; then
|
2005-10-12 20:45:14 +00:00
|
|
|
GNUSTEP_HOST_OS=`$GNUSTEP_MAKEFILES/os.sh $GNUSTEP_HOST`
|
|
|
|
GNUSTEP_HOST_OS=`$GNUSTEP_MAKEFILES/clean_os.sh $GNUSTEP_HOST_OS`
|
2001-01-16 03:17:45 +00:00
|
|
|
export GNUSTEP_HOST_OS
|
|
|
|
fi
|
|
|
|
|
2003-05-14 15:10:22 +00:00
|
|
|
if [ "$LIBRARY_COMBO" = nx-nx-nx -a "$GNUSTEP_HOST_OS" = nextstep4 ]; then
|
2001-01-16 03:17:45 +00:00
|
|
|
if [ -f "$full_appname/library_paths.openapp" ]; then
|
2003-05-14 15:10:22 +00:00
|
|
|
additional_library_paths="`cat \"$full_appname/library_paths.openapp\"`"
|
2001-01-16 03:17:45 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
1997-11-17 22:55:20 +00:00
|
|
|
if [ -f "$full_appname/library_paths.openapp" ]; then
|
2003-05-14 15:10:22 +00:00
|
|
|
additional_library_paths="`cat \"$full_appname/library_paths.openapp\"`"
|
1997-11-17 22:55:20 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2003-05-14 15:10:22 +00:00
|
|
|
appname="`echo \"$app\" | sed 's/\.[a-z]*$//'`"
|
|
|
|
appname="`basename \"$appname\"`"
|
2002-03-26 17:36:57 +00:00
|
|
|
appname="$appname$EXEEXT"
|
2005-10-12 20:45:14 +00:00
|
|
|
. "$GNUSTEP_MAKEFILES/ld_lib_path.sh"
|
1997-10-20 15:53:51 +00:00
|
|
|
|
1997-10-30 19:06:58 +00:00
|
|
|
|
2004-03-08 14:02:12 +00:00
|
|
|
if [ "$LIBRARY_COMBO" = "apple-apple-apple" ]; then
|
|
|
|
if [ ! -f "$full_appname/Contents/MacOS/$appname" ]; then
|
1997-10-20 15:53:51 +00:00
|
|
|
echo "$full_appname application does not have a binary for this kind of machine and operating system."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2004-03-08 14:02:12 +00:00
|
|
|
if [ -z "$corearg" ]; then
|
|
|
|
"$GDB" "$full_appname/Contents/MacOS/$appname"
|
|
|
|
else
|
|
|
|
"$GDB" "$full_appname/Contents/MacOS/$appname" "$corearg"
|
|
|
|
fi
|
1997-10-20 15:53:51 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
# Determine if the application has a binary for this operating system
|
2003-05-14 15:10:22 +00:00
|
|
|
if [ -z "$GNUSTEP_FLATTENED" -a ! -d "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS" ]; then
|
1997-10-20 15:53:51 +00:00
|
|
|
echo "$full_appname application does not have a binary for this kind of machine and operating system."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2003-05-14 15:10:22 +00:00
|
|
|
if [ -z "$GNUSTEP_FLATTENED" -a ! -d "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO" ]; then
|
1997-11-14 19:45:02 +00:00
|
|
|
echo "$full_appname application does not have a binary for this combination of libraries: $LIBRARY_COMBO."
|
1997-10-20 15:53:51 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2004-03-08 14:02:12 +00:00
|
|
|
if [ -z "$GNUSTEP_FLATTENED" ]; then
|
|
|
|
file_appname="$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO/$appname"
|
1997-10-30 19:06:58 +00:00
|
|
|
else
|
2004-03-08 14:02:12 +00:00
|
|
|
file_appname="$full_appname/$appname"
|
|
|
|
fi
|
2003-07-21 09:29:05 +00:00
|
|
|
|
2004-03-08 14:02:12 +00:00
|
|
|
# Old versions of gdb don't support --args, so we only use it if
|
|
|
|
# 'gdb --help' lists it.
|
|
|
|
args=
|
2004-06-01 14:45:46 +00:00
|
|
|
if (gdb --help | grep -e '\-\-args' > /dev/null); then
|
2004-03-08 14:02:12 +00:00
|
|
|
args="--args"
|
1997-10-30 19:06:58 +00:00
|
|
|
fi
|
1997-10-20 15:53:51 +00:00
|
|
|
|
2004-03-08 14:02:12 +00:00
|
|
|
if [ -z "$corearg" ]; then
|
|
|
|
|
|
|
|
# Arguments passed to debugapp are passed over to the
|
|
|
|
# application, in the same way as it happens for openapp.
|
|
|
|
"$GDB" $args "$file_appname" "$@"
|
|
|
|
else
|
|
|
|
"$GDB" "$file_appname" "$corearg"
|
|
|
|
fi
|
2003-10-24 22:53:56 +00:00
|
|
|
fi
|