Run-test: Support using --gdb and --gdbserver with --chroot

--gdb and --gdbserver were unusable with --chroot due to --chroot
changing how dnslookup happened on device and differing symbol
directory setup.

This CL does the basic setup so that gdb can connect to the remote
program and (provided it is configured correctly) be used to debug it.

In order to get symbols one must set both the `solib-search-path` and
`solib-absolute-prefix` appropriately. See GDB documentation for more
information.

Test: ./test/run-test --gdbserver --chroot /data/local/art-test-chroot --64 001-HelloWorld
Change-Id: I598cb7654f5b8b669e1c658e25fb941c3d046666
diff --git a/tools/buildbot-build.sh b/tools/buildbot-build.sh
index b7b82cc..14d3544 100755
--- a/tools/buildbot-build.sh
+++ b/tools/buildbot-build.sh
@@ -76,7 +76,7 @@
   fi
   make_command="build/soong/soong_ui.bash --make-mode $j_arg $extra_args $showcommands build-art-target-tests $common_targets"
   make_command+=" libjavacrypto-target libnetd_client-target toybox toolbox sh"
-  make_command+=" debuggerd su"
+  make_command+=" debuggerd su gdbserver"
   make_command+=" libstdc++ "
   make_command+=" ${ANDROID_PRODUCT_OUT#"${ANDROID_BUILD_TOP}/"}/system/etc/public.libraries.txt"
   if [[ -n "$ART_TEST_CHROOT" ]]; then
@@ -131,4 +131,9 @@
   link_command="mkdir -p $(dirname "$link_name") && ln -sf com.android.art.testing \"$link_name\""
   echo "Executing $link_command"
   bash -c "$link_command"
+  find $ANDROID_PRODUCT_OUT/symbols/apex/com.android.runtime/bin -type f | while read target; do
+    cmd="ln -sf $target  $ANDROID_PRODUCT_OUT/symbols/system/bin/$(basename $target)"
+    echo "Executing $cmd"
+    bash -c "$cmd"
+  done
 fi