From nobody Tue Nov 26 22:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704726900; cv=none; d=zohomail.com; s=zohoarc; b=dwx5VEllQEnLKxyU6eH8p9TLdlAqBYCFHpRRYad61DTtPq6Z7RBFnyP6m3fGaeyAsk+DT7uQoMXt1eK78Tqr0lP6zNolO6n7ha1YvzhP4COktLtms1+ZUpzMlQ3Lx6IEScW+vBO2ff/rLmTQD+HF9fnvF6lwwJif3DCpNSFZuJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704726900; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ytoJGUOfVhpGlmTk7EPY0JIdgCeWa/v+zzjLeogcti8=; b=loTDYx+mDvDj9uUgXaVoroL1hIXPe5CweAwq96aWff+1FoutxUYe15O16pdGiS2l9oQC7OsvrsuNWsoBInFAe0njaweZjQApY5SoqICHXP8KHfR4bnoq2QSDdDVS27T/7Zc+2GzWFhmnWj7GofSsQwny3+msjZYE+V1MqsTpBwE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704726900751251.40606590003608; Mon, 8 Jan 2024 07:15:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMrKH-0004Ei-Lk; Mon, 08 Jan 2024 10:14:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rMrKF-0004Do-Nu for qemu-devel@nongnu.org; Mon, 08 Jan 2024 10:14:03 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rMrKA-0001YM-5M for qemu-devel@nongnu.org; Mon, 08 Jan 2024 10:14:03 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-336788cb261so1852102f8f.3 for ; Mon, 08 Jan 2024 07:13:57 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l3-20020adff483000000b0033719111458sm8056448wro.36.2024.01.08.07.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 07:13:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3C7F25F944; Mon, 8 Jan 2024 15:13:53 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704726836; x=1705331636; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ytoJGUOfVhpGlmTk7EPY0JIdgCeWa/v+zzjLeogcti8=; b=DpUrXjZV95ey8DPQn+7cGZO+fQof3YY2Ni12pA92IRMpzVJ7YGOcHnDk7BKV2LYttK S6SdbYMF+oTgF2XB+OR2fHpY04vyz6Z9HK520G4hiLy3NKebl3O54DGr1QmJGzvo8LB3 e/JO2xDMLqJlDd6q+2hif7vpu8qYFP2MBw+GNn7wFi0e3kY8AAO6/K5Klzd8yhLarWpJ ywHTwIgbmMMzq4y/T62PRVbQ09zjYkJsD9eEMKiwZ+FuvYRHxayfOkQ/XPRkgQY/Izlb jSOQQomHe6Ig2+C59Fq9d5Rm2S9ntAV3WtdGGMbEFKOg5P9fkYOJk/cgqKp1WbJlm0e/ M8fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704726836; x=1705331636; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ytoJGUOfVhpGlmTk7EPY0JIdgCeWa/v+zzjLeogcti8=; b=jOB5jNRYlwe/Eb8EUvtguNt+KwYDahkeIvRl6YxhzRpSX+RyHSaDr1FLYo6FKBvlqM sSBLcTroZ/ZsSkQpht/caZWsxvwlq8QNSwaw3q8I9Hdv+YxqWcJ4TpqpSpy3AMzj6xKd D+mBBgZ4OfkB1WOaBErW//mv7DjbfPEX3v0GElwhFGmssOEqObrp8EbIr9uVgsq64XP2 Wb9uIUPT6w3/D374o2dnD26N71bsut4QnZjzHeuagmDkCTdxMs0InJdvaOpwMxuZaBoQ 1ACE4GabV+OZh1V93XRiS03Z2ozfma7Dy/BhQGJZWG+99WnTL492CZHh6Eot6Uduwubh CIPg== X-Gm-Message-State: AOJu0YyO9PlSBMHO0vwrbhO0TZmmtxxDp0MFeu3GHJvN8zw43fZPw32p KUsK5iznHL/jn1Swo2jjqp3HX07ShQyvlcuZVF2Rrv/zEv8= X-Google-Smtp-Source: AGHT+IENL7Sysu+xb8vai5o+U0jJsJnlYMT6PkjU4Wlsmi1yePO4/baA18SIm4JqAoNmL4/a0yjdiw== X-Received: by 2002:a5d:4343:0:b0:337:5b64:7414 with SMTP id u3-20020a5d4343000000b003375b647414mr1763861wrr.100.1704726836540; Mon, 08 Jan 2024 07:13:56 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , John Snow , Cleber Rosa Subject: [PULL 04/13] scripts/replay-dump: update to latest format Date: Mon, 8 Jan 2024 15:13:43 +0000 Message-Id: <20240108151352.2199097-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240108151352.2199097-1-alex.bennee@linaro.org> References: <20240108151352.2199097-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704726901806100001 To help debugging replay logs I've implemented decode_plain and decode_char_write as well as put in a new table for the current format of log. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Message-Id: <20231211091346.14616-5-alex.bennee@linaro.org> diff --git a/scripts/replay-dump.py b/scripts/replay-dump.py index b89dc29555a..6f300e4c54e 100755 --- a/scripts/replay-dump.py +++ b/scripts/replay-dump.py @@ -21,6 +21,7 @@ import argparse import struct from collections import namedtuple +from os import path =20 # This mirrors some of the global replay state which some of the # stream loading refers to. Some decoders may read the next event so @@ -82,6 +83,12 @@ def read_qword(fin): "Read a 64 bit word" return struct.unpack('>Q', fin.read(8))[0] =20 +def read_array(fin): + "Read a sized array" + size =3D read_dword(fin) + data =3D fin.read(size) + return data + # Generic decoder structure Decoder =3D namedtuple("Decoder", "eid name fn") =20 @@ -115,6 +122,11 @@ def decode_unimp(eid, name, _unused_dumpfile): print("%s not handled - will now stop" % (name)) return False =20 +def decode_plain(eid, name, _unused_dumpfile): + "Plain events without additional data" + print_event(eid, name, "no data") + return True + # Checkpoint decoder def swallow_async_qword(eid, name, dumpfile): "Swallow a qword of data without looking at it" @@ -151,6 +163,12 @@ def decode_instruction(eid, name, dumpfile): print_event(eid, name, "0x%x" % (ins_diff)) return True =20 +def decode_char_write(eid, name, dumpfile): + res =3D read_dword(dumpfile) + offset =3D read_dword(dumpfile) + print_event(eid, name, "%d -> %d" % (offset, res)) + return True + def decode_audio_out(eid, name, dumpfile): audio_data =3D read_dword(dumpfile) print_event(eid, name, "%d" % (audio_data)) @@ -189,14 +207,19 @@ def decode_clock(eid, name, dumpfile): print_event(eid, name, "0x%x" % (clock_data)) return True =20 +def decode_random(eid, name, dumpfile): + ret =3D read_dword(dumpfile) + data =3D read_array(dumpfile) + print_event(eid, "%d bytes of random data" % len(data)) + return True =20 # pre-MTTCG merge v5_event_table =3D [Decoder(0, "EVENT_INSTRUCTION", decode_instruction), Decoder(1, "EVENT_INTERRUPT", decode_interrupt), - Decoder(2, "EVENT_EXCEPTION", decode_unimp), + Decoder(2, "EVENT_EXCEPTION", decode_plain), Decoder(3, "EVENT_ASYNC", decode_async), Decoder(4, "EVENT_SHUTDOWN", decode_unimp), - Decoder(5, "EVENT_CHAR_WRITE", decode_unimp), + Decoder(5, "EVENT_CHAR_WRITE", decode_char_write), Decoder(6, "EVENT_CHAR_READ_ALL", decode_unimp), Decoder(7, "EVENT_CHAR_READ_ALL_ERROR", decode_unimp), Decoder(8, "EVENT_CLOCK_HOST", decode_clock), @@ -215,10 +238,10 @@ def decode_clock(eid, name, dumpfile): # post-MTTCG merge, AUDIO support added v6_event_table =3D [Decoder(0, "EVENT_INSTRUCTION", decode_instruction), Decoder(1, "EVENT_INTERRUPT", decode_interrupt), - Decoder(2, "EVENT_EXCEPTION", decode_unimp), + Decoder(2, "EVENT_EXCEPTION", decode_plain), Decoder(3, "EVENT_ASYNC", decode_async), Decoder(4, "EVENT_SHUTDOWN", decode_unimp), - Decoder(5, "EVENT_CHAR_WRITE", decode_unimp), + Decoder(5, "EVENT_CHAR_WRITE", decode_char_write), Decoder(6, "EVENT_CHAR_READ_ALL", decode_unimp), Decoder(7, "EVENT_CHAR_READ_ALL_ERROR", decode_unimp), Decoder(8, "EVENT_AUDIO_OUT", decode_audio_out), @@ -250,7 +273,7 @@ def decode_clock(eid, name, dumpfile): Decoder(10, "EVENT_SHUTDOWN_GUEST_RESET", decode_unimp), Decoder(11, "EVENT_SHUTDOWN_GUEST_PANIC", decode_unimp), Decoder(12, "EVENT_SHUTDOWN___MAX", decode_unimp), - Decoder(13, "EVENT_CHAR_WRITE", decode_unimp), + Decoder(13, "EVENT_CHAR_WRITE", decode_char_write), Decoder(14, "EVENT_CHAR_READ_ALL", decode_unimp), Decoder(15, "EVENT_CHAR_READ_ALL_ERROR", decode_unimp), Decoder(16, "EVENT_AUDIO_OUT", decode_audio_out), @@ -268,6 +291,48 @@ def decode_clock(eid, name, dumpfile): Decoder(28, "EVENT_CP_RESET", decode_checkpoint), ] =20 +v12_event_table =3D [Decoder(0, "EVENT_INSTRUCTION", decode_instruction), + Decoder(1, "EVENT_INTERRUPT", decode_interrupt), + Decoder(2, "EVENT_EXCEPTION", decode_plain), + Decoder(3, "EVENT_ASYNC", decode_async), + Decoder(4, "EVENT_ASYNC", decode_async), + Decoder(5, "EVENT_ASYNC", decode_async), + Decoder(6, "EVENT_ASYNC", decode_async), + Decoder(6, "EVENT_ASYNC", decode_async), + Decoder(8, "EVENT_ASYNC", decode_async), + Decoder(9, "EVENT_ASYNC", decode_async), + Decoder(10, "EVENT_ASYNC", decode_async), + Decoder(11, "EVENT_SHUTDOWN", decode_unimp), + Decoder(12, "EVENT_SHUTDOWN_HOST_ERR", decode_unimp), + Decoder(13, "EVENT_SHUTDOWN_HOST_QMP_QUIT", decode_unimp= ), + Decoder(14, "EVENT_SHUTDOWN_HOST_QMP_RESET", decode_unim= p), + Decoder(14, "EVENT_SHUTDOWN_HOST_SIGNAL", decode_unimp), + Decoder(15, "EVENT_SHUTDOWN_HOST_UI", decode_unimp), + Decoder(16, "EVENT_SHUTDOWN_GUEST_SHUTDOWN", decode_unim= p), + Decoder(17, "EVENT_SHUTDOWN_GUEST_RESET", decode_unimp), + Decoder(18, "EVENT_SHUTDOWN_GUEST_PANIC", decode_unimp), + Decoder(19, "EVENT_SHUTDOWN_GUEST_SUBSYSTEM_RESET", deco= de_unimp), + Decoder(20, "EVENT_SHUTDOWN_GUEST_SNAPSHOT_LOAD", decode= _unimp), + Decoder(21, "EVENT_SHUTDOWN___MAX", decode_unimp), + 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_IN", decode_unimp), + Decoder(26, "EVENT_AUDIO_OUT", decode_audio_out), + 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_checkpoi= nt), + Decoder(31, "EVENT_CP_CLOCK_WARP_ACCOUNT", decode_checkp= oint), + Decoder(32, "EVENT_CP_RESET_REQUESTED", decode_checkpoin= t), + Decoder(33, "EVENT_CP_SUSPEND_REQUESTED", decode_checkpo= int), + Decoder(34, "EVENT_CP_CLOCK_VIRTUAL", decode_checkpoint), + Decoder(35, "EVENT_CP_CLOCK_HOST", decode_checkpoint), + Decoder(36, "EVENT_CP_CLOCK_VIRTUAL_RT", decode_checkpoi= nt), + Decoder(37, "EVENT_CP_INIT", decode_checkpoint_init), + Decoder(38, "EVENT_CP_RESET", decode_checkpoint), +] + def parse_arguments(): "Grab arguments for script" parser =3D argparse.ArgumentParser() @@ -278,14 +343,18 @@ def parse_arguments(): def decode_file(filename): "Decode a record/replay dump" dumpfile =3D open(filename, "rb") - + dumpsize =3D path.getsize(filename) # read and throwaway the header version =3D read_dword(dumpfile) junk =3D read_qword(dumpfile) =20 + # see REPLAY_VERSION print("HEADER: version 0x%x" % (version)) =20 - if version =3D=3D 0xe02007: + if version =3D=3D 0xe0200c: + event_decode_table =3D v12_event_table + replay_state.checkpoint_start =3D 30 + elif version =3D=3D 0xe02007: event_decode_table =3D v7_event_table replay_state.checkpoint_start =3D 12 elif version =3D=3D 0xe02006: @@ -299,8 +368,13 @@ def decode_file(filename): decode_ok =3D True while decode_ok: event =3D read_event(dumpfile) - decode_ok =3D call_decode(event_decode_table, event, dumpfile) + decode_ok =3D call_decode(event_decode_table, event, + dumpfile) + except Exception as inst: + print(f"error {inst}") + finally: + print(f"Reached {dumpfile.tell()} of {dumpsize} bytes") dumpfile.close() =20 if __name__ =3D=3D "__main__": --=20 2.39.2