[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/12] trace: [tracetool] Do not precompute the even
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH 05/12] trace: [tracetool] Do not precompute the event number |
Date: |
Tue, 13 Mar 2012 21:03:04 +0100 |
User-agent: |
StGit/0.16 |
An event number is implicit in its position on the list of events.
Signed-off-by: Lluís Vilanova <address@hidden>
Signed-off-by: Harsh Prateek Bora <address@hidden>
---
scripts/tracetool.py | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index 51c2106..4a85f26 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -106,14 +106,14 @@ def simple_h(events):
print '#include "trace/simple.h"'
print
- for event in events:
+ for num, event in enumerate(events):
if event.argc:
argstr = event.argnames.split()
arg_prefix = '(uint64_t)(uintptr_t)'
cast_args = arg_prefix + arg_prefix.join(argstr)
- simple_args = (str(event.num) + ', ' + cast_args)
+ simple_args = (str(num) + ', ' + cast_args)
else:
- simple_args = str(event.num)
+ simple_args = str(num)
print '''static inline void trace_%(name)s(%(args)s)
{
@@ -125,7 +125,7 @@ def simple_h(events):
'trace_args': simple_args
}
print
- print '#define NR_TRACE_EVENTS %d' % (event.num + 1)
+ print '#define NR_TRACE_EVENTS %d' % len(events)
print 'extern TraceEvent trace_list[NR_TRACE_EVENTS];'
@@ -154,7 +154,7 @@ def stderr_h(events):
#include "trace/stderr.h"
extern TraceEvent trace_list[];'''
- for event in events:
+ for num, event in enumerate(events):
argnames = event.argnames
if event.argc > 0:
argnames = ', ' + event.argnames
@@ -169,12 +169,12 @@ static inline void trace_%(name)s(%(args)s)
}''' % {
'name': event.name,
'args': event.args,
- 'event_num': event.num,
+ 'event_num': num,
'fmt': event.fmt,
'argnames': argnames
}
print
- print '#define NR_TRACE_EVENTS %d' % (event.num + 1)
+ print '#define NR_TRACE_EVENTS %d' % len(events)
def stderr_c(events):
print '''#include "trace.h"
@@ -384,8 +384,7 @@ trace_gen = {
cre = re.compile("(?P<name>[^(\s]+)\((?P<args>[^)]*)\)\s*(?P<fmt>\".*)?")
class Event(object):
- def __init__(self, num, line):
- self.num = num
+ def __init__(self, line):
m = cre.match(line)
assert m is not None
groups = m.groupdict('')
@@ -402,15 +401,13 @@ class Event(object):
# Generator that yields Event objects given a trace-events file object
def read_events(fobj):
- event_num = 0
res = []
for line in fobj:
if not line.strip():
continue
if line.lstrip().startswith('#'):
continue
- res.append(Event(event_num, line))
- event_num += 1
+ res.append(Event(line))
return res
binary = ""
- [Qemu-devel] [PATCH 00/12] Rewrite tracetool using python, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 02/12] trace: [tracetool] Remove unused 'sizestr' attribute in 'Event', Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 01/12] Converting tracetool.sh to tracetool.py, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 05/12] trace: [tracetool] Do not precompute the event number,
Lluís Vilanova <=
- [Qemu-devel] [PATCH 06/12] trace: [tracetool] Add support for event properties, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 07/12] trace: [tracetool] Process the "disable" event property, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 03/12] trace: [tracetool] Do not rebuild event list in backend code, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 04/12] trace: [tracetool] Simplify event line parsing, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 08/12] trace: [tracetool] Rewrite event argument parsing, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 09/12] trace: [tracetool] Make format-specific code optional and with access to events, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 10/12] trace: [tracetool] Automatically establish available backends and formats, Lluís Vilanova, 2012/03/13