diff mbox

[13/13] trace: Rename C++-specific names in event arguments

Message ID 150091889458.30739.16324719944323757435.stgit@frigg.lan
State New
Headers show

Commit Message

Lluís Vilanova July 24, 2017, 5:54 p.m. UTC
Allows instrumentation clients in C++ to use the auto-generated headers.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 scripts/tracetool/__init__.py |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 7c19dc8c94..be7f28d2be 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -42,6 +42,8 @@  def out(*lines, **kwargs):
     sys.stdout.writelines("\n".join(lines) + "\n")
 
 
+FORBIDDEN = ["new", "class"]
+
 class Arguments:
     """Event arguments description."""
 
@@ -85,6 +87,9 @@  class Arguments:
             else:
                 arg_type, identifier = arg.rsplit(None, 1)
 
+            if identifier in FORBIDDEN:
+                identifier += "_"
+
             res.append((arg_type, identifier))
         return Arguments(res)
 
@@ -230,7 +235,10 @@  class Event(object):
         fmt_trans = groups["fmt_trans"]
         if len(fmt_trans) > 0:
             fmt = [fmt_trans, fmt]
-        args = Arguments.build(groups["args"])
+        try:
+            args = Arguments.build(groups["args"])
+        except ForbiddenArgumentError as e:
+            error("Error: event '%s' uses forbidden argument name '%s'" % (name, e.name))
 
         if "tcg-trans" in props:
             raise ValueError("Invalid property 'tcg-trans'")