From patchwork Tue Aug 12 13:37:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 35264 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9B50D20540 for ; Tue, 12 Aug 2014 13:48:58 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id y10sf65283818pdj.4 for ; Tue, 12 Aug 2014 06:48:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=h/jFA9jb41Ru1RYE7kjs6Z5woUPUzKl6701WjgmX3Dk=; b=Xmd7hEXFgOmuGy7G70kqQGnPrQu6KzNCaJYJ5PkT2CIafsUEb56VA3wL6vIZKv9k98 5djRT9kvqxuZa5OdO7UjsqLZDo+MFbACvbTIYGmdRG6ok56kWXaBLsUP/nCe0OpJpMBO rdg9Sv1MgIl6CkdcjHS/ham5Z4CrqkpW4he8GgBwvJwv9r9nXDwDmkTLN3RWW4EFa9LM s/NjLKpa6HPRZGoqZr1p1xq8kd4lINIK74jkM369YVlzgBpAObKDOn5Zb1R0t4qZJcE/ 9QtNlGJTf4dT6veunb/Qi+7AoZJVY/oV50ZdcRHr35qytFxdfv+qSrl5+odGq2VPrSqi hjAA== X-Gm-Message-State: ALoCoQm7mlNRaF9TOm4xOaZnzp0Vx4Xf0FCIOXiHtZ98YpcP3ZF02/TBiuA5/0AdhC52d6TGqqF6 X-Received: by 10.68.222.194 with SMTP id qo2mr2393510pbc.6.1407851337938; Tue, 12 Aug 2014 06:48:57 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.102 with SMTP id i93ls124569qgd.40.gmail; Tue, 12 Aug 2014 06:48:57 -0700 (PDT) X-Received: by 10.220.186.196 with SMTP id ct4mr707731vcb.63.1407851337810; Tue, 12 Aug 2014 06:48:57 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id fi5si8261709vcb.4.2014.08.12.06.48.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 06:48:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id lf12so13082383vcb.40 for ; Tue, 12 Aug 2014 06:48:57 -0700 (PDT) X-Received: by 10.52.119.229 with SMTP id kx5mr9251067vdb.40.1407851337741; Tue, 12 Aug 2014 06:48:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp250381vcb; Tue, 12 Aug 2014 06:48:57 -0700 (PDT) X-Received: by 10.140.98.118 with SMTP id n109mr6394799qge.47.1407851336425; Tue, 12 Aug 2014 06:48:56 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j10si25691033qaf.123.2014.08.12.06.48.56 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 12 Aug 2014 06:48:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:42147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCRc-0000nW-3K for patch@linaro.org; Tue, 12 Aug 2014 09:48:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCHf-000139-TE for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:38:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHCHb-000894-2h for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:38:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCHa-00088r-RM for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:38:34 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7CDcWZl012319 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Aug 2014 09:38:33 -0400 Received: from localhost (ovpn-112-30.ams2.redhat.com [10.36.112.30]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s7CDcV3X006711; Tue, 12 Aug 2014 09:38:32 -0400 From: Stefan Hajnoczi To: Date: Tue, 12 Aug 2014 14:37:53 +0100 Message-Id: <1407850675-11890-17-git-send-email-stefanha@redhat.com> In-Reply-To: <1407850675-11890-1-git-send-email-stefanha@redhat.com> References: <1407850675-11890-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id s7CDcWZl012319 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Hajnoczi Subject: [Qemu-devel] [PULL 16/18] trace: teach lttng backend to use format strings X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Alex Bennée This makes the UST backend pay attention to the format string arguments that are defined when defining payload data. With this you can now ensure integers are reported in hex mode if you want. Signed-off-by: Alex Bennée Signed-off-by: Stefan Hajnoczi --- scripts/tracetool/__init__.py | 12 ++++++++++-- scripts/tracetool/format/ust_events_h.py | 15 +++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index a51e0f2..36c789d 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -136,6 +136,8 @@ class Event(object): Properties of the event. args : Arguments The event arguments. + arg_fmts : str + The format strings for each argument. """ _CRE = re.compile("((?P.*)\s+)?" @@ -144,10 +146,11 @@ class Event(object): "\s*" "(?:(?:(?P\".+),)?\s*(?P\".+))?" "\s*") + _FMT = re.compile("(%\w+|%.*PRI\S+)") _VALID_PROPS = set(["disable", "tcg", "tcg-trans", "tcg-exec"]) - def __init__(self, name, props, fmt, args, orig=None): + def __init__(self, name, props, fmt, args, arg_fmts, orig=None): """ Parameters ---------- @@ -159,13 +162,17 @@ class Event(object): Event printing format (or formats). args : Arguments Event arguments. + arg_fmts : list of str + Format strings for each argument. orig : Event or None Original Event before transformation. + """ self.name = name self.properties = props self.fmt = fmt self.args = args + self.arg_fmts = arg_fmts if orig is None: self.original = weakref.ref(self) @@ -203,6 +210,7 @@ class Event(object): if len(fmt_trans) > 0: fmt = [fmt_trans, fmt] args = Arguments.build(groups["args"]) + arg_fmts = Event._FMT.findall(fmt) if "tcg-trans" in props: raise ValueError("Invalid property 'tcg-trans'") @@ -213,7 +221,7 @@ class Event(object): if "tcg" in props and isinstance(fmt, str): raise ValueError("Events with 'tcg' property must have two formats") - return Event(name, props, fmt, args) + return Event(name, props, fmt, args, arg_fmts) def __repr__(self): """Evaluable string representation for this object.""" diff --git a/scripts/tracetool/format/ust_events_h.py b/scripts/tracetool/format/ust_events_h.py index 5102565..d189899 100644 --- a/scripts/tracetool/format/ust_events_h.py +++ b/scripts/tracetool/format/ust_events_h.py @@ -63,13 +63,20 @@ def generate(events, backend): name=e.name, args=", ".join(", ".join(i) for i in e.args)) - for t, n in e.args: - if ('int' in t) or ('long' in t) or ('unsigned' in t) or ('size_t' in t): + types = e.args.types() + names = e.args.names() + fmts = e.arg_fmts + for t,n,f in zip(types, names, fmts): + if ('char *' in t) or ('char*' in t): + out(' ctf_string(' + n + ', ' + n + ')') + elif ("%p" in f) or ("x" in f) or ("PRIx" in f): + out(' ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')') + elif ("ptr" in t) or ("*" in t): + out(' ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')') + elif ('int' in t) or ('long' in t) or ('unsigned' in t) or ('size_t' in t): out(' ctf_integer(' + t + ', ' + n + ', ' + n + ')') elif ('double' in t) or ('float' in t): out(' ctf_float(' + t + ', ' + n + ', ' + n + ')') - elif ('char *' in t) or ('char*' in t): - out(' ctf_string(' + n + ', ' + n + ')') elif ('void *' in t) or ('void*' in t): out(' ctf_integer_hex(unsigned long, ' + n + ', ' + n + ')')