Re: / (slash) command : fast way to temporarily change setting(s) to run a command
Simon Marchi <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <[email protected]> |
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