Revision 45be2f5d

b/Makefile
35 35
GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h
36 36
GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c
37 37

  
38
GENERATED_HEADERS += trace/generated-events.h
39
GENERATED_SOURCES += trace/generated-events.c
40

  
38 41
GENERATED_HEADERS += trace/generated-tracers.h
39 42
ifeq ($(TRACE_BACKEND),dtrace)
40 43
GENERATED_HEADERS += trace/generated-tracers-dtrace.h
b/scripts/tracetool/backend/events.py
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3

  
4
"""
5
Generic event description.
6

  
7
This is a dummy backend to establish appropriate frontend/backend compatibility
8
checks.
9
"""
10

  
11
__author__     = "Lluís Vilanova <vilanova@ac.upc.edu>"
12
__copyright__  = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
13
__license__    = "GPL version 2 or (at your option) any later version"
14

  
15
__maintainer__ = "Stefan Hajnoczi"
16
__email__      = "stefanha@linux.vnet.ibm.com"
17

  
18

  
19
def events_h(events):
20
    pass
21

  
22
def events_c(events):
23
    pass
b/scripts/tracetool/format/events_c.py
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3

  
4
"""
5
Generate .c for event description.
6
"""
7

  
8
__author__     = "Lluís Vilanova <vilanova@ac.upc.edu>"
9
__copyright__  = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
10
__license__    = "GPL version 2 or (at your option) any later version"
11

  
12
__maintainer__ = "Stefan Hajnoczi"
13
__email__      = "stefanha@linux.vnet.ibm.com"
14

  
15

  
16
from tracetool import out
17

  
18

  
19
def begin(events):
20
    out('/* This file is autogenerated by tracetool, do not edit. */',
21
        '',
22
        '#include "trace.h"',
23
        '#include "trace/generated-events.h"',
24
        '#include "trace/control.h"',
25
        '',
26
        )
27

  
28
    out('TraceEvent trace_events[TRACE_EVENT_COUNT] = {')
29

  
30
    for e in events:
31
        out('    { .id = %(id)s, .name = \"%(name)s\", .sstate = %(sstate)s, .dstate = 0 },',
32
            id = "TRACE_" + e.name.upper(),
33
            name = e.name,
34
            sstate = "TRACE_%s_ENABLED" % e.name.upper(),
35
            )
36

  
37
    out('};',
38
        '',
39
        )
b/scripts/tracetool/format/events_h.py
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3

  
4
"""
5
Generate .h for event description.
6
"""
7

  
8
__author__     = "Lluís Vilanova <vilanova@ac.upc.edu>"
9
__copyright__  = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
10
__license__    = "GPL version 2 or (at your option) any later version"
11

  
12
__maintainer__ = "Stefan Hajnoczi"
13
__email__      = "stefanha@linux.vnet.ibm.com"
14

  
15

  
16
from tracetool import out
17

  
18

  
19
def begin(events):
20
    out('/* This file is autogenerated by tracetool, do not edit. */',
21
        '',
22
        '#ifndef TRACE__GENERATED_EVENTS_H',
23
        '#define TRACE__GENERATED_EVENTS_H',
24
        '',
25
        '#include <stdbool.h>',
26
        ''
27
        )
28

  
29
    # event identifiers
30
    out('typedef enum {')
31

  
32
    for e in events:
33
        out('    TRACE_%s,' % e.name.upper())
34

  
35
    out('    TRACE_EVENT_COUNT',
36
        '} TraceEventID;',
37
        )
38

  
39
    # static state
40
    for e in events:
41
        if 'disable' in e.properties:
42
            enabled = 0
43
        else:
44
            enabled = 1
45
        out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled))
46

  
47
    out('#include "trace/event-internal.h"',
48
        '',
49
        '#endif  /* TRACE__GENERATED_EVENTS_H */',
50
        )
b/scripts/tracetool/format/h.py
25 25
        '#include "qemu-common.h"')
26 26

  
27 27
def end(events):
28
    for e in events:
29
        if "disable" in e.properties:
30
            enabled = 0
31
        else:
32
            enabled = 1
33
        out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled))
34
    out('',
35
        '#endif /* TRACE__GENERATED_TRACERS_H */')
28
    out('#endif /* TRACE__GENERATED_TRACERS_H */')
36 29

  
37 30
def nop(events):
38 31
    for e in events:
b/trace/Makefile.objs
1 1
# -*- mode: makefile -*-
2 2

  
3 3
######################################################################
4
# Auto-generated header for tracing routines
4
# Auto-generated event descriptions
5

  
6
$(obj)/generated-events.h: $(obj)/generated-events.h-timestamp
7
$(obj)/generated-events.h-timestamp: $(SRC_PATH)/trace-events
8
	$(call quiet-command,$(TRACETOOL) \
9
		--format=events-h \
10
		--backend=events \
11
		< $< > $@,"  GEN   $(patsubst %-timestamp,%,$@)")
12
	@cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp,%,$@)
13

  
14
$(obj)/generated-events.c: $(obj)/generated-events.c-timestamp
15
$(obj)/generated-events.c-timestamp: $(SRC_PATH)/trace-events
16
	$(call quiet-command,$(TRACETOOL) \
17
		--format=events-c \
18
		--backend=events \
19
		< $< > $@,"  GEN   $(patsubst %-timestamp,%,$@)")
20
	@cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp,%,$@)
21

  
22
util-obj-y += generated-events.o
23

  
24

  
25
######################################################################
26
# Auto-generated tracing routines
5 27

  
6 28
$(obj)/generated-tracers.h: $(obj)/generated-tracers.h-timestamp
7 29
	@cmp -s $< $@ || cp $< $@
b/trace/event-internal.h
1
/*
2
 * Interface for configuring and controlling the state of tracing events.
3
 *
4
 * Copyright (C) 2012 Lluís Vilanova <vilanova@ac.upc.edu>
5
 *
6
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7
 * See the COPYING file in the top-level directory.
8
 */
9

  
10
#ifndef TRACE__EVENT_INTERNAL_H
11
#define TRACE__EVENT_INTERNAL_H
12

  
13
#include "trace/generated-events.h"
14

  
15

  
16
/**
17
 * TraceEvent:
18
 * @id: Unique event identifier.
19
 * @name: Event name.
20
 * @sstate: Static tracing state.
21
 * @dstate: Dynamic tracing state.
22
 *
23
 * Opaque generic description of a tracing event.
24
 */
25
typedef struct TraceEvent {
26
    TraceEventID id;
27
    const char * name;
28
    const bool sstate;
29
    bool dstate;
30
} TraceEvent;
31

  
32

  
33
#endif  /* TRACE__EVENT_INTERNAL_H */

Also available in: Unified diff