[RFC PATCH] scripts/tracetool: don't barf validating TCG types

Alex Bennée posted 1 patch 3 years ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210406165307.5993-1-alex.bennee@linaro.org
scripts/tracetool/__init__.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
[RFC PATCH] scripts/tracetool: don't barf validating TCG types
Posted by Alex Bennée 3 years ago
TCG types will be transformed into the appropriate host types later on
in the tool. Try and work around this by detecting those cases and
pressing on.

[AJB: this seems a bit too hacky - but the problem is validate_type is
buried a few layers deep. Maybe we should just drop TCGv from
ALLOWED_TYPES and manually do if bit.startswith("TCGv_") in validate_type?]

Fixes: 73ff061032 ("trace: only permit standard C types and fixed size integer types")
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Cc: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
 scripts/tracetool/__init__.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 5bc94d95cf..ea078e34b4 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -87,10 +87,11 @@ def out(*lines, **kwargs):
     "ssize_t",
     "uintptr_t",
     "ptrdiff_t",
-    # Magic substitution is done by tracetool
+    # Magic substitution is done by tracetool TCG_2_HOST
     "TCGv",
 ]
 
+
 def validate_type(name):
     bits = name.split(" ")
     for bit in bits:
@@ -405,9 +406,13 @@ def read_events(fobj, fname):
         try:
             event = Event.build(line, lineno, fname)
         except ValueError as e:
-            arg0 = 'Error at %s:%d: %s' % (fname, lineno, e.args[0])
-            e.args = (arg0,) + e.args[1:]
-            raise
+            # these get translated by TCG_2_HOST later
+            if "TCGv_" not in e.args[0]:
+                arg0 = 'Error at %s:%d: %s' % (fname, lineno, e.args[0])
+                e.args = (arg0,) + e.args[1:]
+                raise
+            else:
+                pass
 
         # transform TCG-enabled events
         if "tcg" not in event.properties:
-- 
2.20.1