Skip to contentSkip to conversation

Few minor improvements of monitor disas command (v4)

PATCH In review Fabien Chouteau 3 participants 14 messages Oct 4, 2013 – Oct 7, 2013

lore
Share & tools
lore
#11 lore raw

PATCH 4/4 Add ARM registers definitions for Monitor commands

In reply to Fabien Chouteau
---
 target-arm/Makefile.objs |    2 +-
 target-arm/cpu.c         |    7 +++++++
 target-arm/monitor.c     |   40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 target-arm/monitor.c
target-arm/Makefile.objs +1 -1
index 6453f5c..6c3ec32 100644
@@ -1,5 +1,5 @@
 obj-y += arm-semi.o
-obj-$(CONFIG_SOFTMMU) += machine.o
+obj-$(CONFIG_SOFTMMU) += machine.o monitor.o
 obj-$(CONFIG_KVM) += kvm.o
 obj-$(CONFIG_NO_KVM) += kvm-stub.o
 obj-y += translate.o op_helper.o helper.o cpu.o
target-arm/cpu.c +7 -0
index d40f2a7..bb15ee8 100644
@@ -26,6 +26,9 @@
 #include "hw/arm/arm.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
+#include "monitor/monitor_def.h"
+
+extern const MonitorDef arm_monitor_defs[];
 
 static void arm_cpu_set_pc(CPUState *cs, vaddr value)
 {
@@ -217,6 +220,10 @@ static void arm_cpu_initfn(Object *obj)
                        ARRAY_SIZE(cpu->gt_timer_outputs));
 #endif
 
