target: guard MonitorDef tables with CONFIG_HMP
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. Note that the #ifdef in hmp.c is not optimal, but will be removed later once the unit is built conditionally. Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260828-qemu-no-hmp-v5-42-9227de146347@redhat.com>
Marc-André Lureau committed
Aug 28, 2026 at 16:04 UTC
8b6882066703926b01fa419012e982ba1343969b
5 files changed
+16
-3
include/hw/core/sysemu-cpu-ops.h
+2
@@ -109,11 +109,13 @@ typedef struct SysemuCPUOps {
109
*/
110
int (*monitor_get_register)(CPUState *cs, const char *name, int64_t *pval);
111
112
+#ifdef CONFIG_HMP
113
/**
114
* @monitor_defs: Array of MonitorDef entries. This field is legacy,
115
* use @gdb_core_xml_file to dump registers instead.
116
*/
117
const MonitorDef *monitor_defs;
118
+#endif
119
120
/**
121
* @legacy_vmsd: Legacy state for migration.
monitor/hmp.c
+3
-1
@@ -1725,13 +1725,15 @@ void monitor_register_hmp_info_hrt(const char *name,
1725
static int get_monitor_def(MonitorHMP *hmp, int64_t *pval, const char *name)
1726
{
1727
CPUState *cs = monitor_hmp_get_cpu(hmp);
1728
- const MonitorDef *md;
1728
+ const MonitorDef *md = NULL;
1729
void *ptr;
1730
1731
if (cs == NULL) {
1732
return -1;
1733
}
1734
+#ifdef CONFIG_HMP
1735
md = cs->cc->sysemu_ops->monitor_defs;
1736
+#endif
1737
if (md == NULL) {
1738
return -1;
1739
}
target/i386/cpu.c
+4
@@ -10853,6 +10853,7 @@ static const Property x86_cpu_properties[] = {
10853
10854
#ifndef CONFIG_USER_ONLY
10855
10856
+#ifdef CONFIG_HMP
10857
static int64_t monitor_get_pc(MonitorHMP *hmp, const struct MonitorDef *md,
10858
int offset)
10859
{
@@ -10878,6 +10879,7 @@ static const MonitorDef x86_monitor_defs[] = {
10879
{ NULL },
10880
#undef SEG
10881
};
10882
+#endif
10883
10884
#include "hw/core/sysemu-cpu-ops.h"
10885
@@ -10892,7 +10894,9 @@ static const struct SysemuCPUOps i386_sysemu_ops = {
10894
.write_elf64_note = x86_cpu_write_elf64_note,
10895
.write_elf32_qemunote = x86_cpu_write_elf32_qemunote,
10896
.write_elf64_qemunote = x86_cpu_write_elf64_qemunote,
10897
+#ifdef CONFIG_HMP
10898
.monitor_defs = x86_monitor_defs,
10899
+#endif
10900
.legacy_vmsd = &vmstate_x86_cpu,
10901
};
10902
#endif
target/m68k/cpu.c
+4
@@ -666,6 +666,7 @@ static const VMStateDescription vmstate_m68k_cpu = {
666
},
667
};
668
669
+#ifdef CONFIG_HMP
670
static const MonitorDef m68k_monitor_defs[] = {
671
{ "ssp", offsetof(CPUM68KState, sp[0]) },
672
{ "usp", offsetof(CPUM68KState, sp[1]) },
@@ -681,13 +682,16 @@ static const MonitorDef m68k_monitor_defs[] = {
682
{ "mmusr", offsetof(CPUM68KState, mmu.mmusr) },
683
{ NULL },
684
};
685
+#endif
686
687
#include "hw/core/sysemu-cpu-ops.h"
688
689
static const struct SysemuCPUOps m68k_sysemu_ops = {
690
.has_work = m68k_cpu_has_work,
691
.get_phys_addr_debug = m68k_cpu_get_phys_addr_debug,
692
+#ifdef CONFIG_HMP
693
.monitor_defs = m68k_monitor_defs,
694
+#endif
695
};
696
#endif /* !CONFIG_USER_ONLY */
697
target/sparc/cpu.c
+3
-2
@@ -997,7 +997,7 @@ static const Property sparc_cpu_properties[] = {
997
998
#ifdef TARGET_SPARC64
999
#include "monitor/hmp.h"
1000
-
1000
+#ifdef CONFIG_HMP
1001
static const MonitorDef sparc64_monitor_defs[] = {
1002
{ "asi", offsetof(CPUSPARCState, asi) },
1003
{ "pstate", offsetof(CPUSPARCState, pstate) },
@@ -1009,6 +1009,7 @@ static const MonitorDef sparc64_monitor_defs[] = {
1009
{ NULL },
1010
};
1011
#endif
1012
+#endif
1013
1014
#include "hw/core/sysemu-cpu-ops.h"
1015
@@ -1016,7 +1017,7 @@ static const struct SysemuCPUOps sparc_sysemu_ops = {
1017
.has_work = sparc_cpu_has_work,
1018
.get_phys_addr_debug = sparc_cpu_get_phys_addr_debug,
1019
.legacy_vmsd = &vmstate_sparc_cpu,
1019
-#if defined(TARGET_SPARC64)
1020
+#if defined(TARGET_SPARC64) && defined(CONFIG_HMP)
1021
.monitor_defs = sparc64_monitor_defs,
1022
#endif
1023
};