From: compudj Date: Mon, 12 Jun 2006 16:40:30 +0000 (+0000) Subject: thread brand java X-Git-Tag: v0.12.20~1567 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d84f6d3c6d59e7b55fa9edb87244e6e6a6cc2c6a;p=lttv.git thread brand java git-svn-id: http://ltt.polymtl.ca/svn@1922 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt-usertrace/java/Sample.java b/ltt-usertrace/java/Sample.java index 75f1c0c4..27f38b10 100644 --- a/ltt-usertrace/java/Sample.java +++ b/ltt-usertrace/java/Sample.java @@ -1,4 +1,4 @@ -// The Sample-java.java file +// The Sample.java file public class Sample { // Declaration of the Native (C) function diff --git a/ltt-usertrace/java/TestBrand.java b/ltt-usertrace/java/TestBrand.java new file mode 100644 index 00000000..b6cb7c91 --- /dev/null +++ b/ltt-usertrace/java/TestBrand.java @@ -0,0 +1,11 @@ + +import ThreadBrand; + +// The Sample.java file +public class TestBrand +{ + public static void main(String[] args) + { + ThreadBrand.trace_java_generic_thread_brand("Brand_test"); + } +} diff --git a/ltt-usertrace/java/ThreadBrand.java b/ltt-usertrace/java/ThreadBrand.java new file mode 100644 index 00000000..14a30790 --- /dev/null +++ b/ltt-usertrace/java/ThreadBrand.java @@ -0,0 +1,9 @@ +// The ThreadBrand.java file +public class ThreadBrand +{ + // Declaration of the Native (C) function + private static native void trace_java_generic_thread_brand(String arg); + static { + System.loadLibrary("ltt-java-thread_brand"); + } +} diff --git a/ltt-usertrace/java/generate.sh b/ltt-usertrace/java/generate.sh index 92ca1992..78a7b9f0 100755 --- a/ltt-usertrace/java/generate.sh +++ b/ltt-usertrace/java/generate.sh @@ -1,5 +1,6 @@ #!/bin/sh +#Sample javac Sample.java CLASSPATH=.:/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/bin javah -jni Sample gcc -I /usr/lib/jvm/java-1.5.0-sun-1.5.0.06/include \ @@ -8,3 +9,13 @@ gcc -I /usr/lib/jvm/java-1.5.0-sun-1.5.0.06/include \ -o libltt-java-string.so ltt-java-string.c \ ../ltt-facility-loader-user_generic.c LD_LIBRARY_PATH=. java Sample + +#TestBrand +javac TestBrand.java +CLASSPATH=.:/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/bin javah -jni TestBrand +gcc -I /usr/lib/jvm/java-1.5.0-sun-1.5.0.06/include \ + -I /usr/lib/jvm/java-1.5.0-sun-1.5.0.06/include/linux \ + -shared -Wl,-soname,libltt-java-thread_brand \ + -o libltt-java-thread_brand.so ltt-java-thread_brand.c \ + ../ltt-facility-loader-user_generic.c +LD_LIBRARY_PATH=. java TestBrand diff --git a/ltt-usertrace/java/ltt-java-thread_brand.c b/ltt-usertrace/java/ltt-java-thread_brand.c new file mode 100644 index 00000000..aa088405 --- /dev/null +++ b/ltt-usertrace/java/ltt-java-thread_brand.c @@ -0,0 +1,20 @@ + +#include +#include "Sample.h" +#include +#include + +#define LTT_TRACE +#define LTT_BLOCKING 1 +#include + +JNIEXPORT void JNICALL Java_ThreadBrand_trace_1java_1generic_1thread_brand + (JNIEnv *env, jobject obj, jstring jstr) +{ + const char *str; + str = (*env)->GetStringUTFChars(env, jstr, NULL); + if (str == NULL) return; // out of memory error thrown + trace_user_generic_thread_brand(str); + (*env)->ReleaseStringUTFChars(env, jstr, str); +} +