|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* ust-core.c
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* This library is free software; you can redistribute it and/or
|
|
Packit |
c04fcb |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
c04fcb |
* License as published by the Free Software Foundation; only
|
|
Packit |
c04fcb |
* version 2.1 of the License.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
c04fcb |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
c04fcb |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
c04fcb |
* Lesser General Public License for more details.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
c04fcb |
* License along with this library; if not, write to the Free Software
|
|
Packit |
c04fcb |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
#include <stdlib.h>
|
|
Packit |
c04fcb |
#include <lttng/ust-events.h>
|
|
Packit |
c04fcb |
#include <usterr-signal-safe.h>
|
|
Packit |
c04fcb |
#include "lttng-tracer-core.h"
|
|
Packit |
c04fcb |
#include "jhash.h"
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
static CDS_LIST_HEAD(lttng_transport_list);
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
struct lttng_transport *lttng_transport_find(const char *name)
|
|
Packit |
c04fcb |
{
|
|
Packit |
c04fcb |
struct lttng_transport *transport;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
cds_list_for_each_entry(transport, <tng_transport_list, node) {
|
|
Packit |
c04fcb |
if (!strcmp(transport->name, name))
|
|
Packit |
c04fcb |
return transport;
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
return NULL;
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/**
|
|
Packit |
c04fcb |
* lttng_transport_register - LTT transport registration
|
|
Packit |
c04fcb |
* @transport: transport structure
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* Registers a transport which can be used as output to extract the data out of
|
|
Packit |
c04fcb |
* LTTng. Called with ust_lock held.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
void lttng_transport_register(struct lttng_transport *transport)
|
|
Packit |
c04fcb |
{
|
|
Packit |
c04fcb |
cds_list_add_tail(&transport->node, <tng_transport_list);
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/**
|
|
Packit |
c04fcb |
* lttng_transport_unregister - LTT transport unregistration
|
|
Packit |
c04fcb |
* @transport: transport structure
|
|
Packit |
c04fcb |
* Called with ust_lock held.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
void lttng_transport_unregister(struct lttng_transport *transport)
|
|
Packit |
c04fcb |
{
|
|
Packit |
c04fcb |
cds_list_del(&transport->node);
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* Needed by comm layer.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
struct lttng_enum *lttng_ust_enum_get(struct lttng_session *session,
|
|
Packit |
c04fcb |
const char *enum_name)
|
|
Packit |
c04fcb |
{
|
|
Packit |
c04fcb |
struct lttng_enum *_enum;
|
|
Packit |
c04fcb |
struct cds_hlist_head *head;
|
|
Packit |
c04fcb |
struct cds_hlist_node *node;
|
|
Packit |
c04fcb |
size_t name_len = strlen(enum_name);
|
|
Packit |
c04fcb |
uint32_t hash;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
hash = jhash(enum_name, name_len, 0);
|
|
Packit |
c04fcb |
head = &session->enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)];
|
|
Packit |
c04fcb |
cds_hlist_for_each_entry(_enum, node, head, hlist) {
|
|
Packit |
c04fcb |
assert(_enum->desc);
|
|
Packit |
c04fcb |
if (!strncmp(_enum->desc->name, enum_name,
|
|
Packit |
c04fcb |
LTTNG_UST_SYM_NAME_LEN - 1))
|
|
Packit |
c04fcb |
return _enum;
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
return NULL;
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
size_t lttng_ust_dummy_get_size(struct lttng_ctx_field *field, size_t offset)
|
|
Packit |
c04fcb |
{
|
|
Packit |
c04fcb |
size_t size = 0;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
size += lib_ring_buffer_align(offset, lttng_alignof(char));
|
|
Packit |
c04fcb |
size += sizeof(char); /* tag */
|
|
Packit |
c04fcb |
return size;
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
void lttng_ust_dummy_record(struct lttng_ctx_field *field,
|
|
Packit |
c04fcb |
struct lttng_ust_lib_ring_buffer_ctx *ctx,
|
|
Packit |
c04fcb |
struct lttng_channel *chan)
|
|
Packit |
c04fcb |
{
|
|
Packit |
c04fcb |
char sel_char = (char) LTTNG_UST_DYNAMIC_TYPE_NONE;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
lib_ring_buffer_align_ctx(ctx, lttng_alignof(sel_char));
|
|
Packit |
c04fcb |
chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
void lttng_ust_dummy_get_value(struct lttng_ctx_field *field,
|
|
Packit |
c04fcb |
struct lttng_ctx_value *value)
|
|
Packit |
c04fcb |
{
|
|
Packit |
c04fcb |
value->sel = LTTNG_UST_DYNAMIC_TYPE_NONE;
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
int lttng_context_is_app(const char *name)
|
|
Packit |
c04fcb |
{
|
|
Packit |
c04fcb |
if (strncmp(name, "$app.", strlen("$app.")) != 0) {
|
|
Packit |
c04fcb |
return 0;
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
return 1;
|
|
Packit |
c04fcb |
}
|