aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2005-02-14 14:37:38 +0000
committerAndrew Cagney <cagney@redhat.com>2005-02-14 14:37:38 +0000
commit66bf4b3a03e67c9c38fb7525c6ce25c4f870206a (patch)
tree9de77d59e9da5809b17deadcd753de54454d3100 /gdb/utils.c
parent8adce22da6e4805b565e6519d112e93f2a09814c (diff)
downloadgdb-66bf4b3a03e67c9c38fb7525c6ce25c4f870206a.zip
gdb-66bf4b3a03e67c9c38fb7525c6ce25c4f870206a.tar.gz
gdb-66bf4b3a03e67c9c38fb7525c6ce25c4f870206a.tar.bz2
2005-02-14 Andrew Cagney <cagney@gnu.org>
* utils.c (paddress): New function. * defs.h (paddress): Declare. * printcmd.c (deprecated_print_address_numeric): Rename print_address_numeric, call paddress. * valprint.c, ui-out.c, tui/tui-stack.c, tracepoint.c: Update. * symmisc.c, symfile.c stack.c, p-valprint.c, printcmd.c: Update. * maint.c, m32r-rom.c, infcmd.c, f-valprint.c, exec.c: Update. * dwarf2read.c, dve3900-rom.c, defs.h, c-valprint.c: Update. * corefile.c, cli/cli-cmds.c, breakpoint.c, annotate.c: Update. * ada-valprint.c: Update.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index f6fb20e..bea5257 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2528,6 +2528,25 @@ paddr_nz (CORE_ADDR addr)
return phex_nz (addr, TARGET_ADDR_BIT / 8);
}
+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 ADDRESS_TO_POINTER() or
+ some ADDRESS_TO_PRINTABLE() be used to do the conversion? */
+
+ int addr_bit = TARGET_ADDR_BIT;
+
+ if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
+ addr &= ((CORE_ADDR) 1 << addr_bit) - 1;
+ return hex_string (addr);
+}
+
static void
decimal2str (char *paddr_str, char *sign, ULONGEST addr, int width)
{