Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Siddhesh Poyarekar <siddhesh@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Eliminate local variables to use TYPE_LENGTH directly
Date: Tue, 25 Sep 2012 08:26:00 -0000	[thread overview]
Message-ID: <20120925082558.GA9305@host2.jankratochvil.net> (raw)
In-Reply-To: <20120924173542.625d322c@spoyarek>

Hi Siddhesh,

On Mon, 24 Sep 2012 14:05:42 +0200, Siddhesh Poyarekar wrote:
[...]
> --- ax-gdb.c	19 Jul 2012 15:38:16 -0000	1.105
> +++ ax-gdb.c	24 Sep 2012 09:16:37 -0000
> @@ -367,9 +367,7 @@
>  	    {
>  	    case axs_lvalue_memory:
>  	      {
> -		int length = TYPE_LENGTH (check_typedef (value.type));
> -
> -		ax_const_l (ax, length);
> +		ax_const_l (ax, TYPE_LENGTH (check_typedef (value.type)));

While correct I find this expression too tricky, check_typedef should be
called rather ahead of some block of code later depending on it.  I would
choose:
		/* Initialize TYPE_LENGTH of it.  */
		check_typedef (value.type);

		ax_const_l (ax, TYPE_LENGTH (value.type));


(You even did so in s390_value_from_register as I see.)


>  		ax_simple (ax, aop_trace);
>  	      }
>  	      break;
> @@ -425,8 +423,6 @@
>  
>        case axs_lvalue_memory:
>  	{
> -	  int length = TYPE_LENGTH (check_typedef (value->type));
> -

Again here, similar to above:
	  /* Initialize TYPE_LENGTH of it.  */
	  check_typedef (value->type);


>  	  if (string_trace)
>  	    ax_simple (ax, aop_dup);
>  
> @@ -435,7 +431,7 @@
>  	     "const8 SIZE trace" is also three bytes, does the same
>  	     thing, and the simplest code which generates that will also
>  	     work correctly for objects with large sizes.  */
> -	  ax_const_l (ax, length);
> +	  ax_const_l (ax, TYPE_LENGTH (check_typedef (value->type)));

and:
	  ax_const_l (ax, TYPE_LENGTH (value->type));


>  	  ax_simple (ax, aop_trace);
>  
>  	  if (string_trace)
[...]
> --- stack.c	19 Jul 2012 15:33:25 -0000	1.256
> +++ stack.c	24 Sep 2012 09:16:42 -0000
[...]
> @@ -373,12 +374,12 @@
>  
>  		  TRY_CATCH (except, RETURN_MASK_ERROR)
>  		    {
> -		      unsigned len_deref;
> +		      struct type *t;

A nitpick but here is already 'type' and now also 't', please rename 't' to
for example 'type_deref'.


>  
>  		      val_deref = coerce_ref (val);
>  		      if (value_lazy (val_deref))
>  			value_fetch_lazy (val_deref);
> -		      len_deref = TYPE_LENGTH (value_type (val_deref));
> +		      t = value_type (val_deref);
>  
>  		      entryval_deref = coerce_ref (entryval);
>  		      if (value_lazy (entryval_deref))
> @@ -389,7 +390,7 @@
>  		      if (val != val_deref
>  			  && value_available_contents_eq (val_deref, 0,
>  							  entryval_deref, 0,
> -							  len_deref))
> +							  TYPE_LENGTH (t)))

It will not fit here then but you can indent the line left just to keep it to
80 columns in such case (the columns will not align):
						      TYPE_LENGTH (type_deref)))


>  			val_equal = 1;
>  		    }
>  
> Index: tracepoint.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/tracepoint.c,v
> retrieving revision 1.266
> diff -u -r1.266 tracepoint.c
> --- tracepoint.c	18 Sep 2012 12:09:26 -0000	1.266
> +++ tracepoint.c	24 Sep 2012 09:16:43 -0000
> @@ -1456,7 +1456,7 @@
>  		}
>  	      else
>  		{
> -		  unsigned long addr, len;
> +		  unsigned long addr;
>  		  struct cleanup *old_chain = NULL;
>  		  struct cleanup *old_chain1 = NULL;
>  
> @@ -1486,8 +1486,9 @@
>  		      /* Safe because we know it's a simple expression.  */
>  		      tempval = evaluate_expression (exp);
>  		      addr = value_address (tempval);
> -		      len = TYPE_LENGTH (check_typedef (exp->elts[1].type));
> -		      add_memrange (collect, memrange_absolute, addr, len);

Maybe add a line here:
	  /* Initialize TYPE_LENGTH of it.  */

> +		      check_typedef (exp->elts[1].type);
> +		      add_memrange (collect, memrange_absolute, addr,
> +				    TYPE_LENGTH (exp->elts[1].type));
>  		      break;
>  
>  		    case OP_VAR_VALUE:
[...]


I see no bugs there, OK for check-in with those few changes.


Thanks,
Jan


  reply	other threads:[~2012-09-25  8:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-24 12:06 Siddhesh Poyarekar
2012-09-25  8:26 ` Jan Kratochvil [this message]
2012-09-25 12:51   ` Siddhesh Poyarekar
2012-09-25 20:28   ` Tom Tromey
2012-09-25 20:37     ` Jan Kratochvil
2012-09-25 20:49       ` Tom Tromey

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=20120925082558.GA9305@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=siddhesh@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