From 4ea155a2759e8aa65d9f211d4b9c594de40b0da9 Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 5 Apr 2007 21:06:18 +0000 Subject: [PATCH 1/1] update to new changes (serializer git-svn-id: http://ltt.polymtl.ca/svn@2476 04897980-b3bd-0310-b5e0-8ef037075253 --- .../ltt-facility-loader-user_generic.c | 4 +- .../ltt-facility-loader-user_generic.h | 2 + ltt-usertrace/ltt/ltt-facility-user_generic.h | 202 ++++++++---------- ltt-usertrace/ltt/ltt-usertrace-fast.h | 41 ++-- ltt-usertrace/ltt/ltt-usertrace.h | 2 +- 5 files changed, 113 insertions(+), 138 deletions(-) diff --git a/ltt-usertrace/ltt-facility-loader-user_generic.c b/ltt-usertrace/ltt-facility-loader-user_generic.c index 8314ef82..68890dbf 100644 --- a/ltt-usertrace/ltt-facility-loader-user_generic.c +++ b/ltt-usertrace/ltt-facility-loader-user_generic.c @@ -19,7 +19,7 @@ static struct user_facility_info facility = { .name = LTT_FACILITY_NAME, .num_events = LTT_FACILITY_NUM_EVENTS, #ifndef LTT_PACK - .alignment = sizeof(void*), + .alignment = LTT_FACILITY_ALIGNMENT?sizeof(void*):0, #else .alignment = 0, #endif //LTT_PACK @@ -40,7 +40,7 @@ static void __attribute__((constructor)) __ltt_user_init(void) err = ltt_register_generic(<T_FACILITY_SYMBOL, &facility); LTT_FACILITY_CHECKSUM_SYMBOL = LTT_FACILITY_SYMBOL; - if(err) { + if (err) { #ifdef LTT_SHOW_DEBUG perror("Error in ltt_register_generic"); #endif //LTT_SHOW_DEBUG diff --git a/ltt-usertrace/ltt-facility-loader-user_generic.h b/ltt-usertrace/ltt-facility-loader-user_generic.h index 7bb6c0d8..5b616bb6 100644 --- a/ltt-usertrace/ltt-facility-loader-user_generic.h +++ b/ltt-usertrace/ltt-facility-loader-user_generic.h @@ -13,4 +13,6 @@ ltt_facility_t ltt_facility_user_generic_B1865E44; #define LTT_FACILITY_NAME "user_generic" #define LTT_FACILITY_NUM_EVENTS facility_user_generic_num_events +#define LTT_FACILITY_ALIGNMENT 1 + #endif //_LTT_FACILITY_LOADER_USER_GENERIC_H_ diff --git a/ltt-usertrace/ltt/ltt-facility-user_generic.h b/ltt-usertrace/ltt/ltt-facility-user_generic.h index 597caf96..1bf5fac1 100644 --- a/ltt-usertrace/ltt/ltt-facility-user_generic.h +++ b/ltt-usertrace/ltt/ltt-facility-user_generic.h @@ -24,8 +24,8 @@ static inline void lttng_write_string_user_generic_string_data( size_t align; /* Flush pending memcpy */ - if(*len != 0) { - if(buffer != NULL) + if (*len != 0) { + if (buffer != NULL) memcpy(buffer+*to_base+*to, *from, *len); } *to += *len; @@ -33,7 +33,7 @@ static inline void lttng_write_string_user_generic_string_data( align = sizeof(char); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -42,7 +42,7 @@ static inline void lttng_write_string_user_generic_string_data( /* Contains variable sized fields : must explode the structure */ size = strlen(obj) + 1; /* Include final NULL char. */ - if(buffer != NULL) + if (buffer != NULL) memcpy(buffer+*to_base+*to, obj, size); *to += size; @@ -99,7 +99,7 @@ static inline int trace_user_generic_string( lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -137,9 +137,7 @@ static inline int trace_user_generic_string( const char *real_from; const char **from = &real_from; uint64_t tsc; - size_t before_hdr_pad, after_hdr_pad, header_size; - - if(!trace) { + if (!trace) { ltt_thread_init(); trace = thread_trace_info; } @@ -162,22 +160,20 @@ static inline int trace_user_generic_string( ltt_buf = ltt_get_channel_from_index(trace, index); slot_size = 0; buffer = ltt_reserve_slot(trace, ltt_buf, - reserve_size, &slot_size, &tsc, - &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) goto end; /* buffer full */ + reserve_size, &slot_size, &tsc); + if (!buffer) + goto end; /* buffer full */ *to_base = *to = *len = 0; - ltt_write_event_header(trace, ltt_buf, buffer, + buffer = ltt_write_event_header(trace, ltt_buf, buffer, ltt_facility_user_generic_B1865E44, event_user_generic_string, - reserve_size, before_hdr_pad, tsc); - *to_base += before_hdr_pad + after_hdr_pad + header_size; - + reserve_size, tsc); *from = (const char*)lttng_param_data; lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -206,8 +202,8 @@ static inline void lttng_write_string_user_generic_string_pointer_string( size_t align; /* Flush pending memcpy */ - if(*len != 0) { - if(buffer != NULL) + if (*len != 0) { + if (buffer != NULL) memcpy(buffer+*to_base+*to, *from, *len); } *to += *len; @@ -215,7 +211,7 @@ static inline void lttng_write_string_user_generic_string_pointer_string( align = sizeof(char); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -224,7 +220,7 @@ static inline void lttng_write_string_user_generic_string_pointer_string( /* Contains variable sized fields : must explode the structure */ size = strlen(obj) + 1; /* Include final NULL char. */ - if(buffer != NULL) + if (buffer != NULL) memcpy(buffer+*to_base+*to, obj, size); *to += size; @@ -276,7 +272,7 @@ static inline int trace_user_generic_string_pointer( *from = (const char*)<tng_param_pointer; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -295,7 +291,7 @@ static inline int trace_user_generic_string_pointer( lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -304,7 +300,7 @@ static inline int trace_user_generic_string_pointer( *from = (const char*)<tng_param_pointer; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -313,7 +309,7 @@ static inline int trace_user_generic_string_pointer( *len += sizeof(const void *); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -353,9 +349,7 @@ static inline int trace_user_generic_string_pointer( const char *real_from; const char **from = &real_from; uint64_t tsc; - size_t before_hdr_pad, after_hdr_pad, header_size; - - if(!trace) { + if (!trace) { ltt_thread_init(); trace = thread_trace_info; } @@ -372,7 +366,7 @@ static inline int trace_user_generic_string_pointer( *from = (const char*)<tng_param_pointer; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -389,22 +383,20 @@ static inline int trace_user_generic_string_pointer( ltt_buf = ltt_get_channel_from_index(trace, index); slot_size = 0; buffer = ltt_reserve_slot(trace, ltt_buf, - reserve_size, &slot_size, &tsc, - &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) goto end; /* buffer full */ + reserve_size, &slot_size, &tsc); + if (!buffer) + goto end; /* buffer full */ *to_base = *to = *len = 0; - ltt_write_event_header(trace, ltt_buf, buffer, + buffer = ltt_write_event_header(trace, ltt_buf, buffer, ltt_facility_user_generic_B1865E44, event_user_generic_string_pointer, - reserve_size, before_hdr_pad, tsc); - *to_base += before_hdr_pad + after_hdr_pad + header_size; - + reserve_size, tsc); *from = (const char*)lttng_param_string; lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -413,7 +405,7 @@ static inline int trace_user_generic_string_pointer( *from = (const char*)<tng_param_pointer; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -422,7 +414,7 @@ static inline int trace_user_generic_string_pointer( *len += sizeof(const void *); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -451,8 +443,8 @@ static inline void lttng_write_string_user_generic_slow_printf_string( size_t align; /* Flush pending memcpy */ - if(*len != 0) { - if(buffer != NULL) + if (*len != 0) { + if (buffer != NULL) memcpy(buffer+*to_base+*to, *from, *len); } *to += *len; @@ -460,7 +452,7 @@ static inline void lttng_write_string_user_generic_slow_printf_string( align = sizeof(char); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -469,7 +461,7 @@ static inline void lttng_write_string_user_generic_slow_printf_string( /* Contains variable sized fields : must explode the structure */ size = strlen(obj) + 1; /* Include final NULL char. */ - if(buffer != NULL) + if (buffer != NULL) memcpy(buffer+*to_base+*to, obj, size); *to += size; @@ -531,9 +523,7 @@ static inline int trace_user_generic_slow_printf( const char *real_from; const char **from = &real_from; uint64_t tsc; - size_t before_hdr_pad, after_hdr_pad, header_size; - - if(!trace) { + if (!trace) { ltt_thread_init(); trace = thread_trace_info; } @@ -556,22 +546,20 @@ static inline int trace_user_generic_slow_printf( ltt_buf = ltt_get_channel_from_index(trace, index); slot_size = 0; buffer = ltt_reserve_slot(trace, ltt_buf, - reserve_size, &slot_size, &tsc, - &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) goto end; /* buffer full */ + reserve_size, &slot_size, &tsc); + if (!buffer) + goto end; /* buffer full */ *to_base = *to = *len = 0; - ltt_write_event_header(trace, ltt_buf, buffer, + buffer = ltt_write_event_header(trace, ltt_buf, buffer, ltt_facility_user_generic_B1865E44, event_user_generic_slow_printf, - reserve_size, before_hdr_pad, tsc); - *to_base += before_hdr_pad + after_hdr_pad + header_size; - + reserve_size, tsc); *from = (const char*)lttng_param_string; lttng_write_string_user_generic_slow_printf_string(buffer, to_base, to, from, len, lttng_param_string); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -624,7 +612,7 @@ static inline int trace_user_generic_function_entry( *from = (const char*)<tng_param_this_fn; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -635,7 +623,7 @@ static inline int trace_user_generic_function_entry( *from = (const char*)<tng_param_call_site; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -653,7 +641,7 @@ static inline int trace_user_generic_function_entry( *from = (const char*)<tng_param_this_fn; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -662,7 +650,7 @@ static inline int trace_user_generic_function_entry( *len += sizeof(const void *); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -671,7 +659,7 @@ static inline int trace_user_generic_function_entry( *from = (const char*)<tng_param_call_site; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -680,7 +668,7 @@ static inline int trace_user_generic_function_entry( *len += sizeof(const void *); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -720,9 +708,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun const char *real_from; const char **from = &real_from; uint64_t tsc; - size_t before_hdr_pad, after_hdr_pad, header_size; - - if(!trace) { + if (!trace) { ltt_thread_init(); trace = thread_trace_info; } @@ -736,7 +722,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *from = (const char*)<tng_param_this_fn; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -747,7 +733,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *from = (const char*)<tng_param_call_site; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -764,21 +750,19 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun ltt_buf = ltt_get_channel_from_index(trace, index); slot_size = 0; buffer = ltt_reserve_slot(trace, ltt_buf, - reserve_size, &slot_size, &tsc, - &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) goto end; /* buffer full */ + reserve_size, &slot_size, &tsc); + if (!buffer) + goto end; /* buffer full */ *to_base = *to = *len = 0; - ltt_write_event_header(trace, ltt_buf, buffer, + buffer = ltt_write_event_header(trace, ltt_buf, buffer, ltt_facility_user_generic_B1865E44, event_user_generic_function_entry, - reserve_size, before_hdr_pad, tsc); - *to_base += before_hdr_pad + after_hdr_pad + header_size; - + reserve_size, tsc); *from = (const char*)<tng_param_this_fn; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -787,7 +771,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *len += sizeof(const void *); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -796,7 +780,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *from = (const char*)<tng_param_call_site; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -805,7 +789,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *len += sizeof(const void *); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -858,7 +842,7 @@ static inline int trace_user_generic_function_exit( *from = (const char*)<tng_param_this_fn; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -869,7 +853,7 @@ static inline int trace_user_generic_function_exit( *from = (const char*)<tng_param_call_site; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -887,7 +871,7 @@ static inline int trace_user_generic_function_exit( *from = (const char*)<tng_param_this_fn; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -896,7 +880,7 @@ static inline int trace_user_generic_function_exit( *len += sizeof(const void *); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -905,7 +889,7 @@ static inline int trace_user_generic_function_exit( *from = (const char*)<tng_param_call_site; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -914,7 +898,7 @@ static inline int trace_user_generic_function_exit( *len += sizeof(const void *); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -954,9 +938,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun const char *real_from; const char **from = &real_from; uint64_t tsc; - size_t before_hdr_pad, after_hdr_pad, header_size; - - if(!trace) { + if (!trace) { ltt_thread_init(); trace = thread_trace_info; } @@ -970,7 +952,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *from = (const char*)<tng_param_this_fn; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -981,7 +963,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *from = (const char*)<tng_param_call_site; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -998,21 +980,19 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun ltt_buf = ltt_get_channel_from_index(trace, index); slot_size = 0; buffer = ltt_reserve_slot(trace, ltt_buf, - reserve_size, &slot_size, &tsc, - &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) goto end; /* buffer full */ + reserve_size, &slot_size, &tsc); + if (!buffer) + goto end; /* buffer full */ *to_base = *to = *len = 0; - ltt_write_event_header(trace, ltt_buf, buffer, + buffer = ltt_write_event_header(trace, ltt_buf, buffer, ltt_facility_user_generic_B1865E44, event_user_generic_function_exit, - reserve_size, before_hdr_pad, tsc); - *to_base += before_hdr_pad + after_hdr_pad + header_size; - + reserve_size, tsc); *from = (const char*)<tng_param_this_fn; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -1021,7 +1001,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *len += sizeof(const void *); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -1030,7 +1010,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *from = (const char*)<tng_param_call_site; align = sizeof(const void *); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -1039,7 +1019,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *len += sizeof(const void *); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -1068,8 +1048,8 @@ static inline void lttng_write_string_user_generic_thread_brand_name( size_t align; /* Flush pending memcpy */ - if(*len != 0) { - if(buffer != NULL) + if (*len != 0) { + if (buffer != NULL) memcpy(buffer+*to_base+*to, *from, *len); } *to += *len; @@ -1077,7 +1057,7 @@ static inline void lttng_write_string_user_generic_thread_brand_name( align = sizeof(char); - if(*len == 0) { + if (*len == 0) { *to += ltt_align(*to, align); /* align output */ } else { *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ @@ -1086,7 +1066,7 @@ static inline void lttng_write_string_user_generic_thread_brand_name( /* Contains variable sized fields : must explode the structure */ size = strlen(obj) + 1; /* Include final NULL char. */ - if(buffer != NULL) + if (buffer != NULL) memcpy(buffer+*to_base+*to, obj, size); *to += size; @@ -1143,7 +1123,7 @@ static inline int trace_user_generic_thread_brand( lttng_write_string_user_generic_thread_brand_name(buffer, to_base, to, from, len, lttng_param_name); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; @@ -1181,9 +1161,7 @@ static inline int trace_user_generic_thread_brand( const char *real_from; const char **from = &real_from; uint64_t tsc; - size_t before_hdr_pad, after_hdr_pad, header_size; - - if(!trace) { + if (!trace) { ltt_thread_init(); trace = thread_trace_info; } @@ -1206,22 +1184,20 @@ static inline int trace_user_generic_thread_brand( ltt_buf = ltt_get_channel_from_index(trace, index); slot_size = 0; buffer = ltt_reserve_slot(trace, ltt_buf, - reserve_size, &slot_size, &tsc, - &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) goto end; /* buffer full */ + reserve_size, &slot_size, &tsc); + if (!buffer) + goto end; /* buffer full */ *to_base = *to = *len = 0; - ltt_write_event_header(trace, ltt_buf, buffer, + buffer = ltt_write_event_header(trace, ltt_buf, buffer, ltt_facility_user_generic_B1865E44, event_user_generic_thread_brand, - reserve_size, before_hdr_pad, tsc); - *to_base += before_hdr_pad + after_hdr_pad + header_size; - + reserve_size, tsc); *from = (const char*)lttng_param_name; lttng_write_string_user_generic_thread_brand_name(buffer, to_base, to, from, len, lttng_param_name); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; diff --git a/ltt-usertrace/ltt/ltt-usertrace-fast.h b/ltt-usertrace/ltt/ltt-usertrace-fast.h index b46c2927..29588755 100644 --- a/ltt-usertrace/ltt/ltt-usertrace-fast.h +++ b/ltt-usertrace/ltt/ltt-usertrace-fast.h @@ -56,7 +56,7 @@ extern "C" { #define LTT_TRACER_VERSION_MINOR 8 #ifndef atomic_cmpxchg -#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new)) +#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), old, new)) #endif //atomic_cmpxchg struct ltt_trace_header { @@ -155,7 +155,7 @@ void __attribute__((no_instrument_function)) * for every trace). */ static inline unsigned int __attribute__((no_instrument_function)) - ltt_get_index_from_facility(ltt_facility_t fID, + ltt_get_index_from_facility(uint8_t fID, uint8_t eID) { return GET_CHANNEL_INDEX(process); @@ -188,12 +188,12 @@ static inline struct ltt_buf * __attribute__((no_instrument_function)) static inline unsigned char __attribute__((no_instrument_function)) ltt_get_header_size(struct ltt_trace_info *trace, void *address, - size_t *before_hdr_pad, - size_t *after_hdr_pad, - size_t *header_size) + size_t data_size, + size_t *before_hdr_pad) { unsigned int padding; unsigned int header; + size_t after_hdr_pad; header = sizeof(struct ltt_event_header_nohb); @@ -203,10 +203,8 @@ static inline unsigned char __attribute__((no_instrument_function)) /* Padding after header, considering header aligned on ltt_align. * Calculated statically if header size if known. */ - *after_hdr_pad = ltt_align(header, sizeof(void*)); - padding += *after_hdr_pad; - - *header_size = header; + after_hdr_pad = ltt_align(header, sizeof(void*)); + padding += after_hdr_pad; return header+padding; } @@ -221,24 +219,25 @@ static inline unsigned char __attribute__((no_instrument_function)) * @fID : facility ID * @eID : event ID * @event_size : size of the event, excluding the event header. - * @offset : offset of the beginning of the header, for alignment. - * Calculated by ltt_get_event_header_size. * @tsc : time stamp counter. */ -static inline void __attribute__((no_instrument_function)) +static inline char *__attribute__((no_instrument_function)) ltt_write_event_header( struct ltt_trace_info *trace, struct ltt_buf *buf, - void *ptr, ltt_facility_t fID, uint32_t eID, size_t event_size, - size_t offset, uint64_t tsc) + void *ptr, uint8_t fID, uint32_t eID, size_t event_size, + uint64_t tsc) { + size_t after_hdr_pad; struct ltt_event_header_nohb *nohb; event_size = min(event_size, 0xFFFFU); - nohb = (struct ltt_event_header_nohb *)(ptr+offset); + nohb = (struct ltt_event_header_nohb *)(ptr); nohb->timestamp = (uint64_t)tsc; nohb->facility_id = fID; nohb->event_id = eID; nohb->event_size = (uint16_t)event_size; + after_hdr_pad = ltt_align(sizeof(*nohb), sizeof(void*)); + return ptr + sizeof(*nohb) + after_hdr_pad; } @@ -357,16 +356,14 @@ static inline void * __attribute__((no_instrument_function)) ltt_reserve_slot( struct ltt_buf *ltt_buf, unsigned int data_size, size_t *slot_size, - uint64_t *tsc, - size_t *before_hdr_pad, - size_t *after_hdr_pad, - size_t *header_size) + uint64_t *tsc) { int offset_begin, offset_end, offset_old; //int has_switch; int begin_switch, end_switch_current, end_switch_old; int reserve_commit_diff = 0; unsigned int size; + size_t before_hdr_pad; int consumed_old, consumed_new; int commit_count, reserve_count; int ret; @@ -390,7 +387,7 @@ static inline void * __attribute__((no_instrument_function)) ltt_reserve_slot( begin_switch = 1; /* For offset_begin */ } else { size = ltt_get_header_size(trace, ltt_buf->start + offset_begin, - before_hdr_pad, after_hdr_pad, header_size) + data_size, &before_hdr_pad) + data_size; if((SUBBUF_OFFSET(offset_begin, ltt_buf)+size)>ltt_buf->subbuf_size) { @@ -458,7 +455,7 @@ static inline void * __attribute__((no_instrument_function)) ltt_reserve_slot( * sem_wait. */ } size = ltt_get_header_size(trace, ltt_buf->start + offset_begin, - before_hdr_pad, after_hdr_pad, header_size) + data_size; + data_size, &before_hdr_pad) + data_size; if((SUBBUF_OFFSET(offset_begin,ltt_buf)+size)>ltt_buf->subbuf_size) { /* Event too big for subbuffers, report error, don't complete * the sub-buffer switch. */ @@ -620,7 +617,7 @@ static inline void * __attribute__((no_instrument_function)) ltt_reserve_slot( //BUG_ON(*slot_size != (data_size + *before_hdr_pad + *after_hdr_pad + *header_size)); //BUG_ON(*slot_size != (offset_end - offset_begin)); - return ltt_buf->start + BUFFER_OFFSET(offset_begin, ltt_buf); + return ltt_buf->start + BUFFER_OFFSET(offset_begin, ltt_buf) + before_hdr_pad; } diff --git a/ltt-usertrace/ltt/ltt-usertrace.h b/ltt-usertrace/ltt/ltt-usertrace.h index 2ac32b46..c5b50a5c 100644 --- a/ltt-usertrace/ltt/ltt-usertrace.h +++ b/ltt-usertrace/ltt/ltt-usertrace.h @@ -96,7 +96,7 @@ extern "C" { #ifndef LTT_BLOCKING #define LTT_BLOCKING 0 #endif //LTT_BLOCKING - + typedef unsigned int ltt_facility_t; struct user_facility_info { -- 2.34.1