X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=tests%2Fkernel%2Fltt-facility-tests.h;h=f28b4238b4e553e47c559d7ff0b573c7779f29b1;hb=54e7c22401bde470df54f7b9c1b02d126a1b8c80;hp=a0aa42e1b31f6dcebed9b53c3d02ae2d8626a274;hpb=abbd00d33b2bf48a80769dd0c40af8b60d1e59c0;p=lttv.git diff --git a/tests/kernel/ltt-facility-tests.h b/tests/kernel/ltt-facility-tests.h index a0aa42e1..f28b4238 100644 --- a/tests/kernel/ltt-facility-tests.h +++ b/tests/kernel/ltt-facility-tests.h @@ -1,9 +1,12 @@ #ifndef _LTT_FACILITY_TESTS_H_ #define _LTT_FACILITY_TESTS_H_ + #include #include "ltt-facility-id-tests.h" -#include +#include + +#define ltt_get_index_from_facility_tests ltt_get_index_from_facility /* Named types */ @@ -11,17 +14,13 @@ /* Event write_4bytes logging function */ static inline void trace_tests_write_4bytes( - int lttng_param_data) -#if (!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) -{ -} -#else + unsigned int lttng_param_value) { unsigned int index; struct ltt_channel_struct *channel; struct ltt_trace_struct *trace; - struct rchan_buf *relayfs_buf; - void *buffer = NULL; + void *transport_data; + char *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; @@ -31,329 +30,23 @@ static inline void trace_tests_write_4bytes( size_t reserve_size; size_t slot_size; size_t align; - const void *real_from; - const void **from = &real_from; - u64 tsc; - size_t before_hdr_pad, after_hdr_pad, header_size; - - if(ltt_traces.num_active_traces == 0) return; - - /* 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 = <tng_param_data; - align = sizeof(int); - - 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 */ - } - - *len += sizeof(int); - - reserve_size = *to_base + *to + *len; - preempt_disable(); - ltt_nesting[smp_processor_id()]++; - index = ltt_get_index_from_facility(ltt_facility_tests_2F06D8DB, - event_tests_write_4bytes); - - list_for_each_entry_rcu(trace, <t_traces.head, list) { - if(!trace->active) continue; - - channel = ltt_get_channel_from_index(trace, index); - relayfs_buf = channel->rchan->buf[smp_processor_id()]; - - slot_size = 0; - buffer = ltt_reserve_slot(trace, relayfs_buf, - reserve_size, &slot_size, &tsc, - &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) continue; /* buffer full */ - - *to_base = *to = *len = 0; - - ltt_write_event_header(trace, channel, buffer, - ltt_facility_tests_2F06D8DB, event_tests_write_4bytes, - reserve_size, before_hdr_pad, tsc); - *to_base += before_hdr_pad + after_hdr_pad + header_size; - - *from = <tng_param_data; - align = sizeof(int); - - 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 */ - } - - *len += sizeof(int); - - /* Flush pending memcpy */ - if(*len != 0) { - memcpy(buffer+*to_base+*to, *from, *len); - *to += *len; - *len = 0; - } - - ltt_commit_slot(relayfs_buf, buffer, slot_size); - - } - - ltt_nesting[smp_processor_id()]--; - preempt_enable_no_resched(); -} -#endif //(!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) - - -/* Event write_string structures */ -static inline void lttng_write_string_tests_write_string_data( - 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 write_string logging function */ -static inline void trace_tests_write_string( - const char * lttng_param_data) -#if (!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) -{ -} -#else -{ - unsigned int index; - struct ltt_channel_struct *channel; - struct ltt_trace_struct *trace; - struct rchan_buf *relayfs_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; + const char *real_from; + const char **from = &real_from; u64 tsc; size_t before_hdr_pad, after_hdr_pad, header_size; - if(ltt_traces.num_active_traces == 0) return; + if (ltt_traces.num_active_traces == 0) + return; /* 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_data; - lttng_write_string_tests_write_string_data(buffer, to_base, to, from, len, lttng_param_data); - - reserve_size = *to_base + *to + *len; - preempt_disable(); - ltt_nesting[smp_processor_id()]++; - index = ltt_get_index_from_facility(ltt_facility_tests_2F06D8DB, - event_tests_write_string); - - list_for_each_entry_rcu(trace, <t_traces.head, list) { - if(!trace->active) continue; - - channel = ltt_get_channel_from_index(trace, index); - relayfs_buf = channel->rchan->buf[smp_processor_id()]; - - slot_size = 0; - buffer = ltt_reserve_slot(trace, relayfs_buf, - reserve_size, &slot_size, &tsc, - &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) continue; /* buffer full */ - - *to_base = *to = *len = 0; - - ltt_write_event_header(trace, channel, buffer, - ltt_facility_tests_2F06D8DB, event_tests_write_string, - reserve_size, before_hdr_pad, tsc); - *to_base += before_hdr_pad + after_hdr_pad + header_size; - - *from = lttng_param_data; - lttng_write_string_tests_write_string_data(buffer, to_base, to, from, len, lttng_param_data); - - /* Flush pending memcpy */ - if(*len != 0) { - memcpy(buffer+*to_base+*to, *from, *len); - *to += *len; - *len = 0; - } - - ltt_commit_slot(relayfs_buf, buffer, slot_size); - - } - - ltt_nesting[smp_processor_id()]--; - preempt_enable_no_resched(); -} -#endif //(!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) - - -/* Event write_struct structures */ -typedef struct lttng_sequence_tests_write_struct_data2_data5 lttng_sequence_tests_write_struct_data2_data5; -struct lttng_sequence_tests_write_struct_data2_data5 { - unsigned int len; - const int64_t *array; -}; - -struct lttng_tests_write_struct_data2 { - const char * data3; - int data4; - lttng_sequence_tests_write_struct_data2_data5 data5; - int data6; -} LTT_ALIGN; - -static inline size_t lttng_get_alignment_sequence_tests_write_struct_data2_data5( - lttng_sequence_tests_write_struct_data2_data5 *obj) -{ - size_t align=0, localign; - localign = sizeof(unsigned int); - align = max(align, localign); - - localign = sizeof(int64_t); - align = max(align, localign); - - return align; -} - -static inline size_t lttng_get_alignment_struct_tests_write_struct_data2( - struct lttng_tests_write_struct_data2 *obj) -{ - size_t align=0, localign; - localign = sizeof(char); - align = max(align, localign); - - localign = sizeof(int); - align = max(align, localign); - - localign = lttng_get_alignment_sequence_tests_write_struct_data2_data5(&obj->data5); - align = max(align, localign); - - localign = sizeof(int); - align = max(align, localign); - - return align; -} - -static inline void lttng_write_string_tests_write_struct_data2_data3( - 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; -} - -static inline void lttng_write_sequence_tests_write_struct_data2_data5( - void *buffer, - size_t *to_base, - size_t *to, - const void **from, - size_t *len, - lttng_sequence_tests_write_struct_data2_data5 *obj) -{ - size_t align; - - /* Flush pending memcpy */ - if(*len != 0) { - if(buffer != NULL) - memcpy(buffer+*to_base+*to, *from, *len); - } - *to += *len; - *len = 0; - - align = lttng_get_alignment_sequence_tests_write_struct_data2_data5(obj); - - 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 */ - - /* Copy members */ + *from = (const char*)<tng_param_value; align = sizeof(unsigned int); - 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 */ @@ -361,191 +54,55 @@ static inline void lttng_write_sequence_tests_write_struct_data2_data5( *len += sizeof(unsigned int); - if(buffer != NULL) - memcpy(buffer+*to_base+*to, &obj->len, *len); - *to += *len; - *len = 0; - - align = sizeof(int64_t); - - 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 */ - } - - *len += sizeof(int64_t); - - *len = obj->len * (*len); - if(buffer != NULL) - memcpy(buffer+*to_base+*to, obj->array, *len); - *to += *len; - *len = 0; - - - /* 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 sequence */ - *from = obj+1; -} - -static inline void lttng_write_struct_tests_write_struct_data2( - void *buffer, - size_t *to_base, - size_t *to, - const void **from, - size_t *len, - struct lttng_tests_write_struct_data2 *obj) -{ - size_t align; - - align = lttng_get_alignment_struct_tests_write_struct_data2(obj); - - 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 */ - - lttng_write_string_tests_write_struct_data2_data3(buffer, to_base, to, from, len, obj->data3); - - align = sizeof(int); - - 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 */ - } - - *len += sizeof(int); - - lttng_write_sequence_tests_write_struct_data2_data5(buffer, to_base, to, from, len, &obj->data5); - align = sizeof(int); - - 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 */ - } - - *len += sizeof(int); - -} - - -/* Event write_struct logging function */ -static inline void trace_tests_write_struct( - int lttng_param_data1, - struct lttng_tests_write_struct_data2 * lttng_param_data2) -#if (!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) -{ -} -#else -{ - unsigned int index; - struct ltt_channel_struct *channel; - struct ltt_trace_struct *trace; - struct rchan_buf *relayfs_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; - size_t align; - const void *real_from; - const void **from = &real_from; - u64 tsc; - size_t before_hdr_pad, after_hdr_pad, header_size; - - if(ltt_traces.num_active_traces == 0) return; - - /* 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 = <tng_param_data1; - align = sizeof(int); - - 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 */ - } - - *len += sizeof(int); - - *from = lttng_param_data2; - lttng_write_struct_tests_write_struct_data2(buffer, to_base, to, from, len, lttng_param_data2); reserve_size = *to_base + *to + *len; preempt_disable(); ltt_nesting[smp_processor_id()]++; - index = ltt_get_index_from_facility(ltt_facility_tests_2F06D8DB, - event_tests_write_struct); + index = ltt_get_index_from_facility_tests( event_tests_write_4bytes); list_for_each_entry_rcu(trace, <t_traces.head, list) { - if(!trace->active) continue; + if (!trace->active) + continue; channel = ltt_get_channel_from_index(trace, index); - relayfs_buf = channel->rchan->buf[smp_processor_id()]; slot_size = 0; - buffer = ltt_reserve_slot(trace, relayfs_buf, + buffer = ltt_reserve_slot(trace, channel, &transport_data, reserve_size, &slot_size, &tsc, &before_hdr_pad, &after_hdr_pad, &header_size); - if(!buffer) continue; /* buffer full */ + if (!buffer) + continue; /* buffer full */ *to_base = *to = *len = 0; ltt_write_event_header(trace, channel, buffer, - ltt_facility_tests_2F06D8DB, event_tests_write_struct, + ltt_facility_tests_CA7F1536, event_tests_write_4bytes, reserve_size, before_hdr_pad, tsc); *to_base += before_hdr_pad + after_hdr_pad + header_size; - *from = <tng_param_data1; - align = sizeof(int); + *from = (const char*)<tng_param_value; + align = sizeof(unsigned int); - 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 */ } - *len += sizeof(int); + *len += sizeof(unsigned int); /* Flush pending memcpy */ - if(*len != 0) { + if (*len != 0) { memcpy(buffer+*to_base+*to, *from, *len); *to += *len; *len = 0; } - *from = lttng_param_data2; - lttng_write_struct_tests_write_struct_data2(buffer, to_base, to, from, len, lttng_param_data2); - /* Flush pending memcpy */ - if(*len != 0) { - memcpy(buffer+*to_base+*to, *from, *len); - *to += *len; - *len = 0; - } - - ltt_commit_slot(relayfs_buf, buffer, slot_size); + ltt_commit_slot(channel, &transport_data, buffer, slot_size); } ltt_nesting[smp_processor_id()]--; preempt_enable_no_resched(); } -#endif //(!defined(CONFIG_LTT) || !defined(CONFIG_LTT_FACILITY_TESTS)) - #endif //_LTT_FACILITY_TESTS_H_