public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH] Fixing regression in mi -add-inferior command
       [not found] <75b6ba73-d3df-b97c-7c86-792dfd8623a2@hotmail.com>
@ 2022-03-03 19:20 ` Muhammad Umair Sair
  0 siblings, 0 replies; 2+ messages in thread
From: Muhammad Umair Sair @ 2022-03-03 19:20 UTC (permalink / raw)
  To: gdb-patches, aburgess

Hi Andrew,

I just checked the archive and found the new thread related to this 
patch. I hadn't subscribed the list previously, now I have subscribed it.

Thanks for grooming the patch.

Ref: https://sourceware.org/pipermail/gdb-patches/2022-March/186254.html

- Umair

On 2/24/22 10:25 PM, Muhammad Umair Sair wrote:
>  From 6b0edd1364f5ea63416838c3d08631adeed55474 Mon Sep 17 00:00:00 2001
> From: Umair Sair <umair_sair@hotmail.com>
> Date: Tue, 22 Feb 2022 01:40:06 +0500
> Subject: [PATCH] Fixing regression in mi -add-inferior command
> 
> This commit fixes the regression (backward compatibility issue) in 
> -add-inferior mi command after the addition of multi-target debugging 
> support. Previously adding a new inferior via mi or cli uses same 
> connection as other inferiors are using.
> Now after the addition of multi-target support, add-inferior command 
> without arguments in cli adds a new inferior and sets the connection of 
> previously selected inferior as the connection of new inferior as well 
> which keeps the backward compatibility intact. But the same command for 
> machine interpreter is not setting the connection for new inferior and 
> causing backward compatibility issue. This commit fixes the backward 
> compatibility issue and makes the console and machine interpreter 
> behavior consistent for add-inferior command with no arguments.
> ---
>   gdb/inferior.c                           |  2 +-
>   gdb/inferior.h                           |  3 ++
>   gdb/mi/mi-main.c                         |  2 +
>   gdb/testsuite/gdb.mi/mi-add-inferior.exp | 49 ++++++++++++++++++++++++
>   4 files changed, 55 insertions(+), 1 deletion(-)
>   create mode 100644 gdb/testsuite/gdb.mi/mi-add-inferior.exp
> 
> diff --git a/gdb/inferior.c b/gdb/inferior.c
> index bebddb44173..82fd39c142d 100644
> --- a/gdb/inferior.c
> +++ b/gdb/inferior.c
> @@ -761,7 +761,7 @@ add_inferior_with_spaces (void)
>      NO_CONNECTION is true, push the process_stratum_target of ORG_INF
>      to NEW_INF.  */
> 
> -static void
> +void
>   switch_to_inferior_and_push_target (inferior *new_inf,
>                       bool no_connection, inferior *org_inf)
>   {
> diff --git a/gdb/inferior.h b/gdb/inferior.h
> index 45de3c2d9c8..00978bec404 100644
> --- a/gdb/inferior.h
> +++ b/gdb/inferior.h
> @@ -740,4 +740,7 @@ extern struct inferior *add_inferior_with_spaces 
> (void);
>   /* Print the current selected inferior.  */
>   extern void print_selected_inferior (struct ui_out *uiout);
> 
> +extern void switch_to_inferior_and_push_target (inferior *new_inf,
> +            bool no_connection, inferior *org_inf);
> +
>   #endif /* !defined (INFERIOR_H) */
> diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
> index 4860da7536a..3a477bf3d05 100644
> --- a/gdb/mi/mi-main.c
> +++ b/gdb/mi/mi-main.c
> @@ -1710,6 +1710,8 @@ mi_cmd_add_inferior (const char *command, char 
> **argv, int argc)
> 
>     inf = add_inferior_with_spaces ();
> 
> +  switch_to_inferior_and_push_target (inf, false, current_inferior ());
> +
>     current_uiout->field_fmt ("inferior", "i%d", inf->num);
>   }
> 
> diff --git a/gdb/testsuite/gdb.mi/mi-add-inferior.exp 
> b/gdb/testsuite/gdb.mi/mi-add-inferior.exp
> new file mode 100644
> index 00000000000..6f10e9cc2d6
> --- /dev/null
> +++ b/gdb/testsuite/gdb.mi/mi-add-inferior.exp
> @@ -0,0 +1,49 @@
> +# Copyright 2022 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# Test MI -add-inferior
> +
> +load_lib mi-support.exp
> +set MIFLAGS "-i=mi"
> +
> +gdb_exit
> +if [mi_gdb_start] {
> +    continue
> +}
> +
> +standard_testfile basics.c
> +
> +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" 
> executable {debug}] != "" } {
> +     untested "failed to compile"
> +     return -1
> +}
> +
> +mi_gdb_load ${binfile}
> +
> +# Start execution to establish a connection
> +mi_runto_main
> +
> +# Adding new inferior should use the connection of previous inferior
> +# Match following
> +#  -add-inferior
> +#  =thread-group-added,id="i2"
> +#  ~"[New inferior 2]\n"
> +#  ~"Added inferior 2 on connection 1.*"
> +#  ^done,inferior="i2"
> +mi_gdb_test "-add-inferior" 
> "=thread-group-added,id=\"i2\"\r\n~\"\\\[New inferior 
> 2\\\]\\\\n\"\r\n\~\"Added inferior 2 on connection 
> .*\"\r\n\\^done,inferior=\"i2\"" \
> +            "mi add inferior"
> +
> +mi_gdb_exit
> +return 0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] Fixing regression in mi -add-inferior command
@ 2022-02-24 17:25 Muhammad Umair Sair
  0 siblings, 0 replies; 2+ messages in thread
From: Muhammad Umair Sair @ 2022-02-24 17:25 UTC (permalink / raw)
  To: gdb-patches

 From 6b0edd1364f5ea63416838c3d08631adeed55474 Mon Sep 17 00:00:00 2001
From: Umair Sair <umair_sair@hotmail.com>
Date: Tue, 22 Feb 2022 01:40:06 +0500
Subject: [PATCH] Fixing regression in mi -add-inferior command

This commit fixes the regression (backward compatibility issue) in 
-add-inferior mi command after the addition of multi-target debugging 
support. Previously adding a new inferior via mi or cli uses same 
connection as other inferiors are using.
Now after the addition of multi-target support, add-inferior command 
without arguments in cli adds a new inferior and sets the connection of 
previously selected inferior as the connection of new inferior as well 
which keeps the backward compatibility intact. But the same command for 
machine interpreter is not setting the connection for new inferior and 
causing backward compatibility issue. This commit fixes the backward 
compatibility issue and makes the console and machine interpreter 
behavior consistent for add-inferior command with no arguments.
---
  gdb/inferior.c                           |  2 +-
  gdb/inferior.h                           |  3 ++
  gdb/mi/mi-main.c                         |  2 +
  gdb/testsuite/gdb.mi/mi-add-inferior.exp | 49 ++++++++++++++++++++++++
  4 files changed, 55 insertions(+), 1 deletion(-)
  create mode 100644 gdb/testsuite/gdb.mi/mi-add-inferior.exp

diff --git a/gdb/inferior.c b/gdb/inferior.c
index bebddb44173..82fd39c142d 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -761,7 +761,7 @@ add_inferior_with_spaces (void)
     NO_CONNECTION is true, push the process_stratum_target of ORG_INF
     to NEW_INF.  */

-static void
+void
  switch_to_inferior_and_push_target (inferior *new_inf,
  				    bool no_connection, inferior *org_inf)
  {
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 45de3c2d9c8..00978bec404 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -740,4 +740,7 @@ extern struct inferior *add_inferior_with_spaces (void);
  /* Print the current selected inferior.  */
  extern void print_selected_inferior (struct ui_out *uiout);

+extern void switch_to_inferior_and_push_target (inferior *new_inf,
+            bool no_connection, inferior *org_inf);
+
  #endif /* !defined (INFERIOR_H) */
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 4860da7536a..3a477bf3d05 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1710,6 +1710,8 @@ mi_cmd_add_inferior (const char *command, char 
**argv, int argc)

    inf = add_inferior_with_spaces ();

+  switch_to_inferior_and_push_target (inf, false, current_inferior ());
+
    current_uiout->field_fmt ("inferior", "i%d", inf->num);
  }

diff --git a/gdb/testsuite/gdb.mi/mi-add-inferior.exp 
b/gdb/testsuite/gdb.mi/mi-add-inferior.exp
new file mode 100644
index 00000000000..6f10e9cc2d6
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-add-inferior.exp
@@ -0,0 +1,49 @@
+# Copyright 2022 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test MI -add-inferior
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi"
+
+gdb_exit
+if [mi_gdb_start] {
+    continue
+}
+
+standard_testfile basics.c
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" 
executable {debug}] != "" } {
+     untested "failed to compile"
+     return -1
+}
+
+mi_gdb_load ${binfile}
+
+# Start execution to establish a connection
+mi_runto_main
+
+# Adding new inferior should use the connection of previous inferior
+# Match following
+#  -add-inferior
+#  =thread-group-added,id="i2"
+#  ~"[New inferior 2]\n"
+#  ~"Added inferior 2 on connection 1.*"
+#  ^done,inferior="i2"
+mi_gdb_test "-add-inferior" 
"=thread-group-added,id=\"i2\"\r\n~\"\\\[New inferior 
2\\\]\\\\n\"\r\n\~\"Added inferior 2 on connection 
.*\"\r\n\\^done,inferior=\"i2\"" \
+            "mi add inferior"
+
+mi_gdb_exit
+return 0
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-03 19:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <75b6ba73-d3df-b97c-7c86-792dfd8623a2@hotmail.com>
2022-03-03 19:20 ` [PATCH] Fixing regression in mi -add-inferior command Muhammad Umair Sair
2022-02-24 17:25 Muhammad Umair Sair

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).