X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=liblttng-ust-java-agent%2Fjni%2Fcommon%2Flttng_ust_context.c;h=ae478ba3c407c26ccd015ea9a2232454e763c5c7;hb=e016c06adf51c2e213303343026c2b5d3d7776e1;hp=e9b6da282db3bfbc5ec075a8ea64178c6f9ef851;hpb=9b3a9a1f8ee47787e50a130b444dae38eee5dca0;p=lttng-ust.git diff --git a/liblttng-ust-java-agent/jni/common/lttng_ust_context.c b/liblttng-ust-java-agent/jni/common/lttng_ust_context.c index e9b6da28..ae478ba3 100644 --- a/liblttng-ust-java-agent/jni/common/lttng_ust_context.c +++ b/liblttng-ust-java-agent/jni/common/lttng_ust_context.c @@ -1,20 +1,9 @@ /* - * Copyright (C) 2016 - EfficiOS Inc., Alexandre Montplaisir - * 2016 - EfficiOS Inc., Mathieu Desnoyers + * SPDX-License-Identifier: LGPL-2.1-only * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; only - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (C) 2016 EfficiOS Inc. + * Copyright (C) 2016 Alexandre Montplaisir + * Copyright (C) 2016 Mathieu Desnoyers */ #include "org_lttng_ust_agent_context_LttngContextApi.h" @@ -22,11 +11,10 @@ #include #include #include -#include -#include -#include +#include +#include -#include "helper.h" +#include "ust-helper.h" #include "lttng_ust_context.h" enum lttng_ust_jni_type { @@ -57,7 +45,7 @@ struct lttng_ust_jni_ctx_entry { } __attribute__((packed)); /* TLS passing context info from JNI to callbacks. */ -DECLARE_URCU_TLS_IE(struct lttng_ust_jni_tls, lttng_ust_context_info_tls); +__thread struct lttng_ust_jni_tls lttng_ust_context_info_tls; static const char *get_ctx_string_at_offset(int32_t offset) { @@ -85,11 +73,11 @@ static struct lttng_ust_jni_ctx_entry *lookup_ctx_by_name(const char *ctx_name) return NULL; } -static size_t get_size_cb(struct lttng_ctx_field *field, size_t offset) +static size_t get_size_cb(struct lttng_ust_ctx_field *field, size_t offset) { struct lttng_ust_jni_ctx_entry *jctx; size_t size = 0; - const char *ctx_name = field->event_field.name; + const char *ctx_name = field->event_field->name; enum lttng_ust_jni_type jni_type; @@ -147,12 +135,12 @@ static size_t get_size_cb(struct lttng_ctx_field *field, size_t offset) } -static void record_cb(struct lttng_ctx_field *field, +static void record_cb(struct lttng_ust_ctx_field *field, struct lttng_ust_lib_ring_buffer_ctx *ctx, - struct lttng_channel *chan) + struct lttng_ust_channel_buffer *lttng_chan_buf) { struct lttng_ust_jni_ctx_entry *jctx; - const char *ctx_name = field->event_field.name; + const char *ctx_name = field->event_field->name; enum lttng_ust_jni_type jni_type; char sel_char; @@ -167,7 +155,7 @@ static void record_cb(struct lttng_ctx_field *field, case JNI_TYPE_NULL: sel_char = LTTNG_UST_DYNAMIC_TYPE_NONE; lib_ring_buffer_align_ctx(ctx, lttng_alignof(char)); - chan->ops->event_write(ctx, &sel_char, sizeof(sel_char)); + lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char)); break; case JNI_TYPE_INTEGER: { @@ -175,9 +163,9 @@ static void record_cb(struct lttng_ctx_field *field, sel_char = LTTNG_UST_DYNAMIC_TYPE_S32; lib_ring_buffer_align_ctx(ctx, lttng_alignof(char)); - chan->ops->event_write(ctx, &sel_char, sizeof(sel_char)); + lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char)); lib_ring_buffer_align_ctx(ctx, lttng_alignof(v)); - chan->ops->event_write(ctx, &v, sizeof(v)); + lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v)); break; } case JNI_TYPE_LONG: @@ -186,9 +174,9 @@ static void record_cb(struct lttng_ctx_field *field, sel_char = LTTNG_UST_DYNAMIC_TYPE_S64; lib_ring_buffer_align_ctx(ctx, lttng_alignof(char)); - chan->ops->event_write(ctx, &sel_char, sizeof(sel_char)); + lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char)); lib_ring_buffer_align_ctx(ctx, lttng_alignof(v)); - chan->ops->event_write(ctx, &v, sizeof(v)); + lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v)); break; } case JNI_TYPE_DOUBLE: @@ -197,9 +185,9 @@ static void record_cb(struct lttng_ctx_field *field, sel_char = LTTNG_UST_DYNAMIC_TYPE_DOUBLE; lib_ring_buffer_align_ctx(ctx, lttng_alignof(char)); - chan->ops->event_write(ctx, &sel_char, sizeof(sel_char)); + lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char)); lib_ring_buffer_align_ctx(ctx, lttng_alignof(v)); - chan->ops->event_write(ctx, &v, sizeof(v)); + lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v)); break; } case JNI_TYPE_FLOAT: @@ -208,9 +196,9 @@ static void record_cb(struct lttng_ctx_field *field, sel_char = LTTNG_UST_DYNAMIC_TYPE_FLOAT; lib_ring_buffer_align_ctx(ctx, lttng_alignof(char)); - chan->ops->event_write(ctx, &sel_char, sizeof(sel_char)); + lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char)); lib_ring_buffer_align_ctx(ctx, lttng_alignof(v)); - chan->ops->event_write(ctx, &v, sizeof(v)); + lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v)); break; } case JNI_TYPE_SHORT: @@ -219,9 +207,9 @@ static void record_cb(struct lttng_ctx_field *field, sel_char = LTTNG_UST_DYNAMIC_TYPE_S16; lib_ring_buffer_align_ctx(ctx, lttng_alignof(char)); - chan->ops->event_write(ctx, &sel_char, sizeof(sel_char)); + lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char)); lib_ring_buffer_align_ctx(ctx, lttng_alignof(v)); - chan->ops->event_write(ctx, &v, sizeof(v)); + lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v)); break; } case JNI_TYPE_BYTE: @@ -230,9 +218,9 @@ static void record_cb(struct lttng_ctx_field *field, sel_char = LTTNG_UST_DYNAMIC_TYPE_S8; lib_ring_buffer_align_ctx(ctx, lttng_alignof(char)); - chan->ops->event_write(ctx, &sel_char, sizeof(sel_char)); + lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char)); lib_ring_buffer_align_ctx(ctx, lttng_alignof(v)); - chan->ops->event_write(ctx, &v, sizeof(v)); + lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v)); break; } case JNI_TYPE_BOOLEAN: @@ -241,9 +229,9 @@ static void record_cb(struct lttng_ctx_field *field, sel_char = LTTNG_UST_DYNAMIC_TYPE_S8; lib_ring_buffer_align_ctx(ctx, lttng_alignof(char)); - chan->ops->event_write(ctx, &sel_char, sizeof(sel_char)); + lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char)); lib_ring_buffer_align_ctx(ctx, lttng_alignof(v)); - chan->ops->event_write(ctx, &v, sizeof(v)); + lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v)); break; } case JNI_TYPE_STRING: @@ -257,9 +245,9 @@ static void record_cb(struct lttng_ctx_field *field, sel_char = LTTNG_UST_DYNAMIC_TYPE_NONE; } lib_ring_buffer_align_ctx(ctx, lttng_alignof(char)); - chan->ops->event_write(ctx, &sel_char, sizeof(sel_char)); + lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char)); if (str) { - chan->ops->event_write(ctx, str, strlen(str) + 1); + lttng_chan_buf->ops->event_write(ctx, str, strlen(str) + 1); } break; } @@ -268,11 +256,11 @@ static void record_cb(struct lttng_ctx_field *field, } } -static void get_value_cb(struct lttng_ctx_field *field, - struct lttng_ctx_value *value) +static void get_value_cb(struct lttng_ust_ctx_field *field, + struct lttng_ust_ctx_value *value) { struct lttng_ust_jni_ctx_entry *jctx; - const char *ctx_name = field->event_field.name; + const char *ctx_name = field->event_field->name; enum lttng_ust_jni_type jni_type; jctx = lookup_ctx_by_name(ctx_name); @@ -366,6 +354,7 @@ JNIEXPORT jlong JNICALL Java_org_lttng_ust_agent_context_LttngContextApi_registe if (!provider) { goto error_provider; } + provider->struct_size = sizeof(*provider); provider->name = provider_name_cstr; provider->get_size = get_size_cb; provider->record = record_cb;