From patchwork Wed Oct 31 16:53:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149843 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7038840ljp; Wed, 31 Oct 2018 10:00:17 -0700 (PDT) X-Google-Smtp-Source: AJdET5fY+YBgXSDiRp77rx5sPNiw3Ttimh3WDN/QjQY5RMdqXnBAF3izAdMMqwaLGwk560iBBE+S X-Received: by 2002:aed:29e2:: with SMTP id o89-v6mr3520365qtd.364.1541005217345; Wed, 31 Oct 2018 10:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541005217; cv=none; d=google.com; s=arc-20160816; b=iJMKEWHhMB8ktENsNAe4JL7y/WCpNpFjBrkc1Dr1gnDikBs+c8tbQ2ry0y5N7dcv94 U44InsGWUIAzmipzRl0mWmeOH5BVs6yVvU3AckKxW+Usv/IC7Fa2o0YHjmTVePegu1hY mEGEP0mVwOnVUoMi9hgHZpDUM8RSYa0ujVnTwcy4cA8VbEvsaLbaTiG6vxXUXhS85JfV 9u1QZb2jPgA+3V3NkEWGtunpas6blTvf8y94kTFEJu50f/Tu81jGr1La1XPY/S5Kj6jX jTGFI7uX+1y/LhZSsl1WiH3Osh/DQTxCPQV/0RbG9FNl+T9htFa4WFeqMkR60LUSGK7C PkDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=JIUdfi8Wiee3VEFA1DC9zFaD8+pHIsuCf9eAvQVoCks=; b=seqJsn9efsbYVf3KsPk4OIT9WPmeMPR01GW2KFoz2U2i2p1mDTUvJpVGmstGWPmcMR 7tMhL2Oa4e5phnv8GaLd+W4vWDz1yn51te3ioXMADFwZ2wKL90V9uqQcQC+1/Y+xvdu7 zItLj7hY9uw9JoVCFVlgICEzNQ0UeAvLlo3SRbrX/Lnl2fymGPO6SUVzX6U3mFTETrSR +m9up+k4v/8cuMVSQC2qAskCxkYyjVgaUby1UpkeS01u8Yt5+JT4cTmwcB/rZmRikPga JJON8RDIgsdG4Q/S2k77/x3wqXfzY4SNXXUBxjS3dAYpS3jF5qh8yhUgfanI6QweIdY5 MTyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=g6rNW59T; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o6si2982982qkf.127.2018.10.31.10.00.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 31 Oct 2018 10:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=g6rNW59T; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHtqq-0004F1-Qq for patch@linaro.org; Wed, 31 Oct 2018 13:00:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHtkY-0005Xz-8a for qemu-devel@nongnu.org; Wed, 31 Oct 2018 12:53:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHtkV-0008Oo-Jt for qemu-devel@nongnu.org; Wed, 31 Oct 2018 12:53:46 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:51838) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHtkV-0008FD-6U for qemu-devel@nongnu.org; Wed, 31 Oct 2018 12:53:43 -0400 Received: by mail-wm1-x32e.google.com with SMTP id w7-v6so4784125wmc.1 for ; Wed, 31 Oct 2018 09:53:28 -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 :mime-version:content-transfer-encoding; bh=JIUdfi8Wiee3VEFA1DC9zFaD8+pHIsuCf9eAvQVoCks=; b=g6rNW59TEzwIINCPPEP1E1RMyzltgWa3sUAzosuH+nJtWtn+kMQ3GVYCA4LPsIX+HF pvsTIqzEtbqDsssXnzND6T+Yrbp0GGtUCcVo28fXulcQtAtPBbcwRe1RiTrXwtBk3eya qkln/rlwCh5YEUTk70mknRmE+c7Sr9iz8TGVA= 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:mime-version:content-transfer-encoding; bh=JIUdfi8Wiee3VEFA1DC9zFaD8+pHIsuCf9eAvQVoCks=; b=Bfmasa+DkHm8yOS0MF7MXuSEAO3/kkm9Rkppe78vTJoiTtFkcsqG1wUwYdtegnphxf kSLMEtRX7ngsKl42z7RN8FS+N+9819qbLT7oI/l6l8RysJ1gnkC1SxlCAP/EvPpm5rlS Di3TMrfC/uK0uXgjp3IqW+Bv75gEgvDPOqPsc0N7GD5cDBfQgNRvyWe3kVLG2HstBkuy +sYcUCDgJBXQhRz8AfPxPgr56cES9hX1linVhms7UhsvVr4JDNDk2LZ88W7Z1E2sx093 ena6lHKZvbTMb/UkcqxmGI0t2KS76l1Qv917PueaUG1IkjIqy5fDB6TlWUemecWv9ZTL qLLw== X-Gm-Message-State: AGRZ1gJjyxJkpmwYQvIvrbxSKiYslDwMuWL3IMa7ZEdojgsQQXQ2fgyD SVdA0T7erBxKWgSRRqMBrmAP1qEIwQw= X-Received: by 2002:a1c:2846:: with SMTP id o67-v6mr2936882wmo.60.1541004807177; Wed, 31 Oct 2018 09:53:27 -0700 (PDT) Received: from cloudburst.twiddle.net.twiddle.net (79-69-241-110.dynamic.dsl.as9105.com. [79.69.241.110]) by smtp.gmail.com with ESMTPSA id u5-v6sm7580168wrm.77.2018.10.31.09.53.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 09:53:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Oct 2018 16:53:21 +0000 Message-Id: <20181031165321.4422-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181031165321.4422-1-richard.henderson@linaro.org> References: <20181031165321.4422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32e Subject: [Qemu-devel] [PULL 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.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. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Bastian Koppelmann Signed-off-by: Richard Henderson --- scripts/decodetree.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) -- 2.17.2 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)