From patchwork Thu Apr 18 21:52:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 32343 Received: (qmail 99327 invoked by alias); 18 Apr 2019 21:52:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 99316 invoked by uid 89); 18 Apr 2019 21:52:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Received:530e, paragraphs, silly X-HELO: mail-wr1-f48.google.com Received: from mail-wr1-f48.google.com (HELO mail-wr1-f48.google.com) (209.85.221.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 Apr 2019 21:52:37 +0000 Received: by mail-wr1-f48.google.com with SMTP id o12so1403366wrn.2 for ; Thu, 18 Apr 2019 14:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=c0BF5ug7t5LcMZ6s9wBjo31hfytevIlmdpQz3t+U2AE=; b=Wp0L3scF8WXPl0nsqqCfYPVgIDB4i51+lv4m1YXB49Qabjf73H/+o5SteFOYgm9jk1 4uiV2OvfYn8AA7TCPrlEtoRqS9oPBfcXI8NKV4wWE8hBA10y7GMveDzi/5SLhhozLJ2O JIeRvoc/tdSwej+ZCymSpZoNk9zhhZGxcZtjW9UuVtp/q+SyNp6kQN5IaoOgqTjv3/3q A08P2F7gtxRNXDbKZ+TA5xb+HbGaMpjXnpstyAF3vxxnInQnP430xd9HMWdgVgUoAsxc z6cefJLPJOxkqAFe9aZW6ZX9bSpJf+QXriHEz5wC7lnSxBE9br0skEtziejEwWzi7f8c Lv/A== Return-Path: Received: from localhost (host86-164-133-98.range86-164.btcentralplus.com. [86.164.133.98]) by smtp.gmail.com with ESMTPSA id x5sm2203155wmi.37.2019.04.18.14.52.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2019 14:52:33 -0700 (PDT) Date: Thu, 18 Apr 2019 22:52:32 +0100 From: Andrew Burgess To: Eli Zaretskii Cc: gdb-patches@sourceware.org, Philippe Waroquiers Subject: Re: [PATCHv2 5/5] gdb: Introduce 'print max-depth' feature Message-ID: <20190418215232.GU2737@embecosm.com> References: <5cbfdd5672b59422d41f4b3c0ca20a9d45c20442.1555455013.git.andrew.burgess@embecosm.com> <83h8awg0nk.fsf@gnu.org> <20190418010726.GS2737@embecosm.com> <83o954domk.fsf@gnu.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <83o954domk.fsf@gnu.org> X-Fortune: * UNIX is a Trademark of Bell Laboratories. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes * Eli Zaretskii [2019-04-18 05:38:11 +0300]: > > Date: Thu, 18 Apr 2019 02:07:26 +0100 > > From: Andrew Burgess > > Cc: gdb-patches@sourceware.org > > > > > "increase ... to increase" sounds awkward and perhaps even confusing. > > > Can we come up with a better wording? > > > > You're right, that doesn't read well, how about simply dropping the > > '...to increase' like this: > > > > > > +To see the contents of structures that have been hidden the user > > +can either increase the print max-depth, or they can print the > > +elements of the structure that are visible, for example > > Fine with me, thanks. Eli, thanks for the feedback. Having taken Philippe's feedback on board too, I have now adjusted how I show the effects of the different depth settings to use a table instead of a set of paragraphs. I just wanted to run this by you to make sure I hadn't made any silly style mistakes. The diff below is only for gdb/doc/gdb.texinfo - this is the only file I've changed over the previous version of the patch. thanks, Andrew diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index f410d026b82..02e90284494 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -10560,6 +10560,64 @@ Display the current threshold for printing repeated identical elements. +@item set print max-depth @var{depth} +@item set print max-depth unlimited +@cindex printing nested structures +Set the threshold after which nested structures are replaced with +ellipsis, this can make visualising deeply nested structures easier. + +For example, given this C code + +@smallexample +typedef struct s1 @{ int a; @} s1; +typedef struct s2 @{ s1 b; @} s2; +typedef struct s3 @{ s2 c; @} s3; +typedef struct s4 @{ s3 d; @} s4; + +s4 var = @{ @{ @{ @{ 3 @} @} @} @}; +@end smallexample + +The following table shows how different values of @var{depth} will +effect how @code{var} is printed by @value{GDBN}: + +@multitable @columnfractions .3 .7 +@headitem @var{depth} setting @tab Result of @samp{p var} +@item unlimited +@tab @code{$1 = @{d = @{c = @{b = @{a = 3@}@}@}@}} +@item @code{0} +@tab @code{$1 = @{...@}} +@item @code{1} +@tab @code{$1 = @{d = @{...@}@}} +@item @code{2} +@tab @code{$1 = @{d = @{c = @{...@}@}@}} +@item @code{3} +@tab @code{$1 = @{d = @{c = @{b = @{...@}@}@}@}} +@item @code{4} +@tab @code{$1 = @{d = @{c = @{b = @{a = 3@}@}@}@}} +@end multitable + +To see the contents of structures that have been hidden the user can +either increase the print max-depth, or they can print the elements of +the structure that are visible, for example + +@smallexample +(gdb) set print max-depth 2 +(gdb) p var +$1 = @{d = @{c = @{...@}@}@} +(gdb) p var.d +$2 = @{c = @{b = @{...@}@}@} +(gdb) p var.d.c +$3 = @{b = @{a = 3@}@} +@end smallexample + +The pattern used to replace nested structures varies based on +language, for most languages @code{@{...@}} is used, but Fortran uses +@code{(...)}. + +@item show print max-depth +Display the current threshold after which nested structures are +replaces with ellipsis. + @item set print null-stop @cindex @sc{null} elements in arrays Cause @value{GDBN} to stop printing the characters of an array when the first