Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
To: Andrew Burgess <andrew.burgess@embecosm.com>, gdb-patches@sourceware.org
Subject: Re: [PATCHv4] gdb: Change how frames are selected for 'frame' and 'info frame'.
Date: Mon, 23 Jul 2018 20:46:00 -0000	[thread overview]
Message-ID: <1532378755.1467.1.camel@skynet.be> (raw)
In-Reply-To: <20180717155751.30898-1-andrew.burgess@embecosm.com>

On Tue, 2018-07-17 at 16:57 +0100, Andrew Burgess wrote:
> Now that the 'frame apply' command has been merged to master, this is
> a rebase of the v3 patch.  Merge conflicts have been resolved, but the
> content is largely unchanged.
FWIW, I like the idea of the patch, as it is too easy to
(too silently) get a wrong frame with 'frame <a wrong frame level/number>'.

Find below some comments to discuss the terminology 'frame level'
versus 'frame number'.

Philippe

> 
> Thanks,
> Andrew
> 
> ---
> 
> The 'frame' command, and thanks to code reuse the 'info frame' and
> 'select-frame' commands, currently have an overloaded mechanism for
> selecting a frame.
> 
> These commands take one or two parameters, if it's one parameter then
> we first try to use the parameter as an integer to select a frame by
> level (or depth in the stack).  If that fails then we treat the
> parameter as an address and try to select a stack frame by
> stack-address.  If we still have not selected a stack frame, or we
> initially had two parameters, then GDB allows the user to view a stack
> frame that is not part of the current backtrace.  Internally, a new
> frame is created with the given stack and pc addresses, and this is
> shown to the user.
> 
> The result of this is that a typo by the user, entering the wrong stack
> frame level for example, can result in a brand new frame being viewed
> rather than an error.
> 
> The purpose of this commit is to remove this overloading, while still
> offering the same functionality through some new sub-commands.  By
> making the default behaviour of 'frame' (and friends) be to select a
> stack frame by level number, it is hoped that enough
> backwards-compatibility is maintained that users will not be overly
> inconvenienced.
> 
> The 'frame', 'select-frame', and 'info frame' commands now all take a
> frame specification string as an argument, this string can be any of the
> following:
> 
>   (1) An integer.  This is treated as a frame number.  If a frame for
>   that number does not exist then the user gets an error.
> 
>   (2) A string like 'level <NUMBER>', where <NUMBER> is a frame number
>   as in option (1) above.

I did a trial to scan the documentation for the usage of 'frame number',
in order to replace it by 'frame level'.
Note that Eli has some reserve about this idea/replacement,
see thread https://sourceware.org/ml/gdb-patches/2018-07/msg00365.html.

IMO, the sentences (1) and (2) above should preferably
use consistently 'frame level' 'level <LEVEL>' : at the moment,
we seem to semi-randomly use level or number, explaining at some places
that level is a frame number. 

It would be good to clarify exactly what naming convention should
be used, and apply it (more) systematically (in the existing
documentation and/or in this patch).



>   (3) A string like 'address <ADDRESS>', where <ADDRESS> is a
>   stack-frame address.  If there is no frame for this address then the
>   user gets an error.
Below, (5) and (6) are using STACK-ADDRESS instead of ADDRESS.
I am not sure to understand if there is (or not) a difference of concept
between this ADDRESS and the below STACK-ADDRESS.
I am wondering which address we are speaking about.
When doing 'info frame', I get something like:
  (gdb) info frame
  Stack level 1, frame at 0x7fffffffdf80:
   rip = 0x555555554f5e in sleeper_or_burner (sleepers.c:86); saved rip = 0x55555555549d
   called by frame at 0x7fffffffe040, caller of frame at 0x7fffffffdf40
   source language c.
   Arglist at 0x7fffffffdf70, args: v=0x7fffffffdf90
   Locals at 0x7fffffffdf70, Previous frame's sp is 0x7fffffffdf80
   Saved registers:
    rbp at 0x7fffffffdf70, rip at 0x7fffffffdf78
  (gdb) 
