All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Daniel Berrange <berrange@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH for-2.10 1/2] trace: use static event ID mapping in simpletrace.stp
Date: Mon, 14 Aug 2017 17:21:41 +0100	[thread overview]
Message-ID: <20170814162142.29666-2-stefanha@redhat.com> (raw)
In-Reply-To: <20170814162142.29666-1-stefanha@redhat.com>

Commit 7f1b588f20d027730676e627713ae3bbf6baab04 ("trace: emit name <->
ID mapping in simpletrace header") broke the SystemTap flight recorder
because event mapping records may no longer 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>
---
 scripts/tracetool/format/simpletrace_stap.py | 36 ++++++++++++----------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/tracetool/format/simpletrace_stap.py
index 144b704bcd..6cfdc32867 100644
--- a/scripts/tracetool/format/simpletrace_stap.py
+++ b/scripts/tracetool/format/simpletrace_stap.py
@@ -22,33 +22,18 @@ 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")
+    id_map = global_var_name("id_map")
+
     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)
+        id_map=id_map)
 
     for event_id, e in enumerate(events):
         if 'disable' in e.properties:
@@ -56,11 +41,20 @@ def generate(events, backend, group):
 
         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)
 
+        out('    if (!(["%(name)s"] in %(id_map)s)) {',
+            '        %(id_map)s["%(name)s"] = 1',
+            '        printf("%%8b%%8b%%4b%%.*s", 0, ',
+            '               %(event_id)s, %(name_len)s, %(name_len)s,',
+            '               "%(name)s")',
+            '    }',
+            id_map=id_map,
+            name=e.name,
+            name_len=len(e.name),
+            event_id=event_id)
+
         # Calculate record size
         sizes = ['24'] # sizeof(TraceRecord)
         for type_, name in e.args:
@@ -77,7 +71,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()')]
-- 
2.13.4

  reply	other threads:[~2017-08-14 16:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-14 16:21 [Qemu-devel] [PATCH for-2.10 0/2] trace: fix simpletrace.stp flight recorder mode Stefan Hajnoczi
2017-08-14 16:21 ` Stefan Hajnoczi [this message]
2017-08-14 16:21 ` [Qemu-devel] [PATCH for-2.10 2/2] simpletrace: fix flight recorder --no-header option Stefan Hajnoczi
2017-08-14 16:39 ` [Qemu-devel] [PATCH for-2.10 0/2] trace: fix simpletrace.stp flight recorder mode Daniel P. Berrange
2017-08-15  8:23   ` Stefan Hajnoczi
2017-08-15  8:28   ` Stefan Hajnoczi
2017-08-14 16:45 ` no-reply
2017-08-15  8:24   ` 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=20170814162142.29666-2-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.