From: Nicholas Piggin <npiggin@gmail.com>
To: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
Cc: "Nicholas Piggin" <npiggin@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"John Snow" <jsnow@redhat.com>, "Cleber Rosa" <crosa@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
"Beraldo Leal" <bleal@redhat.com>,
qemu-devel@nongnu.org
Subject: [PATCH 1/4] scripts/replay_dump.sh: Update to current rr record format
Date: Tue, 15 Aug 2023 02:31:32 +1000 [thread overview]
Message-ID: <20230814163135.187882-2-npiggin@gmail.com> (raw)
In-Reply-To: <20230814163135.187882-1-npiggin@gmail.com>
This thing seems to have fallen by the wayside. This gets it working with
the current format, although does not quite implement all events.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
My python skills are not good. Any help on this or patch 2 is
appreciated.
Thanks,
Nick
scripts/replay-dump.py | 107 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 101 insertions(+), 6 deletions(-)
diff --git a/scripts/replay-dump.py b/scripts/replay-dump.py
index 3ba97a6d30..937ae19ff1 100755
--- a/scripts/replay-dump.py
+++ b/scripts/replay-dump.py
@@ -20,6 +20,7 @@
import argparse
import struct
+import os
from collections import namedtuple
# This mirrors some of the global replay state which some of the
@@ -62,6 +63,10 @@ def read_byte(fin):
"Read a single byte"
return struct.unpack('>B', fin.read(1))[0]
+def read_bytes(fin, nr):
+ "Read a nr bytes"
+ return fin.read(nr)
+
def read_event(fin):
"Read a single byte event, but save some state"
if replay_state.already_read:
@@ -122,12 +127,18 @@ def swallow_async_qword(eid, name, dumpfile):
print(" %s(%d) @ %d" % (name, eid, step_id))
return True
+def swallow_bytes(eid, name, dumpfile, nr):
+ "Swallow nr bytes of data without looking at it"
+ dumpfile.seek(nr, os.SEEK_CUR)
+ return True
+
async_decode_table = [ Decoder(0, "REPLAY_ASYNC_EVENT_BH", swallow_async_qword),
- Decoder(1, "REPLAY_ASYNC_INPUT", decode_unimp),
- Decoder(2, "REPLAY_ASYNC_INPUT_SYNC", decode_unimp),
- Decoder(3, "REPLAY_ASYNC_CHAR_READ", decode_unimp),
- Decoder(4, "REPLAY_ASYNC_EVENT_BLOCK", decode_unimp),
- Decoder(5, "REPLAY_ASYNC_EVENT_NET", decode_unimp),
+ Decoder(1, "REPLAY_ASYNC_BH_ONESHOT", decode_unimp),
+ Decoder(2, "REPLAY_ASYNC_INPUT", decode_unimp),
+ Decoder(3, "REPLAY_ASYNC_INPUT_SYNC", decode_unimp),
+ Decoder(4, "REPLAY_ASYNC_CHAR_READ", decode_unimp),
+ Decoder(5, "REPLAY_ASYNC_EVENT_BLOCK", decode_unimp),
+ Decoder(6, "REPLAY_ASYNC_EVENT_NET", decode_unimp),
]
# See replay_read_events/replay_read_event
def decode_async(eid, name, dumpfile):
@@ -156,6 +167,13 @@ def decode_audio_out(eid, name, dumpfile):
print_event(eid, name, "%d" % (audio_data))
return True
+def decode_random(eid, name, dumpfile):
+ ret = read_dword(dumpfile)
+ size = read_dword(dumpfile)
+ swallow_bytes(eid, name, dumpfile, size)
+ print_event(eid, name, "%d %d" % (ret, size))
+ return True
+
def decode_checkpoint(eid, name, dumpfile):
"""Decode a checkpoint.
@@ -184,6 +202,38 @@ def decode_interrupt(eid, name, dumpfile):
print_event(eid, name)
return True
+def decode_exception(eid, name, dumpfile):
+ print_event(eid, name)
+ return True
+
+def decode_shutdown(eid, name, dumpfile):
+ print_event(eid, name)
+ return True
+
+def decode_end(eid, name, dumpfile):
+ print_event(eid, name)
+ return False
+
+def decode_char_write(eid, name, dumpfile):
+ res = read_dword(dumpfile)
+ offset = read_dword(dumpfile)
+ print_event(eid, name)
+ return True
+
+def decode_async_char_read(eid, name, dumpfile):
+ char_id = read_byte(dumpfile)
+ size = read_dword(dumpfile)
+ print_event(eid, name, "device:%x chars:%s" % (char_id, read_bytes(dumpfile, size)))
+ return True
+
+def decode_async_net(eid, name, dumpfile):
+ net_id = read_byte(dumpfile)
+ flags = read_dword(dumpfile)
+ size = read_dword(dumpfile)
+ swallow_bytes(eid, name, dumpfile, size)
+ print_event(eid, name, "net:%x flags:%x bytes:%d" % (net_id, flags, size))
+ return True
+
def decode_clock(eid, name, dumpfile):
clock_data = read_qword(dumpfile)
print_event(eid, name, "0x%x" % (clock_data))
@@ -268,6 +318,48 @@ def decode_clock(eid, name, dumpfile):
Decoder(28, "EVENT_CP_RESET", decode_checkpoint),
]
+v12_event_table = [Decoder(0, "EVENT_INSTRUCTION", decode_instruction),
+ Decoder(1, "EVENT_INTERRUPT", decode_interrupt),
+ Decoder(2, "EVENT_EXCEPTION", decode_exception),
+ Decoder(3, "EVENT_ASYNC_BH", swallow_async_qword),
+ Decoder(4, "EVENT_ASYNC_BH_ONESHOT", swallow_async_qword),
+ Decoder(5, "EVENT_ASYNC_INPUT", decode_unimp),
+ Decoder(6, "EVENT_ASYNC_INPUT_SYNC", decode_unimp),
+ Decoder(7, "EVENT_ASYNC_CHAR_READ", decode_async_char_read),
+ Decoder(8, "EVENT_ASYNC_BLOCK", swallow_async_qword),
+ Decoder(9, "EVENT_ASYNC_NET", decode_async_net),
+ Decoder(10, "EVENT_SHUTDOWN", decode_unimp),
+ Decoder(11, "EVENT_SHUTDOWN_HOST_ERR", decode_shutdown),
+ Decoder(12, "EVENT_SHUTDOWN_HOST_QMP_QUIT", decode_shutdown),
+ Decoder(13, "EVENT_SHUTDOWN_HOST_QMP_RESET", decode_shutdown),
+ Decoder(14, "EVENT_SHUTDOWN_HOST_SIGNAL", decode_shutdown),
+ Decoder(15, "EVENT_SHUTDOWN_HOST_UI", decode_shutdown),
+ Decoder(16, "EVENT_SHUTDOWN_GUEST_SHUTDOWN", decode_shutdown),
+ Decoder(17, "EVENT_SHUTDOWN_GUEST_RESET", decode_shutdown),
+ Decoder(18, "EVENT_SHUTDOWN_GUEST_PANIC", decode_shutdown),
+ Decoder(19, "EVENT_SHUTDOWN_SUBSYS_RESET", decode_shutdown),
+ Decoder(20, "EVENT_SHUTDOWN_SNAPSHOT_LOAD", decode_shutdown),
+ Decoder(21, "EVENT_SHUTDOWN___MAX", decode_shutdown),
+ Decoder(22, "EVENT_CHAR_WRITE", decode_char_write),
+ Decoder(23, "EVENT_CHAR_READ_ALL", decode_unimp),
+ Decoder(24, "EVENT_CHAR_READ_ALL_ERROR", decode_unimp),
+ Decoder(25, "EVENT_AUDIO_OUT", decode_audio_out),
+ Decoder(26, "EVENT_AUDIO_IN", decode_unimp),
+ Decoder(27, "EVENT_RANDOM", decode_random),
+ Decoder(28, "EVENT_CLOCK_HOST", decode_clock),
+ Decoder(29, "EVENT_CLOCK_VIRTUAL_RT", decode_clock),
+ Decoder(30, "EVENT_CP_CLOCK_WARP_START", decode_checkpoint),
+ Decoder(31, "EVENT_CP_CLOCK_WARP_ACCOUNT", decode_checkpoint),
+ Decoder(32, "EVENT_CP_RESET_REQUESTED", decode_checkpoint),
+ Decoder(33, "EVENT_CP_SUSPEND_REQUESTED", decode_checkpoint),
+ Decoder(34, "EVENT_CP_CLOCK_VIRTUAL", decode_checkpoint),
+ Decoder(35, "EVENT_CP_CLOCK_HOST", decode_checkpoint),
+ Decoder(36, "EVENT_CP_CLOCK_VIRTUAL_RT", decode_checkpoint),
+ Decoder(37, "EVENT_CP_INIT", decode_checkpoint_init),
+ Decoder(38, "EVENT_CP_RESET", decode_checkpoint),
+ Decoder(39, "EVENT_END", decode_end),
+]
+
def parse_arguments():
"Grab arguments for script"
parser = argparse.ArgumentParser()
@@ -285,7 +377,10 @@ def decode_file(filename):
print("HEADER: version 0x%x" % (version))
- if version == 0xe02007:
+ if version == 0xe0200c:
+ event_decode_table = v12_event_table
+ replay_state.checkpoint_start = 12
+ elif version == 0xe02007:
event_decode_table = v7_event_table
replay_state.checkpoint_start = 12
elif version == 0xe02006:
--
2.40.1
next prev parent reply other threads:[~2023-08-14 16:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-14 16:31 [PATCH for-8.2 0/4] Assorted replay patches Nicholas Piggin
2023-08-14 16:31 ` Nicholas Piggin [this message]
2023-08-18 4:19 ` [PATCH 1/4] scripts/replay_dump.sh: Update to current rr record format Pavel Dovgalyuk
2023-08-14 16:31 ` [PATCH 2/4] tests/avocado: replay_linux.py add replay-dump.py test Nicholas Piggin
2023-08-18 4:23 ` Pavel Dovgalyuk
2023-08-14 16:31 ` [PATCH 3/4] replay: allow runstate shutdown->running when replaying trace Nicholas Piggin
2023-08-18 4:25 ` Pavel Dovgalyuk
2023-08-14 16:31 ` [PATCH 4/4] replay: simple auto-snapshot mode for record Nicholas Piggin
2023-08-18 4:36 ` Pavel Dovgalyuk
2024-02-26 7:36 ` Nicholas Piggin
2024-02-28 5:07 ` Pavel Dovgalyuk
2024-02-29 6:32 ` Nicholas Piggin
2024-03-04 16:33 ` Nicholas Piggin
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=20230814163135.187882-2-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=bleal@redhat.com \
--cc=crosa@redhat.com \
--cc=jsnow@redhat.com \
--cc=pavel.dovgaluk@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=wainersm@redhat.com \
/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.