Add a native method dalvik.system.VMDebug.infopoint(int id).
With gdb, the JIT can use it to inspect the VM state when an instrumented line
is reached.
Change-Id: Id39ac4cd564bc1a61208cb7527c30f62b5de3e4e
diff --git a/libcore/dalvik/src/main/java/dalvik/system/VMDebug.java b/libcore/dalvik/src/main/java/dalvik/system/VMDebug.java
index 6f64c5f..31e82ec 100644
--- a/libcore/dalvik/src/main/java/dalvik/system/VMDebug.java
+++ b/libcore/dalvik/src/main/java/dalvik/system/VMDebug.java
@@ -359,6 +359,14 @@
*/
public static native void crash();
+ /**
+ * Together with gdb, provide a handy way to stop the VM at user-tagged
+ * locations.
+ *
+ * @hide
+ */
+ public static native void infopoint(int id);
+
/*
* Fake method, inserted into dmtrace output when the garbage collector
* runs. Not actually called.
diff --git a/vm/native/dalvik_system_VMDebug.c b/vm/native/dalvik_system_VMDebug.c
index f2b364b..612c9b5 100644
--- a/vm/native/dalvik_system_VMDebug.c
+++ b/vm/native/dalvik_system_VMDebug.c
@@ -873,6 +873,23 @@
dvmAbort();
}
+/*
+ * static void infopoint(int id)
+ *
+ * Provide a hook for gdb to hang to so that the VM can be stopped when
+ * user-tagged source locations are being executed.
+ */
+static void Dalvik_dalvik_system_VMDebug_infopoint(const u4* args,
+ JValue* pResult)
+{
+ gDvm.nativeDebuggerActive = true;
+
+ LOGD("VMDebug infopoint %d hit", args[0]);
+
+ gDvm.nativeDebuggerActive = false;
+ RETURN_VOID();
+}
+
const DalvikNativeMethod dvm_dalvik_system_VMDebug[] = {
{ "getVmFeatureList", "()[Ljava/lang/String;",
Dalvik_dalvik_system_VMDebug_getVmFeatureList },
@@ -928,6 +945,7 @@
Dalvik_dalvik_system_VMDebug_dumpReferenceTables },
{ "crash", "()V",
Dalvik_dalvik_system_VMDebug_crash },
+ { "infopoint", "(I)V",
+ Dalvik_dalvik_system_VMDebug_infopoint },
{ NULL, NULL, NULL },
};
-