trace: do not attempt to read across the pivot page

This is an optimization. We first check if the entry is valid using
the 'tp' field and only if it is we try to read the rest.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
trace: encode and decode strings

Python3 became more restrictive with regards to string handling than
python2. In python3 strings no longer conform to byte array interface,
they have to be encoded explicitly. The current code throws exception
when run in python3.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: remove dead import

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: use "int" type instead of "long"

There is no difference between them in python2 and python3 no
longer has "long".

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: use print with parentheses

Needed by python3.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: create a wrapper for getting dict values

Python3 dicts do not have itervalues() or viewvalues(), they have values().

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: apply 2to3 fixes which work with both versions

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: strip \0 from thread_name in portable way

In python3 struct.unpack() returns bytes, not str, which
does not have rstrip().

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
gdb: concatenate trace_log in a generic way

The GDB which uses python3 returns memoryview object from
read_memory().  This class does not support + operator. I added a
concatenation wrapper which works with all indexable types.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>