X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=ltt%2Fjni_interface.c;h=52c9993c5e035f3319a838d858e7f2cab2c8ac6e;hb=8b0a0cc80e207156081d4aee7b8e52d8f3b22e2f;hp=d1bd993740cbab25be544648a93c73ff31384dae;hpb=a709aa2ceff366821bc40ca26326f6d3b65eb9e2;p=lttv.git diff --git a/ltt/jni_interface.c b/ltt/jni_interface.c index d1bd9937..52c9993c 100644 --- a/ltt/jni_interface.c +++ b/ltt/jni_interface.c @@ -30,7 +30,7 @@ #include #include #include - +#include /* ***FIXME*** ***HACK*** @@ -142,7 +142,24 @@ JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1open } const char *c_pathname = (*env)->GetStringUTFChars(env, pathname, 0); - LttTrace *newPtr = ltt_trace_open( c_pathname ); + LttTrace *newPtr = ltt_trace_open(c_pathname); + + (*env)->ReleaseStringUTFChars(env, pathname, c_pathname); + + return CONVERT_PTR_TO_JLONG(newPtr); +} + +/* JNI mapping of < LttTrace *ltt_trace_open_live(const gchar *pathname) > (trace.h) */ +JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTraceLive(JNIEnv *env, jobject jobj, jstring pathname, jboolean show_debug) { + + if ( !show_debug) { + /* Make sure we don't use any debug (speed up the read) */ + g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL); + g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL); + } + + const char *c_pathname = (*env)->GetStringUTFChars(env, pathname, 0); + LttTrace *newPtr = ltt_trace_open_live(c_pathname); (*env)->ReleaseStringUTFChars(env, pathname, c_pathname); @@ -242,6 +259,14 @@ JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getS return CONVERT_UINT64_TO_JLONG(newPtr->start_monotonic); } +/* JNI mapping of < int ltt_trace_update(LttTrace *t) > (trace.h) */ +JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1updateTrace(JNIEnv *env, jobject jobj, jlong trace_ptr){ + + LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr); + + return (jint)ltt_trace_update(newPtr); +} + /* Access to start_time */ /* Note that we are calling the setTimeFromC function in Jaf_Time from here */ JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTime(JNIEnv *env, jobject jobj, jlong trace_ptr, jobject time_jobj) { @@ -671,6 +696,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1posit ERANGE = 34 out of range, back to last event (might be system dependent?) EPERM = 1 error while reading (might be system dependent?) */ + if (tracefilePtr->trace == NULL) { + return (jint) EPERM; + } /* Seek to the start time... this will also read the first event, as we want. */ int returnedValue = ltt_tracefile_seek_time(tracefilePtr, ((struct LttTrace)*(tracefilePtr->trace)).start_time_from_tsc);