From patchwork Fri Oct 14 21:26:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 682440 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3swgfp6gxbz9s3T for ; Sat, 15 Oct 2016 08:27:30 +1100 (AEDT) Received: from localhost ([::1]:49495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvA0m-0007U6-U5 for incoming@patchwork.ozlabs.org; Fri, 14 Oct 2016 17:27:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv9zp-0006tN-0I for qemu-devel@nongnu.org; Fri, 14 Oct 2016 17:26:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bv9zl-0003aw-OY for qemu-devel@nongnu.org; Fri, 14 Oct 2016 17:26:28 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60265) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bv9zl-0003al-GA for qemu-devel@nongnu.org; Fri, 14 Oct 2016 17:26:25 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9ELOA1G118449 for ; Fri, 14 Oct 2016 17:26:24 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 26327tc42w-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 14 Oct 2016 17:26:23 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Oct 2016 15:26:23 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 14 Oct 2016 15:26:20 -0600 Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 529011FF0026; Fri, 14 Oct 2016 15:26:00 -0600 (MDT) Received: from b01ledav03.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9ELQJrV16646644; Fri, 14 Oct 2016 21:26:19 GMT Received: from b01ledav03.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4BFE5B2058; Fri, 14 Oct 2016 17:26:19 -0400 (EDT) Received: from [192.168.66.108] (unknown [9.83.37.45]) by b01ledav03.gho.pok.ibm.com (Postfix) with ESMTP id D9559B204D; Fri, 14 Oct 2016 17:26:18 -0400 (EDT) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 14 Oct 2016 23:26:17 +0200 User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16101421-8235-0000-0000-000009667380 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005912; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000187; SDB=6.00768467; UDB=6.00367837; IPR=6.00544612; BA=6.00004809; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012994; XFM=3.00000011; UTC=2016-10-14 21:26:21 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16101421-8236-0000-0000-000035A678C9 Message-Id: <147648037766.14770.15179642645810274907.stgit@bahia> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-10-14_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610140377 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id u9ELOA1G118449 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH] trace: fix group name generation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Since commit "80dd5c4918ab trace: introduce a formal group name for trace events", tracetool generates C variable names and macro definitions out of the path to the trace-events-all file. The current code takes care of turning '/' and '-' characters into underscores so that the resulting names are valid C tokens. This is enough because these are the only illegal characters that appear in a relative path within the QEMU source tree. Things are different for out of tree builds where the path may contain arbitrary character combinations, causing tracetool to generate invalid names. This may cause a variety of build breaks like below: trace/generated-tracers.h:4:15: warning: ISO C99 requires whitespace after the macro name #define TRACE_.BUILD_GENERATED_TRACERS_H or trace/generated-tracers.c:17497:13: error: variable or field ‘trace_’ declared void static void trace_=build_register_events(void) or trace/generated-tracers.c: In function ‘trace_2build_register_event’: trace/generated-tracers.c:17499:32: error: invalid suffix "build_trace_events" on integer constant trace_event_register_group(2build_trace_events); This patch ensures that only letters [A-Za-z], digits [0-9] and underscores are kept. All other characters are turned into underscores. Also, since the first character of C symbol names cannot be a digit, an underscore is prepended to the group name. Signed-off-by: Greg Kurz --- scripts/tracetool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tracetool.py b/scripts/tracetool.py index 629b2593c846..b81b834db924 100755 --- a/scripts/tracetool.py +++ b/scripts/tracetool.py @@ -70,7 +70,7 @@ def make_group_name(filename): if dirname == "": return "common" - return re.sub(r"/|-", "_", dirname) + return "_" + re.sub(r"[^\w]", "_", dirname) def main(args): global _SCRIPT