X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=probes%2Flttng-types.c;h=2975cc496b3d769bcb6f2b60d201f30cd8a46479;hb=a90917c3f8c4ed79117f1caa333b29a2108084ec;hp=a4b40cf720b604466b03794dbc5c93f0ddc90dbe;hpb=a509e13364a2d024a2ae2acbeee3ac4ac2634842;p=lttng-modules.git diff --git a/probes/lttng-types.c b/probes/lttng-types.c index a4b40cf7..2975cc49 100644 --- a/probes/lttng-types.c +++ b/probes/lttng-types.c @@ -4,197 +4,35 @@ * Copyright 2010 (c) - Mathieu Desnoyers * * LTTng types. + * + * Dual LGPL v2.1/GPL v2 license. */ #include #include -#include -#include /* tid_t */ -#include -#include /* for vmalloc_sync_all */ +#include "../wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */ +#include "../lttng-events.h" #include "lttng-types.h" - -struct dentry *lttng_types_dentry; - -#undef ENTRY -#define ENTRY(name) [atype_##name] = #name - -const char * const astract_types[NR_ABSTRACT_TYPES] = { - ENTRY(integer), - ENTRY(enum), - ENTRY(array), - ENTRY(sequence), - ENTRY(string), -}; - -#undef ENTRY -#define ENTRY(name) [lttng_encode_##name] = #name - -const char * const string_encodings[NR_STRING_ENCODINGS] = { - ENTRY(UTF8), - ENTRY(ASCII), -}; +#include #define STAGE_EXPORT_ENUMS #include "lttng-types.h" #include "lttng-type-list.h" #undef STAGE_EXPORT_ENUMS -struct lttng_type lttng_types[] = { +struct lttng_enum lttng_enums[] = { #define STAGE_EXPORT_TYPES #include "lttng-types.h" #include "lttng-type-list.h" #undef STAGE_EXPORT_TYPES }; -static void print_indent(struct seq_file *m, unsigned int indent) -{ - int i; - - for (i = 0; i < indent; i++) - seq_printf(m, "\t"); -} - -static void print_enum(struct seq_file *m, unsigned int indent, - const struct lttng_enum *lttng_enum) -{ - int i; - - for (i = 0; i < lttng_enum->len; i++) { - print_indent(m, indent); - if (lttng_enum->entries[i].start == lttng_enum->entries[i].end) - seq_printf(m, "{ %llu, %s },\n", - lttng_enum->entries[i].start, - lttng_enum->entries[i].string); - else - seq_printf(m, "{ { %llu, %llu }, %s },\n", - lttng_enum->entries[i].start, - lttng_enum->entries[i].end, - lttng_enum->entries[i].string); - } -} - -void lttng_print_event_type(struct seq_file *m, unsigned int indent, - const struct lttng_type *type) -{ - print_indent(m, indent); - switch(type->atype) { - case atype_integer: - seq_printf(m, "type %s%s{ parent = %s; size = %u; signed = %u; align = %u;", - type->name ? : "", type->name ? " " : "", - astract_types[type->atype], - type->u.integer.size, - type->u.integer.signedness, - type->u.integer.alignment); - if (type->u.integer.reverse_byte_order) - seq_printf(m, " byte_order = %s;", - (__BYTE_ORDER == __LITTLE_ENDIAN) ? - "be" : "le"); - seq_printf(m, " }"); - break; - case atype_enum: - seq_printf(m, "type %s%s{ parent = %s; parent.parent = %s; map = {\n", - type->name ? : "", type->name ? " " : "", - astract_types[type->atype], - type->u.enumeration.parent_type); - print_enum(m, indent + 2, &type->u.enumeration.def); - print_indent(m, indent + 1); - seq_printf(m, "};\n"); - print_indent(m, indent); - seq_printf(m, "}"); - break; - case atype_array: - seq_printf(m, "type %s%s{ parent = %s; elem_type = %s; length = %u; }", - type->name ? : "", type->name ? " " : "", - astract_types[type->atype], - type->u.array.elem_type, - type->u.array.length); - break; - case atype_sequence: - seq_printf(m, "type %s%s{ parent = %s; elem_type = %s; length_type = %s; }", - type->name ? : "", type->name ? " " : "", - astract_types[type->atype], - type->u.sequence.elem_type, - type->u.sequence.length_type); - break; - case atype_string: - seq_printf(m, "type %s%s{ parent = %s; encoding = %s; }", - type->name ? : "", type->name ? " " : "", - astract_types[type->atype], - string_encodings[type->u.string.encoding]); - break; - default: - seq_printf(m, "<<< unknown abstract type %s for type %s%s>>>", - astract_types[type->atype], - type->name ? : "", type->name ? " " : ""); - } -} -EXPORT_SYMBOL_GPL(lttng_print_event_type); - -static void *lttng_seq_start(struct seq_file *m, loff_t *pos) -{ - struct lttng_type *type = <tng_types[*pos]; - - if (type > <tng_types[ARRAY_SIZE(lttng_types) - 1]) - return NULL; - return type; -} - -static void *lttng_seq_next(struct seq_file *m, void *v, loff_t *ppos) -{ - struct lttng_type *type = <tng_types[++(*ppos)]; - - if (type > <tng_types[ARRAY_SIZE(lttng_types) - 1]) - return NULL; - return type; -} - -static void lttng_seq_stop(struct seq_file *m, void *v) -{ -} - -static int lttng_seq_show(struct seq_file *m, void *v) -{ - struct lttng_type *type = v; - - lttng_print_event_type(m, 0, type); - seq_printf(m, ";\n"); - return 0; -} - -static const struct seq_operations lttng_types_seq_ops = { - .start = lttng_seq_start, - .next = lttng_seq_next, - .stop = lttng_seq_stop, - .show = lttng_seq_show, -}; - -static int -lttng_types_open(struct inode *inode, struct file *file) -{ - return seq_open(file, <tng_types_seq_ops); -} - -static const struct file_operations lttng_types_fops = { - .open = lttng_types_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release_private, -}; - static int lttng_types_init(void) { int ret = 0; - vmalloc_sync_all(); - lttng_types_dentry = debugfs_create_file("lttng-types", S_IWUSR, - NULL, NULL, <tng_types_fops); - if (IS_ERR(lttng_types_dentry) || !lttng_types_dentry) { - printk(KERN_ERR "Error creating LTTng type export file\n"); - ret = -ENOMEM; - goto error; - } -error: + wrapper_vmalloc_sync_all(); + /* TODO */ return ret; } @@ -202,7 +40,6 @@ module_init(lttng_types_init); static void lttng_types_exit(void) { - debugfs_remove(lttng_types_dentry); } module_exit(lttng_types_exit);