From patchwork Fri Feb 10 11:55:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 140639 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9E591B6EF7 for ; Sat, 11 Feb 2012 00:44:18 +1100 (EST) Received: from localhost ([::1]:58433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvqlp-0002Ss-8a for incoming@patchwork.ozlabs.org; Fri, 10 Feb 2012 08:44:13 -0500 Received: from eggs.gnu.org ([140.186.70.92]:52041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvp4s-00020Y-US for qemu-devel@nongnu.org; Fri, 10 Feb 2012 06:55:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rvp4l-0003Hs-To for qemu-devel@nongnu.org; Fri, 10 Feb 2012 06:55:46 -0500 Received: from gw.ac.upc.edu ([147.83.30.3]:60357) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvp4l-0003HX-Ft for qemu-devel@nongnu.org; Fri, 10 Feb 2012 06:55:39 -0500 Received: from localhost (unknown [10.8.0.22]) by gw.ac.upc.edu (Postfix) with ESMTP id 6237E2D000D; Fri, 10 Feb 2012 12:55:38 +0100 (CET) To: qemu-devel@nongnu.org From: =?utf-8?b?TGx1w61z?= Vilanova Date: Fri, 10 Feb 2012 12:55:30 +0100 Message-ID: <20120210115530.9787.18557.stgit@ginnungagap.bsc.es> In-Reply-To: <20120210115429.9787.92858.stgit@ginnungagap.bsc.es> References: <20120210115429.9787.92858.stgit@ginnungagap.bsc.es> User-Agent: StGit/0.15 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 147.83.30.3 Cc: stefanha@gmail.com, harsh@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v4 11/11] trace: [tracetool] Add error-reporting functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: LluĂ­s Vilanova --- scripts/tracetool.py | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/tracetool.py b/scripts/tracetool.py index 1134544..7053a74 100755 --- a/scripts/tracetool.py +++ b/scripts/tracetool.py @@ -12,6 +12,13 @@ import sys import getopt +def error_write(*lines): + sys.stderr.writelines(lines) + +def error(*lines): + error_write(*lines) + sys.exit(1) + ###################################################################### # format auto-registration @@ -443,14 +450,11 @@ def dtrace_nop_d(events): def trace_stap_begin(events): global probeprefix if binary == "": - print '--binary is required for SystemTAP tapset generator' - sys.exit(1) + error("--binary is required for SystemTAP tapset generator\n") if ((probeprefix == "") and (targettype == "")): - print '--target-type is required for SystemTAP tapset generator' - sys.exit(1) + error("--target-type is required for SystemTAP tapset generator\n") if ((probeprefix == "") and (targetarch == "")): - print '--target-arch is required for SystemTAP tapset generator' - sys.exit(1) + error("--target-arch is required for SystemTAP tapset generator\n") if probeprefix == "": probeprefix = 'qemu.' + targettype + '.' + targetarch print '/* This file is autogenerated by tracetool, do not edit. */' @@ -601,8 +605,9 @@ def main(): try: opts, args = getopt.getopt(sys.argv[1:], "", long_options) except getopt.GetoptError, err: - # print help information and exit: - print str(err) # will print something like "option -a not recognized" + # print help information and exit + # will print something like "option -a not recognized" + error_write(str(err)+"\n") usage() sys.exit(2) for opt, arg in opts: @@ -631,12 +636,10 @@ def main(): usage() if format_ not in _formats: - print "Unknown format: %s" % format_ - print + error_write("Unknown format: %s\n\n" % format_) usage() if backend not in _backends: - print "Unknown backend: %s" % backend - print + error_write("Unknown backend: %s\n\n" % backend) usage() events = read_events(sys.stdin)