]> git.proxmox.com Git - mirror_qemu.git/commitdiff
simpletrace: Convert name from mapping record to str
authorEduardo Habkost <ehabkost@redhat.com>
Tue, 19 Jun 2018 19:45:49 +0000 (16:45 -0300)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 29 Jun 2018 14:04:18 +0000 (15:04 +0100)
The rest of the code assumes that idtoname is a (int -> str)
dictionary, so convert the data accordingly.

This is necessary to make the script work with Python 3 (where
reads from a binary file return 'bytes' objects, not 'str').

Fixes the following error:

  $ python3 ./scripts/simpletrace.py trace-events-all trace-27445
  b'object_class_dynamic_cast_assert' event is logged but is not \
  declared in the trace events file, try using trace-events-all instead.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-id: 20180619194549.15584-1-ehabkost@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
scripts/simpletrace.py

index d4a50a1e2b989978732538c88ac355530e7d065e..4ad34f90cd55a78b2a9c802161b390fdcd31ad95 100755 (executable)
@@ -70,7 +70,7 @@ def get_record(edict, idtoname, rechdr, fobj):
 def get_mapping(fobj):
     (event_id, ) = struct.unpack('=Q', fobj.read(8))
     (len, ) = struct.unpack('=L', fobj.read(4))
-    name = fobj.read(len)
+    name = fobj.read(len).decode()
 
     return (event_id, name)