Received: by 2002:a05:7022:52b:b0:7e:eb73:5b3b with SMTP id 43csp990872dlj; Fri, 7 Jun 2024 05:00:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWJD/7RPrFC2Qz6uhlC83BX1/eg1aUMeoP9Qvh8egTm2D/W+4x2BHX7X2W+i0meINrUPha4AyCYP07YdNV1jwSq+MsLJXdg X-Google-Smtp-Source: AGHT+IGnKgTwDBJPNIyjI7S/NPQUQqMqR1gDgGd4SK9UDL/9O8WymKYfVTnHMWTy5dXgqHxXvJcD X-Received: by 2002:adf:a404:0:b0:356:6c6f:2609 with SMTP id ffacd0b85a97d-35efed3d5damr1671144f8f.17.1717761627655; Fri, 07 Jun 2024 05:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717761627; cv=none; d=google.com; s=arc-20160816; b=gKKrrG1W2dPflCgT5wVxsuITUXmx9MFBVP1ZJumF0Zx3CYtvwi3be5MY1eVHKNt3es pqOeigy4tzEZtNrsenG1EZRNiPfWIld0YRL5bfowxZZJIji/pIAh2Ox5qOAr30ZNSI7u TiZdcPCUT5NtqB4rcDJq09wPK1jlLHKwut8GcZmO4FNu3kpNw7OLJyDPbdX955x3QZEU 7g61S39gC9FqvuwkjzG36aGDeoZjGSkRlvScgzpaae4/vRdLr1zTACPkYunVRzYhLnAP NVD4I9jL99aDU2CXKzASyL4TD51SpC3DWsZ5KI0DSvL0LgXzziaJsTyQDLbg6yN5xZhq 09MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Prs/MoDPhG8YIh1BRlc3S7ddcISogZyxxjZUeOw/dPM=; fh=CjFwyFzaCSmkOKy2YiKnMv5LVRyC5Im7ETbbL0XKxCE=; b=bfIcubkkR0LknJCZFWUUBRiIg4c+/t83jaHimRX/uXkWHX/zNnI7/USqYAU9rqUjeF qb46t1K9prh95zehOiS1GlBtvwwnHZBo/crP3leJBbONvWh4YVm5qFaXHvFkFXX10jU0 UOUg06S1Pw1pccwgeJrYQWbZAPd1EzoDnXJjXua1pm6/McS72TJOwf8VwLAMR3TiDzdJ oCwBiwZhHOAQ4DuMr4cp9wiRPIAfIAV8fagPek2eu+6ji9Du7RttaTdAG6EligjAH9kt S2+ZMfOWvb88TGZn+6aMAyE00zKJeL9ZPnYaMJs1DMNFxFaKUIlt9ZEAscfH+7dZb+A2 bDjw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of salil.mehta@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=salil.mehta@huawei.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from frasgout.his.huawei.com (frasgout.his.huawei.com. [185.176.79.56]) by mx.google.com with ESMTPS id ffacd0b85a97d-35ef5e5c8afsi2044210f8f.627.2024.06.07.05.00.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Jun 2024 05:00:27 -0700 (PDT) Received-SPF: pass (google.com: domain of salil.mehta@huawei.com designates 185.176.79.56 as permitted sender) client-ip=185.176.79.56; Authentication-Results: mx.google.com; spf=pass (google.com: domain of salil.mehta@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=salil.mehta@huawei.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 From: Salil Mehta 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: 8bit Content-Type: text/plain 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) X-TUID: klh0flp6fBey 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 example, 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, } } +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 = NULL; + cpu->gdb_num_regs = 0; + cpu->gdb_num_g_regs = 0; +} + static void gdb_process_breakpoint_remove_all(GDBProcess *p) { CPUState *cpu = 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 = CPU(obj); - 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_reg, const GDBFeature *feature, int g_pos); +/** + * gdb_unregister_coprocessor_all() - unregisters supplemental set of registers + * @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 -- 2.34.1