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 From: Greg Kurz Date: Fri, 14 Oct 2016 23:26:17 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <147648037766.14770.15179642645810274907.stgit@bahia> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH] trace: fix group name generation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi 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 afte= r the macro name #define TRACE_.BUILD_GENERATED_TRACERS_H or trace/generated-tracers.c:17497:13: error: variable or field =E2=80=98tra= ce_=E2=80=99 declared void static void trace_=3Dbuild_register_events(void) or trace/generated-tracers.c: In function =E2=80=98trace_2build_register_eve= nt=E2=80=99: trace/generated-tracers.c:17499:32: error: invalid suffix "build_trace_ev= ents" on integer constant trace_event_register_group(2build_trace_events); This patch ensures that only letters [A-Za-z], digits [0-9] and underscor= es are kept. All other characters are turned into underscores. Also, since t= he 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): =20 if dirname =3D=3D "": return "common" - return re.sub(r"/|-", "_", dirname) + return "_" + re.sub(r"[^\w]", "_", dirname) =20 def main(args): global _SCRIPT