On Wed, Sep 28, 2016 at 02:08:14PM +0100, Daniel P. Berrange wrote: > 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" > + } > while True: > - rec = read_record(edict, fobj) > - if rec is None: > + t = fobj.read(8) > + if len(t) == 0: > break > > - yield rec > + (rectype, ) = struct.unpack('=Q', t) > + if rectype == record_type_mapping: > + mapping = get_mapping(fobj) > + idtoname[mapping[0]] = mapping[1]
Unpacking the tuple makes the code easier to read: event_id, name = get_mapping(fobj) idtoname[event_id] = name > diff --git a/scripts/tracetool/format/simpletrace_stap.py > b/scripts/tracetool/format/simpletrace_stap.py > index 7e44bc1..ac3580f 100644 > --- a/scripts/tracetool/format/simpletrace_stap.py > +++ b/scripts/tracetool/format/simpletrace_stap.py > @@ -21,6 +21,25 @@ from tracetool.format.stap import stap_escape > > def generate(events, backend): > 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)', > + '', > + '{', > + ' if (!([name] in event_name_to_id_map)) {', > + ' event_name_to_id_map[name] = event_next_id', > + ' 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', > + ' }', > + ' return event_name_to_id_map[name]', > + '}', > + 'probe begin', > + '{', > + ' printf("%%8b%%8b%%8b", 0xffffffffffffffff, 0xf2b177cb0aa429b4, > 4)', The reason the SystemTap script doesn't emit a header is because it was designed for trace flight-recorder mode. There's probably no harm in emitting the header. Flight-recorder users will still have to use --no-header though.
signature.asc
Description: PGP signature