[RFA] Implement 'print -raw-values' and 'set print raw-values on|off'
Commit Message
The option framework documentation was speaking about a 'print -raw'
option, but this option does not exist.
This patch implements -raw-values option that tells to ignore the
active pretty printers when printing a value.
As we already have -raw-frame-arguments, I thought -raw-values
was more clear, in particular to differentiate
set print raw-values and set print raw-frame-arguments.
gdb/doc/ChangeLog
2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Command Options): Use -p and -pretty in the example,
as -r is ambiguous. Update the print - TAB TAB completion result.
(Data): Document new option -raw-values. Use -p and -pretty in the
example, as -r is ambiguous.
(Print Settings): Document set print raw values.
(Pretty-Printer Commands): Document interaction between enabled
pretty printers and -raw-values/-raw-frame-arguments.
gdb/ChangeLog
2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS: Document -raw-values option and the related setting commands.
* printcmd.c (print_command_parse_format): Do not set opts->raw off,
only set it on when /r is given.
* valprint.c (value_print_option_defs): New element raw-values.
* Makefile.in: Add the new file.
2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/options.exp: Add -raw-values in the print completion list.
* gdb.python/py-prettyprint.exp: Add tests for -raw-values.
---
gdb/NEWS | 11 ++++-
gdb/doc/gdb.texinfo | 51 +++++++++++++++++----
gdb/printcmd.c | 6 ++-
gdb/testsuite/gdb.base/options.exp | 1 +
gdb/testsuite/gdb.python/py-prettyprint.exp | 10 ++++
gdb/valprint.c | 10 ++++
6 files changed, 75 insertions(+), 14 deletions(-)
Comments
>>>>> "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:
Philippe> This patch implements -raw-values option that tells to ignore the
Philippe> active pretty printers when printing a value.
FWIW I think "print/r" already covers this.
Maybe it's desirable to have a complete-able option for it?
Tom
> From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
> Cc: Philippe Waroquiers <philippe.waroquiers@skynet.be>
> Date: Wed, 7 Aug 2019 21:39:24 +0200
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index fa01adf6e8..8f27b102ea 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -101,6 +101,12 @@ show print max-depth
> The default max-depth is 20, but this can be set to unlimited to get
> the old behavior back.
>
> +set print raw-values [on|off]
> +show print raw-values
> + By default, GDB applies the enabled pretty printers when printing a
> + value. This allows to ignore the enabled pretty printers for a series
> + of commands. The default is 'off'.
> +
> set logging debugredirect [on|off]
> By default, GDB debug output will go to both the terminal and the logfile.
> Set if you want debug output to go only to the log file.
> @@ -200,6 +206,7 @@ maint show test-options-completion-result
> -null-stop [on|off]
> -object [on|off]
> -pretty [on|off]
> + -raw-values [on|off]
> -repeats NUMBER|unlimited
> -static-members [on|off]
> -symbol [on|off]
> @@ -244,11 +251,11 @@ maint show test-options-completion-result
> "on" if omitted. This allows writing compact command invocations,
> like for example:
>
> - (gdb) p -r -p -o 0 -- *myptr
> + (gdb) p -ra -p -o 0 -- *myptr
>
> The above is equivalent to:
>
> - (gdb) print -raw -pretty -object off -- *myptr
> + (gdb) print -raw-values -pretty -object off -- *myptr
>
> ** The "info types" command now supports the '-q' flag to disable
> printing of some header information in a similar fashion to "info
This part is OK.
> +@item set print raw-values off
> +Print values in pretty-printed form, if there is a pretty-printer
> +for the value (@pxref{Pretty Printing}),
> +otherwise print the value in raw form.
> +This is the default.
I suggest a slight rewording:
+@anchor{set print raw-values}
+@item set print raw-values on
+Print values in raw form, without applying the pretty
+printers for the value.
+
+@item set print raw-values off
+Print values in pretty-printed form, if there is a pretty-printer
+for the value (@pxref{Pretty Printing}),
+otherwise print the value in raw form.
+
+The default setting is OFF.
> +The print option @code{-raw-values} and @value{GDBN} setting @xref{set
> +print raw-values} can be used to print values without applying the
This use of @xref is a bad idea, because the printed output and even
the Info output that result from this look like a typo. For starters,
@xref produces a capitalized "See", which is inappropriate in the
middle of a sentence.
My suggestion is to use the following style:
The print option @code{-raw-values} and @value{GDBN} setting
@code{set print raw-values} (@pxref{set print raw-values}) can be
used to print ...
Yes, this repeats some of the text, but there's nothing much we can do
about that.
> +Similarly, the backtrace option @code{-raw-frame-arguments} and
> +@value{GDBN} setting @xref{set print raw-frame-arguments} can be used
> +to ignore the enabled pretty printers when printing frame argument
> +values
Likewise here. Also, a period is missing at the end of the last
sentence.
Thanks.
On Wed, 2019-08-07 at 15:38 -0600, Tom Tromey wrote:
> > > > > > "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:
>
> Philippe> This patch implements -raw-values option that tells to ignore the
> Philippe> active pretty printers when printing a value.
>
> FWIW I think "print/r" already covers this.
Yes.
In fact, someone at my work was using /r, and I had no idea what this was.
Searching at home, I found the print -raw doc, but not the -raw option.
BTW, I could not find any description of /r:
nothing found in help print, and nothing found in the manual.
Is /r documented somewhere ?
(might be good to reference /r in the -raw-values doc and manual).
>
> Maybe it's desirable to have a complete-able option for it?
Yes. /r only works on the current print command.
-raw-values is complete-able, corresponds to a GDB setting,
can be used in the "with" command.
Philippe
Ping.
Thanks
Philippe
On Wed, 2019-08-07 at 21:39 +0200, Philippe Waroquiers wrote:
> The option framework documentation was speaking about a 'print -raw'
> option, but this option does not exist.
>
> This patch implements -raw-values option that tells to ignore the
> active pretty printers when printing a value.
> As we already have -raw-frame-arguments, I thought -raw-values
> was more clear, in particular to differentiate
> set print raw-values and set print raw-frame-arguments.
>
> gdb/doc/ChangeLog
> 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be>
>
> * gdb.texinfo (Command Options): Use -p and -pretty in the example,
> as -r is ambiguous. Update the print - TAB TAB completion result.
> (Data): Document new option -raw-values. Use -p and -pretty in the
> example, as -r is ambiguous.
> (Print Settings): Document set print raw values.
> (Pretty-Printer Commands): Document interaction between enabled
> pretty printers and -raw-values/-raw-frame-arguments.
>
> gdb/ChangeLog
> 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be>
>
> * NEWS: Document -raw-values option and the related setting commands.
> * printcmd.c (print_command_parse_format): Do not set opts->raw off,
> only set it on when /r is given.
> * valprint.c (value_print_option_defs): New element raw-values.
> * Makefile.in: Add the new file.
>
> 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be>
>
> * gdb.base/options.exp: Add -raw-values in the print completion list.
> * gdb.python/py-prettyprint.exp: Add tests for -raw-values.
> ---
> gdb/NEWS | 11 ++++-
> gdb/doc/gdb.texinfo | 51 +++++++++++++++++----
> gdb/printcmd.c | 6 ++-
> gdb/testsuite/gdb.base/options.exp | 1 +
> gdb/testsuite/gdb.python/py-prettyprint.exp | 10 ++++
> gdb/valprint.c | 10 ++++
> 6 files changed, 75 insertions(+), 14 deletions(-)
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index fa01adf6e8..8f27b102ea 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -101,6 +101,12 @@ show print max-depth
> The default max-depth is 20, but this can be set to unlimited to get
> the old behavior back.
>
> +set print raw-values [on|off]
> +show print raw-values
> + By default, GDB applies the enabled pretty printers when printing a
> + value. This allows to ignore the enabled pretty printers for a series
> + of commands. The default is 'off'.
> +
> set logging debugredirect [on|off]
> By default, GDB debug output will go to both the terminal and the logfile.
> Set if you want debug output to go only to the log file.
> @@ -200,6 +206,7 @@ maint show test-options-completion-result
> -null-stop [on|off]
> -object [on|off]
> -pretty [on|off]
> + -raw-values [on|off]
> -repeats NUMBER|unlimited
> -static-members [on|off]
> -symbol [on|off]
> @@ -244,11 +251,11 @@ maint show test-options-completion-result
> "on" if omitted. This allows writing compact command invocations,
> like for example:
>
> - (gdb) p -r -p -o 0 -- *myptr
> + (gdb) p -ra -p -o 0 -- *myptr
>
> The above is equivalent to:
>
> - (gdb) print -raw -pretty -object off -- *myptr
> + (gdb) print -raw-values -pretty -object off -- *myptr
>
> ** The "info types" command now supports the '-q' flag to disable
> printing of some header information in a similar fashion to "info
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 7f8c0aff1c..f65f8b1764 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -1936,8 +1936,8 @@ Some commands take raw input as argument. For example, the print
> command processes arbitrary expressions in any of the languages
> supported by @value{GDBN}. With such commands, because raw input may
> start with a leading dash that would be confused with an option or any
> -of its abbreviations, e.g.@: @code{print -r} (short for @code{print
> --raw} or printing negative @code{r}?), if you specify any command
> +of its abbreviations, e.g.@: @code{print -p} (short for @code{print
> +-pretty} or printing negative @code{p}?), if you specify any command
> option, then you must use a double-dash (@code{--}) delimiter to
> indicate the end of options.
>
> @@ -1963,10 +1963,10 @@ on @code{-} after the command name. For example:
>
> @smallexample
> (@value{GDBP}) print -@key{TAB}@key{TAB}
> --address -max-depth -repeats -vtbl
> --array -null-stop -static-members
> --array-indexes -object -symbol
> --elements -pretty -union
> +-address -max-depth -raw-values -union
> +-array -null-stop -repeats -vtbl
> +-array-indexes -object -static-members
> +-elements -pretty -symbol
> @end smallexample
>
> Completion will in some cases guide you with a suggestion of what kind
> @@ -9541,6 +9541,11 @@ Set printing C@t{++} virtual function tables. Related setting:
> Set pretty formatting of structures. Related setting: @ref{set print
> pretty}.
>
> +@item -raw-values [@code{on}|@code{off}]
> +Set whether to print values in raw form, bypassing any
> +pretty-printers for that value. Related setting: @ref{set print
> +raw-values}.
> +
> @item -repeats @var{number-of-repeats}|@code{unlimited}
> Set threshold for repeated print elements. @code{unlimited} causes
> all elements to be individually printed. Related setting: @ref{set
> @@ -9568,17 +9573,17 @@ may look like options (including abbreviations), if you specify any
> command option, then you must use a double dash (@code{--}) to mark
> the end of option processing.
>
> -For example, this prints the value of the @code{-r} expression:
> +For example, this prints the value of the @code{-p} expression:
>
> @smallexample
> -(@value{GDBP}) print -r
> +(@value{GDBP}) print -p
> @end smallexample
>
> While this repeats the last value in the value history (see below)
> -with the @code{-raw} option in effect:
> +with the @code{-pretty} option in effect:
>
> @smallexample
> -(@value{GDBP}) print -r --
> +(@value{GDBP}) print -p --
> @end smallexample
>
> Here is an example including both on option and an expression:
> @@ -11169,6 +11174,20 @@ This is the default format.
> @item show print pretty
> Show which format @value{GDBN} is using to print structures.
>
> +@anchor{set print raw-values}
> +@item set print raw-values on
> +Print values in raw form, without applying the pretty
> +printers for the value.
> +
> +@item set print raw-values off
> +Print values in pretty-printed form, if there is a pretty-printer
> +for the value (@pxref{Pretty Printing}),
> +otherwise print the value in raw form.
> +This is the default.
> +
> +@item show print raw-values
> +Show whether to print values in raw form.
> +
> @item set print sevenbit-strings on
> @cindex eight-bit characters in strings
> @cindex octal escapes in strings
> @@ -11508,6 +11527,18 @@ library2.so:
> Note that for @code{bar} the entire printer can be disabled,
> as can each individual subprinter.
>
> +Printing values and frame arguments is done by default using
> +the enabled pretty printers.
> +
> +The print option @code{-raw-values} and @value{GDBN} setting @xref{set
> +print raw-values} can be used to print values without applying the
> +enabled pretty printers.
> +
> +Similarly, the backtrace option @code{-raw-frame-arguments} and
> +@value{GDBN} setting @xref{set print raw-frame-arguments} can be used
> +to ignore the enabled pretty printers when printing frame argument
> +values
> +
> @node Value History
> @section Value History
>
> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
> index 7529842e73..9c3982338a 100644
> --- a/gdb/printcmd.c
> +++ b/gdb/printcmd.c
> @@ -1142,6 +1142,9 @@ print_command_parse_format (const char **expp, const char *cmdname,
> {
> const char *exp = *expp;
>
> + /* opts->raw value might already have been set by 'set print raw-values'
> + or by using 'print -raw-values'.
> + So, do not set opts->raw to 0, only set it to 1 if /r is given. */
> if (exp && *exp == '/')
> {
> format_data fmt;
> @@ -1152,12 +1155,11 @@ print_command_parse_format (const char **expp, const char *cmdname,
> last_format = fmt.format;
>
> opts->format = fmt.format;
> - opts->raw = fmt.raw;
> + opts->raw = opts->raw || fmt.raw;
> }
> else
> {
> opts->format = 0;
> - opts->raw = 0;
> }
>
> *expp = exp;
> diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
> index 7a18fe936b..78ddc26577 100644
> --- a/gdb/testsuite/gdb.base/options.exp
> +++ b/gdb/testsuite/gdb.base/options.exp
> @@ -168,6 +168,7 @@ proc_with_prefix test-print {{prefix ""}} {
> "-null-stop"
> "-object"
> "-pretty"
> + "-raw-values"
> "-repeats"
> "-static-members"
> "-symbol"
> diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
> index 82e7e65031..3d88f7e9f2 100644
> --- a/gdb/testsuite/gdb.python/py-prettyprint.exp
> +++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
> @@ -199,3 +199,13 @@ gdb_test_no_output "python enable_lookup_function ()"
>
> gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>" \
> "print ss enabled #2"
> +
> +gdb_test "print -raw-values -- ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
> + "print -raw-values -- ss"
> +
> +gdb_test "print -raw-values on -- ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
> + "print -raw-values on -- ss"
> +
> +gdb_test "with print raw-values -- print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
> + "with print raw-values -- print ss"
> +
> diff --git a/gdb/valprint.c b/gdb/valprint.c
> index e5b28f3ee9..96e8ff6dca 100644
> --- a/gdb/valprint.c
> +++ b/gdb/valprint.c
> @@ -3192,6 +3192,16 @@ Use \"unlimited\" to print the complete structure.")
> NULL, /* help_doc */
> },
>
> + boolean_option_def {
> + "raw-values",
> + [] (value_print_options *opt) { return &opt->raw; },
> + NULL, /* show_cmd_cb */
> + N_("Set whether to print values in raw form."),
> + N_("Show whether to print values in raw form."),
> + N_("If set, values are printed in raw form, bypassing any\n\
> +pretty-printers for that value.")
> + },
> +
> uinteger_option_def {
> "repeats",
> [] (value_print_options *opt) { return &opt->repeat_count_threshold; },
Ping.
Thanks
Philippe
On Wed, 2019-08-07 at 21:39 +0200, Philippe Waroquiers wrote:
> The option framework documentation was speaking about a 'print -raw'
> option, but this option does not exist.
>
> This patch implements -raw-values option that tells to ignore the
> active pretty printers when printing a value.
> As we already have -raw-frame-arguments, I thought -raw-values
> was more clear, in particular to differentiate
> set print raw-values and set print raw-frame-arguments.
>
> gdb/doc/ChangeLog
> 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be>
>
> * gdb.texinfo (Command Options): Use -p and -pretty in the example,
> as -r is ambiguous. Update the print - TAB TAB completion result.
> (Data): Document new option -raw-values. Use -p and -pretty in the
> example, as -r is ambiguous.
> (Print Settings): Document set print raw values.
> (Pretty-Printer Commands): Document interaction between enabled
> pretty printers and -raw-values/-raw-frame-arguments.
>
> gdb/ChangeLog
> 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be>
>
> * NEWS: Document -raw-values option and the related setting commands.
> * printcmd.c (print_command_parse_format): Do not set opts->raw off,
> only set it on when /r is given.
> * valprint.c (value_print_option_defs): New element raw-values.
> * Makefile.in: Add the new file.
>
> 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be>
>
> * gdb.base/options.exp: Add -raw-values in the print completion list.
> * gdb.python/py-prettyprint.exp: Add tests for -raw-values.
> ---
> gdb/NEWS | 11 ++++-
> gdb/doc/gdb.texinfo | 51 +++++++++++++++++----
> gdb/printcmd.c | 6 ++-
> gdb/testsuite/gdb.base/options.exp | 1 +
> gdb/testsuite/gdb.python/py-prettyprint.exp | 10 ++++
> gdb/valprint.c | 10 ++++
> 6 files changed, 75 insertions(+), 14 deletions(-)
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index fa01adf6e8..8f27b102ea 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -101,6 +101,12 @@ show print max-depth
> The default max-depth is 20, but this can be set to unlimited to get
> the old behavior back.
>
> +set print raw-values [on|off]
> +show print raw-values
> + By default, GDB applies the enabled pretty printers when printing a
> + value. This allows to ignore the enabled pretty printers for a series
> + of commands. The default is 'off'.
> +
> set logging debugredirect [on|off]
> By default, GDB debug output will go to both the terminal and the logfile.
> Set if you want debug output to go only to the log file.
> @@ -200,6 +206,7 @@ maint show test-options-completion-result
> -null-stop [on|off]
> -object [on|off]
> -pretty [on|off]
> + -raw-values [on|off]
> -repeats NUMBER|unlimited
> -static-members [on|off]
> -symbol [on|off]
> @@ -244,11 +251,11 @@ maint show test-options-completion-result
> "on" if omitted. This allows writing compact command invocations,
> like for example:
>
> - (gdb) p -r -p -o 0 -- *myptr
> + (gdb) p -ra -p -o 0 -- *myptr
>
> The above is equivalent to:
>
> - (gdb) print -raw -pretty -object off -- *myptr
> + (gdb) print -raw-values -pretty -object off -- *myptr
>
> ** The "info types" command now supports the '-q' flag to disable
> printing of some header information in a similar fashion to "info
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 7f8c0aff1c..f65f8b1764 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -1936,8 +1936,8 @@ Some commands take raw input as argument. For example, the print
> command processes arbitrary expressions in any of the languages
> supported by @value{GDBN}. With such commands, because raw input may
> start with a leading dash that would be confused with an option or any
> -of its abbreviations, e.g.@: @code{print -r} (short for @code{print
> --raw} or printing negative @code{r}?), if you specify any command
> +of its abbreviations, e.g.@: @code{print -p} (short for @code{print
> +-pretty} or printing negative @code{p}?), if you specify any command
> option, then you must use a double-dash (@code{--}) delimiter to
> indicate the end of options.
>
> @@ -1963,10 +1963,10 @@ on @code{-} after the command name. For example:
>
> @smallexample
> (@value{GDBP}) print -@key{TAB}@key{TAB}
> --address -max-depth -repeats -vtbl
> --array -null-stop -static-members
> --array-indexes -object -symbol
> --elements -pretty -union
> +-address -max-depth -raw-values -union
> +-array -null-stop -repeats -vtbl
> +-array-indexes -object -static-members
> +-elements -pretty -symbol
> @end smallexample
>
> Completion will in some cases guide you with a suggestion of what kind
> @@ -9541,6 +9541,11 @@ Set printing C@t{++} virtual function tables. Related setting:
> Set pretty formatting of structures. Related setting: @ref{set print
> pretty}.
>
> +@item -raw-values [@code{on}|@code{off}]
> +Set whether to print values in raw form, bypassing any
> +pretty-printers for that value. Related setting: @ref{set print
> +raw-values}.
> +
> @item -repeats @var{number-of-repeats}|@code{unlimited}
> Set threshold for repeated print elements. @code{unlimited} causes
> all elements to be individually printed. Related setting: @ref{set
> @@ -9568,17 +9573,17 @@ may look like options (including abbreviations), if you specify any
> command option, then you must use a double dash (@code{--}) to mark
> the end of option processing.
>
> -For example, this prints the value of the @code{-r} expression:
> +For example, this prints the value of the @code{-p} expression:
>
> @smallexample
> -(@value{GDBP}) print -r
> +(@value{GDBP}) print -p
> @end smallexample
>
> While this repeats the last value in the value history (see below)
> -with the @code{-raw} option in effect:
> +with the @code{-pretty} option in effect:
>
> @smallexample
> -(@value{GDBP}) print -r --
> +(@value{GDBP}) print -p --
> @end smallexample
>
> Here is an example including both on option and an expression:
> @@ -11169,6 +11174,20 @@ This is the default format.
> @item show print pretty
> Show which format @value{GDBN} is using to print structures.
>
> +@anchor{set print raw-values}
> +@item set print raw-values on
> +Print values in raw form, without applying the pretty
> +printers for the value.
> +
> +@item set print raw-values off
> +Print values in pretty-printed form, if there is a pretty-printer
> +for the value (@pxref{Pretty Printing}),
> +otherwise print the value in raw form.
> +This is the default.
> +
> +@item show print raw-values
> +Show whether to print values in raw form.
> +
> @item set print sevenbit-strings on
> @cindex eight-bit characters in strings
> @cindex octal escapes in strings
> @@ -11508,6 +11527,18 @@ library2.so:
> Note that for @code{bar} the entire printer can be disabled,
> as can each individual subprinter.
>
> +Printing values and frame arguments is done by default using
> +the enabled pretty printers.
> +
> +The print option @code{-raw-values} and @value{GDBN} setting @xref{set
> +print raw-values} can be used to print values without applying the
> +enabled pretty printers.
> +
> +Similarly, the backtrace option @code{-raw-frame-arguments} and
> +@value{GDBN} setting @xref{set print raw-frame-arguments} can be used
> +to ignore the enabled pretty printers when printing frame argument
> +values
> +
> @node Value History
> @section Value History
>
> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
> index 7529842e73..9c3982338a 100644
> --- a/gdb/printcmd.c
> +++ b/gdb/printcmd.c
> @@ -1142,6 +1142,9 @@ print_command_parse_format (const char **expp, const char *cmdname,
> {
> const char *exp = *expp;
>
> + /* opts->raw value might already have been set by 'set print raw-values'
> + or by using 'print -raw-values'.
> + So, do not set opts->raw to 0, only set it to 1 if /r is given. */
> if (exp && *exp == '/')
> {
> format_data fmt;
> @@ -1152,12 +1155,11 @@ print_command_parse_format (const char **expp, const char *cmdname,
> last_format = fmt.format;
>
> opts->format = fmt.format;
> - opts->raw = fmt.raw;
> + opts->raw = opts->raw || fmt.raw;
> }
> else
> {
> opts->format = 0;
> - opts->raw = 0;
> }
>
> *expp = exp;
> diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
> index 7a18fe936b..78ddc26577 100644
> --- a/gdb/testsuite/gdb.base/options.exp
> +++ b/gdb/testsuite/gdb.base/options.exp
> @@ -168,6 +168,7 @@ proc_with_prefix test-print {{prefix ""}} {
> "-null-stop"
> "-object"
> "-pretty"
> + "-raw-values"
> "-repeats"
> "-static-members"
> "-symbol"
> diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
> index 82e7e65031..3d88f7e9f2 100644
> --- a/gdb/testsuite/gdb.python/py-prettyprint.exp
> +++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
> @@ -199,3 +199,13 @@ gdb_test_no_output "python enable_lookup_function ()"
>
> gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>" \
> "print ss enabled #2"
> +
> +gdb_test "print -raw-values -- ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
> + "print -raw-values -- ss"
> +
> +gdb_test "print -raw-values on -- ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
> + "print -raw-values on -- ss"
> +
> +gdb_test "with print raw-values -- print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
> + "with print raw-values -- print ss"
> +
> diff --git a/gdb/valprint.c b/gdb/valprint.c
> index e5b28f3ee9..96e8ff6dca 100644
> --- a/gdb/valprint.c
> +++ b/gdb/valprint.c
> @@ -3192,6 +3192,16 @@ Use \"unlimited\" to print the complete structure.")
> NULL, /* help_doc */
> },
>
> + boolean_option_def {
> + "raw-values",
> + [] (value_print_options *opt) { return &opt->raw; },
> + NULL, /* show_cmd_cb */
> + N_("Set whether to print values in raw form."),
> + N_("Show whether to print values in raw form."),
> + N_("If set, values are printed in raw form, bypassing any\n\
> +pretty-printers for that value.")
> + },
> +
> uinteger_option_def {
> "repeats",
> [] (value_print_options *opt) { return &opt->repeat_count_threshold; },
> From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
> Date: Sun, 29 Sep 2019 17:29:54 +0200
>
> Ping.
I believe the documentation parts were already reviewed, right?
On Sun, 2019-09-29 at 18:33 +0300, Eli Zaretskii wrote:
> > From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
> > Date: Sun, 29 Sep 2019 17:29:54 +0200
> >
> > Ping.
>
> I believe the documentation parts were already reviewed, right?
Yes (see https://sourceware.org/ml/gdb-patches/2019-08/msg00207.html).
I have applied all the proposed changes.
Thanks
Philippe
On 2019-08-07 3:39 p.m., Philippe Waroquiers wrote:
> The option framework documentation was speaking about a 'print -raw'
> option, but this option does not exist.
>
> This patch implements -raw-values option that tells to ignore the
> active pretty printers when printing a value.
> As we already have -raw-frame-arguments, I thought -raw-values
> was more clear, in particular to differentiate
> set print raw-values and set print raw-frame-arguments.
Hi Philippe,
I'm just a bit worried about the naming, but I don't have anything better
to suggest. I mention it in case you do. The "set print raw-values" sounds
like superset of "set print raw-frame-arguments", because in my mind frame
arguments are printed as values.
Other than that, the patch looks fine to me.
Simon
On 12/4/19 3:43 AM, Simon Marchi wrote:
> On 2019-08-07 3:39 p.m., Philippe Waroquiers wrote:
>> The option framework documentation was speaking about a 'print -raw'
>> option, but this option does not exist.
Eh. I think I recall that it would be a good idea to have it,
like I made "bt -full/-no-filters/-hide" options to
supersede "bt full/no-filters/hide", but then dropped it for some
reason.
So +1 from me.
(But see the other email I sent.)
>>
>> This patch implements -raw-values option that tells to ignore the
>> active pretty printers when printing a value.
>> As we already have -raw-frame-arguments, I thought -raw-values
>> was more clear, in particular to differentiate
>> set print raw-values and set print raw-frame-arguments.
>
> Hi Philippe,
>
> I'm just a bit worried about the naming, but I don't have anything better
> to suggest. I mention it in case you do. The "set print raw-values" sounds
> like superset of "set print raw-frame-arguments", because in my mind frame
> arguments are printed as values.
But isn't it a superset?
> Other than that, the patch looks fine to me.
Thanks,
Pedro Alves
On 2019-12-04 11:24 a.m., Pedro Alves wrote:
> On 12/4/19 3:43 AM, Simon Marchi wrote:
>> On 2019-08-07 3:39 p.m., Philippe Waroquiers wrote:
>>> The option framework documentation was speaking about a 'print -raw'
>>> option, but this option does not exist.
>
> Eh. I think I recall that it would be a good idea to have it,
> like I made "bt -full/-no-filters/-hide" options to
> supersede "bt full/no-filters/hide", but then dropped it for some
> reason.
>
> So +1 from me.
>
> (But see the other email I sent.)
>
>>>
>>> This patch implements -raw-values option that tells to ignore the
>>> active pretty printers when printing a value.
>>> As we already have -raw-frame-arguments, I thought -raw-values
>>> was more clear, in particular to differentiate
>>> set print raw-values and set print raw-frame-arguments.
>>
>> Hi Philippe,
>>
>> I'm just a bit worried about the naming, but I don't have anything better
>> to suggest. I mention it in case you do. The "set print raw-values" sounds
>> like superset of "set print raw-frame-arguments", because in my mind frame
>> arguments are printed as values.
>
> But isn't it a superset?
From my testing, "set print raw-values on/off" didn't affect how parameter values
were printed in "bt" or "frame". But I might have tested it wrong.
Simon
On 12/4/19 4:34 PM, Simon Marchi wrote:
> On 2019-12-04 11:24 a.m., Pedro Alves wrote:
>> On 12/4/19 3:43 AM, Simon Marchi wrote:
>>> I'm just a bit worried about the naming, but I don't have anything better
>>> to suggest. I mention it in case you do. The "set print raw-values" sounds
>>> like superset of "set print raw-frame-arguments", because in my mind frame
>>> arguments are printed as values.
>>
>> But isn't it a superset?
>
> From my testing, "set print raw-values on/off" didn't affect how parameter values
> were printed in "bt" or "frame". But I might have tested it wrong.
Hmm, print_frame_arg does:
vp_opts.raw = fp_opts.print_raw_frame_arguments;
and I guess that is what ends up ignoring whatever's
the "set print raw-values" setting, even if you don't
explicitly specify "-raw-frame-arguments".
Thanks,
Pedro Alves
On Wed, 2019-12-04 at 17:19 +0000, Pedro Alves wrote:
> On 12/4/19 4:34 PM, Simon Marchi wrote:
> > On 2019-12-04 11:24 a.m., Pedro Alves wrote:
> > > On 12/4/19 3:43 AM, Simon Marchi wrote:
> > > > I'm just a bit worried about the naming, but I don't have anything better
> > > > to suggest. I mention it in case you do. The "set print raw-values" sounds
> > > > like superset of "set print raw-frame-arguments", because in my mind frame
> > > > arguments are printed as values.
> > >
> > > But isn't it a superset?
> >
> > From my testing, "set print raw-values on/off" didn't affect how parameter values
> > were printed in "bt" or "frame". But I might have tested it wrong.
>
> Hmm, print_frame_arg does:
>
> vp_opts.raw = fp_opts.print_raw_frame_arguments;
>
> and I guess that is what ends up ignoring whatever's
> the "set print raw-values" setting, even if you don't
> explicitly specify "-raw-frame-arguments".
Yes, effectively, "set print raw-values on/off" controls printing
expressions from print commands, while "set print raw-frame-arguments"
independently controls how the "frame related commands" print their
frame arguments.
Philippe
@@ -101,6 +101,12 @@ show print max-depth
The default max-depth is 20, but this can be set to unlimited to get
the old behavior back.
+set print raw-values [on|off]
+show print raw-values
+ By default, GDB applies the enabled pretty printers when printing a
+ value. This allows to ignore the enabled pretty printers for a series
+ of commands. The default is 'off'.
+
set logging debugredirect [on|off]
By default, GDB debug output will go to both the terminal and the logfile.
Set if you want debug output to go only to the log file.
@@ -200,6 +206,7 @@ maint show test-options-completion-result
-null-stop [on|off]
-object [on|off]
-pretty [on|off]
+ -raw-values [on|off]
-repeats NUMBER|unlimited
-static-members [on|off]
-symbol [on|off]
@@ -244,11 +251,11 @@ maint show test-options-completion-result
"on" if omitted. This allows writing compact command invocations,
like for example:
- (gdb) p -r -p -o 0 -- *myptr
+ (gdb) p -ra -p -o 0 -- *myptr
The above is equivalent to:
- (gdb) print -raw -pretty -object off -- *myptr
+ (gdb) print -raw-values -pretty -object off -- *myptr
** The "info types" command now supports the '-q' flag to disable
printing of some header information in a similar fashion to "info
@@ -1936,8 +1936,8 @@ Some commands take raw input as argument. For example, the print
command processes arbitrary expressions in any of the languages
supported by @value{GDBN}. With such commands, because raw input may
start with a leading dash that would be confused with an option or any
-of its abbreviations, e.g.@: @code{print -r} (short for @code{print
--raw} or printing negative @code{r}?), if you specify any command
+of its abbreviations, e.g.@: @code{print -p} (short for @code{print
+-pretty} or printing negative @code{p}?), if you specify any command
option, then you must use a double-dash (@code{--}) delimiter to
indicate the end of options.
@@ -1963,10 +1963,10 @@ on @code{-} after the command name. For example:
@smallexample
(@value{GDBP}) print -@key{TAB}@key{TAB}
--address -max-depth -repeats -vtbl
--array -null-stop -static-members
--array-indexes -object -symbol
--elements -pretty -union
+-address -max-depth -raw-values -union
+-array -null-stop -repeats -vtbl
+-array-indexes -object -static-members
+-elements -pretty -symbol
@end smallexample
Completion will in some cases guide you with a suggestion of what kind
@@ -9541,6 +9541,11 @@ Set printing C@t{++} virtual function tables. Related setting:
Set pretty formatting of structures. Related setting: @ref{set print
pretty}.
+@item -raw-values [@code{on}|@code{off}]
+Set whether to print values in raw form, bypassing any
+pretty-printers for that value. Related setting: @ref{set print
+raw-values}.
+
@item -repeats @var{number-of-repeats}|@code{unlimited}
Set threshold for repeated print elements. @code{unlimited} causes
all elements to be individually printed. Related setting: @ref{set
@@ -9568,17 +9573,17 @@ may look like options (including abbreviations), if you specify any
command option, then you must use a double dash (@code{--}) to mark
the end of option processing.
-For example, this prints the value of the @code{-r} expression:
+For example, this prints the value of the @code{-p} expression:
@smallexample
-(@value{GDBP}) print -r
+(@value{GDBP}) print -p
@end smallexample
While this repeats the last value in the value history (see below)
-with the @code{-raw} option in effect:
+with the @code{-pretty} option in effect:
@smallexample
-(@value{GDBP}) print -r --
+(@value{GDBP}) print -p --
@end smallexample
Here is an example including both on option and an expression:
@@ -11169,6 +11174,20 @@ This is the default format.
@item show print pretty
Show which format @value{GDBN} is using to print structures.
+@anchor{set print raw-values}
+@item set print raw-values on
+Print values in raw form, without applying the pretty
+printers for the value.
+
+@item set print raw-values off
+Print values in pretty-printed form, if there is a pretty-printer
+for the value (@pxref{Pretty Printing}),
+otherwise print the value in raw form.
+This is the default.
+
+@item show print raw-values
+Show whether to print values in raw form.
+
@item set print sevenbit-strings on
@cindex eight-bit characters in strings
@cindex octal escapes in strings
@@ -11508,6 +11527,18 @@ library2.so:
Note that for @code{bar} the entire printer can be disabled,
as can each individual subprinter.
+Printing values and frame arguments is done by default using
+the enabled pretty printers.
+
+The print option @code{-raw-values} and @value{GDBN} setting @xref{set
+print raw-values} can be used to print values without applying the
+enabled pretty printers.
+
+Similarly, the backtrace option @code{-raw-frame-arguments} and
+@value{GDBN} setting @xref{set print raw-frame-arguments} can be used
+to ignore the enabled pretty printers when printing frame argument
+values
+
@node Value History
@section Value History
@@ -1142,6 +1142,9 @@ print_command_parse_format (const char **expp, const char *cmdname,
{
const char *exp = *expp;
+ /* opts->raw value might already have been set by 'set print raw-values'
+ or by using 'print -raw-values'.
+ So, do not set opts->raw to 0, only set it to 1 if /r is given. */
if (exp && *exp == '/')
{
format_data fmt;
@@ -1152,12 +1155,11 @@ print_command_parse_format (const char **expp, const char *cmdname,
last_format = fmt.format;
opts->format = fmt.format;
- opts->raw = fmt.raw;
+ opts->raw = opts->raw || fmt.raw;
}
else
{
opts->format = 0;
- opts->raw = 0;
}
*expp = exp;
@@ -168,6 +168,7 @@ proc_with_prefix test-print {{prefix ""}} {
"-null-stop"
"-object"
"-pretty"
+ "-raw-values"
"-repeats"
"-static-members"
"-symbol"
@@ -199,3 +199,13 @@ gdb_test_no_output "python enable_lookup_function ()"
gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>" \
"print ss enabled #2"
+
+gdb_test "print -raw-values -- ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
+ "print -raw-values -- ss"
+
+gdb_test "print -raw-values on -- ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
+ "print -raw-values on -- ss"
+
+gdb_test "with print raw-values -- print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
+ "with print raw-values -- print ss"
+
@@ -3192,6 +3192,16 @@ Use \"unlimited\" to print the complete structure.")
NULL, /* help_doc */
},
+ boolean_option_def {
+ "raw-values",
+ [] (value_print_options *opt) { return &opt->raw; },
+ NULL, /* show_cmd_cb */
+ N_("Set whether to print values in raw form."),
+ N_("Show whether to print values in raw form."),
+ N_("If set, values are printed in raw form, bypassing any\n\
+pretty-printers for that value.")
+ },
+
uinteger_option_def {
"repeats",
[] (value_print_options *opt) { return &opt->repeat_count_threshold; },