Skip to content

Commit

Permalink
trace: use static event ID mapping in simpletrace.stp
Browse files Browse the repository at this point in the history
This is a partial revert of commit
7f1b588 ("trace: emit name <-> ID
mapping in simpletrace header"), which broke the SystemTap flight
recorder because event mapping records may not be present in the ring
buffer when the trace is analyzed.  This means simpletrace.py
--no-header does not know the event ID mapping needed to pretty-print
the trace.

Instead of numbering events dynamically, use a static event ID mapping
as dictated by the event order in the trace-events-all file.

The simpletrace.py script also uses trace-events-all so the next patch
will fix the simpletrace.py --no-header option to take advantage of this
knowledge.

Cc: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 20170815084430.7128-2-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
stefanhaRH committed Aug 15, 2017
1 parent 5681da2 commit d6b76d6
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions scripts/tracetool/format/simpletrace_stap.py
Expand Up @@ -22,43 +22,16 @@ 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:
continue

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
Expand All @@ -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()')]
Expand Down

0 comments on commit d6b76d6

Please sign in to comment.