public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2][PR cli/22640] Have ptype support hex display of offsets and sizes
@ 2020-12-31 12:53 Lancelot SIX
  2020-12-31 12:53 ` [PATCH 1/2] typeprint.h: reorder struct declaration Lancelot SIX
  2020-12-31 12:53 ` [PATCH 2/2] ptype: add option to use hexadecimal notation Lancelot SIX
  0 siblings, 2 replies; 10+ messages in thread
From: Lancelot SIX @ 2020-12-31 12:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot SIX

Hi,

Here is a series of patch designed to address PR cli/22640.

The idea is to allow 'ptype' to print offsets and sizes of struct
members using hex notation if desired. Currently, gdb only uses the
decimal notation.

Before:

    (gdb) ptype /o struct type_print_options
    /* offset    |  size */  type = struct type_print_options {
    /*    0: 0   |     4 */    unsigned int raw : 1;
    /*    0: 1   |     4 */    unsigned int print_methods : 1;
    /*    0: 2   |     4 */    unsigned int print_typedefs : 1;
    /*    0: 3   |     4 */    unsigned int print_offsets : 1;
    /*    0: 4   |     4 */    unsigned int print_in_hex : 1;
    /* XXX  3-bit hole   */
    /* XXX  3-byte hole  */
    /*    4      |     4 */    int print_nested_type_limit;
    /*    8      |     8 */    typedef_hash_table *local_typedefs;
    /*   16      |     8 */    typedef_hash_table *global_typedefs;
    /*   24      |     8 */    ext_lang_type_printers *global_printers;
    
                               /* total size (bytes):   32 */
                             }

With the patches and hex option on:

    (gdb) ptype /ox struct type_print_options
    /* offset    |  size */  type = struct type_print_options {
    /* 0x00: 0   |  0x04 */    unsigned int raw : 1;
    /* 0x00: 1   |  0x04 */    unsigned int print_methods : 1;
    /* 0x00: 2   |  0x04 */    unsigned int print_typedefs : 1;
    /* 0x00: 3   |  0x04 */    unsigned int print_offsets : 1;
    /* 0x00: 4   |  0x04 */    unsigned int print_in_hex : 1;
    /* XXX  3-bit hole   */
    /* XXX  3-byte hole  */
    /* 0x04      |  0x04 */    int print_nested_type_limit;
    /* 0x08      |  0x08 */    typedef_hash_table *local_typedefs;
    /* 0x10      |  0x08 */    typedef_hash_table *global_typedefs;
    /* 0x18      |  0x08 */    ext_lang_type_printers *global_printers;
    
                               /* total size (bytes):   32 */
                             }

This patch series also allows the user to set the default behavior using
the 'set print type hex' command.

I am happy to discuss any improvement on the commands and options names
if desired.

The first patch of the series only swaps two types declaration (leaving
them unchanged otherwise) because the second will rely on this new order.

My copyright assignment have not yet been finalized, I’ll notify
maintainers as soon as it is.

Lancelot SIX (2):
  typeprint.h: reorder struct declaration
  ptype: add option to use hexadecimal notation

 gdb/c-typeprint.c                        |   8 +-
 gdb/doc/gdb.texinfo                      |  27 ++++++
 gdb/rust-lang.c                          |   2 +-
 gdb/testsuite/gdb.base/ptype-offsets.exp | 114 +++++++++++++++++++++++
 gdb/typeprint.c                          |  72 +++++++++++++-
 gdb/typeprint.h                          |  69 ++++++++------
 6 files changed, 252 insertions(+), 40 deletions(-)

-- 
2.29.2


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

end of thread, other threads:[~2021-04-15  0:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31 12:53 [PATCH 0/2][PR cli/22640] Have ptype support hex display of offsets and sizes Lancelot SIX
2020-12-31 12:53 ` [PATCH 1/2] typeprint.h: reorder struct declaration Lancelot SIX
2020-12-31 13:01   ` Lancelot SIX
2020-12-31 15:51     ` Andrew Burgess
2020-12-31 12:53 ` [PATCH 2/2] ptype: add option to use hexadecimal notation Lancelot SIX
2021-04-13 23:18   ` John Baldwin
2021-04-14  0:08     ` Paul Koning
2021-04-14 22:45       ` Lancelot SIX
2021-04-15  0:08         ` Paul Koning
2021-04-14 22:33     ` Lancelot SIX

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