Hi

On Thu, Aug 20, 2026 at 6:40 PM Philippe Mathieu-Daudé
<[email protected]> wrote:
>
> On 16/8/26 21:13, Marc-André Lureau wrote:
> > Guard SysemuCPUOps::monitor_defs field and the per-target MonitorDef
> > arrays with CONFIG_HMP. These tables are only used by HMP 'print' and
> > 'info registers' commands.
> >
> > Signed-off-by: Marc-André Lureau <[email protected]>
> > ---
> >   include/hw/core/sysemu-cpu-ops.h | 2 ++
> >   monitor/hmp.c                    | 4 +++-
> >   target/i386/cpu.c                | 4 ++++
> >   target/m68k/cpu.c                | 4 ++++
> >   target/sparc/cpu.c               | 5 +++--
> >   5 files changed, 16 insertions(+), 3 deletions(-)
> >
> > diff --git a/include/hw/core/sysemu-cpu-ops.h 
> > b/include/hw/core/sysemu-cpu-ops.h
> > index 9a45596169a3..e56eea18b785 100644
> > --- a/include/hw/core/sysemu-cpu-ops.h
> > +++ b/include/hw/core/sysemu-cpu-ops.h
> > @@ -109,11 +109,13 @@ typedef struct SysemuCPUOps {
> >        */
> >       int (*monitor_get_register)(CPUState *cs, const char *name, int64_t 
> > *pval);
> >
> > +#ifdef CONFIG_HMP
> >       /**
> >        * @monitor_defs: Array of MonitorDef entries. This field is legacy,
> >        *                use @gdb_core_xml_file to dump registers instead.
> >        */
> >       const MonitorDef *monitor_defs;
> > +#endif
> >
> >       /**
> >        * @legacy_vmsd: Legacy state for migration.
> > diff --git a/monitor/hmp.c b/monitor/hmp.c
> > index e5f8b9c576e0..3c70adcd35bb 100644
> > --- a/monitor/hmp.c
> > +++ b/monitor/hmp.c
> > @@ -1725,13 +1725,15 @@ void monitor_register_hmp_info_hrt(const char *name,
> >   static int get_monitor_def(MonitorHMP *hmp, int64_t *pval, const char 
> > *name)
> >   {
> >       CPUState *cs = monitor_hmp_get_cpu(hmp);
> > -    const MonitorDef *md;
> > +    const MonitorDef *md = NULL;
> >       void *ptr;
> >
> >       if (cs == NULL) {
> >           return -1;
> >       }
> > +#ifdef CONFIG_HMP
> >       md = cs->cc->sysemu_ops->monitor_defs;
> > +#endif
> >       if (md == NULL) {
> >           return -1;
> >       }
> Logically we need to skip more:
>
> -- >8 --
> diff --git a/monitor/hmp.c b/monitor/hmp.c
> index 22b1972d346..cb4e070fc4c 100644
> --- a/monitor/hmp.c
> +++ b/monitor/hmp.c
> @@ -1726,12 +1726,13 @@ void monitor_register_hmp_info_hrt(const char *name,
>   static int get_monitor_def(Monitor *mon, int64_t *pval, const char *name)
>   {
>       CPUState *cs = mon_get_cpu(mon);
> -    const MonitorDef *md;
> +    const MonitorDef *md = NULL;
>       void *ptr;
>
>       if (cs == NULL) {
>           return -1;
>       }
> +#ifdef CONFIG_HMP
>       md = cs->cc->sysemu_ops->monitor_defs;
>       if (md == NULL) {
>           return -1;
> @@ -1749,6 +1750,7 @@ static int get_monitor_def(Monitor *mon, int64_t
> *pval, const char *name)
>               return 0;
>           }
>       }
> +#endif
>

Yeah, I will add a note, the #ifdef is removed again with "build-sys:
make HMP source files conditional on have_hmp"

Reply via email to