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 DG |
11 | |
12 | #define TRACEPOINT_DEFINE | |
13 | #define TRACEPOINT_CREATE_PROBES | |
14 | #include "lttng_ust_jul.h" | |
8ab5c06b | 15 | #include "../common/lttng_ust_context.h" |
43e5396b | 16 | |
9aabed2d | 17 | /* |
8ab5c06b | 18 | * Deprecated function from before the context information was passed. |
9aabed2d | 19 | */ |
6e7bc9e0 | 20 | JNIEXPORT void JNICALL Java_org_lttng_ust_agent_jul_LttngJulApi_tracepoint(JNIEnv *env, |
43e5396b DG |
21 | jobject jobj, |
22 | jstring msg, | |
23 | jstring logger_name, | |
24 | jstring class_name, | |
25 | jstring method_name, | |
26 | jlong millis, | |
27 | jint log_level, | |
28 | jint thread_id) | |
29 | { | |
30 | jboolean iscopy; | |
31 | const char *msg_cstr = (*env)->GetStringUTFChars(env, msg, &iscopy); | |
32 | const char *logger_name_cstr = (*env)->GetStringUTFChars(env, logger_name, &iscopy); | |
33 | const char *class_name_cstr = (*env)->GetStringUTFChars(env, class_name, &iscopy); | |
34 | const char *method_name_cstr = (*env)->GetStringUTFChars(env, method_name, &iscopy); | |
35 | ||
8286ff50 | 36 | tracepoint(lttng_jul, event, msg_cstr, logger_name_cstr, |
9aabed2d DG |
37 | class_name_cstr, method_name_cstr, millis, log_level, thread_id); |
38 | ||
39 | (*env)->ReleaseStringUTFChars(env, msg, msg_cstr); | |
40 | (*env)->ReleaseStringUTFChars(env, logger_name, logger_name_cstr); | |
41 | (*env)->ReleaseStringUTFChars(env, class_name, class_name_cstr); | |
42 | (*env)->ReleaseStringUTFChars(env, method_name, method_name_cstr); | |
43 | } | |
8ab5c06b AM |
44 | |
45 | /* | |
46 | * Tracepoint used by Java applications using the JUL handler. | |
47 | */ | |
48 | JNIEXPORT void JNICALL Java_org_lttng_ust_agent_jul_LttngJulApi_tracepointWithContext(JNIEnv *env, | |
49 | jobject jobj, | |
50 | jstring msg, | |
51 | jstring logger_name, | |
52 | jstring class_name, | |
53 | jstring method_name, | |
54 | jlong millis, | |
55 | jint log_level, | |
56 | jint thread_id, | |
b1ca4c5f AM |
57 | jbyteArray context_info_entries, |
58 | jbyteArray context_info_strings) | |
8ab5c06b AM |
59 | { |
60 | jboolean iscopy; | |
61 | const char *msg_cstr = (*env)->GetStringUTFChars(env, msg, &iscopy); | |
62 | const char *logger_name_cstr = (*env)->GetStringUTFChars(env, logger_name, &iscopy); | |
63 | const char *class_name_cstr = (*env)->GetStringUTFChars(env, class_name, &iscopy); | |
64 | const char *method_name_cstr = (*env)->GetStringUTFChars(env, method_name, &iscopy); | |
b1ca4c5f AM |
65 | signed char *context_info_entries_array; |
66 | signed char *context_info_strings_array; | |
8ab5c06b AM |
67 | |
68 | /* | |
69 | * Write these to the TLS variables, so that the UST callbacks in | |
70 | * lttng_ust_context.c can access them. | |
71 | */ | |
b1ca4c5f AM |
72 | context_info_entries_array = (*env)->GetByteArrayElements(env, context_info_entries, &iscopy); |
73 | lttng_ust_context_info_tls.ctx_entries = (struct lttng_ust_jni_ctx_entry *) context_info_entries_array; | |
74 | lttng_ust_context_info_tls.ctx_entries_len = (*env)->GetArrayLength(env, context_info_entries); | |
75 | context_info_strings_array = (*env)->GetByteArrayElements(env, context_info_strings, &iscopy); | |
76 | lttng_ust_context_info_tls.ctx_strings = context_info_strings_array; | |
77 | lttng_ust_context_info_tls.ctx_strings_len = (*env)->GetArrayLength(env, context_info_strings); | |
8ab5c06b AM |
78 | |
79 | tracepoint(lttng_jul, event, msg_cstr, logger_name_cstr, | |
80 | class_name_cstr, method_name_cstr, millis, log_level, thread_id); | |
81 | ||
b1ca4c5f AM |
82 | lttng_ust_context_info_tls.ctx_entries = NULL; |
83 | lttng_ust_context_info_tls.ctx_entries_len = 0; | |
84 | lttng_ust_context_info_tls.ctx_strings = NULL; | |
85 | lttng_ust_context_info_tls.ctx_strings_len = 0; | |
8ab5c06b AM |
86 | (*env)->ReleaseStringUTFChars(env, msg, msg_cstr); |
87 | (*env)->ReleaseStringUTFChars(env, logger_name, logger_name_cstr); | |
88 | (*env)->ReleaseStringUTFChars(env, class_name, class_name_cstr); | |
89 | (*env)->ReleaseStringUTFChars(env, method_name, method_name_cstr); | |
b1ca4c5f AM |
90 | (*env)->ReleaseByteArrayElements(env, context_info_entries, context_info_entries_array, 0); |
91 | (*env)->ReleaseByteArrayElements(env, context_info_strings, context_info_strings_array, 0); | |
8ab5c06b | 92 | } |