public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* How to input decimal numbers when radix is set to hexadecimal
@ 2020-06-16 19:42 Luveh Keraph
  2020-06-16 19:55 ` Luveh Keraph
  0 siblings, 1 reply; 2+ messages in thread
From: Luveh Keraph @ 2020-06-16 19:42 UTC (permalink / raw)
  To: gdb

I run my gdb sessions so that the input and output radix is hex:

(gdb) show radix
Input and output radices set to decimal 16, hex 10, octal 20.

Occasionally, I would like to input integers using some base other than
hex. The gdb documentation (Controlling GDB section, Numbers subsection)
says the following:

"You can always enter numbers in octal, decimal, or hexadecimal in GDB by
the usual conventions: octal numbers begin with `0', decimal numbers end
with `.', and hexadecimal numbers begin with `0x'.".

This works fine with the set radix command, but not with the print command
for numbers to base 10:

(gdb) p 017
$1 = 0xf
(gdb) p 17.
$2 = 17

This seems to be in contradiction with the paragraph that I quoted, for it
does not say that such conventions are constrained to the commands to set
the radix. This aside, with the settings that I have (input and output in
hex) is it possible to input integers so that they are interpreted by gdb
as integers to base 10, rather than 16? My expectation was that, given the
way it works for octal, we would be able to do the following:

(gdb) p 17.
$2 = 11

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

* Re: How to input decimal numbers when radix is set to hexadecimal
  2020-06-16 19:42 How to input decimal numbers when radix is set to hexadecimal Luveh Keraph
@ 2020-06-16 19:55 ` Luveh Keraph
  0 siblings, 0 replies; 2+ messages in thread
From: Luveh Keraph @ 2020-06-16 19:55 UTC (permalink / raw)
  To: gdb

Replying to myself, for I found out about it five minutes after I posted
the question (and such a thing happens so often to me that I am beginning
to wonder...)

Here is how this works:

(gdb) show radix
Input and output radices set to decimal 10, hex a, octal 12.
(gdb) set radix 16
Input and output radices now set to decimal 16, hex 10, octal 20.
(gdb) p 017
$1 = 0xf
(gdb) p 0d17
$2 = 0x11



On Tue, Jun 16, 2020 at 1:42 PM Luveh Keraph <1.41421@gmail.com> wrote:

> I run my gdb sessions so that the input and output radix is hex:
>
> (gdb) show radix
> Input and output radices set to decimal 16, hex 10, octal 20.
>
> Occasionally, I would like to input integers using some base other than
> hex. The gdb documentation (Controlling GDB section, Numbers subsection)
> says the following:
>
> "You can always enter numbers in octal, decimal, or hexadecimal in GDB by
> the usual conventions: octal numbers begin with `0', decimal numbers end
> with `.', and hexadecimal numbers begin with `0x'.".
>
> This works fine with the set radix command, but not with the print command
> for numbers to base 10:
>
> (gdb) p 017
> $1 = 0xf
> (gdb) p 17.
> $2 = 17
>
> This seems to be in contradiction with the paragraph that I quoted, for it
> does not say that such conventions are constrained to the commands to set
> the radix. This aside, with the settings that I have (input and output in
> hex) is it possible to input integers so that they are interpreted by gdb
> as integers to base 10, rather than 16? My expectation was that, given the
> way it works for octal, we would be able to do the following:
>
> (gdb) p 17.
> $2 = 11
>
>

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

end of thread, other threads:[~2020-06-16 19:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16 19:42 How to input decimal numbers when radix is set to hexadecimal Luveh Keraph
2020-06-16 19:55 ` Luveh Keraph

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).