public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* output-radix breaks char output
@ 2011-11-08  4:39 Mike Frysinger
  2011-11-08 15:13 ` Pedro Alves
  2011-11-08 17:04 ` Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Mike Frysinger @ 2011-11-08  4:39 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 591 bytes --]

am i doing something wrong here ?  seems like setting output-radix to 16 
breaks x/c output.

$ echo 'char f[]="abc";main(){}' | gcc -x c -g - -o a.out
$ gdb ./a.out
(gdb) b main
(gdb) r
(gdb) set output-radix 10
Output radix now set to decimal 10, hex a, octal 12.
(gdb) x/4c f
0x601018 <f>:   97 'a'  98 'b'  99 'c'  0 '\000'
(gdb) set output-radix 16
Output radix now set to decimal 16, hex 10, octal 20.
(gdb) x/4c f
0x601018 <f>:   0x61    0x62    0x63    0x0

i can understand the 0x61/97 change, but imo, the latter output shouldn't be 
missing the 'a' bits.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: output-radix breaks char output
  2011-11-08  4:39 output-radix breaks char output Mike Frysinger
@ 2011-11-08 15:13 ` Pedro Alves
  2011-11-08 17:04 ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Pedro Alves @ 2011-11-08 15:13 UTC (permalink / raw)
  To: gdb; +Cc: Mike Frysinger

On Tuesday 08 November 2011 04:39:08, Mike Frysinger wrote:
> am i doing something wrong here ?  seems like setting output-radix to 16 
> breaks x/c output.
> 
> $ echo 'char f[]="abc";main(){}' | gcc -x c -g - -o a.out
> $ gdb ./a.out
> (gdb) b main
> (gdb) r
> (gdb) set output-radix 10
> Output radix now set to decimal 10, hex a, octal 12.
> (gdb) x/4c f
> 0x601018 <f>:   97 'a'  98 'b'  99 'c'  0 '\000'
> (gdb) set output-radix 16
> Output radix now set to decimal 16, hex 10, octal 20.
> (gdb) x/4c f
> 0x601018 <f>:   0x61    0x62    0x63    0x0
> 
> i can understand the 0x61/97 change, but imo, the latter output shouldn't be 
> missing the 'a' bits.

I agree.

static void
set_output_radix_1 (int from_tty, unsigned radix)
{
  /* Validate the radix and disallow ones that we aren't prepared to
     handle correctly, leaving the radix unchanged.  */
  switch (radix)
    {
    case 16:
      user_print_options.output_format = 'x';	/* hex */
      break;
    case 10:
      user_print_options.output_format = 0;	/* decimal */
      break;
    case 8:
      user_print_options.output_format = 'o';	/* octal */
      break;
    default:

So radix==10 means "no format", and other radices work as if
the user overrode the format whenever printing, basically
the same as:

(top-gdb) p **argv
$3 = 47 '/'

GDB knew that was a char from the type.

(top-gdb) p /d **argv
$4 = 47

... when overridden as decimal number, the '/' is gone.

(top-gdb) x /d *argv
0x7fffffffe30a: 47

... same with `x' (the machinery that decides this is basically the same).

(top-gdb) p /x **argv
$5 = 0x2f
(top-gdb) p /o **argv
$6 = 057
(top-gdb) p /c **argv
$7 = 47 '/'

... and other formats too.

-- 
Pedro Alves

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

* Re: output-radix breaks char output
  2011-11-08  4:39 output-radix breaks char output Mike Frysinger
  2011-11-08 15:13 ` Pedro Alves
@ 2011-11-08 17:04 ` Tom Tromey
  2011-11-08 18:11   ` Mike Frysinger
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2011-11-08 17:04 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb

>>>>> "Mike" == Mike Frysinger <vapier@gentoo.org> writes:

Mike> am i doing something wrong here ?  seems like setting output-radix to 16 
Mike> breaks x/c output.

I vaguely recall something in bugzilla about this.
Anyway it seems weird to me, too.

Tom

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

* Re: output-radix breaks char output
  2011-11-08 17:04 ` Tom Tromey
@ 2011-11-08 18:11   ` Mike Frysinger
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2011-11-08 18:11 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb

[-- Attachment #1: Type: Text/Plain, Size: 356 bytes --]

On Tuesday 08 November 2011 10:05:28 Tom Tromey wrote:
> >>>>> "Mike" == Mike Frysinger <vapier@gentoo.org> writes:
> Mike> am i doing something wrong here ?  seems like setting output-radix to
> Mike> 16 breaks x/c output.
> 
> I vaguely recall something in bugzilla about this.

indeed: http://sourceware.org/bugzilla/show_bug.cgi?id=8678
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2011-11-08 18:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-08  4:39 output-radix breaks char output Mike Frysinger
2011-11-08 15:13 ` Pedro Alves
2011-11-08 17:04 ` Tom Tromey
2011-11-08 18:11   ` Mike Frysinger

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 read-only IMAP folder(s) and NNTP newsgroup(s).