diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/tracetool/format/simpletrace_stap.py | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/tracetool/format/simpletrace_stap.py index c35e662e00..144b704bcd 100644 --- a/scripts/tracetool/format/simpletrace_stap.py +++ b/scripts/tracetool/format/simpletrace_stap.py @@ -18,29 +18,37 @@ from tracetool.backend.dtrace import binary, probeprefix from tracetool.backend.simple import is_string from tracetool.format.stap import stap_escape +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 event_name_to_id_map', - 'global event_next_id', - 'function simple_trace_map_event(name)', + 'global %(id_map)s', + 'global %(next_id)s', + 'function %(map_func)s(name)', '', '{', - ' if (!([name] in event_name_to_id_map)) {', - ' event_name_to_id_map[name] = event_next_id', + ' if (!([name] in %(id_map)s)) {', + ' %(id_map)s[name] = %(next_id)s', ' name_len = strlen(name)', ' printf("%%8b%%8b%%4b%%.*s", 0, ', - ' event_next_id, name_len, name_len, name)', - ' event_next_id = event_next_id + 1', + ' %(next_id)s, name_len, name_len, name)', + ' %(next_id)s = %(next_id)s + 1', ' }', - ' return event_name_to_id_map[name]', + ' 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: @@ -48,8 +56,9 @@ def generate(events, backend, group): out('probe %(probeprefix)s.simpletrace.%(name)s = %(probeprefix)s.%(name)s ?', '{', - ' id = simple_trace_map_event("%(name)s")', + ' id = %(map_func)s("%(name)s")', probeprefix=probeprefix(), + map_func=map_func, name=e.name) # Calculate record size |