From nobody Mon Feb 9 08:16:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1609770914; cv=none; d=zohomail.com; s=zohoarc; b=F9AjrRhTuRxpdaiQ4rDU2lNeO8d/SfNC4btBPiVmjTDWN88Esle6MORyDhOi2tTVSfT6l46HMNa+sxPO72Kr3715s31e32/B0q7DZin2dKK24uG/9J0G81wdYDD6IarRWkdDzGJXIWC7xVVFhjHzOlZ/D2irGxjzgZA56zHT4zs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609770914; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=obD3qSTMw3n4C1f6m1wW9WuZJhfO/kPfGgqxSpt6MoI=; b=WGzHvFurcmiwvcLwj8/35I6V1Vbfe6bPHFbiC0V7GklE2KmlZV71OwN8eY/WCB7dj8wfXkKg4DutM1tAK8DTfVbkQvaVWgk4JVPZ4JdniWNd8hF7oG4BRV3q0fWj+OswBhLMeCN8Gz6AtY9HDgPP+bVGXuYWDXdVeFQi7Mj6sF0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609770914577956.1269476415583; Mon, 4 Jan 2021 06:35:14 -0800 (PST) Received: from localhost ([::1]:42858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwQws-0007t2-2t for importer@patchew.org; Mon, 04 Jan 2021 09:35:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwQu1-00069y-9I for qemu-devel@nongnu.org; Mon, 04 Jan 2021 09:32:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:31724) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kwQtz-0000yb-H3 for qemu-devel@nongnu.org; Mon, 04 Jan 2021 09:32:09 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-576-OLf8X1bbPX2bUcYlCJxjVg-1; Mon, 04 Jan 2021 09:32:04 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A2CE8180E461; Mon, 4 Jan 2021 14:32:03 +0000 (UTC) Received: from localhost (ovpn-113-37.ams2.redhat.com [10.36.113.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32B965D9D5; Mon, 4 Jan 2021 14:32:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609770726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=obD3qSTMw3n4C1f6m1wW9WuZJhfO/kPfGgqxSpt6MoI=; b=SaJPH5sTL+Eejqr9ebfQNhm3Vwm5mprM3fYQbO+pbj03l3iO2YwZtBKMWrbNreOE9zZw0B lH5uBw6ORedoN7lgEJtgLY8vyh03FB9llCWzCkKN+9KYObZ2DkncfcTXTkYsbUDi3mSgZ1 PHMvPT5CbaLSD3a4vHrNxXuABGLmuYc= X-MC-Unique: OLf8X1bbPX2bUcYlCJxjVg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL 1/5] trace: Send "-d trace:help" output to stdout Date: Mon, 4 Jan 2021 14:31:50 +0000 Message-Id: <20210104143154.462212-2-stefanha@redhat.com> In-Reply-To: <20210104143154.462212-1-stefanha@redhat.com> References: <20210104143154.462212-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.243, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , qemu-block@nongnu.org, Doug Evans , Stefan Hajnoczi , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Doug Evans ... for consistency with "-d help". Signed-off-by: Doug Evans Message-id: 20201125215245.3514695-1-dje@google.com Signed-off-by: Stefan Hajnoczi --- trace/control.h | 3 ++- trace/control.c | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/trace/control.h b/trace/control.h index 05b95ea453..9522a7b318 100644 --- a/trace/control.h +++ b/trace/control.h @@ -201,10 +201,11 @@ void trace_fini_vcpu(CPUState *vcpu); =20 /** * trace_list_events: + * @f: Where to send output. * * List all available events. */ -void trace_list_events(void); +void trace_list_events(FILE *f); =20 /** * trace_enable_events: diff --git a/trace/control.c b/trace/control.c index b82fb87316..cd04dd4e0c 100644 --- a/trace/control.c +++ b/trace/control.c @@ -125,18 +125,18 @@ TraceEvent *trace_event_iter_next(TraceEventIter *ite= r) return NULL; } =20 -void trace_list_events(void) +void trace_list_events(FILE *f) { TraceEventIter iter; TraceEvent *ev; trace_event_iter_init(&iter, NULL); while ((ev =3D trace_event_iter_next(&iter)) !=3D NULL) { - fprintf(stderr, "%s\n", trace_event_get_name(ev)); + fprintf(f, "%s\n", trace_event_get_name(ev)); } #ifdef CONFIG_TRACE_DTRACE - fprintf(stderr, "This list of names of trace points may be incomplete " - "when using the DTrace/SystemTap backends.\n" - "Run 'qemu-trace-stap list %s' to print the full list.= \n", + fprintf(f, "This list of names of trace points may be incomplete " + "when using the DTrace/SystemTap backends.\n" + "Run 'qemu-trace-stap list %s' to print the full list.\n", error_get_progname()); #endif } @@ -176,7 +176,7 @@ static void do_trace_enable_events(const char *line_buf) void trace_enable_events(const char *line_buf) { if (is_help_option(line_buf)) { - trace_list_events(); + trace_list_events(stdout); if (monitor_cur() =3D=3D NULL) { exit(0); } --=20 2.29.2 From nobody Mon Feb 9 08:16:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1609770922; cv=none; d=zohomail.com; s=zohoarc; b=Lu7NJeVlrLRGARHXSmams17l4yhDGbQA82EyIsXiDdC7IWi7qI36ZthRGRN/yApRPcyakxoNv/oQ5xIbW686qfRGqXHpgAwmoHRDa3Sn2/fFtvvikK0XTL2cDqbi8IYctnoQts4cjqfPTd4T6N/fsMeIoxBfSpDeBuugvTRQzLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609770922; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l22MkQv4PPmQr1cIToHXMTejwHoADlb6eSp91V/U3Dw=; b=UDKPX/XnB4TnEiHqGm7bu3W4frdEO+UlSCTh0DBy9RirUkIFhTZ2vumtN1vDV2z2XUs+RM7pIBDXqWqtWgJ+ThYPK6tu7J4y175lAl/TGJyxbxoN/627Jm3y6utKQ4HpMvV5AhPcfP8VH80dNyG8Hw3cJAOHL8oeRxH6JbxOT1s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609770922169634.7476044106853; Mon, 4 Jan 2021 06:35:22 -0800 (PST) Received: from localhost ([::1]:43544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwQx6-0008Cl-Rd for importer@patchew.org; Mon, 04 Jan 2021 09:35:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwQu7-0006FP-Sp for qemu-devel@nongnu.org; Mon, 04 Jan 2021 09:32:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kwQu5-0000zu-L8 for qemu-devel@nongnu.org; Mon, 04 Jan 2021 09:32:15 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-165-diXEFCquMb6ekKCfJzyB9w-1; Mon, 04 Jan 2021 09:32:09 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9779A107ACE6; Mon, 4 Jan 2021 14:32:08 +0000 (UTC) Received: from localhost (ovpn-113-37.ams2.redhat.com [10.36.113.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id D16E66F442; Mon, 4 Jan 2021 14:32:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609770732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l22MkQv4PPmQr1cIToHXMTejwHoADlb6eSp91V/U3Dw=; b=CnqIu58HRex3GGv/HOGfPBIKiDJl9u0HrHhIoxBQ6ou1LC1nT5eiRm1+iQ9lLyAkvAIZbt DqRKWYibjilNYYmodAbD/54jmY9hINnBe1YAs0q6JikzKCgiDOsVyeBI3PzB4HRe6ggT/u MnxMzH17GCJSa7G/64i0vABYpKVFJpw= X-MC-Unique: diXEFCquMb6ekKCfJzyB9w-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL 2/5] tracetool: add output filename command-line argument Date: Mon, 4 Jan 2021 14:31:51 +0000 Message-Id: <20210104143154.462212-3-stefanha@redhat.com> In-Reply-To: <20210104143154.462212-1-stefanha@redhat.com> References: <20210104143154.462212-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.243, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The tracetool.py script writes to stdout. This means the output filename is not available to the script. Add the output filename to the command-line so that the script has access to the filename. This also simplifies the tracetool.py invocation. It's no longer necessary to use meson's custom_build(capture : true) to save output. Signed-off-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell Message-Id: <20200827142915.108730-2-stefanha@redhat.com> --- docs/devel/tracing.txt | 3 ++- meson.build | 3 +-- scripts/tracetool.py | 12 +++++++----- scripts/tracetool/__init__.py | 18 ++++++++++++++++-- trace/meson.build | 21 +++++++-------------- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/docs/devel/tracing.txt b/docs/devel/tracing.txt index d2160655b4..dba43fc7a4 100644 --- a/docs/devel/tracing.txt +++ b/docs/devel/tracing.txt @@ -318,7 +318,8 @@ probes: --target-type system \ --target-name x86_64 \ --group=3Dall \ - trace-events-all >qemu.stp + trace-events-all \ + qemu.stp =20 To facilitate simple usage of systemtap where there merely needs to be pri= ntf logging of certain probes, a helper script "qemu-trace-stap" is provided. diff --git a/meson.build b/meson.build index 372576f82c..4a92213231 100644 --- a/meson.build +++ b/meson.build @@ -1901,7 +1901,6 @@ foreach target : target_dirs custom_target(exe['name'] + stp['ext'], input: trace_events_all, output: exe['name'] + stp['ext'], - capture: true, install: stp['install'], install_dir: get_option('datadir') / 'systemtap/taps= et', command: [ @@ -1910,7 +1909,7 @@ foreach target : target_dirs '--target-name=3D' + target_name, '--target-type=3D' + target_type, '--probe-prefix=3Dqemu.' + target_type + '.' + tar= get_name, - '@INPUT@', + '@INPUT@', '@OUTPUT@' ]) endforeach endif diff --git a/scripts/tracetool.py b/scripts/tracetool.py index 31146242b7..ab7653a5ce 100755 --- a/scripts/tracetool.py +++ b/scripts/tracetool.py @@ -16,7 +16,7 @@ __email__ =3D "stefanha@redhat.com" import sys import getopt =20 -from tracetool import error_write, out +from tracetool import error_write, out, out_open import tracetool.backend import tracetool.format =20 @@ -32,7 +32,7 @@ def error_opt(msg =3D None): format_descr =3D "\n".join([ " %-15s %s" % (n, d) for n,d in tracetool.format.get_list() ]) error_write("""\ -Usage: %(script)s --format=3D --backends=3D [] +Usage: %(script)s --format=3D --backends=3D [] = ... =20 Backends: %(backends)s @@ -135,13 +135,15 @@ def main(args): if probe_prefix is None: probe_prefix =3D ".".join(["qemu", target_type, target_name]) =20 - if len(args) < 1: - error_opt("missing trace-events filepath") + if len(args) < 2: + error_opt("missing trace-events and output filepaths") events =3D [] - for arg in args: + for arg in args[:-1]: with open(arg, "r") as fh: events.extend(tracetool.read_events(fh, arg)) =20 + out_open(args[-1]) + try: tracetool.generate(events, arg_group, arg_format, arg_backends, binary=3Dbinary, probe_prefix=3Dprobe_prefix) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 3ee54be223..a6013389a0 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -31,14 +31,28 @@ def error(*lines): sys.exit(1) =20 =20 +out_filename =3D '' +out_fobj =3D sys.stdout + +def out_open(filename): + global out_filename, out_fobj + out_filename =3D filename + out_fobj =3D open(filename, 'wt') + def out(*lines, **kwargs): """Write a set of output lines. =20 You can use kwargs as a shorthand for mapping variables when formattin= g all the strings in lines. + + The 'out_filename' kwarg is automatically added with the output filena= me. """ - lines =3D [ l % kwargs for l in lines ] - sys.stdout.writelines("\n".join(lines) + "\n") + output =3D [] + for l in lines: + kwargs['out_filename'] =3D out_filename + output.append(l % kwargs) + + out_fobj.writelines("\n".join(output) + "\n") =20 # We only want to allow standard C types or fixed sized # integer types. We don't want QEMU specific types diff --git a/trace/meson.build b/trace/meson.build index 843ea14495..8569e8a0c4 100644 --- a/trace/meson.build +++ b/trace/meson.build @@ -11,20 +11,17 @@ foreach dir : [ '.' ] + trace_events_subdirs trace_h =3D custom_target(fmt.format('trace', 'h'), output: fmt.format('trace', 'h'), input: trace_events_file, - command: [ tracetool, group, '--format=3Dh', '@I= NPUT@' ], - capture: true) + command: [ tracetool, group, '--format=3Dh', '@I= NPUT@', '@OUTPUT@' ]) genh +=3D trace_h trace_c =3D custom_target(fmt.format('trace', 'c'), output: fmt.format('trace', 'c'), input: trace_events_file, - command: [ tracetool, group, '--format=3Dc', '@I= NPUT@' ], - capture: true) + command: [ tracetool, group, '--format=3Dc', '@I= NPUT@', '@OUTPUT@' ]) if 'CONFIG_TRACE_UST' in config_host trace_ust_h =3D custom_target(fmt.format('trace-ust', 'h'), output: fmt.format('trace-ust', 'h'), input: trace_events_file, - command: [ tracetool, group, '--format=3Du= st-events-h', '@INPUT@' ], - capture: true) + command: [ tracetool, group, '--format=3Du= st-events-h', '@INPUT@', '@OUTPUT@' ]) trace_ss.add(trace_ust_h, lttng, urcubp) genh +=3D trace_ust_h endif @@ -33,8 +30,7 @@ foreach dir : [ '.' ] + trace_events_subdirs trace_dtrace =3D custom_target(fmt.format('trace-dtrace', 'dtrace'), output: fmt.format('trace-dtrace', 'dtrac= e'), input: trace_events_file, - command: [ tracetool, group, '--format=3D= d', '@INPUT@' ], - capture: true) + command: [ tracetool, group, '--format=3D= d', '@INPUT@', '@OUTPUT@' ]) trace_dtrace_h =3D custom_target(fmt.format('trace-dtrace', 'h'), output: fmt.format('trace-dtrace', 'h'), input: trace_dtrace, @@ -69,8 +65,7 @@ foreach d : [ gen =3D custom_target(d[0], output: d[0], input: meson.source_root() / 'trace-events', - command: [ tracetool, '--group=3Droot', '--format=3D@0@'.f= ormat(d[1]), '@INPUT@' ], - capture: true) + command: [ tracetool, '--group=3Droot', '--format=3D@0@'.f= ormat(d[1]), '@INPUT@', '@OUTPUT@' ]) specific_ss.add(gen) endforeach =20 @@ -78,13 +73,11 @@ if 'CONFIG_TRACE_UST' in config_host trace_ust_all_h =3D custom_target('trace-ust-all.h', output: 'trace-ust-all.h', input: trace_events_files, - command: [ tracetool, '--group=3Dall', '= --format=3Dust-events-h', '@INPUT@' ], - capture: true) + command: [ tracetool, '--group=3Dall', '= --format=3Dust-events-h', '@INPUT@', '@OUTPUT@' ]) trace_ust_all_c =3D custom_target('trace-ust-all.c', output: 'trace-ust-all.c', input: trace_events_files, - command: [ tracetool, '--group=3Dall', '= --format=3Dust-events-c', '@INPUT@' ], - capture: true) + command: [ tracetool, '--group=3Dall', '= --format=3Dust-events-c', '@INPUT@', '@OUTPUT@' ]) trace_ss.add(trace_ust_all_h, trace_ust_all_c) genh +=3D trace_ust_all_h endif --=20 2.29.2 From nobody Mon Feb 9 08:16:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1609770922; cv=none; d=zohomail.com; s=zohoarc; b=Zu8DKAQpASY1e8K+tGHfobd2AGU/tlQcNx12nf9GyzXlfDBgi3+wtRJ1m0UVwtptwh8h4EVFoLbxyYp7OJ7HKrYwhM64vT8HAmKw7sNGHgDCJfhSYLrfgbQYXbHL/iwoAeT92kgPfhiZQPtPcNkIuB698uUl3OAnntO/rjShXnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609770922; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6tWCWCOLGkXyGUfh+u9khJvMWhDNT7Dc8hK3fzeKu4c=; b=mr7EhnCSbypy+5gaunOHvLVv+a+RVwJ00ExmrVbRdoilzFHRuhFZg/dp/BOgghnJiKSrA15SE8pXxTWPirJ2d/LBz1Mnr69UM8kAYYfEtvGcmLJZY50lsj8WKga0IA7dYI8LiX3QKDIpEWu/5l4w6RN0YgKnrHBgBO1tzlD/n0Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609770922227627.8581717115522; Mon, 4 Jan 2021 06:35:22 -0800 (PST) Received: from localhost ([::1]:43648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwQx7-0008FI-3r for importer@patchew.org; Mon, 04 Jan 2021 09:35:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwQuB-0006O1-9h for qemu-devel@nongnu.org; Mon, 04 Jan 2021 09:32:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:21158) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kwQu9-000115-DN for qemu-devel@nongnu.org; Mon, 04 Jan 2021 09:32:18 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-100-8QCs-Um8MSuaQdclRxzVUQ-1; Mon, 04 Jan 2021 09:32:14 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B7F4107ACE3; Mon, 4 Jan 2021 14:32:13 +0000 (UTC) Received: from localhost (ovpn-113-37.ams2.redhat.com [10.36.113.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id E50D71042A83; Mon, 4 Jan 2021 14:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609770736; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6tWCWCOLGkXyGUfh+u9khJvMWhDNT7Dc8hK3fzeKu4c=; b=fjIglMQPcRPs5PYy3l8GAHukAUw8fn+rMnHV3KpVw08qftyNS1CbMo01R7ywQNCb3IRRDb qI/ipLCaYVUjq3RKGtcE//cjKXQmlakNfEW4IGubIpr2jWOHbEjthsToRFwwu/oC4skTqK dhwARIG3GYmzBSI0a0mnlwZ76G9ifJ8= X-MC-Unique: 8QCs-Um8MSuaQdclRxzVUQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL 3/5] tracetool: add out_lineno and out_next_lineno to out() Date: Mon, 4 Jan 2021 14:31:52 +0000 Message-Id: <20210104143154.462212-4-stefanha@redhat.com> In-Reply-To: <20210104143154.462212-1-stefanha@redhat.com> References: <20210104143154.462212-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.243, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi , Eduardo Habkost , qemu-block@nongnu.org, Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Make the output file line number and next line number available to out(). A later patch will use this to improve error messages. Signed-off-by: Stefan Hajnoczi Reviewed-by: Peter Maydell Message-Id: <20200827142915.108730-3-stefanha@redhat.com> --- scripts/tracetool/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index a6013389a0..da5004ea45 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -31,6 +31,7 @@ def error(*lines): sys.exit(1) =20 =20 +out_lineno =3D 1 out_filename =3D '' out_fobj =3D sys.stdout =20 @@ -45,12 +46,19 @@ def out(*lines, **kwargs): You can use kwargs as a shorthand for mapping variables when formattin= g all the strings in lines. =20 - The 'out_filename' kwarg is automatically added with the output filena= me. + The 'out_lineno' kwarg is automatically added to reflect the current o= utput + file line number. The 'out_next_lineno' kwarg is also automatically ad= ded + with the next output line number. The 'out_filename' kwarg is automati= cally + added with the output filename. """ + global out_lineno output =3D [] for l in lines: + kwargs['out_lineno'] =3D out_lineno + kwargs['out_next_lineno'] =3D out_lineno + 1 kwargs['out_filename'] =3D out_filename output.append(l % kwargs) + out_lineno +=3D 1 =20 out_fobj.writelines("\n".join(output) + "\n") =20 --=20 2.29.2 From nobody Mon Feb 9 08:16:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1609771066; cv=none; d=zohomail.com; s=zohoarc; b=G26ayHS6NzKFG6sIGdYNz7GPT7GWm22I4A2vKjJotAkTXOwWAneBC0Cgq0FVPsPXrDk1ZvyVOHlaMosbBXt15ndHY/TYBL0AzOlBjOEfX3YszF/4595CPJ2DHqEYz2B91jus+3d2K/bu99Q3WPHvve1lvOQiGyFE27UX+ofr55w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609771066; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6BSbfoYZQUCUaGY/gemcWXuxJ/ui53Ca+rS+uU1wPRs=; b=no+gSuS6uBuIK6JPj/2Kjm3PPDolZiCJSHzgrE3cN3XDzKtYAjjhHHRwhb2g/7JuiyqSTcup+TKgxrj5rTMgfF0Yb/2tRQL0lvLfDS+ge/K8wFNmAc45ytXvIjHr8NHtg49Q2AnTu0ZNqNDqrxZ2RpGmMIq9JgPmwBI5KzFHsu4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609771066953784.1128935565873; Mon, 4 Jan 2021 06:37:46 -0800 (PST) Received: from localhost ([::1]:50752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwQzR-0002o5-Rk for importer@patchew.org; Mon, 04 Jan 2021 09:37:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwQuE-0006S9-1a for qemu-devel@nongnu.org; Mon, 04 Jan 2021 09:32:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57381) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kwQuB-00012G-Ue for qemu-devel@nongnu.org; Mon, 04 Jan 2021 09:32:21 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-457-0L6NDBQSPL2gejYWkrGmjw-1; Mon, 04 Jan 2021 09:32:16 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1899100E420; Mon, 4 Jan 2021 14:32:14 +0000 (UTC) Received: from localhost (ovpn-113-37.ams2.redhat.com [10.36.113.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 938575D9D5; Mon, 4 Jan 2021 14:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609770739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6BSbfoYZQUCUaGY/gemcWXuxJ/ui53Ca+rS+uU1wPRs=; b=Sby93aluLCgFtvUna3RzVkQfzwCf4kLlDoa3C39WtbKCcEVZ40JgfnW4WeXRS06WBKHVQa b32grzMKUwqXzH4zr1pfVivtxDte1Jo7tUqwbmpxRUgafGttISYy8q5kBac6bpwg7UxLWu ja7+lrfovYdVJSgr0LFIvEUphot7cOo= X-MC-Unique: 0L6NDBQSPL2gejYWkrGmjw-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL 4/5] tracetool: add input filename and line number to Event Date: Mon, 4 Jan 2021 14:31:53 +0000 Message-Id: <20210104143154.462212-5-stefanha@redhat.com> In-Reply-To: <20210104143154.462212-1-stefanha@redhat.com> References: <20210104143154.462212-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.243, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Store the input filename and line number in Event. A later patch will use this to improve error messages. Signed-off-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell Message-Id: <20200827142915.108730-4-stefanha@redhat.com> --- scripts/tracetool/__init__.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index da5004ea45..96b1cd69a5 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -218,6 +218,10 @@ class Event(object): Properties of the event. args : Arguments The event arguments. + lineno : int + The line number in the input file. + filename : str + The path to the input file. =20 """ =20 @@ -230,7 +234,7 @@ class Event(object): =20 _VALID_PROPS =3D set(["disable", "tcg", "tcg-trans", "tcg-exec", "vcpu= "]) =20 - def __init__(self, name, props, fmt, args, orig=3DNone, + def __init__(self, name, props, fmt, args, lineno, filename, orig=3DNo= ne, event_trans=3DNone, event_exec=3DNone): """ Parameters @@ -243,6 +247,10 @@ class Event(object): Event printing format string(s). args : Arguments Event arguments. + lineno : int + The line number in the input file. + filename : str + The path to the input file. orig : Event or None Original Event before transformation/generation. event_trans : Event or None @@ -255,6 +263,8 @@ class Event(object): self.properties =3D props self.fmt =3D fmt self.args =3D args + self.lineno =3D int(lineno) + self.filename =3D str(filename) self.event_trans =3D event_trans self.event_exec =3D event_exec =20 @@ -276,16 +286,21 @@ class Event(object): def copy(self): """Create a new copy.""" return Event(self.name, list(self.properties), self.fmt, - self.args.copy(), self, self.event_trans, self.event_= exec) + self.args.copy(), self.lineno, self.filename, + self, self.event_trans, self.event_exec) =20 @staticmethod - def build(line_str): + def build(line_str, lineno, filename): """Build an Event instance from a string. =20 Parameters ---------- line_str : str Line describing the event. + lineno : int + Line number in input file. + filename : str + Path to input file. """ m =3D Event._CRE.match(line_str) assert m is not None @@ -315,7 +330,7 @@ class Event(object): if "tcg" in props and isinstance(fmt, str): raise ValueError("Events with 'tcg' property must have two for= mat strings") =20 - event =3D Event(name, props, fmt, args) + event =3D Event(name, props, fmt, args, lineno, filename) =20 # add implicit arguments when using the 'vcpu' property import tracetool.vcpu @@ -360,6 +375,8 @@ class Event(object): list(self.properties), self.fmt, self.args.transform(*trans), + self.lineno, + self.filename, self) =20 =20 @@ -386,7 +403,7 @@ def read_events(fobj, fname): continue =20 try: - event =3D Event.build(line) + event =3D Event.build(line, lineno, fname) except ValueError as e: arg0 =3D 'Error at %s:%d: %s' % (fname, lineno, e.args[0]) e.args =3D (arg0,) + e.args[1:] --=20 2.29.2 From nobody Mon Feb 9 08:16:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1609771058; cv=none; d=zohomail.com; s=zohoarc; b=cvSmn5/sFu9agkfxuRYbglDN6qIesQxwGC+OzxCL7nYqMGAdd49PDfwnwwLoW+c9MKzmwTjfKWutpmthKq6cJcv8L1Ly68UL8dhJSxy6TeM8Tedb9yNfF/p8ejwlf4dOp1+uhKG0u+ObuIb87pPAHa8/uA7Arls3gE4zfTN7T7g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609771058; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9vee9K26BvrmT5nT/Jr7ylwdherUzohr7+W+KBGF2G4=; b=Lcg/BmyIB+SG7dldXOWMFxgpR581p53Dey7WcikwLoi5291alILXFnp/KA6nRiyNXp9iEh35okAF+uzfTrOe8zBC3tToVQbCrXck2I1jwyTsSNYtBh1NvPH9Lf+AdIr/zAHblgW4Hm/fR3EqmS7yprSTGlsvmG5+gbW8zZw9Uxg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609771058709986.1214089099366; Mon, 4 Jan 2021 06:37:38 -0800 (PST) Received: from localhost ([::1]:50286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwQzJ-0002bS-JS for importer@patchew.org; Mon, 04 Jan 2021 09:37:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwQuL-0006U4-A0 for qemu-devel@nongnu.org; Mon, 04 Jan 2021 09:32:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kwQuI-00013y-6d for qemu-devel@nongnu.org; Mon, 04 Jan 2021 09:32:29 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-e_c4o7ryO4G7PC-Y2Yv-kg-1; Mon, 04 Jan 2021 09:32:17 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A942C1842140; Mon, 4 Jan 2021 14:32:16 +0000 (UTC) Received: from localhost (ovpn-113-37.ams2.redhat.com [10.36.113.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 456D06F818; Mon, 4 Jan 2021 14:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609770743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9vee9K26BvrmT5nT/Jr7ylwdherUzohr7+W+KBGF2G4=; b=Xq0AddVTW3INT7gKBSSOoOwoDpTPUgCVPFPeJIGOzASNpcQvH0AkU74v0PV0K0NtYKlCYb fBdTozoUR7d4bM4sA9MYO5YoyYxsg2nZaGk/SplnSPFqzLAqdWvewk78kcsTjeOlKZo5xp K1t++sAamh9y9EZ1YL8EMwSidDgDf5k= X-MC-Unique: e_c4o7ryO4G7PC-Y2Yv-kg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL 5/5] tracetool: show trace-events filename/lineno in fmt string errors Date: Mon, 4 Jan 2021 14:31:54 +0000 Message-Id: <20210104143154.462212-6-stefanha@redhat.com> In-Reply-To: <20210104143154.462212-1-stefanha@redhat.com> References: <20210104143154.462212-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.243, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi , Eduardo Habkost , qemu-block@nongnu.org, Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The compiler encounters trace event format strings in generated code. Format strings are error-prone and therefore clear compiler errors are important. Use the #line directive to show the trace-events filename and line number in format string errors: https://gcc.gnu.org/onlinedocs/gcc-10.2.0/cpp/Line-Control.html For example, if the cpu_in trace event's %u is changed to %p the following error is reported: trace-events:29:18: error: format =E2=80=98%p=E2=80=99 expects argument o= f type =E2=80=98void *=E2=80=99, but argument 7 has type =E2=80=98unsigned = int=E2=80=99 [-Werror=3Dformat=3D] Line 29 in trace-events is where cpu_in is defined. This works for any trace-events file in the QEMU source tree and the correct path is displayed. Unfortunately there does not seem to be a way to set the column, so "18" is not the right character on that line. Suggested-by: Peter Maydell Signed-off-by: Stefan Hajnoczi Reviewed-by: Peter Maydell Message-Id: <20200827142915.108730-5-stefanha@redhat.com> --- scripts/tracetool/backend/ftrace.py | 4 ++++ scripts/tracetool/backend/log.py | 4 ++++ scripts/tracetool/backend/syslog.py | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backen= d/ftrace.py index e9844dd335..5fa30ccc08 100644 --- a/scripts/tracetool/backend/ftrace.py +++ b/scripts/tracetool/backend/ftrace.py @@ -33,8 +33,10 @@ def generate_h(event, group): ' int unused __attribute__ ((unused));', ' int trlen;', ' if (trace_event_get_state(%(event_id)s)) {', + '#line %(event_lineno)d "%(event_filename)s"', ' trlen =3D snprintf(ftrace_buf, MAX_TRACE_STRLEN,', ' "%(name)s " %(fmt)s "\\n" %(argnames= )s);', + '#line %(out_next_lineno)d "%(out_filename)s"', ' trlen =3D MIN(trlen, MAX_TRACE_STRLEN - 1);', ' unused =3D write(trace_marker_fd, ftrace_buf, trlen);= ', ' }', @@ -42,6 +44,8 @@ def generate_h(event, group): name=3Devent.name, args=3Devent.args, event_id=3D"TRACE_" + event.name.upper(), + event_lineno=3Devent.lineno, + event_filename=3Devent.filename, fmt=3Devent.fmt.rstrip("\n"), argnames=3Dargnames) =20 diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/l= og.py index 877222bbe9..bc43dbb4f4 100644 --- a/scripts/tracetool/backend/log.py +++ b/scripts/tracetool/backend/log.py @@ -37,12 +37,16 @@ def generate_h(event, group): out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {', ' struct timeval _now;', ' gettimeofday(&_now, NULL);', + '#line %(event_lineno)d "%(event_filename)s"', ' qemu_log("%%d@%%zu.%%06zu:%(name)s " %(fmt)s "\\n",', ' qemu_get_thread_id(),', ' (size_t)_now.tv_sec, (size_t)_now.tv_usec', ' %(argnames)s);', + '#line %(out_next_lineno)d "%(out_filename)s"', ' }', cond=3Dcond, + event_lineno=3Devent.lineno, + event_filename=3Devent.filename, name=3Devent.name, fmt=3Devent.fmt.rstrip("\n"), argnames=3Dargnames) diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backen= d/syslog.py index 1373a90192..5a3a00fe31 100644 --- a/scripts/tracetool/backend/syslog.py +++ b/scripts/tracetool/backend/syslog.py @@ -35,9 +35,13 @@ def generate_h(event, group): cond =3D "trace_event_get_state(%s)" % ("TRACE_" + event.name.uppe= r()) =20 out(' if (%(cond)s) {', + '#line %(event_lineno)d "%(event_filename)s"', ' syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);', + '#line %(out_next_lineno)d "%(out_filename)s"', ' }', cond=3Dcond, + event_lineno=3Devent.lineno, + event_filename=3Devent.filename, name=3Devent.name, fmt=3Devent.fmt.rstrip("\n"), argnames=3Dargnames) --=20 2.29.2