Exemple #1
0
/*
 * Class:     HelperSDT
 * Method:    METHOD_STAP_BT
 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)V
 */
JNIEXPORT void JNICALL Java_org_systemtap_byteman_helper_HelperSDT_METHOD_1STAP_1BT
(JNIEnv *env, jobject obj, jstring _rulename, jstring _exception, jint _counter)
{
  char* rulename = get_java_string(env, _rulename);
  char* excp = get_java_string(env, _exception);
  int stdepth = _counter;
  STAP_PROBE3(HelperSDT, method__bt, excp, stdepth, rulename);
}
Exemple #2
0
/*
 * Class:     HelperSDT
 * Method:    METHOD_STAP_PROBE1
 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V
 */
JNIEXPORT void JNICALL Java_org_systemtap_byteman_helper_HelperSDT_METHOD_1STAP_1PROBE1
(JNIEnv *env, jobject obj, jstring _rulename, jobject _arg1)
{
  char* rulename = get_java_string(env, _rulename);
  _staparg arg1 = {0}; //initialize to zero so we don't get garbage the first time through
  arg1 = determine_java_type(env, _arg1, arg1);
  if(arg1.type == OTHER || arg1.type == NONE)
    arg1.vartype.c = get_java_string(env, _arg1); // we need to create some type of check for strings
  STAP_PROBE2(HelperSDT, method__1, arg1.vartype.d, rulename);
}
Exemple #3
0
/*
 * Class:     HelperSDT
 * Method:    METHOD_STAP_PROBE7
 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
 */
JNIEXPORT void JNICALL Java_org_systemtap_byteman_helper_HelperSDT_METHOD_1STAP_1PROBE7
(JNIEnv *env, jobject obj, jstring _rulename, jobject _arg1, jobject _arg2, jobject _arg3, jobject _arg4, jobject _arg5, jobject _arg6, jobject _arg7)
{
  char* rulename = get_java_string(env, _rulename);
  _staparg arg1 = {0}; //initialize to zero so we don't get garbage the first time through
  _staparg arg2 = {0};
  _staparg arg3 = {0};
  _staparg arg4 = {0};
  _staparg arg5 = {0};
  _staparg arg6 = {0};
  _staparg arg7 = {0};
  arg1 = determine_java_type(env, _arg1, arg1);
  arg2 = determine_java_type(env, _arg2, arg2);
  arg3 = determine_java_type(env, _arg3, arg3);
  arg4 = determine_java_type(env, _arg4, arg4);
  arg5 = determine_java_type(env, _arg5, arg5);
  arg6 = determine_java_type(env, _arg6, arg6);
  arg7 = determine_java_type(env, _arg7, arg7);
  if(arg1.type == OTHER || arg1.type == NONE)
    arg1.vartype.c = get_java_string(env, _arg1); // we need to create some type of check for strings
  if(arg2.type == OTHER || arg2.type == NONE)
    arg2.vartype.c = get_java_string(env, _arg2);
  if(arg3.type == OTHER || arg3.type == NONE)
    arg3.vartype.c = get_java_string(env, _arg3);
  if(arg4.type == OTHER || arg4.type == NONE)
    arg4.vartype.c = get_java_string(env, _arg4);
  if(arg5.type == OTHER || arg5.type == NONE)
    arg5.vartype.c = get_java_string(env, _arg5);
  if(arg6.type == OTHER || arg6.type == NONE)
    arg6.vartype.c = get_java_string(env, _arg6);
  if(arg7.type == OTHER || arg7.type == NONE)
    arg7.vartype.c = get_java_string(env, _arg7);
  STAP_PROBE8(HelperSDT, method__7, arg1.vartype.d, arg2.vartype.d, arg3.vartype.d, arg4.vartype.d, arg5.vartype.d, arg6.vartype.d, arg7.vartype.d, rulename);
}
Exemple #4
0
/* Report an error via the errcall mechanism.
 */