+#if !defined(CONFIG_USER_ONLY)
+    cs->monitor_defs = arm_monitor_defs;
+#endif
+
     if (tcg_enabled() && !inited) {
         inited = true;
         arm_translate_init();
target-arm/monitor.c new file +40 -0
new file mode 100644
index 0000000..0d68a14
@@ -0,0 +1,40 @@
+/*
+ * ARM MonitorDef
+ *
+ * Copyright (c) 2013 AdaCore
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "monitor/monitor_def.h"
+
+const MonitorDef arm_monitor_defs[] = {
+    { "r0",     offsetof(CPUARMState, regs[0])  },
+    { "r1",     offsetof(CPUARMState, regs[1])  },
+    { "r2",     offsetof(CPUARMState, regs[2])  },
+    { "r3",     offsetof(CPUARMState, regs[3])  },
+    { "r4",     offsetof(CPUARMState, regs[4])  },
+    { "r5",     offsetof(CPUARMState, regs[5])  },
+    { "r6",     offsetof(CPUARMState, regs[6])  },
+    { "r7",     offsetof(CPUARMState, regs[7])  },
+    { "r8",     offsetof(CPUARMState, regs[8])  },
+    { "r9",     offsetof(CPUARMState, regs[9])  },
+    { "r10",    offsetof(CPUARMState, regs[10]) },
+    { "r11",    offsetof(CPUARMState, regs[11]) },
+    { "r12",    offsetof(CPUARMState, regs[12]) },
+    { "r13|sp", offsetof(CPUARMState, regs[13]) },
+    { "r14|lr", offsetof(CPUARMState, regs[14]) },
+    { "r15|pc", offsetof(CPUARMState, regs[15]) },
+    { NULL },
+};
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/4 Improve Monitor disas with symbol lookup

In reply to Fabien Chouteau
---
 disas.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
disas.c +9 -1
index 32407de..c83bf5b 100644
@@ -507,7 +507,15 @@ void monitor_disas(Monitor *mon, CPUArchState *env,
 #endif
 
     for (i = 0; i < nb_insn; i++) {
-        monitor_printf(mon, "0x" TARGET_FMT_lx ":  ", pc);
+        const char *sym = lookup_symbol(pc);
+
+        monitor_printf(mon, "0x" TARGET_FMT_lx, pc);
+        if (sym[0] != '\0') {
+            monitor_printf(mon, " <%s>:  ", sym);
+        } else {
+            monitor_printf(mon, ":  ");
+        }
+
         count = print_insn(pc, &s.info);
         monitor_printf(mon, "\n");
         if (count < 0) {
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/4 Refactoring MonitorDef array

In reply to Fabien Chouteau

Everything has been moved to cpu specific directories (SPARC, PPC, i386).

---
 include/monitor/monitor_def.h |   18 ++
 include/qemu/typedefs.h       |    1 +
 include/qom/cpu.h             |    3 +
 monitor.c                     |  396 +----------------------------------------
 target-i386/Makefile.objs     |    2 +-
 target-i386/cpu-qom.h         |    1 +
 target-i386/cpu.c             |    7 +
 target-i386/monitor.c         |   62 +++++++
 target-ppc/Makefile.objs      |    2 +-
 target-ppc/monitor.c          |  234 ++++++++++++++++++++++++
 target-ppc/translate_init.c   |    8 +
 target-sparc/Makefile.objs    |    2 +-
 target-sparc/cpu-qom.h        |    1 -
 target-sparc/cpu.c            |    7 +
 target-sparc/monitor.c        |  138 ++++++++++++++
 15 files changed, 490 insertions(+), 392 deletions(-)
 create mode 100644 include/monitor/monitor_def.h
 create mode 100644 target-i386/monitor.c
 create mode 100644 target-ppc/monitor.c
 create mode 100644 target-sparc/monitor.c
include/monitor/monitor_def.h new file +18 -0
new file mode 100644
index 0000000..7d4e3b6
@@ -0,0 +1,18 @@
+#ifndef _MONITOR_DEF_H_
+#define _MONITOR_DEF_H_
+
+#include "cpu.h"
+
+CPUArchState *mon_get_cpu(void);
+
+#define MD_TLONG 0
+#define MD_I32   1
+
+typedef struct MonitorDef {
+    const char *name;
+    int offset;
+    target_long (*get_value)(const struct MonitorDef *md, int val);
+    int type;
+} MonitorDef;
+
+#endif /* ! _MONITOR_DEF_H_ */
include/qemu/typedefs.h +1 -0
index 3205540..4465fe8 100644
@@ -13,6 +13,7 @@ typedef struct AioContext AioContext;
 struct Monitor;
 typedef struct Monitor Monitor;
 typedef struct MigrationParams MigrationParams;
+typedef struct MonitorDef MonitorDef;
 
 typedef struct Property Property;
 typedef struct PropertyInfo PropertyInfo;
include/qom/cpu.h +3 -0
index 7739e00..07ad3ee 100644
@@ -156,6 +156,7 @@ struct kvm_run;
  * @gdb_num_g_regs: Number of registers in GDB 'g' packets.
  * @next_cpu: Next CPU sharing TB cache.
  * @kvm_fd: vCPU file descriptor for KVM.
+ * @monitor_defs array of register definitions for monitor functions
  *
  * State of one CPU core or thread.
  */
@@ -198,6 +199,8 @@ struct CPUState {
     struct KVMState *kvm_state;
     struct kvm_run *kvm_run;
 
+    const MonitorDef *monitor_defs;
+
     /* TODO Move common fields from CPUArchState here. */
     int cpu_index; /* used by alpha TCG */
     uint32_t halted; /* used by alpha, cris, ppc TCG */
monitor.c +8 -388

423 lines not on this page · raw message

target-i386/Makefile.objs +1 -1
index da1fc40..839c8e6 100644
@@ -2,7 +2,7 @@ obj-y += translate.o helper.o cpu.o
 obj-y += excp_helper.o fpu_helper.o cc_helper.o int_helper.o svm_helper.o
 obj-y += smm_helper.o misc_helper.o mem_helper.o seg_helper.o
 obj-y += gdbstub.o
-obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o
+obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o monitor.o
 obj-$(CONFIG_KVM) += kvm.o
 obj-$(CONFIG_NO_KVM) += kvm-stub.o
 obj-$(CONFIG_LINUX_USER) += ioport-user.o
target-i386/cpu-qom.h +1 -0
index f4fab15..cb90123 100644
@@ -23,6 +23,7 @@
 #include "qom/cpu.h"
 #include "cpu.h"
 #include "qapi/error.h"
+#include "monitor/monitor_def.h"
 
 #ifdef TARGET_X86_64
 #define TYPE_X86_CPU "x86_64-cpu"
target-i386/cpu.c +7 -0
index b682802..616b7da 100644
@@ -22,6 +22,7 @@
 #include <inttypes.h>
 
 #include "cpu.h"
+#include "cpu-qom.h"
 #include "sysemu/kvm.h"
 #include "sysemu/cpus.h"
 #include "topology.h"
@@ -47,7 +48,9 @@
 #include "hw/xen/xen.h"
 #include "hw/i386/apic_internal.h"
 #endif
+#include "monitor/monitor_def.h"
 
+extern const MonitorDef i386_monitor_defs[];
 
 /* Cache topology CPUID constants: */
 
@@ -2664,6 +2667,10 @@ static void x86_cpu_initfn(Object *obj)
         cpu_set_debug_excp_handler(breakpoint_handler);
 #endif
     }
+
+#ifndef CONFIG_USER_ONLY
+    cs->monitor_defs = i386_monitor_defs;
+#endif
 }
 
 static int64_t x86_cpu_get_arch_id(CPUState *cs)
