Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [RFA] info breakpoints: handle 64-bit addresses
@ 2001-03-15 17:34 Ed Satterthwaite
  2001-03-16 11:25 ` Michael Snyder
  0 siblings, 1 reply; 2+ messages in thread
From: Ed Satterthwaite @ 2001-03-15 17:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Michael Snyder, cagney, ehs

As written, this patch has a slightly unfortunate side effect for MIPS
targets.

Michael Snyder <msnyder@cygnus.com> wrote

> 2001-03-14  Michael Snyder  <msnyder@redhat.com>
> 
>         * breakpoint.c (print_one_breakpoint): Handle 64-bit addresses.

In the code below, b->address is a CORE_ADDR, which is 64 bits when
gdb is configured to support 64-bit MIPS targets.  TARGET_ADDR_BIT is
implicitly set in mips-tdep.c according to the ABI deduced from the
object file.  For 32-bit or unknown ABI's, that will be 32.  In the
MIPS architecture, a 64-bit CPU sign-extends 32-bit addresses.

At least on some hosts, the output conversion is done by sprintf.
Thus 32-bit addresses with bit 31 clear will print as 8 hex digits,
while those with bit 31 set (e.g., kseg0 and kseg1) will spill into 16
hex digits, thereby spoiling the intended column alignment.

Here's a possible alternative for the first arm of the new
conditional.  It's similar to usage in mips-tdep.c.  It avoids the
cast to unsigned long in the original code but does assume ANSI C.

   tmp = longest_local_hex_string_custom ((b->address
                                           & (CORE_ADDR) 0xffffffff),
                                          "08l");

> *** 3330,3341 ****
>   #else
>         if (addressprint)
>         {
>           annotate_field (4);
> !         /* FIXME-32x64: need a print_address_numeric with
> !            field width */
> !         printf_filtered ("%s ",
> !                          local_hex_string_custom
> !                          ((unsigned long) b->address, "08l"));
>         }
>         annotate_field (5);
>         *last_addr = b->address;
> --- 3335,3350 ----
>   #else
>         if (addressprint)
>         {
> +         char *tmp;
> + 
>           annotate_field (4);
> ! 
> !         if (TARGET_ADDR_BIT <= 32)
> !           tmp = longest_local_hex_string_custom (b->address, "08l");
> !         else
> !           tmp = longest_local_hex_string_custom (b->address, "016l");
> ! 
> !         printf_filtered ("%s ", tmp);
>         }
>         annotate_field (5);
>         *last_addr = b->address;


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RFA] info breakpoints: handle 64-bit addresses
  2001-03-15 17:34 [RFA] info breakpoints: handle 64-bit addresses Ed Satterthwaite
@ 2001-03-16 11:25 ` Michael Snyder
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Snyder @ 2001-03-16 11:25 UTC (permalink / raw)
  To: Ed Satterthwaite; +Cc: gdb-patches, cagney

Ed Satterthwaite wrote:
> 
> As written, this patch has a slightly unfortunate side effect for MIPS
> targets.
> 
> Michael Snyder <msnyder@cygnus.com> wrote
> 
> > 2001-03-14  Michael Snyder  <msnyder@redhat.com>
> >
> >         * breakpoint.c (print_one_breakpoint): Handle 64-bit addresses.
> 
> In the code below, b->address is a CORE_ADDR, which is 64 bits when
> gdb is configured to support 64-bit MIPS targets.  TARGET_ADDR_BIT is
> implicitly set in mips-tdep.c according to the ABI deduced from the
> object file.  For 32-bit or unknown ABI's, that will be 32.  In the
> MIPS architecture, a 64-bit CPU sign-extends 32-bit addresses.
> 
> At least on some hosts, the output conversion is done by sprintf.
> Thus 32-bit addresses with bit 31 clear will print as 8 hex digits,
> while those with bit 31 set (e.g., kseg0 and kseg1) will spill into 16
> hex digits, thereby spoiling the intended column alignment.
> 
> Here's a possible alternative for the first arm of the new
> conditional.  It's similar to usage in mips-tdep.c.  It avoids the
> cast to unsigned long in the original code but does assume ANSI C.
> 
>    tmp = longest_local_hex_string_custom ((b->address
>                                            & (CORE_ADDR) 0xffffffff),
>                                           "08l");

Ah -- OK, this is reasonable.  Thanks for the suggestion.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-03-16 11:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-15 17:34 [RFA] info breakpoints: handle 64-bit addresses Ed Satterthwaite
2001-03-16 11:25 ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox