From: compudj Date: Mon, 6 Mar 2006 16:01:38 +0000 (+0000) Subject: add slow_printf support to generic X-Git-Tag: v0.12.20~1907 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1e08067e6117bec20132c95893616588f3e03ec7;p=lttv.git add slow_printf support to generic git-svn-id: http://ltt.polymtl.ca/svn@1582 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/genevent-new/genevent.c b/genevent-new/genevent.c index f3768ce7..e640834d 100644 --- a/genevent-new/genevent.c +++ b/genevent-new/genevent.c @@ -1588,20 +1588,38 @@ int print_event_logging_function(char *basename, facility_t *fac, int print_event_logging_function_user(char *basename, facility_t *fac, event_t *event, FILE *fd) { - fprintf(fd, "static inline int trace_%s(\n", basename); + if(event->param_buffer) { + fprintf(fd, "static inline int trace_%s_param_buffer(\n", basename); + } else { + fprintf(fd, "static inline int trace_%s(\n", basename); + } int has_argument = 0; int has_type_fixed = 0; - for(unsigned int j = 0; j < event->fields.position; j++) { - /* For each field, print the function argument */ - field_t *f = (field_t*)event->fields.array[j]; - type_descriptor_t *t = f->type; + if(event->param_buffer) { if(has_argument) { - fprintf(fd, ","); - fprintf(fd, "\n"); + fprintf(fd, ","); + fprintf(fd, "\n"); } - if(print_arg(t, fd, 2, basename, f->name)) return 1; + print_tabs(2, fd); + fprintf(fd, "void *buffer"); has_argument = 1; + fprintf(fd, ","); + fprintf(fd, "\n"); + print_tabs(2, fd); + fprintf(fd, "size_t reserve_size"); + } else { + for(unsigned int j = 0; j < event->fields.position; j++) { + /* For each field, print the function argument */ + field_t *f = (field_t*)event->fields.array[j]; + type_descriptor_t *t = f->type; + if(has_argument) { + fprintf(fd, ","); + fprintf(fd, "\n"); + } + if(print_arg(t, fd, 2, basename, f->name)) return 1; + has_argument = 1; + } } if(!has_argument) { print_tabs(2, fd); @@ -1616,6 +1634,15 @@ int print_event_logging_function_user(char *basename, facility_t *fac, fprintf(fd, "{\n"); /* Print the function variables */ print_tabs(1, fd); + fprintf(fd, "int ret = 0;\n"); + if(event->param_buffer) { + print_tabs(1, fd); + fprintf(fd, "reserve_size = ltt_align(reserve_size, sizeof(void *));\n"); + print_tabs(1, fd); + fprintf(fd, "{\n"); + goto do_syscall; + } + print_tabs(1, fd); fprintf(fd, "void *buffer = NULL;\n"); print_tabs(1, fd); fprintf(fd, "size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */\n"); @@ -1634,8 +1661,6 @@ int print_event_logging_function_user(char *basename, facility_t *fac, print_tabs(1, fd); fprintf(fd, "size_t slot_size;\n"); print_tabs(1, fd); - fprintf(fd, "int ret = 0;\n"); - print_tabs(1, fd); if(event->fields.position > 0) { for(unsigned int i=0;ifields.position;i++){ @@ -1758,9 +1783,9 @@ int print_event_logging_function_user(char *basename, facility_t *fac, fprintf(fd, "\n"); } - +do_syscall: print_tabs(2, fd); - fprintf(fd, "ret = ltt_trace_generic(ltt_facility_%s_%X, event_%s_%s, stack_buffer, sizeof(stack_buffer));\n", fac->name, fac->checksum, fac->name, event->name); + fprintf(fd, "ret = ltt_trace_generic(ltt_facility_%s_%X, event_%s_%s, buffer, reserve_size, LTT_BLOCKING);\n", fac->name, fac->checksum, fac->name, event->name); print_tabs(1, fd); fprintf(fd, "}\n\n"); diff --git a/genevent-new/parser.c b/genevent-new/parser.c index 3183367e..ba331e9e 100644 --- a/genevent-new/parser.c +++ b/genevent-new/parser.c @@ -247,6 +247,7 @@ void getEventAttributes(parse_file_t *in, event_t *ev) ev->name = NULL; ev->per_trace = 0; ev->per_tracefile = 0; + ev->param_buffer = 0; while(1) { token = getToken(in); @@ -265,7 +266,9 @@ void getEventAttributes(parse_file_t *in, event_t *ev) ev->per_trace = 1; } else if(!strcmp("per_tracefile", token)) { ev->per_tracefile = 1; - } + } else if(!strcmp("param_buffer", token)) { + ev->param_buffer = 1; + } } } diff --git a/genevent-new/parser.h b/genevent-new/parser.h index c0394049..7c579e00 100644 --- a/genevent-new/parser.h +++ b/genevent-new/parser.h @@ -134,6 +134,7 @@ typedef struct _event { sequence_t fields; /* event fields */ int per_trace; /* Is the event able to be logged to a specific trace ? */ int per_tracefile; /* Must we log this event in a specific tracefile ? */ + int param_buffer; /* For userspace tracing : takes a buffer as parameter? */ } event_t; typedef struct _facility {