From patchwork Mon Mar 11 19:12:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 779426 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp1689656wrt; Mon, 11 Mar 2024 12:20:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX9hmtCRgsGVfRRmSJdBA07oLvwi+8RtYbnEw82tpvDG4S1qUKzqDfGmBqaENAiQ+62blM+H+6LaoReVuQE1mRH X-Google-Smtp-Source: AGHT+IHKDWeUMSarzFF3PtZasZBiq8+ZSEfmqYQpjTyMe+kCVzfv2O55XQxYET5h/ChardupaXSp X-Received: by 2002:a05:6359:4597:b0:17b:59e6:ff8c with SMTP id no23-20020a056359459700b0017b59e6ff8cmr10993156rwb.6.1710184836132; Mon, 11 Mar 2024 12:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710184836; cv=none; d=google.com; s=arc-20160816; b=p6TTC2Nk3hwtFxRZYP2DuAHW/rL8YOMvugdmmC1dCiWz1Lel521a/hFh4ppxMv9kHq Z3uLwe3lPdPn1+6F8h82szr8VipzNB+A7t55NTog3sf2FHA7KXa161Pcubo4tcnDXy99 hMwQlkol3cLNfxX9vMXO13vcnPnjMw0032X3TBLvh6Ir4ausnUnsqFRZvEM+zdJp+zg3 l0XBP6l7d/xrCKg1bu4fz7fINxVTk8xrLqbRbe22A0a8nheaM6fnxGfS8zLpTLPAhgoS WhBEA2nvNd7oQuXYwzY4K6koknBq/SRyJBJFhmjpAWb3NZKZow7WZKV2cf5XJZCAo1tD AE/Q== 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:to:from :dkim-signature; bh=zc+ckQmpBvqBoIUO6cJJ2qIcD3yUGjjQZyKjrxix+5k=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=BEJWvtd/AsZDsCxqaYRGw+pqLZktO6plbWFtGdAPRhamyct7meA8Lmebn9lSNzQUBF UxqZ+2Jf+NfHCJdxzFJs1vtidtkn23/eNI8sloGQULpntcbsID0erQx1lAinvy0Vii6o vHsxkGO8mkmtqZkfFURBqHGvqhfLTgtpwUPg+j4aY29fGFJ7dr0nSLwiQZmx/AmcjLuf 8vMqHbnuc+0Ke6XW8fzl33vqyDSD5QtO27+Iaw7H+vCJbUm9/hceTiv+MQl3Ad7+vC8u Y3XzXVW2CPuCToSTL9r8odjI7q8pIlhy7Gtk6BT/01yI3/Z6Yfg9CYEFEMQN45saqkKZ Bqtw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p8059nxJ; 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 bs39-20020a05620a472700b007877ab19a77si6471957qkb.147.2024.03.11.12.20.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2024 12:20:36 -0700 (PDT) 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=p8059nxJ; 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 1rjl9S-0006es-Js; Mon, 11 Mar 2024 15:17:36 -0400 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 1rjl4r-0003Js-D5 for qemu-devel@nongnu.org; Mon, 11 Mar 2024 15:12:53 -0400 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 1rjl4p-0000M4-CC for qemu-devel@nongnu.org; Mon, 11 Mar 2024 15:12:49 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-41332865b05so379135e9.0 for ; Mon, 11 Mar 2024 12:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710184365; x=1710789165; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=zc+ckQmpBvqBoIUO6cJJ2qIcD3yUGjjQZyKjrxix+5k=; b=p8059nxJ/VmA2lq1S2u6oaqz3fQHYPU8WQxweqyMc2Vf96A1t4WqTUeUTLJr9OkSp2 YQ0YySl8tOJOk7Xq0jVxIaw8Q8FqN8KW7HliCxV5iIgZilVTG2qjVcu0OjFlYrQpx1Rt 8JqlzqvsSk4KWX+edQfxS0w2J6sRRVXws+ig893alqvin2BLQcGyZZReGDTBzlt3yFI4 hzTz2YZ90sLXsAt+LnNexZhuiRR7FsTHkzvzz4UCvVO8TBKP5KiHM55mAeAFmJXo4/ST Bo8/OY9xrdAYprR3lbr5a3N95TGFRO2fQVBZZJdV6OfeAoX3WAmsYNNI6oXdnY4Saxjv CpGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710184365; x=1710789165; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zc+ckQmpBvqBoIUO6cJJ2qIcD3yUGjjQZyKjrxix+5k=; b=dwX9xjsf1Rsxnx70/Jl9Z7KO0IfxNrMaSHpNrTCT3flsQ5fuzOMecg/DVrnV/f6jqw dH7yMelKL+QtI2NTvpDNR00e7cSO+hYlz4oouoeJdKT5uWIN2FgHnPccANpT0CekrCZp 1F1oiAmS1A2EJbE9ReXaKM6yqk367aEQSsJ4gIj7WsKQB3UZ5wZSLc8bK1Lz/vMtPqYL 6wM3oYsgKl6ayZOh2t4TnzELjR34p8cZGI6ruju+kzDSQsuZg4A1lUoXRYQvUyc88OH0 tW9TWe2iGd7sf03CSqjsF1TvXotp5drBsRzc6g0edwGGh6CHuxxx5dymRQrvW8X3kvys 6plA== X-Gm-Message-State: AOJu0YyOgqG67tSljY4OfzVboHQ9PoVsfBBeWSq9iiokK3QyAfyd10Z5 j+pHCP9R/yo885GLhrYmL/bIidmQY8cZJaeXz3SqdcMJlfZeaWV3yVKqcZqDuJMknz/9wthMHef d X-Received: by 2002:a05:600c:4e4e:b0:413:15fc:231 with SMTP id e14-20020a05600c4e4e00b0041315fc0231mr5142454wmq.29.1710184364730; Mon, 11 Mar 2024 12:12:44 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t10-20020a05600c450a00b004131388d948sm14425266wmo.0.2024.03.11.12.12.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 12:12:44 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/20] contrib/elf2dmp: Continue even contexts are lacking Date: Mon, 11 Mar 2024 19:12:25 +0000 Message-Id: <20240311191241.4177990-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311191241.4177990-1-peter.maydell@linaro.org> References: <20240311191241.4177990-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@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 From: Akihiko Odaki Let fill_context() continue even if it fails to fill contexts of some CPUs. A dump may still contain valuable information even if it lacks contexts of some CPUs due to dump corruption or a failure before starting CPUs. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell Tested-by: Viktor Prutyanov Message-id: 20240307-elf2dmp-v4-3-4f324ad4d99d@daynix.com Signed-off-by: Peter Maydell --- contrib/elf2dmp/main.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c index 9b278f392e3..86e709e6da3 100644 --- a/contrib/elf2dmp/main.c +++ b/contrib/elf2dmp/main.c @@ -336,8 +336,13 @@ static int fill_header(WinDumpHeader64 *hdr, struct pa_space *ps, return 0; } -static int fill_context(KDDEBUGGER_DATA64 *kdbg, - struct va_space *vs, QEMU_Elf *qe) +/* + * fill_context() continues even if it fails to fill contexts of some CPUs. + * A dump may still contain valuable information even if it lacks contexts of + * some CPUs due to dump corruption or a failure before starting CPUs. + */ +static void fill_context(KDDEBUGGER_DATA64 *kdbg, + struct va_space *vs, QEMU_Elf *qe) { int i; @@ -350,7 +355,7 @@ static int fill_context(KDDEBUGGER_DATA64 *kdbg, if (va_space_rw(vs, kdbg->KiProcessorBlock + sizeof(Prcb) * i, &Prcb, sizeof(Prcb), 0)) { eprintf("Failed to read CPU #%d PRCB location\n", i); - return 1; + continue; } if (!Prcb) { @@ -361,7 +366,7 @@ static int fill_context(KDDEBUGGER_DATA64 *kdbg, if (va_space_rw(vs, Prcb + kdbg->OffsetPrcbContext, &Context, sizeof(Context), 0)) { eprintf("Failed to read CPU #%d ContextFrame location\n", i); - return 1; + continue; } printf("Filling context for CPU #%d...\n", i); @@ -369,11 +374,9 @@ static int fill_context(KDDEBUGGER_DATA64 *kdbg, if (va_space_rw(vs, Context, &ctx, sizeof(ctx), 1)) { eprintf("Failed to fill CPU #%d context\n", i); - return 1; + continue; } } - - return 0; } static int pe_get_data_dir_entry(uint64_t base, void *start_addr, int idx, @@ -619,9 +622,7 @@ int main(int argc, char *argv[]) goto out_kdbg; } - if (fill_context(kdbg, &vs, &qemu_elf)) { - goto out_kdbg; - } + fill_context(kdbg, &vs, &qemu_elf); if (write_dump(&ps, &header, argv[2])) { eprintf("Failed to save dump\n");