From nobody Sun Dec 29 01:33:09 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719579187; cv=none; d=zohomail.com; s=zohoarc; b=EJuOKC3hs0KOBkAZESqCjexJN+IOXo59OUTfd60vuCjKALBS/6TfiVabreR1+Rtv0IIrpVbcIwUaZ0wHbbky4e/VrMLCeTFH448nc8S2Aa5D+y1695oLu7Quqsx9ESg+flZmrTRJOHrdrwt02cvKbWOrBifKgPjcBVWHDNoUi90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719579187; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JoliEJsSzkKhZQwY3f6Epel/jCgNkpeyE6ZHVJ+pXJo=; b=TVu/mi+zB3P+pTGkaHDCq3ALq9OZE/Ld+V44tGkb4F41ZUvBYmgLA6sxIG00KYn/P6cDGPCcgHQdHan1AZAuxavbRQ+VSiBzQrBjusw3jWY5MPieNZqAwj4C6veJ7lPrjwj5wVtsGUeltBNgRa62xf9GQTGWZk6Hkq3d3h3eai4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719579187596780.3733184742891; Fri, 28 Jun 2024 05:53:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNB5A-0002nx-CU; Fri, 28 Jun 2024 08:52:04 -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 1sNB56-0002lJ-Qe for qemu-devel@nongnu.org; Fri, 28 Jun 2024 08:52:00 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450: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 1sNB54-0007jM-V3 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 08:52:00 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a725d756d41so100776166b.0 for ; Fri, 28 Jun 2024 05:51:58 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab0900e6sm76137866b.181.2024.06.28.05.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 05:51:56 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E3A665FA3F; Fri, 28 Jun 2024 13:43:00 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719579117; x=1720183917; 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=JoliEJsSzkKhZQwY3f6Epel/jCgNkpeyE6ZHVJ+pXJo=; b=XMQTeEOWPLugiUvX2quflz//TwR2majA2URfNdIlB2CaP96pUj713uOhYRnwxL5Fav cb9MHmbTMNOlYEGpGpSY/wswD0VjWkryJLi/SJe9CimulHEyk6e0Uw+H9wHHM7Suv4L0 WuiYl+d6C/samdXsdObtHzPx3C5o++pvZwQNRBFEQhle+6s0ArwDt6+gIAI+pZIWgkp5 WZMFCgfWYTW8RoRoXot171SCp4rj5e4h+ac91fFGK8lVhLTOTrFzMwz70JnjwJwo9Bf6 oqEpmYIy7IWma08NuTJHrt8iHno9NfMlDZkFXi3Si8cEagSUKd3kKWR18pfnUP94EOum Vabw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719579117; x=1720183917; 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=JoliEJsSzkKhZQwY3f6Epel/jCgNkpeyE6ZHVJ+pXJo=; b=JkKr587oFAjjQSLb1fS5Y+1FC5dhc/HcwYr+1vFf2MxgThRQwvHdueez0+UowF6aWc GJo8lgZ9GAch/WpNq+e7sm6IffS6wDgkUv3L0YAehs3ZxZx0Ea1eZHjr34PHWQcjk+3m HNueMyUrICJkqrmMdltsVOA5mKucw8ywnZamCyJb0TZF3Zh99Q1G9BJZEBal9jErEC1j KDYtf4FG/49rZHMuSgfG2vYR4nqxd0HyYfvZlVazX+++YhufoM2O91g1absJYUE+kvLB Md4CSWEqow9eDA0sHg0akq3/pxIo/vmaehwL6mCF6ctoyaKZM4xqSk/7jE+ta/Iej5kC pbRw== X-Gm-Message-State: AOJu0Ywa/5laGQwQTnZ0vxqbxKbGL7Y+MqL90pV9McuVFkBMnwj5sdPt VJq58n5G2t/yHyQHqeQjCUJYnSoAODxB7hm9yfJxooFV0QhbN9FgDvRcdWO1KWM= X-Google-Smtp-Source: AGHT+IHML+4LeuY6guOPxLx7IJNY+hNPKhVXQYBOR4qRcH8m2ZvVdkSAAzfpmndTSCeeB3/OIGh4wg== X-Received: by 2002:a17:906:46d2:b0:a72:7bc0:efed with SMTP id a640c23a62f3a-a72aee8c5ecmr120955066b.13.1719579116902; Fri, 28 Jun 2024 05:51:56 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Beraldo Leal , Eduardo Habkost , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Wainer dos Santos Moschetta , qemu-arm@nongnu.org, Peter Xu , Mads Ynddal , Mahmoud Mandour , Pierrick Bouvier , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alexandre Iooss , Stefan Hajnoczi , Peter Maydell , Richard Henderson , Thomas Huth , Gustavo Romero Subject: [PATCH 20/23] gdbstub: Pass CPU context to command handler Date: Fri, 28 Jun 2024 13:42:55 +0100 Message-Id: <20240628124258.832466-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240628124258.832466-1-alex.bennee@linaro.org> References: <20240628124258.832466-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719579188655100007 From: Gustavo Romero Allow passing the current CPU context to command handlers via user_ctx when the handler requires it. Signed-off-by: Gustavo Romero Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240628050850.536447-9-gustavo.romero@linaro.org> --- include/gdbstub/commands.h | 3 +++ gdbstub/gdbstub.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/gdbstub/commands.h b/include/gdbstub/commands.h index e51f276b40..f3058f9dda 100644 --- a/include/gdbstub/commands.h +++ b/include/gdbstub/commands.h @@ -54,6 +54,8 @@ typedef union GdbCmdVariant { * "stop reply" packet. The list of commands that accept such response is * defined at the GDB Remote Serial Protocol documentation. See: * https://sourceware.org/gdb/onlinedocs/gdb/Stop-Reply-Packets.html#Stop-= Reply-Packets. + * + * @need_cpu_context: Pass current CPU context to command handler via user= _ctx. */ typedef struct GdbCmdParseEntry { GdbCmdHandler handler; @@ -61,6 +63,7 @@ typedef struct GdbCmdParseEntry { bool cmd_startswith; const char *schema; bool allow_stop_reply; + bool need_cpu_context; } GdbCmdParseEntry; =20 /** diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index b1ca253f97..5c1612ed2a 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -938,6 +938,7 @@ static bool process_string_cmd(const char *data, =20 for (i =3D 0; i < num_cmds; i++) { const GdbCmdParseEntry *cmd =3D &cmds[i]; + void *user_ctx =3D NULL; g_assert(cmd->handler && cmd->cmd); =20 if ((cmd->cmd_startswith && !startswith(data, cmd->cmd)) || @@ -952,8 +953,12 @@ static bool process_string_cmd(const char *data, } } =20 + if (cmd->need_cpu_context) { + user_ctx =3D (void *)gdbserver_state.g_cpu; + } + gdbserver_state.allow_stop_reply =3D cmd->allow_stop_reply; - cmd->handler(params, NULL); + cmd->handler(params, user_ctx); return true; } =20 --=20 2.39.2