Make it easier to run libjdwp.so as debugger for run-test

Adds a --debug-agent argument to run test that allows one to specify
the path for a debugger JVMTI agent. Also adds a --debug-wrap-agent
option that makes the agent specified by --debug-agent use
libwrapagentproperties to ensure compatibility.

Currently this only supports host use.

Also refactored JVMTI plugin loading slightly since it was getting
to be required by a large number of different options.

Test: ./test/run-test \
         --debug-agent $ANDROID_JAVA_HOME/jre/lib/amd64/libjdwp.so \
         --debug-wrap-agent \
         --64 \
         --host \
         001-HelloWorld

Bug: 67752243

Change-Id: Ie0b38999826cc09651a6d100be6acccf79e706dc
diff --git a/test/run-test b/test/run-test
index d04cd05..09a70e5 100755
--- a/test/run-test
+++ b/test/run-test
@@ -288,6 +288,14 @@
     elif [ "x$1" = "x--debug" ]; then
         run_args="${run_args} --debug"
         shift
+    elif [ "x$1" = "x--debug-wrap-agent" ]; then
+        run_args="${run_args} --debug-wrap-agent"
+        shift
+    elif [ "x$1" = "x--debug-agent" ]; then
+        shift
+        option="$1"
+        run_args="${run_args} --debug-agent $1"
+        shift
     elif [ "x$1" = "x--gdb" ]; then
         run_args="${run_args} --gdb"
         dev_mode="yes"
@@ -647,7 +655,12 @@
         echo "    -Xcompiler-option     Pass an option to the compiler."
         echo "    --build-option        Pass an option to the build script."
         echo "    --runtime-option      Pass an option to the runtime."
-        echo "    --debug               Wait for a debugger to attach."
+        echo "    --debug               Wait for the default debugger to attach."
+        echo "    --debug-agent <agent-path>"
+        echo "                          Wait for the given debugger agent to attach. Currently"
+        echo "                          only supported on host."
+        echo "    --debug-wrap-agent    use libwrapagentproperties and tools/libjdwp-compat.props"
+        echo "                          to load the debugger agent specified by --debug-agent."
         echo "    --debuggable          Whether to compile Java code for a debugger."
         echo "    --gdb                 Run under gdb; incompatible with some tests."
         echo "    --gdb-arg             Pass an option to gdb."