Removed /system/bin prefix from gdbclient.

Now a program run through gdbclient will not automatically have
/system/bin added to its path, so programs not in /system/bin will no
longer need to be prefixed with ../../.

The following now works as an example:
 adb shell gdbserver :5039 /system/xbin/crasher
 bg
 gdbclient /system/xbin/crasher :5039 /system/xbin/crasher

And the following now no longer works:
 adb shell gdbserver :5039 /system/xbin/crasher
 bg
 gdbclient ../../system/xbin/crasher :5039 /system/xbin/crasher

Change-Id: I299b66d03915aeb1dc300e43a81c9a51f0bd7dec
diff --git a/envsetup.sh b/envsetup.sh
index 6c25ebe..9689cce 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -944,6 +944,11 @@
     $GDB_CMD -x "$@"
 }
 
+function get_symbols_directory()
+{
+    echo $(get_abs_build_var TARGET_OUT_UNSTRIPPED)
+}
+
 # process the symbolic link of /proc/$PID/exe and use the host file tool to
 # determine whether it is a 32-bit or 64-bit executable. It returns "" or "64"
 # which can be conveniently used as suffix.
@@ -951,14 +956,9 @@
 {
     local PID="$1"
     if [ "$PID" ] ; then
-        local EXE=`adb shell ls -l /proc/$PID/exe \
-                   | tr -d '\r' \
-                   | cut -d'>' -f2 \
-                   | tr -d ' ' \
-                   | cut -d'/' -f4`
-
-        local OUT_EXE_SYMBOLS=$(get_abs_build_var TARGET_OUT_EXECUTABLES_UNSTRIPPED)
-        local IS64BIT=`file $OUT_EXE_SYMBOLS/$EXE | grep "64-bit"`
+        local EXE=`adb shell readlink /proc/$PID/exe`
+        local EXE_DIR=`get_abs_build_var PRODUCT_OUT`
+        local IS64BIT=`file "$EXE_DIR$EXE" | grep "64-bit"`
         if [ "$IS64BIT" != "" ]; then
             echo "64"
         else
@@ -978,7 +978,7 @@
    local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED)
    local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)
    local OUT_VENDOR_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_VENDOR_SHARED_LIBRARIES_UNSTRIPPED)
-   local OUT_EXE_SYMBOLS=$(get_abs_build_var TARGET_OUT_EXECUTABLES_UNSTRIPPED)
+   local OUT_EXE_SYMBOLS=$(get_symbols_directory)
    local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS)
    local ARCH=$(get_build_var TARGET_ARCH)
    local GDB
@@ -1058,6 +1058,7 @@
        else
            WHICH_GDB=$ANDROID_TOOLCHAIN_2ND_ARCH/$GDB
        fi
+
        gdbwrapper $WHICH_GDB "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE"
   else
        echo "Unable to determine build system output dir."