解决了我一个大问题!!!
http://stackoverflow.com/questions/5048112/use-gdb-to-debug-a-c-program-called-from-a-shell-script
There are two options that you can do:
1) invoke GDB directly within the shell script. This would imply that you don't have standard in and standard out redirected.
2) run the shell script and then attach the debugger to the already running c++ process like so: gdb progname 1234 where 1234 is the process ID of the running c++ process.
If you need to do things before the program starts running then option 1 would be the better choice, otherwise option 2 is the cleaner way.
if test -f $ASHA_HOME/bin/hasocket; then #exec $ASHA_HOME/bin/hasocket $PRODUCT_HOME/bin/$EXE $* echo "$PRODUCT_HOME/bin/$EXE $*" gdb "$PRODUCT_HOME/bin/$EXE" else #exec $PRODUCT_HOME/bin/$EXE $* echo "$PRODUCT_HOME/bin/$EXE $*" gdb $PRODUCT_HOME/bin/$EXE fi