Skip to content

Commit

Permalink
simpletrace: Convert name from mapping record to str
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ehabkost authored and stefanhaRH committed Jun 29, 2018
1 parent 609ef9f commit 749c1d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/simpletrace.py
Expand Up @@ -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)

Expand Down

0 comments on commit 749c1d8

Please sign in to comment.