Bug 23390 - Let user default character escapes to hex
Summary: Let user default character escapes to hex
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 8.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-09 17:43 UTC by Jeffrey Walton
Modified: 2023-06-16 22:04 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2018-07-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Walton 2018-07-09 17:43:46 UTC
I've tried setting base 16 radix in GDB interactive session and .gdbinit. Both are no joy. I don't read in octal so it makes a GDB session quite painful.

The session below is from an ARM dev-board but the same happens on desktops, too.

I've also noticed GDB has problems displaying short's too. It tries to print them as strings rather that the 2-byte hex as requested.

The problem has existed since at least the GDB 6 days.

Breakpoint 2, CRYPTOGAMS_encrypt (
    inBlock=0x4f3020 "}ќ\322\021i\f;\270\001\344\267R\253\t\004",
    xorBlock=0x0,
    outBlock=0x4fc1f0 "}ќ\322\021i\f;\270\001\344\267R\253\t\004",
    rkey=0x4fbce8) at rijndael.cpp:334
334             AES_encrypt(inBlock, outBlock, rkey);

(gdb) set output-radix 16
Output radix now set to decimal 16, hex 10, octal 20.
(gdb) c
Continuing.

Breakpoint 2, CRYPTOGAMS_encrypt (
    inBlock=0x4f3020 "%F\233\235;\354*6\236\360\232\f\036\017\023q",
    xorBlock=0x0,
    outBlock=0x4fc1f0 "%F\233\235;\354*6\236\360\232\f\036\017\023q",
    rkey=0x4fbce8) at rijndael.cpp:334
334             AES_encrypt(inBlock, outBlock, rkey);

(gdb) shell gdb --version
GNU gdb (GDB) 8.0
Copyright (C) 2017 Free Software Foundation, Inc.

Out of morbid curiosity, who (or how many people) read in octal? How did it become the dominant use case so that it is displayed by default and ignore user settings? (I know lots of people who fluently scan hex. I don't know anyone who does the same in octal. I guess the Red Hat offices are different than the most of the world)
Comment 1 Tom Tromey 2018-07-18 13:53:59 UTC
It took me a minute to realize that this refers to the escape
sequences in the strings.  And indeed it would be nice if there
were a way to avoid octal here; though I'm not certain that
output-radix is the best way.
Comment 2 Jeffrey Walton 2018-07-18 15:49:30 UTC
(In reply to Tom Tromey from comment #1)
> It took me a minute to realize that this refers to the escape
> sequences in the strings.  And indeed it would be nice if there
> were a way to avoid octal here; though I'm not certain that
> output-radix is the best way.

Lol... I don't even know what output-radix controls. It is the canonical answer for displaying in hex, but it does not work here, it does not work with short arrays (x/4h <addr>, which attempts to print as unicode), ...
Comment 3 Tom Tromey 2018-07-18 16:46:49 UTC
I think it just controls the printing of scalars from "print"
and "output".

(gdb) print 23
$1 = 0x17

The "x" command has its own flags for the radix.