Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Vladimir Prus <vladimir@codesourcery.com>
Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: [patch 0/4] varobj_list replacement  [Re: [patch 4/8] Types GC 	[varobj_list to all_root_varobjs]]
Date: Fri, 10 Jul 2009 20:17:00 -0000	[thread overview]
Message-ID: <20090710201104.GA7014@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <200907021409.39886.vladimir@codesourcery.com>

On Thu, 02 Jul 2009 12:09:39 +0200, Vladimir Prus wrote:
> Can we just make varobj.c expose vector of varobjs?

In general iterators are preferred over direct variable access in modern
programming.  It makes the implementation free to change the underlying data
structures to always use algorithms with optimal complexity.

Specifically the VEC structure (contiguous array) is not well suited as:
* It cannot effectively insert/remove elements while keeping the original order.
* Iterating such VEC while it is being changed is difficult.
* Current varobj_delete + install_variable API does not report the number of
  successfully deleted/inserted root items to make such iteration safe.

There are at least ways of implementing there the VEC:

VEC_safe_push + VEC_unordered_remove:
+ It is algorithmically optimal complexity.
- It no longer keeps the root variables order - this breaks the testsuite.
  Verified all the FAILs are just an order change having no real regressions.
  I will fix the testsuite if it gets approved this way.
  I believe frontends do not depend on the ordering, I would test
  Eclipse+Nemiver or some others upon recommendation.
- Difficult to keep iterating the VEC being changed
  by varobj_delete + install_variable in the meantime.
  varobj_delete + install_variable API change may be more appropriate.

VEC_safe_insert + VEC_ordered_remove:
+ It keeps the root variables in the current order.
+ It has no testsuite changes / regressions.
- It is ineffective (two memmove calls per varobj_invalidate per rootvar).
- Difficult to keep iterating the VEC being changed
  by varobj_delete + install_variable in the meantime.
  * Guess the index / placement will match one remove + insert
  or
  * Extend the varobj_delete + install_variable API to return the exact number
    of removed and inserted rootvars.

Still I would prefer:

Iterator - so-called "safe" (keeping the next pointer) double link list:
+ It is algorithmically optimal complexity.
+ It keeps the root variables in the current order.
+ It has no testsuite changes / regressions.
+ More simple usage at the caller (no varobj_root_get_var).
+ Separates the interface and implementation parts.
+ Easy iterating the list being changed by varobj_delete + install_variable
  in the meantime.  One just keeps the "next" pointer before calling them.

Regression tested all the 4 patches on {x86_64,i686}-fedora-linux-gnu.


Thanks,
Jan


  parent reply	other threads:[~2009-07-10 20:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-25  8:02 [patch 4/8] Types GC [varobj_list to all_root_varobjs] Jan Kratochvil
2009-06-09 20:50 ` Tom Tromey
2009-07-02  8:39   ` Jan Kratochvil
2009-07-02 10:09     ` Vladimir Prus
2009-07-04 21:11       ` Jan Kratochvil
2009-07-07  8:54         ` Vladimir Prus
2009-07-07  9:32           ` Jan Kratochvil
2009-07-10 20:17       ` Jan Kratochvil [this message]
2009-07-29 21:34         ` [patch 0/4] varobj_list replacement [Re: [patch 4/8] Types GC [varobj_list to all_root_varobjs]] Tom Tromey
2009-07-30  8:46           ` Vladimir Prus
2009-07-30 14:00             ` Jan Kratochvil
2009-07-30 15:13               ` Vladimir Prus
2009-07-30 15:16                 ` Jan Kratochvil
2009-07-10 20:18       ` [patch 1/4] varobj_list replacement, choice 1 of 3: VEC_safe_push + VEC_unordered_remove Jan Kratochvil
2009-07-10 20:21       ` [patch 2/4] varobj_list replacement, choice 2 of 3: VEC_safe_insert + VEC_ordered_remove Jan Kratochvil
2009-07-10 21:11       ` [patch 3/4] varobj_list replacement, choice 3 of 3: Iterator Jan Kratochvil
2009-07-10 22:12       ` [patch 4/4] varobj_list replacement, choice 3 of 3: Iterator optimization Jan Kratochvil

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=20090710201104.GA7014@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    --cc=vladimir@codesourcery.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