From patchwork Tue Jul 15 11:42:19 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: 33658 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8D8F920CAD for ; Tue, 15 Jul 2014 11:42:28 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id v10sf35588909pde.11 for ; Tue, 15 Jul 2014 04:42:27 -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=AymySO22Ykhd0eq8KlCybjOt5gfOrEhh1Sh834qAArI=; b=SWC45FvQf/uxjNGt0QRblK5pDH0KCvz5dOaEx8Vcq91ghnPItcJRGLCwhj/453KkpZ 26iWxqPduNY6j8V/gOR1/+meOwC16Xw1LbTnwJFI4UtYb4Cxujdu3nSqjEU7FeGlBVGR CM5J2/oBabBm2LZrby0r6WXmS1hhF1jMhvDk4C4FxGdMS4CCHmM7ZNz7o/wuKvbEtaK2 t0rcmq4bGees3C9gUet/X0fKqDskrbSuLwmlXc3RIt+s1J1HiNMcPX0RDS08pfYM3maq TGRirU9jbyAZxokHXo5W9rU9CrdYn3O4QKz2dXFf2bssN3wvx0rDv3duiZl6mNSn7AWj AH/w== X-Gm-Message-State: ALoCoQlC6Yc3+Yh7kFVebbTqZnENh1dwunf19t4Hk7yEZ/TV+CJCptPc4g94mglKmrt0Qtj6hXZZ X-Received: by 10.66.237.4 with SMTP id uy4mr10831213pac.40.1405424547550; Tue, 15 Jul 2014 04:42:27 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.139 with SMTP id f11ls61969qgf.87.gmail; Tue, 15 Jul 2014 04:42:27 -0700 (PDT) X-Received: by 10.220.92.135 with SMTP id r7mr21398810vcm.11.1405424547429; Tue, 15 Jul 2014 04:42:27 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id gv1si6549326vdb.27.2014.07.15.04.42.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jul 2014 04:42:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id id10so10067549vcb.30 for ; Tue, 15 Jul 2014 04:42:27 -0700 (PDT) X-Received: by 10.220.203.134 with SMTP id fi6mr21805404vcb.18.1405424547322; Tue, 15 Jul 2014 04:42:27 -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 tc5csp207550vcb; Tue, 15 Jul 2014 04:42:26 -0700 (PDT) X-Received: by 10.224.152.5 with SMTP id e5mr31283826qaw.65.1405424546637; Tue, 15 Jul 2014 04:42:26 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k20si20109875qgd.59.2014.07.15.04.42.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 15 Jul 2014 04:42:26 -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]:34064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X717q-0001SV-9V for patch@linaro.org; Tue, 15 Jul 2014 07:42:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7173-0000r0-7Z for qemu-devel@nongnu.org; Tue, 15 Jul 2014 07:41:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X716x-0003Y2-Pk for qemu-devel@nongnu.org; Tue, 15 Jul 2014 07:41:37 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:59341 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X716x-0003XP-Jc for qemu-devel@nongnu.org; Tue, 15 Jul 2014 07:41:31 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaro.local) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1X71Cw-0007um-4u; Tue, 15 Jul 2014 13:47:42 +0200 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: stefanha@redhat.com Date: Tue, 15 Jul 2014 12:42:19 +0100 Message-Id: <1405424541-21803-2-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1405424541-21803-1-git-send-email-alex.bennee@linaro.org> References: <1405424541-21803-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, mohamad.gebai@gmail.com Subject: [Qemu-devel] [PATCH v2 1/3] 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.171 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 diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index eccf552..0a65d6a 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -122,13 +122,16 @@ 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+)?(?P[^(\s]+)\((?P[^)]*)\)\s*(?P\".*)?") + _FMT = re.compile("(%\w+|%.*PRI\S+)") _VALID_PROPS = set(["disable"]) - def __init__(self, name, props, fmt, args): + def __init__(self, name, props, fmt, args, arg_fmts): """ Parameters ---------- @@ -140,11 +143,15 @@ class Event(object): Event printing format. args : Arguments Event arguments. + arg_fmts : list of str + Format strings for each argument. + """ self.name = name self.properties = props self.fmt = fmt self.args = args + self.arg_fmts = arg_fmts unknown_props = set(self.properties) - self._VALID_PROPS if len(unknown_props) > 0: @@ -173,8 +180,9 @@ class Event(object): props = groups["props"].split() fmt = groups["fmt"] args = Arguments.build(groups["args"]) + arg_fmts = Event._FMT.findall(fmt) - 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 + ')')