fc2ab4f570b8182ef69f44a8e3375e5adcde1630
4 * LTTng UST trace/channel/event context management.
6 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; only
11 * version 2.1 of the License.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <lttng/ust-events.h>
25 #include <lttng/ust-tracer.h>
31 * The filter implementation requires that two consecutive "get" for the
32 * same context performed by the same thread return the same result.
35 int lttng_find_context(struct lttng_ctx
*ctx
, const char *name
)
39 for (i
= 0; i
< ctx
->nr_fields
; i
++) {
40 /* Skip allocated (but non-initialized) contexts */
41 if (!ctx
->fields
[i
].event_field
.name
)
43 if (!strcmp(ctx
->fields
[i
].event_field
.name
, name
))
49 int lttng_get_context_index(struct lttng_ctx
*ctx
, const char *name
)
55 for (i
= 0; i
< ctx
->nr_fields
; i
++) {
56 /* Skip allocated (but non-initialized) contexts */
57 if (!ctx
->fields
[i
].event_field
.name
)
59 if (!strcmp(ctx
->fields
[i
].event_field
.name
, name
))
66 * Note: as we append context information, the pointer location may change.
68 struct lttng_ctx_field
*lttng_append_context(struct lttng_ctx
**ctx_p
)
70 struct lttng_ctx_field
*field
;
71 struct lttng_ctx
*ctx
;
74 *ctx_p
= zmalloc(sizeof(struct lttng_ctx
));
79 if (ctx
->nr_fields
+ 1 > ctx
->allocated_fields
) {
80 struct lttng_ctx_field
*new_fields
;
82 ctx
->allocated_fields
= max_t(size_t, 1, 2 * ctx
->allocated_fields
);
83 new_fields
= zmalloc(ctx
->allocated_fields
* sizeof(struct lttng_ctx_field
));
87 memcpy(new_fields
, ctx
->fields
, sizeof(*ctx
->fields
) * ctx
->nr_fields
);
89 ctx
->fields
= new_fields
;
91 field
= &ctx
->fields
[ctx
->nr_fields
];
97 * Remove last context field.
99 void lttng_remove_context_field(struct lttng_ctx
**ctx_p
,
100 struct lttng_ctx_field
*field
)
102 struct lttng_ctx
*ctx
;
106 assert(&ctx
->fields
[ctx
->nr_fields
] == field
);
107 memset(&ctx
->fields
[ctx
->nr_fields
], 0, sizeof(struct lttng_ctx_field
));
110 void lttng_destroy_context(struct lttng_ctx
*ctx
)
116 for (i
= 0; i
< ctx
->nr_fields
; i
++) {
117 if (ctx
->fields
[i
].destroy
)
118 ctx
->fields
[i
].destroy(&ctx
->fields
[i
]);
This page took 0.033131 seconds and 4 git commands to generate.