qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] disas: Fix printing of addresses in disassembly
Date: Mon, 09 Jul 2012 14:45:22 +0200	[thread overview]
Message-ID: <4FFAD262.6040204@suse.de> (raw)
In-Reply-To: <CAFEAcA8x8zeRbTVA45nfV+KmStS0EcTNo=VewYadOhBZStDe7g@mail.gmail.com>

Am 09.07.2012 12:27, schrieb Peter Maydell:
> Ping? [patchwork url http://patchwork.ozlabs.org/patch/167132/]
> 
> -- PMM
> 
> On 25 June 2012 15:55, Peter Maydell <peter.maydell@linaro.org> wrote:
>> In our disassembly code, the bfd_vma type is always 64 bits,
>> even if the target's virtual address width is only 32 bits. This
>> means that when we print out addresses we need to truncate them
>> to 32 bits, to avoid odd output which has incorrectly sign-extended
>> a value to 64 bits, for instance this ARM example:
>>     0x80479a60:  e59f4088     ldr  r4, [pc, #136]  ; 0xffffffff80479a4f
>>
>> (It would also be possible to truncate before passing the address
>> to info->print_address_func(), but truncating in the final print
>> function is the same approach that binutils takes to this problem.)

Is this bug fixed in binutils and didn't make it into QEMU due to GPLv3?
Or is this in QEMU glue code?

Andreas

>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>  disas.c |   19 +++++++++++++++++++
>>  1 files changed, 19 insertions(+), 0 deletions(-)
>>
>> diff --git a/disas.c b/disas.c
>> index 93d8d30..7b2acc9 100644
>> --- a/disas.c
>> +++ b/disas.c
>> @@ -64,6 +64,22 @@ generic_print_address (bfd_vma addr, struct disassemble_info *info)
>>      (*info->fprintf_func) (info->stream, "0x%" PRIx64, addr);
>>  }
>>
>> +/* Print address in hex, truncated to the width of a target virtual address. */
>> +static void
>> +generic_print_target_address(bfd_vma addr, struct disassemble_info *info)
>> +{
>> +    uint64_t mask = ~0ULL >> (64 - TARGET_VIRT_ADDR_SPACE_BITS);
>> +    generic_print_address(addr & mask, info);
>> +}
>> +
>> +/* Print address in hex, truncated to the width of a host virtual address. */
>> +static void
>> +generic_print_host_address(bfd_vma addr, struct disassemble_info *info)
>> +{
>> +    uint64_t mask = ~0ULL >> (64 - (sizeof(void *) * 8));
>> +    generic_print_address(addr & mask, info);
>> +}
>> +
>>  /* Just return the given address.  */
>>
>>  int
>> @@ -154,6 +170,7 @@ void target_disas(FILE *out, target_ulong code, target_ulong size, int flags)
>>      disasm_info.read_memory_func = target_read_memory;
>>      disasm_info.buffer_vma = code;
>>      disasm_info.buffer_length = size;
>> +    disasm_info.print_address_func = generic_print_target_address;
>>
>>  #ifdef TARGET_WORDS_BIGENDIAN
>>      disasm_info.endian = BFD_ENDIAN_BIG;
>> @@ -274,6 +291,7 @@ void disas(FILE *out, void *code, unsigned long size)
>>      int (*print_insn)(bfd_vma pc, disassemble_info *info);
>>
>>      INIT_DISASSEMBLE_INFO(disasm_info, out, fprintf);
>> +    disasm_info.print_address_func = generic_print_host_address;
>>
>>      disasm_info.buffer = code;
>>      disasm_info.buffer_vma = (uintptr_t)code;
>> @@ -386,6 +404,7 @@ void monitor_disas(Monitor *mon, CPUArchState *env,
>>      monitor_disas_env = env;
>>      monitor_disas_is_physical = is_physical;
>>      disasm_info.read_memory_func = monitor_read_memory;
>> +    disasm_info.print_address_func = generic_print_target_address;
>>
>>      disasm_info.buffer_vma = pc;
>>
>> --
>> 1.7.1
>>
>>
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2012-07-09 12:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1340636155-26426-1-git-send-email-peter.maydell@linaro.org>
2012-07-09 10:27 ` [Qemu-devel] [PATCH] disas: Fix printing of addresses in disassembly Peter Maydell
2012-07-09 12:45   ` Andreas Färber [this message]
2012-07-09 12:59     ` Peter Maydell
2012-07-14 12:19   ` Blue Swirl
2012-07-09 13:19 ` Andreas Färber
2012-07-09 13:26   ` Peter Maydell
2012-07-09 14:37     ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FFAD262.6040204@suse.de \
    --to=afaerber@suse.de \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).