summaryrefslogtreecommitdiffstats
path: root/scripts/tracetool/format/stap.py
diff options
context:
space:
mode:
authorStefan Hajnoczi2014-06-22 15:46:04 +0200
committerStefan Hajnoczi2014-08-12 15:26:11 +0200
commita76ccf3c1cb06576af091c5ac8bc264515b1bb7f (patch)
tree1abca48701be45aa32e8e13e4ef9b1637b8800af /scripts/tracetool/format/stap.py
parentMerge remote-tracking branch 'remotes/mdroth/qga-pull-2014-08-08' into staging (diff)
downloadqemu-a76ccf3c1cb06576af091c5ac8bc264515b1bb7f.tar.gz
qemu-a76ccf3c1cb06576af091c5ac8bc264515b1bb7f.tar.xz
qemu-a76ccf3c1cb06576af091c5ac8bc264515b1bb7f.zip
trace: extract stap_escape() function for reuse
SystemTap reserved words sometimes conflict with QEMU variable names. We escape them to prevent conflicts. Move escaping into its own function so the next patch can reuse it. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'scripts/tracetool/format/stap.py')
-rw-r--r--scripts/tracetool/format/stap.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/tracetool/format/stap.py b/scripts/tracetool/format/stap.py
index e24abf7f11..9e780f1b06 100644
--- a/scripts/tracetool/format/stap.py
+++ b/scripts/tracetool/format/stap.py
@@ -27,6 +27,13 @@ RESERVED_WORDS = (
)
+def stap_escape(identifier):
+ # Append underscore to reserved keywords
+ if identifier in RESERVED_WORDS:
+ return identifier + '_'
+ return identifier
+
+
def generate(events, backend):
events = [e for e in events
if "disable" not in e.properties]
@@ -45,9 +52,7 @@ def generate(events, backend):
i = 1
if len(e.args) > 0:
for name in e.args.names():
- # Append underscore to reserved keywords
- if name in RESERVED_WORDS:
- name += '_'
+ name = stap_escape(name)
out(' %s = $arg%d;' % (name, i))
i += 1