I keep getting an illegal instruction exception when a
breadpoint is
reached. Basically I have just constructed a simple class that uses JNI to set
the event hook
and to set a breakpoint. However, when I make a call to the method with
containing the break
point, I get the illegal instruction error. Any thoughts on what might be
happenning? Am I doing
something stupid here?
I am running the program using:
java com.javix.debugger.Break
Thanks for your help,
Bryan
******************************************
Here is the Java code:
package com.javix.debugger;
public class Break
{
public native boolean setBreakPoint();
static {
try {
System.loadLibrary ("break");
} catch (Exception e) {
System.err.println ("could not load library");
}
}
public static void main (String[] args)
{
Break b = new Break();
b.setBreakPoint();
b.foo();
}
public void foo()
{
return;
}
}
And here is the c code for the native method setBreakPoint:
#include <jni.h>
#include <jvmdi.h>
#include "com_javix_debugger_Break.h"
void EventHook (JNIEnv *env, JVMDI_Event *event)
{
printf ("got event");
}
void showError (jvmdiError error)
{
switch (error) {
case JVMDI_ERROR_NONE:
printf ("no error\n");
break;
case JVMDI_ERROR_NULL_POINTER:
printf ("null pointer\n");
break;
case JVMDI_ERROR_INVALID_METHODID:
printf ("invalid method\n");
break;
case JVMDI_ERROR_INVALID_CLASS:
printf ("invalid class\n");
break;
case JVMDI_ERROR_INVALID_LOCATION:
printf ("invalid location\n");
break;
case JVMDI_ERROR_DUPLICATE_BREAKPOINT:
printf ("duplicate breakpoint\n");
break;
case JVMDI_ERROR_VM_DEAD:
printf ("vm dead\n");
break;
case JVMDI_ERROR_OUT_OF_MEMORY:
printf ("out of memory\n");
break;
}
}
JNIEXPORT jboolean JNICALL Java_com_javix_debugger_Break_setBreakPoint (JNIEnv
*env, jobject obj)
{
jmethodID method;
jclass clazz = (*env)->FindClass (env, "com/javix/debugger/Break");
if (!clazz)
printf ("could not find class\n");
method = (*env)->GetMethodID (env, clazz, "foo", "()V");
if (!method)
printf ("could not find method\n");
showError(JVMDI_SetEventHook (env, EventHook));
showError(JVMDI_SetBreakpoint (env, clazz, method, 0));
return 0;
}
breadpoint is
reached. Basically I have just constructed a simple class that uses JNI to set
the event hook
and to set a breakpoint. However, when I make a call to the method with
containing the break
point, I get the illegal instruction error. Any thoughts on what might be
happenning? Am I doing
something stupid here?
I am running the program using:
java com.javix.debugger.Break
Thanks for your help,
Bryan
******************************************
Here is the Java code:
package com.javix.debugger;
public class Break
{
public native boolean setBreakPoint();
static {
try {
System.loadLibrary ("break");
} catch (Exception e) {
System.err.println ("could not load library");
}
}
public static void main (String[] args)
{
Break b = new Break();
b.setBreakPoint();
b.foo();
}
public void foo()
{
return;
}
}
And here is the c code for the native method setBreakPoint:
#include <jni.h>
#include <jvmdi.h>
#include "com_javix_debugger_Break.h"
void EventHook (JNIEnv *env, JVMDI_Event *event)
{
printf ("got event");
}
void showError (jvmdiError error)
{
switch (error) {
case JVMDI_ERROR_NONE:
printf ("no error\n");
break;
case JVMDI_ERROR_NULL_POINTER:
printf ("null pointer\n");
break;
case JVMDI_ERROR_INVALID_METHODID:
printf ("invalid method\n");
break;
case JVMDI_ERROR_INVALID_CLASS:
printf ("invalid class\n");
break;
case JVMDI_ERROR_INVALID_LOCATION:
printf ("invalid location\n");
break;
case JVMDI_ERROR_DUPLICATE_BREAKPOINT:
printf ("duplicate breakpoint\n");
break;
case JVMDI_ERROR_VM_DEAD:
printf ("vm dead\n");
break;
case JVMDI_ERROR_OUT_OF_MEMORY:
printf ("out of memory\n");
break;
}
}
JNIEXPORT jboolean JNICALL Java_com_javix_debugger_Break_setBreakPoint (JNIEnv
*env, jobject obj)
{
jmethodID method;
jclass clazz = (*env)->FindClass (env, "com/javix/debugger/Break");
if (!clazz)
printf ("could not find class\n");
method = (*env)->GetMethodID (env, clazz, "foo", "()V");
if (!method)
printf ("could not find method\n");
showError(JVMDI_SetEventHook (env, EventHook));
showError(JVMDI_SetBreakpoint (env, clazz, method, 0));
return 0;
}
- duplicates
-
JDK-4140915 C code cannot invoke a VM and set /catch breakpoints
-
- Closed
-