summaryrefslogtreecommitdiff
path: root/libjava/jvmti.cc
diff options
context:
space:
mode:
authorkseitz <kseitz@138bc75d-0d04-0410-961f-82ee72b054a4>2006-11-01 18:20:19 +0000
committerkseitz <kseitz@138bc75d-0d04-0410-961f-82ee72b054a4>2006-11-01 18:20:19 +0000
commita93dc87b965e5c2e17305df6bde9a22cc495f384 (patch)
tree643906a19a9e931c1606a2d77b09af272b5296de /libjava/jvmti.cc
parent7737bfbc0cc39109a21b893874999b06c15f05ee (diff)
downloadgcc-a93dc87b965e5c2e17305df6bde9a22cc495f384.tar.gz
* gnu/gcj/jvmti/Location.java: New file.
* gnu/gcj/jvmti/BreakpointManager.java: New file. * jvmti.cc (_Jv_JVMTI_SetBreakpoint): New function. (_Jv_JVMTI_ClearBreakpoint): New function. (_Jv_JVMTI_Interface): Define SetBreakpoint and ClearBreakpoint. * sources.am: Regenerated. * Makefile.in: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118391 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/jvmti.cc')
-rw-r--r--libjava/jvmti.cc74
1 files changed, 72 insertions, 2 deletions
diff --git a/libjava/jvmti.cc b/libjava/jvmti.cc
index c1bdc788411..5569551c2a3 100644
--- a/libjava/jvmti.cc
+++ b/libjava/jvmti.cc
@@ -14,6 +14,7 @@ details. */
#include <jvm.h>
#include <java-threads.h>
#include <java-gc.h>
+#include <java-interp.h>
#include <jvmti.h>
#include "jvmti-int.h"
@@ -21,6 +22,9 @@ details. */
#include <gnu/classpath/SystemProperties.h>
#include <gnu/gcj/runtime/BootClassLoader.h>
+#include <gnu/gcj/jvmti/Breakpoint.h>
+#include <gnu/gcj/jvmti/BreakpointManager.h>
+
#include <java/lang/Class.h>
#include <java/lang/ClassLoader.h>
#include <java/lang/Object.h>
@@ -280,6 +284,72 @@ _Jv_JVMTI_RawMonitorNotifyAll (MAYBE_UNUSED jvmtiEnv *env,
}
static jvmtiError JNICALL
+_Jv_JVMTI_SetBreakpoint (jvmtiEnv *env, jmethodID method, jlocation location)
+{
+ REQUIRE_PHASE (env, JVMTI_PHASE_LIVE);
+
+ using namespace gnu::gcj::jvmti;
+ Breakpoint *bp
+ = BreakpointManager::getBreakpoint (reinterpret_cast<jlong> (method),
+ location);
+ if (bp == NULL)
+ {
+ jclass klass;
+ jvmtiError err = env->GetMethodDeclaringClass (method, &klass);
+ if (err != JVMTI_ERROR_NONE)
+ return err;
+
+ if (!_Jv_IsInterpretedClass (klass))
+ return JVMTI_ERROR_INVALID_CLASS;
+
+ _Jv_MethodBase *base = _Jv_FindInterpreterMethod (klass, method);
+ if (base == NULL)
+ return JVMTI_ERROR_INVALID_METHODID;
+
+ jint flags;
+ err = env->GetMethodModifiers (method, &flags);
+ if (err != JVMTI_ERROR_NONE)
+ return err;
+
+ if (flags & java::lang::reflect::Modifier::NATIVE)
+ return JVMTI_ERROR_NATIVE_METHOD;
+
+ _Jv_InterpMethod *imeth = reinterpret_cast<_Jv_InterpMethod *> (base);
+ if (imeth->get_insn (location) == NULL)
+ return JVMTI_ERROR_INVALID_LOCATION;
+
+ // Now the breakpoint can be safely installed
+ bp = BreakpointManager::newBreakpoint (reinterpret_cast<jlong> (method),
+ location);
+ }
+ else
+ {
+ // Duplicate breakpoints are not permitted by JVMTI
+ return JVMTI_ERROR_DUPLICATE;
+ }
+
+ return JVMTI_ERROR_NONE;
+}
+
+static jvmtiError JNICALL
+_Jv_JVMTI_ClearBreakpoint (MAYBE_UNUSED jvmtiEnv *env, jmethodID method,
+ jlocation location)
+{
+ REQUIRE_PHASE (env, JVMTI_PHASE_LIVE);
+
+ using namespace gnu::gcj::jvmti;
+
+ Breakpoint *bp
+ = BreakpointManager::getBreakpoint (reinterpret_cast<jlong> (method),
+ location);
+ if (bp == NULL)
+ return JVMTI_ERROR_NOT_FOUND;
+
+ BreakpointManager::deleteBreakpoint (reinterpret_cast<jlong> (method), location);
+ return JVMTI_ERROR_NONE;
+}
+
+static jvmtiError JNICALL
_Jv_JVMTI_Allocate (MAYBE_UNUSED jvmtiEnv *env, jlong size,
unsigned char **result)
{
@@ -1278,8 +1348,8 @@ struct _Jv_jvmtiEnv _Jv_JVMTI_Interface =
_Jv_JVMTI_RawMonitorWait, // RawMonitorWait
_Jv_JVMTI_RawMonitorNotify, // RawMonitorNotify
_Jv_JVMTI_RawMonitorNotifyAll, // RawMonitorNotifyAll
- UNIMPLEMENTED, // SetBreakpoint
- UNIMPLEMENTED, // ClearBreakpoint
+ _Jv_JVMTI_SetBreakpoint, // SetBreakpoint
+ _Jv_JVMTI_ClearBreakpoint, // ClearBreakpoint
RESERVED, // reserved40
UNIMPLEMENTED, // SetFieldAccessWatch
UNIMPLEMENTED, // ClearFieldAccessWatch