public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Alan Hayward <Alan.Hayward@arm.com>
Cc: Pedro Alves <palves@redhat.com>,
	 Joel Brobecker <brobecker@adacore.com>,
	 "gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>,
Subject: Re: [PATCH] Removal of uses of MAX_REGISTER_SIZE
Date: Wed, 08 Feb 2017 12:24:00 -0000	[thread overview]
Message-ID: <86inokq39w.fsf@gmail.com> (raw)
In-Reply-To: <5F3D30AE-9A53-493A-B6DC-DF594C2FAB18@arm.com> (Alan Hayward's	message of "Tue, 7 Feb 2017 16:33:19 +0000")

Alan Hayward <Alan.Hayward@arm.com> writes:

> diff --git a/gdb/stack.c b/gdb/stack.c
> index e00e2972cf20bc63917af19f86bf57f1c6b0b5b0..7ba7d68bde8d83ea1e700faa466c6951979e0f76 100644
> --- a/gdb/stack.c
> +++ b/gdb/stack.c
> @@ -1650,33 +1650,35 @@ frame_info (char *addr_exp, int from_tty)
>      int count;
>      int i;
>      int need_nl = 1;
> +    int sp_regnum = gdbarch_sp_regnum (gdbarch);
>
>      /* The sp is special; what's displayed isn't the save address, but
>         the value of the previous frame's sp.  This is a legacy thing,
>         at one stage the frame cached the previous frame's SP instead
>         of its address, hence it was easiest to just display the cached
>         value.  */
> -    if (gdbarch_sp_regnum (gdbarch) >= 0)
> +    if (sp_regnum >= 0)
>        {
>  	/* Find out the location of the saved stack pointer with out
>             actually evaluating it.  */
> -	frame_register_unwind (fi, gdbarch_sp_regnum (gdbarch),
> -			       &optimized, &unavailable, &lval, &addr,
> -			       &realnum, NULL);
> +	frame_register_unwind (fi, sp_regnum, &optimized, &unavailable, &lval,
> +			       &addr, &realnum, NULL);
>  	if (!optimized && !unavailable && lval == not_lval)
>  	  {
>  	    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> -	    int sp_size = register_size (gdbarch, gdbarch_sp_regnum (gdbarch));
> -	    gdb_byte value[MAX_REGISTER_SIZE];
> +	    int sp_size = register_size (gdbarch, sp_regnum);
>  	    CORE_ADDR sp;
> +	    struct value *value = frame_unwind_register_value (fi, sp_regnum);
>
> -	    frame_register_unwind (fi, gdbarch_sp_regnum (gdbarch),
> -				   &optimized, &unavailable, &lval, &addr,
> -				   &realnum, value);
> +	    gdb_assert (value != NULL);

Why don't you hoist frame_unwind_register_value above?, so the
frame_register_unwind call is no longer needed,


  struct value *value = frame_unwind_register_value (fi, sp_regnum);

  gdb_assert (value != NULL);

  if (!value_optimized_out (value) && value_entirely_available (value))
     {
       if (VALUE_LVAL (value) == not_lval)
         {
            sp = extract_unsigned_integer (value_contents_all (value),
                                          sp_size, byte_order);
         }
       else if (VALUE_LVAL (value) == lval_memory)
         {
            // use value_address (value);
         }
       else if (VALUE_LVAL (value) == lval_register)
         {
            // use VALUE_REGNUM (value);
         }
     }
   /* else keep quiet.  */

   release_value (value);
   value_free (value);

>  	    /* NOTE: cagney/2003-05-22: This is assuming that the
>                 stack pointer was packed as an unsigned integer.  That
>                 may or may not be valid.  */
> -	    sp = extract_unsigned_integer (value, sp_size, byte_order);
> +	    sp = extract_unsigned_integer (value_contents_all (value), sp_size,
> +					   byte_order);
> +	    release_value (value);
> +	    value_free (value);
> +
>  	    printf_filtered (" Previous frame's sp is ");
>  	    fputs_filtered (paddress (gdbarch, sp), gdb_stdout);
>  	    printf_filtered ("\n");
> @@ -1702,7 +1704,7 @@ frame_info (char *addr_exp, int from_tty)
>      numregs = gdbarch_num_regs (gdbarch)
>  	      + gdbarch_num_pseudo_regs (gdbarch);
>      for (i = 0; i < numregs; i++)
> -      if (i != gdbarch_sp_regnum (gdbarch)
> +      if (i != sp_regnum
>  	  && gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
>  	{
>  	  /* Find out the location of the saved register without

-- 
Yao (齐尧)

  parent reply	other threads:[~2017-02-08 12:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-24 10:31 Alan Hayward
2017-01-27 11:49 ` Pedro Alves
2017-01-27 12:11 ` Pedro Alves
2017-01-27 16:46   ` Alan Hayward
2017-02-01 15:49     ` Pedro Alves
2017-02-01 12:45   ` Yao Qi
2017-02-01 15:48     ` Pedro Alves
2017-02-02  9:40       ` Joel Brobecker
2017-02-03  9:59         ` Alan Hayward
2017-02-03 10:28           ` Yao Qi
2017-02-03 11:00             ` Pedro Alves
2017-02-03 11:25               ` Alan Hayward
2017-02-03 16:50                 ` Yao Qi
2017-02-06  9:33                   ` Alan Hayward
     [not found]                     ` <20170206152635.GE11916@E107787-LIN>
2017-02-07 16:33                       ` Alan Hayward
2017-02-08 10:47                         ` Yao Qi
2017-02-08 14:17                           ` Alan Hayward
2017-02-08 12:06                         ` Yao Qi
2017-02-08 12:24                         ` Yao Qi [this message]
2017-02-08 14:44                           ` Alan Hayward
2017-02-18 23:19                             ` Yao Qi
2017-02-20 11:19                               ` Alan Hayward
2017-02-08 15:32                         ` Yao Qi
2017-02-08 17:10                         ` Yao Qi
2017-02-09 13:26                           ` Alan Hayward
2017-02-14 11:24                           ` Alan Hayward
2017-02-08 17:36                         ` Yao Qi
2017-02-13 11:59                           ` Alan Hayward

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=86inokq39w.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=Alan.Hayward@arm.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).