X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttng-context-callstack.c;h=1e791f9c5b24eaa62bad40fe079d5432be5c095c;hb=263b6c88138c3354d63dba3c70a965de94becd22;hp=3fccfcf270bf34e48053a5ab30b761d1dc5bffd6;hpb=b6ee48d2a69c34bf5dd44319cba19bedbbd35fca;p=lttng-modules.git diff --git a/lttng-context-callstack.c b/lttng-context-callstack.c index 3fccfcf2..1e791f9c 100644 --- a/lttng-context-callstack.c +++ b/lttng-context-callstack.c @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) * * lttng-context-callstack.c * @@ -48,8 +48,13 @@ #include "wrapper/ringbuffer/frontend.h" #include "wrapper/vmalloc.h" #include "lttng-tracer.h" +#include "lttng-endian.h" +#ifdef CONFIG_ARCH_STACKWALK +#include "lttng-context-callstack-stackwalk-impl.h" +#else #include "lttng-context-callstack-legacy-impl.h" +#endif static void field_data_free(struct field_data *fdata) @@ -63,7 +68,6 @@ void field_data_free(struct field_data *fdata) static struct field_data __percpu *field_data_create(enum lttng_cs_ctx_modes mode) { - int cpu, i; struct lttng_cs __percpu *cs_set; struct field_data *fdata; @@ -73,20 +77,8 @@ struct field_data __percpu *field_data_create(enum lttng_cs_ctx_modes mode) cs_set = alloc_percpu(struct lttng_cs); if (!cs_set) goto error_alloc; - + lttng_cs_set_init(cs_set); fdata->cs_percpu = cs_set; - for_each_possible_cpu(cpu) { - struct lttng_cs *cs; - - cs = per_cpu_ptr(cs_set, cpu); - for (i = 0; i < RING_BUFFER_MAX_NESTING; i++) { - struct lttng_cs_dispatch *dispatch; - - dispatch = &cs->dispatch[i]; - dispatch->stack_trace.entries = dispatch->entries; - dispatch->stack_trace.max_entries = MAX_ENTRIES; - } - } fdata->mode = mode; return fdata; @@ -96,28 +88,38 @@ error_alloc: } static -void lttng_callstack_destroy(struct lttng_ctx_field *field) +void lttng_callstack_sequence_destroy(struct lttng_ctx_field *field) { struct field_data *fdata = field->priv; field_data_free(fdata); } +static const struct lttng_type sequence_elem_type = + __type_integer(unsigned long, 0, 0, -1, __BYTE_ORDER, 16, none); + static int __lttng_add_callstack_generic(struct lttng_ctx **ctx, enum lttng_cs_ctx_modes mode) { - const char *ctx_name = cs_types[mode].name; - struct lttng_ctx_field *field; + const char *ctx_name = lttng_cs_ctx_mode_name(mode); + const char *ctx_length_name = lttng_cs_ctx_mode_length_name(mode); + struct lttng_ctx_field *length_field, *sequence_field; + struct lttng_event_field *field; struct field_data *fdata; int ret; ret = init_type(mode); if (ret) return ret; - field = lttng_append_context(ctx); - if (!field) + length_field = lttng_append_context(ctx); + if (!length_field) return -ENOMEM; + sequence_field = lttng_append_context(ctx); + if (!sequence_field) { + lttng_remove_context_field(ctx, length_field); + return -ENOMEM; + } if (lttng_find_context(*ctx, ctx_name)) { ret = -EEXIST; goto error_find; @@ -128,35 +130,36 @@ int __lttng_add_callstack_generic(struct lttng_ctx **ctx, goto error_create; } - field->event_field.name = ctx_name; - field->event_field.type.atype = atype_sequence; - field->event_field.type.u.sequence.elem_type.atype = atype_integer; - field->event_field.type.u.sequence.elem_type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT; - field->event_field.type.u.sequence.elem_type.u.basic.integer.alignment = lttng_alignof(long) * CHAR_BIT; - field->event_field.type.u.sequence.elem_type.u.basic.integer.signedness = lttng_is_signed_type(unsigned long); - field->event_field.type.u.sequence.elem_type.u.basic.integer.reverse_byte_order = 0; - field->event_field.type.u.sequence.elem_type.u.basic.integer.base = 16; - field->event_field.type.u.sequence.elem_type.u.basic.integer.encoding = lttng_encode_none; - - field->event_field.type.u.sequence.length_type.atype = atype_integer; - field->event_field.type.u.sequence.length_type.u.basic.integer.size = sizeof(unsigned int) * CHAR_BIT; - field->event_field.type.u.sequence.length_type.u.basic.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT; - field->event_field.type.u.sequence.length_type.u.basic.integer.signedness = lttng_is_signed_type(unsigned int); - field->event_field.type.u.sequence.length_type.u.basic.integer.reverse_byte_order = 0; - field->event_field.type.u.sequence.length_type.u.basic.integer.base = 10; - field->event_field.type.u.sequence.length_type.u.basic.integer.encoding = lttng_encode_none; - - field->get_size_arg = lttng_callstack_get_size; - field->record = lttng_callstack_record; - field->priv = fdata; - field->destroy = lttng_callstack_destroy; - wrapper_vmalloc_sync_all(); + field = &length_field->event_field; + field->name = ctx_length_name; + field->type.atype = atype_integer; + field->type.u.integer.size = sizeof(unsigned int) * CHAR_BIT; + field->type.u.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT; + field->type.u.integer.signedness = lttng_is_signed_type(unsigned int); + field->type.u.integer.reverse_byte_order = 0; + field->type.u.integer.base = 10; + field->type.u.integer.encoding = lttng_encode_none; + length_field->get_size_arg = lttng_callstack_length_get_size; + length_field->record = lttng_callstack_length_record; + + field = &sequence_field->event_field; + field->name = ctx_name; + field->type.atype = atype_sequence_nestable; + field->type.u.sequence_nestable.elem_type = &sequence_elem_type; + field->type.u.sequence_nestable.alignment = 0; + sequence_field->get_size_arg = lttng_callstack_sequence_get_size; + sequence_field->record = lttng_callstack_sequence_record; + sequence_field->priv = fdata; + sequence_field->destroy = lttng_callstack_sequence_destroy; + + wrapper_vmalloc_sync_mappings(); return 0; error_create: field_data_free(fdata); error_find: - lttng_remove_context_field(ctx, field); + lttng_remove_context_field(ctx, sequence_field); + lttng_remove_context_field(ctx, length_field); return ret; }