public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug cli/22640] Extend ptype /o to support offsets and sizes in hex rather than decimal
       [not found] <bug-22640-4717@http.sourceware.org/bugzilla/>
@ 2021-04-25 17:08 ` cvs-commit at gcc dot gnu.org
  2021-04-25 19:13 ` tromey at sourceware dot org
  1 sibling, 0 replies; 2+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-25 17:08 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=22640

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Lancelot SIX <lsix@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fbb46296d7e0d09e792a7c9d7841cb26753cb3ce

commit fbb46296d7e0d09e792a7c9d7841cb26753cb3ce
Author: Lancelot SIX <lsix@lancelotsix.com>
Date:   Sat Apr 17 12:10:23 2021 +0100

    [PR gdb/22640] ptype: add option to use hexadecimal notation

    This commit adds a flag to the ptype command in order to print the
    offsets and sizes of struct members using the hexadecimal notation.  The
    'x' flag ensures use of the hexadecimal notation while the 'd' flag
    ensures use of the decimal notation.  The default is to use decimal
    notation.

    Before this patch, gdb only uses decimal notation, as pointed out in PR
    gdb/22640.

    Here is an example of this new behavior with hex output turned on:

        (gdb) ptype /ox struct type_print_options
        /* offset      |    size */  type = struct type_print_options {
        /* 0x0000: 0x0 |  0x0004 */    unsigned int raw : 1;
        /* 0x0000: 0x1 |  0x0004 */    unsigned int print_methods : 1;
        /* 0x0000: 0x2 |  0x0004 */    unsigned int print_typedefs : 1;
        /* 0x0000: 0x3 |  0x0004 */    unsigned int print_offsets : 1;
        /* 0x0000: 0x4 |  0x0004 */    unsigned int print_in_hex : 1;
        /* XXX  3-bit hole       */
        /* XXX  3-byte hole      */
        /* 0x0004      |  0x0004 */    int print_nested_type_limit;
        /* 0x0008      |  0x0008 */    typedef_hash_table *local_typedefs;
        /* 0x0010      |  0x0008 */    typedef_hash_table *global_typedefs;
        /* 0x0018      |  0x0008 */    ext_lang_type_printers *global_printers;

                                       /* total size (bytes):   32 */
                                     }

    This patch also adds the 'set print type hex' and 'show print type hex'
    commands in order to set and inspect the default behavior regarding the
    use of decimal or hexadecimal notation when printing struct sizes and
    offsets.

    Tested using on x86_64.

    gdb/ChangeLog:

            PR gdb/22640
            * typeprint.h (struct type_print_options): Add print_in_hex
            flag.
            (struct print_offset_data): Add print_in_hex flag, add a
            constructor accepting a type_print_options* argument.
            * typeprint.c (type_print_raw_options, default_ptype_flags): Set
            default value for print_in_hex.
            (print_offset_data::indentation): Allow more horizontal space.
            (print_offset_data::print_offset_data): Add ctor.
            (print_offset_data::maybe_print_hole, print_offset_data::update):
            Handle the print_in_hex flag.
            (whatis_exp): Handle 'x' and 'd' flags.
            (print_offsets_and_sizes_in_hex): Declare.
            (set_print_offsets_and_sizes_in_hex): Create.
            (show_print_offsets_and_sizes_in_hex): Create.
            (_initialize_typeprint): Update help message for the ptype
            command, register the 'set print type hex' and 'show print type
            hex' commands.
            * c-typeprint.c (c_print_type, c_type_print_base_struct_union)
            (c_type_print_base): Construct the print_offset_data
            object using the type_print_optons parameter.
            * rust-lang.c (rust_language::print_type): Construct the
            print_offset_data object using the type_print_optons parameter.
            * NEWS: Mention the new flags of the ptype command.

    gdb/doc/ChangeLog:

            PR gdb/22640
            * gdb.texinfo (Symbols): Describe the 'x' and 'd' flags of the
            ptype command, describe 'set print type hex' and 'show print
            type hex' commands.  Update 'ptype/o' examples.

    gdb/testsuite/ChangeLog:

            PR gdb/22640
            * gdb.base/ptype-offsets.exp: Add tests to verify the behavior
            of 'ptype/ox' and 'ptype/od'. Check that 'set print type hex'
            changes the default behavior of 'ptype/o'.  Update to take into
            account new horizontal layout.
            * gdb.rust/simple.exp: Update ptype test to check new horizontal
            layout.
            * gdb.rust/union.exp: Same.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug cli/22640] Extend ptype /o to support offsets and sizes in hex rather than decimal
       [not found] <bug-22640-4717@http.sourceware.org/bugzilla/>
  2021-04-25 17:08 ` [Bug cli/22640] Extend ptype /o to support offsets and sizes in hex rather than decimal cvs-commit at gcc dot gnu.org
@ 2021-04-25 19:13 ` tromey at sourceware dot org
  1 sibling, 0 replies; 2+ messages in thread
From: tromey at sourceware dot org @ 2021-04-25 19:13 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=22640

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.1
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2021-04-25 19:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-22640-4717@http.sourceware.org/bugzilla/>
2021-04-25 17:08 ` [Bug cli/22640] Extend ptype /o to support offsets and sizes in hex rather than decimal cvs-commit at gcc dot gnu.org
2021-04-25 19:13 ` tromey at sourceware dot org

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