fprintf(fd, "%s", field->name);
fprintf(fd, ";\n");
}
- fprintf(fd, "} LTT_ALIGN;\n");
+ if(td->fac->align)
+ fprintf(fd, "} LTT_ALIGN;\n");
+ else
+ fprintf(fd, "};\n");
fprintf(fd, "\n");
break;
case UNION:
fprintf(fd, "%s", field->name);
fprintf(fd, ";\n");
}
- fprintf(fd, "} LTT_ALIGN;\n");
+ if(td->fac->align)
+ fprintf(fd, "} LTT_ALIGN;\n");
+ else
+ fprintf(fd, "};\n");
fprintf(fd, "\n");
break;
default:
case ENUM:
print_tabs(tabs, fd);
fprintf(fd, "align = ");
- if(print_type_alignment(td, fd, 0, basename, "", "obj")) return 1;
+ if(td->fac->align) {
+ if(print_type_alignment(td, fd, 0, basename, "", "obj")) return 1;
+ } else
+ fprintf(fd, "0");
fprintf(fd, ";\n");
fprintf(fd, "\n");
print_tabs(tabs, fd);
unsigned int basename_len = 0;
if(td->custom_write) return 0; /* Does print custom type */
+ if(td->fac->align == 0) return 0;
strncpy(basename, nest_name, PATH_MAX);
basename_len = strlen(basename);
print_tabs(1, fd);
fprintf(fd, "align = ");
- if(print_type_alignment(td, fd, 0, basename, "", "obj")) return 1;
+ if(td->fac->align) {
+ if(print_type_alignment(td, fd, 0, basename, "", "obj")) return 1;
+ } else
+ fprintf(fd, "0");
fprintf(fd, ";\n");
fprintf(fd, "\n");
print_tabs(1, fd);
print_tabs(1, fd);
fprintf(fd, "/* Realign the *to_base on arch size, set *to to 0 */\n");
print_tabs(1, fd);
- fprintf(fd, "*to += ltt_align(*to, sizeof(void *));\n");
+ if(td->fac->align)
+ fprintf(fd, "*to += ltt_align(*to, sizeof(void *));\n");
print_tabs(1, fd);
fprintf(fd, "*to_base = *to_base+*to;\n");
print_tabs(1, fd);
print_tabs(1, fd);
fprintf(fd, "/* Realign the *to_base on arch size, set *to to 0 */\n");
print_tabs(1, fd);
- fprintf(fd, "*to += ltt_align(*to, sizeof(void *));\n");
+ if(td->fac->align)
+ fprintf(fd, "*to += ltt_align(*to, sizeof(void *));\n");
print_tabs(1, fd);
fprintf(fd, "*to_base = *to_base+*to;\n");
print_tabs(1, fd);
fprintf(fd, "size_t before_hdr_pad, after_hdr_pad, header_size;\n");
fprintf(fd, "\n");
- print_tabs(1, fd);
- fprintf(fd, "if (ltt_traces.num_active_traces == 0)\n");
- print_tabs(2, fd);
- fprintf(fd, "return;\n");
- fprintf(fd, "\n");
+ if(!event->force) {
+ print_tabs(1, fd);
+ fprintf(fd, "if (ltt_traces.num_active_traces == 0)\n");
+ print_tabs(2, fd);
+ fprintf(fd, "return;\n");
+ fprintf(fd, "\n");
+ }
/* Calculate event variable len + event data alignment offset.
* Assume that the padding for alignment starts at a void*
/* For each trace */
print_tabs(1, fd);
fprintf(fd, "list_for_each_entry_rcu(trace, <t_traces.head, list) {\n");
- print_tabs(2, fd);
- fprintf(fd, "if (!trace->active)\n");
- print_tabs(3, fd);
- fprintf(fd, "continue;\n\n");
+ if(!event->force) {
+ print_tabs(2, fd);
+ fprintf(fd, "if (!trace->active)\n");
+ print_tabs(3, fd);
+ fprintf(fd, "continue;\n\n");
+ }
if(event->per_trace) {
print_tabs(2, fd);
fprintf(fd, "\n");
/* Write event header */
- print_tabs(2, fd);
- fprintf(fd, "ltt_write_event_header(trace, channel, buffer,\n");
- print_tabs(3, fd);
- fprintf(fd, "ltt_facility_%s_%X, event_%s_%s,\n", fac->name, fac->checksum,
- fac->name, event->name);
- print_tabs(3, fd);
- fprintf(fd, "reserve_size, before_hdr_pad, tsc);\n");
+ if(strcmp("compact", fac->name) != 0) {
+ print_tabs(2, fd);
+ fprintf(fd, "ltt_write_event_header(trace, channel, buffer,\n");
+ print_tabs(3, fd);
+ fprintf(fd, "ltt_facility_%s_%X, event_%s_%s,\n", fac->name, fac->checksum,
+ fac->name, event->name);
+ print_tabs(3, fd);
+ fprintf(fd, "reserve_size, before_hdr_pad, tsc);\n");
+ } else {
+ print_tabs(2, fd);
+ fprintf(fd, "ltt_write_compact_header(trace, channel, buffer,\n");
+ print_tabs(3, fd);
+ fprintf(fd, "ltt_facility_%s_%X, event_%s_%s,\n", fac->name, fac->checksum,
+ fac->name, event->name);
+ print_tabs(3, fd);
+ fprintf(fd, "reserve_size, before_hdr_pad, tsc, compact_data);\n");
+ }
print_tabs(2, fd);
fprintf(fd, "*to_base += before_hdr_pad + after_hdr_pad + header_size;\n");
fprintf(fd, "\n");
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,
+ if(((type_descriptor_t*)types->array[i])->fac->align)
+ 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,
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;
+ if(fac->align) {
+ 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,"#define LTT_FACILITY_NAME\t\t\"%s\"\n", fac->name);
fprintf(fd,"#define LTT_FACILITY_NUM_EVENTS\tfacility_%s_num_events\n\n",
fac->name);
+ fprintf(fd,"#define LTT_FACILITY_ALIGNMENT\t\t%u\n\n",
+ fac->align);
fprintf(fd, "#endif //CONFIG_LTT\n\n");
fprintf(fd, "#endif //_LTT_FACILITY_LOADER_%s_H_\n", fac->capname);
fprintf(fd,"#define LTT_FACILITY_NAME\t\t\t\t\t\t\t\t\"%s\"\n", fac->name);
fprintf(fd,"#define LTT_FACILITY_NUM_EVENTS\t\t\t\t\tfacility_%s_num_events\n\n",
fac->name);
+ fprintf(fd,"#define LTT_FACILITY_ALIGNMENT\t\t\t\t\t%u\n\n",
+ fac->align);
fprintf(fd, "#endif //_LTT_FACILITY_LOADER_%s_H_\n", fac->capname);
fclose(fd);
fprintf(fd, "\t.num_events = LTT_FACILITY_NUM_EVENTS,\n");
fprintf(fd, "\t.checksum = LTT_FACILITY_CHECKSUM,\n");
fprintf(fd, "\t.symbol = SYMBOL_STRING(LTT_FACILITY_SYMBOL),\n");
+ fprintf(fd, "\t.alignment = LTT_FACILITY_ALIGNMENT,\n");
fprintf(fd, "};\n");
fprintf(fd, "\n");
fprintf(fd, "static int __init facility_init(void)\n");
fprintf(fd, "\t.name = LTT_FACILITY_NAME,\n");
fprintf(fd, "\t.num_events = LTT_FACILITY_NUM_EVENTS,\n");
fprintf(fd, "#ifndef LTT_PACK\n");
- fprintf(fd, "\t.alignment = sizeof(void*),\n");
+ fprintf(fd, "\t.alignment = LTT_FACILITY_ALIGNMENT?sizeof(void*):0,\n");
fprintf(fd, "#else\n");
fprintf(fd, "\t.alignment = 0,\n");
fprintf(fd, "#endif //LTT_PACK\n");
**************************************************************************/
void getTypeAttributes(parse_file_t *in, type_descriptor_t *t,
- sequence_t * unnamed_types, table_t * named_types)
+ sequence_t * unnamed_types, table_t * named_types)
{
char * token;
int car;
t->fmt = NULL;
t->size = 0;
t->custom_write = 0;
- t->network = 0;
+ t->network = 0;
while(1) {
token = getToken(in);
t->size = getSize(in);
} else if(!strcmp("custom_write", token)) {
t->custom_write = 1;
- } else if(!strcmp("byte_order",token)) {
- getEqual(in);
- car = seekNextChar(in);
- if(car == EOF) in->error(in,"byte order was expected (network?)");
- else if(car == '\"') token = getQuotedString(in);
- else token = getName(in);
- if(!strcmp("network", token)) {
- t->network = 1;
- }
- } else if(!strcmp("write",token)) {
- getEqual(in);
- car = seekNextChar(in);
- if(car == EOF) in->error(in,"write type was expected (custom?)");
- else if(car == '\"') token = getQuotedString(in);
- else token = getName(in);
- if(!strcmp("custom", token)) {
- t->custom_write = 1;
- }
- }
- }
+ } else if(!strcmp("byte_order",token)) {
+ getEqual(in);
+ car = seekNextChar(in);
+ if(car == EOF) in->error(in,"byte order was expected (network?)");
+ else if(car == '\"') token = getQuotedString(in);
+ else token = getName(in);
+ if(!strcmp("network", token)) {
+ t->network = 1;
+ }
+ } else if(!strcmp("write",token)) {
+ getEqual(in);
+ car = seekNextChar(in);
+ if(car == EOF) in->error(in,"write type was expected (custom?)");
+ else if(car == '\"') token = getQuotedString(in);
+ else token = getName(in);
+ if(!strcmp("custom", token)) {
+ t->custom_write = 1;
+ }
+ }
+ }
}
/**************************************************************************
ev->param_buffer = 0;
ev->no_instrument_function = 0;
ev->high_priority = 0;
+ ev->force = 0;
+ ev->compact_data = 0;
while(1) {
token = getToken(in);
ev->no_instrument_function = 1;
else if(!strcmp(token, "high_priority"))
ev->high_priority = 1;
+ else if(!strcmp(token, "force"))
+ ev->force = 1;
+ else if(!strcmp(token, "compact_data"))
+ ev->compact_data = 1;
}
}
}
fac->name = NULL;
fac->arch = NULL;
- fac->user = 0;
+ fac->align = 1;
+ fac->user = 0;
while(1) {
token = getToken(in);
getEqual(in);
car = seekNextChar(in);
if(car == '\"') fac->arch = allocAndCopy(getQuotedString(in));
- else fac->arch = allocAndCopy(getName(in));
- }
+ else fac->arch = allocAndCopy(getName(in));
+ } else if(!strcmp("align", token)) {
+ getEqual(in);
+ fac->align = getSize(in);
+ }
+
}
}
if(strcmp("event",token) == 0){
ev = (event_t*) memAlloc(sizeof(event_t));
sequence_push(&(fac->events),ev);
- parseEvent(in,ev, &(fac->unnamed_types), &(fac->named_types));
+ parseEvent(fac, in, ev, &(fac->unnamed_types), &(fac->named_types));
}else if(strcmp("type",token) == 0){
- parseTypeDefinition(in, &(fac->unnamed_types), &(fac->named_types));
+ parseTypeDefinition(fac, in, &(fac->unnamed_types), &(fac->named_types));
}else if(in->type == FORWARDSLASH){
break;
}else in->error(in,"event or type token expected\n");
/*****************************************************************************
*Function name
* parseEvent : generate event from event definition
- *Input params
+ *Input params
+ * fac : facility holding the event
* in : input file handle
* ev : new event
* unnamed_types : array of unamed types
* ev : new event (parameters are passed to it)
****************************************************************************/
-void parseEvent(parse_file_t *in, event_t * ev, sequence_t * unnamed_types,
+void parseEvent(facility_t *fac, parse_file_t *in, event_t * ev, sequence_t * unnamed_types,
table_t * named_types)
{
char *token;
field_t *f;
+ ev->fac = fac;
sequence_init(&(ev->fields));
//<event name=eventtype_name>
getEventAttributes(in, ev);
if(strcmp("field",token))in->error(in,"expecting a field");
f = (field_t *)memAlloc(sizeof(field_t));
sequence_push(&(ev->fields),f);
- parseFields(in, f, unnamed_types, named_types, 1);
+ parseFields(fac, in, f, unnamed_types, named_types, 1);
break;
default:
in->error(in, "expecting </event> or <field >");
*Function name
* parseField : get field infomation from buffer
*Input params
+ * fac : facility holding the field
* in : input file handle
* f : field
* unnamed_types : array of unamed types
* tag : is field surrounded by a <field> </field> tag ?
****************************************************************************/
-void parseFields(parse_file_t *in, field_t *f,
+void parseFields(facility_t *fac, parse_file_t *in, field_t *f,
sequence_t * unnamed_types,
table_t * named_types,
int tag)
{
char * token;
+ f->fac = fac;
if(tag) {
//<field name=field_name> <description> <type> </field>
getFieldAttributes(in, f);
//<int size=...>
getLAnglebracket(in);
- f->type = parseType(in,NULL, unnamed_types, named_types);
+ f->type = parseType(fac, in,NULL, unnamed_types, named_types);
if(tag) {
getLAnglebracket(in);
* type name:
* type(name,type)
*Input params
+ * fac : facility
* in : input file handle
* inType : a type descriptor
* unnamed_types : array of unamed types
* type_descriptor* : a type descriptor
****************************************************************************/
-type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType,
+type_descriptor_t *parseType(facility_t *fac, parse_file_t *in, type_descriptor_t *inType,
sequence_t * unnamed_types, table_t * named_types)
{
char *token;
sequence_push(unnamed_types,t);
}
else t = inType;
+ t->fac = fac;
token = getName(in);
f = (field_t *)memAlloc(sizeof(field_t));
sequence_push(&(t->fields),f);
- parseFields(in, f, unnamed_types, named_types, 1);
+ parseFields(fac, in, f, unnamed_types, named_types, 1);
//next field
getLAnglebracket(in);
while(strcmp("field",token) == 0){
f = (field_t *)memAlloc(sizeof(field_t));
sequence_push(&(t->fields),f);
- parseFields(in, f, unnamed_types, named_types, 1);
+ parseFields(fac, in, f, unnamed_types, named_types, 1);
//next field
getLAnglebracket(in);
f->name = NULL;
sequence_push(&(t->fields),f);
- parseFields(in, f, unnamed_types, named_types, 0);
+ parseFields(fac, in, f, unnamed_types, named_types, 0);
//getLAnglebracket(in); //<type struct>
//t->nested_type = parseType(in, NULL, unnamed_types, named_types);
f = (field_t *)memAlloc(sizeof(field_t));
f->name = NULL;
sequence_push(&(t->fields),f);
- parseFields(in, f, unnamed_types, named_types, 0);
+ parseFields(fac, in, f, unnamed_types, named_types, 0);
//getLAnglebracket(in); //<subtype>
/* subfield */
f = (field_t *)memAlloc(sizeof(field_t));
f->name = NULL;
sequence_push(&(t->fields),f);
- parseFields(in, f, unnamed_types, named_types, 0);
+ parseFields(fac, in, f, unnamed_types, named_types, 0);
//getLAnglebracket(in); //<type sequence>
//t->length_type = parseType(in, NULL, unnamed_types, named_types);
*Function name
* parseTypeDefinition : get type information from type definition
*Input params
+ * fac : facility
* in : input file handle
* unnamed_types : array of unamed types
* named_types : array of named types
*****************************************************************************/
-void parseTypeDefinition(parse_file_t * in, sequence_t * unnamed_types,
+void parseTypeDefinition(facility_t *fac, parse_file_t * in, sequence_t * unnamed_types,
table_t * named_types)
{
char *token;
token = getName(in);
//MD ??if(strcmp("struct",token))in->error(in,"not a valid type definition");
ungetToken(in);
- parseType(in,t, unnamed_types, named_types);
+ parseType(fac, in,t, unnamed_types, named_types);
//</type>
getLAnglebracket(in);
NONE
} data_type_t;
+typedef struct _facility facility_t;
+typedef struct _event event_t;
+
typedef struct _type_descriptor {
+ facility_t *fac;
char * type_name; //used for named type
data_type_t type;
char *fmt;
} type_descriptor_t;
-
/* Fields within types or events */
typedef struct _field{
+ facility_t *fac;
char *name;
char *description;
type_descriptor_t *type;
/* Events definitions */
-typedef struct _event {
+struct _event {
+ facility_t *fac;
char *name;
char *description;
//type_descriptor_t *type;
- sequence_t fields; /* event fields */
+ 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? */
- int no_instrument_function;
- int high_priority;
-} event_t;
+ int param_buffer; /* For userspace tracing : takes a buffer as parameter? */
+ int no_instrument_function;
+ int high_priority;
+ int force;
+ int compact_data;
+};
-typedef struct _facility {
+struct _facility {
char * name;
- char * capname;
- char * arch;
+ char * capname;
+ char * arch;
+ int align; /* Alignment : default 1, 0 no alignment. */
char * description;
sequence_t events;
sequence_t unnamed_types; //FIXME : remove
table_t named_types;
- unsigned int checksum;
- int user; /* Is this a userspace facility ? */
-} facility_t;
+ unsigned int checksum;
+ int user; /* Is this a userspace facility ? */
+};
int getSizeindex(unsigned int value);
unsigned long long int getSize(parse_file_t *in);
unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor_t * type);
void parseFacility(parse_file_t *in, facility_t * fac);
-void parseEvent(parse_file_t *in, event_t *ev, sequence_t * unnamed_types,
+void parseEvent(facility_t *fac, parse_file_t *in, event_t *ev, sequence_t * unnamed_types,
table_t * named_types);
-void parseTypeDefinition(parse_file_t *in,
+void parseTypeDefinition(facility_t *fac, parse_file_t *in,
sequence_t * unnamed_types, table_t * named_types);
-type_descriptor_t *parseType(parse_file_t *in,
+type_descriptor_t *parseType(facility_t *fac, parse_file_t *in,
type_descriptor_t *t, sequence_t * unnamed_types, table_t * named_types);
-void parseFields(parse_file_t *in, field_t *f,
+void parseFields(facility_t *fac, parse_file_t *in, field_t *f,
sequence_t * unnamed_types,
table_t * named_types,
int tag);