qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

ust_events_h.py (3670B)


      1 # -*- coding: utf-8 -*-
      2 
      3 """
      4 trace/generated-ust-provider.h
      5 """
      6 
      7 __author__     = "Mohamad Gebai <mohamad.gebai@polymtl.ca>"
      8 __copyright__  = "Copyright 2012, Mohamad Gebai <mohamad.gebai@polymtl.ca>"
      9 __license__    = "GPL version 2 or (at your option) any later version"
     10 
     11 __maintainer__ = "Stefan Hajnoczi"
     12 __email__      = "stefanha@redhat.com"
     13 
     14 
     15 from tracetool import out
     16 
     17 
     18 def generate(events, backend, group):
     19     events = [e for e in events
     20               if "disabled" not in e.properties]
     21 
     22     if group == "all":
     23         include = "trace-ust-all.h"
     24     else:
     25         include = "trace-ust.h"
     26 
     27     out('/* This file is autogenerated by tracetool, do not edit. */',
     28         '',
     29         '#undef TRACEPOINT_PROVIDER',
     30         '#define TRACEPOINT_PROVIDER qemu',
     31         '',
     32         '#undef TRACEPOINT_INCLUDE',
     33         '#define TRACEPOINT_INCLUDE "./%s"' % include,
     34         '',
     35         '#if !defined (TRACE_%s_GENERATED_UST_H) || \\'  % group.upper(),
     36         '     defined(TRACEPOINT_HEADER_MULTI_READ)',
     37         '#define TRACE_%s_GENERATED_UST_H' % group.upper(),
     38         '',
     39         '#include <lttng/tracepoint.h>',
     40         '',
     41         '/*',
     42         ' * LTTng ust 2.0 does not allow you to use TP_ARGS(void) for tracepoints',
     43         ' * requiring no arguments. We define these macros introduced in more recent'
     44         ' * versions of LTTng ust as a workaround',
     45         ' */',
     46         '#ifndef _TP_EXPROTO1',
     47         '#define _TP_EXPROTO1(a)               void',
     48         '#endif',
     49         '#ifndef _TP_EXDATA_PROTO1',
     50         '#define _TP_EXDATA_PROTO1(a)          void *__tp_data',
     51         '#endif',
     52         '#ifndef _TP_EXDATA_VAR1',
     53         '#define _TP_EXDATA_VAR1(a)            __tp_data',
     54         '#endif',
     55         '#ifndef _TP_EXVAR1',
     56         '#define _TP_EXVAR1(a)',
     57         '#endif',
     58         '')
     59 
     60     for e in events:
     61         if len(e.args) > 0:
     62             out('TRACEPOINT_EVENT(',
     63                 '   qemu,',
     64                 '   %(name)s,',
     65                 '   TP_ARGS(%(args)s),',
     66                 '   TP_FIELDS(',
     67                 name=e.name,
     68                 args=", ".join(", ".join(i) for i in e.args))
     69 
     70             types = e.args.types()
     71             names = e.args.names()
     72             fmts = e.formats()
     73             for t,n,f in zip(types, names, fmts):
     74                 if ('char *' in t) or ('char*' in t):
     75                     out('       ctf_string(' + n + ', ' + n + ')')
     76                 elif ("%p" in f) or ("x" in f) or ("PRIx" in f):
     77                     out('       ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')')
     78                 elif ("ptr" in t) or ("*" in t):
     79                     out('       ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')')
     80                 elif ('int' in t) or ('long' in t) or ('unsigned' in t) \
     81                         or ('size_t' in t) or ('bool' in t):
     82                     out('       ctf_integer(' + t + ', ' + n + ', ' + n + ')')
     83                 elif ('double' in t) or ('float' in t):
     84                     out('       ctf_float(' + t + ', ' + n + ', ' + n + ')')
     85                 elif ('void *' in t) or ('void*' in t):
     86                     out('       ctf_integer_hex(unsigned long, ' + n + ', ' + n + ')')
     87 
     88             out('   )',
     89                 ')',
     90                 '')
     91 
     92         else:
     93             out('TRACEPOINT_EVENT(',
     94                 '   qemu,',
     95                 '   %(name)s,',
     96                 '   TP_ARGS(void),',
     97                 '   TP_FIELDS()',
     98                 ')',
     99                 '',
    100                 name=e.name)
    101 
    102     out('#endif /* TRACE_%s_GENERATED_UST_H */' % group.upper(),
    103         '',
    104         '/* This part must be outside ifdef protection */',
    105         '#include <lttng/tracepoint-event.h>')