X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=probes%2Flttng-types.c;h=76519a88b1b919269979d3de78604eb75fd2e9f5;hb=886d51a3d7ed5fa6b41d7f19b3e14ae6c535a44c;hp=e1a41374b6cc0af8609fbb2ed88c4a2f135e4ff7;hpb=40652b65bb2b500ea04eaa61c3dfcfaa719073be;p=lttng-modules.git diff --git a/probes/lttng-types.c b/probes/lttng-types.c index e1a41374..76519a88 100644 --- a/probes/lttng-types.c +++ b/probes/lttng-types.c @@ -1,163 +1,50 @@ /* * probes/lttng-types.c * - * Copyright 2010 (c) - Mathieu Desnoyers - * * LTTng types. + * + * Copyright (C) 2010-2012 Mathieu Desnoyers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; only + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include -#include -#include /* tid_t */ -#include +#include "../wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */ +#include "../lttng-events.h" #include "lttng-types.h" - -struct dentry *lttng_types_dentry; - -#define ATYPE_ENTRY(name) [atype_##name] = #name - -const char * const astract_types[NR_ABSTRACT_TYPES] = { - ATYPE_ENTRY(integer), - ATYPE_ENTRY(enum), - ATYPE_ENTRY(array), -}; +#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_enum(struct seq_file *m, const struct lttng_enum *lttng_enum) -{ - int i; - - for (i = 0; i < lttng_enum->len; i++) { - if (lttng_enum->entries[i].start == lttng_enum->entries[i].end) - seq_printf(m, "\t\t{ %llu, %s },\n", - lttng_enum->entries[i].start, - lttng_enum->entries[i].string); - else - seq_printf(m, "\t\t{ { %llu, %llu }, %s },\n", - lttng_enum->entries[i].start, - lttng_enum->entries[i].end, - lttng_enum->entries[i].string); - } -} - -static void print_event_type(struct seq_file *m, const struct lttng_type *type) -{ - switch(type->atype) { - case atype_integer: - seq_printf(m, "type %s {\n" - "\tparent = %s;\n" - "\tsize = %u;\n" - "\tsigned = %u;\n" - "\talign = %u;\n" - "};\n", type->name, - astract_types[type->atype], - type->u.integer.size, - type->u.integer.signedness, - type->u.integer.alignment); - break; - case atype_enum: - seq_printf(m, "type %s {\n" - "\tparent = %s;\n" - "\tparent.parent = %s;\n" - "\tmap = {\n", - type->name, - astract_types[type->atype], - type->u.enumeration.parent_type); - print_enum(m, &type->u.enumeration.def); - seq_printf(m, "\t};\n" - "};\n"); - break; - case atype_array: - seq_printf(m, "type %s {\n" - "\tparent = %s;\n" - "\telem_type = %s;\n" - "\tlength = %u;\n" - "};\n", type->name, - astract_types[type->atype], - type->u.array.elem_type, - type->u.array.length); - break; - default: - seq_printf(m, "<<< unknown abstract type %s for type %s >>>\n", - astract_types[type->atype], - type->name); - } -} - -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; - - print_event_type(m, type); - 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; - 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; } @@ -165,7 +52,6 @@ module_init(lttng_types_init); static void lttng_types_exit(void) { - debugfs_remove(lttng_types_dentry); } module_exit(lttng_types_exit);