[0/4] Remove some uses of iterate_over_inferiors

Message ID 20200115191222.28208-1-simon.marchi@efficios.com
Headers show
Series
  • Remove some uses of iterate_over_inferiors
Related show

Message

Simon Marchi Jan. 15, 2020, 7:12 p.m.
Today, it's very easy to iterate over inferiors using a range-based for
loop combined with all_inferiors.  I think it gives simpler and easier
to understand code than iterate_over_inferiors, which uses a void
pointer to pass data from the caller.  I noticed that there were very
few uses of iterate_over_inferiors left, so I think we could convert
them to range-based for loop and get rid of it.

This patch series removes the uses that are in the files I can build
easily, I can take care of the rest later.

Simon Marchi (4):
  gdb: remove use of iterate_over_inferiors in py-inferior.c
  gdb: remove use of iterate_over_inferiors in mi/mi-interp.c
  gdb: remove uses of iterate_over_inferiors in mi/mi-main.c
  gdb: remove uses of iterate_over_inferiors in top.c

 gdb/mi/mi-interp.c       | 40 +++++++++-------------
 gdb/mi/mi-main.c         | 73 +++++++++++++++-------------------------
 gdb/python/py-inferior.c | 24 ++++++-------
 gdb/top.c                | 51 +++++++++++-----------------
 4 files changed, 72 insertions(+), 116 deletions(-)

-- 
2.25.0

Comments

Tom Tromey Jan. 16, 2020, 3:48 p.m. | #1
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:


Simon> Today, it's very easy to iterate over inferiors using a range-based for
Simon> loop combined with all_inferiors.  I think it gives simpler and easier
Simon> to understand code than iterate_over_inferiors, which uses a void
Simon> pointer to pass data from the caller.  I noticed that there were very
Simon> few uses of iterate_over_inferiors left, so I think we could convert
Simon> them to range-based for loop and get rid of it.

I sent some patches like this a while back, but never got around to
finishing the series, so I never checked them in.

https://sourceware.org/ml/gdb-patches/2019-09/msg00381.html

These all look fine to me and I think you should push them.

You wrote one patch I didn't (and I think you did more in mi-main.c
too?), and I wrote one you didn't; I'll resurrect that one and push it
once yours are in:

https://sourceware.org/ml/gdb-patches/2019-09/msg00383.html

Tom
Simon Marchi Jan. 16, 2020, 10:31 p.m. | #2
On 2020-01-16 10:48 a.m., Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:

> 

> Simon> Today, it's very easy to iterate over inferiors using a range-based for

> Simon> loop combined with all_inferiors.  I think it gives simpler and easier

> Simon> to understand code than iterate_over_inferiors, which uses a void

> Simon> pointer to pass data from the caller.  I noticed that there were very

> Simon> few uses of iterate_over_inferiors left, so I think we could convert

> Simon> them to range-based for loop and get rid of it.

> 

> I sent some patches like this a while back, but never got around to

> finishing the series, so I never checked them in.

> 

> https://sourceware.org/ml/gdb-patches/2019-09/msg00381.html

> 

> These all look fine to me and I think you should push them.

> 

> You wrote one patch I didn't (and I think you did more in mi-main.c

> too?), and I wrote one you didn't; I'll resurrect that one and push it

> once yours are in:

> 

> https://sourceware.org/ml/gdb-patches/2019-09/msg00383.html

> 

> Tom

> 


Wow, I had completely forgotten about it!

Your patch for target.c is no longer needed, that call has been removed by
Pedro's multi-target patch.

I can merge my series.  I'll just wait for a response from Baris on my
new version of patch #2.

Simon