From nobody Tue Feb 10 05:45:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1717761768; cv=none; d=zohomail.com; s=zohoarc; b=H2ovaE47pgng91vgpA5Nq1J10DV7xwyz/KVaUjtfwIpy9NN6XtHXJE/cXMquhFDqnAJSGuS0ZApQ1v9N0Gw1xrb+ktVAiRRGr/t8RM3FEgp1TfQOZguQp0ADRtkY1f17Z2VhQHVTCJYb9CunL0l6KoU3lAM8jsnAdIiGhpUIRwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717761768; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=Prs/MoDPhG8YIh1BRlc3S7ddcISogZyxxjZUeOw/dPM=; b=hoXsH8PvtBSlRzgqprA8zhZ51qoGYFJ9vSC0URRx8S8UrOMdae2nEMC3vjIhwWYP6hge0RDC8yG3reSsszN6Ldkw53qweR8FVPr5/wewHgr4RUO1gxbLsY4SjdpkK3frgPht19j7y95sMI9f6l773k/60XMrJq5vNcaPllzbiOc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=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 171776176821571.20472264742784; Fri, 7 Jun 2024 05:02:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFYIX-0007zf-DM; Fri, 07 Jun 2024 08:02:24 -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 1sFYGl-0006FR-KE; Fri, 07 Jun 2024 08:00:32 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFYGi-0001DQ-Sj; Fri, 07 Jun 2024 08:00:30 -0400 Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4VwfmL1qj5z6HJqt; Fri, 7 Jun 2024 19:56:02 +0800 (CST) Received: from lhrpeml500001.china.huawei.com (unknown [7.191.163.213]) by mail.maildlp.com (Postfix) with ESMTPS id 37E8814025A; Fri, 7 Jun 2024 20:00:26 +0800 (CST) Received: from 00293818-MRGF.china.huawei.com (10.48.147.102) by lhrpeml500001.china.huawei.com (7.191.163.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 7 Jun 2024 13:00:03 +0100 To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Shaoqin Huang , Zhao Liu Subject: [PATCH V13 7/8] gdbstub: Add helper function to unregister GDB register space Date: Fri, 7 Jun 2024 12:56:48 +0100 Message-ID: <20240607115649.214622-8-salil.mehta@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240607115649.214622-1-salil.mehta@huawei.com> References: <20240607115649.214622-1-salil.mehta@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.48.147.102] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To lhrpeml500001.china.huawei.com (7.191.163.213) 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=185.176.79.56; envelope-from=salil.mehta@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Reply-to: Salil Mehta From: Salil Mehta via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1717761770382100003 Content-Type: text/plain; charset="utf-8" Add common function to help unregister the GDB register space. This shall be done in context to the CPU unrealization. Note: These are common functions exported to arch specific code. For exampl= e, for ARM this code is being referred in associated arch specific patch-set: Link: https://lore.kernel.org/qemu-devel/20230926103654.34424-1-salil.mehta= @huawei.com/ Signed-off-by: Salil Mehta Tested-by: Vishnu Pajjuri Reviewed-by: Gavin Shan Tested-by: Xianglai Li Tested-by: Miguel Luis Reviewed-by: Shaoqin Huang Reviewed-by: Vishnu Pajjuri Tested-by: Zhao Liu --- gdbstub/gdbstub.c | 13 +++++++++++++ hw/core/cpu-common.c | 1 - include/exec/gdbstub.h | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index b3574997ea..1949b09240 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -617,6 +617,19 @@ void gdb_register_coprocessor(CPUState *cpu, } } =20 +void gdb_unregister_coprocessor_all(CPUState *cpu) +{ + /* + * Safe to nuke everything. GDBRegisterState::xml is static const char= so + * it won't be freed + */ + g_array_free(cpu->gdb_regs, true); + + cpu->gdb_regs =3D NULL; + cpu->gdb_num_regs =3D 0; + cpu->gdb_num_g_regs =3D 0; +} + static void gdb_process_breakpoint_remove_all(GDBProcess *p) { CPUState *cpu =3D gdb_get_first_cpu_in_process(p); diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 0f0a247f56..e5140b4bc1 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -274,7 +274,6 @@ static void cpu_common_finalize(Object *obj) { CPUState *cpu =3D CPU(obj); =20 - g_array_free(cpu->gdb_regs, TRUE); qemu_lockcnt_destroy(&cpu->in_ioctl_lock); qemu_mutex_destroy(&cpu->work_mutex); } diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index eb14b91139..249d4d4bc8 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -49,6 +49,12 @@ void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_r= eg, const GDBFeature *feature, int g_pos); =20 +/** + * gdb_unregister_coprocessor_all() - unregisters supplemental set of regi= sters + * @cpu - the CPU associated with registers + */ +void gdb_unregister_coprocessor_all(CPUState *cpu); + /** * gdbserver_start: start the gdb server * @port_or_device: connection spec for gdb --=20 2.34.1