From e619eb4ee797c25cddb101302a8653cc37294d2d Mon Sep 17 00:00:00 2001 From: compudj Date: Mon, 12 Jun 2006 13:36:57 +0000 Subject: [PATCH] thread brand git-svn-id: http://ltt.polymtl.ca/svn@1916 04897980-b3bd-0310-b5e0-8ef037075253 --- .../ltt-facility-loader-user_generic.h | 6 +- .../ltt/ltt-facility-id-user_generic.h | 3 +- ltt-usertrace/ltt/ltt-facility-user_generic.h | 211 ++++++++++++++++-- 3 files changed, 200 insertions(+), 20 deletions(-) diff --git a/ltt-usertrace/ltt-facility-loader-user_generic.h b/ltt-usertrace/ltt-facility-loader-user_generic.h index e3373f6f..7bb6c0d8 100644 --- a/ltt-usertrace/ltt-facility-loader-user_generic.h +++ b/ltt-usertrace/ltt-facility-loader-user_generic.h @@ -5,11 +5,11 @@ #include ltt_facility_t ltt_facility_user_generic; -ltt_facility_t ltt_facility_user_generic_F583779E; +ltt_facility_t ltt_facility_user_generic_B1865E44; #define LTT_FACILITY_SYMBOL ltt_facility_user_generic -#define LTT_FACILITY_CHECKSUM_SYMBOL ltt_facility_user_generic_F583779E -#define LTT_FACILITY_CHECKSUM 0xF583779E +#define LTT_FACILITY_CHECKSUM_SYMBOL ltt_facility_user_generic_B1865E44 +#define LTT_FACILITY_CHECKSUM 0xB1865E44 #define LTT_FACILITY_NAME "user_generic" #define LTT_FACILITY_NUM_EVENTS facility_user_generic_num_events diff --git a/ltt-usertrace/ltt/ltt-facility-id-user_generic.h b/ltt-usertrace/ltt/ltt-facility-id-user_generic.h index 03b10502..d5443caa 100644 --- a/ltt-usertrace/ltt/ltt-facility-id-user_generic.h +++ b/ltt-usertrace/ltt/ltt-facility-id-user_generic.h @@ -6,7 +6,7 @@ /**** facility handle ****/ -extern ltt_facility_t ltt_facility_user_generic_F583779E; +extern ltt_facility_t ltt_facility_user_generic_B1865E44; extern ltt_facility_t ltt_facility_user_generic; @@ -18,6 +18,7 @@ enum user_generic_event { event_user_generic_slow_printf, event_user_generic_function_entry, event_user_generic_function_exit, + event_user_generic_thread_brand, facility_user_generic_num_events }; diff --git a/ltt-usertrace/ltt/ltt-facility-user_generic.h b/ltt-usertrace/ltt/ltt-facility-user_generic.h index 925db27e..d94ace9a 100644 --- a/ltt-usertrace/ltt/ltt-facility-user_generic.h +++ b/ltt-usertrace/ltt/ltt-facility-user_generic.h @@ -98,7 +98,7 @@ static inline int trace_user_generic_string( *len = 0; } - ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_string, buffer, reserve_size, LTT_BLOCKING); + ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_string, buffer, reserve_size, LTT_BLOCKING); } return ret; @@ -148,7 +148,7 @@ static inline int trace_user_generic_string( reserve_size = *to_base + *to + *len; trace->nesting++; - index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E, + index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44, event_user_generic_string); { @@ -162,7 +162,7 @@ static inline int trace_user_generic_string( *to_base = *to = *len = 0; ltt_write_event_header(trace, ltt_buf, buffer, - ltt_facility_user_generic_F583779E, event_user_generic_string, + 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; @@ -308,7 +308,7 @@ static inline int trace_user_generic_string_pointer( *len = 0; } - ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_string_pointer, buffer, reserve_size, LTT_BLOCKING); + ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_string_pointer, buffer, reserve_size, LTT_BLOCKING); } return ret; @@ -371,7 +371,7 @@ static inline int trace_user_generic_string_pointer( reserve_size = *to_base + *to + *len; trace->nesting++; - index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E, + index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44, event_user_generic_string_pointer); { @@ -385,7 +385,7 @@ static inline int trace_user_generic_string_pointer( *to_base = *to = *len = 0; ltt_write_event_header(trace, ltt_buf, buffer, - ltt_facility_user_generic_F583779E, event_user_generic_string_pointer, + 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; @@ -483,9 +483,9 @@ static inline int trace_user_generic_slow_printf_param_buffer( #else { int ret = 0; - reserve_size += ltt_align(reserve_size, sizeof(void *)); + reserve_size = ltt_align(reserve_size, sizeof(void *)); { - ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_slow_printf, buffer, reserve_size, LTT_BLOCKING); + ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_slow_printf, buffer, reserve_size, LTT_BLOCKING); } return ret; @@ -535,7 +535,7 @@ static inline int trace_user_generic_slow_printf( reserve_size = *to_base + *to + *len; trace->nesting++; - index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E, + index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44, event_user_generic_slow_printf); { @@ -549,7 +549,7 @@ static inline int trace_user_generic_slow_printf( *to_base = *to = *len = 0; ltt_write_event_header(trace, ltt_buf, buffer, - ltt_facility_user_generic_F583779E, event_user_generic_slow_printf, + 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; @@ -668,7 +668,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *len = 0; } - ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_function_entry, buffer, reserve_size, LTT_BLOCKING); + ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_function_entry, buffer, reserve_size, LTT_BLOCKING); } return ret; @@ -739,7 +739,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun reserve_size = *to_base + *to + *len; trace->nesting++; - index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E, + index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44, event_user_generic_function_entry); { @@ -753,7 +753,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *to_base = *to = *len = 0; ltt_write_event_header(trace, ltt_buf, buffer, - ltt_facility_user_generic_F583779E, event_user_generic_function_entry, + 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; @@ -898,7 +898,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *len = 0; } - ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_function_exit, buffer, reserve_size, LTT_BLOCKING); + ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_function_exit, buffer, reserve_size, LTT_BLOCKING); } return ret; @@ -969,7 +969,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun reserve_size = *to_base + *to + *len; trace->nesting++; - index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E, + index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44, event_user_generic_function_exit); { @@ -983,7 +983,7 @@ static inline __attribute__((no_instrument_function)) int trace_user_generic_fun *to_base = *to = *len = 0; ltt_write_event_header(trace, ltt_buf, buffer, - ltt_facility_user_generic_F583779E, event_user_generic_function_exit, + 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; @@ -1033,4 +1033,183 @@ end: #endif //LTT_TRACE #endif //LTT_TRACE_FAST +/* Event thread_brand structures */ +static inline void lttng_write_string_user_generic_thread_brand_name( + void *buffer, + size_t *to_base, + size_t *to, + const void **from, + size_t *len, + const char * obj) +{ + size_t size; + size_t align; + + /* Flush pending memcpy */ + if(*len != 0) { + if(buffer != NULL) + memcpy(buffer+*to_base+*to, *from, *len); + } + *to += *len; + *len = 0; + + align = sizeof(char); + + 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 */ + } + + /* Contains variable sized fields : must explode the structure */ + + size = strlen(obj) + 1; /* Include final NULL char. */ + if(buffer != NULL) + memcpy(buffer+*to_base+*to, obj, size); + *to += size; + + /* Realign the *to_base on arch size, set *to to 0 */ + *to += ltt_align(*to, sizeof(void *)); + *to_base = *to_base+*to; + *to = 0; + + /* Put source *from just after the C string */ + *from += size; +} + + +/* Event thread_brand logging function */ +#ifndef LTT_TRACE_FAST +static inline int trace_user_generic_thread_brand( + const char * lttng_param_name) +#ifndef LTT_TRACE +{ +} +#else +{ + int ret = 0; + void *buffer = NULL; + size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */ + size_t *to_base = &real_to_base; + size_t real_to = 0; + size_t *to = &real_to; + size_t real_len = 0; + size_t *len = &real_len; + size_t reserve_size; + size_t slot_size; + const void *real_from; + const void **from = &real_from; + /* For each field, calculate the field size. */ + /* size = *to_base + *to + *len */ + /* Assume that the padding for alignment starts at a + * sizeof(void *) address. */ + + *from = lttng_param_name; + lttng_write_string_user_generic_thread_brand_name(buffer, to_base, to, from, len, lttng_param_name); + + reserve_size = *to_base + *to + *len; + { + char stack_buffer[reserve_size]; + buffer = stack_buffer; + + *to_base = *to = *len = 0; + + *from = 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) { + memcpy(buffer+*to_base+*to, *from, *len); + *to += *len; + *len = 0; + } + + ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_thread_brand, buffer, reserve_size, LTT_BLOCKING); + } + + return ret; + +} +#endif //LTT_TRACE +#endif //!LTT_TRACE_FAST + +#ifdef LTT_TRACE_FAST +static inline int trace_user_generic_thread_brand( + const char * lttng_param_name) +#ifndef LTT_TRACE +{ +} +#else +{ + unsigned int index; + struct ltt_trace_info *trace = thread_trace_info; + struct ltt_buf *ltt_buf; + void *buffer = NULL; + size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */ + size_t *to_base = &real_to_base; + size_t real_to = 0; + size_t *to = &real_to; + size_t real_len = 0; + size_t *len = &real_len; + size_t reserve_size; + size_t slot_size; + const void *real_from; + const void **from = &real_from; + uint64_t tsc; + size_t before_hdr_pad, after_hdr_pad, header_size; + + if(!trace) { + ltt_thread_init(); + trace = thread_trace_info; + } + + + /* For each field, calculate the field size. */ + /* size = *to_base + *to + *len */ + /* Assume that the padding for alignment starts at a + * sizeof(void *) address. */ + + *from = lttng_param_name; + lttng_write_string_user_generic_thread_brand_name(buffer, to_base, to, from, len, lttng_param_name); + + reserve_size = *to_base + *to + *len; + trace->nesting++; + index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44, + event_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 */ + + *to_base = *to = *len = 0; + + 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; + + *from = 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) { + memcpy(buffer+*to_base+*to, *from, *len); + *to += *len; + *len = 0; + } + + ltt_commit_slot(ltt_buf, buffer, slot_size); + +} + +end: + trace->nesting--; +} +#endif //LTT_TRACE +#endif //LTT_TRACE_FAST + #endif //_LTT_FACILITY_USER_GENERIC_H_ -- 2.34.1