#include "ltt-events.h"
#include "ltt-tracer.h"
+int lttng_find_context(struct lttng_ctx *ctx, const char *name)
+{
+ unsigned int i;
+
+ for (i = 0; i < ctx->nr_fields; i++) {
+ if (!strcmp(ctx->fields[i].event_field.name, name))
+ return 1;
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_find_context);
+
struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p)
{
struct lttng_ctx_field *field;
int ltt_probes_init(void);
void ltt_probes_exit(void);
struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
+int lttng_find_context(struct lttng_ctx *ctx, const char *name);
void lttng_remove_context_field(struct lttng_ctx **ctx,
struct lttng_ctx_field *field);
void lttng_destroy_context(struct lttng_ctx *ctx);
field = lttng_append_context(ctx);
if (!field)
return -ENOMEM;
+ if (lttng_find_context(*ctx, "comm")) {
+ lttng_remove_context_field(ctx, field);
+ return -EEXIST;
+ }
field->event_field.name = "comm";
field->event_field.type.atype = atype_array;
field->event_field.type.u.array.elem_type.atype = atype_integer;
field = lttng_append_context(ctx);
if (!field)
return -ENOMEM;
+ if (lttng_find_context(*ctx, "nice")) {
+ lttng_remove_context_field(ctx, field);
+ return -EEXIST;
+ }
field->event_field.name = "nice";
field->event_field.type.atype = atype_integer;
field->event_field.type.u.basic.integer.size = sizeof(int) * CHAR_BIT;
ret = -ENOMEM;
goto append_context_error;
}
+ if (lttng_find_context(*ctx, name_alloc)) {
+ ret = -EEXIST;
+ goto find_error;
+ }
#ifdef CONFIG_HOTPLUG_CPU
field->u.perf_counter.nb.notifier_call =
#ifdef CONFIG_HOTPLUG_CPU
unregister_cpu_notifier(&field->u.perf_counter.nb);
#endif
+find_error:
lttng_remove_context_field(ctx, field);
append_context_error:
kfree(name_alloc);
field = lttng_append_context(ctx);
if (!field)
return -ENOMEM;
+ if (lttng_find_context(*ctx, "pid")) {
+ lttng_remove_context_field(ctx, field);
+ return -EEXIST;
+ }
field->event_field.name = "pid";
field->event_field.type.atype = atype_integer;
field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
field = lttng_append_context(ctx);
if (!field)
return -ENOMEM;
+ if (lttng_find_context(*ctx, "ppid")) {
+ lttng_remove_context_field(ctx, field);
+ return -EEXIST;
+ }
field->event_field.name = "ppid";
field->event_field.type.atype = atype_integer;
field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
field = lttng_append_context(ctx);
if (!field)
return -ENOMEM;
+ if (lttng_find_context(*ctx, "prio")) {
+ lttng_remove_context_field(ctx, field);
+ return -EEXIST;
+ }
field->event_field.name = "prio";
field->event_field.type.atype = atype_integer;
field->event_field.type.u.basic.integer.size = sizeof(int) * CHAR_BIT;
field = lttng_append_context(ctx);
if (!field)
return -ENOMEM;
+ if (lttng_find_context(*ctx, "tid")) {
+ lttng_remove_context_field(ctx, field);
+ return -EEXIST;
+ }
field->event_field.name = "tid";
field->event_field.type.atype = atype_integer;
field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
field = lttng_append_context(ctx);
if (!field)
return -ENOMEM;
+ if (lttng_find_context(*ctx, "vpid")) {
+ lttng_remove_context_field(ctx, field);
+ return -EEXIST;
+ }
field->event_field.name = "vpid";
field->event_field.type.atype = atype_integer;
field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
field = lttng_append_context(ctx);
if (!field)
return -ENOMEM;
+ if (lttng_find_context(*ctx, "vppid")) {
+ lttng_remove_context_field(ctx, field);
+ return -EEXIST;
+ }
field->event_field.name = "vppid";
field->event_field.type.atype = atype_integer;
field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
field = lttng_append_context(ctx);
if (!field)
return -ENOMEM;
+ if (lttng_find_context(*ctx, "vtid")) {
+ lttng_remove_context_field(ctx, field);
+ return -EEXIST;
+ }
field->event_field.name = "vtid";
field->event_field.type.atype = atype_integer;
field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;