From patchwork Mon Aug 5 00:31:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 816726 Delivered-To: patch@linaro.org Received: by 2002:adf:e00d:0:b0:367:895a:4699 with SMTP id s13csp1133601wrh; Sun, 4 Aug 2024 17:32:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVOd5chavZmCy18/urEptgqB69hk6WZXh1V05GoMwy5dkMFX2QFypnJFI6TGxvFVeOt3Y+wkZh0tA57U4qsZPsR X-Google-Smtp-Source: AGHT+IF3zLaqK7aLSVacD1C9CR7LjCGr/eCoqRedrXPk9vmO+BGME27Zy689MK2pfmedqZZyq6TF X-Received: by 2002:a05:6122:3b0f:b0:4f5:22cc:71b9 with SMTP id 71dfb90a1353d-4f89ff6c45emr12046174e0c.5.1722817951685; Sun, 04 Aug 2024 17:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722817951; cv=none; d=google.com; s=arc-20160816; b=sUag/ye0HT82yAuTDXBsEU043ZFsee4P1Wrx80JbXTaqeXEmym8Z0JXVoEZHJ8K4QD b7s2xhLXDTKQqye9Hu3M4RrMlO+42OW7XGbVGZHtpkDQI1TWuUVOeCsB/fVckcYr8rkl /5PmJD9gzwcLV/V2J+ZoyG40jBJ7u85yxMn1qnSGWjRSAqQwehOc4kJznn1hsFlQdgdp N6nWrUNAXXqhC+bQ2mcGPHsCvYitjGYkLo6v2tzWnsVlCLXtuL+opIGryAAae2gBaMiv YvSgCiub4FwKKEinTv12TJKPduutNEtil+Ve31XDxwkZEluVRYQ+jdg/i8B4uUlSjPBL MrJA== 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=8WJQORCpqGoeFxGSwBWz+2gItcHfSAbHK8FGjbSdfpM=; fh=4RqdLMIrR7qTEUmnmFFI+83EHhKCrT2Fs4rC7TcdDhw=; b=qPCqqshyRcIcBLNn56fLVCXIo2X3WhZrd0Gd75p0Q6elN+Je1EqrV2FgZbWHeUSJcw IwjgBBW2dzbRtWOoiP8GtF0EGuz7Jgcj00eEk8MS00eWcT9KFjra8sVKShaVIo6NZwOu nfHuzNhASybyUYsHTvDdKvnpjMZ3/7xLYBQXAMNRzsyYDbNTQLXOIYWIxhvG6AEW42dA 9ySTpQA3y2aWlxobQsEmIbdUNBakR06dJJBlfks8+0U8BEQziHdspOcq4gKRTpwiRXe0 20+jl2TSTJxt4uzCsD8iSeHOOjB+0WbsFowSPvea4ep16ZzWDrN0kF3PnIRys0u0brVr SVZw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g53sSO+R; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a34f6ce7c3si868290685a.145.2024.08.04.17.32.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Aug 2024 17:32:31 -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=g53sSO+R; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1saldY-0007Z6-8Y; Sun, 04 Aug 2024 20:31:44 -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 1saldW-0007Rl-Fj for qemu-devel@nongnu.org; Sun, 04 Aug 2024 20:31:42 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1saldU-0002IY-TS for qemu-devel@nongnu.org; Sun, 04 Aug 2024 20:31:42 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-70d2b921c48so7633708b3a.1 for ; Sun, 04 Aug 2024 17:31:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722817899; x=1723422699; 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=8WJQORCpqGoeFxGSwBWz+2gItcHfSAbHK8FGjbSdfpM=; b=g53sSO+RsOfxs0qHyP53M+L/fOnR+O3Ag8kiudkpuAHWWoLv+Ig+e3mwbYt7k+o8TO TRsoRbzOZghwfMztIjKkVM5vm6B/HEcU8sgJ8coRZlAn4/E7eCwu5/LpmjWK0b7C7uZc KSSrgDR7VjKf1dEroFhP5iLQNxP6pEbS35f+LNCuTY2rQAPrpvYDM2q9+Kt2FoODsj2P htcYfBiH4wURX6R+UQ5P6cgvVmnNZm9b7KJKjo58QKnoXV9GsQ4PgO7zEVQeHflDPWmd 1Dgsq+Ku9ziq+e0SFiIB6b7cLHp7k1vw31ZMY+tbqZ0ucw1q4KtLodSBZlU0ms/nX+49 0E0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722817899; x=1723422699; 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=8WJQORCpqGoeFxGSwBWz+2gItcHfSAbHK8FGjbSdfpM=; b=D9UDyadZCHeBYZs6YXW8Dpe7G+qYGVbn7wd/OPVv1TjqPVxEvJQVTbNgvf7fau084C KkdC7bwqM9OPUw504SbqUeENUuQJAgWiXdgvlMulNi3/mqEezMqk70p0E9o6/LYOG83A gQZVXskX2tzqYyiTJ/ixttcAtYhw+396j+xU4mAsVzyFiiV864QSjBlrtoc9BBlqMlTN ulJLbEll5EtBABTQ53K8yxgjyVC5QYrv5CCX1u2R3QdAbOynsqML148cz+fY/JdmCvCm +BkYtd1iaDv3wkG1eskmH4QjK7kkDKtG/6W9yVYvH2amZLUnOsnpW+NjizK5oZ/ui2cw KGOA== X-Gm-Message-State: AOJu0YzOJxAVXKhb2Kepo+47SgQlBKBRJgH/63Avq/fvk4Jjv3eRPoIa p0X9zKGOO6BRGvKM5jij+VLlcWxfsn8Lkure1pt0RI4021yRsGgRxcbEEHT5HliZikHy1/CKq6W Znn0hBg== X-Received: by 2002:a05:6a20:7f84:b0:1c4:8da5:5825 with SMTP id adf61e73a8af0-1c699429e34mr10679109637.0.1722817899175; Sun, 04 Aug 2024 17:31:39 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7106ed16cb3sm4576038b3a.179.2024.08.04.17.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Aug 2024 17:31:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , qemu-stable@nongnu.org Subject: [PULL 1/6] linux-user/elfload: Fix pr_pid values in core files Date: Mon, 5 Aug 2024 10:31:23 +1000 Message-ID: <20240805003130.1421051-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240805003130.1421051-1-richard.henderson@linaro.org> References: <20240805003130.1421051-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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 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: Ilya Leoshkevich Analyzing qemu-produced core dumps of multi-threaded apps runs into: (gdb) info threads [...] 21 Thread 0x3ff83cc0740 (LWP 9295) warning: Couldn't find general-purpose registers in core file. in ?? () The reason is that all pr_pid values are the same, because the same TaskState is used for all CPUs when generating NT_PRSTATUS notes. Fix by using TaskStates associated with individual CPUs. Cc: qemu-stable@nongnu.org Fixes: 243c47066253 ("linux-user/elfload: Write corefile elf header in one block") Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Message-ID: <20240801202340.21845-1-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- linux-user/elfload.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0d4dc1f6d1..b27dd01734 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4102,8 +4102,7 @@ static void fill_elf_note_phdr(struct elf_phdr *phdr, size_t sz, off_t offset) bswap_phdr(phdr, 1); } -static void fill_prstatus_note(void *data, const TaskState *ts, - CPUState *cpu, int signr) +static void fill_prstatus_note(void *data, CPUState *cpu, int signr) { /* * Because note memory is only aligned to 4, and target_elf_prstatus @@ -4113,7 +4112,7 @@ static void fill_prstatus_note(void *data, const TaskState *ts, struct target_elf_prstatus prstatus = { .pr_info.si_signo = signr, .pr_cursig = signr, - .pr_pid = ts->ts_tid, + .pr_pid = get_task_state(cpu)->ts_tid, .pr_ppid = getppid(), .pr_pgrp = getpgrp(), .pr_sid = getsid(0), @@ -4428,8 +4427,7 @@ static int elf_core_dump(int signr, const CPUArchState *env) CPU_FOREACH(cpu_iter) { dptr = fill_note(&hptr, NT_PRSTATUS, "CORE", sizeof(struct target_elf_prstatus)); - fill_prstatus_note(dptr, ts, cpu_iter, - cpu_iter == cpu ? signr : 0); + fill_prstatus_note(dptr, cpu_iter, cpu_iter == cpu ? signr : 0); } if (dump_write(fd, header, data_offset) < 0) {