Maybe it would be good to reference in the doc the field given
in the above output ?


Note that the above command output uses 'Stack level 1',
and not 'Stack number 1' :).


> 
>   (4) A string like 'function <NAME>', where <NAME> is a function name,
>   the inner most frame for function <NAME> is selected.  If there is no
>   frame for function <NAME> then the user gets an error.
> 
>   (5) A string like 'view <STACK-ADDRESS>', this views a new frame
>   with stack address <STACK-ADDRESS>.
> 
>   (6) A string like 'view <STACK-ADDRESS> <PC-ADDRESS>', this views
>   a new frame with stack address <STACK-ADDRESS> an the pc <PC-ADDRESS>.
> 
> This change assumes that the most common use of the commands like
> 'frame' is to select a frame by frame level number, it is for this
> reason that this is the behaviour that is kept for backwards
> compatibility.  Any of the alternative behaviours, which are assumed to
> be less used, now require a change in user behaviour.
> 
> The MI command '-stack-select-frame' has also changed in the same way.
> The default behaviour is to select a frame by level number, but the
> other selection methods are also available.

In the rest of the patch, assuming there is an agreement about
using frame level instead of frame number, there are some other
occurrences of number to replace/clarify.

Philippe


  reply	other threads:[~2018-07-23 20:46 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-08 16:58 [PATCHv2 0/2] Changes to frame selection Andrew Burgess
2018-05-08 16:58 ` [PATCHv2 1/2] gdb: Split func_command into two parts Andrew Burgess
2018-05-18 19:57   ` Pedro Alves
2018-05-21 15:52     ` Andrew Burgess
2018-05-21 16:06       ` Pedro Alves
2018-05-08 16:59 ` [PATCHv2 2/2] gdb: Change how frames are selected for 'frame' and 'info frame' Andrew Burgess
2018-05-11 15:44   ` Eli Zaretskii
2018-05-21 12:16     ` Andrew Burgess
2018-05-21 17:46       ` Eli Zaretskii
2018-06-05 18:53         ` Andrew Burgess
2018-06-05 21:16           ` Philippe Waroquiers
     [not found]             ` <20180606082211.GF15881@embecosm.com>
2018-06-06 14:56               ` Eli Zaretskii
2018-06-07 16:19   ` [PATCHv3] " Andrew Burgess
2018-06-29 12:23     ` Andrew Burgess
2018-07-17 15:58     ` [PATCHv4] " Andrew Burgess
2018-07-23 20:46       ` Philippe Waroquiers [this message]
2018-07-25 18:14         ` Andrew Burgess
2018-08-13 22:20           ` [PATCHv5 0/2] " Andrew Burgess
2018-08-14 10:31             ` Philippe Waroquiers
2018-08-21 13:10               ` Joel Brobecker
2018-08-27 11:04             ` Andrew Burgess
2018-08-27 15:23               ` Eli Zaretskii
2018-08-28  8:43                 ` Andrew Burgess
2018-08-28  9:08                   ` Eli Zaretskii
2018-08-28 18:03                     ` [PATCHv6] " Andrew Burgess
2018-08-28 18:20                       ` Eli Zaretskii
2018-09-05  7:46                       ` PING: " Andrew Burgess
2018-09-13 18:02                       ` Pedro Alves
2018-09-18 23:01                         ` Andrew Burgess
2018-09-19 16:26                           ` Pedro Alves
2018-09-26 23:06                             ` Andrew Burgess
2018-09-27 20:58                               ` Pedro Alves
     [not found]           ` <cover.1534197765.git.andrew.burgess@embecosm.com>
2018-08-13 22:20             ` [PATCHv5_B 2/2] " Andrew Burgess
2018-08-13 22:20           ` [PATCHv5_A 1/2] " Andrew Burgess

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=1532378755.1467.1.camel@skynet.be \
    --to=philippe.waroquiers@skynet.be \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /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