From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wyi6U-0001Rx-VC for qemu-devel@nongnu.org; Sun, 22 Jun 2014 09:46:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wyi6L-0007L9-98 for qemu-devel@nongnu.org; Sun, 22 Jun 2014 09:46:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wyi6L-0007Kq-0G for qemu-devel@nongnu.org; Sun, 22 Jun 2014 09:46:33 -0400 From: Stefan Hajnoczi Date: Sun, 22 Jun 2014 21:46:04 +0800 Message-Id: <1403444767-2601-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1403444767-2601-1-git-send-email-stefanha@redhat.com> References: <1403444767-2601-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v2 1/4] trace: extract stap_escape() function for reuse List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: saito.kazuya@jp.fujitsu.com, Stefan Hajnoczi , vilanova@ac.upc.edu 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 --- scripts/tracetool/format/stap.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/tracetool/format/stap.py b/scripts/tracetool/format/stap.py index e24abf7..9e780f1 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 -- 1.9.3