qemu with hax to log dma reads & writes
jcs.org/2018/11/12/vfio
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4"""
5Stderr built-in backend.
6"""
7
8__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
9__copyright__ = "Copyright 2012-2017, 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
16from tracetool import out
17
18
19PUBLIC = True
20
21
22def generate_h_begin(events, group):
23 out('#include "qemu/log-for-trace.h"',
24 '')
25
26
27def generate_h(event, group):
28 argnames = ", ".join(event.args.names())
29 if len(event.args) > 0:
30 argnames = ", " + argnames
31
32 if "vcpu" in event.properties:
33 # already checked on the generic format code
34 cond = "true"
35 else:
36 cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
37
38 out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {',
39 ' struct timeval _now;',
40 ' gettimeofday(&_now, NULL);',
41 ' qemu_log("%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",',
42 ' getpid(),',
43 ' (size_t)_now.tv_sec, (size_t)_now.tv_usec',
44 ' %(argnames)s);',
45 ' }',
46 cond=cond,
47 name=event.name,
48 fmt=event.fmt.rstrip("\n"),
49 argnames=argnames)
50
51
52def generate_h_backend_dstate(event, group):
53 out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
54 event_id="TRACE_" + event.name.upper())