From patchwork Fri Aug 1 16:08:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 34725 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f197.google.com (mail-ig0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0C74A202A1 for ; Fri, 1 Aug 2014 16:10:14 +0000 (UTC) Received: by mail-ig0-f197.google.com with SMTP id r2sf3886634igi.0 for ; Fri, 01 Aug 2014 09:10:14 -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=tzWAONVu99cm5CnF4FOHW7hPq3MEcj1JWB89ktI0QrI=; b=Zcep+Q13kP0ytfOF2t3zR/GBYRHTSZEA42hBLKjZtHDIm2f54dGqbuDNPGDBb7NyYg T5kl9zd8VXlUwLBASN/wNUW+w53tMVPxQu+MS0QEhlneOROp06zrzD07tyhiu8KCTCID xtPIZMReTgKd0io4ZjEjQe4onuHW75NLoqeWaWFZ8As6mNb3lnUl7jv52+TmyG+qpWhX JIl76KnSm0RTUHXH80pylFcZO8zArgC23Xk3zsa00OdunpHIlAx3tXKGBT0YH1PA0P5T ttrthJ1KvSp9PtZf+jQ3OqdVzmwAO7PWS+oZmVuMGvq2TCn8AGH5RHBgK7DqNMTvDJ/B I22A== X-Gm-Message-State: ALoCoQnyWg9EQ+TpQF8hCy+qFwq5QBvfVRYAFOPxWm7Jk1rl391+ewwX4HexZMm7+EvGnDp11gQr X-Received: by 10.182.110.130 with SMTP id ia2mr620717obb.42.1406909414363; Fri, 01 Aug 2014 09:10:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.39.39 with SMTP id u36ls1458043qgu.63.gmail; Fri, 01 Aug 2014 09:10:14 -0700 (PDT) X-Received: by 10.52.164.80 with SMTP id yo16mr6355733vdb.44.1406909414250; Fri, 01 Aug 2014 09:10:14 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id ls1si7711218vcb.99.2014.08.01.09.10.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Aug 2014 09:10:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hq11so6972891vcb.38 for ; Fri, 01 Aug 2014 09:10:14 -0700 (PDT) X-Received: by 10.220.131.207 with SMTP id y15mr3687704vcs.71.1406909414148; Fri, 01 Aug 2014 09:10:14 -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 tc5csp122465vcb; Fri, 1 Aug 2014 09:10:13 -0700 (PDT) X-Received: by 10.224.163.83 with SMTP id z19mr10833959qax.68.1406909412827; Fri, 01 Aug 2014 09:10:12 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a5si16295143qag.11.2014.08.01.09.10.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 01 Aug 2014 09:10:12 -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]:40467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDFPI-00026J-4D for patch@linaro.org; Fri, 01 Aug 2014 12:10:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDFO8-0000qd-5z for qemu-devel@nongnu.org; Fri, 01 Aug 2014 12:09:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XDFO2-00058g-NE for qemu-devel@nongnu.org; Fri, 01 Aug 2014 12:09:00 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:56652 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDFO2-00058O-9J for qemu-devel@nongnu.org; Fri, 01 Aug 2014 12:08:54 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaro.local) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1XDFY9-0004QQ-RX; Fri, 01 Aug 2014 18:19:21 +0200 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: stefanha@redhat.com Date: Fri, 1 Aug 2014 17:08:56 +0100 Message-Id: <1406909337-32224-2-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.0.3 In-Reply-To: <1406909337-32224-1-git-send-email-alex.bennee@linaro.org> References: <1406909337-32224-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 88.198.71.155 Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v4 1/2] 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: alex.bennee@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.179 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 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 --- v2 - remove silly debug statements v3 - fix spelling - rebase to latest tracetool v4: - rebase onto tracing-next 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 + ')')