target-i386/monitor.c new file +62 -0

62 lines not on this page · raw message

target-ppc/Makefile.objs +1 -1
index f72e399..802eb83 100644
@@ -1,7 +1,7 @@
 obj-y += cpu-models.o
 obj-y += translate.o
 ifeq ($(CONFIG_SOFTMMU),y)
-obj-y += machine.o mmu_helper.o mmu-hash32.o
+obj-y += machine.o mmu_helper.o mmu-hash32.o monitor.o
 obj-$(TARGET_PPC64) += mmu-hash64.o
 endif
 obj-$(CONFIG_KVM) += kvm.o kvm_ppc.o
target-ppc/monitor.c new file +234 -0

234 lines not on this page · raw message

target-ppc/translate_init.c +8 -0
index d2645ba..fd97c15 100644
@@ -25,14 +25,18 @@
 #include "sysemu/arch_init.h"
 #include "sysemu/cpus.h"
 #include "cpu-models.h"
+#include "cpu-qom.h"
 #include "mmu-hash32.h"
 #include "mmu-hash64.h"
 #include "qemu/error-report.h"
+#include "monitor/monitor_def.h"
 
 //#define PPC_DUMP_CPU
 //#define PPC_DEBUG_SPR
 //#define PPC_DUMP_SPR_ACCESSES
 
+extern const MonitorDef ppc_monitor_defs[];
+
 /* For user-mode emulation, we don't emulate any IRQ controller */
 #if defined(CONFIG_USER_ONLY)
 #define PPC_IRQ_INIT_FN(name)                                                 \
@@ -8542,6 +8546,10 @@ static void ppc_cpu_initfn(Object *obj)
     }
 #endif /* defined(TARGET_PPC64) */
 
+#if !defined(CONFIG_USER_ONLY)
+    cs->monitor_defs = ppc_monitor_defs;
+#endif
+
     if (tcg_enabled()) {
         ppc_translate_init();
     }
target-sparc/Makefile.objs +1 -1
index 1cd81cc..ec90569 100644
@@ -1,4 +1,4 @@
-obj-$(CONFIG_SOFTMMU) += machine.o
+obj-$(CONFIG_SOFTMMU) += machine.o monitor.o
 obj-y += translate.o helper.o cpu.o
 obj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
 obj-$(TARGET_SPARC) += int32_helper.o
target-sparc/cpu-qom.h +0 -1
index 8e3e0de..a2b83ad 100644
@@ -21,7 +21,6 @@
 #define QEMU_SPARC_CPU_QOM_H
 
 #include "qom/cpu.h"
