qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, "Lluís Vilanova" <vilanova@ac.upc.edu>
Subject: Re: [Qemu-devel] [PATCH v5 11/20] trace: emit name <-> ID mapping in simpletrace header
Date: Mon, 3 Oct 2016 14:57:14 +0100	[thread overview]
Message-ID: <20161003135714.GD10245@stefanha-x1.localdomain> (raw)
In-Reply-To: <1475068103-356-12-git-send-email-berrange@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2235 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2016-10-03 13:57 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28 13:08 [Qemu-devel] [PATCH v5 00/20] Refactor trace to allow modular build Daniel P. Berrange
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 01/20] trace: move colo trace events to net/ sub-directory Daniel P. Berrange
2016-10-03 13:25   ` Stefan Hajnoczi
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 02/20] trace: remove double-underscore in event name Daniel P. Berrange
2016-09-28 13:25   ` Lluís Vilanova
2016-10-03 13:25   ` Stefan Hajnoczi
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 03/20] trace: add trace event iterator APIs Daniel P. Berrange
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 04/20] trace: convert code to use event iterators Daniel P. Berrange
2016-09-30 14:00   ` Lluís Vilanova
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 05/20] trace: remove some now unused functions Daniel P. Berrange
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 06/20] trace: remove global 'uint16 dstate[]' array Daniel P. Berrange
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 07/20] trace: remove duplicate control.h includes in generated-tracers.h Daniel P. Berrange
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 08/20] trace: break circular dependency in event-internal.h Daniel P. Berrange
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 09/20] trace: give each trace event a named TraceEvent struct Daniel P. Berrange
2016-09-30 14:09   ` Lluís Vilanova
2016-10-03 13:27   ` Stefan Hajnoczi
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 10/20] trace: remove the TraceEventID and TraceEventVCPUID enums Daniel P. Berrange
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 11/20] trace: emit name <-> ID mapping in simpletrace header Daniel P. Berrange
2016-10-03 13:57   ` Stefan Hajnoczi [this message]
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 12/20] trace: don't abort qemu if ftrace can't be initialized Daniel P. Berrange
2016-10-03 13:59   ` Stefan Hajnoczi
2016-10-04  9:07     ` Daniel P. Berrange
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 13/20] trace: provide mechanism for registering trace events Daniel P. Berrange
2016-10-03 14:02   ` Stefan Hajnoczi
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 14/20] trace: dynamically allocate trace_dstate in CPUState Daniel P. Berrange
2016-09-30 14:17   ` Lluís Vilanova
2016-10-03 14:04   ` Stefan Hajnoczi
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 15/20] trace: dynamically allocate event IDs at runtime Daniel P. Berrange
2016-10-03 14:21   ` Stefan Hajnoczi
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 16/20] trace: get rid of generated-events.h/generated-events.c Daniel P. Berrange
2016-10-03 14:38   ` Stefan Hajnoczi
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 17/20] trace: rename _read_events to read_events Daniel P. Berrange
2016-10-03 14:39   ` Stefan Hajnoczi
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 18/20] trace: push reading of events up a level to tracetool main Daniel P. Berrange
2016-10-03 14:39   ` Stefan Hajnoczi
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 19/20] trace: pass trace-events to tracetool as a positional param Daniel P. Berrange
2016-10-03 14:41   ` Stefan Hajnoczi
2016-09-28 13:08 ` [Qemu-devel] [PATCH v5 20/20] trace: introduce a formal group name for trace events Daniel P. Berrange
2016-09-30 14:36   ` Lluís Vilanova
2016-10-03 14:43   ` Stefan Hajnoczi
2016-10-03 14:44 ` [Qemu-devel] [PATCH v5 00/20] Refactor trace to allow modular build Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161003135714.GD10245@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vilanova@ac.upc.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).