diff options
author | Andrew Cagney <cagney@redhat.com> | 2000-05-22 02:07:19 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2000-05-22 02:07:19 +0000 |
commit | 5683e87aa5680099320f4900de6ec7edc99d9f5d (patch) | |
tree | bd0233cdf94f4f72c8a32d8ec2f911cbd9c7f7fd /gdb/utils.c | |
parent | e8475ad46302c0439093e9e25d631e56331f20e4 (diff) | |
download | gdb-5683e87aa5680099320f4900de6ec7edc99d9f5d.zip gdb-5683e87aa5680099320f4900de6ec7edc99d9f5d.tar.gz gdb-5683e87aa5680099320f4900de6ec7edc99d9f5d.tar.bz2 |
Replace preg() with phex(). Cleanup monitor.c.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 111 |
1 files changed, 30 insertions, 81 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index 45fdb1d..8e2c5c5 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2836,6 +2836,8 @@ floatformat_from_doublest (fmt, from, to) } } +/* print routines to handle variable size regs, etc. */ + /* temporary storage using circular buffer */ #define NUMCELLS 16 #define CELLSIZE 32 @@ -2849,79 +2851,22 @@ get_cell () return buf[cell]; } -/* print routines to handle variable size regs, etc. - - FIXME: Note that t_addr is a bfd_vma, which is currently either an - unsigned long or unsigned long long, determined at configure time. - If t_addr is an unsigned long long and sizeof (unsigned long long) - is greater than sizeof (unsigned long), then I believe this code will - probably lose, at least for little endian machines. I believe that - it would also be better to eliminate the switch on the absolute size - of t_addr and replace it with a sequence of if statements that compare - sizeof t_addr with sizeof the various types and do the right thing, - which includes knowing whether or not the host supports long long. - -fnf - - */ - int strlen_paddr (void) { return (TARGET_PTR_BIT / 8 * 2); } - -/* eliminate warning from compiler on 32-bit systems */ -static int thirty_two = 32; - char * paddr (CORE_ADDR addr) { - char *paddr_str = get_cell (); - switch (TARGET_PTR_BIT / 8) - { - case 8: - sprintf (paddr_str, "%08lx%08lx", - (unsigned long) (addr >> thirty_two), (unsigned long) (addr & 0xffffffff)); - break; - case 4: - sprintf (paddr_str, "%08lx", (unsigned long) addr); - break; - case 2: - sprintf (paddr_str, "%04x", (unsigned short) (addr & 0xffff)); - break; - default: - sprintf (paddr_str, "%lx", (unsigned long) addr); - } - return paddr_str; + return phex (addr, TARGET_PTR_BIT / 8); } char * paddr_nz (CORE_ADDR addr) { - char *paddr_str = get_cell (); - switch (TARGET_PTR_BIT / 8) - { - case 8: - { - unsigned long high = (unsigned long) (addr >> thirty_two); - if (high == 0) - sprintf (paddr_str, "%lx", (unsigned long) (addr & 0xffffffff)); - else - sprintf (paddr_str, "%lx%08lx", - high, (unsigned long) (addr & 0xffffffff)); - break; - } - case 4: - sprintf (paddr_str, "%lx", (unsigned long) addr); - break; - case 2: - sprintf (paddr_str, "%x", (unsigned short) (addr & 0xffff)); - break; - default: - sprintf (paddr_str, "%lx", (unsigned long) addr); - } - return paddr_str; + return phex_nz (addr, TARGET_PTR_BIT / 8); } static void @@ -2976,54 +2921,58 @@ paddr_d (LONGEST addr) return paddr_str; } +/* eliminate warning from compiler on 32-bit systems */ +static int thirty_two = 32; + char * -preg (reg) - t_reg reg; +phex (ULONGEST l, int sizeof_l) { - char *preg_str = get_cell (); - switch (sizeof (t_reg)) + char *str = get_cell (); + switch (sizeof_l) { case 8: - sprintf (preg_str, "%08lx%08lx", - (unsigned long) (reg >> thirty_two), (unsigned long) (reg & 0xffffffff)); + sprintf (str, "%08lx%08lx", + (unsigned long) (l >> thirty_two), + (unsigned long) (l & 0xffffffff)); break; case 4: - sprintf (preg_str, "%08lx", (unsigned long) reg); + sprintf (str, "%08lx", (unsigned long) l); break; case 2: - sprintf (preg_str, "%04x", (unsigned short) (reg & 0xffff)); + sprintf (str, "%04x", (unsigned short) (l & 0xffff)); break; default: - sprintf (preg_str, "%lx", (unsigned long) reg); + phex (l, sizeof (l)); + break; } - return preg_str; + return str; } char * -preg_nz (reg) - t_reg reg; +phex_nz (ULONGEST l, int sizeof_l) { - char *preg_str = get_cell (); - switch (sizeof (t_reg)) + char *str = get_cell (); + switch (sizeof_l) { case 8: { - unsigned long high = (unsigned long) (reg >> thirty_two); + unsigned long high = (unsigned long) (l >> thirty_two); if (high == 0) - sprintf (preg_str, "%lx", (unsigned long) (reg & 0xffffffff)); + sprintf (str, "%lx", (unsigned long) (l & 0xffffffff)); else - sprintf (preg_str, "%lx%08lx", - high, (unsigned long) (reg & 0xffffffff)); + sprintf (str, "%lx%08lx", + high, (unsigned long) (l & 0xffffffff)); break; } case 4: - sprintf (preg_str, "%lx", (unsigned long) reg); + sprintf (str, "%lx", (unsigned long) l); break; case 2: - sprintf (preg_str, "%x", (unsigned short) (reg & 0xffff)); + sprintf (str, "%x", (unsigned short) (l & 0xffff)); break; default: - sprintf (preg_str, "%lx", (unsigned long) reg); + phex_nz (l, sizeof (l)); + break; } - return preg_str; + return str; } |