[PATCH 2/2] gdb: Add new inferior_cloned observable

Aktemur, Tankut Baris tankut.baris.aktemur@intel.com
Wed Dec 15 08:55:23 GMT 2021


On Tuesday, December 14, 2021 12:02 PM, Lancelot SIX wrote:
> Add inferior_cloned in gdb::observers.  Callbacks called when this event
> is triggered receive a pointer to the original inferior as well as a
> pointer to the newly created inferior.
> 
> This event is triggered in clone_inferior_command.
> 
> This observable is not yet used in core GDB but is added as an extension
> mechanism so target dependent codes can react to the clone-inferior
> event if necessary.
> 
> Tested on x86_64-linux.
> 
> Change-Id: I4b384fd489cfca56bc63c3e4256992c991d0fbed
> ---
>  gdb/inferior.c   | 4 ++++
>  gdb/observable.c | 1 +
>  gdb/observable.h | 6 ++++++
>  3 files changed, 11 insertions(+)
> 
> diff --git a/gdb/inferior.c b/gdb/inferior.c
> index 8fbc4109178..1b70f1e7a00 100644
> --- a/gdb/inferior.c
> +++ b/gdb/inferior.c
> @@ -948,6 +948,10 @@ clone_inferior_command (const char *args, int from_tty)
>  	}
>        for (auto unset_var : orginf->environment.user_unset_env ())
>  	inf->environment.unset (unset_var.c_str ());
> +
> +      /* Notify that the inferior has been cloned so target dependent logic
> +	 can be applied if necessary.  */
> +      gdb::observers::inferior_cloned.notify (orginf, inf);
>      }
>  }
> 
> diff --git a/gdb/observable.c b/gdb/observable.c
> index fe88b0bf702..740c50613d0 100644
> --- a/gdb/observable.c
> +++ b/gdb/observable.c
> @@ -64,6 +64,7 @@ DEFINE_OBSERVABLE (inferior_added);
>  DEFINE_OBSERVABLE (inferior_appeared);
>  DEFINE_OBSERVABLE (inferior_exit);
>  DEFINE_OBSERVABLE (inferior_removed);
> +DEFINE_OBSERVABLE (inferior_cloned);
>  DEFINE_OBSERVABLE (memory_changed);
>  DEFINE_OBSERVABLE (before_prompt);
>  DEFINE_OBSERVABLE (gdb_datadir_changed);
> diff --git a/gdb/observable.h b/gdb/observable.h
> index d3c441dc764..29a00cfacef 100644
> --- a/gdb/observable.h
> +++ b/gdb/observable.h
> @@ -188,6 +188,12 @@ extern observable<struct inferior */* inf */> inferior_exit;
>     This method is called immediately before freeing INF.  */
>  extern observable<struct inferior */* inf */> inferior_removed;
> 
> +/* The inferior CLONE has been created by cloning INF.
> +   This method is called after all required operations for the clone have
> +   been performed.  */
> +extern observable<struct inferior */* inf */, struct inferior */* clone */>
> +    inferior_cloned;

As far as I can tell, the tendency is to omit the redundant 'struct' keyword in
newly-written code.

Thanks.
-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928



More information about the Gdb-patches mailing list