From nobody Sun Nov 16 05:40:48 2025 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=1598538719; cv=none; d=zohomail.com; s=zohoarc; b=WkSptedauUdeeAzWZM9VQUbR3vvS2JK0FSOGAJG0ksUbRhBv8dhliMzcu8jro0kKLFL31ccxBfjxMtwHFInWxt3J+9z3MRXDC/qezyzDRyec+tj8vrb3WpkNR9+XpgVWAm7ETDxxHDrRq8eNYLu34MjD9XPtFVCb10UOqh7afcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598538719; 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=KsReAXs+dPUL8HFnO/3zojF1/6SDvYdyCpVVhkLzaZ4=; b=WlqmJzdBkk+LzsyaWuLANQl/7yG1jgUcnGo1gq1Rhe9RztsqUI3RnHQhUZEcSBREj6M+3Na0ZiNL+Xd8+NLaslyNXToLjBgGZWVo30G9H9fSPQxn8seo8TjgwP4na86IPZYzjiaUxmpjz653XqXOcucs/TjbvNJXKRh8rqY3C4U= 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 1598538719263875.4623707342914; Thu, 27 Aug 2020 07:31:59 -0700 (PDT) Received: from localhost ([::1]:51290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBIwX-0004hK-Tm for importer@patchew.org; Thu, 27 Aug 2020 10:31:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBIuH-0001lS-Q7 for qemu-devel@nongnu.org; Thu, 27 Aug 2020 10:29:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kBIuG-0004J7-4l for qemu-devel@nongnu.org; Thu, 27 Aug 2020 10:29:37 -0400 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-396-AhnFzwObOaa3zFkJfHZTHQ-1; Thu, 27 Aug 2020 10:29:27 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32EF8801AE8; Thu, 27 Aug 2020 14:29:26 +0000 (UTC) Received: from localhost (ovpn-115-8.ams2.redhat.com [10.36.115.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE1F95C1D0; Thu, 27 Aug 2020 14:29:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598538575; 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=KsReAXs+dPUL8HFnO/3zojF1/6SDvYdyCpVVhkLzaZ4=; b=Xo3i6z1X2qNl7MEPrHdsqQeTztbEL0pqL2Q+eE9d5h8JuuMVn7vuxkVeHLk0VjOheKgrzn cv9Rj+8d8zKbmSZCQGvDkxViFQY0EpLfZCQ1K+7QiuCyDrJOwB702GyqLjpGIutf9ooMek yqMqizRtLqqMhK1Agz1pA1HXYCh2j6Y= X-MC-Unique: AhnFzwObOaa3zFkJfHZTHQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH 2/4] tracetool: add out_lineno and out_next_lineno to out() Date: Thu, 27 Aug 2020 15:29:13 +0100 Message-Id: <20200827142915.108730-3-stefanha@redhat.com> In-Reply-To: <20200827142915.108730-1-stefanha@redhat.com> References: <20200827142915.108730-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com X-Mimecast-Spam-Score: 0.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-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/27 02:54:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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.959, 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_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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 , 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" 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 --- 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 98104fa50e..e4ee4d5e61 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 formating= 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.26.2