5 # Copyright (C) 1997 Free Software Foundation, Inc.
7 # Author: Ovidiu Predescu <ovidiu@net-community.com>
10 # This file is part of the GNUstep Makefile Package.
12 # This library is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
17 # You should have received a copy of the GNU General Public
18 # License along with this library; see the file COPYING.LIB.
19 # If not, write to the Free Software Foundation,
20 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 # Execute gdb for the application passed as argument. The application is
23 # searched through the GNUstep directories if a complete or relative path name
24 # is not specified. The arguments passed after the application name are passed
25 # unmodified to the application.
28 echo usage: `basename "$0"` [--library-combo=...] [--gdb=...] application [arguments...]
29 echo `basename "$0"` --help for help
33 if [ -z "$EXEEXT" ]; then
36 if [ -z "$LIBRARY_COMBO" ]; then
37 LIBRARY_COMBO=@ac_cv_library_combo@
39 if [ -z "$GDB" ]; then
43 # Read command line arguments now
44 while [ x"$1" != x ]; do
47 echo usage: `basename "$0"` [--library-combo=...] [--gbd=...] application [arguments...]
49 echo [--library-combo=...] specifies a GNUstep backend to use.
50 echo It overrides the default LIBRARY_COMBO environment variable.
51 echo --library-combo=gnu for GNUstep
52 echo --library-combo=nx for NeXT OPENSTEP
53 echo --library-combo=apple for Apple OSX
55 echo [--gdb=...] specifies the debugger to use.
56 echo It overrides the default GDB environment variable. If the --gdb=...
57 echo flag is not used, and the GDB variable is not set, then the program
58 echo called \"gdb\" is invoked.
60 echo application is the complete or relative name of the application
61 echo program with the .app or .debug extension, like Edit.debug.
63 echo [arguments...] are the arguments to the application.
68 LIBRARY_COMBO=`echo "$1" | sed 's/--library-combo=//'`
72 GDB=`echo "$1" | sed 's/--gdb=//'`
81 if [ "$LIBRARY_COMBO" = nx ]; then
82 LIBRARY_COMBO=nx-nx-nx
83 elif [ "$LIBRARY_COMBO" = gnu ]; then
84 LIBRARY_COMBO=gnu-gnu-gnu
85 elif [ "$LIBRARY_COMBO" = fd ]; then
87 elif [ "$LIBRARY_COMBO" = apple ]; then
88 LIBRARY_COMBO=apple-apple-apple
91 # Remove leading slashes at the end of the application name
92 app="`echo \"$app\" | sed 's%/*$%%'`"
95 /*) # An absolute path.
97 */*) # A relative path
98 full_appname="`(cd \"$app\"; pwd)`";;
99 *) # A path that should be searched into the GNUstep paths
100 if [ -n "$GNUSTEP_PATHLIST" ]; then
101 SPATH="$GNUSTEP_PATHLIST"
107 for dir in $SPATH; do
108 if [ -d "$dir/Applications/$app" ]; then
109 full_appname="`(cd \"$dir/Applications/$app\"; pwd)`"
112 if [ -d "$dir/$app" ]; then
113 full_appname="`(cd \"$dir/$app\"; pwd)`"
119 # Search for a core file in the current directory.
122 for corefile in $corefiles; do
123 if [ -f "$corefile" ]; then
124 echo -e "Core image ($corefile) has been found in working directory. Use it (y/n)? ";
125 # Need an argument here for Solaris
127 if [ $REPLY = y ]; then
129 corearg="--core=$corefile";
132 echo -e "Ignoring it.";
139 if [ -z "$full_appname" ]; then
140 echo "Can't find the required application: $app!"
144 if [ -z "$GNUSTEP_FLATTENED" ]; then
146 # Determine the host information
148 if [ -z "$GNUSTEP_HOST" ]; then
149 GNUSTEP_HOST=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/config.guess`
150 GNUSTEP_HOST=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/config.sub $GNUSTEP_HOST`
153 if [ -z "$GNUSTEP_HOST_CPU" ]; then
154 GNUSTEP_HOST_CPU=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/cpu.sh $GNUSTEP_HOST`
155 GNUSTEP_HOST_CPU=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/clean_cpu.sh $GNUSTEP_HOST_CPU`
156 export GNUSTEP_HOST_CPU
158 if [ -z "$GNUSTEP_HOST_VENDOR" ]; then
159 GNUSTEP_HOST_VENDOR=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/vendor.sh $GNUSTEP_HOST`
160 GNUSTEP_HOST_VENDOR=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/clean_vendor.sh $GNUSTEP_HOST_VENDOR`
161 export GNUSTEP_HOST_VENDOR
163 if [ -z "$GNUSTEP_HOST_OS" ]; then
164 GNUSTEP_HOST_OS=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/os.sh $GNUSTEP_HOST`
165 GNUSTEP_HOST_OS=`$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/clean_os.sh $GNUSTEP_HOST_OS`
166 export GNUSTEP_HOST_OS
169 if [ "$LIBRARY_COMBO" = nx-nx-nx -a "$GNUSTEP_HOST_OS" = nextstep4 ]; then
170 if [ -f "$full_appname/library_paths.openapp" ]; then
171 additional_library_paths="`cat \"$full_appname/library_paths.openapp\"`"
175 if [ -f "$full_appname/library_paths.openapp" ]; then
176 additional_library_paths="`cat \"$full_appname/library_paths.openapp\"`"
180 appname="`echo \"$app\" | sed 's/\.[a-z]*$//'`"
181 appname="`basename \"$appname\"`"
182 appname="$appname$EXEEXT"
183 . "$GNUSTEP_SYSTEM_ROOT/@MAKEFILES_SUFFIX@/ld_lib_path.sh"
186 if [ "$LIBRARY_COMBO" = "apple-apple-apple" ]; then
187 if [ ! -f "$full_appname/Contents/MacOS/$appname" ]; then
188 echo "$full_appname application does not have a binary for this kind of machine and operating system."
192 if [ -z "$corearg" ]; then
193 "$GDB" "$full_appname/Contents/MacOS/$appname"
195 "$GDB" "$full_appname/Contents/MacOS/$appname" "$corearg"
199 # Determine if the application has a binary for this operating system
200 if [ -z "$GNUSTEP_FLATTENED" -a ! -d "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS" ]; then
201 echo "$full_appname application does not have a binary for this kind of machine and operating system."
205 if [ -z "$GNUSTEP_FLATTENED" -a ! -d "$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO" ]; then
206 echo "$full_appname application does not have a binary for this combination of libraries: $LIBRARY_COMBO."
210 if [ -z "$GNUSTEP_FLATTENED" ]; then
211 file_appname="$full_appname/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO/$appname"
213 file_appname="$full_appname/$appname"
216 # Old versions of gdb don't support --args, so we only use it if
217 # 'gdb --help' lists it.
219 if (gdb --help | grep -e '\-\-args' > /dev/null); then
223 if [ -z "$corearg" ]; then
225 # Arguments passed to debugapp are passed over to the
226 # application, in the same way as it happens for openapp.
227 "$GDB" $args "$file_appname" "$@"
229 "$GDB" "$file_appname" "$corearg"