From patchwork Tue Dec 5 20:41:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 750396 Delivered-To: patch@linaro.org Received: by 2002:adf:9b9d:0:b0:333:3a04:f257 with SMTP id d29csp1897166wrc; Tue, 5 Dec 2023 12:43:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjLsQqjG45II8TVgj5M+fhbqve/fb3hVRWsN6Uc/NMctQ8PzqfMkPT3abklLGPPlhkh0VP X-Received: by 2002:a05:6214:519d:b0:67a:5815:9996 with SMTP id kl29-20020a056214519d00b0067a58159996mr2536329qvb.6.1701808997490; Tue, 05 Dec 2023 12:43:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701808997; cv=none; d=google.com; s=arc-20160816; b=cZbUlRbzVYGn/uqVU+IoEZ1ck9wwE/PhiesLr3L61A6wUp73Ct9RMTJNqML8a/WVv1 v8HDxOE92axiuE1e/fP1naF8j5xM3r+QrgfLzsn0D/oJAmv6E6VnZ+Cc2iba/L84aO85 s9C7ut2UlIpeM3k0VsP3U2hChcUO/eAPANqPCZFD3wyv9AagFdxp5DrUafMjtTXCsXf7 0PlkjDGMRPnA+n6lGYK84uwA3jSDZp3jFqB81w+c7lA4WV6qBEV+ZNsTaTqqTqJxmHEQ ZR6VUYO/4U5hx7cFS32y1iEejR5JEKVZnX68ic2k6MP9i+iPZ0OudYROoTCfHVqFZD0D 5F1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Nlo6CezYV3r03v3L8dVzCnnygHyr+7WQt60cA9zru2s=; fh=WQskExECjOtS2oBrq9x2ue7OeVr6ye1r4N0aDOSz0G8=; b=i6VDH+Pju13Pg9qHnp2pQHOo5fvdPF/RsepEh1v2UGfmIOheDVLX/btluzbLamqV6D 0sVcu/5CCNlSCFE8BcUlLGMy7wGKg09Oamep9wGQXWsajHurTMjtoW5izCcGI1mxi0jG 8rtE/YHGxAb5wfwlb83Llp26ATQ1ilbUqC8HbD0j6DylZYIYRAVsXv88uDMPxWXxWpk2 D2m3mopEnzA1aw5AKOp3fXGCWbx4IbUO2Lj2t5q5KQtlG5T3i50LXQ17NYlYbMYF+nGH JfZHk15JxNi2hoEIiUDKSMpLgs+E2FlUUJtRuhjCoSrGp2eSgrz2sU4yAuzQkTC5yfd7 vSJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rz5ED1JF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y18-20020a0cec12000000b0067a9ef0ac5asi9657397qvo.253.2023.12.05.12.43.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Dec 2023 12:43:17 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rz5ED1JF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rAcEM-0007SH-2Z; Tue, 05 Dec 2023 15:41:22 -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 1rAcEG-0007Qn-CB for qemu-devel@nongnu.org; Tue, 05 Dec 2023 15:41:16 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rAcEE-0002Fl-In for qemu-devel@nongnu.org; Tue, 05 Dec 2023 15:41:16 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40c09f4bea8so29022645e9.1 for ; Tue, 05 Dec 2023 12:41:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701808873; x=1702413673; 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=Nlo6CezYV3r03v3L8dVzCnnygHyr+7WQt60cA9zru2s=; b=Rz5ED1JFG/OHwJhRSuGcoTM00ALIt7PSBeSSE00vybgDWnjfDVgvH3qUAZiagXdpji p3Cu1AK9BOadylYWwqzMajL/y8mZEn663MHVoEZe3k9bP7y/tmBVNBNnxOHYtyP8UkLD 86Ikh0S9MM21/67AHzXnixYD6agtfNNQUL+gOE09kfRvzUgdZcQ5jaLdAToRyYXEbTnd 1hndvUkv8EDS77jgNljgrxjj7bzTJ9kfgqTQJRYYCRnMFTYtEsgs+DXjtzLIL/MK/v0R Gkk/50rt2dQy9BhCtB6RDwMldPqxH9Uooej4Gd/jt8Nr6ind60iAmNF1Qu5rWgGTyEO/ LzoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701808873; x=1702413673; 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=Nlo6CezYV3r03v3L8dVzCnnygHyr+7WQt60cA9zru2s=; b=PWJW+9joA90tNsHlrsRObtstIXTktur7m/0oVDbxD+rHwDYNChljEHYRP+Gj2zmMVu 5FOhObl1FLfCl5GTFkmmP1kG18WjsJSZtIfLTPvizstXno/Vu4Q9fdMiEbwW6X6+p7F6 sz+maTHfoSpRN8TrcZM/queoJsyGfISAZ+9VCj6IjpV8b+Yzx2jfduk8Ey28AehnZlW6 HEChJS04nTKHaPwbdMdZ9LkZ7FLIpU5Y4q5An5IMHo2c0/1JpB40lLACaNczX0lFRJ7t Zq5kLrtsVwX5x9DTsdNcYsIXCf2iws09v7StGNZZDHHeiqwhLL27nfMHtGTeDgcov5jz lHWw== X-Gm-Message-State: AOJu0YwGhEjgQ2bz4d51JpCx9AxCtABP1gMub74J+hTd3BZ7a3oLN64F yxMndl/llia/XUKGXvJYjye6Lg== X-Received: by 2002:a05:600c:1f90:b0:407:7ea1:e9a4 with SMTP id je16-20020a05600c1f9000b004077ea1e9a4mr1011296wmb.5.1701808872877; Tue, 05 Dec 2023 12:41:12 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id w18-20020a5d4b52000000b0033334df1259sm11421633wrs.20.2023.12.05.12.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 12:41:09 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id AC8F25FBC8; Tue, 5 Dec 2023 20:41:06 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Cleber Rosa , Beraldo Leal , Eduardo Habkost , Richard Henderson , Wainer dos Santos Moschetta , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow , Pavel Dovgalyuk , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 08/11] replay: introduce a central report point for sync errors Date: Tue, 5 Dec 2023 20:41:03 +0000 Message-Id: <20231205204106.95531-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231205204106.95531-1-alex.bennee@linaro.org> References: <20231205204106.95531-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.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, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Figuring out why replay has failed is tricky at the best of times. Lets centralise the reporting of a replay sync error and add a little bit of extra information to help with debugging. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- replay/replay-internal.h | 12 ++++++++++++ replay/replay-char.c | 6 ++---- replay/replay-internal.c | 1 + replay/replay.c | 9 +++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/replay/replay-internal.h b/replay/replay-internal.h index 1bc8fd5086..709e2eb4cb 100644 --- a/replay/replay-internal.h +++ b/replay/replay-internal.h @@ -74,6 +74,7 @@ enum ReplayEvents { * @cached_clock: Cached clocks values * @current_icount: number of processed instructions * @instruction_count: number of instructions until next event + * @current_event: current event index * @data_kind: current event * @has_unread_data: true if event not yet processed * @file_offset: offset into replay log at replay snapshot @@ -84,6 +85,7 @@ typedef struct ReplayState { int64_t cached_clock[REPLAY_CLOCK_COUNT]; uint64_t current_icount; int instruction_count; + unsigned int current_event; unsigned int data_kind; bool has_unread_data; uint64_t file_offset; @@ -188,6 +190,16 @@ void replay_event_net_save(void *opaque); /*! Reads network from the file. */ void *replay_event_net_load(void); +/* Diagnostics */ + +/** + * replay_sync_error(): report sync error and exit + * + * When we reach an error condition we want to report it centrally so + * we can also dump some useful information into the logs. + */ +G_NORETURN void replay_sync_error(const char *error); + /* VMState-related functions */ /* Registers replay VMState. diff --git a/replay/replay-char.c b/replay/replay-char.c index a31aded032..72b1f832dd 100644 --- a/replay/replay-char.c +++ b/replay/replay-char.c @@ -113,8 +113,7 @@ void replay_char_write_event_load(int *res, int *offset) *offset = replay_get_dword(); replay_finish_event(); } else { - error_report("Missing character write event in the replay log"); - exit(1); + replay_sync_error("Missing character write event in the replay log"); } } @@ -135,8 +134,7 @@ int replay_char_read_all_load(uint8_t *buf) replay_finish_event(); return res; } else { - error_report("Missing character read all event in the replay log"); - exit(1); + replay_sync_error("Missing character read all event in the replay log"); } } diff --git a/replay/replay-internal.c b/replay/replay-internal.c index 634025096e..654b99cfb5 100644 --- a/replay/replay-internal.c +++ b/replay/replay-internal.c @@ -175,6 +175,7 @@ void replay_fetch_data_kind(void) if (replay_file) { if (!replay_state.has_unread_data) { replay_state.data_kind = replay_get_byte(); + replay_state.current_event++; if (replay_state.data_kind == EVENT_INSTRUCTION) { replay_state.instruction_count = replay_get_dword(); } diff --git a/replay/replay.c b/replay/replay.c index d729214197..e83c01285c 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -226,6 +226,14 @@ bool replay_has_event(void) return res; } +G_NORETURN void replay_sync_error(const char *error) +{ + error_report("%s (insn total %"PRId64"/%d left, event %u/%u)", error, + replay_state.current_icount, replay_state.instruction_count, + replay_state.current_event, replay_state.data_kind); + abort(); +} + static void replay_enable(const char *fname, int mode) { const char *fmode = NULL; @@ -258,6 +266,7 @@ static void replay_enable(const char *fname, int mode) replay_state.data_kind = -1; replay_state.instruction_count = 0; replay_state.current_icount = 0; + replay_state.current_event = 0; replay_state.has_unread_data = false; /* skip file header for RECORD and check it for PLAY */