-----BEGIN PGP SIGNATURE-----

iQEcBAABAgAGBQJZkvbGAAoJEJykq7OBq3PI7boH/R80wRA3VDhOafoTTzCvPt72
 9I58RQDyLQPwVTbkh1M21i1sAhhm1W1CmgMkCgMYIbNY9dmMZtlYhPoJDvG5KD3d
 PtJCzt21TKerI7CdEabIlK2+EYu/a9uDa/HBkPmz/r4nwSpo3vB4dxv3oWS60yf3
 zdZhQ1r5ecXL3AkS9XE0OuWCCZvOsSJyHUzNdMI6mYZUS7wTV2mFBUYeeliViOyG
 pzg5bO7PdMl0vPoy9tGKzVQDpOyHAWiiQumAehUn9+oIV1UkuQUWhWTcD1T6oma+
 S57qjpK8jLWWCgaYVXnGlsA4HFn4CwKT/UxjukZU1tq7L2D0YR+hm20wiP63KXo=
 =fD2o
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging

# gpg: Signature made Tue 15 Aug 2017 14:27:34 BST
# gpg:                using RSA key 0x9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/tracing-pull-request:
  simpletrace: fix flight recorder --no-header option
  trace: use static event ID mapping in simpletrace.stp

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2017-08-15 14:29:03 +01:00
commit 81a6a2d48a
2 changed files with 20 additions and 35 deletions

View File

@ -97,11 +97,17 @@ def read_trace_header(fobj):
raise ValueError('Log format %d not supported with this QEMU release!'
% log_version)
def read_trace_records(edict, fobj):
"""Deserialize trace records from a file, yielding record tuples (event_num, timestamp, pid, arg1, ..., arg6)."""
idtoname = {
dropped_event_id: "dropped"
}
def read_trace_records(edict, idtoname, fobj):
"""Deserialize trace records from a file, yielding record tuples (event_num, timestamp, pid, arg1, ..., arg6).
Note that `idtoname` is modified if the file contains mapping records.
Args:
edict (str -> Event): events dict, indexed by name
idtoname (int -> str): event names dict, indexed by event ID
fobj (file): input file
"""
while True:
t = fobj.read(8)
if len(t) == 0:
@ -171,10 +177,16 @@ def process(events, log, analyzer, read_header=True):
dropped_event = Event.build("Dropped_Event(uint64_t num_events_dropped)")
edict = {"dropped": dropped_event}
idtoname = {dropped_event_id: "dropped"}
for event in events:
edict[event.name] = event
# If there is no header assume event ID mapping matches events list
if not read_header:
for event_id, event in enumerate(events):
idtoname[event_id] = event.name
def build_fn(analyzer, event):
if isinstance(event, str):
return analyzer.catchall
@ -197,7 +209,7 @@ def process(events, log, analyzer, read_header=True):
analyzer.begin()
fn_cache = {}
for rec in read_trace_records(edict, log):
for rec in read_trace_records(edict, idtoname, log):
event_num = rec[0]
event = edict[event_num]
if event_num not in fn_cache:

View File

@ -22,33 +22,8 @@ def global_var_name(name):
return probeprefix().replace(".", "_") + "_" + name
def generate(events, backend, group):
id_map = global_var_name("event_name_to_id_map")
next_id = global_var_name("event_next_id")
map_func = global_var_name("simple_trace_map_event")
out('/* This file is autogenerated by tracetool, do not edit. */',
'',
'global %(id_map)s',
'global %(next_id)s',
'function %(map_func)s(name)',
'',
'{',
' if (!([name] in %(id_map)s)) {',
' %(id_map)s[name] = %(next_id)s',
' name_len = strlen(name)',
' printf("%%8b%%8b%%4b%%.*s", 0, ',
' %(next_id)s, name_len, name_len, name)',
' %(next_id)s = %(next_id)s + 1',
' }',
' return %(id_map)s[name]',
'}',
'probe begin',
'{',
' printf("%%8b%%8b%%8b", 0xffffffffffffffff, 0xf2b177cb0aa429b4, 4)',
'}',
'',
id_map=id_map,
next_id=next_id,
map_func=map_func)
'')
for event_id, e in enumerate(events):
if 'disable' in e.properties:
@ -56,9 +31,7 @@ def generate(events, backend, group):
out('probe %(probeprefix)s.simpletrace.%(name)s = %(probeprefix)s.%(name)s ?',
'{',
' id = %(map_func)s("%(name)s")',
probeprefix=probeprefix(),
map_func=map_func,
name=e.name)
# Calculate record size
@ -77,7 +50,7 @@ def generate(events, backend, group):
sizestr = ' + '.join(sizes)
# Generate format string and value pairs for record header and arguments
fields = [('8b', 'id'),
fields = [('8b', str(event_id)),
('8b', 'gettimeofday_ns()'),
('4b', sizestr),
('4b', 'pid()')]