Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Adam Nemet <anemet@caviumnetworks.com>
Subject: Re: [PATCH] add-symbol-file not to print address truncated
Date: Sun, 04 May 2008 00:29:00 -0000	[thread overview]
Message-ID: <200805040053.27168.pedro@codesourcery.com> (raw)
In-Reply-To: <18460.63955.147821.776423@localhost.localdomain>

A Sunday 04 May 2008 00:48:35, Adam Nemet wrote:
> Pedro Alves writes:
> > Would paddr_nz (in utils.c) do the trick?
>
> I thought of that but I don't think it would truncate the value when it
> needs to be truncated.  IOW, note the masking in hex_string_addr.
>

Ah, that looks like paddress then, except for the width.

const char *
paddress (CORE_ADDR addr)
{
  /* Truncate address to the size of a target address, avoiding shifts
     larger or equal than the width of a CORE_ADDR.  The local
     variable ADDR_BIT stops the compiler reporting a shift overflow
     when it won't occur. */
  /* NOTE: This assumes that the significant address information is
     kept in the least significant bits of ADDR - the upper bits were
     either zero or sign extended.  Should gdbarch_address_to_pointer or
     some ADDRESS_TO_PRINTABLE() be used to do the conversion?  */

  int addr_bit = gdbarch_addr_bit (current_gdbarch);

  if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
    addr &= ((CORE_ADDR) 1 << addr_bit) - 1;
  return hex_string (addr);
}

char *
hex_string_addr (CORE_ADDR addr)
{
  int addr_bit = gdbarch_addr_bit (current_gdbarch);

  if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
    addr &= ((CORE_ADDR) 1 << addr_bit) - 1;

  return hex_string_custom (addr, addr_bit <= 32 ? 8 : 16);
}

-- 
Pedro Alves


  reply	other threads:[~2008-05-03 23:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-03 23:48 Adam Nemet
2008-05-03 23:52 ` Pedro Alves
2008-05-03 23:53   ` Adam Nemet
2008-05-04  0:29     ` Pedro Alves [this message]
2008-05-04  0:43       ` Adam Nemet
2008-05-04  3:39         ` Daniel Jacobowitz
2008-05-04  7:24           ` Adam Nemet

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=200805040053.27168.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=anemet@caviumnetworks.com \
    --cc=gdb-patches@sourceware.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