From nobody Mon Apr 29 01:38:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502803811598554.2046092958666; Tue, 15 Aug 2017 06:30:11 -0700 (PDT) Received: from localhost ([::1]:33396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhbv8-0005yY-Ik for importer@patchew.org; Tue, 15 Aug 2017 09:30:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhbt8-00038c-3u for qemu-devel@nongnu.org; Tue, 15 Aug 2017 09:28:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhbt5-0002uG-Dc for qemu-devel@nongnu.org; Tue, 15 Aug 2017 09:28:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48292) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dhbt5-0002sy-4x for qemu-devel@nongnu.org; Tue, 15 Aug 2017 09:28:03 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id EA9B8653EB; Tue, 15 Aug 2017 13:27:59 +0000 (UTC) Received: from localhost (ovpn-117-29.ams2.redhat.com [10.36.117.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id D819668731; Tue, 15 Aug 2017 13:27:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EA9B8653EB Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Tue, 15 Aug 2017 14:27:45 +0100 Message-Id: <20170815132746.12540-2-stefanha@redhat.com> In-Reply-To: <20170815132746.12540-1-stefanha@redhat.com> References: <20170815132746.12540-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 15 Aug 2017 13:28:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/2] trace: use static event ID mapping in simpletrace.stp 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: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is a partial revert of commit 7f1b588f20d027730676e627713ae3bbf6baab04 ("trace: emit name <-> ID mapping in simpletrace header"), which broke the SystemTap flight recorder because event mapping records may not be present in the ring buffer when the trace is analyzed. This means simpletrace.py --no-header does not know the event ID mapping needed to pretty-print the trace. Instead of numbering events dynamically, use a static event ID mapping as dictated by the event order in the trace-events-all file. The simpletrace.py script also uses trace-events-all so the next patch will fix the simpletrace.py --no-header option to take advantage of this knowledge. Cc: Daniel P. Berrange Signed-off-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrange Message-id: 20170815084430.7128-2-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- scripts/tracetool/format/simpletrace_stap.py | 31 ++----------------------= ---- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/traceto= ol/format/simpletrace_stap.py index 144b704bcd..e7e44842ca 100644 --- a/scripts/tracetool/format/simpletrace_stap.py +++ b/scripts/tracetool/format/simpletrace_stap.py @@ -22,33 +22,8 @@ def global_var_name(name): return probeprefix().replace(".", "_") + "_" + name =20 def generate(events, backend, group): - id_map =3D global_var_name("event_name_to_id_map") - next_id =3D global_var_name("event_next_id") - map_func =3D global_var_name("simple_trace_map_event") out('/* This file is autogenerated by tracetool, do not edit. */', - '', - 'global %(id_map)s', - 'global %(next_id)s', - 'function %(map_func)s(name)', - '', - '{', - ' if (!([name] in %(id_map)s)) {', - ' %(id_map)s[name] =3D %(next_id)s', - ' name_len =3D strlen(name)', - ' printf("%%8b%%8b%%4b%%.*s", 0, ', - ' %(next_id)s, name_len, name_len, name)', - ' %(next_id)s =3D %(next_id)s + 1', - ' }', - ' return %(id_map)s[name]', - '}', - 'probe begin', - '{', - ' printf("%%8b%%8b%%8b", 0xffffffffffffffff, 0xf2b177cb0aa429b4= , 4)', - '}', - '', - id_map=3Did_map, - next_id=3Dnext_id, - map_func=3Dmap_func) + '') =20 for event_id, e in enumerate(events): if 'disable' in e.properties: @@ -56,9 +31,7 @@ def generate(events, backend, group): =20 out('probe %(probeprefix)s.simpletrace.%(name)s =3D %(probeprefix)= s.%(name)s ?', '{', - ' id =3D %(map_func)s("%(name)s")', probeprefix=3Dprobeprefix(), - map_func=3Dmap_func, name=3De.name) =20 # Calculate record size @@ -77,7 +50,7 @@ def generate(events, backend, group): sizestr =3D ' + '.join(sizes) =20 # Generate format string and value pairs for record header and arg= uments - fields =3D [('8b', 'id'), + fields =3D [('8b', str(event_id)), ('8b', 'gettimeofday_ns()'), ('4b', sizestr), ('4b', 'pid()')] --=20 2.13.4 From nobody Mon Apr 29 01:38:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502803886072405.98287104958445; Tue, 15 Aug 2017 06:31:26 -0700 (PDT) Received: from localhost ([::1]:33454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhbwK-0007SM-Au for importer@patchew.org; Tue, 15 Aug 2017 09:31:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhbt8-00039a-A5 for qemu-devel@nongnu.org; Tue, 15 Aug 2017 09:28:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhbt7-0002v5-5P for qemu-devel@nongnu.org; Tue, 15 Aug 2017 09:28:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59946) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dhbt6-0002u5-T1 for qemu-devel@nongnu.org; Tue, 15 Aug 2017 09:28:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D03CC733F5; Tue, 15 Aug 2017 13:28:02 +0000 (UTC) Received: from localhost (ovpn-117-29.ams2.redhat.com [10.36.117.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id C213467CD0; Tue, 15 Aug 2017 13:28:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D03CC733F5 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Tue, 15 Aug 2017 14:27:46 +0100 Message-Id: <20170815132746.12540-3-stefanha@redhat.com> In-Reply-To: <20170815132746.12540-1-stefanha@redhat.com> References: <20170815132746.12540-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 15 Aug 2017 13:28:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/2] simpletrace: fix flight recorder --no-header option 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: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The simpletrace.py script can pretty-print flight recorder ring buffers. These are not full simpletrace binary trace files but just the end of a trace file. There is no header and the event ID mapping information is often unavailable since the ring buffer may have filled up and discarded event ID mapping records. The simpletrace.stp script that generates ring buffer traces uses the same trace-events-all input file as simpletrace.py. Therefore both scripts have the same global ordering of trace events. A dynamic event ID mapping isn't necessary: just use the trace-events-all file as the reference for how event IDs are numbered. It is now possible to analyze simpletrace.stp ring buffers again using: $ ./simpletrace.py trace-events-all path/to/ring-buffer Signed-off-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrange Message-id: 20170815084430.7128-3-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- scripts/simpletrace.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py index 2a977e2ab9..a3a6315055 100755 --- a/scripts/simpletrace.py +++ b/scripts/simpletrace.py @@ -97,11 +97,17 @@ def read_trace_header(fobj): raise ValueError('Log format %d not supported with this QEMU relea= se!' % log_version) =20 -def read_trace_records(edict, fobj): - """Deserialize trace records from a file, yielding record tuples (even= t_num, timestamp, pid, arg1, ..., arg6).""" - idtoname =3D { - dropped_event_id: "dropped" - } +def read_trace_records(edict, idtoname, fobj): + """Deserialize trace records from a file, yielding record tuples (even= t_num, timestamp, pid, arg1, ..., arg6). + + Note that `idtoname` is modified if the file contains mapping records. + + Args: + edict (str -> Event): events dict, indexed by name + idtoname (int -> str): event names dict, indexed by event ID + fobj (file): input file + + """ while True: t =3D fobj.read(8) if len(t) =3D=3D 0: @@ -171,10 +177,16 @@ def process(events, log, analyzer, read_header=3DTrue= ): =20 dropped_event =3D Event.build("Dropped_Event(uint64_t num_events_dropp= ed)") edict =3D {"dropped": dropped_event} + idtoname =3D {dropped_event_id: "dropped"} =20 for event in events: edict[event.name] =3D event =20 + # If there is no header assume event ID mapping matches events list + if not read_header: + for event_id, event in enumerate(events): + idtoname[event_id] =3D event.name + def build_fn(analyzer, event): if isinstance(event, str): return analyzer.catchall @@ -197,7 +209,7 @@ def process(events, log, analyzer, read_header=3DTrue): =20 analyzer.begin() fn_cache =3D {} - for rec in read_trace_records(edict, log): + for rec in read_trace_records(edict, idtoname, log): event_num =3D rec[0] event =3D edict[event_num] if event_num not in fn_cache: --=20 2.13.4