From patchwork Thu Mar 7 18:26:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 778517 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:47:b0:33e:474f:8c56 with SMTP id k7csp951204wrx; Thu, 7 Mar 2024 10:28:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVWXBzLZrtI27TgM/cFaBfBR4/jVBbfH4qzLkqP6ofA/Kf26gG0BJGEBMs+h/Rud0kgQDx/BVoBadsjHQR6lwpi X-Google-Smtp-Source: AGHT+IFGDQKhoRvtM0/JFwCzMQMy+PqHfgo47sr3ArFJ2oP0mhk7qrl4uecokkvVGzzNMFvccndP X-Received: by 2002:a05:6871:31b5:b0:220:cf76:a9b7 with SMTP id lv53-20020a05687131b500b00220cf76a9b7mr582653oac.44.1709836090971; Thu, 07 Mar 2024 10:28:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709836090; cv=none; d=google.com; s=arc-20160816; b=To6uhGpZr5epL4lf+TBZE8wl+haOabLfPL0dXEbIdg5/ltglWJA1/n57LlQSrN7rC4 bS9Yp3Gtc5Pw2kf2HfYcbR5iDFGRQf25VALvBfc8sxaHiqf56rhJyZtu1RB8xfEaHZMH N6MKbFqZs5/Wd/u/fGQSBuVodUNOV/W+l+HPNYtaGEOwmlJiXMnxO/eG1nlw/N0KE4Qf W90/kkJ6UubGNYETt/qulFvH83H7yuUS4xtrjOpyfdzZPQDcC+jNNZ8Aln/kQkGlwmcG SKoUho3iufMBveLG3WP8EAa1xy3OaU32DQJQyJ4AYxst8dgIyuq/X1EjnMdsd5JBQcco P8sg== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=IZpmqKkC/6jXIwMfBnBHrJzkGHHB70zum6jLXtu3a9I=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=qKiIDOjdEGEh0HBw7YLhxp1wiJbxGmbQ3jGuMRHmEfdMwRySJMC0SNHWJTP1TpLLY5 BYRzPT4hT4qacP5rrGgQUqDYBUtMm7vgW/bMaOxsrvdV7TKIW+SCqGnylBaqCTYjql7G TBnZbCKaJSPAJTMIAMAZYDUtjpQffU2ax9CIFZIHT1zS0S5txTdO+pT/aMkJOCFgq+q9 ae7MJ7cTpRhFNHvnStNXu3c45ub4uOTcgSriiJ2Xq8uNA7WERx8evfjiRQ26Xs4dOI/1 D4femdebo3Ph6uKTlOYCy3u8tuApMnB58WZ5U3zA5cbDLTt72YRozFV4RpDcIczw3i+g Go7A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cEAoI8Qu; 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 fz22-20020a05622a5a9600b0042e5f6a661dsi12455723qtb.45.2024.03.07.10.28.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2024 10:28:10 -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=cEAoI8Qu; 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 1riISV-0001CB-B9; Thu, 07 Mar 2024 13:27:11 -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 1riIST-0001Bm-Oh for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:09 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1riISS-0000ad-4j for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:09 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dc09556599so11040655ad.1 for ; Thu, 07 Mar 2024 10:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709836026; x=1710440826; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IZpmqKkC/6jXIwMfBnBHrJzkGHHB70zum6jLXtu3a9I=; b=cEAoI8QuKQhkI6Id130yoe8YtYTtAozvPh5Qb52a12tV+gA0X84tG2/hxXHV1dtfor Yw3sfsHsrsm2WkqvcTL0uVwa3mOF35RQN0wYYOUFAiT8Z/E32KD4eglNVGyXI5yl6gQT yJbOqZSQcPgj6Mj/G+7dAZxKwuB4FTvuItozeLXloMBmOtIESqiaYmuHez8MyBGQVAD2 +e8lwjZqZVzio3SSCLXsmQzSJ9gFZuW1TCJXQjDNJ0yrOja0RxscZDi2r1/QqWsSwnu2 jj+ivtcG1FI6wbtfnK9BcdpoUhkAJumxB2e8ZJUzCF4ExHcKENUza930kPdJskPey/3t YiZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709836026; x=1710440826; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IZpmqKkC/6jXIwMfBnBHrJzkGHHB70zum6jLXtu3a9I=; b=fXGUX0ocxUaTEK2gNGyCblcua5Pw8CJgpnVTlfY95677NmWLyVR/OSKEca1ZCltanX D3Msba95OD7dcFuG6OdjMQ1a7iqopxxn5Kn/PPhrFzFk2bmYDcaqt4OB/59zMQ8x25lW XiAyHAlHMPmOQmEI4bG8NtW5mOZhCaP+r/P/gLZ2/OYY6TgQc5FU+s3ygcWy+cKy5Ndq vU6WYDOTKquRwZn+cMPcm/+PjRrIIr8RQQZsztzYZIgVCdBbnRZvpce/a1CJ2nIbjpD4 8HWhN4XlSSPYzxkhZA5yHXxH/4/n2EVXzoL0EuHrRdA5ZX8tk4UzpuFLTpwmbcsoNEIj 3yTg== X-Gm-Message-State: AOJu0Ywo5rE9LMSjgAD16bhGoobYiJ50NJsxXduzU3STwzVlDohht4ur 1DnWVhh6oUEn9BnS8nJP2JVL6Mr5ElqYSJZOjR6jYtUXyvLMKa75hbgmHyIXpw2MZDDMOfK/Ph0 vvhU= X-Received: by 2002:a17:902:e84f:b0:1dc:3c3f:c64b with SMTP id t15-20020a170902e84f00b001dc3c3fc64bmr10655856plg.24.1709836025959; Thu, 07 Mar 2024 10:27:05 -0800 (PST) Received: from amd.. ([2804:7f0:b401:120f:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id mm12-20020a1709030a0c00b001dc96d1a662sm14939068plb.197.2024.03.07.10.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 10:27:05 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, richard.henderson@linaro.org Cc: alex.bennee@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v2 1/5] gdbstub: Rename back gdb_handlesig Date: Thu, 7 Mar 2024 18:26:19 +0000 Message-Id: <20240307182623.1450717-1-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=gustavo.romero@linaro.org; helo=mail-pl1-x632.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 Rename gdb_handlesig_reason back to gdb_handlesig. There is no need to add a wrapper for gdb_handlesig and rename it when a new parameter is added. Signed-off-by: Gustavo Romero Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- gdbstub/user.c | 8 ++++---- include/gdbstub/user.h | 15 ++------------- linux-user/main.c | 2 +- linux-user/signal.c | 2 +- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/gdbstub/user.c b/gdbstub/user.c index 14918d1a21..a157e67f95 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -131,7 +131,7 @@ void gdb_qemu_exit(int code) exit(code); } -int gdb_handlesig_reason(CPUState *cpu, int sig, const char *reason) +int gdb_handlesig(CPUState *cpu, int sig, const char *reason) { char buf[256]; int n; @@ -510,7 +510,7 @@ void gdb_breakpoint_remove_all(CPUState *cs) void gdb_syscall_handling(const char *syscall_packet) { gdb_put_packet(syscall_packet); - gdb_handlesig(gdbserver_state.c_cpu, 0); + gdb_handlesig(gdbserver_state.c_cpu, 0, NULL); } static bool should_catch_syscall(int num) @@ -528,7 +528,7 @@ void gdb_syscall_entry(CPUState *cs, int num) { if (should_catch_syscall(num)) { g_autofree char *reason = g_strdup_printf("syscall_entry:%x;", num); - gdb_handlesig_reason(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason); } } @@ -536,7 +536,7 @@ void gdb_syscall_return(CPUState *cs, int num) { if (should_catch_syscall(num)) { g_autofree char *reason = g_strdup_printf("syscall_return:%x;", num); - gdb_handlesig_reason(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason); } } diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h index 68b6534130..6647af2123 100644 --- a/include/gdbstub/user.h +++ b/include/gdbstub/user.h @@ -10,7 +10,7 @@ #define GDBSTUB_USER_H /** - * gdb_handlesig_reason() - yield control to gdb + * gdb_handlesig() - yield control to gdb * @cpu: CPU * @sig: if non-zero, the signal number which caused us to stop * @reason: stop reason for stop reply packet or NULL @@ -25,18 +25,7 @@ * or 0 if no signal should be delivered, ie the signal that caused * us to stop should be ignored. */ -int gdb_handlesig_reason(CPUState *, int, const char *); - -/** - * gdb_handlesig() - yield control to gdb - * @cpu CPU - * @sig: if non-zero, the signal number which caused us to stop - * @see gdb_handlesig_reason() - */ -static inline int gdb_handlesig(CPUState *cpu, int sig) -{ - return gdb_handlesig_reason(cpu, sig, NULL); -} +int gdb_handlesig(CPUState *, int, const char *); /** * gdb_signalled() - inform remote gdb of sig exit diff --git a/linux-user/main.c b/linux-user/main.c index 551acf1661..049fd85a2a 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1014,7 +1014,7 @@ int main(int argc, char **argv, char **envp) gdbstub); exit(EXIT_FAILURE); } - gdb_handlesig(cpu, 0); + gdb_handlesig(cpu, 0, NULL); } #ifdef CONFIG_SEMIHOSTING diff --git a/linux-user/signal.c b/linux-user/signal.c index d3e62ab030..a57c45de35 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -1180,7 +1180,7 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, /* dequeue signal */ k->pending = 0; - sig = gdb_handlesig(cpu, sig); + sig = gdb_handlesig(cpu, sig, NULL); if (!sig) { sa = NULL; handler = TARGET_SIG_IGN; From patchwork Thu Mar 7 18:26:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 778518 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:47:b0:33e:474f:8c56 with SMTP id k7csp951435wrx; Thu, 7 Mar 2024 10:28:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXPnApMpWTeGseFYx+gL+9VzvtxdLNcVrxTJWZ0h0Bfm/kPc1oiK3C0daMNtlSIyauIR4u+Ab69IweaMrjbpqsb X-Google-Smtp-Source: AGHT+IEfMK0qsd1NNCE5rHkjWzkKtF33yJpK0WGef33NtnQX1IHxdcvzcwHVlp8bN7zghtuwsHnG X-Received: by 2002:a0c:eec3:0:b0:690:b0e3:707f with SMTP id h3-20020a0ceec3000000b00690b0e3707fmr280263qvs.37.1709836126046; Thu, 07 Mar 2024 10:28:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709836126; cv=none; d=google.com; s=arc-20160816; b=m9Vr+NIgtxY9WVI9rZ2uWZlSDZWYC2g/LbZc72irlJUy/ZwhxPPdXBWrzYop6j8WJ7 4qf/sL0lAMXMM5ZwFTK8uOgW3oXIjujAmGYuegvYqHRbFSnpl1QN3zj9GB/Xp/9T/mCH 3SGjeh7ztxz9I0Z2/BSzOqLopGUrjdqy5wYkVbL2rRCU8srWCsE7Seuep4TE3SR7iPAL Ex55NwQtwSaGf2rN5UPDWAWja44hEzp2VpMmvq5+WDV5/ZY0d6Pp9b81Thy5GVo7VkDC N0aFNhjMqGOOZPlZPP4+XlNsqeIdH3PbB3BPmqRFHGWRrZ0fhySpdlDCxx29H23K4uA7 8ieQ== 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=HVPjMYWRfzew5Tu6uPDgk6Hue0SFV++AwAN6XVkbF9k=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=vh8e3zkIppCxj0j5bO2vxDpxvDdg3d2Mw0dFQaXgrnaCk55a4BVCNY67D0BgE3L7GU 8IkGzjQVQqbycaBA7Y/TUcnOY9SY6a39PKlQAbdZjnb5oHxkQbCdoGR4vAScPwfuStEM 38KqAFrYwty7yoLqCgNpjBNLr9qFCHkFl03TLXEpGC8WucZZN05GzyrlLKSgUiynwIYx e36sqPQ/IlC2nz3mV6D23vRRnRrctN5xM0ykDM/CMGapt60oF8zry5gQyw5VP6Ga6Du7 SQpEeLRmxWLMq+GCXkNlBp2jyz7+7nivYqwmscXUBobx5geLqyiqlLgTNiIz6r02dX67 SwMQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qubZzwsm; 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 k15-20020ad45bef000000b0068c4ff28befsi17105440qvc.202.2024.03.07.10.28.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2024 10:28:46 -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=qubZzwsm; 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 1riISZ-0001Cr-BY; Thu, 07 Mar 2024 13:27:15 -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 1riISX-0001CJ-1C for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:13 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1riISU-0000bG-UZ for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:12 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dc96f64c10so9845585ad.1 for ; Thu, 07 Mar 2024 10:27:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709836029; x=1710440829; 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=HVPjMYWRfzew5Tu6uPDgk6Hue0SFV++AwAN6XVkbF9k=; b=qubZzwsmTsQO043NwHUNI/MPAjC2BBL/uPqZE1o11NcTQccaaNWXBfJ+kBfVzIjqnM 3iExoA1/S+5SnDkAAbTrBIwr/zbFMuQc5rlwRZ91c+LIGJdMQGkLJcNwOxlbzYHRoLC4 lwe6bppeSJqbiCs6Upq+9FqHyZ/yI9SLiveOoGuNokgjCaA5l20EPpKA/vxAWsr+X4XG ex+STI1t6xFmzSAcVqFfUMOx01lhOIFIwZr/MV/x0THpwXxDsI1JKpfmLieoAqUK6eb/ CTxCjpOmK4IclAYGT1bPMNT+8G8yX2aa+3r5xTpKFJrvT6bS5ZbX19WTyavKN9HAUFj+ m4uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709836029; x=1710440829; 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=HVPjMYWRfzew5Tu6uPDgk6Hue0SFV++AwAN6XVkbF9k=; b=U8EigriV3dq6a7nM/RLx+e1tL/ZtlHTLjDDJlm/3P/h14KLrfZ9YcEwyotFFTSSyIA cNCCkxKpMYpIYlKeTX5dmP5Kzg9rnubzW8DVo3ws+bgvFkqQF0ChGaReSUnvz2XyAbex gwf7yTLHlGGV6YxtEp1m/+1XROWpt1DlKlb9wVo7rRIdPSXLCZqjwlVeYUVTTkvKXRcd d9vIo9uexfI9Gy04RUE5nHpZsmNq0tqm645BtC9osGP3G35E1NSznWm/s+xtu6OUToRc JPjcE+jm9Nov8n0EQJmwKz725qkyjfsvnZn6oV5W6EWOteqy/Le1wNeQj2s5UNxIOBPh K3zg== X-Gm-Message-State: AOJu0Yz5DmhVm+/hX4Rar69TQx8SA7IFhh5NgxFixUYTN4PypEUYtzlu 6NT6FDv6w8VASdTyxkNa+4+cDBro56c3HjpFbgelj1aSCy0+HT8z+6tI+DYzOyr7mSWQQE0mQPU yNrQ= X-Received: by 2002:a17:902:cecb:b0:1db:ab9e:8f90 with SMTP id d11-20020a170902cecb00b001dbab9e8f90mr10411110plg.37.1709836028647; Thu, 07 Mar 2024 10:27:08 -0800 (PST) Received: from amd.. ([2804:7f0:b401:120f:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id mm12-20020a1709030a0c00b001dc96d1a662sm14939068plb.197.2024.03.07.10.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 10:27:08 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, richard.henderson@linaro.org Cc: alex.bennee@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v2 2/5] linux-user: Move tswap_siginfo out of target code Date: Thu, 7 Mar 2024 18:26:20 +0000 Message-Id: <20240307182623.1450717-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307182623.1450717-1-gustavo.romero@linaro.org> References: <20240307182623.1450717-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=gustavo.romero@linaro.org; helo=mail-pl1-x632.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 Move tswap_siginfo from target code to handle_pending_signal. This will allow some cleanups and having the siginfo ready to be used in gdbstub. Signed-off-by: Gustavo Romero Suggested-by: Richard Henderson Reviewed-by: Richard Henderson --- linux-user/aarch64/signal.c | 2 +- linux-user/alpha/signal.c | 2 +- linux-user/arm/signal.c | 2 +- linux-user/hexagon/signal.c | 2 +- linux-user/hppa/signal.c | 2 +- linux-user/i386/signal.c | 6 +++--- linux-user/loongarch64/signal.c | 2 +- linux-user/m68k/signal.c | 4 ++-- linux-user/microblaze/signal.c | 2 +- linux-user/mips/signal.c | 4 ++-- linux-user/nios2/signal.c | 2 +- linux-user/openrisc/signal.c | 2 +- linux-user/ppc/signal.c | 4 ++-- linux-user/riscv/signal.c | 2 +- linux-user/s390x/signal.c | 2 +- linux-user/sh4/signal.c | 2 +- linux-user/signal-common.h | 2 -- linux-user/signal.c | 10 ++++++++-- linux-user/sparc/signal.c | 2 +- linux-user/xtensa/signal.c | 2 +- 20 files changed, 31 insertions(+), 27 deletions(-) diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index a1e22d526d..bc7a13800d 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -670,7 +670,7 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK); if (info) { - tswap_siginfo(&frame->info, info); + frame->info = *info; env->xregs[1] = frame_addr + offsetof(struct target_rt_sigframe, info); env->xregs[2] = frame_addr + offsetof(struct target_rt_sigframe, uc); } diff --git a/linux-user/alpha/signal.c b/linux-user/alpha/signal.c index 4ec42994d4..896c2c148a 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -173,7 +173,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - tswap_siginfo(&frame->info, info); + frame->info = *info; __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index f77f692c63..420fc04cfa 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -357,7 +357,7 @@ void setup_rt_frame(int usig, struct target_sigaction *ka, info_addr = frame_addr + offsetof(struct rt_sigframe, info); uc_addr = frame_addr + offsetof(struct rt_sigframe, sig.uc); - tswap_siginfo(&frame->info, info); + frame->info = *info; setup_sigframe(&frame->sig.uc, set, env); diff --git a/linux-user/hexagon/signal.c b/linux-user/hexagon/signal.c index 60fa7e1bce..492b51f155 100644 --- a/linux-user/hexagon/signal.c +++ b/linux-user/hexagon/signal.c @@ -162,7 +162,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } setup_ucontext(&frame->uc, env, set); - tswap_siginfo(&frame->info, info); + frame->info = *info; /* * The on-stack signal trampoline is no longer executed; * however, the libgcc signal frame unwinding code checks diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c index d08a97dae6..8960175da3 100644 --- a/linux-user/hppa/signal.c +++ b/linux-user/hppa/signal.c @@ -127,7 +127,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - tswap_siginfo(&frame->info, info); + frame->info = *info; frame->uc.tuc_flags = 0; frame->uc.tuc_link = 0; diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index bc5d45302e..cfe70fc5cf 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -430,7 +430,7 @@ void setup_frame(int sig, struct target_sigaction *ka, setup_sigcontext(&frame->sc, &frame->fpstate, env, set->sig[0], frame_addr + offsetof(struct sigframe, fpstate)); - for(i = 1; i < TARGET_NSIG_WORDS; i++) { + for (i = 1; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->extramask[i - 1]); } @@ -490,7 +490,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(addr, &frame->puc); #endif if (ka->sa_flags & TARGET_SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame->info = *info; } /* Create the ucontext. */ @@ -504,7 +504,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate, env, set->sig[0], frame_addr + offsetof(struct rt_sigframe, fpstate)); - for(i = 0; i < TARGET_NSIG_WORDS; i++) { + for (i = 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } diff --git a/linux-user/loongarch64/signal.c b/linux-user/loongarch64/signal.c index 39ea82c814..1a322f9697 100644 --- a/linux-user/loongarch64/signal.c +++ b/linux-user/loongarch64/signal.c @@ -376,7 +376,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, extctx.end.haddr = (void *)frame + (extctx.end.gaddr - frame_addr); } - tswap_siginfo(&frame->rs_info, info); + frame->rs_info = *info; __put_user(0, &frame->rs_uc.tuc_flags); __put_user(0, &frame->rs_uc.tuc_link); diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c index 5f35354487..77555781aa 100644 --- a/linux-user/m68k/signal.c +++ b/linux-user/m68k/signal.c @@ -295,7 +295,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, uc_addr = frame_addr + offsetof(struct target_rt_sigframe, uc); __put_user(uc_addr, &frame->puc); - tswap_siginfo(&frame->info, info); + frame->info = *info; /* Create the ucontext */ @@ -307,7 +307,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (err) goto give_sigsegv; - for(i = 0; i < TARGET_NSIG_WORDS; i++) { + for (i = 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } diff --git a/linux-user/microblaze/signal.c b/linux-user/microblaze/signal.c index 5188d74025..f6d47d76ff 100644 --- a/linux-user/microblaze/signal.c +++ b/linux-user/microblaze/signal.c @@ -147,7 +147,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, return; } - tswap_siginfo(&frame->info, info); + frame->info = *info; __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index 58a9d7a8a3..d69a5d73dd 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -303,7 +303,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - tswap_siginfo(&frame->rs_info, info); + frame->rs_info = *info; __put_user(0, &frame->rs_uc.tuc_flags); __put_user(0, &frame->rs_uc.tuc_link); @@ -311,7 +311,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_sigcontext(env, &frame->rs_uc.tuc_mcontext); - for(i = 0; i < TARGET_NSIG_WORDS; i++) { + for (i = 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &frame->rs_uc.tuc_sigmask.sig[i]); } diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index 32b3dc99c6..64c345f409 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -157,7 +157,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, return; } - tswap_siginfo(&frame->info, info); + frame->info = *info; /* Create the ucontext. */ __put_user(0, &frame->uc.tuc_flags); diff --git a/linux-user/openrisc/signal.c b/linux-user/openrisc/signal.c index be8b68784a..cb74a9fe5e 100644 --- a/linux-user/openrisc/signal.c +++ b/linux-user/openrisc/signal.c @@ -103,7 +103,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } if (ka->sa_flags & SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame->info = *info; } __put_user(0, &frame->uc.tuc_flags); diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index 7e7302823b..0ebfc0b26b 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -493,7 +493,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (!lock_user_struct(VERIFY_WRITE, rt_sf, rt_sf_addr, 1)) goto sigsegv; - tswap_siginfo(&rt_sf->info, info); + rt_sf->info = *info; __put_user(0, &rt_sf->uc.tuc_flags); __put_user(0, &rt_sf->uc.tuc_link); @@ -502,7 +502,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(h2g (&rt_sf->uc.tuc_mcontext), &rt_sf->uc.tuc_regs); #endif - for(i = 0; i < TARGET_NSIG_WORDS; i++) { + for (i = 0; i < TARGET_NSIG_WORDS; i++) { __put_user(set->sig[i], &rt_sf->uc.tuc_sigmask.sig[i]); } diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c index 941eadce87..358fa1d82d 100644 --- a/linux-user/riscv/signal.c +++ b/linux-user/riscv/signal.c @@ -125,7 +125,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } setup_ucontext(&frame->uc, env, set); - tswap_siginfo(&frame->info, info); + frame->info = *info; env->pc = ka->_sa_handler; env->gpr[xSP] = frame_addr; diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index b40f738a70..df49c24708 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -267,7 +267,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } /* Create siginfo on the signal stack. */ - tswap_siginfo(&frame->info, info); + frame->info = *info; /* Create ucontext on the signal stack. */ uc_flags = 0; diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c index c16c2c2d57..9ecc026fae 100644 --- a/linux-user/sh4/signal.c +++ b/linux-user/sh4/signal.c @@ -233,7 +233,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - tswap_siginfo(&frame->info, info); + frame->info = *info; /* Create the ucontext. */ __put_user(0, &frame->uc.tuc_flags); diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 3e2dc604c2..f02d2b6b64 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -43,8 +43,6 @@ void host_to_target_sigset_internal(target_sigset_t *d, const sigset_t *s); void target_to_host_sigset_internal(sigset_t *d, const target_sigset_t *s); -void tswap_siginfo(target_siginfo_t *tinfo, - const target_siginfo_t *info); void set_sigmask(const sigset_t *set); void force_sig(int sig); void force_sigsegv(int oldsig); diff --git a/linux-user/signal.c b/linux-user/signal.c index a57c45de35..7a4c8e416e 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -409,8 +409,8 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, tinfo->si_code = deposit32(si_code, 16, 16, si_type); } -void tswap_siginfo(target_siginfo_t *tinfo, - const target_siginfo_t *info) +static void tswap_siginfo(target_siginfo_t *tinfo, + const target_siginfo_t *info) { int si_type = extract32(info->si_code, 16, 16); int si_code = sextract32(info->si_code, 0, 16); @@ -1180,6 +1180,12 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, /* dequeue signal */ k->pending = 0; + /* + * Writes out siginfo values byteswapped, accordingly to the target. It also + * cleans the si_type from si_code making it correct for the target. + */ + tswap_siginfo(&k->info, &k->info); + sig = gdb_handlesig(cpu, sig, NULL); if (!sig) { sa = NULL; diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index c2dc1000e2..f164b74032 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -333,7 +333,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(0, &sf->rwin_save); /* TODO: save_rwin_state */ - tswap_siginfo(&sf->info, info); + sf->info = *info; tswap_sigset(&sf->mask, set); target_save_altstack(&sf->stack, env); diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c index 32dcfa5229..11e60c3c82 100644 --- a/linux-user/xtensa/signal.c +++ b/linux-user/xtensa/signal.c @@ -184,7 +184,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } if (ka->sa_flags & SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame->info = *info; } __put_user(0, &frame->uc.tuc_flags); From patchwork Thu Mar 7 18:26:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 778516 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:47:b0:33e:474f:8c56 with SMTP id k7csp951154wrx; Thu, 7 Mar 2024 10:28:02 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVr8D9+y07HKzVGY8TX961Cl49N5durGsvgoIVx1v5eJhufOw5hg4pYMN5UsSOBQq9+l4HV9KStNzf5B3msT917 X-Google-Smtp-Source: AGHT+IGQYwRQQBACxGwgXP1bVEurEzS5mZybn5M1cZy8DPAT6hdIjQLkdcj5exkzZVPP96eOQuJ9 X-Received: by 2002:a05:6870:972a:b0:220:932f:1a1b with SMTP id n42-20020a056870972a00b00220932f1a1bmr736586oaq.10.1709836082368; Thu, 07 Mar 2024 10:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709836082; cv=none; d=google.com; s=arc-20160816; b=I+BvVsttOfkwhv6DLwgNdwuq6pTOqM4EM7VsZ+RXoDExlkVMCH1vTpAIRebbgXAMM/ aNCFnNPNQNvlbu/RlnzZWm7fedu51U57cbf7USaPSojcJtT/tTnmb2sk8dyENIXv7Qcn OngsE0vUj9PYXriRCd162uVY/EARhm4/OEW+RuepAva3EspXNtQ22bPPbvCM6u/YuFPQ XHuhDLYMBWYcfZ+PphWgmUlg0/2jHQV4vULO8UxGFN9QPTExchr3VijswbkocDwZKLqH gNGvYUNaBqDRC5sEa9wrvTikUGu2Ikj6C26zBSMeLFzf+Y0d0LutoPqNBbThOYT8fAyY qjww== 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=tJRyVmau9ruD0qJjHtVWvNsb9E69SYPlhZ6E6+1O2KM=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=KA8ik7A7UqEfqNCHcJPN3bSzPceY8FIaRRj7zcVKc57/oPloNG4qS7X6SefEnA8Smj cSHWTl2GwDVPJatIHODtPUlFgX+L9nbsm0Ca4w6P7w3WO6ypi/mUXNnHHnAX5OsfeUJS UKFRoFu10Qx+owIBxmXptzE+NlLvpQ8agVMb941T2jfBe9OD2Z2oyiEfhVgLXFFmGs7L 2VnxliVz8y+zBTxVoz7vpYPhTa494gJAd4e26v8RlZYK6eMFUFRV+t6xDaUjJULN94+l 3JOu6RZ7ujql5KBme6gvy7vbnXW5PNAMmEXoaAQJaSlB1MV4+t3bHjq2fsO+/DbxmiZQ KhjQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mHCD6hzp; 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 y13-20020a05622a120d00b0042f20b5f2fcsi1013094qtx.447.2024.03.07.10.28.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2024 10:28:02 -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=mHCD6hzp; 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 1riISZ-0001Ct-PW; Thu, 07 Mar 2024 13:27:15 -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 1riISY-0001CV-Fz for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:14 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1riISW-0000bc-TP for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:14 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dc0e5b223eso9549055ad.1 for ; Thu, 07 Mar 2024 10:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709836031; x=1710440831; 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=tJRyVmau9ruD0qJjHtVWvNsb9E69SYPlhZ6E6+1O2KM=; b=mHCD6hzpO/GtSmVTiRElm/LOVxcgmpJhz6Xn3hpDE/IRyyJ4qJFpCkzZ2LVe5O8+dq 9TzNfd1etUCkGuY+//ii6hOP2lNhw3U3PtBtUoVqz5upamsSp+rhtogTp3CfsulIZaTN 6Xpp1gUJBCukx/nfQnjSSLkFdEKRhWEu25/nkP24cF8CaswlJ4U+Xl92BEdIxSPxqFSS BsL+3UIULmMubZ7HSvJq6VnawiSD0hbCQW0jyrQq+/beoO6EXOV2rMvo3s219BuleCfj eP7IH+IQyZfIh4mMVl5f7XE6E483tfUPGo1HRlQbR3HsmCPxROj6KLnzq34VSB/rD9z6 gUjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709836031; x=1710440831; 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=tJRyVmau9ruD0qJjHtVWvNsb9E69SYPlhZ6E6+1O2KM=; b=KA3VE5e5V+oIquvHSFNFuaGVu+lJW6PYMivvmcXlo8Od3c68/Jp5YfEWncfoKRVZkM apCn42+ncjdSO6i7Ax8cpcer7n+tL8Xraw9Q/P3j4os6C5RgRHe6yJtUXUy6SpkNey88 Z5hlzcC4XXapZND1gczNt5sySDX5LCpvKfVP/UsxouWLA0lXh0Oo1XSqxpztz7gOKEc7 xWET46Iah4nHQhjTtFw5VL15AKS8Bdqpe6SO9g3CylChn9GYScOJZqMrlBi1K+IP2k5N BDgeV9rUe1U9g4oh9OQnZMhFizmanG1O7FQ0UwSVr2U7hOuAyymN0yUPlfZOtDQKyQrv 7d4A== X-Gm-Message-State: AOJu0YykoVPtS5GX2eTShrYKa30A3V8bYOnf2yVf4V9v8+eGO6OQqQ9S 0jP9tAnU7JxowL6V5kMLaIHeoSF6GgBT4Ta6E2uZslkob+9VDWhxyN3e5n3e6wiLfvu5ZW5zmvD qM+s= X-Received: by 2002:a17:902:e847:b0:1dc:75ea:8562 with SMTP id t7-20020a170902e84700b001dc75ea8562mr9166374plg.32.1709836031390; Thu, 07 Mar 2024 10:27:11 -0800 (PST) Received: from amd.. ([2804:7f0:b401:120f:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id mm12-20020a1709030a0c00b001dc96d1a662sm14939068plb.197.2024.03.07.10.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 10:27:10 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, richard.henderson@linaro.org Cc: alex.bennee@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v2 3/5] gdbstub: Save target's siginfo Date: Thu, 7 Mar 2024 18:26:21 +0000 Message-Id: <20240307182623.1450717-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307182623.1450717-1-gustavo.romero@linaro.org> References: <20240307182623.1450717-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=gustavo.romero@linaro.org; helo=mail-pl1-x632.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 Save target's siginfo into gdbserver_state so it can be used later, for example, in any stub that requires the target's si_signo and si_code. This change affects only linux-user mode. Signed-off-by: Gustavo Romero Suggested-by: Richard Henderson --- gdbstub/internals.h | 3 +++ gdbstub/user-target.c | 3 ++- gdbstub/user.c | 14 ++++++++++---- include/gdbstub/user.h | 6 +++++- linux-user/main.c | 2 +- linux-user/signal.c | 5 ++++- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 56b7c13b75..a7cc69dab3 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -58,6 +58,9 @@ typedef struct GDBState { int line_csum; /* checksum at the end of the packet */ GByteArray *last_packet; int signal; +#ifdef CONFIG_USER_ONLY + uint8_t siginfo[MAX_SIGINFO_LENGTH]; +#endif bool multiprocess; GDBProcess *processes; int process_num; diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c index b7d4c37cd8..215bf33ab3 100644 --- a/gdbstub/user-target.c +++ b/gdbstub/user-target.c @@ -10,11 +10,12 @@ #include "qemu/osdep.h" #include "exec/gdbstub.h" #include "qemu.h" -#include "internals.h" #ifdef CONFIG_LINUX #include "linux-user/loader.h" #include "linux-user/qemu.h" +#include "gdbstub/user.h" #endif +#include "internals.h" /* * Map target signal numbers to GDB protocol signal numbers and vice diff --git a/gdbstub/user.c b/gdbstub/user.c index a157e67f95..777fa78ef4 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -131,7 +131,8 @@ void gdb_qemu_exit(int code) exit(code); } -int gdb_handlesig(CPUState *cpu, int sig, const char *reason) +int gdb_handlesig(CPUState *cpu, int sig, const char *reason, void *siginfo, + int siginfo_len) { char buf[256]; int n; @@ -140,6 +141,11 @@ int gdb_handlesig(CPUState *cpu, int sig, const char *reason) return sig; } + if (siginfo) { + /* Save target-specific siginfo. */ + memcpy(gdbserver_state.siginfo, siginfo, siginfo_len); + } + /* disable single step if it was enabled */ cpu_single_step(cpu, 0); tb_flush(cpu); @@ -510,7 +516,7 @@ void gdb_breakpoint_remove_all(CPUState *cs) void gdb_syscall_handling(const char *syscall_packet) { gdb_put_packet(syscall_packet); - gdb_handlesig(gdbserver_state.c_cpu, 0, NULL); + gdb_handlesig(gdbserver_state.c_cpu, 0, NULL, NULL, 0); } static bool should_catch_syscall(int num) @@ -528,7 +534,7 @@ void gdb_syscall_entry(CPUState *cs, int num) { if (should_catch_syscall(num)) { g_autofree char *reason = g_strdup_printf("syscall_entry:%x;", num); - gdb_handlesig(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason, NULL, 0); } } @@ -536,7 +542,7 @@ void gdb_syscall_return(CPUState *cs, int num) { if (should_catch_syscall(num)) { g_autofree char *reason = g_strdup_printf("syscall_return:%x;", num); - gdb_handlesig(cs, gdb_target_sigtrap(), reason); + gdb_handlesig(cs, gdb_target_sigtrap(), reason, NULL, 0); } } diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h index 6647af2123..0ec9a7e596 100644 --- a/include/gdbstub/user.h +++ b/include/gdbstub/user.h @@ -9,11 +9,15 @@ #ifndef GDBSTUB_USER_H #define GDBSTUB_USER_H +#define MAX_SIGINFO_LENGTH 128 + /** * gdb_handlesig() - yield control to gdb * @cpu: CPU * @sig: if non-zero, the signal number which caused us to stop * @reason: stop reason for stop reply packet or NULL + * @siginfo: target-specific siginfo struct + * @siginfo_len: target-specific siginfo struct length * * This function yields control to gdb, when a user-mode-only target * needs to stop execution. If @sig is non-zero, then we will send a @@ -25,7 +29,7 @@ * or 0 if no signal should be delivered, ie the signal that caused * us to stop should be ignored. */ -int gdb_handlesig(CPUState *, int, const char *); +int gdb_handlesig(CPUState *, int, const char *, void *, int); /** * gdb_signalled() - inform remote gdb of sig exit diff --git a/linux-user/main.c b/linux-user/main.c index 049fd85a2a..3187be48d6 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1014,7 +1014,7 @@ int main(int argc, char **argv, char **envp) gdbstub); exit(EXIT_FAILURE); } - gdb_handlesig(cpu, 0, NULL); + gdb_handlesig(cpu, 0, NULL, NULL, 0); } #ifdef CONFIG_SEMIHOSTING diff --git a/linux-user/signal.c b/linux-user/signal.c index 7a4c8e416e..98d1eacffe 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -34,6 +34,9 @@ #include "user/safe-syscall.h" #include "tcg/tcg.h" +/* target_siginfo_t must fit in gdbstub's siginfo save area. */ +QEMU_BUILD_BUG_ON(sizeof(target_siginfo_t) > MAX_SIGINFO_LENGTH); + static struct target_sigaction sigact_table[TARGET_NSIG]; static void host_signal_handler(int host_signum, siginfo_t *info, @@ -1186,7 +1189,7 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, */ tswap_siginfo(&k->info, &k->info); - sig = gdb_handlesig(cpu, sig, NULL); + sig = gdb_handlesig(cpu, sig, NULL, &k->info, sizeof(k->info)); if (!sig) { sa = NULL; handler = TARGET_SIG_IGN; From patchwork Thu Mar 7 18:26:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 778514 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:47:b0:33e:474f:8c56 with SMTP id k7csp951151wrx; Thu, 7 Mar 2024 10:28:02 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWYC5HkPy0lmfMk2DqVe+MVFXtHfVXOgQKIL/lC74dSwwGfZq4Fs/aNuI5GKy+H/yOPezoQ+cXr+RJvqLrX69Pt X-Google-Smtp-Source: AGHT+IGEzs6I3dXpyqAieGeLfKM4BIMtJ3yVd1AEs6L/DnkM0bNF2bh7H2jjYdtV1NaVex/PDRsD X-Received: by 2002:a05:6808:314:b0:3c0:3189:d9e2 with SMTP id i20-20020a056808031400b003c03189d9e2mr7960806oie.20.1709836082196; Thu, 07 Mar 2024 10:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709836082; cv=none; d=google.com; s=arc-20160816; b=zhue4tUKsnC9LmsWVEjGjvm5vB3BGQra4v7LeazDWzvJywHNDJXCRM8PaQ+4kV3zp1 gZmJAHM1MER+Z+cWs6mpM2g7OGS0JdExOHf2jNsa9Gz2hPPR71cFlhyLrJwDdag3UzTM OyT2vzgypwMuEExmrSdZfDS9QWyM/mCdbxFnl2hd6svtv8VMeV2kQzPiqrBRcOPs06gQ b6tE1tfLp19u56qQvks3LP1rADrbNBIDqq1qxOIWb4C9ydveyE+YNLQkRjspGnCYxx8s C0lxP0OH/GQa0eKKToIIAgdxRXiL5J+2GyA3WN50hrAxm3AEvUTg5fM6Ng9kOaDVuHxf zuHw== 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=1J82rSzajf0utMtQj7GKwdIJ1FdozcoqFW6lAvgBRhQ=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=RmgdbDZjFLoBDmB5Y0+Wpkh3uESrqWg+uaS439AO9CPhgGCfVj4SeIO8EAAz54mRZu 4SrKt/LNmQQIi913mYB+ZrOOohzlU0cnDrrYd+bDdJrgy9PhE35R/1VuIAWoDAqAWLO0 A0dVyBzJ7WwXGrDwZd+vAD905jpJk5mEQzqYmTI7N0hGSRQl6Dk3SD5KW1T/ck1X+iUd 4W9qQhl89IE4pwHv/ykS5D2/YeSqZ6XRkzbYEJBzJ6i+nIM5XKxB7A6rpa3LIeC2FTWv MlqrFJ/faCBzd/Ld1znQhhLsBo98KDlhJjRIzgXEtAyWKVMDpL7Hn7bWXjnvhpTjgAki PqBA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QUexHbdV; 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 wi8-20020a05620a570800b0078822280e7bsi11002897qkn.361.2024.03.07.10.28.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2024 10:28:02 -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=QUexHbdV; 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 1riISd-0001DQ-TT; Thu, 07 Mar 2024 13:27:19 -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 1riISc-0001DF-AW for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:18 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1riISa-0000c4-QB for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:18 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1dc96f64c10so9846065ad.1 for ; Thu, 07 Mar 2024 10:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709836034; x=1710440834; 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=1J82rSzajf0utMtQj7GKwdIJ1FdozcoqFW6lAvgBRhQ=; b=QUexHbdV1wdtv7uCUBTYyxayRa4ROypRl26nyLk8hVVasWw785NWfg0tYA4T7QXFOb R6Uxx2XDX4PxAF/n6plSal+gBHYyJjLYtlgoRkN4/LcqPu2xvqvoG1dBTazoqDupmakS J9gZFBKZSraZO+1ST8A4/ts85aiK5yjwoCCUyfDdINZojJX1Bt6fTXuSlm8vYCLwofoM ssp2qFkyOIxOnBKmW1FkwGRbUWnGCZsYxtF0fp/wPWe2PVRzE0QCVcni27LpnFw7BnE4 tZ9T3FxaQwxy5AglP/uG+N8gOGwiI1q3xkl1GzPtiL9+wAJftahKjyultxrP34cqlSnT zViA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709836034; x=1710440834; 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=1J82rSzajf0utMtQj7GKwdIJ1FdozcoqFW6lAvgBRhQ=; b=c+YPxJ3SkYMLjpZ4BRt/U9zm8qc7v8o8fwoA3ls49+2+MKLzRjqrgviT8WIe8PQ7pB UEVY8kN1S7qKCP9ubKFO9zqDGeaabQ0oDi2z7/O9dHoSG0r89c2gq6RzaTzhygw6ykWq AUC5xZOu2CKMvZfCSvAjUnu25aE5DDPK9LMLvaFmUsIrkKsugiyi5zSda+8lNFP/vSB7 g+g8QajQUtp9u1GReyux/zKlsSxmZs6l5tOzVo/yllSOT6SIibHUUUqJjJYqEeyHFK7Q 12s+UmwG8d1iZUCd1eS9mobrSfXkW12N7a5EjmRc5C3U2a3oULrKcgnryiqjxNfYYB/l dI3Q== X-Gm-Message-State: AOJu0Yyo2FkZCZQs21vrmE8v3ki/Xq7wMiXHawNooCB8s0qUy1Mi1enP o4fSEkUUV/TRAWVsAwnuPOiB3TYFC1t727pB0CgoIc0KQfCoTvr98Hwiusf+4D9N4Pw05cAu2bG yIDE= X-Received: by 2002:a17:902:9009:b0:1db:f965:470d with SMTP id a9-20020a170902900900b001dbf965470dmr8035885plp.24.1709836033942; Thu, 07 Mar 2024 10:27:13 -0800 (PST) Received: from amd.. ([2804:7f0:b401:120f:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id mm12-20020a1709030a0c00b001dc96d1a662sm14939068plb.197.2024.03.07.10.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 10:27:13 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, richard.henderson@linaro.org Cc: alex.bennee@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v2 4/5] gdbstub: Add Xfer:siginfo:read stub Date: Thu, 7 Mar 2024 18:26:22 +0000 Message-Id: <20240307182623.1450717-4-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307182623.1450717-1-gustavo.romero@linaro.org> References: <20240307182623.1450717-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=gustavo.romero@linaro.org; helo=mail-pl1-x636.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 Add stub to handle Xfer:siginfo:read packet query that requests the machine's siginfo data. This is used when GDB user executes 'print $_siginfo' and when the machine stops due to a signal, for instance, on SIGSEGV. The information in siginfo allows GDB to determiner further details on the signal, like the fault address/insn when the SIGSEGV is caught. Signed-off-by: Gustavo Romero --- gdbstub/gdbstub.c | 8 ++++++++ gdbstub/internals.h | 1 + gdbstub/user-target.c | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 2909bc8c69..ab38cea46b 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1651,6 +1651,8 @@ static void handle_query_supported(GArray *params, void *user_ctx) g_string_append(gdbserver_state.str_buf, ";qXfer:auxv:read+"); } g_string_append(gdbserver_state.str_buf, ";QCatchSyscalls+"); + + g_string_append(gdbserver_state.str_buf, ";qXfer:siginfo:read+"); #endif g_string_append(gdbserver_state.str_buf, ";qXfer:exec-file:read+"); #endif @@ -1799,6 +1801,12 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = { .cmd_startswith = 1, .schema = "l,l0" }, + { + .handler = gdb_handle_query_xfer_siginfo, + .cmd = "Xfer:siginfo:read::", + .cmd_startswith = 1, + .schema = "l,l0" + }, #endif { .handler = gdb_handle_query_xfer_exec_file, diff --git a/gdbstub/internals.h b/gdbstub/internals.h index a7cc69dab3..15c01c525a 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -193,6 +193,7 @@ typedef union GdbCmdVariant { void gdb_handle_query_rcmd(GArray *params, void *user_ctx); /* softmmu */ void gdb_handle_query_offsets(GArray *params, void *user_ctx); /* user */ void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx); /*user */ +void gdb_handle_query_xfer_siginfo(GArray *params, void *user_ctx); /*user */ void gdb_handle_v_file_open(GArray *params, void *user_ctx); /* user */ void gdb_handle_v_file_close(GArray *params, void *user_ctx); /* user */ void gdb_handle_v_file_pread(GArray *params, void *user_ctx); /* user */ diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c index 215bf33ab3..93739852b0 100644 --- a/gdbstub/user-target.c +++ b/gdbstub/user-target.c @@ -285,6 +285,29 @@ void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx) gdb_put_packet_binary(gdbserver_state.str_buf->str, gdbserver_state.str_buf->len, true); } + +void gdb_handle_query_xfer_siginfo(GArray *params, void *user_ctx) +{ + unsigned long offset, len; + uint8_t *siginfo_offset; + + offset = get_param(params, 0)->val_ul; + len = get_param(params, 1)->val_ul; + + if (offset + len > sizeof(target_siginfo_t)) { + /* Invalid offset and/or requested length. */ + gdb_put_packet("E01"); + return; + } + + siginfo_offset = (uint8_t *)gdbserver_state.siginfo + offset; + + /* Reply */ + g_string_assign(gdbserver_state.str_buf, "l"); + gdb_memtox(gdbserver_state.str_buf, (const char *)siginfo_offset, len); + gdb_put_packet_binary(gdbserver_state.str_buf->str, + gdbserver_state.str_buf->len, true); +} #endif static const char *get_filename_param(GArray *params, int i) From patchwork Thu Mar 7 18:26:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 778515 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:47:b0:33e:474f:8c56 with SMTP id k7csp951156wrx; Thu, 7 Mar 2024 10:28:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXT5XFoLXMHW3MEbNrM64eXoFRx6VPfu97zqp+Z8iogya0E1TFAoYetyeHOVeSzrXOLwR2NJcRxF/jkBAVD4dmx X-Google-Smtp-Source: AGHT+IFSza3p8zBHer224gylbFP8NIulusfOTc8wdLbt29JtaKFUS94UgekxvPAVrLMoMEiHA8pp X-Received: by 2002:a05:6358:1992:b0:17b:e053:84e2 with SMTP id v18-20020a056358199200b0017be05384e2mr10062028rwn.12.1709836082605; Thu, 07 Mar 2024 10:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709836082; cv=none; d=google.com; s=arc-20160816; b=L1sRTOeksp/7rvJ8bKc951zbJp6gM/yIg7RqnMQMqJ71FeyGY9YYCrlE19FNiJrku1 l5aF2SqpxOPKamthIQfLuDi08cofDvOh4oTsbI1QpwWCbiB/DQkiUUJziK7cHPL2Cq+v 70Js5yqDfCQdet1Je1T3SEAUn5/hJFG/I5J4KbDApDI2x82+SdoThQTQQcpWOwVk7YKI duMJdlFT0TqJsIHJzV5gkrwVAcT5FerNtEAUToWYnlKJ6XGcKw8EhjVw7YaTbkOwqp55 eY8Hh5sFKhBV9fHzrjcdVhh99IXqHo3yZGhB0Acn5YG1YrokZlCi6LTLetLAd59c4kmQ Gt2Q== 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=o8huhRHNOBYWkXgN/4/yH0cLjdQL8crIEtN89AF3mvM=; fh=+Jn5QrUSs46cFc7pLBHSJR4rdczRsVh7RhZKgXapQ8c=; b=po0k3CID/XgJb44hqWa3Kt0jP7DFA9CWcW1WkTxcte/WO0rUJdghBumFnmm/lRyith ysSufR0GMpWzTC5arkXN3WlA+9jW4eWIeYZ6bseY6llgnWw1LE1RHcEmjiS4oV7cx+kB YZ3lHc+pJy5OSVxJgMAdGKZ6uKh8B6+XVX4hK0ukg7Fy7zWAvkiIifl+igkxafUQebeZ R8ttWXV5QC+PvSA/Cpl3slfQTMftSVh/nhO25yEJv6U2UM6S+I+ao7YpAKolhLQ9oEcz YxyChfQ0A8qeT9awkECogY6WvGCXEbrwt6ns79ntqxgUO9SOyxkKLZVNQpBWfJX8xOaq 6Nzg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QjuhTniC; 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 h2-20020a05620a284200b007882e6f4e5fsi8943017qkp.463.2024.03.07.10.28.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2024 10:28:02 -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=QjuhTniC; 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 1riISf-0001E8-Dn; Thu, 07 Mar 2024 13:27:21 -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 1riISd-0001DP-R0 for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:19 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1riISc-0000cL-8i for qemu-devel@nongnu.org; Thu, 07 Mar 2024 13:27:19 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1dd0d46ecc3so9508845ad.2 for ; Thu, 07 Mar 2024 10:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709836036; x=1710440836; 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=o8huhRHNOBYWkXgN/4/yH0cLjdQL8crIEtN89AF3mvM=; b=QjuhTniCu+O6egwC7OuADAoVOOK24tezDqkvR+cdOjNjCyvAS3d+oSQpmS4XpdvnSD 24wYtYR/8YFDryVtM8/qhQ0b/tfnILeDFQN5wLbI8TycjUkRZtnPzI2d0zmtxgSncfni ECSGLoa4ZiRx/It+NtrCvWc5xDBQ/+cFi2zcjX1AHOzA+O2jz8T8/znGAk+gDKNc2J1Z kyZTHTb2iQ6TROVHwf0eNRb0vSkt6uT3AKMvIa2EFZiYqpa8SnzakIXv550m5ftdya9F v30GHhEuqQ9LFD5e6+c69a6uO72hHDvaNhBDAgN/ByC0v+Jvwfeem+/yk+ufCfyc0xH2 xSmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709836036; x=1710440836; 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=o8huhRHNOBYWkXgN/4/yH0cLjdQL8crIEtN89AF3mvM=; b=wkWkya4/zT/C0aTu+HWC01NqinEqQYLTrvzJGU17IuiOPUS++f2zpYNUXd8I7/pt3A jDXdlomjkOIk3l7JPM6ozyMV3BVb2b7XtGgnC+W44dDVqud1pcOar3ZdUNW7plUn2WkF 4GoZrdHSg8NW8penb86hlOKus6dPYKZiW2/FRwtbxS3+R1LL+euU0Q0Tr5D/6KU4k5Id w9xnUyMK0Lzzz1fZ4JajRVaOiATJfFZyR514zfQVN+ZarO5E50qqqJG0O4hZsc3UYxA0 Kl+cBkSw6NDd7XGPMNSAVzf3i+zd5wfB+nenv5by1RqXcIt1IbE+Ml8DYii7qdXRaPo/ X3Bg== X-Gm-Message-State: AOJu0Yza/Xu33NuLPewkFB0Q3qaEyQPotomeE0Bv4xaXY3ChZmNihaq4 dCuBQA2wxnGAN4xrZV5Ndvs6rwAVg8XTbY917oCtaCDHGCuIHGwcQhmXmQbvab8F1BY5agOB+Dq 842g= X-Received: by 2002:a17:902:d2c5:b0:1dc:b003:ed7a with SMTP id n5-20020a170902d2c500b001dcb003ed7amr10982899plc.5.1709836036537; Thu, 07 Mar 2024 10:27:16 -0800 (PST) Received: from amd.. ([2804:7f0:b401:120f:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id mm12-20020a1709030a0c00b001dc96d1a662sm14939068plb.197.2024.03.07.10.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 10:27:16 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, richard.henderson@linaro.org Cc: alex.bennee@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v2 5/5] tests/tcg: Add multiarch test for Xfer:siginfo:read stub Date: Thu, 7 Mar 2024 18:26:23 +0000 Message-Id: <20240307182623.1450717-5-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307182623.1450717-1-gustavo.romero@linaro.org> References: <20240307182623.1450717-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=gustavo.romero@linaro.org; helo=mail-pl1-x633.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 Add multiarch test for testing if Xfer:siginfo:read query is properly handled by gdbstub. Signed-off-by: Gustavo Romero Reviewed-by: Richard Henderson --- tests/tcg/multiarch/Makefile.target | 10 ++++++- .../gdbstub/test-qxfer-siginfo-read.py | 26 +++++++++++++++++++ tests/tcg/multiarch/segfault.c | 14 ++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py create mode 100644 tests/tcg/multiarch/segfault.c diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index f11f3b084d..5ab4ba89b2 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -71,6 +71,13 @@ run-gdbstub-qxfer-auxv-read: sha1 --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \ basic gdbstub qXfer:auxv:read support) +run-gdbstub-qxfer-siginfo-read: segfault + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin "$< -s" --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-siginfo-read.py, \ + basic gdbstub qXfer:siginfo:read support) + run-gdbstub-proc-mappings: sha1 $(call run-test, $@, $(GDB_SCRIPT) \ --gdb $(GDB) \ @@ -113,7 +120,8 @@ endif EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \ run-gdbstub-registers run-gdbstub-prot-none \ - run-gdbstub-catch-syscalls + run-gdbstub-catch-syscalls \ + run-gdbstub-qxfer-siginfo-read # ARM Compatible Semi Hosting Tests # diff --git a/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py b/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py new file mode 100644 index 0000000000..862596b07a --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py @@ -0,0 +1,26 @@ +from __future__ import print_function +# +# Test gdbstub Xfer:siginfo:read stub. +# +# The test runs a binary that causes a SIGSEGV and then looks for additional +# info about the signal through printing GDB's '$_siginfo' special variable, +# which sends a Xfer:siginfo:read query to the gdbstub. +# +# The binary causes a SIGSEGV at dereferencing a pointer with value 0xdeadbeef, +# so the test looks for and checks if this address is correctly reported by the +# gdbstub. +# +# This is launched via tests/guest-debug/run-test.py +# + +import gdb +from test_gdbstub import main, report + +def run_test(): + "Run through the test" + + gdb.execute("continue", False, True) + resp = gdb.execute("print/x $_siginfo", False, True) + report(resp.find("si_addr = 0xdeadbeef"), "Found fault address.") + +main(run_test) diff --git a/tests/tcg/multiarch/segfault.c b/tests/tcg/multiarch/segfault.c new file mode 100644 index 0000000000..e6c8ff31ca --- /dev/null +++ b/tests/tcg/multiarch/segfault.c @@ -0,0 +1,14 @@ +#include +#include + +/* Cause a segfault for testing purposes. */ + +int main(int argc, char *argv[]) +{ + int *ptr = (void *)0xdeadbeef; + + if (argc == 2 && strcmp(argv[1], "-s") == 0) { + /* Cause segfault. */ + printf("%d\n", *ptr); + } +}