> From: Gavin Shan <gs...@redhat.com> > Sent: Tuesday, October 3, 2023 4:17 AM > To: Salil Mehta <salil.me...@huawei.com>; qemu-devel@nongnu.org; qemu- > a...@nongnu.org > Cc: m...@kernel.org; jean-phili...@linaro.org; Jonathan Cameron > <jonathan.came...@huawei.com>; lpieral...@kernel.org; > peter.mayd...@linaro.org; richard.hender...@linaro.org; > imamm...@redhat.com; andrew.jo...@linux.dev; da...@redhat.com; > phi...@linaro.org; eric.au...@redhat.com; oliver.up...@linux.dev; > pbonz...@redhat.com; m...@redhat.com; w...@kernel.org; raf...@kernel.org; > alex.ben...@linaro.org; li...@armlinux.org.uk; > dar...@os.amperecomputing.com; il...@os.amperecomputing.com; > vis...@os.amperecomputing.com; karl.heub...@oracle.com; > miguel.l...@oracle.com; salil.me...@opnsrc.net; zhukeqian > <zhukeqi...@huawei.com>; wangxiongfeng (C) <wangxiongfe...@huawei.com>; > wangyanan (Y) <wangyana...@huawei.com>; jiakern...@gmail.com; > maob...@loongson.cn; lixiang...@loongson.cn; Linuxarm <linux...@huawei.com> > Subject: Re: [PATCH V2 09/10] gdbstub: Add helper function to unregister > GDB register space > > > On 9/30/23 10:19, Salil Mehta wrote: > > Add common function to help unregister the GDB Register Space. This shall > be > > done in context to the CPU unrealization. > > > > Signed-off-by: Salil Mehta <salil.me...@huawei.com> > > --- > > gdbstub/gdbstub.c | 14 ++++++++++++++ > > include/exec/gdbstub.h | 5 +++++ > > 2 files changed, 19 insertions(+) > > > > With the following nits addressed: > > Reviewed-by: Gavin Shan <gs...@redhat.com> > > > diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c > > index 349d348c7b..89ac0edfea 100644 > > --- a/gdbstub/gdbstub.c > > +++ b/gdbstub/gdbstub.c > > @@ -491,6 +491,20 @@ void gdb_register_coprocessor(CPUState *cpu, > > } > > } > > > > +void gdb_unregister_coprocessor_all(CPUState *cpu) > > +{ > > + GDBRegisterState *s, *p; > > + > > + p = cpu->gdb_regs; > > + while (p) { > > + s = p; > > + p = p->next; > > + /* s->xml is static const char so isn't freed */ > ^^^ > string so that it needn't be freed > > + g_free(s); > > + } > > + cpu->gdb_regs = NULL; > > +} > > + > > For consistency, CPUState::gdb_num_regs and CPUState::gdb_num_g_regs > need to be updated accordingly, even the CPU instance will be destroyed > shortly.
Good point. Thanks Salil.