Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
To: Simon Marchi <simon.marchi@efficios.com>,
	"gdb-patches@sourceware.org"	<gdb-patches@sourceware.org>
Subject: RE: [PATCH 2/4] gdb: remove use of iterate_over_inferiors in mi/mi-interp.c
Date: Thu, 16 Jan 2020 11:29:00 -0000	[thread overview]
Message-ID: <BYAPR11MB303040C052014A5EFB2F87A1C4360@BYAPR11MB3030.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200115191222.28208-3-simon.marchi@efficios.com>

On Wednesday, January 15, 2020 8:12 PM, Simon Marchi wrote:
> Replace it with a range-based for.  I figured that in the hypothetical case
> where there are multiple inferiors, we only need to configure the terminal and
> flush the output once, so I have moved these out of the loop.
> 
> gdb/ChangeLog:
> 
> 	* mi/mi-interp.c (report_initial_inferior): Remove.
> 	(mi_interp::init): Use range-based for to iterate over inferiors.
> ---
>  gdb/mi/mi-interp.c | 40 ++++++++++++++++------------------------
>  1 file changed, 16 insertions(+), 24 deletions(-)
> 
> diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
> index 2ac4c119961c..6f4f56849611 100644
> --- a/gdb/mi/mi-interp.c
> +++ b/gdb/mi/mi-interp.c
> @@ -91,8 +91,6 @@ static void mi_memory_changed (struct inferior *inf, CORE_ADDR memaddr,
>  			       ssize_t len, const bfd_byte *myaddr);
>  static void mi_on_sync_execution_done (void);
> 
> -static int report_initial_inferior (struct inferior *inf, void *closure);
> -
>  /* Display the MI prompt.  */
> 
>  static void
> @@ -140,8 +138,22 @@ mi_interp::init (bool top_level)
>        /* The initial inferior is created before this function is
>  	 called, so we need to report it explicitly.  Use iteration in
>  	 case future version of GDB creates more than one inferior
> -	 up-front.  */
> -      iterate_over_inferiors (report_initial_inferior, mi);
> +	 up-front.
> +
> +         This function is called from mi_interpreter_init, and since

There is an 8-spaces/tab issue above.  And also, the comment piece "This
function is called from mi_interpreter_init, and" seems obsolete now.

Thanks,
-Baris

> +	 mi_inferior_added assumes that inferior is fully initialized
> +	 and top_level_interpreter_data is set, we cannot call
> +	 it here.  */
> +
> +      target_terminal::scoped_restore_terminal_state term_state;
> +      target_terminal::ours_for_output ();
> +
> +      for (inferior *inf : all_inferiors ())
> +	fprintf_unfiltered (mi->event_channel,
> +			    "thread-group-added,id=\"i%d\"",
> +			    inf->num);
> +
> +      gdb_flush (mi->event_channel);
>      }
>  }
> 
> @@ -1253,26 +1265,6 @@ mi_user_selected_context_changed (user_selected_what selection)
>      }
>  }
> 
> -static int
> -report_initial_inferior (struct inferior *inf, void *closure)
> -{
> -  /* This function is called from mi_interpreter_init, and since
> -     mi_inferior_added assumes that inferior is fully initialized
> -     and top_level_interpreter_data is set, we cannot call
> -     it here.  */
> -  struct mi_interp *mi = (struct mi_interp *) closure;
> -
> -  target_terminal::scoped_restore_terminal_state term_state;
> -  target_terminal::ours_for_output ();
> -
> -  fprintf_unfiltered (mi->event_channel,
> -		      "thread-group-added,id=\"i%d\"",
> -		      inf->num);
> -  gdb_flush (mi->event_channel);
> -
> -  return 0;
> -}
> -
>  ui_out *
>  mi_interp::interp_ui_out ()
>  {
> --
> 2.25.0

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

  reply	other threads:[~2020-01-16  9:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15 19:12 [PATCH 0/4] Remove some uses of iterate_over_inferiors Simon Marchi
2020-01-15 19:12 ` [PATCH 4/4] gdb: remove uses of iterate_over_inferiors in top.c Simon Marchi
2020-01-15 19:12 ` [PATCH 2/4] gdb: remove use of iterate_over_inferiors in mi/mi-interp.c Simon Marchi
2020-01-16 11:29   ` Aktemur, Tankut Baris [this message]
2020-01-16 15:31     ` Simon Marchi
2020-01-17  7:52       ` Aktemur, Tankut Baris
2020-01-17 15:14         ` Simon Marchi
2020-01-15 19:18 ` [PATCH 1/4] gdb: remove use of iterate_over_inferiors in py-inferior.c Simon Marchi
2020-01-15 19:50 ` [PATCH 3/4] gdb: remove uses of iterate_over_inferiors in mi/mi-main.c Simon Marchi
2020-01-16 16:23 ` [PATCH 0/4] Remove some uses of iterate_over_inferiors Tom Tromey
2020-01-16 22:46   ` Simon Marchi

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=BYAPR11MB303040C052014A5EFB2F87A1C4360@BYAPR11MB3030.namprd11.prod.outlook.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.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