diff mbox

[1/2] trace: do not calculate arguments for disabled trace-points

Message ID 20170721143149.43721-2-vsementsov@virtuozzo.com
State New
Headers show

Commit Message

Vladimir Sementsov-Ogievskiy July 21, 2017, 2:31 p.m. UTC
Do not calculate arguments if trace-point is disabled. For this:
 - move to macro do { ... } while (0) scheme
 - use additional macro-layer to handle calls of trace-points where
   a macro generates parameter list
   (like trace_e1000e_mac_set_permanent(MAC_ARG(macaddr)))

This is needed to allow some additional logic in trace-point parameter
calculation, which will not be executed if this trace-point is
disabled.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 scripts/tracetool/format/h.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py
index aecf249d66..d0baccc453 100644
--- a/scripts/tracetool/format/h.py
+++ b/scripts/tracetool/format/h.py
@@ -73,12 +73,13 @@  def generate(events, backend, group):
             cond = "true"
 
         out('',
-            'static inline void %(api)s(%(args)s)',
-            '{',
-            '    if (%(cond)s) {',
-            '        %(api_nocheck)s(%(names)s);',
-            '    }',
-            '}',
+            '#define %(api)s(...)  _do_%(api)s(__VA_ARGS__)',
+            '#define _do_%(api)s(%(names)s) \\',
+            'do { \\',
+            '    if (%(cond)s) { \\',
+            '        %(api_nocheck)s(%(names)s); \\',
+            '    } \\',
+            '} while (0)',
             api=e.api(),
             api_nocheck=e.api(e.QEMU_TRACE_NOCHECK),
             args=e.args,