diff options
author | Andrew Burgess <aburgess@broadcom.com> | 2013-07-25 10:16:08 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@broadcom.com> | 2013-07-25 10:16:08 +0000 |
commit | 6fbe845e0c00ca40e98aa23401e0b5490717a646 (patch) | |
tree | 6e6cd06893ba6d7525ea00f4922fdc741dc7af62 | |
parent | db6a5d5f908a3139924421da1d80d8edf479646c (diff) | |
download | gdb-6fbe845e0c00ca40e98aa23401e0b5490717a646.zip gdb-6fbe845e0c00ca40e98aa23401e0b5490717a646.tar.gz gdb-6fbe845e0c00ca40e98aa23401e0b5490717a646.tar.bz2 |
Add new 'z' format for print command.
http://sourceware.org/ml/gdb-patches/2013-07/msg00235.html
gdb/ChangeLog
* NEWS: Mention new 'z' formatter.
* printcmd.c (print_scalar_formatted): Add new 'z' formatter.
(_initialize_printcmd): Mention 'z' formatter in help text of the
'x' command.
gdb/doc/ChangeLog
* gdb.texinfo (Output Formats): Mention the new 'z' formatter.
gdb/testsuite/ChangeLog
* gdb.base/printcmds.exp (test_print_int_arrays): Add tests for x,
z, o, and t output formats.
* gdb.base/display.exp: Use 'k' as an undefined format now that
'z' is defined.
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/NEWS | 3 | ||||
-rw-r--r-- | gdb/doc/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 5 | ||||
-rw-r--r-- | gdb/printcmd.c | 7 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/display.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/printcmds.exp | 10 |
8 files changed, 43 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5323efe..b028b58 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2013-07-25 Andrew Burgess <aburgess@broadcom.com> + + * NEWS: Mention new 'z' formatter. + * printcmd.c (print_scalar_formatted): Add new 'z' formatter. + (_initialize_printcmd): Mention 'z' formatter in help text of the + 'x' command. + 2013-07-24 Maciej W. Rozycki <macro@codesourcery.com> * mips-tdep.c (micromips_deal_with_atomic_sequence): Correct @@ -128,6 +128,9 @@ qXfer:libraries-svr4:read's annex 'qXfer:traceframe-info:read'. It has the id of the collected trace state variables. +* New 'z' formatter for printing and examining memory, this displays the + value as hexadecimal zero padded on the left to the size of the type. + *** Changes in GDB 7.6 * Target record has been renamed to record-full. diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 87a1f08..3c3c124 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2013-07-25 Andrew Burgess <aburgess@broadcom.com> + + * gdb.texinfo (Output Formats): Mention the new 'z' formatter. + 2013-07-17 Doug Evans <dje@google.com> * gdb.texinfo (Print Settings): Document "print raw frame-arguments". diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 4caeea5..cb393e8 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -8517,6 +8517,11 @@ Without this format, @value{GDBN} displays pointers to and arrays of strings. Single-byte members of a vector are displayed as an integer array. +@item z +Like @samp{x} formatting, the value is treated as an integer and +printed as hexadecimal, but leading zeros are printed to pad the value +to the size of the integer type. + @item r @cindex raw printing Print using the @samp{raw} formatting. By default, @value{GDBN} will diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 99d4dba..1cc248d7 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -533,6 +533,10 @@ print_scalar_formatted (const void *valaddr, struct type *type, } break; + case 'z': + print_hex_chars (stream, valaddr, len, byte_order); + break; + default: error (_("Undefined output format \"%c\"."), options->format); } @@ -2496,7 +2500,8 @@ Examine memory: x/FMT ADDRESS.\n\ ADDRESS is an expression for the memory address to examine.\n\ FMT is a repeat count followed by a format letter and a size letter.\n\ Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\ - t(binary), f(float), a(address), i(instruction), c(char) and s(string).\n\ + t(binary), f(float), a(address), i(instruction), c(char), s(string)\n\ + and z(hex, zero padded on the left).\n\ Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\ The specified number of objects of the specified size are printed\n\ according to the format.\n\n\ diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 1df1669..12a7de4 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2013-07-25 Andrew Burgess <aburgess@broadcom.com> + + * gdb.base/printcmds.exp (test_print_int_arrays): Add tests for x, + z, o, and t output formats. + * gdb.base/display.exp: Use 'k' as an undefined format now that + 'z' is defined. + 2013-07-24 Doug Evans <dje@google.com> * boards/native-stdio-gdbserver.exp (${board}_build_remote_cmd): Pass diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp index 5db84cc..9a0b1dd 100644 --- a/gdb/testsuite/gdb.base/display.exp +++ b/gdb/testsuite/gdb.base/display.exp @@ -168,7 +168,7 @@ gdb_test "printf \"%p\\n\", 1" "0x1" # play with "print", too # -gdb_test "print/z j" ".*Undefined output format.*" +gdb_test "print/k j" ".*Undefined output format.*" gdb_test "print/d j" " = 0\[\\r\\n\]+" "debug test output 1" gdb_test "print/r j" " = 0\[\\r\\n\]+" "debug test output 1a" gdb_test "print/x j" " = 0x0\[\\r\\n\]+" "debug test output 2" diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp index 0c06557..4f88382 100644 --- a/gdb/testsuite/gdb.base/printcmds.exp +++ b/gdb/testsuite/gdb.base/printcmds.exp @@ -587,6 +587,16 @@ proc test_print_int_arrays {} { " = {{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}" gdb_test_escape_braces "p int4dim" \ " = {{{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}}" + + # Some checks for various output formats. + gdb_test_escape_braces "p/x int4dim" \ + " = {{{{0x0, 0x1}, {0x2, 0x3}, {0x4, 0x5}}, {{0x6, 0x7}, {0x8, 0x9}, {0xa, 0xb}}}}" + gdb_test_escape_braces "p/z int4dim" \ + " = {{{{0x0+0, 0x0+1}, {0x0+2, 0x0+3}, {0x0+4, 0x0+5}}, {{0x0+6, 0x0+7}, {0x0+8, 0x0+9}, {0x0+a, 0x0+b}}}}" + gdb_test_escape_braces "p/o int4dim" \ + " = {{{{0, 01}, {02, 03}, {04, 05}}, {{06, 07}, {010, 011}, {012, 013}}}}" + gdb_test_escape_braces "p/t int4dim" \ + " = {{{{0, 1}, {10, 11}, {100, 101}}, {{110, 111}, {1000, 1001}, {1010, 1011}}}}" } proc test_print_typedef_arrays {} { |