| 1 | #ifndef _LTT_FACILITY_TEST_H_ |
| 2 | #define _LTT_FACILITY_TEST_H_ |
| 3 | |
| 4 | |
| 5 | /* Facility activation at compile time. */ |
| 6 | #ifdef CONFIG_LTT_FACILITY_TEST |
| 7 | |
| 8 | /* Named types */ |
| 9 | |
| 10 | enum lttng_tasklet_priority { |
| 11 | LTTNG_LOW, |
| 12 | LTTNG_HIGH, |
| 13 | }; |
| 14 | |
| 15 | enum lttng_irq_mode { |
| 16 | LTTNG_user, |
| 17 | LTTNG_kernel, |
| 18 | }; |
| 19 | |
| 20 | struct lttng_mystruct2 { |
| 21 | unsigned int irq_id; |
| 22 | enum lttng_irq_mode mode; |
| 23 | //struct lttng_mystruct teststr1; |
| 24 | }; |
| 25 | |
| 26 | size_t lttng_get_size_mystruct2(size_t *ret_align, |
| 27 | struct lttng_mystruct2 *obj) |
| 28 | { |
| 29 | size_t size=0, align=0, locsize, localign; |
| 30 | |
| 31 | locsize = sizeof(unsigned int); |
| 32 | align = max(align, locsize); |
| 33 | size += ltt_align(size, locsize) + locsize; |
| 34 | |
| 35 | locsize = sizeof(enum lttng_irq_mode); |
| 36 | align = max(align, locsize); |
| 37 | size += ltt_align(size, locsize) + locsize; |
| 38 | |
| 39 | *ret_align = align; |
| 40 | |
| 41 | return size; |
| 42 | } |
| 43 | |
| 44 | void lttng_write_mystruct2(void **ws, |
| 45 | void **we, |
| 46 | struct lttng_mystruct2 *obj) |
| 47 | { |
| 48 | size_t align=0, locsize, localign; |
| 49 | |
| 50 | locsize = lttng_get_size_mystruct2(&align, |
| 51 | obj); |
| 52 | |
| 53 | if(*ws == *we) { |
| 54 | *we += ltt_align(*we, align); |
| 55 | *ws = *we; |
| 56 | } else { |
| 57 | *we += ltt_align(*we, align); /* C alignment, ok to do a memcpy of it */ |
| 58 | } |
| 59 | |
| 60 | BUG_ON(locsize != sizeof(struct lttng_mystruct2)); |
| 61 | *we += locsize; |
| 62 | } |
| 63 | |
| 64 | |
| 65 | |
| 66 | #define LTTNG_ARRAY_SIZE_mystruct_myarray 10 |
| 67 | typedef uint64_t lttng_array_mystruct_myarray[LTTNG_ARRAY_SIZE_mystruct_myarray]; |
| 68 | |
| 69 | size_t lttng_get_size_array_mystruct_myarray(size_t *ret_align, |
| 70 | lttng_array_mystruct_myarray obj) |
| 71 | { |
| 72 | size_t size=0, align=0, locsize, localign; |
| 73 | |
| 74 | locsize = sizeof(uint64_t); |
| 75 | align = max(align, locsize); |
| 76 | size += ltt_align(size, locsize) + (LTTNG_ARRAY_SIZE_mystruct_myarray * locsize); |
| 77 | |
| 78 | *ret_align = align; |
| 79 | |
| 80 | return size; |
| 81 | } |
| 82 | |
| 83 | void lttng_write_array_mystruct_myarray(void **ws, |
| 84 | void **we, |
| 85 | struct lttng_mystruct2 *obj) |
| 86 | { |
| 87 | size_t align=0, locsize, localign; |
| 88 | |
| 89 | locsize = lttng_get_size_array_mystruct_myarray(&align, |
| 90 | obj); |
| 91 | |
| 92 | if(*ws == *we) { |
| 93 | *we += ltt_align(*we, align); |
| 94 | *ws = *we; |
| 95 | } else { |
| 96 | *we += ltt_align(*we, align); /* C alignment, ok to do a memcpy of it */ |
| 97 | } |
| 98 | |
| 99 | BUG_ON(locsize != LTTNG_ARRAY_SIZE_mystruct_myarray * sizeof(uint64_t)); |
| 100 | |
| 101 | *we += locsize; |
| 102 | } |
| 103 | |
| 104 | |
| 105 | typedef struct lttng_sequence_mystruct_mysequence lttng_sequence_mystruct_mysequence; |
| 106 | struct lttng_sequence_mystruct_mysequence { |
| 107 | unsigned int len; |
| 108 | double *array; |
| 109 | }; |
| 110 | |
| 111 | |
| 112 | size_t lttng_get_size_sequence_mystruct_mysequence(size_t *ret_align, |
| 113 | lttng_sequence_mystruct_mysequence *obj) |
| 114 | { |
| 115 | size_t size=0, align=0, locsize, localign; |
| 116 | |
| 117 | locsize = sizeof(unsigned int); |
| 118 | align = max(align, locsize); |
| 119 | size += ltt_align(size, locsize) + locsize; |
| 120 | |
| 121 | locsize = sizeof(double); |
| 122 | align = max(align, locsize); |
| 123 | size += ltt_align(size, locsize) + (obj->len * locsize); |
| 124 | |
| 125 | *ret_align = align; |
| 126 | |
| 127 | return size; |
| 128 | } |
| 129 | |
| 130 | void lttng_write_sequence_mystruct_mysequence(void **ws, |
| 131 | void **we, |
| 132 | lttng_sequence_mystruct_mysequence *obj) |
| 133 | { |
| 134 | size_t align=0, locsize, localign; |
| 135 | |
| 136 | /* Flush pending memcpy */ |
| 137 | if(*ws != *we) { |
| 138 | memcpy(*ws, obj, *we-*ws); |
| 139 | *ws = *we; |
| 140 | } |
| 141 | |
| 142 | lttng_get_size_sequence_mystruct_mysequence(&align, |
| 143 | obj); |
| 144 | |
| 145 | *we += ltt_align(*we, align); |
| 146 | *ws = *we; |
| 147 | |
| 148 | *we += ltt_align(*we, sizeof(unsigned int)); |
| 149 | *ws = *we; |
| 150 | *we += sizeof(unsigned int); |
| 151 | memcpy(*ws, &obj->len, *we-*ws); |
| 152 | *ws = *we; |
| 153 | |
| 154 | *we += ltt_align(*we, sizeof(double)); |
| 155 | *ws = *we; |
| 156 | *we += obj->len * sizeof(double); |
| 157 | memcpy(*ws, obj->array, *we-*ws); |
| 158 | *ws = *we; |
| 159 | } |
| 160 | |
| 161 | |
| 162 | |
| 163 | union lttng_mystruct_myunion { |
| 164 | double myfloat; |
| 165 | unsigned long myulong; |
| 166 | }; |
| 167 | |
| 168 | size_t lttng_get_size_mystruct_myunion(size_t *ret_align, |
| 169 | union lttng_mystruct_myunion *obj) |
| 170 | { |
| 171 | size_t size=0, align=0, locsize, localign; |
| 172 | |
| 173 | locsize = sizeof(double); |
| 174 | align = max(align, locsize); |
| 175 | size = max(size, locsize); |
| 176 | |
| 177 | locsize = sizeof(unsigned long); |
| 178 | align = max(align, locsize); |
| 179 | size = max(size, locsize); |
| 180 | |
| 181 | *ret_align = align; |
| 182 | |
| 183 | return size; |
| 184 | } |
| 185 | |
| 186 | |
| 187 | void lttng_write_mystruct_myunion(void **ws, |
| 188 | void **we, |
| 189 | union lttng_mystruct_myunion *obj) |
| 190 | { |
| 191 | size_t align=0, locsize, localign; |
| 192 | |
| 193 | locsize = lttng_get_size_mystruct_myunion(&align, |
| 194 | obj); |
| 195 | |
| 196 | if(*ws == *we) { |
| 197 | *we += ltt_align(*we, align); |
| 198 | *ws = *we; |
| 199 | } else { |
| 200 | *we += ltt_align(*we, align); /* C alignment, ok to do a memcpy of it */ |
| 201 | } |
| 202 | |
| 203 | BUG_ON(locsize != sizeof(union lttng_mystruct_myunion)); |
| 204 | |
| 205 | *we += locsize; |
| 206 | } |
| 207 | |
| 208 | |
| 209 | struct lttng_mystruct { |
| 210 | unsigned int irq_id; |
| 211 | enum lttng_irq_mode mode; |
| 212 | struct lttng_mystruct2 teststr; |
| 213 | lttng_array_mystruct_myarray myarray; |
| 214 | lttng_sequence_mystruct_mysequence mysequence; |
| 215 | union lttng_mystruct_myunion myunion; |
| 216 | }; |
| 217 | |
| 218 | size_t lttng_get_size_mystruct(size_t *ret_align, |
| 219 | struct lttng_mystruct *obj) |
| 220 | { |
| 221 | size_t size=0, align=0, locsize, localign; |
| 222 | |
| 223 | locsize = sizeof(unsigned int); |
| 224 | align = max(align, locsize); |
| 225 | size += ltt_align(size, locsize) + locsize; |
| 226 | |
| 227 | locsize = sizeof(enum lttng_irq_mode); |
| 228 | align = max(align, locsize); |
| 229 | size += ltt_align(size, locsize) + locsize; |
| 230 | |
| 231 | locsize = lttng_get_size_mystruct2(&localign, |
| 232 | &obj->teststr); |
| 233 | align = max(align, localign); |
| 234 | size += ltt_align(size, localign) + locsize; |
| 235 | |
| 236 | locsize = lttng_get_size_array_mystruct_myarray(&localign, |
| 237 | obj->myarray); |
| 238 | align = max(align, localign); |
| 239 | size += ltt_align(size, localign) + locsize; |
| 240 | |
| 241 | locsize = lttng_get_size_sequence_mystruct_mysequence(&localign, |
| 242 | &obj->mysequence); |
| 243 | align = max(align, localign); |
| 244 | size += ltt_align(size, localign) + locsize; |
| 245 | |
| 246 | locsize = lttng_get_size_mystruct_myunion(&localign, |
| 247 | &obj->myunion); |
| 248 | align = max(align, localign); |
| 249 | size += ltt_align(size, localign) + locsize; |
| 250 | |
| 251 | *ret_align = align; |
| 252 | |
| 253 | return size; |
| 254 | } |
| 255 | |
| 256 | struct lttng_mystruct { |
| 257 | unsigned int irq_id; |
| 258 | enum lttng_irq_mode mode; |
| 259 | struct lttng_mystruct2 teststr; |
| 260 | lttng_array_mystruct_myarray myarray; |
| 261 | lttng_sequence_mystruct_mysequence mysequence; |
| 262 | union lttng_mystruct_myunion myunion; |
| 263 | }; |
| 264 | |
| 265 | |
| 266 | void lttng_write_mystruct(void **ws, |
| 267 | void **we, |
| 268 | struct lttng_mystruct *obj) |
| 269 | { |
| 270 | size_t align=0, locsize, localign; |
| 271 | |
| 272 | lttng_get_size_mystruct(&align, |
| 273 | obj); |
| 274 | |
| 275 | if(*ws == *we) { |
| 276 | *we += ltt_align(*we, align); |
| 277 | *ws = *we; |
| 278 | } else { |
| 279 | *we += ltt_align(*we, align); /* C alignment, ok to do a memcpy of it */ |
| 280 | } |
| 281 | |
| 282 | locsize = sizeof(unsigned int); |
| 283 | *we += ltt_align(*we, locsize) + locsize; |
| 284 | |
| 285 | locsize = sizeof(enum lttng_irq_mode); |
| 286 | *we += ltt_align(*we, locsize) + locsize; |
| 287 | |
| 288 | lttng_write_mystruct2(ws, we, |
| 289 | &obj->teststr); |
| 290 | |
| 291 | lttng_write_array_mystruct_myarray(ws, we, |
| 292 | obj->myarray); |
| 293 | |
| 294 | /* Variable length field */ |
| 295 | lttng_write_sequence_mystruct_mysequence(ws, we, |
| 296 | &obj->mysequence); |
| 297 | |
| 298 | lttng_write_mystruct_myunion(ws, we, |
| 299 | obj->myunion); |
| 300 | |
| 301 | /* Don't forget to flush last write..... */ |
| 302 | } |
| 303 | |
| 304 | |
| 305 | |
| 306 | /* Event syscall_entry structures */ |
| 307 | |
| 308 | /* Event syscall_entry logging function */ |
| 309 | static inline void trace_test_syscall_entry( |
| 310 | unsigned int syscall_id, |
| 311 | void * address) |
| 312 | #ifndef CONFIG_LTT |
| 313 | { |
| 314 | } |
| 315 | #else |
| 316 | { |
| 317 | } |
| 318 | #endif //CONFIG_LTT |
| 319 | |
| 320 | |
| 321 | /* Event syscall_exit structures */ |
| 322 | |
| 323 | /* Event syscall_exit logging function */ |
| 324 | static inline void trace_test_syscall_exit( |
| 325 | void) |
| 326 | #ifndef CONFIG_LTT |
| 327 | { |
| 328 | } |
| 329 | #else |
| 330 | { |
| 331 | } |
| 332 | #endif //CONFIG_LTT |
| 333 | |
| 334 | |
| 335 | /* Event trap_entry structures */ |
| 336 | |
| 337 | /* Event trap_entry logging function */ |
| 338 | static inline void trace_test_trap_entry( |
| 339 | unsigned int trap_id, |
| 340 | void * address) |
| 341 | #ifndef CONFIG_LTT |
| 342 | { |
| 343 | } |
| 344 | #else |
| 345 | { |
| 346 | } |
| 347 | #endif //CONFIG_LTT |
| 348 | |
| 349 | |
| 350 | /* Event trap_exit structures */ |
| 351 | |
| 352 | /* Event trap_exit logging function */ |
| 353 | static inline void trace_test_trap_exit( |
| 354 | void) |
| 355 | #ifndef CONFIG_LTT |
| 356 | { |
| 357 | } |
| 358 | #else |
| 359 | { |
| 360 | } |
| 361 | #endif //CONFIG_LTT |
| 362 | |
| 363 | |
| 364 | /* Event soft_irq_entry structures */ |
| 365 | |
| 366 | /* Event soft_irq_entry logging function */ |
| 367 | static inline void trace_test_soft_irq_entry( |
| 368 | void * softirq_id) |
| 369 | #ifndef CONFIG_LTT |
| 370 | { |
| 371 | } |
| 372 | #else |
| 373 | { |
| 374 | } |
| 375 | #endif //CONFIG_LTT |
| 376 | |
| 377 | |
| 378 | /* Event soft_irq_exit structures */ |
| 379 | |
| 380 | /* Event soft_irq_exit logging function */ |
| 381 | static inline void trace_test_soft_irq_exit( |
| 382 | void * softirq_id) |
| 383 | #ifndef CONFIG_LTT |
| 384 | { |
| 385 | } |
| 386 | #else |
| 387 | { |
| 388 | } |
| 389 | #endif //CONFIG_LTT |
| 390 | |
| 391 | |
| 392 | /* Event tasklet_entry structures */ |
| 393 | |
| 394 | /* Event tasklet_entry logging function */ |
| 395 | static inline void trace_test_tasklet_entry( |
| 396 | enum lttng_tasklet_priority priority, |
| 397 | void * address, |
| 398 | unsigned long data) |
| 399 | #ifndef CONFIG_LTT |
| 400 | { |
| 401 | } |
| 402 | #else |
| 403 | { |
| 404 | } |
| 405 | #endif //CONFIG_LTT |
| 406 | |
| 407 | |
| 408 | /* Event tasklet_exit structures */ |
| 409 | |
| 410 | /* Event tasklet_exit logging function */ |
| 411 | static inline void trace_test_tasklet_exit( |
| 412 | enum lttng_tasklet_priority priority, |
| 413 | void * address, |
| 414 | unsigned long data) |
| 415 | #ifndef CONFIG_LTT |
| 416 | { |
| 417 | } |
| 418 | #else |
| 419 | { |
| 420 | } |
| 421 | #endif //CONFIG_LTT |
| 422 | |
| 423 | |
| 424 | /* Event irq_entry structures */ |
| 425 | |
| 426 | /* Event irq_entry logging function */ |
| 427 | static inline void trace_test_irq_entry( |
| 428 | unsigned int irq_id, |
| 429 | enum lttng_irq_mode mode) |
| 430 | #ifndef CONFIG_LTT |
| 431 | { |
| 432 | } |
| 433 | #else |
| 434 | { |
| 435 | } |
| 436 | #endif //CONFIG_LTT |
| 437 | |
| 438 | |
| 439 | /* Event irq_exit structures */ |
| 440 | |
| 441 | /* Event irq_exit logging function */ |
| 442 | static inline void trace_test_irq_exit( |
| 443 | void) |
| 444 | #ifndef CONFIG_LTT |
| 445 | { |
| 446 | } |
| 447 | #else |
| 448 | { |
| 449 | } |
| 450 | #endif //CONFIG_LTT |
| 451 | |
| 452 | |
| 453 | /* Event big_array structures */ |
| 454 | union lttng_test_big_array_myarray_b { |
| 455 | void * c; |
| 456 | }; |
| 457 | |
| 458 | struct lttng_test_big_array_myarray { |
| 459 | void * a; |
| 460 | union lttng_test_big_array_myarray_b b; |
| 461 | }; |
| 462 | |
| 463 | #define LTTNG_ARRAY_SIZE_test_big_array_myarray 2 |
| 464 | typedef struct lttng_test_big_array_myarray lttng_array_test_big_array_myarray[LTTNG_ARRAY_SIZE_test_big_array_myarray]; |
| 465 | |
| 466 | #define LTTNG_ARRAY_SIZE_test_big_array_myarray 10000 |
| 467 | typedef lttng_array_test_big_array_myarray lttng_array_test_big_array_myarray[LTTNG_ARRAY_SIZE_test_big_array_myarray]; |
| 468 | |
| 469 | |
| 470 | /* Event big_array logging function */ |
| 471 | static inline void trace_test_big_array( |
| 472 | lttng_array_test_big_array_myarray myarray) |
| 473 | #ifndef CONFIG_LTT |
| 474 | { |
| 475 | } |
| 476 | #else |
| 477 | { |
| 478 | } |
| 479 | #endif //CONFIG_LTT |
| 480 | |
| 481 | |
| 482 | #endif //CONFIG_LTT_FACILITY_TEST |
| 483 | |
| 484 | #endif //_LTT_FACILITY_TEST_H_ |