From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125001 invoked by alias); 16 Apr 2019 03:06:58 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 124991 invoked by uid 89); 16 Apr 2019 03:06:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-4.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_1,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=am, a.m, UD:a.m, H*i:sk:1555313 X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 Apr 2019 03:06:56 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id x3G36jXg012911 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Apr 2019 23:06:50 -0400 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 489401E0A9; Mon, 15 Apr 2019 23:06:45 -0400 (EDT) Subject: Re: / (slash) command : fast way to temporarily change setting(s) to run a command To: Philippe Waroquiers , gdb@sourceware.org References: <1555313564.1473.2.camel@skynet.be> From: Simon Marchi Message-ID: <0dd32aff-8b46-92c8-5761-6b4f72efbaf0@polymtl.ca> Date: Tue, 16 Apr 2019 03:06:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.3 MIME-Version: 1.0 In-Reply-To: <1555313564.1473.2.camel@skynet.be> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2019-04/txt/msg00007.txt.bz2 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