From: Wen Congyang <we...@cn.fujitsu.com> Subject: Re: [RFC][PATCH 06/14 v7] target-i386: Add API to write cpu status to core file Date: Thu, 01 Mar 2012 13:05:31 +0800
> At 03/01/2012 01:01 PM, HATAYAMA Daisuke Wrote: >> From: Wen Congyang <we...@cn.fujitsu.com> >> Subject: [RFC][PATCH 06/14 v7] target-i386: Add API to write cpu status to >> core file >> Date: Thu, 01 Mar 2012 10:48:17 +0800 >> >>> +struct QEMUCPUState { >>> + uint32_t version; >>> + uint32_t size; >>> + uint64_t rax, rbx, rcx, rdx, rsi, rdi, rsp, rbp; >>> + uint64_t r8, r9, r10, r11, r12, r13, r14, r15; >>> + uint64_t rip, rflags; >>> + QEMUCPUSegment cs, ds, es, fs, gs, ss; >>> + QEMUCPUSegment ldt, tr, gdt, idt; >>> + uint64_t cr[5]; >>> +}; >>> + >>> +typedef struct QEMUCPUState QEMUCPUState; >> <cut> >>> +static void qemu_get_cpustate(QEMUCPUState *s, CPUState *env) >>> +{ >>> + memset(s, 0, sizeof(QEMUCPUState)); >>> + >>> + s->version = 1; >> >> It seems to me better to prepare a macro: >> >> #define QEMUCPUSTATE_VERSION (1) >> >> and use it as: >> >> s->version = QEMUCPUSTATE_VERSION; >> >> and add comment above the macro definition indicating: please count up >> QEMUCPUSTATE_VERSION if you have changed definition of QEMUCPUState, >> and modify the tools using this information accordingly. > > Yes, I will fix it. > > PS: Do you have any comment about QEMUCPUState? I think the content is enough > to calculate phys_base now. > Yes, for the purpose it might be enough. But looking at CPUX86State, there are still useful states for debugging to know guest machine state at crash, such as device states, NMI states, TSC, etc. For now, I think it's OK to pick up minimum kinds of registers only. If they are classified sufficiently in their types such as general registers, floating-point registers, control registers, processor features and so on, it's possible to add new note later easily. Thanks. HATAYAMA, Daisuke