Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>, gdb@sourceware.org
Subject: Re: / (slash) command : fast way to temporarily change setting(s) to run a command
Date: Tue, 16 Apr 2019 03:06:00 -0000	[thread overview]
Message-ID: <0dd32aff-8b46-92c8-5761-6b4f72efbaf0@polymtl.ca> (raw)
In-Reply-To: <1555313564.1473.2.camel@skynet.be>

On 2019-04-15 3:32 a.m., Philippe Waroquiers wrote:
> GDB has a lot of settings related to how commands behaves and/or print things.
>     
> There is however currently no easy way to temporarily change a setting
> for a command.
> 
> The proposed new / command allows to temporarily change
> the settings in order to execute another command.
> A simple example:
>  By default, 'set print pretty on|off' is off.
>  To temporarily pretty
> print something, today, you have to do:
>    (gdb) set print pretty on
>    (gdb) print
> something
>    (gdb) set print pretty off
>  With the / command:
>    (gdb) /p print something
> 
> 
> The objective for this / command is to be fast to type, so it uses
> 1 or 2 letters codes to identify which settings(s) to temporarily set.
> See the proposed user manual at
> https://sourceware.org/ml/gdb-patches/2019-04/msg00245.html
> and the patch at
> https://sourceware.org/ml/gdb-patches/2019-04/msg00244.html
> 
> 
> Several settings can be changed at once:
>    (gdb) /lAai print some_array
> is the equivalent of:
>    (gdb) set language ada
>    (gdb) set print array on
>    (gdb) set print array-indexes on
>    (gdb) print some_array
>    (gdb) set language auto
>    (gdb) set print array off
>    (gdb) set print array-indexes off
> 
> An advantage of this approach is that the same options
> are usable for all commands.
> For example, you can use:
>    (gdb) /lAai backtrace full
> so that what backtrace prints is temporarily using
> the settings identified by /lAai.
> 
> The full list of currently changeable settings is given
> in the 'help /' below.
> 
> Feedback/comments/... welcome
> 
> Thank
> Philippe
> 
> 
> (gdb) help /
> Usage: /SETTING... COMMAND
> Temporarily changes settings according to SETTING, run COMMAND,
> and then restore the settings to their previous values.
> Each temporarily changeable setting is identified by a unique sequence
> of one or more letters.
> A boolean setting is temporarily activated (set to "on") by giving
> its sequence of letters.  If the boolean sequence of letters is prefixed
> by !, the boolean setting is deactivated (set to "off").
> An integer setting is temporarily changed by using its sequence of letters
> optionally prefixed by the temporary value desired.
> If no prefix value is given before the integer setting letters,
> the integer setting is temporarily changed to an unlimited value.
> An enum setting is temporarily changed by giving its sequence of letters
> followed by a letter designating the chosen enum value.
> Example:
>   /100e!ai print some_array
> is equivalent to:
>   # save current values of the settings set print elements/array/array-index.
>   set print elements 100
>   set print array off
>   set print array-index on
>   print some_array
>   # restore the saved values of the changed settings.
> The temporarily changeable settings are:
> /Be       set backtrace past-entry       Boolean on|off
> /Bl       set backtrace limit            Unsigned integer (0 means unlimited)
> /Bm       set backtrace past-main        Boolean on|off
> /Co       set print object               Boolean on|off
> /Cs       set print static-members       Boolean on|off
> /Cv       set print vtbl                 Boolean on|off
> /Pa       set print address              Boolean on|off
> /Ps       set print symbol               Boolean on|off
> /Rf       set print raw frame-arguments  Boolean on|off
> /a        set print array                Boolean on|off
> /e        set print elements             Unsigned integer (0 means unlimited)
> /f[asn]   set print frame-arguments      Enum, a = all, s = scalars, n = none
> /i        set print array-indexes        Boolean on|off
> /l[aluAscCdfgmMOo] set language          Enum, a = auto, l = local,
>                                 u = unknown, A = ada, s = asm, c = c, C = c++,
>                                 d = d, f = fortran, g = go, m = minimal,
>                                 M = modula-2, O = objective-c, o = opencl
> /n        set print null-stop            Boolean on|off
> /p        set print pretty               Boolean on|off
> /r        set print repeats              Unsigned integer (0 means unlimited)
> /u        set print union                Boolean on|off
> /v        set varsize-limit              Unsigned integer (0 means unlimited)
> (gdb) 

Hi Philippe,

I like the idea, I would probably use it most with /e (for long strings) and /p.
I just tried it a little bit, and I appreciate the fact that it's easy to apply
to your previous command.  Just type up and add the prefix to the beginning of the
line.

About that help, I would just add a few newlines here and there to space things
out and ease the reading.  Other than that, it's quite clear.

Simon

Simon


       reply	other threads:[~2019-04-16  3:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1555313564.1473.2.camel@skynet.be>
2019-04-16  3:06 ` Simon Marchi [this message]
2019-04-16  6:48   ` Philippe Waroquiers
2019-04-16 12:20     ` Simon Marchi
2019-04-16 21:22       ` Philippe Waroquiers
2019-04-17  8:14 ` Kevin Buettner
2019-04-17 20:59   ` Philippe Waroquiers
2019-04-19 16:52   ` John Baldwin
2019-05-03  3:10     ` Kevin Buettner
2019-05-03  8:23       ` Pedro Alves
2019-05-03  9:10         ` Philippe Waroquiers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0dd32aff-8b46-92c8-5761-6b4f72efbaf0@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb@sourceware.org \
    --cc=philippe.waroquiers@skynet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox