From nobody Wed Nov 5 15:51:28 2025 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.zoho.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 1496864837705359.97608017506457; Wed, 7 Jun 2017 12:47:17 -0700 (PDT) Received: from localhost ([::1]:45752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIg94-0004mv-DW for importer@patchew.org; Wed, 07 Jun 2017 14:57:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIg7U-0003gN-9d for qemu-devel@nongnu.org; Wed, 07 Jun 2017 14:55:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIg7T-00075a-GI for qemu-devel@nongnu.org; Wed, 07 Jun 2017 14:55:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIg7T-000750-B2 for qemu-devel@nongnu.org; Wed, 07 Jun 2017 14:55:51 -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 48BD97F3EC; Wed, 7 Jun 2017 18:55:50 +0000 (UTC) Received: from localhost (ovpn-117-84.ams2.redhat.com [10.36.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E7E75DD65; Wed, 7 Jun 2017 18:55:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 48BD97F3EC Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 48BD97F3EC From: Stefan Hajnoczi To: Date: Wed, 7 Jun 2017 19:55:40 +0100 Message-Id: <20170607185540.12767-2-stefanha@redhat.com> In-Reply-To: <20170607185540.12767-1-stefanha@redhat.com> References: <20170607185540.12767-1-stefanha@redhat.com> MIME-Version: 1.0 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.25]); Wed, 07 Jun 2017 18:55:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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/1] simpletrace: Improve the error message if event is not declared 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 , Jose Ricardo Ziviani , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Jose Ricardo Ziviani Today, if we use a trace-event file which does not declare an event existing in the log file we'll get the following error: $ scripts/simpletrace.py trace-events trace-68508 Traceback (most recent call last): File "scripts/simpletrace.py", line 242, in run(Formatter()) File "scripts/simpletrace.py", line 217, in run process(events, sys.argv[2], analyzer, read_header=3Dread_header) File "scripts/simpletrace.py", line 192, in process for rec in read_trace_records(edict, log): File "scripts/simpletrace.py", line 107, in read_trace_records rec =3D read_record(edict, idtoname, fobj) File "scripts/simpletrace.py", line 71, in read_record return get_record(edict, idtoname, rechdr, fobj) File "scripts/simpletrace.py", line 45, in get_record event =3D edict[name] KeyError: 'qemu_mutex_locked' This patch improves this error by adding a hint instead of just that KeyError log: $ scripts/simpletrace.py trace-events trace-68508 'qemu_mutex_locked' event is logged but is not declared in the trace events file, try using trace-events-all instead. Signed-off-by: Jose Ricardo Ziviani Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 1496075404-8845-1-git-send-email-joserz@linux.vnet.ibm.com Signed-off-by: Stefan Hajnoczi --- scripts/simpletrace.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py index d60b3a0..f1be6e4 100755 --- a/scripts/simpletrace.py +++ b/scripts/simpletrace.py @@ -42,7 +42,15 @@ def get_record(edict, idtoname, rechdr, fobj): event_id =3D rechdr[0] name =3D idtoname[event_id] rec =3D (name, rechdr[1], rechdr[3]) - event =3D edict[name] + try: + event =3D edict[name] + except KeyError, e: + import sys + sys.stderr.write('%s event is logged but is not declared ' \ + 'in the trace events file, try using ' \ + 'trace-events-all instead.\n' % str(e)) + sys.exit(1) + for type, name in event.args: if is_string(type): l =3D fobj.read(4) --=20 2.9.4