From patchwork Mon Mar 24 17:35:26 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: 26942 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1125C20062 for ; Mon, 24 Mar 2014 17:36:07 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id eb12sf24721377oac.11 for ; Mon, 24 Mar 2014 10:36:07 -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=kBgJ/OWrGKeLQChfCnvibf1lJCpslSYthN8fTXxnXao=; b=btSF+SMVJn64Q6SOPUAQg3e/xoUM9t+pyNw7VBNWYrQkOYatXDfDyIZFXOXznGEctF CiHJt2oD8xQJYAmI0ur8zbXz6AaoQqOKLA1Yu44lLLILsSQ9Y4xMZty+N9REfHndZGh6 Lfmq/iEp0lAQ5nNu5dOmP+FuFZpKHMy/dPk6mVZkOvJkphSDVvNbUDMjAdLy75y9wP3h 5r3dXMfopYz805vYcX9bIrjpA3ELHO7lJRHX9E1mX1oSyP6M31xb/4zWcz1L9clMBxjf n33XFhJxMLguPv5gmLs2KrG/t8mFOIvxx+mlwkk50d9JuV9ooW1JBsM3xlMdf3/eoSBa YuZA== X-Gm-Message-State: ALoCoQnwrYpN/kRUymavmRR+P1FT8XahTn/Yu8lSqs5WIzYtEGe21/a5y7JDvlCbc49TxdYN0YGQ X-Received: by 10.182.194.71 with SMTP id hu7mr13136850obc.37.1395682567436; Mon, 24 Mar 2014 10:36:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.120 with SMTP id y111ls1768847qgd.0.gmail; Mon, 24 Mar 2014 10:36:07 -0700 (PDT) X-Received: by 10.58.201.5 with SMTP id jw5mr49597182vec.6.1395682567304; Mon, 24 Mar 2014 10:36:07 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id wy9si1910451vdc.163.2014.03.24.10.36.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Mar 2014 10:36:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id pa12so6134842veb.14 for ; Mon, 24 Mar 2014 10:36:07 -0700 (PDT) X-Received: by 10.52.108.164 with SMTP id hl4mr2993285vdb.25.1395682567212; Mon, 24 Mar 2014 10:36:07 -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.220.78.9 with SMTP id i9csp241035vck; Mon, 24 Mar 2014 10:36:06 -0700 (PDT) X-Received: by 10.224.30.70 with SMTP id t6mr77419428qac.30.1395682566797; Mon, 24 Mar 2014 10:36:06 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n3si6805896qga.72.2014.03.24.10.36.06 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 24 Mar 2014 10:36:06 -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]:37727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS8n8-0000xa-3D for patch@linaro.org; Mon, 24 Mar 2014 13:36:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS8mQ-0008NF-8e for qemu-devel@nongnu.org; Mon, 24 Mar 2014 13:35:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WS8mJ-0001I0-F0 for qemu-devel@nongnu.org; Mon, 24 Mar 2014 13:35:20 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:59318 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS8mJ-0001Hl-8c for qemu-devel@nongnu.org; Mon, 24 Mar 2014 13:35:15 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaro.local) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1WS8me-0004P6-Pn; Mon, 24 Mar 2014 18:35:36 +0100 From: alex.bennee@linaro.org To: qemu-devel@nongnu.org Date: Mon, 24 Mar 2014 17:35:26 +0000 Message-Id: <1395682526-7538-1-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1395680694-27758-1-git-send-email-alex.bennee@linaro.org> References: <1395680694-27758-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: Mohamad Gebai , =?UTF-8?q?Alex=20Benn=C3=A9e?= , vilanova@ac.upc.edu, stefanha@redhat.com, mohamad.gebai@gmail.com Subject: [Qemu-devel] [PATCH] 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=neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 --- v2 - remove silly debug statements --- scripts/tracetool/__init__.py | 12 ++++++++++-- scripts/tracetool/backend/ust.py | 17 ++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 175df08..71e2ab5 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -118,13 +118,16 @@ class Event(object): Properties of the event. args : Arguments The event arguments. + arg_fmts : str + The format strings for each arugment. """ _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 ---------- @@ -136,11 +139,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: @@ -163,8 +170,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/backend/ust.py b/scripts/tracetool/backend/ust.py index 41c1c75..6223f20 100644 --- a/scripts/tracetool/backend/ust.py +++ b/scripts/tracetool/backend/ust.py @@ -56,13 +56,20 @@ def ust_events_h(events): 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 + ')') @@ -79,4 +86,4 @@ def ust_events_h(events): ')', '', name = e.name, - ) \ No newline at end of file + )