From 1e645c514f39820a628b3f5f2fbb2db6defa7567 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 6 Sep 2024 16:38:15 +0200 Subject: [PATCH 1/4] T: bugfix: check limits --- common/utils/T/tracer/event.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/utils/T/tracer/event.c b/common/utils/T/tracer/event.c index a5d04166d4..f75af1e398 100644 --- a/common/utils/T/tracer/event.c +++ b/common/utils/T/tracer/event.c @@ -71,6 +71,12 @@ event new_event(int type, int length, char *buffer, void *database) e.buffer = buffer; f = get_format(database, type); + if (f.count > T_MAX_ARGS) { + printf("fatal: the T trace %s is defined to take %d arguments, but T_MAX_ARGS is %d. " + "Increase T_MAX_ARGS in event.h and recompile all the tracers (make clean; make).\n", + event_name_from_id(database, type), f.count, T_MAX_ARGS); + exit(1); + } e.ecount = f.count; From 105eaa607fdf365324436c803ddd7f3f57ef1431 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 6 Sep 2024 16:39:16 +0200 Subject: [PATCH 2/4] T: increase max number of args in an event and make the define more private T_MAX_ARGS was 16 and some people start to use the T machinery with more than 16 values. So be it. Let tracers be friendly and accept 32. (More commits to follow for full support.) Also why is T_MAX_ARGS in T_defs.h when it's only used by event.h? Hum? --- common/utils/T/T_defs.h | 3 --- common/utils/T/tracer/event.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/utils/T/T_defs.h b/common/utils/T/T_defs.h index 00e0df4963..13b664a487 100644 --- a/common/utils/T/T_defs.h +++ b/common/utils/T/T_defs.h @@ -36,9 +36,6 @@ /* comment (and recompile everything) to not send time in events */ #define T_SEND_TIME -/* maximum number of arguments for the T macro */ -#define T_MAX_ARGS 16 - /* maximum size of a message - increase if needed */ #define T_BUFFER_MAX (1024*64*4) diff --git a/common/utils/T/tracer/event.h b/common/utils/T/tracer/event.h index 0170ab6680..4e631fbb49 100644 --- a/common/utils/T/tracer/event.h +++ b/common/utils/T/tracer/event.h @@ -7,6 +7,9 @@ #include #endif +/* maximum number of arguments for the T macro */ +#define T_MAX_ARGS 32 + enum event_arg_type { EVENT_INT, EVENT_ULONG, From 9e698bd5345f03995d2f5dd66898b8d9ae12e3a3 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 6 Sep 2024 16:42:56 +0200 Subject: [PATCH 3/4] T: cleanup: make shorter lines 80 columns are enough. --- common/utils/T/T.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/common/utils/T/T.h b/common/utils/T/T.h index 4f5ef046fe..83232cefea 100644 --- a/common/utils/T/T.h +++ b/common/utils/T/T.h @@ -370,7 +370,8 @@ extern int *T_active; } \ } while (0) -#define T23(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9,t10,x10) \ +#define T23(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9, \ + t10,x10) \ do { \ if (T_ACTIVE(t)) { \ T_LOCAL_DATA \ @@ -390,7 +391,8 @@ extern int *T_active; } \ } while (0) -#define T25(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9,t10,x10,t11,x11) \ +#define T25(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9, \ + t10,x10,t11,x11) \ do { \ if (T_ACTIVE(t)) { \ T_LOCAL_DATA \ @@ -411,7 +413,8 @@ extern int *T_active; } \ } while (0) -#define T27(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9,t10,x10,t11,x11,t12,x12) \ +#define T27(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9, \ + t10,x10,t11,x11,t12,x12) \ do { \ if (T_ACTIVE(t)) { \ T_LOCAL_DATA \ @@ -433,7 +436,8 @@ extern int *T_active; } \ } while (0) -#define T29(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9,t10,x10,t11,x11,t12,x12,t13,x13) \ +#define T29(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9, \ + t10,x10,t11,x11,t12,x12,t13,x13) \ do { \ if (T_ACTIVE(t)) { \ T_LOCAL_DATA \ @@ -456,7 +460,8 @@ extern int *T_active; } \ } while (0) -#define T31(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9,t10,x10,t11,x11,t12,x12,t13,x13,t14,x14) \ +#define T31(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9, \ + t10,x10,t11,x11,t12,x12,t13,x13,t14,x14) \ do { \ if (T_ACTIVE(t)) { \ T_LOCAL_DATA \ @@ -480,7 +485,8 @@ extern int *T_active; } \ } while (0) -#define T33(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9,t10,x10,t11,x11,t12,x12,t13,x13,t14,x14,t15,x15) \ +#define T33(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9, \ + t10,x10,t11,x11,t12,x12,t13,x13,t14,x14,t15,x15) \ do { \ if (T_ACTIVE(t)) { \ T_LOCAL_DATA \ From de3a214990b4a974c254f008fda3fafdf92aba32 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 6 Sep 2024 16:44:59 +0200 Subject: [PATCH 4/4] T: support up to 19 variables in the T() macro Some people needed that. Let's stop to 19 for the time being. It's tricky enough. We can increase later if needed. (A previous commit made the tracers to accept up to 32 variables.) --- common/utils/T/T.h | 98 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 4 deletions(-) diff --git a/common/utils/T/T.h b/common/utils/T/T.h index 83232cefea..6d781241a5 100644 --- a/common/utils/T/T.h +++ b/common/utils/T/T.h @@ -96,10 +96,12 @@ struct T_header; /* T macro tricks */ extern int T_stdout; -#define TN(...) TN_N(__VA_ARGS__,33,32,31,30,29,28,27,26,25,24,23,22,21,\ - 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)(__VA_ARGS__) -#define TN_N(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,\ - n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n,...) T##n +#define TN(...) TN_N(__VA_ARGS__,39,38,37,36,35,34,33,32,31,30,29,28,27,26, \ + 25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7, \ + 6,5,4,3,2,1,0)(__VA_ARGS__) +#define TN_N(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17, \ + n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32, \ + n33,n34,n35,n36,n37,n38,n,...) T##n #define T(...) do { if (T_stdout == 0 || T_stdout == 2) TN(__VA_ARGS__); } while (0) /* type used to send arbitrary buffer data */ @@ -511,6 +513,91 @@ extern int *T_active; } \ } while (0) +#define T35(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9, \ + t10,x10,t11,x11,t12,x12,t13,x13,t14,x14,t15,x15,t16,x16) \ + do { \ + if (T_ACTIVE(t)) { \ + T_LOCAL_DATA \ + T_HEADER(t); \ + T_PUT_##t0(2, x0); \ + T_PUT_##t1(3, x1); \ + T_PUT_##t2(4, x2); \ + T_PUT_##t3(5, x3); \ + T_PUT_##t4(6, x4); \ + T_PUT_##t5(7, x5); \ + T_PUT_##t6(8, x6); \ + T_PUT_##t7(9, x7); \ + T_PUT_##t8(10, x8); \ + T_PUT_##t9(11, x9); \ + T_PUT_##t10(12, x10); \ + T_PUT_##t11(13, x11); \ + T_PUT_##t12(14, x12); \ + T_PUT_##t13(15, x13); \ + T_PUT_##t14(16, x14); \ + T_PUT_##t15(17, x15); \ + T_PUT_##t16(18, x16); \ + T_COMMIT(); \ + } \ + } while (0) + +#define T37(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9, \ + t10,x10,t11,x11,t12,x12,t13,x13,t14,x14,t15,x15,t16,x16,t17,x17) \ + do { \ + if (T_ACTIVE(t)) { \ + T_LOCAL_DATA \ + T_HEADER(t); \ + T_PUT_##t0(2, x0); \ + T_PUT_##t1(3, x1); \ + T_PUT_##t2(4, x2); \ + T_PUT_##t3(5, x3); \ + T_PUT_##t4(6, x4); \ + T_PUT_##t5(7, x5); \ + T_PUT_##t6(8, x6); \ + T_PUT_##t7(9, x7); \ + T_PUT_##t8(10, x8); \ + T_PUT_##t9(11, x9); \ + T_PUT_##t10(12, x10); \ + T_PUT_##t11(13, x11); \ + T_PUT_##t12(14, x12); \ + T_PUT_##t13(15, x13); \ + T_PUT_##t14(16, x14); \ + T_PUT_##t15(17, x15); \ + T_PUT_##t16(18, x16); \ + T_PUT_##t17(19, x17); \ + T_COMMIT(); \ + } \ + } while (0) + +#define T39(t,t0,x0,t1,x1,t2,x2,t3,x3,t4,x4,t5,x5,t6,x6,t7,x7,t8,x8,t9,x9, \ + t10,x10,t11,x11,t12,x12,t13,x13,t14,x14,t15,x15,t16,x16,t17,x17, \ + t18,x18) \ + do { \ + if (T_ACTIVE(t)) { \ + T_LOCAL_DATA \ + T_HEADER(t); \ + T_PUT_##t0(2, x0); \ + T_PUT_##t1(3, x1); \ + T_PUT_##t2(4, x2); \ + T_PUT_##t3(5, x3); \ + T_PUT_##t4(6, x4); \ + T_PUT_##t5(7, x5); \ + T_PUT_##t6(8, x6); \ + T_PUT_##t7(9, x7); \ + T_PUT_##t8(10, x8); \ + T_PUT_##t9(11, x9); \ + T_PUT_##t10(12, x10); \ + T_PUT_##t11(13, x11); \ + T_PUT_##t12(14, x12); \ + T_PUT_##t13(15, x13); \ + T_PUT_##t14(16, x14); \ + T_PUT_##t15(17, x15); \ + T_PUT_##t16(18, x16); \ + T_PUT_##t17(19, x17); \ + T_PUT_##t18(20, x18); \ + T_COMMIT(); \ + } \ + } while (0) + #define T_CALL_ERROR \ do { \ printf("%s:%d:%s: error calling T, you have to use T_INT() or T_XX()\n", \ @@ -533,6 +620,9 @@ extern int *T_active; #define T28(...) T_CALL_ERROR #define T30(...) T_CALL_ERROR #define T32(...) T_CALL_ERROR +#define T34(...) T_CALL_ERROR +#define T36(...) T_CALL_ERROR +#define T38(...) T_CALL_ERROR /* special cases for VCD logs */