From 34c1d1b53fc04ed12c02b45b34b204594354fc2e Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 1 Dec 2005 20:02:57 +0000 Subject: [PATCH] enable code for alignment and write git-svn-id: http://ltt.polymtl.ca/svn@1352 04897980-b3bd-0310-b5e0-8ef037075253 --- genevent-new/genevent.c | 50 +++++++++++++++------ genevent-new/parser.c | 26 ++++++----- genevent-new/test.xml | 99 +++++++++++++++++++++-------------------- 3 files changed, 104 insertions(+), 71 deletions(-) diff --git a/genevent-new/genevent.c b/genevent-new/genevent.c index e54398ac..1013d92f 100644 --- a/genevent-new/genevent.c +++ b/genevent-new/genevent.c @@ -543,11 +543,13 @@ int print_type_alignment(type_descriptor_t * td, FILE *fd, unsigned int tabs, * the array. */ if((basename_len != 0) && (basename[basename_len-1] != '_' + && field_name != NULL && (field_name[0] != '\0'))) { strncat(basename, "_", PATH_MAX - basename_len); basename_len = strlen(basename); } - strncat(basename, field_name, PATH_MAX - basename_len); + if(field_name != NULL) + strncat(basename, field_name, PATH_MAX - basename_len); } switch(td->type) { @@ -664,17 +666,17 @@ int print_type_write(type_descriptor_t * td, FILE *fd, unsigned int tabs, break; case SEQUENCE: print_tabs(tabs, fd); - fprintf(fd, "lttng_write_%s(buffer, to_base, to, from, len, obj->%s)", basename, + fprintf(fd, "lttng_write_%s(buffer, to_base, to, from, len, &obj->%s)", basename, field_name); break; case STRUCT: print_tabs(tabs, fd); - fprintf(fd, "lttng_write_struct_%s(buffer, to_base, to, from, len, obj->%s)", basename, + fprintf(fd, "lttng_write_struct_%s(buffer, to_base, to, from, len, &obj->%s)", basename, field_name); break; case UNION: print_tabs(tabs, fd); - fprintf(fd, "lttng_write_union_%s(buffer, to_base, to, from, len, obj->%s)", basename, + fprintf(fd, "lttng_write_union_%s(buffer, to_base, to, from, len, &obj->%s)", basename, field_name); break; case ARRAY: @@ -825,6 +827,7 @@ int print_type_alignment_fct(type_descriptor_t * td, FILE *fd, break; default: printf("print_type_alignment_fct : type has no alignment function.\n"); + return 0; break; } @@ -868,25 +871,34 @@ int print_type_write_fct(type_descriptor_t * td, FILE *fd, unsigned int tabs, strncat(basename, field_name, PATH_MAX - basename_len); } + switch(td->type) { + case SEQUENCE: + case STRUCT: + case UNION: + case ARRAY: + break; + default: + printf("print_type_write_fct : type has no write function.\n"); + return 0; + break; + } + /* Print header */ switch(td->type) { case SEQUENCE: - fprintf(fd, "static inline size_t lttng_get_alignment_sequence_%s(\n", + fprintf(fd, "static inline void lttng_write_sequence_%s(\n", basename); - - fprintf(fd, "lttng_get_alignment_sequence_%s(&obj->%s)", basename, - field_name); break; case STRUCT: - fprintf(fd, "lttng_get_alignment_struct_%s(&obj->%s)", basename, + fprintf(fd, "static inline void lttng_write_struct_%s(\n", basename, field_name); break; case UNION: - fprintf(fd, "lttng_get_alignment_union_%s(&obj->%s)", basename, + fprintf(fd, "static inline void lttng_write_union_%s(\n", basename, field_name); break; case ARRAY: - fprintf(fd, "lttng_get_alignment_array_%s(obj->%s)", basename, + fprintf(fd, "static inline void lttng_write_array_%s(\n", basename, field_name); break; default: @@ -959,7 +971,7 @@ int print_type_write_fct(type_descriptor_t * td, FILE *fd, unsigned int tabs, } print_tabs(1, fd); - fprintf(fd, "align = \n"); + fprintf(fd, "align = "); if(print_type_alignment(td, fd, 0, basename, field_name)) return 1; fprintf(fd, ";\n"); fprintf(fd, "\n"); @@ -1346,6 +1358,12 @@ int print_log_header_types(facility_t *fac, FILE *fd) /* For each named type, print the definition */ if((print_type_declaration(types->array[i], fd, 0, "", ""))) return 1; + /* Print also the align function */ + if((print_type_alignment_fct(types->array[i], fd, + 0, "", ""))) return 1; + /* Print also the write function */ + if((print_type_write_fct(types->array[i], fd, + 0, "", ""))) return 1; } return 0; } @@ -1372,9 +1390,15 @@ int print_log_header_events(facility_t *fac, FILE *fd) /* For each unnamed type, print the definition */ field_t *f = (field_t*)event->fields.array[j]; type_descriptor_t *t = f->type; - if(t->type_name == NULL) + if(t->type_name == NULL) { if((print_type_declaration(t, fd, 0, basename, f->name))) return 1; + /* Print also the align function */ + if((print_type_alignment_fct(t, fd, 0, basename, f->name))) return 1; + /* Print also the write function */ + if((print_type_write_fct(t, fd, 0, basename, f->name))) return 1; + } } + fprintf(fd, "\n"); fprintf(fd, "/* Event %s logging function */\n", diff --git a/genevent-new/parser.c b/genevent-new/parser.c index 48f3bdcf..425d390c 100644 --- a/genevent-new/parser.c +++ b/genevent-new/parser.c @@ -901,16 +901,22 @@ type_descriptor_t * find_named_type(char *name, table_t * named_types) type_descriptor_t *t; t = table_find(named_types,name); - if(t == NULL) { - t = (type_descriptor_t *)memAlloc(sizeof(type_descriptor_t)); - t->type_name = allocAndCopy(name); - t->type = NONE; - t->fmt = NULL; - table_insert(named_types,t->type_name,t); - // table_insert(named_types,allocAndCopy(name),t); - } + return t; -} +} + +type_descriptor_t * create_named_type(char *name, table_t * named_types) +{ + type_descriptor_t *t; + + t = (type_descriptor_t *)memAlloc(sizeof(type_descriptor_t)); + t->type_name = allocAndCopy(name); + t->type = NONE; + t->fmt = NULL; + table_insert(named_types,t->type_name,t); + // table_insert(named_types,allocAndCopy(name),t); + return t; +} /***************************************************************************** *Function name @@ -929,7 +935,7 @@ void parseTypeDefinition(parse_file_t * in, sequence_t * unnamed_types, token = getNameAttribute(in); if(token == NULL) in->error(in, "Type has empty name"); - t = find_named_type(token, named_types); + t = create_named_type(token, named_types); if(t->type != NONE) in->error(in,"redefinition of named type"); getRAnglebracket(in); // diff --git a/genevent-new/test.xml b/genevent-new/test.xml index 343c4625..5b870f83 100644 --- a/genevent-new/test.xml +++ b/genevent-new/test.xml @@ -1,6 +1,57 @@ The kernel facility has events related to kernel execution status. + + + + + + + + + + + + + + IRQ number + Are we executing kernel code + + + + + + IRQ number + Are we executing kernel code + + + + + + + + + + + + + + + + + + + + + + + + + System call entry Syscall entry number in entry.S @@ -71,52 +122,4 @@ - - - - - - - - - - - - - IRQ number - Are we executing kernel code - - - - - - - IRQ number - Are we executing kernel code - - - - - - - - - - - - - - - - - - - - - - -- 2.34.1