-#include "cpu.h"
 
 #ifdef TARGET_SPARC64
 #define TYPE_SPARC_CPU "sparc64-cpu"
target-sparc/cpu.c +7 -0
index 47ce60d..1909107 100644
@@ -18,6 +18,9 @@
  */
 
 #include "cpu.h"
+#include "monitor/monitor_def.h"
+
+extern const MonitorDef sparc_monitor_defs[];
 
 //#define DEBUG_FEATURES
 
@@ -757,6 +760,10 @@ static void sparc_cpu_initfn(Object *obj)
     cs->env_ptr = env;
     cpu_exec_init(env);
 
+#if !defined(CONFIG_USER_ONLY)
+    cs->monitor_defs = sparc_monitor_defs;
+#endif
+
     if (tcg_enabled()) {
         gen_intermediate_code_init(env);
     }
target-sparc/monitor.c new file +138 -0

138 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/4 Fix coding style

In reply to Fabien Chouteau
---
 disas.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
disas.c +6 -5
index 0203ef2..32407de 100644
@@ -506,12 +506,13 @@ void monitor_disas(Monitor *mon, CPUArchState *env,
     return;
 #endif
 
-    for(i = 0; i < nb_insn; i++) {
-	monitor_printf(mon, "0x" TARGET_FMT_lx ":  ", pc);
+    for (i = 0; i < nb_insn; i++) {
+        monitor_printf(mon, "0x" TARGET_FMT_lx ":  ", pc);
         count = print_insn(pc, &s.info);
-	monitor_printf(mon, "\n");
-	if (count < 0)
-	    break;
+        monitor_printf(mon, "\n");
+        if (count < 0) {
+            break;
+        }
         pc += count;
     }
 }
Signature · 1 line
1.7.9.5
#0 lore raw

cover Few minor improvements of monitor disas command (v4)

Another attempt. I think this is the best I can do to fulfil all comments.

Fabien Chouteau (4):
Fix coding style
Improve Monitor disas with symbol lookup Refactoring MonitorDef array
Add ARM registers definitions for Monitor commands

 disas.c                       |   19 +-
 include/monitor/monitor_def.h |   18 ++
 include/qemu/typedefs.h       |    1 +
 include/qom/cpu.h             |    3 +
 monitor.c                     |  396 +----------------------------------------
 target-arm/Makefile.objs      |    2 +-
 target-arm/cpu.c              |    7 +
 target-arm/monitor.c          |   40 +++++
 target-i386/Makefile.objs     |    2 +-
 target-i386/cpu-qom.h         |    1 +
 target-i386/cpu.c             |    7 +
 target-i386/monitor.c         |   62 +++++++
 target-ppc/Makefile.objs      |    2 +-
 target-ppc/monitor.c          |  234 ++++++++++++++++++++++++
 target-ppc/translate_init.c   |    8 +
 target-sparc/Makefile.objs    |    2 +-
 target-sparc/cpu-qom.h        |    1 -
 target-sparc/cpu.c            |    7 +
 target-sparc/monitor.c        |  138 ++++++++++++++
 19 files changed, 552 insertions(+), 398 deletions(-)
 create mode 100644 include/monitor/monitor_def.h
 create mode 100644 target-arm/monitor.c
 create mode 100644 target-i386/monitor.c
 create mode 100644 target-ppc/monitor.c
 create mode 100644 target-sparc/monitor.c
Signature · 1 line
1.7.9.5
#4 lore raw

Re: [Qemu-devel] [PATCH 3/4] Refactoring MonitorDef array

In reply to Fabien Chouteau
Quoted 22 lines · Fabien Chouteau
target-i386/cpu-qom.h +1 -0
@@ -23,6 +23,7 @@
 #include "qom/cpu.h"
 #include "cpu.h"
 #include "qapi/error.h"
+#include "monitor/monitor_def.h"
 #ifdef TARGET_X86_64
 #define TYPE_X86_CPU "x86_64-cpu"
target-i386/cpu.c +1 -0
index b682802..616b7da 100644
@@ -22,6 +22,7 @@
 #include <inttypes.h>
 
 #include "cpu.h"
+#include "cpu-qom.h"
 #include "sysemu/kvm.h"
 #include "sysemu/cpus.h"
 #include "topology.h"

target-i386/cpu.c line 53

Quoted 6 lines
target-i386/cpu.c +2 -0
@@ -47,7 +48,9 @@
 #include "hw/xen/xen.h"
 #include "hw/i386/apic_internal.h"
 #endif
+#include "monitor/monitor_def.h"
 
+extern const MonitorDef i386_monitor_defs[];

Declare this in cpu-qom.h, rather than having an
extern declaration in a .c file.

target-sparc/cpu-qom.h line 24

Quoted 7 lines
target-sparc/cpu-qom.h +0 -1
@@ -21,7 +21,6 @@
 #define QEMU_SPARC_CPU_QOM_H
 
 #include "qom/cpu.h"
-#include "cpu.h"

...why have you deleted this #include ?

target-sparc/cpu-qom.h line 26

Quoted 3 lines
target-sparc/cpu-qom.h +0 -0
 #ifdef TARGET_SPARC64
 #define TYPE_SPARC_CPU "sparc64-cpu"

thanks
-- PMM

#12 lore raw

Re: [Qemu-devel] [PATCH 4/4] Add ARM registers definitions for Monitor commands

In reply to Fabien Chouteau
Quoted 65 lines · Fabien Chouteau
---
 target-arm/Makefile.objs |    2 +-
 target-arm/cpu.c         |    7 +++++++
 target-arm/monitor.c     |   40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 target-arm/monitor.c
target-arm/Makefile.objs +1 -1
index 6453f5c..6c3ec32 100644
@@ -1,5 +1,5 @@
 obj-y += arm-semi.o
-obj-$(CONFIG_SOFTMMU) += machine.o
+obj-$(CONFIG_SOFTMMU) += machine.o monitor.o
 obj-$(CONFIG_KVM) += kvm.o
 obj-$(CONFIG_NO_KVM) += kvm-stub.o
 obj-y += translate.o op_helper.o helper.o cpu.o
target-arm/cpu.c +7 -0
index d40f2a7..bb15ee8 100644
@@ -26,6 +26,9 @@
 #include "hw/arm/arm.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
+#include "monitor/monitor_def.h"
+
+extern const MonitorDef arm_monitor_defs[];
 
 static void arm_cpu_set_pc(CPUState *cs, vaddr value)
 {
@@ -217,6 +220,10 @@ static void arm_cpu_initfn(Object *obj)
                        ARRAY_SIZE(cpu->gt_timer_outputs));
 #endif
 
+#if !defined(CONFIG_USER_ONLY)
+    cs->monitor_defs = arm_monitor_defs;
+#endif
+
     if (tcg_enabled() && !inited) {
         inited = true;
         arm_translate_init();
target-arm/monitor.c new file +14 -0
new file mode 100644
index 0000000..0d68a14
@@ -0,0 +1,40 @@
+/*
+ * ARM MonitorDef
+ *
+ * Copyright (c) 2013 AdaCore
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.

target-arm/monitor.c line 24

Quoted 10 lines
target-arm/monitor.c new file +10 -0
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "monitor/monitor_def.h"
+
+const MonitorDef arm_monitor_defs[] = {
+    { "r0",     offsetof(CPUARMState, regs[0])  },
+    { "r1",     offsetof(CPUARMState, regs[1])  },

These fields are all 32 bits, not target_long, so they need to be marked as MD_I32. (If you build an aarch64-softmmu target then it will have target_long be 64 bit but still support all the 32 bit CPUs, so it does make a difference.)

thanks
-- PMM

#5 lore raw

Re: [Qemu-devel] [PATCH 3/4] Refactoring MonitorDef array

In reply to Peter Maydell

Am 04.10.2013 19:49, schrieb Peter Maydell:

Quoted 11 lines · Fabien Chouteau

target-sparc/cpu-qom.h line 24

Quoted 8 lines
target-sparc/cpu-qom.h +0 -1
@@ -21,7 +21,6 @@
 #define QEMU_SPARC_CPU_QOM_H
 
 #include "qom/cpu.h"
-#include "cpu.h"

...why have you deleted this #include ?

That's removing a circular include, I guess. If I get it as a separate patch I would apply it immediately ... well, in quotes, sorry...

Andreas

Quoted 3 lines
Quoted 3 lines
target-sparc/cpu-qom.h +0 -0
 #ifdef TARGET_SPARC64
 #define TYPE_SPARC_CPU "sparc64-cpu"
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#6 lore raw

Re: [Qemu-devel] [PATCH 3/4] Refactoring MonitorDef array

In reply to Peter Maydell
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Fabien Chouteau

Review

Quoted 1 line
(quoted diff) +0 -0
@@ -47,7 +48,9 @@

#include "hw/xen/xen.h"
#include "hw/i386/apic_internal.h"
#endif
+#include "monitor/monitor_def.h"

Quoted 5 lines
Quoted 1 line

+extern const MonitorDef i386_monitor_defs[];

Declare this in cpu-qom.h, rather than having an
extern declaration in a .c file.

I didn't manage to do that.

Quoted 11 lines

target-sparc/cpu-qom.h line 24

Quoted 8 lines
target-sparc/cpu-qom.h +0 -1
@@ -21,7 +21,6 @@
 #define QEMU_SPARC_CPU_QOM_H
 
 #include "qom/cpu.h"
-#include "cpu.h"

...why have you deleted this #include ?

I thought I added it myself, that's why I removed it.

Signature · 1 line
Fabien Chouteau
#13 lore raw

Re: [Qemu-devel] [PATCH 4/4] Add ARM registers definitions for Monitor commands

In reply to Peter Maydell
Quoted 12 lines · Peter Maydell

target-arm/monitor.c line 24

Quoted 5 lines
target-arm/monitor.c new file +5 -0
+#include "monitor/monitor_def.h"
+
+const MonitorDef arm_monitor_defs[] = {
+    { "r0",     offsetof(CPUARMState, regs[0])  },
+    { "r1",     offsetof(CPUARMState, regs[1])  },

These fields are all 32 bits, not target_long, so they need to be marked as MD_I32. (If you build an aarch64-softmmu target then it will have target_long be 64 bit but still support all the 32 bit CPUs, so it does make a difference.)

OK, I'll mark them MD_I32.

Signature · 1 line
Fabien Chouteau
#7 lore raw

Re: [Qemu-devel] [PATCH 3/4] Refactoring MonitorDef array

In reply to Fabien Chouteau
Quoted 8 lines · Fabien Chouteau
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Fabien Chouteau

Review

Quoted 1 line
(quoted diff) +0 -0
@@ -47,7 +48,9 @@

#include "hw/xen/xen.h"
#include "hw/i386/apic_internal.h"
#endif
+#include "monitor/monitor_def.h"

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+extern const MonitorDef i386_monitor_defs[];

Declare this in cpu-qom.h, rather than having an
extern declaration in a .c file.

I didn't manage to do that.

If you just say "I couldn't make that work" with no details, there isn't much I can say beyond "try harder" :-) If you say *why* you couldn't get it to work then I'm more likely to either (a) suggest an approach that will work or
(b) accept that it really does have to be that way...

thanks
-- PMM

#8 lore raw

Re: [Qemu-devel] [PATCH 3/4] Refactoring MonitorDef array

Quoted 15 lines · Peter Maydell
Quoted 14 lines · Fabien Chouteau
Quoted 12 lines · Peter Maydell

target-i386/cpu.c line 53

Quoted 7 lines · Fabien Chouteau

Review

Quoted 1 line
(quoted diff) +0 -0
@@ -47,7 +48,9 @@

#include "hw/xen/xen.h"
#include "hw/i386/apic_internal.h"
#endif

target-i386/cpu.c +2 -0
+#include "monitor/monitor_def.h"
 
+extern const MonitorDef i386_monitor_defs[];

Declare this in cpu-qom.h, rather than having an
extern declaration in a .c file.

Quoted 8 lines
Quoted 1 line

I didn't manage to do that.

If you just say "I couldn't make that work" with no details, there isn't much I can say beyond "try harder" :-) If you say *why* you couldn't get it to work then I'm more likely to either (a) suggest an approach that will work or
(b) accept that it really does have to be that way...

Sorry I sent the email too quickly. It looks like a circular dependency

In file included from /home/chouteau/src/qemu-main/target-arm/cpu.h:294:0,
from /home/chouteau/src/qemu-main/include/monitor/monitor_def.h:4, from /home/chouteau/src/qemu-main/target-arm/monitor.c:20:
/home/chouteau/src/qemu-main/target-arm/cpu-qom.h:184:25: error: array type has incomplete element type make[1]: *** [target-arm/monitor.o] Error 1

monitor_def.h -> cpu.h -> cpu-qom.h -.
^ |
|__________________________________/

Signature · 1 line
Fabien Chouteau
#9 lore raw

Re: [Qemu-devel] [PATCH 3/4] Refactoring MonitorDef array

Quoted 9 lines · Fabien Chouteau
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Fabien Chouteau
Quoted 5 lines · Peter Maydell
Quoted 1 line · Fabien Chouteau

+extern const MonitorDef i386_monitor_defs[];

Declare this in cpu-qom.h, rather than having an
extern declaration in a .c file.

Quoted 7 lines

Sorry I sent the email too quickly. It looks like a circular dependency

In file included from /home/chouteau/src/qemu-main/target-arm/cpu.h:294:0,
from /home/chouteau/src/qemu-main/include/monitor/monitor_def.h:4, from /home/chouteau/src/qemu-main/target-arm/monitor.c:20:
/home/chouteau/src/qemu-main/target-arm/cpu-qom.h:184:25: error: array type has incomplete element type make[1]: *** [target-arm/monitor.o] Error 1

I think you should be able to declare it as
extern const MonitorDef *i386_monitor_defs;

then you don't need to include monitor_def.h from cpu-qom.h. (untested, but the typedef should be sufficient for this)

-- PMM

#10 lore raw

Re: [Qemu-devel] [PATCH 3/4] Refactoring MonitorDef array

Quoted 18 lines · Peter Maydell
Quoted 9 lines · Fabien Chouteau
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Fabien Chouteau
Quoted 5 lines · Peter Maydell
Quoted 1 line · Fabien Chouteau

+extern const MonitorDef i386_monitor_defs[];

Declare this in cpu-qom.h, rather than having an
extern declaration in a .c file.

Quoted 7 lines

Sorry I sent the email too quickly. It looks like a circular dependency

In file included from /home/chouteau/src/qemu-main/target-arm/cpu.h:294:0,
from /home/chouteau/src/qemu-main/include/monitor/monitor_def.h:4, from /home/chouteau/src/qemu-main/target-arm/monitor.c:20:
/home/chouteau/src/qemu-main/target-arm/cpu-qom.h:184:25: error: array type has incomplete element type make[1]: *** [target-arm/monitor.o] Error 1

Quoted 6 lines

I think you should be able to declare it as
extern const MonitorDef *i386_monitor_defs;

then you don't need to include monitor_def.h from cpu-qom.h. (untested, but the typedef should be sufficient for this)

/home/chouteau/src/qemu-main/target-arm/monitor.c:22:19: error: conflicting types for ‘arm_monitor_defs’ /home/chouteau/src/qemu-main/target-arm/cpu-qom.h:183:26: note: previous declaration of ‘arm_monitor_defs’ was here

cpu-qom.h is indirectly included in target-arm/monitor.c

Signature · 1 line
Fabien Chouteau