Mesa (main): util/utrace: make generated code a tiny bit nicer to look at

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 1 10:02:24 UTC 2022


Module: Mesa
Branch: main
Commit: d014efa33e7042d182896726b431498d664e91c2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d014efa33e7042d182896726b431498d664e91c2

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Mon Jan 31 16:54:53 2022 +0200

util/utrace: make generated code a tiny bit nicer to look at

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14818>

---

 src/util/perf/u_trace.py | 45 ++++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/src/util/perf/u_trace.py b/src/util/perf/u_trace.py
index cd50d862082..9ecca608e20 100644
--- a/src/util/perf/u_trace.py
+++ b/src/util/perf/u_trace.py
@@ -180,38 +180,45 @@ ${declaration.decl};
 % endfor
 
 % for trace_name, trace in TRACEPOINTS.items():
+
 /*
  * ${trace_name}
  */
 struct trace_${trace_name} {
 %    for arg in trace.tp_struct:
-         ${arg.type} ${arg.name};
+   ${arg.type} ${arg.name};
 %    endfor
 %    if len(trace.args) == 0:
 #ifdef  __cplusplus
-     /* avoid warnings about empty struct size mis-match in C vs C++..
-      * the size mis-match is harmless because (a) nothing will deref
-      * the empty struct, and (b) the code that cares about allocating
-      * sizeof(struct trace_${trace_name}) (and wants this to be zero
-      * if there is no payload) is C
-      */
-     uint8_t dummy;
+   /* avoid warnings about empty struct size mis-match in C vs C++..
+    * the size mis-match is harmless because (a) nothing will deref
+    * the empty struct, and (b) the code that cares about allocating
+    * sizeof(struct trace_${trace_name}) (and wants this to be zero
+    * if there is no payload) is C
+    */
+   uint8_t dummy;
 #endif
 %    endif
 };
 %    if trace.tp_perfetto is not None:
 #ifdef HAVE_PERFETTO
-void ${trace.tp_perfetto}(${ctx_param}, uint64_t ts_ns, const void *flush_data, const struct trace_${trace_name} *payload);
+void ${trace.tp_perfetto}(
+   ${ctx_param},
+   uint64_t ts_ns,
+   const void *flush_data,
+   const struct trace_${trace_name} *payload);
 #endif
 %    endif
-void __trace_${trace_name}(struct u_trace *ut, void *cs
+void __trace_${trace_name}(
+       struct u_trace *ut, void *cs
 %    for arg in trace.args:
      , ${arg.type} ${arg.var}
 %    endfor
 );
-static inline void trace_${trace_name}(struct u_trace *ut, void *cs
+static inline void trace_${trace_name}(
+     struct u_trace *ut, void *cs
 %    for arg in trace.args:
-     , ${arg.type} ${arg.var}
+   , ${arg.type} ${arg.var}
 %    endfor
 ) {
 %    if trace.tp_perfetto is not None:
@@ -220,9 +227,10 @@ static inline void trace_${trace_name}(struct u_trace *ut, void *cs
    if (!unlikely(ut->enabled || ut_trace_instrument))
 %    endif
       return;
-   __trace_${trace_name}(ut, cs
+   __trace_${trace_name}(
+        ut, cs
 %    for arg in trace.args:
-        , ${arg.var}
+      , ${arg.var}
 %    endfor
    );
 }
@@ -310,16 +318,19 @@ static const struct u_tracepoint __tp_${trace_name} = {
 #endif
  % endif
 };
-void __trace_${trace_name}(struct u_trace *ut, void *cs
+void __trace_${trace_name}(
+     struct u_trace *ut, void *cs
  % for arg in trace.args:
-     , ${arg.type} ${arg.var}
+   , ${arg.type} ${arg.var}
  % endfor
 ) {
    struct trace_${trace_name} *__entry =
       (struct trace_${trace_name} *)u_trace_append(ut, cs, &__tp_${trace_name});
+ % if len(trace.tp_struct) == 0:
    (void)__entry;
+ % endif
  % for arg in trace.tp_struct:
-        __entry->${arg.name} = ${arg.var};
+   __entry->${arg.name} = ${arg.var};
  % endfor
 }
 



More information about the mesa-commit mailing list