qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC][PATCH 06/14 v7] target-i386: Add API to write cpu


From: HATAYAMA Daisuke
Subject: Re: [Qemu-devel] [RFC][PATCH 06/14 v7] target-i386: Add API to write cpu status to core file
Date: Thu, 01 Mar 2012 14:10:30 +0900 ( )

From: Wen Congyang <address@hidden>
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

> +int cpu_write_elf64_qemunote(write_core_dump_function f, CPUState *env,
> +                             target_phys_addr_t *offset, void *opaque)
> +{
> +    QEMUCPUState state;
> +    Elf64_Nhdr *note;
> +    char *buf;
> +    int descsz, note_size, name_size = 5;
> +    const char *name = "QEMU";
> +    int ret;
> +
> +    qemu_get_cpustate(&state, env);
> +
> +    descsz = sizeof(state);
> +    note_size = ((sizeof(Elf32_Nhdr) + 3) / 4 + (name_size + 3) / 4 +
> +                (descsz + 3) / 4) * 4;
> +    note = g_malloc(note_size);
> +
> +    memset(note, 0, note_size);
> +    note->n_namesz = cpu_to_le32(name_size);
> +    note->n_descsz = cpu_to_le32(descsz);
> +    note->n_type = 0;
> +    buf = (char *)note;
> +    buf += ((sizeof(Elf32_Nhdr) + 3) / 4) * 4;
> +    memcpy(buf, name, name_size);
> +    buf += ((name_size + 3) / 4) * 4;
> +    memcpy(buf, &state, sizeof(state));

x86_64_write_elf64_note() and x86_write_elf64_note() does the same
processing for note data. Is it better to do this in helper functions
in common?

Thanks.
HATAYAMA, Daisuke




reply via email to

[Prev in Thread] Current Thread [Next in Thread]