qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC][PATCH 08/16 v6] target-i386: add API to get dump


From: Peter Maydell
Subject: Re: [Qemu-devel] [RFC][PATCH 08/16 v6] target-i386: add API to get dump info
Date: Wed, 15 Feb 2012 09:12:48 +0000

On 9 February 2012 03:26, Wen Congyang <address@hidden> wrote:
> +int cpu_get_dump_info(ArchDumpInfo *info)
> +{
> +    bool lma = false;
> +    RAMBlock *block;
> +
> +#ifdef TARGET_X86_64
> +    lma = !!(first_cpu->hflags & HF_LMA_MASK);
> +#endif
> +
> +    if (lma) {
> +        info->d_machine = EM_X86_64;
> +    } else {
> +        info->d_machine = EM_386;
> +    }
> +    info->d_endian = ELFDATA2LSB;
> +
> +    if (lma) {
> +        info->d_class = ELFCLASS64;
> +    } else {
> +        info->d_class = ELFCLASS32;
> +    }
> +
> +    QLIST_FOREACH(block, &ram_list.blocks, next) {
> +        if (!lma && (block->offset + block->length > UINT_MAX)) {
> +            /* The memory size is greater than 4G */
> +            info->d_class = ELFCLASS32;
> +            break;
> +        }
> +    }

I think it would be cleaner to have a single
  if (lma) {
     stuff;
  } else {
     stuff;
  }

rather than checking it three times, especially for
the loop, where if lma is true we'll walk the ram_list
without ever doing anything.

-- PMM



reply via email to

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