From nobody Thu Sep 19 00:19:12 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=1719552159; cv=none; d=zohomail.com; s=zohoarc; b=mi5lYKbqIkmCPyZVGh3MNtCRzCjlZyNwWwLRwWiZ1Dw3KtWWAh7EENDvtJslWgNQD+Q5jNPzyS433ZJQ2TeHumVkvRAm6F5aOJTcZYPOUAZy2PpZ2gePFOZ0CBxApmHEm/PQL72yYzBV4ae+QjakLpyQ49R94cmOJUYX9Ek7hsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719552159; 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=XGUVEgkOZ1Z9CgRBWiCr397XSqS24XQydg1qjtX54Dk=; b=cL2We/huVzs3yVUhY+lwsk3ox0V43VgKyaioAz17Ix/Jqvj4w6Ed5NAipSmGcHsjCk2HV6W01wW1lbG1GmB/yfPthx+1vCNpGBTxYL0OTsnfbWi90vsoLPRHSUznEWg67+Mvg1t0zKT6Zt3Pi+uFcZB57WV/+TU8As5in8pXGDc= 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 1719552159488164.09609700578278; Thu, 27 Jun 2024 22:22:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN430-0003JR-70; Fri, 28 Jun 2024 01:21:22 -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 1sN42z-0003J9-4g for qemu-devel@nongnu.org; Fri, 28 Jun 2024 01:21:21 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN42x-0008F3-CZ for qemu-devel@nongnu.org; Fri, 28 Jun 2024 01:21:20 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-706b539fcaeso962959b3a.0 for ; Thu, 27 Jun 2024 22:21:18 -0700 (PDT) Received: from amd.. ([2804:7f0:b401:391e:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-72c6b2a16cdsm423932a12.46.2024.06.27.22.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 22:21:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719552077; x=1720156877; 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=XGUVEgkOZ1Z9CgRBWiCr397XSqS24XQydg1qjtX54Dk=; b=XojL8uT9AorwwpFZt46x1rmnnQFHbdKTwt91GJnfO0SGAbpDzRbvrdESZzVjgVM5XH hMZ8MzdK26LRBDNfZgnKkHQ3rWFxAx5XvtAogqRai5DwVnDQJQf5aOUtarH+QxsApM6d CyDq4UQse9VUgodORjdX1cDAVH4BvVQYAgtr5yoLgjTRzSxvWt9dBX0fdzbUSkCvKcww ozjNlGx+ngkHsp/Lr49KfsfhrCkBWSsbFKj73LH+ItZQC+VIg0yWH5qH8GChgGKyEpwW pv+lWi7LlBBbKaiz9Xb4mXcbkrWIBJocKS9mN1aW3+0lH95xirq1Xnqj59UwRXlLGoxh TEiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719552077; x=1720156877; 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=XGUVEgkOZ1Z9CgRBWiCr397XSqS24XQydg1qjtX54Dk=; b=wWFlH5+KfDSmxpmoavNk2oVsBeaIUlNVTpVcRzpvceppjLnrFG2SkSOp/QfDiD9V72 iQH999MiJXMMRcTZjHPum75wDodmRnWFJrEBWA37ZUnNSU2saOQdBllvdqehj84CvFli icqtnRWbOw/8TEaeLjSKuBD+TlsCVlxeXYj3LXT6k8qlTJN7OSIqKLnPl1HWBgqO3NeZ zDjyZe3wi282kG6vE3IkaszfKFiKf6XMFeNcsQY/3h4SSYnaFgAGxAs8jUwBXquLXiAa Et7fSAwg4wiQubBPCQv8rOGg7HVdHr5bakV11URj7jV1yrNQyLf6JmqyPqnuUU8rA36a mTmQ== X-Gm-Message-State: AOJu0Yxy+m6vvrELqF6IRQCIUXFGSUOyFHQJC4/70hjGT6sjanwUMfD7 cLxeVD0CIg+BGH5MxQlgi7QFicO2Ep1Jk6KnRsGKAnnq9rBXQzBniSt8dIKzAgWQNbvWkwriAAR d X-Google-Smtp-Source: AGHT+IFZULnETnfSGnOWwoTK+dDuN0O484NOA+L2o9juqbeAB07d9F52kVpPr7R5az1JXc3+tfgAtg== X-Received: by 2002:a05:6a20:3d89:b0:1bd:2aaf:4764 with SMTP id adf61e73a8af0-1bee47d4c9fmr1396826637.0.1719552077307; Thu, 27 Jun 2024 22:21:17 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, philmd@linaro.org, alex.bennee@linaro.org, richard.henderson@linaro.org Cc: peter.maydell@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v6 08/11] gdbstub: Pass CPU context to command handler Date: Fri, 28 Jun 2024 05:08:47 +0000 Message-Id: <20240628050850.536447-9-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240628050850.536447-1-gustavo.romero@linaro.org> References: <20240628050850.536447-1-gustavo.romero@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=2607:f8b0:4864:20::435; envelope-from=gustavo.romero@linaro.org; helo=mail-pf1-x435.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: 1719552161113100001 Allow passing the current CPU context to command handlers via user_ctx when the handler requires it. Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Gustavo Romero --- gdbstub/gdbstub.c | 7 ++++++- include/gdbstub/commands.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 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 /** --=20 2.34.1