{
int i;
- for (i = 0; i < ctx->nr_fields; i++)
- ctx->fields[i].destroy(&ctx->fields[i]);
+ for (i = 0; i < ctx->nr_fields; i++) {
+ if (ctx->fields[i].destroy)
+ ctx->fields[i].destroy(&ctx->fields[i]);
+ }
kfree(ctx->fields);
kfree(ctx);
}
#include <linux/kprobes.h>
#include "ltt-debugfs-abi.h"
+#undef is_signed_type
+#define is_signed_type(type) (((type)(-1)) < 0)
+
struct ltt_channel;
struct ltt_session;
struct lib_ring_buffer_ctx;
obj-m += lttng-perf-counters.o
endif
+obj-m += lttng-context-pid.o
+
endif
else
--- /dev/null
+/*
+ * (C) Copyright 2009-2011 -
+ * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * LTTng PID context.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include "../ltt-events.h"
+#include "../wrapper/ringbuffer/frontend_types.h"
+#include "../wrapper/vmalloc.h"
+#include "../ltt-tracer.h"
+
+static
+void pid_record(struct lttng_ctx_field *field,
+ struct lib_ring_buffer_ctx *ctx,
+ struct ltt_channel *chan)
+{
+ pid_t pid;
+
+ pid = current->pid;
+ lib_ring_buffer_align_ctx(ctx, ltt_alignof(pid));
+ chan->ops->event_write(ctx, &pid, sizeof(pid));
+}
+
+int lttng_add_pid_to_ctx(struct lttng_ctx **ctx)
+{
+ struct lttng_ctx_field *field;
+ int ret;
+
+ field = lttng_append_context(ctx);
+ if (!field)
+ return ret;
+ field->name = "pid";
+ field->type.atype = atype_integer;
+ field->type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
+ field->type.u.basic.integer.alignment = ltt_alignof(pid_t) * CHAR_BIT;
+ field->type.u.basic.integer.signedness = is_signed_type(pid_t);
+ field->type.u.basic.integer.reverse_byte_order = 0;
+ field->type.u.basic.integer.base = 10;
+ field->type.u.basic.integer.encoding = lttng_encode_none;
+ field->callback = pid_record;
+ wrapper_vmalloc_sync_all();
+ return 0;
+}
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit Perf Support");
fields[0].type.atype = atype_integer;
fields[0].type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT;
fields[0].type.u.basic.integer.alignment = ltt_alignof(unsigned long) * CHAR_BIT;
- fields[0].type.u.basic.integer.signedness = 0;
+ fields[0].type.u.basic.integer.signedness = is_signed_type(unsigned long);
fields[0].type.u.basic.integer.reverse_byte_order = 0;
fields[0].type.u.basic.integer.base = 16;
fields[0].type.u.basic.integer.encoding = lttng_encode_none;
fields[1].type.atype = atype_integer;
fields[1].type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT;
fields[1].type.u.basic.integer.alignment = ltt_alignof(unsigned long) * CHAR_BIT;
- fields[1].type.u.basic.integer.signedness = 0;
+ fields[1].type.u.basic.integer.signedness = is_signed_type(unsigned long);
fields[1].type.u.basic.integer.reverse_byte_order = 0;
fields[1].type.u.basic.integer.base = 16;
fields[1].type.u.basic.integer.encoding = lttng_encode_none;
field->type.atype = atype_integer;
field->type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT;
field->type.u.basic.integer.alignment = ltt_alignof(unsigned long) * CHAR_BIT;
- field->type.u.basic.integer.signedness = 0;
+ field->type.u.basic.integer.signedness = is_signed_type(unsigned long);
field->type.u.basic.integer.reverse_byte_order = 0;
field->type.u.basic.integer.base = 16;
field->type.u.basic.integer.encoding = lttng_encode_none;
event = field->u.perf_counter.e[ctx->cpu];
event->pmu->read(event);
value = local64_read(&event->count);
- lib_ring_buffer_align_ctx(ctx,
- ltt_alignof(field->type.u.basic.integer.alignment / CHAR_BIT));
+ lib_ring_buffer_align_ctx(ctx, ltt_alignof(value));
chan->ops->event_write(ctx, &value, sizeof(value));
}
field->type.atype = atype_integer;
field->type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT;
field->type.u.basic.integer.alignment = ltt_alignof(unsigned long) * CHAR_BIT;
- field->type.u.basic.integer.signedness = 0;
+ field->type.u.basic.integer.signedness = is_signed_type(unsigned long);
field->type.u.basic.integer.reverse_byte_order = 0;
field->type.u.basic.integer.base = 10;
field->type.u.basic.integer.encoding = lttng_encode_none;
#ifndef _LTTNG_PROBES_LTTNG_H
#define _LTTNG_PROBES_LTTNG_H
-#undef is_signed_type
-#define is_signed_type(type) (((type)(-1)) < 0)
-
#undef PARAMS
#define PARAMS(args...) args