Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [unavailable values part 1, 06/17] array element repeats, <unavailable> confused with 0.
Date: Wed, 16 Feb 2011 10:23:00 -0000	[thread overview]
Message-ID: <201102161015.19382.pedro@codesourcery.com> (raw)
In-Reply-To: <20110216092850.GA5399@host1.dyn.jankratochvil.net>

On Wednesday 16 February 2011 09:28:50, Jan Kratochvil wrote:
> On Tue, 15 Feb 2011 19:28:35 +0100, Pedro Alves wrote:
> > Indeed.  Could you double-check the patch below?
> 
> It seems correct to me now.

Thanks for checking!  I've applied the patch now.

> > -      if (memcmp (val1->contents + org_offset1 + prev_avail,
> > -		  val2->contents + org_offset2 + prev_avail,
> > -		  l2 - prev_avail) != 0)
> > +      if (memcmp (val1->contents + offset1, val2->contents + offset2, l1) != 0)
> 
> [nitpick] GNU Coding standards says 78 columns (this is 79), 

Hmm, it does?  Can you point it out, please?  I'm not finding it.

I usually follow the "whatever emacs does/wants is what the
coding standards say" pseudo-rule.

> OTOH Joel said he already uses 80.  
> http://sourceware.org/ml/gdb-patches/2011-01/msg00255.html

I'm also using 80, except on comments, docs and changelogs, where
I just do M-q (fill-paragraph) and let emacs decide automatically.
And I tend to flip whitespace-mode on often to easily check/see
exceeding lines and spurious whitespace:

 <http://www.emacswiki.org/emacs/WhiteSpace>

Which I clearly remember doing to check that line wasn't
exceeding.  :-)

Anyway, I just went ahead and wrapped the line before
committing.

OOC, I found this emacs wiki page:

 <http://www.emacswiki.org/emacs/EightyColumnRule>

-- 
Pedro Alves

2011-02-16  Pedro Alves  <pedro@codesourcery.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	gdb/
	* value.c (value_available_contents_eq): Remove redundant local
	variables.  Fix available contents comparision.
	* value.h (value_available_contents_eq): Extend describing
	comment.

---
 gdb/value.c |   21 ++++++---------------
 gdb/value.h |   21 +++++++++++++++------
 2 files changed, 21 insertions(+), 21 deletions(-)

Index: src/gdb/value.c
===================================================================
--- src.orig/gdb/value.c	2011-02-15 16:19:15.000000000 +0000
+++ src/gdb/value.c	2011-02-16 09:52:24.906002009 +0000
@@ -533,21 +533,13 @@ value_available_contents_eq (const struc
 			     const struct value *val2, int offset2,
 			     int length)
 {
-  int org_len = length;
-  int org_offset1 = offset1;
-  int org_offset2 = offset2;
   int idx1 = 0, idx2 = 0;
-  int prev_avail;
 
   /* This routine is used by printing routines, where we should
      already have read the value.  Note that we only know whether a
      value chunk is available if we've tried to read it.  */
   gdb_assert (!val1->lazy && !val2->lazy);
 
-  /* The offset from either ORG_OFFSET1 or ORG_OFFSET2 where the
-     available contents we haven't compared yet start.  */
-  prev_avail = 0;
-
   while (length > 0)
     {
       range_s *r1, *r2;
@@ -561,9 +553,9 @@ value_available_contents_eq (const struc
 
       /* The usual case is for both values to be completely available.  */
       if (idx1 == -1 && idx2 == -1)
-	return (memcmp (val1->contents + org_offset1 + prev_avail,
-			val2->contents + org_offset2 + prev_avail,
-			org_len - prev_avail) == 0);
+	return (memcmp (val1->contents + offset1,
+			val2->contents + offset2,
+			length) == 0);
       /* The contents only match equal if the available set matches as
 	 well.  */
       else if (idx1 == -1 || idx2 == -1)
@@ -596,12 +588,11 @@ value_available_contents_eq (const struc
 	return 0;
 
       /* Compare the _available_ contents.  */
-      if (memcmp (val1->contents + org_offset1 + prev_avail,
-		  val2->contents + org_offset2 + prev_avail,
-		  l2 - prev_avail) != 0)
+      if (memcmp (val1->contents + offset1,
+		  val2->contents + offset2,
+		  l1) != 0)
 	return 0;
 
-      prev_avail += h1;
       length -= h1;
       offset1 += h1;
       offset2 += h1;
Index: src/gdb/value.h
===================================================================
--- src.orig/gdb/value.h	2011-02-14 21:51:17.000000000 +0000
+++ src/gdb/value.h	2011-02-15 18:11:23.938123001 +0000
@@ -379,12 +379,21 @@ extern void mark_value_bytes_unavailable
 					  int offset, int length);
 
 /* Compare LENGTH bytes of VAL1's contents starting at OFFSET1 with
-   LENGTH bytes of VAL2's contents starting at OFFSET2.  Returns true
-   iff the set of available contents match.  Unavailable contents
-   compare equal with unavailable contents, and different with any
-   available byte.  For example, if 'x's represent an unavailable
-   byte, and 'V' and 'Z' represent different available bytes, in a
-   value with length 16:
+   LENGTH bytes of VAL2's contents starting at OFFSET2.
+
+   Note that "contents" refers to the whole value's contents
+   (value_contents_all), without any embedded offset adjustment.  For
+   example, to compare a complete object value with itself, including
+   its enclosing type chunk, you'd do:
+
+     int len = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
+     value_available_contents (val, 0, val, 0, len);
+
+   Returns true iff the set of available contents match.  Unavailable
+   contents compare equal with unavailable contents, and different
+   with any available byte.  For example, if 'x's represent an
+   unavailable byte, and 'V' and 'Z' represent different available
+   bytes, in a value with length 16:
 
    offset:   0   4   8   12  16
    contents: xxxxVVVVxxxxVVZZ


  reply	other threads:[~2011-02-16 10:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-07 14:31 Pedro Alves
2011-02-14 12:00 ` Jan Kratochvil
2011-02-15 18:34   ` Pedro Alves
2011-02-16  9:49     ` Jan Kratochvil
2011-02-16 10:23       ` Pedro Alves [this message]
2011-02-16 11:12         ` Jan Kratochvil
2011-02-16 18:26           ` Michael Snyder
2011-02-16 19:46             ` Eli Zaretskii
2011-02-16 19:55               ` Michael Snyder

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=201102161015.19382.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@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