From patchwork Wed Oct 31 12:14:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 991369 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="d2pn3c+G"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lS3S4fxHz9s3q for ; Wed, 31 Oct 2018 23:15:46 +1100 (AEDT) Received: from localhost ([::1]:59096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHpPT-00035d-CK for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2018 08:15:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHpOn-00034H-93 for qemu-devel@nongnu.org; Wed, 31 Oct 2018 08:15:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHpOj-0002fV-5A for qemu-devel@nongnu.org; Wed, 31 Oct 2018 08:15:01 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:43413) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHpOf-0002Ri-Gn for qemu-devel@nongnu.org; Wed, 31 Oct 2018 08:14:55 -0400 Received: by mail-wr1-x42f.google.com with SMTP id t10-v6so16213054wrn.10 for ; Wed, 31 Oct 2018 05:14:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zESlNWMkk7Fcwbo3x2MkGK4XqwPhUldV22MGkv8jLsw=; b=d2pn3c+Gk2JTWpIqOK3opbS6NdhuauI7QQ8lqUc/sPOx62xFSOI+o9y9rzJhRCtXup Gou9OxMUBPRAP2SHaPkP+cQsAboL1+NNqe4gF0s5MT8o87z/GfDPQ+LJkBvzwhf5YrFu YXfIUF0NfF9GoMcCLUZizziQtIhADD/M602UI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zESlNWMkk7Fcwbo3x2MkGK4XqwPhUldV22MGkv8jLsw=; b=tOCuF9ncN5IJ+mYalqD8tZ3vz5d9hEkoWkS34mI36RaJg27Octc4TxfJXujZUsH0kU vAvWDRAUl1SUTIIqm94iaP5vCyPRyHATWu6418tAAwUiHXj0COdi7SU9eHTzo/bYgIY6 EROMWioF+Q1gSAln51dSfWzSE6FWjJGwALFF1WToHyH6j3h80gLPlxcbRg0LZZAkNZ+T BlwKZw7qqiWEsQpJwwRa5AdMFTQqELp4YgEdu7K6Crsq9PBvOKtEn0xVShp9nwefe/TV XiJBF0AxA5lco4XChdw+3TLAIigldhpuWJ/t9DSh2sntM4v1HTfxdVf1CYP865rDFjOm gDLw== X-Gm-Message-State: AGRZ1gJtSVALLwgiNMrBU22mUsgdHY2RBdaGXKXk+Q+H8hr8p4abgkzP zbLQ8MxhizRlO5mcY1ohAEF+MEPZUhQ= X-Google-Smtp-Source: AJdET5cW+Jt2iXUmm2mqGIUVmDnnQnhEJe/DfswXzgVx+cWW8KI78+yvPThrRQJNcjVLddJjJzn/ew== X-Received: by 2002:adf:ed8d:: with SMTP id c13-v6mr2502906wro.39.1540988088638; Wed, 31 Oct 2018 05:14:48 -0700 (PDT) Received: from cloudburst.twiddle.net.lan (79-69-241-110.dynamic.dsl.as9105.com. [79.69.241.110]) by smtp.gmail.com with ESMTPSA id l140-v6sm37008148wmb.24.2018.10.31.05.14.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 05:14:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Oct 2018 12:14:43 +0000 Message-Id: <20181031121443.605-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181031121443.605-1-richard.henderson@linaro.org> References: <20181031121443.605-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f Subject: [Qemu-devel] [PATCH v2 3/3] decodetree: Allow multiple input files 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: kbastian@mail.uni-paderborn.de Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" While it would be possible to concatenate input files with make, passing the original input files to decodetree.py allows us to generate error messages which allows compilation environments (read: emacs) to next-error to the correct input file. Signed-off-by: Richard Henderson Reviewed-by: Bastian Koppelmann --- scripts/decodetree.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 6670d58cc1..4a3d46e4a7 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -175,15 +175,15 @@ decode_function = 'decode' re_ident = '[a-zA-Z][a-zA-Z0-9_]*' -def error(lineno, *args): +def error_with_file(file, lineno, *args): """Print an error message from file:line and args and exit.""" global output_file global output_fd if lineno: - r = '{0}:{1}: error:'.format(input_file, lineno) + r = '{0}:{1}: error:'.format(file, lineno) elif input_file: - r = '{0}: error:'.format(input_file) + r = '{0}: error:'.format(file) else: r = 'error:' for a in args: @@ -195,6 +195,8 @@ def error(lineno, *args): os.remove(output_file) exit(1) +def error(lineno, *args): + error_with_file(input_file, lineno, args) def output(*args): global output_fd @@ -420,6 +422,7 @@ class General: """Common code between instruction formats and instruction patterns""" def __init__(self, name, lineno, base, fixb, fixm, udfm, fldm, flds): self.name = name + self.file = input_file self.lineno = lineno self.base = base self.fixedbits = fixb @@ -472,7 +475,7 @@ class Pattern(General): global translate_prefix ind = str_indent(i) arg = self.base.base.name - output(ind, '/* line ', str(self.lineno), ' */\n') + output(ind, '/* ', self.file, ':', str(self.lineno), ' */\n') if not extracted: output(ind, self.base.extract_name(), '(&u.f_', arg, ', insn);\n') for n, f in self.fields.items(): @@ -920,8 +923,9 @@ def build_tree(pats, outerbits, outermask): if innermask == 0: pnames = [] for p in pats: - pnames.append(p.name + ':' + str(p.lineno)) - error(pats[0].lineno, 'overlapping patterns:', pnames) + pnames.append(p.name + ':' + p.file + ':' + str(p.lineno)) + error_with_file(pats[0].file, pats[0].lineno, + 'overlapping patterns:', pnames) fullmask = outermask | innermask @@ -1012,10 +1016,11 @@ def main(): if len(args) < 1: error(0, 'missing input file') - input_file = args[0] - f = open(input_file, 'r') - parse_file(f) - f.close() + for filename in args: + input_file = filename + f = open(filename, 'r') + parse_file(f) + f.close() t = build_tree(patterns, 0, 0) prop_format(t)