From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br3kB-0001ib-0m for qemu-devel@nongnu.org; Mon, 03 Oct 2016 09:57:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1br3k6-000656-WA for qemu-devel@nongnu.org; Mon, 03 Oct 2016 09:57:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37996) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br3k6-00064t-Mj for qemu-devel@nongnu.org; Mon, 03 Oct 2016 09:57:18 -0400 Date: Mon, 3 Oct 2016 14:57:14 +0100 From: Stefan Hajnoczi Message-ID: <20161003135714.GD10245@stefanha-x1.localdomain> References: <1475068103-356-1-git-send-email-berrange@redhat.com> <1475068103-356-12-git-send-email-berrange@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IDYEmSnFhs3mNXr+" Content-Disposition: inline In-Reply-To: <1475068103-356-12-git-send-email-berrange@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 11/20] trace: emit name <-> ID mapping in simpletrace header List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, =?iso-8859-1?Q?Llu=EDs?= Vilanova --IDYEmSnFhs3mNXr+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 (ev= ent_num, timestamp, pid, arg1, ..., arg6).""" > + idtoname =3D { > + dropped_event_id: "dropped" > + } > while True: > - rec =3D read_record(edict, fobj) > - if rec is None: > + t =3D fobj.read(8) > + if len(t) =3D=3D 0: > break > =20 > - yield rec > + (rectype, ) =3D struct.unpack('=3DQ', t) > + if rectype =3D=3D record_type_mapping: > + mapping =3D get_mapping(fobj) > + idtoname[mapping[0]] =3D mapping[1] Unpacking the tuple makes the code easier to read: event_id, name =3D get_mapping(fobj) idtoname[event_id] =3D name > diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/trace= tool/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 > =20 > 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] =3D event_next_id', > + ' name_len =3D strlen(name)', > + ' printf("%%8b%%8b%%4b%%.*s", 0, ', > + ' event_next_id, name_len, name_len, name)', > + ' event_next_id =3D event_next_id + 1', > + ' }', > + ' return event_name_to_id_map[name]', > + '}', > + 'probe begin', > + '{', > + ' printf("%%8b%%8b%%8b", 0xffffffffffffffff, 0xf2b177cb0aa429= b4, 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. --IDYEmSnFhs3mNXr+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJX8mO6AAoJEJykq7OBq3PI//gIAJZsjYOeOsOXrXfdGaPFDsC4 nUFG/Jemfq8KbNAEnF24IxyHQ8dXEytS89XnKPGMJ9N2lDD8U4twUbXUm8bN2JFd tEKEaQV+qcpkX2NQvF7pm890H1NDbB2WIyBRJ80eEQyixbd4HCaG1jvmO1SehvTy tvrNWczTzw7BzBDE1/lbvcWbWRr/o2lGq2F1R8+GZo4GB5RGFMC1TSgM+PfVUPe1 PhaUoohJOrbsFq2t/n4++2HR893ht+xyAVCiA19a+ODytZpe9sJ6jQ745zrqyL3w pbFyQNXYPODhdISci2qyLVssC09HjLszz0dLbszctVpjvieautWLssTiNyPkDG8= =tnma -----END PGP SIGNATURE----- --IDYEmSnFhs3mNXr+--