public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Luveh Keraph <1.41421@gmail.com>
To: gdb@sourceware.org
Subject: Re: How to input decimal numbers when radix is set to hexadecimal
Date: Tue, 16 Jun 2020 13:55:32 -0600	[thread overview]
Message-ID: <CAFy1yb01DgpwJt-fACKpiZeHiXp531xmAQ-NMvhMTMN5-_8L=g@mail.gmail.com> (raw)
In-Reply-To: <CAFy1yb1F0cpXmL=rEJ_j2CyGyZyjA6GGxt6W5DqzRmEO06A1Jg@mail.gmail.com>

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

      reply	other threads:[~2020-06-16 19:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16 19:42 Luveh Keraph
2020-06-16 19:55 ` Luveh Keraph [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFy1yb01DgpwJt-fACKpiZeHiXp531xmAQ-NMvhMTMN5-_8L=g@mail.gmail.com' \
    --to=1.41421@gmail.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).