aboutsummaryrefslogtreecommitdiff
path: root/gdb/NEWS
diff options
context:
space:
mode:
authorLancelot SIX <lsix@lancelotsix.com>2021-04-17 12:10:23 +0100
committerLancelot SIX <lsix@lancelotsix.com>2021-04-25 18:00:54 +0100
commitfbb46296d7e0d09e792a7c9d7841cb26753cb3ce (patch)
tree57a8906aac5ac27c70664f749980f2d3b6c6f517 /gdb/NEWS
parent18bbba46a974d8b667f9b60c5a7d41bb3cb07369 (diff)
downloadgdb-fbb46296d7e0d09e792a7c9d7841cb26753cb3ce.zip
gdb-fbb46296d7e0d09e792a7c9d7841cb26753cb3ce.tar.gz
gdb-fbb46296d7e0d09e792a7c9d7841cb26753cb3ce.tar.bz2
[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.
Diffstat (limited to 'gdb/NEWS')
-rw-r--r--gdb/NEWS12
1 files changed, 12 insertions, 0 deletions
diff --git a/gdb/NEWS b/gdb/NEWS
index faccf40..1cdf19c 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -101,6 +101,11 @@ show startup-quietly
initialization file (e.g. ~/.config/gdb/gdbearlyinit) in order to
affect GDB.
+set print type hex on|off
+show print type hex
+ When 'on', the 'ptype' command uses hexadecimal notation to print sizes
+ and offsets of struct members. When 'off', decimal notation is used.
+
* Changed commands
break [PROBE_MODIFIER] [LOCATION] [thread THREADNUM]
@@ -145,6 +150,13 @@ maintenance info sections
line flag. It is now possible to filter which sections are printed
even when -all-objects is passed.
+ptype[/FLAGS] TYPE | EXPRESSION
+ The 'ptype' command has two new flags. When '/x' is set, hexadecimal
+ notation is used when printing sizes and offsets of struct members.
+ When '/d' is set, decimal notation is used when printing sizes and
+ offsets of struct members. Default behavior is given by 'show print
+ type hex'.
+
* Removed targets and native configurations
ARM Symbian arm*-*-symbianelf*