|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* lttng-context-ip.c
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* LTTng UST Instruction Pointer Context.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* Copyright (C) 2009-2012 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 <sys/types.h>
|
|
Packit |
c04fcb |
#include <unistd.h>
|
|
Packit |
c04fcb |
#include <lttng/ust-events.h>
|
|
Packit |
c04fcb |
#include <lttng/ust-tracer.h>
|
|
Packit |
c04fcb |
#include <lttng/ringbuffer-config.h>
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
static
|
|
Packit |
c04fcb |
size_t ip_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(void *));
|
|
Packit |
c04fcb |
size += sizeof(void *);
|
|
Packit |
c04fcb |
return size;
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
static
|
|
Packit |
c04fcb |
void ip_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 |
void *ip;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
ip = ctx->ip;
|
|
Packit |
c04fcb |
lib_ring_buffer_align_ctx(ctx, lttng_alignof(ip));
|
|
Packit |
c04fcb |
chan->ops->event_write(ctx, &ip, sizeof(ip));
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
int lttng_add_ip_to_ctx(struct lttng_ctx **ctx)
|
|
Packit |
c04fcb |
{
|
|
Packit |
c04fcb |
struct lttng_ctx_field *field;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
field = lttng_append_context(ctx);
|
|
Packit |
c04fcb |
if (!field)
|
|
Packit |
c04fcb |
return -ENOMEM;
|
|
Packit |
c04fcb |
if (lttng_find_context(*ctx, "ip")) {
|
|
Packit |
c04fcb |
lttng_remove_context_field(ctx, field);
|
|
Packit |
c04fcb |
return -EEXIST;
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
field->event_field.name = "ip";
|
|
Packit |
c04fcb |
field->event_field.type.atype = atype_integer;
|
|
Packit |
c04fcb |
field->event_field.type.u.basic.integer.size = sizeof(void *) * CHAR_BIT;
|
|
Packit |
c04fcb |
field->event_field.type.u.basic.integer.alignment = lttng_alignof(void *) * CHAR_BIT;
|
|
Packit |
c04fcb |
field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(void *);
|
|
Packit |
c04fcb |
field->event_field.type.u.basic.integer.reverse_byte_order = 0;
|
|
Packit |
c04fcb |
field->event_field.type.u.basic.integer.base = 16;
|
|
Packit |
c04fcb |
field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
|
|
Packit |
c04fcb |
field->get_size = ip_get_size;
|
|
Packit |
c04fcb |
field->record = ip_record;
|
|
Packit |
c04fcb |
lttng_context_update(*ctx);
|
|
Packit |
c04fcb |
return 0;
|
|
Packit |
c04fcb |
}
|