[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 11/11] trace: [tracetool] Add error-reporting fun
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH v3 11/11] trace: [tracetool] Add error-reporting functions |
Date: |
Fri, 10 Feb 2012 12:49:50 +0100 |
User-agent: |
StGit/0.15 |
Signed-off-by: Lluís Vilanova <address@hidden>
---
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)
- [Qemu-devel] [PATCH v3 01/11] [trivial] Fix a compiler warning, (continued)
- [Qemu-devel] [PATCH v3 01/11] [trivial] Fix a compiler warning, Lluís Vilanova, 2012/02/10
- [Qemu-devel] [PATCH v3 02/11] trace: [tracetool] Do not rebuild event list in backend code, Lluís Vilanova, 2012/02/10
- [Qemu-devel] [PATCH v3 03/11] trace: [tracetool] Simplify event line parsing, Lluís Vilanova, 2012/02/10
- [Qemu-devel] [PATCH v3 04/11] trace: [ŧrac etool] Do not precompute the event number, Lluís Vilanova, 2012/02/10
- [Qemu-devel] [PATCH v3 05/11] trace: [tracetool] Add support for event properties, Lluís Vilanova, 2012/02/10
- [Qemu-devel] [PATCH v3 06/11] trace: [tracetool] Process the "disable" event property, Lluís Vilanova, 2012/02/10
- [Qemu-devel] [PATCH v3 07/11] trace: [tracetool] Rewrite event argument parsing, Lluís Vilanova, 2012/02/10
- [Qemu-devel] [PATCH v3 10/11] trace: Provide a per-event status define for conditional compilation, Lluís Vilanova, 2012/02/10
- [Qemu-devel] [PATCH v3 09/11] trace: [tracetool] Automatically establish available backends and formats, Lluís Vilanova, 2012/02/10
- [Qemu-devel] [PATCH v3 11/11] trace: [tracetool] Add error-reporting functions,
Lluís Vilanova <=
- [Qemu-devel] [PATCH v3 08/11] trace: [tracetool] Make format-specific code optional and with access to event information, Lluís Vilanova, 2012/02/10