Commit | Line | Data |
---|---|---|
43e5396b | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: LGPL-2.1-only |
43e5396b | 3 | * |
c0c0989a MJ |
4 | * Copyright (C) 2016 EfficiOS Inc. |
5 | * Copyright (C) 2016 Alexandre Montplaisir <alexmonthy@efficios.com> | |
6 | * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
43e5396b DG |
7 | */ |
8 | ||
1ddceb36 | 9 | #define _LGPL_SOURCE |
6e7bc9e0 | 10 | #include "org_lttng_ust_agent_jul_LttngJulApi.h" |
43e5396b | 11 | |
6ba0c2b2 MD |
12 | #define LTTNG_UST_TRACEPOINT_HIDDEN_DEFINITION |
13 | #define LTTNG_UST_TRACEPOINT_PROVIDER_HIDDEN_DEFINITION | |
14 | ||
88c7c4ea | 15 | #define LTTNG_UST_TRACEPOINT_DEFINE |
660323e6 | 16 | #define LTTNG_UST_TRACEPOINT_CREATE_PROBES |
43e5396b | 17 | #include "lttng_ust_jul.h" |
8ab5c06b | 18 | #include "../common/lttng_ust_context.h" |
43e5396b | 19 | |
9aabed2d | 20 | /* |
8ab5c06b | 21 | * Deprecated function from before the context information was passed. |
9aabed2d | 22 | */ |
6e7bc9e0 | 23 | JNIEXPORT void JNICALL Java_org_lttng_ust_agent_jul_LttngJulApi_tracepoint(JNIEnv *env, |
2208d8b5 | 24 | jobject jobj __attribute__((unused)), |
43e5396b DG |
25 | jstring msg, |
26 | jstring logger_name, | |
27 | jstring class_name, | |
28 | jstring method_name, | |
29 | jlong millis, | |
30 | jint log_level, | |
31 | jint thread_id) | |
32 | { | |
33 | jboolean iscopy; | |
34 | const char *msg_cstr = (*env)->GetStringUTFChars(env, msg, &iscopy); | |
35 | const char *logger_name_cstr = (*env)->GetStringUTFChars(env, logger_name, &iscopy); | |
36 | const char *class_name_cstr = (*env)->GetStringUTFChars(env, class_name, &iscopy); | |
37 | const char *method_name_cstr = (*env)->GetStringUTFChars(env, method_name, &iscopy); | |
38 | ||
cbc06a3b | 39 | lttng_ust_tracepoint(lttng_jul, event, msg_cstr, logger_name_cstr, |
9aabed2d DG |
40 | class_name_cstr, method_name_cstr, millis, log_level, thread_id); |
41 | ||
42 | (*env)->ReleaseStringUTFChars(env, msg, msg_cstr); | |
43 | (*env)->ReleaseStringUTFChars(env, logger_name, logger_name_cstr); | |
44 | (*env)->ReleaseStringUTFChars(env, class_name, class_name_cstr); | |
45 | (*env)->ReleaseStringUTFChars(env, method_name, method_name_cstr); | |
46 | } | |
8ab5c06b AM |
47 | |
48 | /* | |
49 | * Tracepoint used by Java applications using the JUL handler. | |
50 | */ | |
51 | JNIEXPORT void JNICALL Java_org_lttng_ust_agent_jul_LttngJulApi_tracepointWithContext(JNIEnv *env, | |
2208d8b5 | 52 | jobject jobj __attribute__((unused)), |
8ab5c06b AM |
53 | jstring msg, |
54 | jstring logger_name, | |
55 | jstring class_name, | |
56 | jstring method_name, | |
57 | jlong millis, | |
58 | jint log_level, | |
59 | jint thread_id, | |
b1ca4c5f AM |
60 | jbyteArray context_info_entries, |
61 | jbyteArray context_info_strings) | |
8ab5c06b AM |
62 | { |
63 | jboolean iscopy; | |
64 | const char *msg_cstr = (*env)->GetStringUTFChars(env, msg, &iscopy); | |
65 | const char *logger_name_cstr = (*env)->GetStringUTFChars(env, logger_name, &iscopy); | |
66 | const char *class_name_cstr = (*env)->GetStringUTFChars(env, class_name, &iscopy); | |
67 | const char *method_name_cstr = (*env)->GetStringUTFChars(env, method_name, &iscopy); | |
b1ca4c5f AM |
68 | signed char *context_info_entries_array; |
69 | signed char *context_info_strings_array; | |
8ab5c06b AM |
70 | |
71 | /* | |
72 | * Write these to the TLS variables, so that the UST callbacks in | |
73 | * lttng_ust_context.c can access them. | |
74 | */ | |
b1ca4c5f AM |
75 | context_info_entries_array = (*env)->GetByteArrayElements(env, context_info_entries, &iscopy); |
76 | lttng_ust_context_info_tls.ctx_entries = (struct lttng_ust_jni_ctx_entry *) context_info_entries_array; | |
77 | lttng_ust_context_info_tls.ctx_entries_len = (*env)->GetArrayLength(env, context_info_entries); | |
78 | context_info_strings_array = (*env)->GetByteArrayElements(env, context_info_strings, &iscopy); | |
79 | lttng_ust_context_info_tls.ctx_strings = context_info_strings_array; | |
80 | lttng_ust_context_info_tls.ctx_strings_len = (*env)->GetArrayLength(env, context_info_strings); | |
8ab5c06b | 81 | |
cbc06a3b | 82 | lttng_ust_tracepoint(lttng_jul, event, msg_cstr, logger_name_cstr, |
8ab5c06b AM |
83 | class_name_cstr, method_name_cstr, millis, log_level, thread_id); |
84 | ||
b1ca4c5f AM |
85 | lttng_ust_context_info_tls.ctx_entries = NULL; |
86 | lttng_ust_context_info_tls.ctx_entries_len = 0; | |
87 | lttng_ust_context_info_tls.ctx_strings = NULL; | |
88 | lttng_ust_context_info_tls.ctx_strings_len = 0; | |
8ab5c06b AM |
89 | (*env)->ReleaseStringUTFChars(env, msg, msg_cstr); |
90 | (*env)->ReleaseStringUTFChars(env, logger_name, logger_name_cstr); | |
91 | (*env)->ReleaseStringUTFChars(env, class_name, class_name_cstr); | |
92 | (*env)->ReleaseStringUTFChars(env, method_name, method_name_cstr); | |
b1ca4c5f AM |
93 | (*env)->ReleaseByteArrayElements(env, context_info_entries, context_info_entries_array, 0); |
94 | (*env)->ReleaseByteArrayElements(env, context_info_strings, context_info_strings_array, 0); | |
8ab5c06b | 95 | } |