From patchwork Tue Mar 5 12:09:46 2024 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: 777990 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp399093wrs; Tue, 5 Mar 2024 04:16:55 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXDWQgssZXTksfiqAr/S19E10vcQvLZyELVPnWnV2t5wXlcalNAa73dLiySFLdniZkAD9i/q8Aue2i3SiYbff/G X-Google-Smtp-Source: AGHT+IHlEmF5JL7H/lkG6EwutPGMSK0uB/UF+rm4zL/o8o5RAiPU8xnZxFV+eGM+seFeflCvTZvd X-Received: by 2002:a05:622a:44:b0:42e:a654:1d2a with SMTP id y4-20020a05622a004400b0042ea6541d2amr1446355qtw.61.1709641015299; Tue, 05 Mar 2024 04:16:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709641015; cv=none; d=google.com; s=arc-20160816; b=RymVOeO5r7IfRfumYG6mwQDlZVOulzQBOkhawvAi6J1NQcwAvETz0WqlhBNAqVm/CA +XIIiXkd1WMChK+4Rm0JO4LXK1e0XqTqW6ibtPb7rVp88zFHofujXOtk7i3gTPpYt32T RXeY/3uXqK+yYruAc12XwPGENQVzwhWGLI2DjoMaVLnGuH6+hgyDeJbNCwFbjZ+dP0oe eHsIBjkfGQQxDUgvwIn0rGrWbvtPwC6S8QOTnYBUaambGaPvfcci+eTx78m+VEl4pRDa lLfHfP1L6gmqI3sIZeoSGufROs70XRja8cRpWVhP9TwenMPH9G9s4cgbJFo4m00F5Io0 ydNg== 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=aJzWza4vI5yWejE/TYAdmrx2G3TCvmG5gLCl8zQLNCk=; fh=f6avZL29XgA8xpJjruaeiY/t2FUw83MgiNvVXs1rDYg=; b=IY6LWKB80HJGG4ocgYNvVO1wSyj/A+qCG+IEmYD490OfXuFwO1c02pYnQWuIXq1WqA fOOQN5EkiYVejhQJSS49aTjHsN3AyxuPhk2hhhuZX4Gv6041iIshqVDTo1mPPEwG3C2L FAcRyzo63vTYsRRKYJ2wQS+uiZweH1Fl5ZROuYnT3ZiLXymABt2AzWeIrbB8oUOfwNwK E+LvprnsNLIzqyitcnsrj3AznPgw8uIVu4eq3Bvb9leLnGFJdSuO1zaGHksBxKTJFMLT DQhHqUZffyPilCMMCQaiuqaz9urKebyfbvyQcTGdfNFX0c2XCg+myH8sjWL+IAnV2rkw 06vQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yUKXzgXm; 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 jd23-20020a05622a719700b0042ef99468bfsi3390820qtb.230.2024.03.05.04.16.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 04:16:55 -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=yUKXzgXm; 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 1rhTeZ-00048B-It; Tue, 05 Mar 2024 07:12: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 1rhTdJ-0001uV-GG for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:03 -0500 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTch-0001SW-8i for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:48 -0500 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2d26227d508so64868261fa.2 for ; Tue, 05 Mar 2024 04:10:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640616; x=1710245416; 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=aJzWza4vI5yWejE/TYAdmrx2G3TCvmG5gLCl8zQLNCk=; b=yUKXzgXmMloK5w6WEn88L/LaegaWwKuVmI6/BeQjXSxHBxt48WsvsIox6KAgfQesNW q8zPsU2MoTgY0+lDQMgPp+xw99ldvcMlmK6wkOSwWjf+G7H8GNUlmlMP9wo7XkJELEE4 7m1fi0fuEkQJVNK6SOalbfr2QRbMFXlocsDTlofaYdl+cYk2ceu9SwFeGckLyEo61RRY 7WqAOPVjqA9QuJXGcxk8wC3wjFxheoKDWxaW2eT65ymkjWbAQpr+HGtZl1nVnYX/FGfP gh+kEgKkHNNHKboYb0TOd194l+eiyNjY49HrnLoYMxsu0LZKGA7vD/4uPiHmrmIisc3X VpFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640616; x=1710245416; 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=aJzWza4vI5yWejE/TYAdmrx2G3TCvmG5gLCl8zQLNCk=; b=mPZILIJufqDE1RBphbFrp6yD9NNEKNMXm8BDfygv10WOKXX33Pzb/H3jo9Kbq4xikc CuPgSAXzKu+E9gDkh1RQ2OGMRdjT2V2m+m9ovPW1J7mI1F2gwv81oim+HbYoQUpXVSB+ nA6EBVwJTMjMyRjKHlHQMcpsqjOw25VII7hGPM8Z6fwVh1sNfyZXyUyvHXOm6lJjP8qI ItFGoHH2BtPhfMHaktRW5DnYFG/05bqklQVNORS4JfkXHEsJJWddRaM4Q4f8/dx+o8qm iPJbdvLW17FfmNI9XIRfBG1mmyJa59x6jV1SG7jcaVMv9byOxfEfyPNly8aPhRO+7CNd Zjhw== X-Gm-Message-State: AOJu0YxbNIurlq+RMhMSRQ3F4MQgKKa0HZ4R2wuIfnawR4wqMpO5XbW7 E5Tu1oLrju1JWGFkUjiTCvtxx/o+PJx62BEvGc3wm9yDA3UspB+uCjlyLYwiLZI= X-Received: by 2002:a05:6512:1054:b0:513:4ad9:a7ef with SMTP id c20-20020a056512105400b005134ad9a7efmr1316093lfb.52.1709640615995; Tue, 05 Mar 2024 04:10:15 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l22-20020a05600c4f1600b004128f41a13fsm17794983wmq.38.2024.03.05.04.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:12 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 755565F9CE; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 10/29] gdbstub: Introduce gdb_handle_set_thread_user() Date: Tue, 5 Mar 2024 12:09:46 +0000 Message-Id: <20240305121005.3528075-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x22d.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=unavailable 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 The upcoming follow-fork-mode child support needs to perform certain actions when GDB switches between the stopped parent and the stopped child. Introduce a user-specific hook for this. Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-10-iii@linux.ibm.com> Signed-off-by: Alex Bennée --- gdbstub/internals.h | 1 + gdbstub/gdbstub.c | 11 +++++++++-- gdbstub/user.c | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index e6063835b1f..b4905c7181a 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -197,6 +197,7 @@ void gdb_handle_v_file_readlink(GArray *params, void *user_ctx); /* user */ void gdb_handle_query_xfer_exec_file(GArray *params, void *user_ctx); /* user */ void gdb_handle_set_catch_syscalls(GArray *params, void *user_ctx); /* user */ void gdb_handle_query_supported_user(const char *gdb_supported); /* user */ +bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid); /* user */ void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 7be4418dcb5..3eb93162aa8 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1099,6 +1099,7 @@ static void handle_cont_with_sig(GArray *params, void *user_ctx) static void handle_set_thread(GArray *params, void *user_ctx) { + uint32_t pid, tid; CPUState *cpu; if (params->len != 2) { @@ -1116,8 +1117,14 @@ static void handle_set_thread(GArray *params, void *user_ctx) return; } - cpu = gdb_get_cpu(get_param(params, 1)->thread_id.pid, - get_param(params, 1)->thread_id.tid); + pid = get_param(params, 1)->thread_id.pid; + tid = get_param(params, 1)->thread_id.tid; +#ifdef CONFIG_USER_ONLY + if (gdb_handle_set_thread_user(pid, tid)) { + return; + } +#endif + cpu = gdb_get_cpu(pid, tid); if (!cpu) { gdb_put_packet("E22"); return; diff --git a/gdbstub/user.c b/gdbstub/user.c index c9e8b83d720..b048754c4f8 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -386,6 +386,11 @@ void gdb_handle_query_supported_user(const char *gdb_supported) { } +bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid) +{ + return false; +} + /* * Execution state helpers */