diff options
author | Daniel P. Berrange | 2016-10-04 15:35:48 +0200 |
---|---|---|
committer | Stefan Hajnoczi | 2016-10-12 09:35:54 +0200 |
commit | 79218be42b835cbc7bd1b0fbd07d115add6e7605 (patch) | |
tree | a97e807878adfcad3099b932a268fa99d5e2e787 /scripts/tracetool/format | |
parent | trace: break circular dependency in event-internal.h (diff) | |
download | qemu-79218be42b835cbc7bd1b0fbd07d115add6e7605.tar.gz qemu-79218be42b835cbc7bd1b0fbd07d115add6e7605.tar.xz qemu-79218be42b835cbc7bd1b0fbd07d115add6e7605.zip |
trace: give each trace event a named TraceEvent struct
Currently we only expose a TraceEvent array, which must
be indexed via the TraceEventID enum constants. This
changes the generator to expose a named TraceEvent
instance for each event, with an _EVENT suffix.
Reviewed-by: LluĂs Vilanova <vilanova@ac.upc.edu>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1475588159-30598-10-git-send-email-berrange@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'scripts/tracetool/format')
-rw-r--r-- | scripts/tracetool/format/events_c.py | 19 | ||||
-rw-r--r-- | scripts/tracetool/format/events_h.py | 11 |
2 files changed, 21 insertions, 9 deletions
diff --git a/scripts/tracetool/format/events_c.py b/scripts/tracetool/format/events_c.py index ef873fa137..a97054fd58 100644 --- a/scripts/tracetool/format/events_c.py +++ b/scripts/tracetool/format/events_c.py @@ -28,22 +28,29 @@ def generate(events, backend): for e in events: out('uint16_t %s;' % e.api(e.QEMU_DSTATE)) - out('TraceEvent trace_events[TRACE_EVENT_COUNT] = {') - for e in events: if "vcpu" in e.properties: vcpu_id = "TRACE_VCPU_" + e.name.upper() else: vcpu_id = "TRACE_VCPU_EVENT_COUNT" - out(' { .id = %(id)s, .vcpu_id = %(vcpu_id)s,' - ' .name = \"%(name)s\",' - ' .sstate = %(sstate)s,', - ' .dstate = &%(dstate)s, }, ', + out('TraceEvent %(event)s = {', + ' .id = %(id)s,', + ' .vcpu_id = %(vcpu_id)s,', + ' .name = \"%(name)s\",', + ' .sstate = %(sstate)s,', + ' .dstate = &%(dstate)s ', + '};', + event = e.api(e.QEMU_EVENT), id = "TRACE_" + e.name.upper(), vcpu_id = vcpu_id, name = e.name, sstate = "TRACE_%s_ENABLED" % e.name.upper(), dstate = e.api(e.QEMU_DSTATE)) + out('TraceEvent *trace_events[TRACE_EVENT_COUNT] = {') + + for e in events: + out(' &%(event)s,', event = e.api(e.QEMU_EVENT)) + out('};', '') diff --git a/scripts/tracetool/format/events_h.py b/scripts/tracetool/format/events_h.py index 03417de0ec..80a66c57d5 100644 --- a/scripts/tracetool/format/events_h.py +++ b/scripts/tracetool/format/events_h.py @@ -21,7 +21,13 @@ def generate(events, backend): '', '#ifndef TRACE__GENERATED_EVENTS_H', '#define TRACE__GENERATED_EVENTS_H', - '') + '', + '#include "trace/event-internal.h"', + ) + + for e in events: + out('extern TraceEvent %(event)s;', + event = e.api(e.QEMU_EVENT)) # event identifiers out('typedef enum {') @@ -58,6 +64,5 @@ def generate(events, backend): enabled=enabled) out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled)) - out('#include "trace/event-internal.h"', - '', + out('', '#endif /* TRACE__GENERATED_EVENTS_H */') |