Add method tracing JVMTI callbacks

Add MethodEntryHook and MethodExitHook callbacks and associated
capabilities.

Split --jvmti-stress option in run-test into --jvmti-trace-stress and
--jvmti-redefine-stress to test each different component.

NB 3 differences from RI found:
  1) RI will call methodExitHook again if the method exit hook throws
     an exception. This can easily cause an infinite loop and the test
     is specifically tweaked to prevent this from happening on the RI.
  2) RI always includes the method being exited in the stack trace of
     errors thrown in the hooks. In ART we will not include the method
     if it is native. This is due to the way we call native methods
     and would be extremely difficult to change.
  3) The RI will allow exceptions thrown in the MethodEnterHook to be
     caught by the entered method in some situations. This occurs with
     the tryCatchExit test in 989. In ART this does not happen.

Bug: 34414073
Test: ./test.py --host -j40
Test: ART_TEST_FULL=true DEXTER_BINARY="/path/to/dexter" \
      ./test/testrunner/testrunner.py --host -j40 -t 988
Test: ART_TEST_FULL=true DEXTER_BINARY="/path/to/dexter" \
      ./test/testrunner/testrunner.py --host -j40 -t 989
Test: lunch aosp_angler-userdebug; \
      m -j40 droid build-art && \
      fastboot -w flashall && \
      ./test.py --target -j4

Change-Id: Iab229353fae23c2ea27c2b698c831627a9f861b1
diff --git a/test/knownfailures.json b/test/knownfailures.json
index dee3b8d..b1b767c 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -511,7 +511,7 @@
             "645-checker-abs-simd",
             "706-checker-scheduler"],
         "description": ["Checker tests are not compatible with jvmti."],
-        "variant": "jvmti-stress"
+        "variant": "jvmti-stress | redefine-stress | trace-stress"
     },
     {
         "tests": [
@@ -519,7 +519,7 @@
             "964-default-iface-init-gen"
         ],
         "description": ["Tests that just take too long with jvmti-stress"],
-        "variant": "jvmti-stress"
+        "variant": "jvmti-stress | redefine-stress | trace-stress"
     },
     {
         "tests": [
@@ -539,7 +539,7 @@
             "dexter/slicer."
         ],
         "bug": "b/37272822",
-        "variant": "jvmti-stress"
+        "variant": "jvmti-stress | redefine-stress"
     },
     {
         "tests": [
@@ -550,7 +550,7 @@
             "981-dedup-original-dex"
         ],
         "description": ["Tests that require exact knowledge of the number of plugins and agents."],
-        "variant": "jvmti-stress"
+        "variant": "jvmti-stress | redefine-stress | trace-stress"
     },
     {
         "tests": [
@@ -564,7 +564,7 @@
         "description": [
             "Tests that use illegal dex files or otherwise break dexter assumptions"
         ],
-        "variant": "jvmti-stress"
+        "variant": "jvmti-stress | redefine-stress"
     },
     {
         "tests": [
@@ -581,7 +581,7 @@
             "Tests that use custom class loaders or other features not supported ",
             "by our JVMTI implementation"
         ],
-        "variant": "jvmti-stress"
+        "variant": "jvmti-stress | redefine-stress"
     },
     {
         "tests": [
@@ -592,7 +592,7 @@
             "Tests that use annotations and debug data that is not kept around by dexter."
         ],
         "bug": "b/37239009",
-        "variant": "jvmti-stress"
+        "variant": "jvmti-stress | redefine-stress"
     },
     {
         "tests": [
@@ -701,6 +701,11 @@
         "env_vars": {"SANITIZE_HOST": "address"}
     },
     {
+        "tests": ["988-method-trace"],
+        "variant": "redefine-stress | jvmti-stress",
+        "description": "Test disabled due to redefine-stress disabling intrinsics which changes the trace output slightly."
+    },
+    {
         "tests": "137-cfi",
         "description": [ "ASan is reporting out-of-bounds reads in libunwind."],
         "variant": "host",