void report_errcall(JNIEnv *jnienv, jobject errcall,
		    jstring prefix, const char *message)
{
	jmethodID id;
	jclass errcall_class;
	jstring msg;

	errcall_class = get_class(jnienv, name_DbErrcall);
	msg = get_java_string(jnienv, message);

	id = (*jnienv)->GetMethodID(jnienv, errcall_class,
				 "errcall",
				 "(Ljava/lang/String;Ljava/lang/String;)V");
	if (id == NULL) {
		fprintf(stderr, "Cannot get errcall methodID!\n");
		fprintf(stderr, "error: %s\n", message);
		return;
	}

	(*jnienv)->CallVoidMethod(jnienv, errcall, id, prefix, msg);
}
Exemple #5
0
/*
 * Class:     HelperSDT
 * Method:    METHOD_BT_DELETE
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_org_systemtap_byteman_helper_HelperSDT_METHOD_1BT_1DELETE
(JNIEnv *env, jobject obj, jstring _rulename)
{
  char* rulename = get_java_string(env, _rulename);
  STAP_PROBE1(HelperSDT, method__bt__delete, rulename);
}
Exemple #6
0
/* Report an exception back to the java side.
 */
void report_exception(JNIEnv *jnienv, const char *text, int err,
		      unsigned long expect_mask)
{
	jstring textString;
	jclass dbexcept;
	jclass javaexcept;
	jmethodID constructId;
	jthrowable obj;

	textString = NULL;
	dbexcept = NULL;
	javaexcept = NULL;
	constructId = NULL;
	obj = NULL;

	switch (err) {
	/* DB_JAVA_CALLBACK is returned by dbji_call_append_recno()
	 * (the append_recno callback) when the Java version of the
	 * callback has thrown an exception, and we want to pass the
	 * exception on.  The exception has already been thrown, we
	 * don't want to throw a new one.
	 */
	case DB_JAVA_CALLBACK:
		break;
	case ENOMEM:
		dbexcept = get_class(jnienv, name_DB_MEMORY_EX);
		break;
	case ENOENT:
		/* In this case there is a corresponding standard java
		 * exception type that we'll use.  First we make sure
		 * that the calling function expected this kind of error,
		 * if not we give an 'internal error' DbException, since
		 * we must not throw an exception type that isn't
		 * declared in the signature.
		 *
		 * We'll make this a little more general if/when we add
		 * more java standard exceptions.
		 */
		if ((expect_mask & EXCEPTION_FILE_NOT_FOUND) == 0) {
			char errstr[1024];

			strncpy(errstr, "internal error: unexpected errno: ",
				sizeof(errstr));
			strncat(errstr, text, sizeof(errstr));
			textString = get_java_string(jnienv, errstr);
			dbexcept = get_class(jnienv, name_DB_EXCEPTION);
		}
		else {
			javaexcept =
			  (*jnienv)->FindClass(jnienv, "java/io/FileNotFoundException");
		}
		break;
	case DB_RUNRECOVERY:
		dbexcept = get_class(jnienv, name_DB_RUNRECOVERY_EX);
		break;
	case DB_LOCK_DEADLOCK:
		dbexcept = get_class(jnienv, name_DB_DEADLOCK_EX);
		break;
	default:
		dbexcept = get_class(jnienv, name_DB_EXCEPTION);
		break;
	}
	if (dbexcept != NULL) {
		if (textString == NULL)
			textString = get_java_string(jnienv, text);
		constructId = (*jnienv)->GetMethodID(jnienv, dbexcept,
						     "<init>",
						     "(Ljava/lang/String;I)V");
		obj = (jthrowable)(*jnienv)->NewObject(jnienv, dbexcept,
						       constructId, textString,
						       err);
		(*jnienv)->Throw(jnienv, obj);
	}
	else if (javaexcept != NULL) {
		javaexcept =
			(*jnienv)->FindClass(jnienv, "java/io/FileNotFoundException");
		(*jnienv)->ThrowNew(jnienv, javaexcept, text);
	}
}
Exemple #7
0
jstring
dbjie_get_errpfx(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv)
{
    return (get_java_string(jnienv, dbjie->errpfx_));
}